diff options
author | Miguel de Icaza <miguel@gnome.org> | 2009-04-06 04:13:36 +0400 |
---|---|---|
committer | Miguel de Icaza <miguel@gnome.org> | 2009-04-06 04:13:36 +0400 |
commit | 6dc86808d6e4e1811ef8746afbd67c1eefca4b44 (patch) | |
tree | 6921df6025812b209376598b038837b7c8e86a8b | |
parent | 056c053b978d965c1882c3e3249990777e56467b (diff) |
Backportwii
svn path=/branches/wii/mono/; revision=131084
-rw-r--r-- | eglib/src/gpath.c | 3 | ||||
-rw-r--r-- | eglib/test/path.c | 25 |
2 files changed, 25 insertions, 3 deletions
diff --git a/eglib/src/gpath.c b/eglib/src/gpath.c index 183aed3dfd2..78a2b5f919b 100644 --- a/eglib/src/gpath.c +++ b/eglib/src/gpath.c @@ -68,7 +68,8 @@ g_build_path (const gchar *separator, const gchar *first_element, ...) g_string_append_len (result, s, p - s); if (next && *next){ - g_string_append (result, separator); + if (strncmp (separator, result->str + strlen (result->str) - slen, slen)) + g_string_append (result, separator); for (; strncmp (next, separator, slen) == 0; ) next += slen; diff --git a/eglib/test/path.c b/eglib/test/path.c index 63714817b96..22b12c296cd 100644 --- a/eglib/test/path.c +++ b/eglib/test/path.c @@ -92,7 +92,14 @@ test_buildpath () if (strcmp (s, "/a/c/") != 0) return FAILED ("14 Got wrong result, got: %s", s); g_free (s); - + + /* Null */ + s = g_build_path ("/", NULL); + if (s == NULL) + return FAILED ("must get a non-NULL return"); + if (s [0] != 0) + return FAILED ("must get an empty string"); + g_free (s); return OK; } @@ -109,6 +116,20 @@ test_buildfname () #endif return FAILED ("1 Got wrong result, got: %s", s); g_free (s); + + s = g_build_filename ("/", "a", NULL); +#ifdef G_OS_WIN32 + if (strcmp (s, "\\a") != 0) +#else + if (strcmp (s, "/a") != 0) +#endif + return FAILED ("1 Got wrong result, got: %s", s); + +#ifndef OS_WIN32 + s = g_build_filename ("/", "foo", "/bar", "tolo/", "/meo/", NULL); + if (strcmp (s, "/foo/bar/tolo/meo/") != 0) + return FAILED ("1 Got wrong result, got: %s", s); +#endif return OK; } @@ -284,8 +305,8 @@ test_misc () } static Test path_tests [] = { - {"g_buildpath", test_buildpath}, {"g_build_filename", test_buildfname}, + {"g_buildpath", test_buildpath}, {"g_path_get_dirname", test_dirname}, {"g_path_get_basename", test_basename}, {"g_find_program_in_path", test_ppath}, |