diff options
author | Eli Zaretskii <eliz@gnu.org> | 2015-05-20 18:18:33 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2015-05-20 18:18:33 +0300 |
commit | e1890e3e829665a54f04284f4e23bd0fd37de06b (patch) | |
tree | 1e752c8c1b671a728c03d18418e32a56a6d66c85 /lib-src | |
parent | 1a17b775b6bd476c051ae5ef00b752aacb6cf103 (diff) | |
download | emacs-e1890e3e829665a54f04284f4e23bd0fd37de06b.tar.gz |
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.
Diffstat (limited to 'lib-src')
-rw-r--r-- | lib-src/etags.c | 25 |
1 files changed, 19 insertions, 6 deletions
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'; } |