From 8fc53ea1d7fb07b6c5ceb973026a37ac9e5c720c Mon Sep 17 00:00:00 2001 From: Jean Raby Date: Mon, 14 Jan 2013 16:58:19 -0500 Subject: [PATCH] sanitizedArguments fixes Various style fixes Don't use the foreach loop as it might break on old gcc/objc runtimes Release sanitizedArguments in dealloc --- Tools/SOGoTool.m | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Tools/SOGoTool.m b/Tools/SOGoTool.m index 9a56debee..1091f6bad 100644 --- a/Tools/SOGoTool.m +++ b/Tools/SOGoTool.m @@ -22,6 +22,7 @@ #import #import +#import #import #import @@ -76,15 +77,21 @@ - (void) setSanitizedArguments: (NSArray *) newArguments { - NSCharacterSet *whitespaces = [NSCharacterSet whitespaceCharacterSet]; NSString *argsString = [newArguments componentsJoinedByString:@" "]; NSDictionary *cliArguments; + NSArray *keys; + + int i; + + argsString = [newArguments componentsJoinedByString:@" "]; /* Remove NSArgumentDomain -key value from the arguments */ cliArguments = [[NSUserDefaults standardUserDefaults] volatileDomainForName:NSArgumentDomain]; - for (NSString *k in cliArguments) + keys = [cliArguments allKeys]; + for (i=0; i < [keys count]; i++) { + NSString *k = [keys objectAtIndex: i]; NSString *v = [cliArguments objectForKey:k]; NSString *argPair = [NSString stringWithFormat:@"-%@ %@", k, v]; argsString = [argsString stringByReplacingOccurrencesOfString: argPair @@ -93,7 +100,8 @@ if ([argsString length]) { /* dance to compact whitespace */ - NSArray *wordsWP = [argsString componentsSeparatedByCharactersInSet: whitespaces]; + NSArray *wordsWP = [argsString componentsSeparatedByCharactersInSet: + [NSCharacterSet whitespaceCharacterSet]]; NSMutableArray *words = [NSMutableArray array]; for (NSString *word in wordsWP) { @@ -107,7 +115,7 @@ } else { - ASSIGN (sanitizedArguments, nil); + DESTROY(sanitizedArguments); } } @@ -120,6 +128,7 @@ - (void) dealloc { [arguments release]; + [sanitizedArguments release]; [super dealloc]; }