Not sure this is a good idea ... but allow the real environment to be

overridden when NSProcessInfo is initialised.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22142 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2005-12-05 08:37:16 +00:00
parent 92645ed803
commit 54f46448cc
2 changed files with 44 additions and 33 deletions

View file

@ -1,3 +1,9 @@
2005-12-05 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSProcessInfo.m: Allow
([+initializeWithArguments:count:environment:]) to override the real
environment on mingw32.
2005-12-02 Richard Frith-Macdonald <rfm@gnu.org> 2005-12-02 Richard Frith-Macdonald <rfm@gnu.org>
* configure.ac: Fix bug configuring whether GNUstep.conf can be * configure.ac: Fix bug configuring whether GNUstep.conf can be

View file

@ -290,47 +290,50 @@ _gnu_process_args(int argc, char *argv[], char *env[])
NSMutableArray *values = [NSMutableArray new]; NSMutableArray *values = [NSMutableArray new];
#if defined(__MINGW32__) #if defined(__MINGW32__)
unichar *base; if (fallbackInitialisation == NO)
base = GetEnvironmentStringsW();
if (base != 0)
{ {
const unichar *wenvp = base; unichar *base;
while (*wenvp != 0) base = GetEnvironmentStringsW();
if (base != 0)
{ {
const unichar *start = wenvp; const unichar *wenvp = base;
NSString *key;
NSString *val;
start = wenvp;
while (*wenvp != '=' && *wenvp != 0)
{
wenvp++;
}
if (*wenvp == '=')
{
key = [NSString stringWithCharacters: start
length: wenvp - start];
wenvp++;
start = wenvp;
}
else
{
break; // Bad format ... expected '='
}
while (*wenvp != 0) while (*wenvp != 0)
{ {
wenvp++; const unichar *start = wenvp;
NSString *key;
NSString *val;
start = wenvp;
while (*wenvp != '=' && *wenvp != 0)
{
wenvp++;
}
if (*wenvp == '=')
{
key = [NSString stringWithCharacters: start
length: wenvp - start];
wenvp++;
start = wenvp;
}
else
{
break; // Bad format ... expected '='
}
while (*wenvp != 0)
{
wenvp++;
}
val = [NSString stringWithCharacters: start
length: wenvp - start];
wenvp++; // Skip past variable terminator
[keys addObject: key];
[values addObject: val];
} }
val = [NSString stringWithCharacters: start FreeEnvironmentStringsW(base);
length: wenvp - start]; env = 0; // Suppress standard code.
wenvp++; // Skip past variable terminator
[keys addObject: key];
[values addObject: val];
} }
FreeEnvironmentStringsW(base);
env = 0; // Suppress standard code.
} }
#endif #endif
if (env != 0) if (env != 0)
@ -1055,6 +1058,7 @@ int main(int argc, char *argv[], char *env[])
@implementation NSProcessInfo (GNUstep) @implementation NSProcessInfo (GNUstep)
static BOOL debugTemporarilyDisabled = NO; static BOOL debugTemporarilyDisabled = NO;
static BOOL fallbackInitialisation = NO;
/** /**
* Fallback method. The developer must call this method to initialize * Fallback method. The developer must call this method to initialize
@ -1068,6 +1072,7 @@ static BOOL debugTemporarilyDisabled = NO;
environment: (char**)env environment: (char**)env
{ {
[gnustep_global_lock lock]; [gnustep_global_lock lock];
fallbackInitialisation = YES;
_gnu_process_args(argc, argv, env); _gnu_process_args(argc, argv, env);
[gnustep_global_lock unlock]; [gnustep_global_lock unlock];
} }