msvcrt: Initialize _wenviron in Unicode environment getter function.
This commit is contained in:
parent
797d6cb4e2
commit
eb09472870
|
@ -34,7 +34,7 @@ char * CDECL MSVCRT_getenv(const char *name)
|
|||
char **environ;
|
||||
unsigned int length=strlen(name);
|
||||
|
||||
for (environ = *__p__environ(); *environ; environ++)
|
||||
for (environ = MSVCRT__environ; *environ; environ++)
|
||||
{
|
||||
char *str = *environ;
|
||||
char *pos = strchr(str,'=');
|
||||
|
@ -55,7 +55,11 @@ MSVCRT_wchar_t * CDECL _wgetenv(const MSVCRT_wchar_t *name)
|
|||
MSVCRT_wchar_t **environ;
|
||||
unsigned int length=strlenW(name);
|
||||
|
||||
for (environ = *__p__wenviron(); *environ; environ++)
|
||||
/* Initialize the _wenviron array if it's not already created. */
|
||||
if (!MSVCRT__wenviron)
|
||||
MSVCRT__wenviron = msvcrt_SnapshotOfEnvironmentW(NULL);
|
||||
|
||||
for (environ = MSVCRT__wenviron; *environ; environ++)
|
||||
{
|
||||
MSVCRT_wchar_t *str = *environ;
|
||||
MSVCRT_wchar_t *pos = strchrW(str,'=');
|
||||
|
|
|
@ -125,6 +125,9 @@ static void test__environ(void)
|
|||
|
||||
static void test__wenviron(void)
|
||||
{
|
||||
static const WCHAR cat_eq_dogW[] = {'c','a','t','=','d','o','g',0};
|
||||
static const WCHAR cat_eqW[] = {'c','a','t','=',0};
|
||||
|
||||
int argc;
|
||||
char **argv, **envp = NULL;
|
||||
WCHAR **wargv, **wenvp = NULL;
|
||||
|
@ -166,6 +169,10 @@ static void test__wenviron(void)
|
|||
|
||||
/* _wenviron isn't initialized until __wgetmainargs is called or
|
||||
* one of the Unicode environment manipulation functions is called. */
|
||||
ok( _wputenv(cat_eq_dogW) == 0, "failed setting cat=dog\n" );
|
||||
ok( *p_wenviron != NULL, "Expected _wenviron to be non-NULL\n" );
|
||||
ok( _wputenv(cat_eqW) == 0, "failed deleting cat\n" );
|
||||
|
||||
__wgetmainargs(&argc, &wargv, &wenvp, 0, &mode);
|
||||
|
||||
ok( *p_wenviron != NULL, "Expected _wenviron to be non-NULL\n" );
|
||||
|
|
Loading…
Reference in New Issue