Commit 32bbef5d authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

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=30244Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com> Signed-off-by: 's avatarPiotr Caban <piotr@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 6c39e731
......@@ -1910,10 +1910,13 @@ wchar_t * CDECL wcstok_s( wchar_t *str, const wchar_t *delim,
if (!str) str = *next_token;
while (*str && wcschr( delim, *str )) str++;
if (!*str) return NULL;
ret = str++;
while (*str && !wcschr( delim, *str )) str++;
if (*str) *str++ = 0;
if (!*str) ret = NULL;
else
{
ret = str++;
while (*str && !wcschr( delim, *str )) str++;
if (*str) *str++ = 0;
}
*next_token = str;
return ret;
}
......
......@@ -418,6 +418,24 @@ static void test_wcstok(void)
ok(!wcscmp(L"words", token), "expected \"words\", got \"%ls\"\n", token);
token = wcstok(NULL, L" ", NULL);
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)
......
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