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
[Message part 1 (text/plain, inline)]
On 02/20/2012 08:21 AM, Pádraig Brady wrote:
> On 02/04/2012 07:05 PM, Eric Blake wrote:
>> On platforms like Cygwin where / and // are distinct, realpath was
>> incorrectly collapsing // into /. http://debbugs.gnu.org/10472.
>>
>> This is the coreutils side of the patch; for this to work, we also
>> have to upgrade to the latest gnulib.
The gnulib update has happened in the meantime.
>>
>> I'm not pushing this until we decide what to do about testing; I
>> guess we've already figured out how to make basename and dirname
>> tests conditional on whether they are on Linux or Cygwin (that is,
>> whether // and / are the same or different), so I should do something
>> similar to that for the realpath test. But I can at least get a
>> code review on realpath.c while figuring out the testing situation.
I'm planning on resubmitting this series soon, once I polish my test,
with hopes of inclusion in this week's release.
>> +++ b/src/realpath.c
>> @@ -131,6 +131,10 @@ path_common_prefix (const char *path1, const char *path2)
>> int i = 0;
>> int ret = 0;
>>
>> + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && *path1 == '/' && *path2 == '/'
>> + && (path1[1] == '/') != (path2[1] == '/'))
>> + return 0;
>> +
>> while (*path1 && *path2)
>> {
>> if (*path1 != *path2)
> is the DOUBLE_SLASH_IS_DISTINCT_ROOT check needed in realpath.c
> I.E. if we get a leading // then that define is implicit?
Good point - path_common_prefix is only ever called with canonical
names, which means that it will only ever encounter // on systems where
it matters.
>
> Also doesn't path_prefix() need the same adjustment,
> so as to verify --relative-base in the same way?
Yes, it looks like it.
--
Eric Blake eblake <at> redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
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.