bug-gnustep
[Top][All Lists]
Advanced

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

bugs in [NSString stringByStandardizingPath]


From: Michael Scheibler
Subject: bugs in [NSString stringByStandardizingPath]
Date: Wed, 20 Feb 2002 10:01:08 +0100

I have to mention two bugs in [NSString stringByStandardizingPath]:

First one:

In NSString.m:

- (NSString*) stringByStandardizingPath
{
...
  s = [[self stringByExpandingTildeInPath] mutableCopy];
  //shouldn't it be autoreleased??
...
  return s;
}




Second one (only on mingw):

Paths like

Z:\SomeDir\SomeOtherDir\../../Bundles/SomeBundle.bundle

were transformed to

../Bundles/SomeBundle.bundle

Here is the fix (it is from an older version, but the latest CVS snapshot
doesn't have this bug fixed, too):

#if defined(__MINGW__)
  /* Condense `/../' */
  r = NSMakeRange(0, [s length]);
  while ((r = [s rangeOfCharacterFromSet: pathSeps()
                                 options: 0
                                   range: r]).length)
    {
      if (r.location + r.length + 3 <= [s length]
        && (*caiImp)(s, caiSel, r.location + 1) == (unichar)'.'
        && (*caiImp)(s, caiSel, r.location + 2) == (unichar)'.'
        && pathSepMember((*caiImp)(s, caiSel, r.location + 3)) == YES)
        {
          if (r.location > 0)
            {
              NSRange r2 = {0, r.location};
              r = [s rangeOfCharacterFromSet: pathSeps()
                                     options: NSBackwardsSearch
                                       range: r2];
              if (r.length == 0)
                r = r2;
>             else
>               r.length = r2.length - r.location - 1;
              r.length += 4;            /* Add the `/../' */
            }
          [s deleteCharactersInRange: r];
        }
      else
        r.location++;
      if ((r.length = [s length]) > r.location)
        r.length -= r.location;
      else
        break;
    }

  return s;
#else


Michael Scheibler




reply via email to

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