Commit ca7a1139 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Factor out env_get_index helper.

parent 52b88199
......@@ -25,25 +25,28 @@
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
static char * getenv_helper(const char *name)
static int env_get_index(const char *name)
{
char **env;
size_t len;
int i, len;
if (!name) return NULL;
len = strlen(name);
for (env = MSVCRT__environ; *env; env++)
for (i = 0; MSVCRT__environ[i]; i++)
{
char *str = *env;
char *pos = strchr(str,'=');
if (pos && ((pos - str) == len) && !_strnicmp(str, name, len))
{
TRACE("(%s): got %s\n", debugstr_a(name), debugstr_a(pos + 1));
return pos + 1;
}
if (!strncmp(name, MSVCRT__environ[i], len) && MSVCRT__environ[i][len] == '=')
return i;
}
return NULL;
return i;
}
static char * getenv_helper(const char *name)
{
int idx;
if (!name) return NULL;
idx = env_get_index(name);
if (!MSVCRT__environ[idx]) return NULL;
return strchr(MSVCRT__environ[idx], '=') + 1;
}
/*********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment