msvcrt: Added _mbstok_s_l implementation.

This commit is contained in:
Piotr Caban 2013-04-30 14:29:11 +02:00 committed by Alexandre Julliard
parent a5f525276f
commit ff7388ca3f
7 changed files with 77 additions and 48 deletions

View File

@ -1183,9 +1183,9 @@
@ cdecl _mbsstr(str str) msvcrt._mbsstr
@ stub _mbsstr_l
@ cdecl _mbstok(str str) msvcrt._mbstok
@ stub _mbstok_l
@ stub _mbstok_s
@ stub _mbstok_s_l
@ cdecl _mbstok_l(str str ptr) msvcrt._mbstok_l
@ cdecl _mbstok_s(str str ptr) msvcrt._mbstok_s
@ cdecl _mbstok_s_l(str str ptr ptr) msvcrt._mbstok_s_l
@ cdecl _mbstowcs_l(ptr str long ptr) msvcrt._mbstowcs_l
@ cdecl _mbstowcs_s_l(ptr ptr long str long ptr) msvcrt._mbstowcs_s_l
@ cdecl _mbstrlen(str) msvcrt._mbstrlen

View File

@ -1545,9 +1545,9 @@
@ cdecl _mbsstr(str str) msvcrt._mbsstr
@ stub _mbsstr_l
@ cdecl _mbstok(str str) msvcrt._mbstok
@ stub _mbstok_l
@ stub _mbstok_s
@ stub _mbstok_s_l
@ cdecl _mbstok_l(str str ptr) msvcrt._mbstok_l
@ cdecl _mbstok_s(str str ptr) msvcrt._mbstok_s
@ cdecl _mbstok_s_l(str str ptr ptr) msvcrt._mbstok_s_l
@ cdecl _mbstowcs_l(ptr str long ptr) msvcrt._mbstowcs_l
@ cdecl _mbstowcs_s_l(ptr ptr long str long ptr) msvcrt._mbstowcs_s_l
@ cdecl _mbstrlen(str) msvcrt._mbstrlen

View File

@ -854,9 +854,9 @@
@ cdecl _mbsstr(str str) msvcrt._mbsstr
@ stub _mbsstr_l
@ cdecl _mbstok(str str) msvcrt._mbstok
@ stub _mbstok_l
@ stub _mbstok_s
@ stub _mbstok_s_l
@ cdecl _mbstok_l(str str ptr) msvcrt._mbstok_l
@ cdecl _mbstok_s(str str ptr) msvcrt._mbstok_s
@ cdecl _mbstok_s_l(str str ptr ptr) msvcrt._mbstok_s_l
@ cdecl _mbstowcs_l(ptr str long ptr) msvcrt._mbstowcs_l
@ cdecl _mbstowcs_s_l(ptr ptr long str long ptr) msvcrt._mbstowcs_s_l
@ cdecl _mbstrlen(str) msvcrt._mbstrlen

View File

@ -832,9 +832,9 @@
@ cdecl _mbsstr(str str) msvcrt._mbsstr
@ stub _mbsstr_l
@ cdecl _mbstok(str str) msvcrt._mbstok
@ stub _mbstok_l
@ stub _mbstok_s
@ stub _mbstok_s_l
@ cdecl _mbstok_l(str str ptr) msvcrt._mbstok_l
@ cdecl _mbstok_s(str str ptr) msvcrt._mbstok_s
@ cdecl _mbstok_s_l(str str ptr ptr) msvcrt._mbstok_s_l
@ cdecl _mbstowcs_l(ptr str long ptr) msvcrt._mbstowcs_l
@ cdecl _mbstowcs_s_l(ptr ptr long str long ptr) msvcrt._mbstowcs_s_l
@ cdecl _mbstrlen(str) msvcrt._mbstrlen

View File

