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

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

parent 32bbef5d
...@@ -287,7 +287,11 @@ char * CDECL strtok( char *str, const char *delim ) ...@@ -287,7 +287,11 @@ char * CDECL strtok( char *str, const char *delim )
if (!(str = data->strtok_next)) return NULL; if (!(str = data->strtok_next)) return NULL;
while (*str && strchr( delim, *str )) str++; while (*str && strchr( delim, *str )) str++;
if (!*str) return NULL; if (!*str)
{
data->strtok_next = str;
return NULL;
}
ret = str++; ret = str++;
while (*str && !strchr( delim, *str )) str++; while (*str && !strchr( delim, *str )) str++;
if (*str) *str++ = 0; if (*str) *str++ = 0;
......
...@@ -1685,6 +1685,14 @@ static void test_strtok(void) ...@@ -1685,6 +1685,14 @@ static void test_strtok(void)
"third call string (%p) \'%s\' return %p\n", "third call string (%p) \'%s\' return %p\n",
teststr, testcases_strtok[i].string, strret); 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) static void test_strtol(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