mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-11 00:30:49 +00:00
Minor bugfix .. pathExtension
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17729 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5c13d64463
commit
ce828f5acf
2 changed files with 28 additions and 7 deletions
|
@ -1,3 +1,9 @@
|
|||
2003-09-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSString.m: Fix pathExtension bug reported by Roland
|
||||
Schwingel. Was failing to handle the case when a dot appears
|
||||
inside a path component properly.
|
||||
|
||||
2003-09-25 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSConnection.m: Fix obscure bug releasing in-progress
|
||||
|
|
|
@ -2869,7 +2869,7 @@ handle_printf_atsign (FILE *stream,
|
|||
- (NSString*) pathExtension
|
||||
{
|
||||
NSRange range;
|
||||
NSString *substring;
|
||||
NSString *substring = @"";
|
||||
unsigned int length = [self length];
|
||||
|
||||
/*
|
||||
|
@ -2880,16 +2880,31 @@ handle_printf_atsign (FILE *stream,
|
|||
length--;
|
||||
}
|
||||
range = NSMakeRange(0, length);
|
||||
|
||||
/*
|
||||
* Look for a dot in the path ... if there isn't one, there is no extension.
|
||||
*/
|
||||
range = [self rangeOfString: @"." options: NSBackwardsSearch range: range];
|
||||
if (range.length == 0)
|
||||
{
|
||||
substring = @"";
|
||||
}
|
||||
else
|
||||
if (range.length > 0)
|
||||
{
|
||||
NSRange sepRange;
|
||||
|
||||
/*
|
||||
* Found a dot, so we determine the range of the (possible)
|
||||
* path extension, then cvheck to see if we have a path
|
||||
* separator within it ... if we have a path separator then
|
||||
* the dot is inside the last path component and there is
|
||||
* thereofore no extension.
|
||||
*/
|
||||
range.location++;
|
||||
range.length = length - range.location;
|
||||
substring = [self substringFromRange: range];
|
||||
sepRange = [self rangeOfCharacterFromSet: pathSeps()
|
||||
options: NSBackwardsSearch
|
||||
range: range];
|
||||
if (sepRange.length == 0)
|
||||
{
|
||||
substring = [self substringFromRange: range];
|
||||
}
|
||||
}
|
||||
|
||||
return substring;
|
||||
|
|
Loading…
Reference in a new issue