Fix a few oddities

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17411 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-08-01 10:15:11 +00:00
parent ac30183cd6
commit 7c391eb265
4 changed files with 51 additions and 22 deletions

View file

@ -1,3 +1,12 @@
2003-08-01 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSProxy.m: Include limits.h for UINT_MAX
* Source/NSProcessInfo.m: Avoid crash when given invalid argument list
* Source/NSString.m: Minor cleanup for coding standards and remove
pointer dereferencing of object which causes problems with new
compiler
Problems reported by Alexander and Roland
2003-07-31 David Ayers <d.ayers@inode.at> 2003-07-31 David Ayers <d.ayers@inode.at>
* Created tag 'pre-header-reorg-20030731'. * Created tag 'pre-header-reorg-20030731'.

View file

@ -187,7 +187,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
free(_gnu_arg_zero); free(_gnu_arg_zero);
} }
if (argv != 0) if (argv != 0 && argv[0] != 0)
{ {
_gnu_arg_zero = (char*)malloc(strlen(argv[0]) + 1); _gnu_arg_zero = (char*)malloc(strlen(argv[0]) + 1);
strcpy(_gnu_arg_zero, argv[0]); strcpy(_gnu_arg_zero, argv[0]);
@ -214,7 +214,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
} }
} }
#else #else
fprintf(stderr, "Error: for some reason, argv == NULL " fprintf(stderr, "Error: for some reason, argv not properly set up "
"during GNUstep base initialization\n"); "during GNUstep base initialization\n");
abort(); abort();
#endif #endif

View file

@ -35,6 +35,11 @@
#include "Foundation/NSDistantObject.h" #include "Foundation/NSDistantObject.h"
#include "Foundation/NSPortCoder.h" #include "Foundation/NSPortCoder.h"
#ifdef HAVE_LIMITS_H
/* For UINT_MAX */
#include <limit.h>
#endif
@class NSDistantObject; @class NSDistantObject;
#ifndef NeXT_RUNTIME #ifndef NeXT_RUNTIME

View file

@ -2711,54 +2711,69 @@ handle_printf_atsign (FILE *stream,
matchesIntoArray: (NSArray**)outputArray matchesIntoArray: (NSArray**)outputArray
filterTypes: (NSArray*)filterTypes filterTypes: (NSArray*)filterTypes
{ {
NSString *base_path = [self stringByDeletingLastPathComponent]; NSString *base_path = [self stringByDeletingLastPathComponent];
NSString *last_compo = [self lastPathComponent]; NSString *last_compo = [self lastPathComponent];
NSString *tmp_path; NSString *tmp_path;
NSDirectoryEnumerator *e; NSDirectoryEnumerator *e;
NSMutableArray *op = nil; NSMutableArray *op = nil;
unsigned match_count = 0; unsigned match_count = 0;
if (outputArray != 0) if (outputArray != 0)
op = (NSMutableArray*)[NSMutableArray array]; {
op = (NSMutableArray*)[NSMutableArray array];
}
if (outputName != NULL) if (outputName != NULL)
*outputName = nil; {
*outputName = nil;
}
if ([base_path length] == 0) if ([base_path length] == 0)
base_path = @"."; {
base_path = @".";
}
e = [[NSFileManager defaultManager] enumeratorAtPath: base_path]; e = [[NSFileManager defaultManager] enumeratorAtPath: base_path];
while (tmp_path = [e nextObject], tmp_path) while (tmp_path = [e nextObject], tmp_path)
{ {
/* Prefix matching */ /* Prefix matching */
if (YES == flag) if (flag == YES)
{ /* Case sensitive */ { /* Case sensitive */
if (NO == [tmp_path hasPrefix: last_compo]) if ([tmp_path hasPrefix: last_compo] == NO)
continue ; {
continue;
}
} }
else else if ([[tmp_path uppercaseString]
hasPrefix: [last_compo uppercaseString]] == NO)
{ {
if (NO == [[tmp_path uppercaseString] continue;
hasPrefix: [last_compo uppercaseString]])
continue;
} }
/* Extensions filtering */ /* Extensions filtering */
if (filterTypes && if (filterTypes
(NO == [filterTypes containsObject: [tmp_path pathExtension]])) && ([filterTypes containsObject: [tmp_path pathExtension]] == NO))
continue ; {
continue;
}
/* Found a completion */ /* Found a completion */
match_count++; match_count++;
if (outputArray != NULL) if (outputArray != NULL)
[*op addObject: tmp_path]; {
[op addObject: tmp_path];
}
if ((outputName != NULL) && if ((outputName != NULL) &&
((*outputName == nil) || (([*outputName length] < [tmp_path length])))) ((*outputName == nil) || (([*outputName length] < [tmp_path length]))))
*outputName = tmp_path; {
*outputName = tmp_path;
}
} }
if (outputArray != NULL) if (outputArray != NULL)
*outputArray = AUTORELEASE([op copy]); {
*outputArray = AUTORELEASE([op copy]);
}
return match_count; return match_count;
} }