Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/eglib
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2009-04-06 04:11:54 +0400
committerMiguel de Icaza <miguel@gnome.org>2009-04-06 04:11:54 +0400
commit78d06c6587d31b300b7426af6cc33f95c494fac1 (patch)
tree40b5f15f9ae08ed20f499554d75f6be14ab04d79 /eglib
parentfe78acafcbd522e6aae88a7bcb9582a5b9d2d054 (diff)
2009-04-05 Miguel de Icaza <miguel@novell.com>
* src/gpath.c: Avoid situations where we add the separator if one of the elements is the separator. svn path=/trunk/mono/; revision=131083
Diffstat (limited to 'eglib')
-rw-r--r--eglib/ChangeLog10
-rw-r--r--eglib/src/gpath.c7
-rw-r--r--eglib/test/path.c25
3 files changed, 38 insertions, 4 deletions
diff --git a/eglib/ChangeLog b/eglib/ChangeLog
index f4e8140792a..f7c08f6fa9b 100644
--- a/eglib/ChangeLog
+++ b/eglib/ChangeLog
@@ -1,3 +1,13 @@
+2009-04-05 Miguel de Icaza <miguel@novell.com>
+
+ * src/gpath.c: Avoid situations where we add the separator if one
+ of the elements is the separator.
+
+2009-04-02 Miguel de Icaza <miguel@novell.com>
+
+ * src/gpath.c: If the first element is NULL, return an empty
+ string.
+
2009-02-19 Gonzalo Paniagua Javier <gonzalo@novell.com>
* src/gstr.c: use memset in g_strnfill.
diff --git a/eglib/src/gpath.c b/eglib/src/gpath.c
index 8d46845031e..78a2b5f919b 100644
--- a/eglib/src/gpath.c
+++ b/eglib/src/gpath.c
@@ -47,7 +47,9 @@ g_build_path (const gchar *separator, const gchar *first_element, ...)
va_list args;
g_return_val_if_fail (separator != NULL, NULL);
- g_return_val_if_fail (first_element != NULL, NULL);
+
+ if (first_element == NULL)
+ return g_strdup ("");
result = g_string_sized_new (48);
@@ -66,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},