Handle root correctly in g_file_get_relative_path (#508719)
authorAlexander Larsson <alexl@redhat.com>
Mon, 14 Jan 2008 14:55:27 +0000 (14:55 +0000)
committerAlexander Larsson <alexl@src.gnome.org>
Mon, 14 Jan 2008 14:55:27 +0000 (14:55 +0000)
2008-01-14  Alexander Larsson  <alexl@redhat.com>

        * glocalfile.c:
        (match_prefix):
Handle root correctly in g_file_get_relative_path (#508719)

svn path=/trunk/; revision=6305

gio/ChangeLog
gio/glocalfile.c

index ecb52eb..5a7ae0a 100644 (file)
@@ -1,5 +1,11 @@
 2008-01-14  Alexander Larsson  <alexl@redhat.com>
 
+        * glocalfile.c:
+        (match_prefix):
+       Handle root correctly in g_file_get_relative_path (#508719)
+
+2008-01-14  Alexander Larsson  <alexl@redhat.com>
+
         * gasyncresult.c:
        Clean up docs and example for GAsyncResult (#508074)
 
index 35ad6ed..1de3e48 100644 (file)
@@ -475,6 +475,13 @@ match_prefix (const char *path,
   prefix_len = strlen (prefix);
   if (strncmp (path, prefix, prefix_len) != 0)
     return NULL;
+  
+  /* Handle the case where prefix is the root, so that
+   * the IS_DIR_SEPRARATOR check below works */
+  if (prefix_len > 0 &&
+      G_IS_DIR_SEPARATOR (prefix[prefix_len-1]))
+    prefix_len--;
+  
   return path + prefix_len;
 }