@ -145,11 +145,6 @@ static inline unsigned char *u_strrchr( const unsigned char *s, unsigned char x
return (unsigned char*) strrchr( (const char*)s, x );
}
static inline unsigned char *u_strtok( unsigned char *s, const unsigned char *delim )
{
return (unsigned char*) strtok( (char*)s, (const char*)delim );
}
static inline unsigned char *u__strset( unsigned char *s, unsigned char c )
{
return (unsigned char*) _strset( (char*)s, c);
@ -1089,39 +1084,72 @@ unsigned char* CDECL _mbsrchr(const unsigned char* s, unsigned int x)
return u_strrchr(s, x);
}
/*********************************************************************
* _mbstok_s_l(MSVCRT.@)
*/
unsigned char* CDECL _mbstok_s_l(unsigned char *str, const unsigned char *delim,
unsigned char **ctx, MSVCRT__locale_t locale)
{
MSVCRT_pthreadmbcinfo mbcinfo;
unsigned int c;
if(!MSVCRT_CHECK_PMT(delim != NULL)) return NULL;
if(!MSVCRT_CHECK_PMT(ctx != NULL)) return NULL;
if(!MSVCRT_CHECK_PMT(str || *ctx)) return NULL;
if(locale)
mbcinfo = locale->mbcinfo;
else
mbcinfo = get_mbcinfo();
if(!mbcinfo->ismbcodepage)
return (unsigned char*)MSVCRT_strtok_s((char*)str, (const char*)delim, (char**)ctx);
if(!str)
str = *ctx;
while((c=_mbsnextc(str)) && _mbschr(delim, c))
str += c>255 ? 2 : 1;
if(!*str)
return NULL;
*ctx = str + (c>255 ? 2 : 1);
while((c=_mbsnextc(*ctx)) && !_mbschr(delim, c))
*ctx += c>255 ? 2 : 1;
if (**ctx) {
*(*ctx)++ = 0;
if(c > 255)
*(*ctx)++ = 0;
}
return str;
}
/*********************************************************************
* _mbstok_s(MSVCRT.@)
*/
unsigned char* CDECL _mbstok_s(unsigned char *str,
const unsigned char *delim, unsigned char **ctx)
{
return _mbstok_s_l(str, delim, ctx, NULL);
}
/*********************************************************************
* _mbstok_l(MSVCRT.@)
*/
unsigned char* CDECL _mbstok_l(unsigned char *str,
const unsigned char *delim, MSVCRT__locale_t locale)
{
return _mbstok_s_l(str, delim, &msvcrt_get_thread_data()->mbstok_next, locale);
}
/*********************************************************************
* _mbstok(MSVCRT.@)
*
* Find and extract tokens from strings
*/
unsigned char* CDECL _mbstok(unsigned char *str, const unsigned char *delim)
{
thread_data_t *data = msvcrt_get_thread_data();
unsigned char *ret;
if(get_mbcinfo()->ismbcodepage)
{
unsigned int c;
if (!str)
if (!(str = data->mbstok_next)) return NULL;
while ((c = _mbsnextc(str)) && _mbschr(delim, c)) {
str += c > 255 ? 2 : 1;
}
if (!*str) return NULL;
ret = str++;
while ((c = _mbsnextc(str)) && !_mbschr(delim, c)) {
str += c > 255 ? 2 : 1;
}
if (*str) {
*str++ = 0;
if (c > 255) *str++ = 0;
}
data->mbstok_next = str;
return ret;
}
return u_strtok(str, delim); /* ASCII CP */
return _mbstok_s_l(str, delim, &msvcrt_get_thread_data()->mbstok_next, NULL);
}
/*********************************************************************

View File

@ -989,6 +989,7 @@ int __cdecl MSVCRT__tolower_l(int,MSVCRT__locale_t);
int __cdecl MSVCRT__strnicoll_l(const char*, const char*, MSVCRT_size_t, MSVCRT__locale_t);
int __cdecl MSVCRT__strncoll_l(const char*, const char*, MSVCRT_size_t, MSVCRT__locale_t);
unsigned int __cdecl _get_output_format(void);
char* __cdecl MSVCRT_strtok_s(char*, const char*, char**);
/* Maybe one day we'll enable the invalid parameter handlers with the full set of information (msvcrXXd)
* #define MSVCRT_INVALID_PMT(x) MSVCRT_call_invalid_parameter_handler(x, __FUNCTION__, __FILE__, __LINE__, 0)

View File

@ -808,9 +808,9 @@
@ cdecl _mbsstr(str str)
# stub _mbsstr_l(str str ptr)
@ cdecl _mbstok(str str)
# stub _mbstok_l(str str ptr)
# stub _mbstok_s(str str ptr)
# stub _mbstok_s_l(str str ptr ptr)
@ cdecl _mbstok_l(str str ptr)
@ cdecl _mbstok_s(str str ptr)
@ cdecl _mbstok_s_l(str str ptr ptr)
@ cdecl _mbstowcs_l(ptr str long ptr) MSVCRT__mbstowcs_l
@ cdecl _mbstowcs_s_l(ptr ptr long str long ptr) MSVCRT__mbstowcs_s_l
@ cdecl _mbstrlen(str)