Commit 80fd0a0c authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor
Browse files

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>
parent d1f5f060
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>
* glist.c (g_list_insert_sorted): Changed function
......
......@@ -715,6 +715,15 @@ GString* g_string_prepend (GString *string,
gchar *val);
GString* g_string_prepend_c (GString *string,
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,
gchar *fmt,
...);
......
......@@ -314,6 +314,64 @@ g_string_prepend_c (GString *fstring, char c)
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
get_length_upper_bound (const gchar* fmt, va_list *args)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment