Commit 1d0cca46 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Add support for quoted paths in _searchenv.

parent f17a228d
......@@ -1683,12 +1683,27 @@ void CDECL MSVCRT__searchenv(const char* file, const char* env, char *buf)
for(; *penv; penv = (*end ? end + 1 : end))
{
end = penv;
while(*end && *end != ';') end++; /* Find end of next path */
path_len = end - penv;
path_len = 0;
while(*end && *end != ';' && path_len < MAX_PATH)
{
if (*end == '"')
{
end++;
while(*end && *end != '"' && path_len < MAX_PATH)
{
path[path_len++] = *end;
end++;
}
if (*end == '"') end++;
continue;
}
path[path_len++] = *end;
end++;
}
if (!path_len || path_len >= MAX_PATH)
continue;
memcpy(path, penv, path_len);
if (path[path_len - 1] != '/' && path[path_len - 1] != '\\')
path[path_len++] = '\\';
if (path_len + fname_len >= MAX_PATH)
......
......@@ -597,6 +597,20 @@ static void test_searchenv(void)
ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp);
}
strcpy(env1, "TEST_PATH=");
strcat(env1, tmppath);
strcat(env1, "\"\\search_env_test\\\"d\"i\"r\"1");
putenv(env1);
strcpy(exp, tmppath);
strcat(exp, files[0]);
_searchenv("1.dat", "TEST_PATH", result);
ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp);
strcat(env1, ";");
putenv(env1);
_searchenv("1.dat", "TEST_PATH", result);
ok(!result[0], "got %s, expected ''\n", result);
putenv("TEST_PATH=");
for (i=ARRAY_SIZE(files)-1; i>=0; i--) {
......
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