Re: path separator

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

 



Hi Ralf,

Ralf Wildenhues wrote:
> * Keith MARSHALL wrote on Tue, Jan 23, 2007 at 05:50:24PM CET:
>> Ralf Wildenhues wrote:
>>
>>>   defined (__OS2__)
>>> # define HAVE_DOS_BASED_FILE_SYSTEM
>>> # ifndef DIR_SEPARATOR_2
>>> #  define DIR_SEPARATOR_2 '\\'
>>> # endif
>>> # ifndef PATH_SEPARATOR_2
>>> #  define PATH_SEPARATOR_2 ';'
>>> # endif
>>> #endif
>>
>> I've never found it particularly useful to distinguish between '/'
>> and '\\' as DIR_SEPARATOR chars; for most purposes MS-Windows, and
>> MS-DOS before it, *don't* *need* '\\', so you may as well just use
>> '/' on every platform.  There is only one exception I can think of,
>> and IME it's rarely encountered in practice; of course, it may be
>> different on OS2, of which I have no experience.
>
> Well, if you want to *parse* file names given to you from some external
> input, then also recognizing '\\' as directory separator is just being
> liberal in what you accept.

Sorry, it wasn't clear, from the snippet you posted, that your intention
was to use DIR_SEPARATOR_2 in a parsing context, and I overlooked this
possibile usage.

You are quite correct, of course; indeed, I would put it more strongly:
if you are parsing a path name on Win32 or MS-DOS, then you *must* check
for *both* '/' *and* '\\', when selecting the DIR_SEPARATORs.  To be
absolutely correct, you may also need to perform the comparisons in the
wchar_t domain, since Win32 path names may be expressed in the multibyte
character set of the system locale, and some of those include '\\' as a
trail byte in a MB sequence, I believe.

FWIW, in my own implementations of `basename' and `dirname' functions,
for MinGW, I *do* search for both '/' and '\\' when looking for the
break point.  My current implementation doesn't do the right thing for
MB locales; I have an outstanding patch to fix that.

Cheers,
Keith.


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux