GNU bug report logs -
#10472
`realpath --relative-to=<path> /` outputs inconsistent trailing slash
Previous Next
Reported by: Mike Frysinger <vapier <at> gentoo.org>
Date: Tue, 10 Jan 2012 20:17:02 UTC
Severity: normal
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On Cygwin, and other platforms where // is detected as distinct
from / at configure time, the canonicalize routines were incorrectly
treating all instances of multiple leading slashes as //.
See also coreutils bug http://debbugs.gnu.org/10472
* lib/canonicalize.c (canonicalize_filename_mode): Don't convert
/// to //, since only // is special.
Signed-off-by: Eric Blake <eblake <at> redhat.com>
---
ChangeLog | 6 ++++++
lib/canonicalize.c | 12 +++++++-----
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4bbe447..a9aa40a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-02-04 Eric Blake <eblake <at> redhat.com>
+
+ canonicalize: fix // handling
+ * lib/canonicalize.c (canonicalize_filename_mode): Don't convert
+ /// to //, since only // is special.
+
2012-02-04 Bruno Haible <bruno <at> clisp.org>
ioctl: Fix test failure on native Windows.
diff --git a/lib/canonicalize.c b/lib/canonicalize.c
index d3e5645..ed094b7 100644
--- a/lib/canonicalize.c
+++ b/lib/canonicalize.c
@@ -145,7 +145,7 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode)
rname_limit = rname + PATH_MAX;
rname[0] = '/';
dest = rname + 1;
- if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] == '/')
+ if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] == '/' && name[2] != '/')
*dest++ = '/';
}
@@ -169,7 +169,7 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode)
if (dest > rname + 1)
while ((--dest)[-1] != '/');
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1
- && *dest == '/')
+ && *dest == '/' && dest[1] != '/')
dest++;
}
else
@@ -267,7 +267,8 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode)
if (buf[0] == '/')
{
dest = rname + 1; /* It's an absolute symlink */
- if (DOUBLE_SLASH_IS_DISTINCT_ROOT && buf[1] == '/')
+ if (DOUBLE_SLASH_IS_DISTINCT_ROOT
+ && buf[1] == '/' && buf[2] != '/')
*dest++ = '/';
}
else
@@ -277,7 +278,7 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode)
if (dest > rname + 1)
while ((--dest)[-1] != '/');
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1
- && *dest == '/')
+ && *dest == '/' && dest[1] != '/')
dest++;
}
@@ -295,7 +296,8 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode)
}
if (dest > rname + 1 && dest[-1] == '/')
--dest;
- if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 && *dest == '/')
+ if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1
+ && *dest == '/' && dest[1] != '/')
dest++;
*dest = '\0';
if (rname_limit != dest + 1)
--
1.7.7.6
This bug report was last modified 13 years and 75 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.