diff options
author | Miguel de Icaza <miguel@gnome.org> | 2006-10-18 22:13:16 +0400 |
---|---|---|
committer | Miguel de Icaza <miguel@gnome.org> | 2006-10-18 22:13:16 +0400 |
commit | 89382360c7ff7309a407e2248a98210774d5c8ef (patch) | |
tree | f5499c1676b7f71fdd8d1b64e9b36c7782caf2ee /eglib | |
parent | 5c06ed786be14b431155c29d73bb0f81e6333ea1 (diff) |
2006-10-18 Miguel de Icaza <miguel@novell.com>
* src/gpath.c (g_build_path): Do not append terminator if the next
string is empty.
* src/gutf8.c (g_utf8_to_utf16): Include trailing zero as
documented.
(g_utf16_to_utf8): Include trailing zero as documented.
svn path=/trunk/mono/; revision=66796
Diffstat (limited to 'eglib')
-rw-r--r-- | eglib/ChangeLog | 9 | ||||
-rw-r--r-- | eglib/src/gpath.c | 3 | ||||
-rw-r--r-- | eglib/src/gutf8.c | 6 | ||||
-rw-r--r-- | eglib/test/path.c | 6 |
4 files changed, 21 insertions, 3 deletions
diff --git a/eglib/ChangeLog b/eglib/ChangeLog index a30d26f6c75..c0c30042de2 100644 --- a/eglib/ChangeLog +++ b/eglib/ChangeLog @@ -1,3 +1,12 @@ +2006-10-18 Miguel de Icaza <miguel@novell.com> + + * src/gpath.c (g_build_path): Do not append terminator if the next + string is empty. + + * src/gutf8.c (g_utf8_to_utf16): Include trailing zero as + documented. + (g_utf16_to_utf8): Include trailing zero as documented. + 2006-10-17 Miguel de Icaza <miguel@novell.com> * src/gstr.c (g_strdown): Actually move. diff --git a/eglib/src/gpath.c b/eglib/src/gpath.c index fa8c226dd3c..84f7cd3ab0f 100644 --- a/eglib/src/gpath.c +++ b/eglib/src/gpath.c @@ -60,13 +60,14 @@ g_build_path (const gchar *separator, const gchar *first_element, ...) } g_string_append_len (result, s, p - s); - if (next){ + if (next && *next){ g_string_append (result, separator); for (; strncmp (next, separator, slen) == 0; ) next += slen; } } + g_string_append_c (result, 0); va_end (args); return g_string_free (result, FALSE); diff --git a/eglib/src/gutf8.c b/eglib/src/gutf8.c index b195c85c7b4..6239178b04b 100644 --- a/eglib/src/gutf8.c +++ b/eglib/src/gutf8.c @@ -49,7 +49,7 @@ g_utf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_wr if (utf16_len < 0) return NULL; - ret = g_malloc (utf16_len * sizeof (gunichar2)); + ret = g_malloc ((1 + utf16_len) * sizeof (gunichar2)); for (in_pos = 0; len < 0 ? str [in_pos] : in_pos < len; in_pos++) { ch = (guchar) str [in_pos]; @@ -102,6 +102,7 @@ g_utf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_wr } } + ret [out_pos] = 0; if (items_written) *items_written = out_pos; return ret; @@ -252,7 +253,7 @@ g_utf16_to_utf8 (const gunichar2 *str, glong len, glong *items_read, glong *item if (utf8_len < 0) return NULL; - ret = g_malloc (utf8_len * sizeof (gchar)); + ret = g_malloc ((1+utf8_len) * sizeof (gchar)); while (len < 0 ? str [in_pos] : in_pos < len) { ch = str [in_pos]; @@ -301,6 +302,7 @@ g_utf16_to_utf8 (const gunichar2 *str, glong len, glong *items_read, glong *item ret [out_pos++] = (gchar) (0x80 | (codepoint & 0x3F)); } } + ret [out_pos] = 0; if (items_written) *items_written = out_pos; diff --git a/eglib/test/path.c b/eglib/test/path.c index 07c73f608ee..58c889d0cbb 100644 --- a/eglib/test/path.c +++ b/eglib/test/path.c @@ -77,6 +77,12 @@ test_buildpath () if (strcmp (s, "a/b/c/d") != 0) return FAILED ("13 Got wrong result, got: %s", s); g_free (s); + + s = g_build_path ("/", "/a", "", "/c/", NULL); + if (strcmp (s, "/a/c/") != 0) + return FAILED ("14 Got wrong result, got: %s", s); + g_free (s); + return OK; return OK; } |