autoconf
[Top][All Lists]
Advanced

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

Re: path separator


From: Keith MARSHALL
Subject: Re: path separator
Date: Wed, 24 Jan 2007 10:21:40 +0000

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.




reply via email to

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