From: Alexander Larsson Date: Mon, 14 Jan 2008 14:55:27 +0000 (+0000) Subject: Handle root correctly in g_file_get_relative_path (#508719) X-Git-Tag: GLIB_2_15_2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a80b1120f1fa19cfb036e371313af8e73eaea049;p=platform%2Fupstream%2Fglib.git Handle root correctly in g_file_get_relative_path (#508719) 2008-01-14 Alexander Larsson * glocalfile.c: (match_prefix): Handle root correctly in g_file_get_relative_path (#508719) svn path=/trunk/; revision=6305 --- diff --git a/gio/ChangeLog b/gio/ChangeLog index ecb52eb..5a7ae0a 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,5 +1,11 @@ 2008-01-14 Alexander Larsson + * glocalfile.c: + (match_prefix): + Handle root correctly in g_file_get_relative_path (#508719) + +2008-01-14 Alexander Larsson + * gasyncresult.c: Clean up docs and example for GAsyncResult (#508074) diff --git a/gio/glocalfile.c b/gio/glocalfile.c index 35ad6ed..1de3e48 100644 --- a/gio/glocalfile.c +++ b/gio/glocalfile.c @@ -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; }