mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
Added g_string_insert[_c]() and g_string_erase().
Sun Mar 1 19:04:40 1998 Owen Taylor <owt1@cornell.edu> * glib.h gstring.c: Added g_string_insert[_c]() and g_string_erase(). From: Stefan Wille <1wille@vsys1.informatik.uni-hamburg.de>
This commit is contained in:
parent
d1f5f06082
commit
80fd0a0c00
@ -1,3 +1,10 @@
|
|||||||
|
Sun Mar 1 19:04:40 1998 Owen Taylor <owt1@cornell.edu>
|
||||||
|
|
||||||
|
* glib.h gstring.c: Added g_string_insert[_c]()
|
||||||
|
and g_string_erase().
|
||||||
|
|
||||||
|
From: Stefan Wille <1wille@vsys1.informatik.uni-hamburg.de>
|
||||||
|
|
||||||
Mon Feb 16 23:05:06 1998 Owen Taylor <owt1@cornell.edu>
|
Mon Feb 16 23:05:06 1998 Owen Taylor <owt1@cornell.edu>
|
||||||
|
|
||||||
* glist.c (g_list_insert_sorted): Changed function
|
* glist.c (g_list_insert_sorted): Changed function
|
||||||
|
@ -715,6 +715,15 @@ GString* g_string_prepend (GString *string,
|
|||||||
gchar *val);
|
gchar *val);
|
||||||
GString* g_string_prepend_c (GString *string,
|
GString* g_string_prepend_c (GString *string,
|
||||||
gchar c);
|
gchar c);
|
||||||
|
GString* g_string_insert (GString *fstring,
|
||||||
|
gint pos,
|
||||||
|
gchar *val);
|
||||||
|
GString* g_string_insert_c (GString *fstring,
|
||||||
|
gint pos,
|
||||||
|
gchar c);
|
||||||
|
GString* g_string_erase (GString *fstring,
|
||||||
|
gint pos,
|
||||||
|
gint len);
|
||||||
void g_string_sprintf (GString *string,
|
void g_string_sprintf (GString *string,
|
||||||
gchar *fmt,
|
gchar *fmt,
|
||||||
...);
|
...);
|
||||||
|
@ -314,6 +314,64 @@ g_string_prepend_c (GString *fstring, char c)
|
|||||||
return fstring;
|
return fstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GString *
|
||||||
|
g_string_insert (GString *fstring, gint pos, gchar *val)
|
||||||
|
{
|
||||||
|
GRealString *string = (GRealString*)fstring;
|
||||||
|
gint len = strlen (val);
|
||||||
|
|
||||||
|
g_return_val_if_fail (pos <= string->len, fstring);
|
||||||
|
|
||||||
|
g_string_maybe_expand (string, len);
|
||||||
|
|
||||||
|
g_memmove (string->str + pos + len, string->str + pos, string->len);
|
||||||
|
|
||||||
|
strncpy (string->str + pos, val, len);
|
||||||
|
|
||||||
|
string->len += len;
|
||||||
|
|
||||||
|
string->str[string->len] = 0;
|
||||||
|
|
||||||
|
return fstring;
|
||||||
|
}
|
||||||
|
|
||||||
|
GString *
|
||||||
|
g_string_insert_c (GString *fstring, gint pos, gchar c)
|
||||||
|
{
|
||||||
|
GRealString *string = (GRealString*)fstring;
|
||||||
|
|
||||||
|
g_return_val_if_fail (pos <= string->len, fstring);
|
||||||
|
|
||||||
|
g_string_maybe_expand (string, 1);
|
||||||
|
|
||||||
|
g_memmove (string->str + pos + 1, string->str + pos, string->len);
|
||||||
|
|
||||||
|
string->str[pos] = c;
|
||||||
|
|
||||||
|
string->len += 1;
|
||||||
|
|
||||||
|
string->str[string->len] = 0;
|
||||||
|
|
||||||
|
return fstring;
|
||||||
|
}
|
||||||
|
|
||||||
|
GString *
|
||||||
|
g_string_erase (GString *fstring, gint pos, gint len)
|
||||||
|
{
|
||||||
|
GRealString *string = (GRealString*)fstring;
|
||||||
|
|
||||||
|
g_return_val_if_fail (pos <= string->len, fstring);
|
||||||
|
g_return_val_if_fail (pos + len <= string->len, fstring);
|
||||||
|
|
||||||
|
g_memmove (string->str + pos, string->str + pos + len, string->len - (pos + len));
|
||||||
|
|
||||||
|
string->len -= len;
|
||||||
|
|
||||||
|
string->str[string->len] = 0;
|
||||||
|
|
||||||
|
return fstring;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_length_upper_bound (const gchar* fmt, va_list *args)
|
get_length_upper_bound (const gchar* fmt, va_list *args)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user