apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bert Huijben" <b...@qqmail.nl>
Subject RE: Windows drive letter check fails on lower case cwd
Date Sat, 07 Nov 2009 21:13:48 GMT


> -----Original Message-----
> From: Philip Martin [mailto:philip@codematters.co.uk]
> Sent: zaterdag 7 november 2009 9:41
> To: Bert Huijben
> Cc: dev@apr.apache.org; dev@subversion.tigris.org
> Subject: Re: Windows drive letter check fails on lower case cwd
> 
> Bert Huijben <rhuijben@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


Mime
View raw message