# HG changeset patch # User Gerd Moellmann # Date 983539893 0 # Node ID 3df7026fc965044ca7c6db38231c36b227a070c6 # Parent 8456d3257f819a5d741c93ac8a6012e9bbac259c (Fexpand_file_name): Collapse sequences of slashes to a single slash in the middle of file names. diff -r 8456d3257f81 -r 3df7026fc965 src/fileio.c --- 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++;