Fix removing leading double slashes in filenames which are used for network resources on Windows (closes #2844085).

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4139 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2009-08-29 19:06:19 +00:00
parent 55b68b76fa
commit f114ba9900
2 changed files with 10 additions and 0 deletions

View File

@ -2,6 +2,9 @@
* src/build.c, src/filetypes.c:
Fix compiler warnings.
* src/utils.c:
Fix removing leading double slashes in filenames which are used for
network resources on Windows (closes #2844085).
2009-08-27 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

View File

@ -1719,13 +1719,20 @@ void utils_tidy_path(gchar *filename)
const gchar *c, *needle;
gchar *tmp;
gssize pos;
gboolean preserve_double_backslash = FALSE;
g_return_if_fail(g_path_is_absolute(filename));
if (str->len >= 2 && strncmp(str->str, "\\\\", 2) == 0)
preserve_double_backslash = TRUE;
/* replace "/./" and "//" */
utils_string_replace_all(str, G_DIR_SEPARATOR_S "." G_DIR_SEPARATOR_S, G_DIR_SEPARATOR_S);
utils_string_replace_all(str, G_DIR_SEPARATOR_S G_DIR_SEPARATOR_S, G_DIR_SEPARATOR_S);
if (preserve_double_backslash)
g_string_prepend(str, "\\");
/* replace "/.." */
needle = G_DIR_SEPARATOR_S "..";
while (1)