mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Fix bug in returning array from completePathIntoString ...
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3246 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
865f17d34a
commit
d9420f1c49
1 changed files with 24 additions and 11 deletions
|
@ -748,14 +748,17 @@ handle_printf_atsign (FILE *stream,
|
|||
|
||||
/* xxx FIXME */
|
||||
- (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet
|
||||
options: (unsigned int)mask
|
||||
range: (NSRange)aRange
|
||||
options: (unsigned int)mask
|
||||
range: (NSRange)aRange
|
||||
{
|
||||
int i, start, stop, step;
|
||||
NSRange range;
|
||||
|
||||
/* xxx check to make sure aRange is within self; raise NSStringBoundsError */
|
||||
assert(NSMaxRange(aRange) <= [self length]);
|
||||
i = [self length];
|
||||
if (aRange.location > i)
|
||||
[NSException raise: NSRangeException format:@"Invalid location."];
|
||||
if (aRange.length > (i - aRange.location))
|
||||
[NSException raise: NSRangeException format:@"Invalid location+length."];
|
||||
|
||||
if ((mask & NSBackwardsSearch) == NSBackwardsSearch)
|
||||
{
|
||||
|
@ -1977,8 +1980,12 @@ else
|
|||
{
|
||||
int len, count;
|
||||
|
||||
/* xxx check to make sure aRange is within self; raise NSStringBoundsError */
|
||||
assert(NSMaxRange(aRange) <= [self cStringLength]);
|
||||
len = [self cStringLength];
|
||||
if (aRange.location > len)
|
||||
[NSException raise: NSRangeException format:@"Invalid location."];
|
||||
if (aRange.length > (len - aRange.location))
|
||||
[NSException raise: NSRangeException format:@"Invalid location+length."];
|
||||
|
||||
if (maxLength < aRange.length)
|
||||
{
|
||||
len = maxLength;
|
||||
|
@ -2151,16 +2158,20 @@ else
|
|||
// Manipulating File System Paths
|
||||
|
||||
- (unsigned int) completePathIntoString: (NSString**)outputName
|
||||
caseSensitive: (BOOL)flag
|
||||
matchesIntoArray: (NSArray**)outputArray
|
||||
filterTypes: (NSArray*)filterTypes
|
||||
caseSensitive: (BOOL)flag
|
||||
matchesIntoArray: (NSArray**)outputArray
|
||||
filterTypes: (NSArray*)filterTypes
|
||||
{
|
||||
NSString * base_path = [self stringByDeletingLastPathComponent];
|
||||
NSString * last_compo = [self lastPathComponent];
|
||||
NSString * tmp_path;
|
||||
NSDirectoryEnumerator * e;
|
||||
NSMutableArray *op;
|
||||
int match_count = 0;
|
||||
|
||||
if (outputArray != 0)
|
||||
op = (NSMutableArray*)[NSMutableArray array];
|
||||
|
||||
if (outputName != NULL) *outputName = nil;
|
||||
|
||||
if ([base_path length] == 0) base_path = @".";
|
||||
|
@ -2189,12 +2200,14 @@ else
|
|||
/* Found a completion */
|
||||
match_count++;
|
||||
if (outputArray != NULL)
|
||||
[*outputArray addObject: tmp_path];
|
||||
[*op addObject: tmp_path];
|
||||
|
||||
if ((outputName != NULL) &&
|
||||
((*outputName == nil) || (([*outputName length] < [tmp_path length]))))
|
||||
((*outputName == nil) || (([*outputName length] < [tmp_path length]))))
|
||||
*outputName = tmp_path;
|
||||
}
|
||||
if (outputArray != NULL)
|
||||
*outputArray = [[op copy] autorelease];
|
||||
return match_count;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue