Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Backport

svn path=/branches/wii/mono/; revision=131084
  • Loading branch information...
commit 6dc86808d6e4e1811ef8746afbd67c1eefca4b44 1 parent 056c053
@migueldeicaza migueldeicaza authored
Showing with 25 additions and 3 deletions.
  1. +2 −1  eglib/src/gpath.c
  2. +23 −2 eglib/test/path.c
View
3  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;
View
25 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},
Please sign in to comment.
Something went wrong with that request. Please try again.