Various minro tidyups

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14744 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2002-10-12 16:12:25 +00:00
parent 72c3b7f7a5
commit f856d3ec00
3 changed files with 30 additions and 15 deletions

View file

@ -1,3 +1,9 @@
2002-10-12 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSProcessInfo.m: Make safe to reinitialise with args.
* Source/Additions/GSXML.m: Correct handling of atttribute values.
* Tools/autogsdoc.m: Initialise NSProcessInfo explicitly.
2002-10-11 Richard Frith-Macdonald <rfm@gnu.org> 2002-10-11 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSUserDefaults.m: ([-initWithContentsOfFile:]) check to see * Source/NSUserDefaults.m: ([-initWithContentsOfFile:]) check to see

View file

@ -171,13 +171,18 @@ static NSMutableSet *_debug_set = nil;
void void
_gnu_process_args(int argc, char *argv[], char *env[]) _gnu_process_args(int argc, char *argv[], char *env[])
{ {
NSAutoreleasePool *arp = [NSAutoreleasePool new]; CREATE_AUTORELEASE_POOL(arp);
int i; int i;
if (_gnu_arg_zero != 0)
{
free(_gnu_arg_zero);
}
_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]);
/* Getting the process name */ /* Getting the process name */
IF_NO_GC(RELEASE(_gnu_processName));
_gnu_processName = [[NSString stringWithCString: argv[0]] lastPathComponent]; _gnu_processName = [[NSString stringWithCString: argv[0]] lastPathComponent];
IF_NO_GC(RETAIN(_gnu_processName)); IF_NO_GC(RETAIN(_gnu_processName));
@ -198,7 +203,9 @@ _gnu_process_args(int argc, char *argv[], char *env[])
else else
obj_argv[added++] = str; obj_argv[added++] = str;
} }
IF_NO_GC(RELEASE(_gnu_arguments));
_gnu_arguments = [[NSArray alloc] initWithObjects: obj_argv count: added]; _gnu_arguments = [[NSArray alloc] initWithObjects: obj_argv count: added];
IF_NO_GC(RELEASE(_debug_set));
_debug_set = mySet; _debug_set = mySet;
} }
@ -252,12 +259,13 @@ _gnu_process_args(int argc, char *argv[], char *env[])
#endif #endif
i++; i++;
} }
IF_NO_GC(RELEASE(_gnu_environment));
_gnu_environment = [[NSDictionary alloc] initWithObjects: values _gnu_environment = [[NSDictionary alloc] initWithObjects: values
forKeys: keys]; forKeys: keys];
[keys release]; IF_NO_GC(RELEASE(keys));
[values release]; IF_NO_GC(RELEASE(values));
} }
[arp release]; IF_NO_GC(RELEASE(arp));
} }
#if !GS_FAKE_MAIN && (defined(HAVE_PROCFS) && defined(HAVE_LOAD_METHOD)) #if !GS_FAKE_MAIN && (defined(HAVE_PROCFS) && defined(HAVE_LOAD_METHOD))
@ -753,16 +761,15 @@ int main(int argc, char *argv[], char *env[])
/** /**
* Fallback method. The developer must call this method to initialize * Fallback method. The developer must call this method to initialize
* the NSProcessInfo system if none of the system-specific hacks to * the NSProcessInfo system if none of the system-specific hacks to
* auto initiailise it are working. * auto-initialize it are working.
*/ */
+ (void) initializeWithArguments: (char**)argv + (void) initializeWithArguments: (char**)argv
count: (int)argc count: (int)argc
environment: (char**)env environment: (char**)env
{ {
if (!_gnu_processName && !_gnu_arguments && !_gnu_environment) [gnustep_global_lock lock];
{ _gnu_process_args(argc, argv, env);
_gnu_process_args(argc, argv, env); [gnustep_global_lock unlock];
}
} }
/** /**

View file

@ -492,13 +492,15 @@ main(int argc, char **argv, char **env)
NSMutableArray *sFiles = nil; // Source NSMutableArray *sFiles = nil; // Source
NSMutableArray *gFiles = nil; // GSDOC NSMutableArray *gFiles = nil; // GSDOC
NSMutableArray *hFiles = nil; // HTML NSMutableArray *hFiles = nil; // HTML
CREATE_AUTORELEASE_POOL(outer); #if GS_WITH_GC == 0
CREATE_AUTORELEASE_POOL(pool); NSAutoreleasePool *outer = nil;
NSAutoreleasePool *pool = nil;
#endif
RELEASE(pool);
#ifdef GS_PASS_ARGUMENTS
[NSProcessInfo initializeWithArguments: argv count: argc environment: env]; [NSProcessInfo initializeWithArguments: argv count: argc environment: env];
#if GS_WITH_GC == 0
outer = [NSAutoreleasePool new];
#endif #endif
#ifndef HAVE_LIBXML #ifndef HAVE_LIBXML
@ -1251,7 +1253,7 @@ main(int argc, char **argv, char **env)
file, gDate, hDate); file, gDate, hDate);
} }
parser = [GSXMLParser parserWithContentsOfFile: gsdocfile]; parser = [GSXMLParser parserWithContentsOfFile: gsdocfile];
[parser substituteEntities: NO]; [parser substituteEntities: YES];
[parser doValidityChecking: YES]; [parser doValidityChecking: YES];
[parser keepBlanks: NO]; [parser keepBlanks: NO];
if ([parser parse] == NO) if ([parser parse] == NO)