diff options
| author | Gerd Moellmann | 2001-03-02 13:31:33 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-03-02 13:31:33 +0000 |
| commit | 214378eca1d48adcdb0d38a5361cfee9cea9203e (patch) | |
| tree | 10fbac13fd28986cb201b2dbdfce870cfe9e5170 /src | |
| parent | b9c769f8667ea5fdf99a8875ec798c5d710caff1 (diff) | |
| download | emacs-214378eca1d48adcdb0d38a5361cfee9cea9203e.tar.gz emacs-214378eca1d48adcdb0d38a5361cfee9cea9203e.zip | |
(Fexpand_file_name): Collapse sequences of slashes
to a single slash in the middle of file names.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 24 |
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'.") | |||
| 1127 | } | 1127 | } |
| 1128 | #endif | 1128 | #endif |
| 1129 | 1129 | ||
| 1130 | /* If nm is absolute, look for /./ or /../ sequences; if none are | 1130 | /* If nm is absolute, look for `/./' or `/../' or `//''sequences; if |
| 1131 | found, we can probably return right away. We will avoid allocating | 1131 | none are found, we can probably return right away. We will avoid |
| 1132 | a new string if name is already fully expanded. */ | 1132 | allocating a new string if name is already fully expanded. */ |
| 1133 | if ( | 1133 | if ( |
| 1134 | IS_DIRECTORY_SEP (nm[0]) | 1134 | IS_DIRECTORY_SEP (nm[0]) |
| 1135 | #ifdef MSDOS | 1135 | #ifdef MSDOS |
| @@ -1165,6 +1165,13 @@ See also the function `substitute-in-file-name'.") | |||
| 1165 | || (p[2] == '.' && (IS_DIRECTORY_SEP (p[3]) | 1165 | || (p[2] == '.' && (IS_DIRECTORY_SEP (p[3]) |
| 1166 | || p[3] == 0)))) | 1166 | || p[3] == 0)))) |
| 1167 | lose = 1; | 1167 | lose = 1; |
| 1168 | /* We want to replace multiple `/' in a row with a single | ||
| 1169 | slash. */ | ||
| 1170 | else if (p > nm | ||
| 1171 | && IS_DIRECTORY_SEP (p[0]) | ||
| 1172 | && IS_DIRECTORY_SEP (p[1])) | ||
| 1173 | lose = 1; | ||
| 1174 | |||
| 1168 | #ifdef VMS | 1175 | #ifdef VMS |
| 1169 | if (p[0] == '\\') | 1176 | if (p[0] == '\\') |
| 1170 | lose = 1; | 1177 | lose = 1; |
| @@ -1525,7 +1532,8 @@ See also the function `substitute-in-file-name'.") | |||
| 1525 | 1532 | ||
| 1526 | /* ASSERT (IS_DIRECTORY_SEP (target[0])) if not VMS */ | 1533 | /* ASSERT (IS_DIRECTORY_SEP (target[0])) if not VMS */ |
| 1527 | 1534 | ||
| 1528 | /* Now canonicalize by removing /. and /foo/.. if they appear. */ | 1535 | /* Now canonicalize by removing `//', `/.' and `/foo/..' if they |
| 1536 | appear. */ | ||
| 1529 | 1537 | ||
| 1530 | p = target; | 1538 | p = target; |
| 1531 | o = target; | 1539 | o = target; |
| @@ -1601,6 +1609,14 @@ See also the function `substitute-in-file-name'.") | |||
| 1601 | ++o; | 1609 | ++o; |
| 1602 | p += 3; | 1610 | p += 3; |
| 1603 | } | 1611 | } |
| 1612 | else if (p > target | ||
| 1613 | && IS_DIRECTORY_SEP (p[0]) && IS_DIRECTORY_SEP (p[1])) | ||
| 1614 | { | ||
| 1615 | /* Collapse multiple `/' in a row. */ | ||
| 1616 | *o++ = *p++; | ||
| 1617 | while (IS_DIRECTORY_SEP (*p)) | ||
| 1618 | ++p; | ||
| 1619 | } | ||
| 1604 | else | 1620 | else |
| 1605 | { | 1621 | { |
| 1606 | *o++ = *p++; | 1622 | *o++ = *p++; |