summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerd Moellmann <gerd@gnu.org>2001-03-02 13:31:33 +0000
committerGerd Moellmann <gerd@gnu.org>2001-03-02 13:31:33 +0000
commit214378eca1d48adcdb0d38a5361cfee9cea9203e (patch)
tree10fbac13fd28986cb201b2dbdfce870cfe9e5170
parentb9c769f8667ea5fdf99a8875ec798c5d710caff1 (diff)
downloademacs-214378eca1d48adcdb0d38a5361cfee9cea9203e.tar.gz
(Fexpand_file_name): Collapse sequences of slashes
to a single slash in the middle of file names.
-rw-r--r--src/fileio.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/fileio.c b/src/fileio.c
index eb6421a1374..93e0161e1fc 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1127,9 +1127,9 @@ See also the function `substitute-in-file-name'.")
}
#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 @@ See also the function `substitute-in-file-name'.")
|| (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 @@ See also the function `substitute-in-file-name'.")
/* 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 @@ See also the function `substitute-in-file-name'.")
++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++;