2016-08-21 16:24:00 +00:00
|
|
|
/* Taken from Wine Staging msvcrt/string.c */
|
|
|
|
|
|
|
|
#include <precomp.h>
|
|
|
|
#include <internal/wine/msvcrt.h>
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strtok_s (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
char * CDECL strtok_s(char *str, const char *delim, char **ctx)
|
|
|
|
{
|
|
|
|
if (!MSVCRT_CHECK_PMT(delim != NULL)) return NULL;
|
|
|
|
if (!MSVCRT_CHECK_PMT(ctx != NULL)) return NULL;
|
|
|
|
if (!MSVCRT_CHECK_PMT(str != NULL || *ctx != NULL)) return NULL;
|
|
|
|
|
|
|
|
if(!str)
|
|
|
|
str = *ctx;
|
|
|
|
|
|
|
|
while(*str && strchr(delim, *str))
|
|
|
|
str++;
|
|
|
|
if(!*str)
|
2016-08-21 16:30:06 +00:00
|
|
|
{
|
|
|
|
*ctx = str;
|
2016-08-21 16:24:00 +00:00
|
|
|
return NULL;
|
2016-08-21 16:30:06 +00:00
|
|
|
}
|
2016-08-21 16:24:00 +00:00
|
|
|
|
|
|
|
*ctx = str+1;
|
|
|
|
while(**ctx && !strchr(delim, **ctx))
|
|
|
|
(*ctx)++;
|
|
|
|
if(**ctx)
|
|
|
|
*(*ctx)++ = 0;
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|