Store mbstok() next pointer in the per-thread data.

This commit is contained in:
Alexandre Julliard 2003-02-01 00:59:22 +00:00
parent d76455df74
commit bb2210bc45
2 changed files with 4 additions and 3 deletions

View File

@ -557,7 +557,7 @@ unsigned char* _mbsrchr(const unsigned char* s, unsigned int x)
*/ */
unsigned char* _mbstok(unsigned char *str, const unsigned char *delim) unsigned char* _mbstok(unsigned char *str, const unsigned char *delim)
{ {
static char *next = NULL; MSVCRT_thread_data *data = msvcrt_get_thread_data();
char *ret; char *ret;
if(MSVCRT___mb_cur_max > 1) if(MSVCRT___mb_cur_max > 1)
@ -565,7 +565,7 @@ unsigned char* _mbstok(unsigned char *str, const unsigned char *delim)
unsigned int c; unsigned int c;
if (!str) if (!str)
if (!(str = next)) return NULL; if (!(str = data->mbstok_next)) return NULL;
while ((c = _mbsnextc(str)) && _mbschr(delim, c)) { while ((c = _mbsnextc(str)) && _mbschr(delim, c)) {
str += c > 255 ? 2 : 1; str += c > 255 ? 2 : 1;
@ -579,7 +579,7 @@ unsigned char* _mbstok(unsigned char *str, const unsigned char *delim)
*str++ = 0; *str++ = 0;
if (c > 255) *str++ = 0; if (c > 255) *str++ = 0;
} }
next = str; data->mbstok_next = str;
return ret; return ret;
} }
return strtok(str, delim); /* ASCII CP */ return strtok(str, delim); /* ASCII CP */

View File

@ -38,6 +38,7 @@ typedef struct __MSVCRT_thread_data
{ {
int errno; int errno;
unsigned long doserrno; unsigned long doserrno;
char *mbstok_next; /* next ptr for mbstok() */
terminate_function terminate_handler; terminate_function terminate_handler;
unexpected_function unexpected_handler; unexpected_function unexpected_handler;
_se_translator_function se_translator; _se_translator_function se_translator;