msvcrt: Set next_token when str is empty in wcstok_s.
Otherwise, when str is empty, an invalid parameter exception is raised.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=30244
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 32bbef5d3e
)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
This commit is contained in:
parent
7f1d6a8ee2
commit
9ef3ca8b2d
|
@ -1910,10 +1910,13 @@ wchar_t * CDECL wcstok_s( wchar_t *str, const wchar_t *delim,
|
||||||
if (!str) str = *next_token;
|
if (!str) str = *next_token;
|
||||||
|
|
||||||
while (*str && wcschr( delim, *str )) str++;
|
while (*str && wcschr( delim, *str )) str++;
|
||||||
if (!*str) return NULL;
|
if (!*str) ret = NULL;
|
||||||
ret = str++;
|
else
|
||||||
while (*str && !wcschr( delim, *str )) str++;
|
{
|
||||||
if (*str) *str++ = 0;
|
ret = str++;
|
||||||
|
while (*str && !wcschr( delim, *str )) str++;
|
||||||
|
if (*str) *str++ = 0;
|
||||||
|
}
|
||||||
*next_token = str;
|
*next_token = str;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -418,6 +418,24 @@ static void test_wcstok(void)
|
||||||
ok(!wcscmp(L"words", token), "expected \"words\", got \"%ls\"\n", token);
|
ok(!wcscmp(L"words", token), "expected \"words\", got \"%ls\"\n", token);
|
||||||
token = wcstok(NULL, L" ", NULL);
|
token = wcstok(NULL, L" ", NULL);
|
||||||
ok(!token, "expected NULL, got %p\n", token);
|
ok(!token, "expected NULL, got %p\n", token);
|
||||||
|
|
||||||
|
next = NULL;
|
||||||
|
wcscpy(buffer, input);
|
||||||
|
token = wcstok(buffer, L"=", &next);
|
||||||
|
ok(!wcscmp(token, input), "expected \"%ls\", got \"%ls\"\n", input, token);
|
||||||
|
ok(next == buffer + wcslen(input), "expected %p, got %p\n", buffer + wcslen(input), next);
|
||||||
|
token = wcstok(NULL, L"=", &next);
|
||||||
|
ok(!token, "expected NULL, got \"%ls\"\n", token);
|
||||||
|
ok(next == buffer + wcslen(input), "expected %p, got %p\n", buffer + wcslen(input), next);
|
||||||
|
|
||||||
|
next = NULL;
|
||||||
|
wcscpy(buffer, L"");
|
||||||
|
token = wcstok(buffer, L"=", &next);
|
||||||
|
ok(token == NULL, "expected NULL, got \"%ls\"\n", token);
|
||||||
|
ok(next == buffer, "expected %p, got %p\n", buffer, next);
|
||||||
|
token = wcstok(NULL, L"=", &next);
|
||||||
|
ok(!token, "expected NULL, got \"%ls\"\n", token);
|
||||||
|
ok(next == buffer, "expected %p, got %p\n", buffer, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test__strnicmp(void)
|
static void test__strnicmp(void)
|
||||||
|
|
Loading…
Reference in New Issue