glib.h gstrfuncs.c Rename g_strccpy to g_strcompress and g_strecpy to

* glib.h
	* gstrfuncs.c
	* tests/strfunc-test.c: Rename g_strccpy to g_strcompress and
	g_strecpy to g_strescape per Tim Janik's suggestion. Dropped the
	destination parameter, always g_malloc a new string.  Fix bug in
	g_strcompress, octal digits were gobbled up without limit, should
	use max three.

	Sources that use g_strescape must have ifdefs to be compilable
	both with GLib 1.2 and 1.3.
This commit is contained in:
Tor Lillqvist
1999-08-02 23:16:32 +00:00
parent 4877766d0e
commit 1c6c7f7489
16 changed files with 167 additions and 61 deletions

View File

@@ -99,15 +99,14 @@ main (int argc,
g_assert (strcmp(string, "00021 test ") == 0);
g_free (string);
g_assert (strcmp(g_strccpy(g_malloc(100),
"abc\\\\\\\"\\b\\f\\n\\r\\t\\003\\177\\234\\313"),
"abc\\\"\b\f\n\r\t\003\177\234\313") == 0);
g_assert (strcmp(g_strecpy(g_malloc(100),
"abc\\\"\b\f\n\r\t\003\177\234\313",
NULL),
g_assert (strcmp
(g_strcompress("abc\\\\\\\"\\b\\f\\n\\r\\t\\003\\177\\234\\313\\12345z"),
"abc\\\"\b\f\n\r\t\003\177\234\313\12345z") == 0);
g_assert (strcmp(g_strescape("abc\\\"\b\f\n\r\t\003\177\234\313",
NULL),
"abc\\\\\\\"\\b\\f\\n\\r\\t\\003\\177\\234\\313") == 0);
g_assert (strcmp(g_strecpy(g_malloc(100),"abc\\\"\b\f\n\r\t\003\177\234\313",
"\b\f\001\002\003\004"),
g_assert (strcmp(g_strescape("abc\\\"\b\f\n\r\t\003\177\234\313",
"\b\f\001\002\003\004"),
"abc\\\\\\\"\b\f\\n\\r\\t\003\\177\\234\\313") == 0);
return 0;