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:
CaS 2003-08-01 10:15:11 +00:00
parent 73dc4cb9f6
commit 4956796298
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>
* 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);
}
if (argv != 0)
if (argv != 0 && argv[0] != 0)
{
_gnu_arg_zero = (char*)malloc(strlen(argv[0]) + 1);
strcpy(_gnu_arg_zero, argv[0]);
@ -214,7 +214,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
}
}
#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");
abort();
#endif

View file

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

View file

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