[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: Windows drive letter check fails on lower case cwd

From: Bert Huijben <rhuijben_at_sharpsvn.net>
Date: Sat, 7 Nov 2009 22:13:48 +0100

> -----Original Message-----
> From: Philip Martin [mailto:philip_at_codematters.co.uk]
> Sent: zaterdag 7 november 2009 9:41
> To: Bert Huijben
> Cc: dev_at_apr.apache.org; dev_at_subversion.tigris.org
> Subject: Re: Windows drive letter check fails on lower case cwd
>
> Bert Huijben <rhuijben_at_sharpsvn.net> writes:
>
> > Index: file_io/win32/filepath.c
> > ===================================================================
> > --- file_io/win32/filepath.c (revision 832725)
> > +++ file_io/win32/filepath.c (working copy)
> > @@ -540,7 +540,8 @@
> > * use the basepath _if_ it matches this drive letter!
> > * Otherwise we must discard the basepath.
> > */
> > - if (addroot[0] == baseroot[0] && baseroot[1] == ':') {
> > + if (apr_toupper(addroot[0]) == apr_toupper(baseroot[0])
> > + && baseroot[1] == ':') {
> > #endif
> > /* Base the result path on the basepath
> > */
> >
> > The call will return me "c:/windows/hi" and no error.
> >
> > (For Subversion the answers "c:/windows/hi" and "C:/windows/hi" are
> both valid as we normalize the resulting drive letter to upper case
> directly after reading it. Normalizing to upper case might be preferred
> for apr itself)
> >
> > Proposed log message:
> > [[
> > Use case insensitive drive letter comparison when making "C:hi"-like
> paths
> > absolute on Windows
> > ]]
>
> How does Win32 handle Turkish? On Linux apr_toupper is locale aware
> so in a Turkish locale (tr_TR) apr_toupper(i) != apr_toupper(I). Do
> "i:/" and "I:/" refer to the same drive in Turkish? Does apr_toupper
> have the same behaviour as drive letters?

The drive letters don't have locales; the rest of the paths have. There are
only 26 driveletters with the US-ASCII characters A-Z. (Internally always
represented by the upper case letters, but the current path can use a lower
case path, as that is only managed in userspace).

I think a wrapper which maps 'a'-'z' explicitly might be a bit better, to
resolve this specific issue..

Something like: (untested)

char drive_to_upper(char letter)
{
  if (letter >= 'a' && letter <= 'z')
    return letter - 'a' + 'A';
  else
    return letter;
}

But the case this patch resolves an issue that has been reported only once
over the last 9 years (at least for Subversion)... and the only place where
this apr_toupper()would fail is when this specific case happens.. combined
with this Turkish locale and the drive I:, which is very uncommon too...

Good theoretical bug ;-)

        Bert

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2415469
Received on 2009-11-07 22:14:22 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.