Commit b44ebda3 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Add strtok_s and wcstok_s.

Implementation copied from msvcrt. Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 7c70b939
...@@ -1604,6 +1604,7 @@ ...@@ -1604,6 +1604,7 @@
@ cdecl strrchr(str long) @ cdecl strrchr(str long)
@ cdecl strspn(str str) @ cdecl strspn(str str)
@ cdecl strstr(str str) @ cdecl strstr(str str)
@ cdecl strtok_s(str str ptr)
@ cdecl strtol(str ptr long) @ cdecl strtol(str ptr long)
@ cdecl strtoul(str ptr long) @ cdecl strtoul(str ptr long)
@ varargs swprintf(ptr wstr) NTDLL_swprintf @ varargs swprintf(ptr wstr) NTDLL_swprintf
...@@ -1637,6 +1638,7 @@ ...@@ -1637,6 +1638,7 @@
@ cdecl wcsspn(wstr wstr) @ cdecl wcsspn(wstr wstr)
@ cdecl wcsstr(wstr wstr) @ cdecl wcsstr(wstr wstr)
@ cdecl wcstok(wstr wstr) @ cdecl wcstok(wstr wstr)
@ cdecl wcstok_s(wstr wstr ptr)
@ cdecl wcstol(wstr ptr long) @ cdecl wcstol(wstr ptr long)
@ cdecl wcstombs(ptr ptr long) @ cdecl wcstombs(ptr ptr long)
@ cdecl wcstoul(wstr ptr long) @ cdecl wcstoul(wstr ptr long)
......
...@@ -795,6 +795,33 @@ int CDECL _tolower(int c) ...@@ -795,6 +795,33 @@ int CDECL _tolower(int c)
} }
/*********************************************************************
* strtok_s (NTDLL.@)
*/
char * __cdecl strtok_s( char *str, const char *delim, char **ctx )
{
char *next;
if (!delim || !ctx) return NULL;
if (!str)
{
str = *ctx;
if (!str) return NULL;
}
while (*str && strchr( delim, *str )) str++;
if (!*str)
{
*ctx = str;
return NULL;
}
next = str + 1;
while (*next && !strchr( delim, *next )) next++;
if (*next) *next++ = 0;
*ctx = next;
return str;
}
static int char_to_int( char c ) static int char_to_int( char c )
{ {
if ('0' <= c && c <= '9') return c - '0'; if ('0' <= c && c <= '9') return c - '0';
......
...@@ -456,6 +456,33 @@ LPWSTR __cdecl wcstok( LPWSTR str, LPCWSTR delim ) ...@@ -456,6 +456,33 @@ LPWSTR __cdecl wcstok( LPWSTR str, LPCWSTR delim )
/********************************************************************* /*********************************************************************
* wcstok_s (NTDLL.@)
*/
wchar_t * __cdecl wcstok_s( wchar_t *str, const wchar_t *delim, wchar_t **ctx )
{
wchar_t *next;
if (!delim || !ctx) return NULL;
if (!str)
{
str = *ctx;
if (!str) return NULL;
}
while (*str && wcschr( delim, *str )) str++;
if (!*str)
{
*ctx = str;
return NULL;
}
next = str + 1;
while (*next && !wcschr( delim, *next )) next++;
if (*next) *next++ = 0;
*ctx = next;
return str;
}
/*********************************************************************
* wcstombs (NTDLL.@) * wcstombs (NTDLL.@)
*/ */
size_t __cdecl wcstombs( char *dst, const WCHAR *src, size_t n ) size_t __cdecl wcstombs( char *dst, const WCHAR *src, size_t n )
......
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