Mercurial > emacs
changeset 36482:3df7026fc965
(Fexpand_file_name): Collapse sequences of slashes
to a single slash in the middle of file names.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 02 Mar 2001 13:31:33 +0000 |
parents | 8456d3257f81 |
children | c3734c1b1362 |
files | src/fileio.c |
diffstat | 1 files changed, 20 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/fileio.c Fri Mar 02 13:30:40 2001 +0000 +++ b/src/fileio.c Fri Mar 02 13:31:33 2001 +0000 @@ -1127,9 +1127,9 @@ } #endif - /* If nm is absolute, look for /./ or /../ sequences; if none are - found, we can probably return right away. We will avoid allocating - a new string if name is already fully expanded. */ + /* If nm is absolute, look for `/./' or `/../' or `//''sequences; if + none are found, we can probably return right away. We will avoid + allocating a new string if name is already fully expanded. */ if ( IS_DIRECTORY_SEP (nm[0]) #ifdef MSDOS @@ -1165,6 +1165,13 @@ || (p[2] == '.' && (IS_DIRECTORY_SEP (p[3]) || p[3] == 0)))) lose = 1; + /* We want to replace multiple `/' in a row with a single + slash. */ + else if (p > nm + && IS_DIRECTORY_SEP (p[0]) + && IS_DIRECTORY_SEP (p[1])) + lose = 1; + #ifdef VMS if (p[0] == '\\') lose = 1; @@ -1525,7 +1532,8 @@ /* ASSERT (IS_DIRECTORY_SEP (target[0])) if not VMS */ - /* Now canonicalize by removing /. and /foo/.. if they appear. */ + /* Now canonicalize by removing `//', `/.' and `/foo/..' if they + appear. */ p = target; o = target; @@ -1601,6 +1609,14 @@ ++o; p += 3; } + else if (p > target + && IS_DIRECTORY_SEP (p[0]) && IS_DIRECTORY_SEP (p[1])) + { + /* Collapse multiple `/' in a row. */ + *o++ = *p++; + while (IS_DIRECTORY_SEP (*p)) + ++p; + } else { *o++ = *p++;