Always use UTF16 arguments on windows

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22830 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2006-04-26 15:33:47 +00:00
parent 87c36691ca
commit 93de83a6a6
2 changed files with 61 additions and 61 deletions

View file

@ -7,6 +7,7 @@
* Source/NSCalendarDate.m: Correction to millisecond fix ... for * Source/NSCalendarDate.m: Correction to millisecond fix ... for
bug #16426 bug #16426
* Resources/GNUmakefile: Fix installation of Ukrainian language. * Resources/GNUmakefile: Fix installation of Ukrainian language.
* Source/NSProcessInfo.m: Always use UTF16 args on mingw32.
2006-04-26 Hubert Chan 2006-04-26 Hubert Chan

View file

@ -267,69 +267,68 @@ _gnu_process_args(int argc, char *argv[], char *env[])
_gnu_processName = [arg0 lastPathComponent]; _gnu_processName = [arg0 lastPathComponent];
IF_NO_GC(RETAIN(_gnu_processName)); IF_NO_GC(RETAIN(_gnu_processName));
/* Copy the argument list */ /* Copy the argument list */
if (argv)
{
NSString *str;
NSMutableSet *mySet;
id obj_argv[argc];
int added = 1;
mySet = [NSMutableSet new];
/* Copy the zero'th argument to the argument list */
obj_argv[0] = arg0;
for (i = 1; i < argc; i++)
{
str = [NSString stringWithCString: argv[i]];
if ([str hasPrefix: @"--GNU-Debug="])
[mySet addObject: [str substringFromIndex: 12]];
else
obj_argv[added++] = str;
}
IF_NO_GC(RELEASE(_gnu_arguments));
_gnu_arguments = [[NSArray alloc] initWithObjects: obj_argv count: added];
IF_NO_GC(RELEASE(_debug_set));
_debug_set = mySet;
RELEASE(arg0);
}
#if defined(__MINGW32__) #if defined(__MINGW32__)
// It appears that in some versions of mingw32 __argv is no longer supported {
// However GetCommandLine always works. Perhaps this should be the default case unichar **argvw = CommandLineToArgvW(GetCommandLineW(), &argc);
// as it is unicode. NSString *str;
else NSMutableSet *mySet;
{ id obj_argv[argc];
unichar **argvw = CommandLineToArgvW(GetCommandLineW(), &argc); int added = 1;
NSString *str;
NSMutableSet *mySet; mySet = [NSMutableSet new];
id obj_argv[argc];
int added = 1; /* Copy the zero'th argument to the argument list */
obj_argv[0] = arg0;
mySet = [NSMutableSet new];
for (i = 1; i < argc; i++)
/* Copy the zero'th argument to the argument list */ {
obj_argv[0] = arg0; str = [NSString stringWithCharacters: argvw[i] length: wcslen(argvw[i])];
if ([str hasPrefix: @"--GNU-Debug="])
for (i = 1; i < argc; i++) {
{ [mySet addObject: [str substringFromIndex: 12]];
str = [NSString stringWithCharacters: argvw[i] length: wcslen(argvw[i])]; }
if ([str hasPrefix: @"--GNU-Debug="]) else
[mySet addObject: [str substringFromIndex: 12]]; {
else obj_argv[added++] = str;
obj_argv[added++] = str; }
} }
IF_NO_GC(RELEASE(_gnu_arguments)); 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)); IF_NO_GC(RELEASE(_debug_set));
_debug_set = mySet; _debug_set = mySet;
RELEASE(arg0); RELEASE(arg0);
} }
#else
if (argv)
{
NSString *str;
NSMutableSet *mySet;
id obj_argv[argc];
int added = 1;
mySet = [NSMutableSet new];
/* Copy the zero'th argument to the argument list */
obj_argv[0] = arg0;
for (i = 1; i < argc; i++)
{
str = [NSString stringWithCString: argv[i]];
if ([str hasPrefix: @"--GNU-Debug="])
[mySet addObject: [str substringFromIndex: 12]];
else
obj_argv[added++] = str;
}
IF_NO_GC(RELEASE(_gnu_arguments));
_gnu_arguments = [[NSArray alloc] initWithObjects: obj_argv count: added];
IF_NO_GC(RELEASE(_debug_set));
_debug_set = mySet;
RELEASE(arg0);
}
#endif #endif
/* Copy the evironment list */ /* Copy the evironment list */