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:
Richard Frith-Macdonald 2005-12-05 08:37:16 +00:00
parent e85198f38b
commit 35f73b6833
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>
* 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];
#if defined(__MINGW32__)
unichar *base;
base = GetEnvironmentStringsW();
if (base != 0)
if (fallbackInitialisation == NO)
{
const unichar *wenvp = base;
unichar *base;
while (*wenvp != 0)
base = GetEnvironmentStringsW();
if (base != 0)
{
const unichar *start = wenvp;
NSString *key;
NSString *val;
const unichar *wenvp = base;
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++;
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
length: wenvp - start];
wenvp++; // Skip past variable terminator
[keys addObject: key];
[values addObject: val];
FreeEnvironmentStringsW(base);
env = 0; // Suppress standard code.
}
FreeEnvironmentStringsW(base);
env = 0; // Suppress standard code.
}
#endif
if (env != 0)
@ -1055,6 +1058,7 @@ int main(int argc, char *argv[], char *env[])
@implementation NSProcessInfo (GNUstep)
static BOOL debugTemporarilyDisabled = NO;
static BOOL fallbackInitialisation = NO;
/**
* Fallback method. The developer must call this method to initialize
@ -1068,6 +1072,7 @@ static BOOL debugTemporarilyDisabled = NO;
environment: (char**)env
{
[gnustep_global_lock lock];
fallbackInitialisation = YES;
_gnu_process_args(argc, argv, env);
[gnustep_global_lock unlock];
}