2006-11-03 Miguel de Icaza <miguel@novell.com>
authorMiguel de Icaza <miguel@gnome.org>
Sat, 4 Nov 2006 00:03:42 +0000 (00:03 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Sat, 4 Nov 2006 00:03:42 +0000 (00:03 -0000)
        * src/gpath.c (g_path_get_dirname): If the pathname starts with
        * a
        "/", return the "/".

svn path=/trunk/mono/; revision=67334

eglib/ChangeLog
eglib/src/gpath.c
eglib/test/path.c

index bdbf05e5de768206cb33fce812c8d92a7e9401ec..d30461c639c70a9ee788fc8710377c5d4748a815 100644 (file)
@@ -1,5 +1,8 @@
 2006-11-03  Miguel de Icaza  <miguel@novell.com>
 
+       * src/gpath.c (g_path_get_dirname): If the pathname starts with a
+       "/", return the "/".
+
        * test/string-util.c (test_strlcpy): Add new test.
 
        * src/gunicode.c (g_filename_from_utf8): g_strlcpy needs the full
index 572c975108c7b058b174ff818e7e9364cc213af5..3991d08e47cceca1744c84fd478670b334411305 100644 (file)
@@ -83,6 +83,8 @@ g_path_get_dirname (const gchar *filename)
        p = strrchr (filename, G_DIR_SEPARATOR);
        if (p == NULL)
                return g_strdup (".");
+       if (p == filename)
+               return g_strdup ("/");
        count = p - filename;
        r = g_malloc (count + 1);
        strncpy (r, filename, count);
index b9e360462e35f457829cf3885dd0adebc4b86821..e6731ad0f13dc63ea71ccbb3edcdf3bedd4076e7 100644 (file)
@@ -118,6 +118,12 @@ test_dirname ()
        s = g_path_get_dirname ("dir.c");
        if (strcmp (s, ".") != 0)
                return FAILED ("Expected `.', got %s", s);
+       g_free (s);
+
+       s = g_path_get_dirname ("/index.html");
+       if (strcmp (s, "/") != 0)
+               return FAILED ("Expected [/], got [%s]", s);
+       
        return OK;
 }