diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index 4b5300fc19a..800fc319983 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -1653,7 +1653,7 @@ @ cdecl wcsstr(wstr wstr) msvcrt.wcsstr @ cdecl wcstod(wstr ptr) msvcrt.wcstod @ cdecl wcstok(wstr wstr) msvcrt.wcstok -@ stub wcstok_s +@ cdecl wcstok_s(ptr wstr ptr) msvcrt.wcstok_s @ cdecl wcstol(wstr ptr long) msvcrt.wcstol @ cdecl wcstombs(ptr ptr long) msvcrt.wcstombs @ cdecl wcstombs_s(ptr ptr long wstr long) msvcrt.wcstombs_s diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index 639c14db5dc..5dfce034f69 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -1507,7 +1507,7 @@ @ cdecl wcsstr(wstr wstr) msvcrt.wcsstr @ cdecl wcstod(wstr ptr) msvcrt.wcstod @ cdecl wcstok(wstr wstr) msvcrt.wcstok -@ stub wcstok_s +@ cdecl wcstok_s(ptr wstr ptr) msvcrt.wcstok_s @ cdecl wcstol(wstr ptr long) msvcrt.wcstol @ cdecl wcstombs(ptr ptr long) msvcrt.wcstombs @ cdecl wcstombs_s(ptr ptr long wstr long) msvcrt.wcstombs_s diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index 19a0ec931bb..2e63ad7e665 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -1491,7 +1491,7 @@ @ cdecl wcsstr(wstr wstr) msvcrt.wcsstr @ cdecl wcstod(wstr ptr) msvcrt.wcstod @ cdecl wcstok(wstr wstr) msvcrt.wcstok -@ stub wcstok_s +@ cdecl wcstok_s(ptr wstr ptr) msvcrt.wcstok_s @ cdecl wcstol(wstr ptr long) msvcrt.wcstol @ cdecl wcstombs(ptr ptr long) msvcrt.wcstombs @ cdecl wcstombs_s(ptr ptr long wstr long) msvcrt.wcstombs_s diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 10a8870f3bd..70d28ce1f25 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -1457,7 +1457,7 @@ @ cdecl wcsstr(wstr wstr) ntdll.wcsstr @ cdecl wcstod(wstr ptr) MSVCRT_wcstod @ cdecl wcstok(wstr wstr) MSVCRT_wcstok -# stub wcstok_s +@ cdecl wcstok_s(ptr wstr ptr) @ cdecl wcstol(wstr ptr long) ntdll.wcstol @ cdecl wcstombs(ptr ptr long) MSVCRT_wcstombs @ cdecl wcstombs_s(ptr ptr long wstr long) MSVCRT_wcstombs_s diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c index 1042008d3e9..48831b25d5d 100644 --- a/dlls/msvcrt/wcs.c +++ b/dlls/msvcrt/wcs.c @@ -1368,25 +1368,37 @@ MSVCRT_wchar_t* CDECL MSVCRT_wcspbrk( const MSVCRT_wchar_t* str, const MSVCRT_wc } /********************************************************************* - * wcstok (MSVCRT.@) + * wcstok_s (MSVCRT.@) */ -MSVCRT_wchar_t * CDECL MSVCRT_wcstok( MSVCRT_wchar_t *str, const MSVCRT_wchar_t *delim ) +MSVCRT_wchar_t * CDECL wcstok_s( MSVCRT_wchar_t *str, const MSVCRT_wchar_t *delim, + MSVCRT_wchar_t **next_token ) { - thread_data_t *data = msvcrt_get_thread_data(); MSVCRT_wchar_t *ret; - if (!str) - if (!(str = data->wcstok_next)) return NULL; + if (!MSVCRT_CHECK_PMT(delim != NULL) || !MSVCRT_CHECK_PMT(next_token != NULL) || + !MSVCRT_CHECK_PMT(str != NULL || *next_token != NULL)) + { + *MSVCRT__errno() = MSVCRT_EINVAL; + return NULL; + } + if (!str) str = *next_token; while (*str && strchrW( delim, *str )) str++; if (!*str) return NULL; ret = str++; while (*str && !strchrW( delim, *str )) str++; if (*str) *str++ = 0; - data->wcstok_next = str; + *next_token = str; return ret; } +/********************************************************************* + * wcstok (MSVCRT.@) + */ +MSVCRT_wchar_t * CDECL MSVCRT_wcstok( MSVCRT_wchar_t *str, const MSVCRT_wchar_t *delim ) +{ + return wcstok_s(str, delim, &msvcrt_get_thread_data()->wcstok_next); +} /********************************************************************* * wctomb (MSVCRT.@)