Commit 99579ca4 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Added _mbtowc_l implementation.

parent 0f53100a
......@@ -1009,28 +1009,6 @@ unsigned char* CDECL _mbstok(unsigned char *str, const unsigned char *delim)
}
/*********************************************************************
* mbtowc(MSVCRT.@)
*/
int CDECL MSVCRT_mbtowc(MSVCRT_wchar_t *dst, const char* str, MSVCRT_size_t n)
{
/* temp var needed because MultiByteToWideChar wants non NULL destination */
MSVCRT_wchar_t tmpdst = '\0';
if(n <= 0 || !str)
return 0;
if(!MultiByteToWideChar(CP_ACP, 0, str, n, &tmpdst, 1))
return -1;
if(dst)
*dst = tmpdst;
/* return the number of bytes from src that have been used */
if(!*str)
return 0;
if(n >= 2 && MSVCRT_isleadbyte(*str) && str[1])
return 2;
return 1;
}
/*********************************************************************
* _mbbtombc(MSVCRT.@)
*/
unsigned int CDECL _mbbtombc(unsigned int c)
......@@ -1869,6 +1847,41 @@ MSVCRT_size_t CDECL _mbstrlen(const char* str)
}
/*********************************************************************
* _mbtowc_l(MSVCRT.@)
*/
int CDECL MSVCRT_mbtowc_l(MSVCRT_wchar_t *dst, const char* str, MSVCRT_size_t n, MSVCRT__locale_t locale)
{
MSVCRT_pthreadlocinfo locinfo;
MSVCRT_wchar_t tmpdst = '\0';
if(!locale)
locinfo = get_locinfo();
else
locinfo = locale->locinfo;
if(n <= 0 || !str)
return 0;
if(!MultiByteToWideChar(locinfo->lc_codepage, 0, str, n, &tmpdst, 1))
return -1;
if(dst)
*dst = tmpdst;
/* return the number of bytes from src that have been used */
if(!*str)
return 0;
if(n >= 2 && MSVCRT__isleadbyte_l(*str, locale) && str[1])
return 2;
return 1;
}
/*********************************************************************
* mbtowc(MSVCRT.@)
*/
int CDECL MSVCRT_mbtowc(MSVCRT_wchar_t *dst, const char* str, MSVCRT_size_t n)
{
return MSVCRT_mbtowc_l(dst, str, n, NULL);
}
/*********************************************************************
* _mbstowcs_l(MSVCRT.@)
*/
MSVCRT_size_t CDECL MSVCRT__mbstowcs_l(MSVCRT_wchar_t *wcstr, const char *mbstr,
......
......@@ -850,6 +850,7 @@ int __cdecl MSVCRT_iswalpha(MSVCRT_wint_t);
int __cdecl MSVCRT_iswspace(MSVCRT_wint_t);
int __cdecl MSVCRT_iswdigit(MSVCRT_wint_t);
int __cdecl MSVCRT_isleadbyte(int);
int __cdecl MSVCRT__isleadbyte_l(int, MSVCRT__locale_t);
void __cdecl MSVCRT__lock_file(MSVCRT_FILE*);
void __cdecl MSVCRT__unlock_file(MSVCRT_FILE*);
......
......@@ -792,7 +792,7 @@
# stub _mbsupr_l(str ptr)
@ cdecl _mbsupr_s(str long)
# stub _mbsupr_s_l(str long ptr)
# stub _mbtowc_l(ptr str long ptr)
@ cdecl _mbtowc_l(ptr str long ptr) MSVCRT_mbtowc_l
@ cdecl _memccpy(ptr ptr long long) ntdll._memccpy
@ cdecl _memicmp(str str long) ntdll._memicmp
# stub _memicmp_l(str str long ptr)
......
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