[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bugs in dirname module

From: Eric Blake
Subject: Re: bugs in dirname module
Date: Thu, 10 Nov 2005 21:37:45 -0700
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

Hash: SHA1

According to Paul Eggert on 11/10/2005 6:44 PM:
> This makes it sound like we cannot implement base_name using the
> current approach.  Currently, base_name always returns a suffix of the
> original file name.  But under Cygwin if the file name is "a:b:c",
> base_name cannot return "b:c", since that does not have the desired
> POSIX property that you can chdir to the dir_name and then use the
> base_name.

In cygwin, a:b:c is treated like a:/b:c, but that is not a valid filename
(managed mounts, where : is legal inside a name, cannot be located at a
drive root).  So, the POSIX formula that a valid filename decomposes into
a valid dir and basename does not need to apply in this case.  Cygwin
basename(3) in <libgen.h> solves this particular example by having dirname
return "a:" and basename return "a:b:c".  In other words, in this case,
base_name still returns a valid filename with no slash characters, which
happens to resemble an absolute pathname, and neither the original nor the
base_name result are valid filenames.

Since I had not contemplated this corner case before your mail, I will
update my testsuite before resubmitting my patch.

On the other hand, on cygwin, "./a:b" is a valid name whose base_name is
unambiguously "a:b" per POSIX, but since a:b is treated as an absolute
filename, this example violates the premise that the basename is the
desired file.  But here, cygwin's basename(3) returned "a:b", so I don't
think it is worth complicating base_name for this extreme corner case
(cygwin managed mounts are documented to support all possible Unix
pathnames gracefully except for the cases of \ still being a directory
separator, and files starting with a drive letter prefix cannot be
referenced without a directory separator).

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org


reply via email to

[Prev in Thread] Current Thread [Next in Thread]