From: Eli Zaretskii Date: Wed, 20 May 2015 15:18:33 +0000 (+0300) Subject: Fix slash collapsing in etags on MS-Windows X-Git-Tag: emacs-25.0.90~2035 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e1890e3e829665a54f04284f4e23bd0fd37de06b;p=emacs.git Fix slash collapsing in etags on MS-Windows * lib-src/etags.c (canonicalize_filename) [DOS_NT]: Separate the MS-Windows code from the Posix code, and support collapsing both forward- and back-slashes on MS-Windows. Fixes a regression found by the test suite. --- diff --git a/lib-src/etags.c b/lib-src/etags.c index 7bacbd3e619..0a308c1984f 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -6484,7 +6484,6 @@ static void canonicalize_filename (register char *fn) { register char* cp; - char sep = '/'; #ifdef DOS_NT /* Canonicalize drive letter case. */ @@ -6492,19 +6491,33 @@ canonicalize_filename (register char *fn) if (fn[0] != '\0' && fn[1] == ':' && ISUPPER (fn[0])) fn[0] = lowcase (fn[0]); - sep = '\\'; -#endif + /* Collapse multiple forward- and back-slashes into a single forward + slash. */ + for (cp = fn; *cp != '\0'; cp++, fn++) + if (*cp == '/' || *cp == '\\') + { + *fn = '/'; + while (cp[1] == '/' || cp[1] == '\\') + cp++; + } + else + *fn = *cp; + +#else /* !DOS_NT */ - /* Collapse multiple separators into a single slash. */ + /* Collapse multiple slashes into a single slash. */ for (cp = fn; *cp != '\0'; cp++, fn++) - if (*cp == sep) + if (*cp == '/') { *fn = '/'; - while (cp[1] == sep) + while (cp[1] == '/') cp++; } else *fn = *cp; + +#endif /* !DOS_NT */ + *fn = '\0'; }