msvcrt: Update search position when no token was found in strtok.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2021-05-25 18:00:15 +02:00 committed by Alexandre Julliard
parent 32bbef5d3e
commit bf7244442d
2 changed files with 13 additions and 1 deletions

View File

@ -287,7 +287,11 @@ char * CDECL strtok( char *str, const char *delim )
if (!(str = data->strtok_next)) return NULL;
while (*str && strchr( delim, *str )) str++;
if (!*str) return NULL;
if (!*str)
{
data->strtok_next = str;
return NULL;
}
ret = str++;
while (*str && !strchr( delim, *str )) str++;
if (*str) *str++ = 0;

View File

@ -1685,6 +1685,14 @@ static void test_strtok(void)
"third call string (%p) \'%s\' return %p\n",
teststr, testcases_strtok[i].string, strret);
}
strcpy( teststr, "test a=b" );
strret = strtok( teststr, " " );
ok( strret == teststr, "strret = %p, expected %p\n", strret, teststr );
strret = strtok( NULL, "ab=" );
ok( !strret, "strret = %p, expected NULL\n", strret );
strret = strtok( NULL, "=" );
ok( !strret, "strret = %p, expected NULL\n", strret );
}
static void test_strtol(void)