Launching Rider on macOS

* Fixing issues where when the editor would try and launch rider on an M1/2 machine it would not properly open because it was the wrong architecture which is now resolved because open will do the right thing
* Making the ParseArgs function a little more resilient against escaped arguments
This commit is contained in:
Andrew Spiering
2023-09-20 23:16:38 -07:00
parent da7ba0ecba
commit d4c71b5fd9
2 changed files with 36 additions and 15 deletions

View File

@@ -85,27 +85,34 @@ NSString* AppleUtils::ToNSString(const char* string)
NSArray* AppleUtils::ParseArguments(NSString* argsString) {
NSMutableArray *argsArray = [NSMutableArray array];
NSScanner *scanner = [NSScanner scannerWithString:argsString];
NSString *currentArg = nil;
NSMutableString *currentArg = [NSMutableString string];
BOOL insideQuotes = NO;
while (![scanner isAtEnd]) {
if (insideQuotes) {
[scanner scanUpToString:@"\"" intoString:&currentArg];
[scanner scanString:@"\"" intoString:NULL];
insideQuotes = NO;
} else {
[scanner scanUpToString:@" " intoString:&currentArg];
[scanner scanString:@" " intoString:NULL];
}
for (NSInteger i = 0; i < argsString.length; ++i) {
unichar c = [argsString characterAtIndex:i];
if ([currentArg isEqualToString:@"\""]) {
insideQuotes = YES;
} else if (currentArg) {
[argsArray addObject:currentArg];
if (c == '\"') {
if (insideQuotes) {
[argsArray addObject:[currentArg copy]];
[currentArg setString:@""];
insideQuotes = NO;
} else {
insideQuotes = YES;
}
} else if (c == ' ' && !insideQuotes) {
if (currentArg.length > 0) {
[argsArray addObject:[currentArg copy]];
[currentArg setString:@""];
}
} else {
[currentArg appendFormat:@"%C", c];
}
}
if (currentArg.length > 0) {
[argsArray addObject:[currentArg copy]];
}
return [argsArray copy];
}