Commit 7352ee84 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Added mbstowcs(_s_l) implementation.

parent d367314b
......@@ -785,8 +785,8 @@
@ stub _mbstok_l
@ stub _mbstok_s
@ stub _mbstok_s_l
@ stub _mbstowcs_l
@ stub _mbstowcs_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
@ stub _mbstrlen_l
@ stub _mbstrnlen
......@@ -1330,7 +1330,7 @@
@ stub mbsrtowcs
@ stub mbsrtowcs_s
@ cdecl mbstowcs(ptr str long) msvcrt.mbstowcs
@ stub mbstowcs_s
@ cdecl mbstowcs_s(ptr ptr long str long) msvcrt.mbstowcs_s
@ cdecl mbtowc(wstr str long) msvcrt.mbtowc
@ cdecl memchr(ptr long long) msvcrt.memchr
@ cdecl memcmp(ptr ptr long) msvcrt.memcmp
......
......@@ -773,8 +773,8 @@
@ stub _mbstok_l
@ stub _mbstok_s
@ stub _mbstok_s_l
@ stub _mbstowcs_l
@ stub _mbstowcs_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
@ stub _mbstrlen_l
@ stub _mbstrnlen
......@@ -1314,7 +1314,7 @@
@ stub mbsrtowcs
@ stub mbsrtowcs_s
@ cdecl mbstowcs(ptr str long) msvcrt.mbstowcs
@ stub mbstowcs_s
@ cdecl mbstowcs_s(ptr ptr long str long) msvcrt.mbstowcs_s
@ cdecl mbtowc(wstr str long) msvcrt.mbtowc
@ cdecl memchr(ptr long long) msvcrt.memchr
@ cdecl memcmp(ptr ptr long) msvcrt.memcmp
......
......@@ -1718,3 +1718,92 @@ MSVCRT_size_t CDECL _mbstrlen(const char* str)
{
return _mbstrlen_l(str, NULL);
}
/*********************************************************************
* _mbstowcs_l(MSVCRT.@)
*/
MSVCRT_size_t CDECL MSVCRT__mbstowcs_l(MSVCRT_wchar_t *wcstr, const char *mbstr,
MSVCRT_size_t count, MSVCRT__locale_t locale)
{
MSVCRT_size_t tmp;
if(!locale)
locale = get_locale();
tmp = _mbstrlen_l(mbstr, locale);
if(tmp>count && wcstr)
tmp = count;
tmp = MultiByteToWideChar(locale->locinfo->lc_codepage, 0,
mbstr, tmp, wcstr, count);
if(tmp<count && wcstr)
wcstr[tmp] = '\0';
return tmp;
}
/*********************************************************************
* mbstowcs(MSVCRT.@)
*/
MSVCRT_size_t CDECL MSVCRT_mbstowcs(MSVCRT_wchar_t *wcstr,
const char *mbstr, MSVCRT_size_t count)
{
return MSVCRT__mbstowcs_l(wcstr, mbstr, count, NULL);
}
/*********************************************************************
* _mbstowcs_s_l(MSVCRT.@)
*/
int CDECL MSVCRT__mbstowcs_s_l(MSVCRT_size_t *ret, MSVCRT_wchar_t *wcstr,
MSVCRT_size_t size, const char *mbstr,
MSVCRT_size_t count, MSVCRT__locale_t locale)
{
MSVCRT_size_t conv;
if(!wcstr && !size) {
conv = MSVCRT__mbstowcs_l(NULL, mbstr, 0, locale);
if(ret)
*ret = conv;
return 0;
}
if(!mbstr || !wcstr) {
MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
if(wcstr && size)
wcstr[0] = '\0';
*MSVCRT__errno() = MSVCRT_EINVAL;
return MSVCRT_EINVAL;
}
if(count==_TRUNCATE || size<count)
conv = size;
else
conv = count;
conv = MSVCRT__mbstowcs_l(wcstr, mbstr, conv, locale);
if(conv<size)
wcstr[conv++] = '\0';
else if(conv==size && (count==_TRUNCATE || wcstr[conv-1]=='\0'))
wcstr[conv-1] = '\0';
else {
MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
if(size)
wcstr[0] = '\0';
*MSVCRT__errno() = MSVCRT_ERANGE;
return MSVCRT_ERANGE;
}
if(ret)
*ret = conv;
return 0;
}
/*********************************************************************
* mbstowcs_s(MSVCRT.@)
*/
int CDECL MSVCRT__mbstowcs_s(MSVCRT_size_t *ret, MSVCRT_wchar_t *wcstr,
MSVCRT_size_t size, const char *mbstr, MSVCRT_size_t count)
{
return MSVCRT__mbstowcs_s_l(ret, wcstr, size, mbstr, count, NULL);
}
......@@ -731,8 +731,8 @@
# stub _mbstok_l
# stub _mbstok_s
# stub _mbstok_s_l
# stub _mbstowcs_l
# stub _mbstowcs_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)
@ cdecl _mbstrlen_l(str ptr)
# stub _mbstrnlen
......@@ -1277,8 +1277,8 @@
# stub mbsdup_dbg
# stub mbsrtowcs
# stub mbsrtowcs_s
@ cdecl mbstowcs(ptr str long) ntdll.mbstowcs
# stub mbstowcs_s
@ cdecl mbstowcs(ptr str long) MSVCRT_mbstowcs
@ cdecl mbstowcs_s(ptr ptr long str long) MSVCRT__mbstowcs_s
@ cdecl mbtowc(wstr str long) MSVCRT_mbtowc
@ cdecl memchr(ptr long long) ntdll.memchr
@ cdecl memcmp(ptr ptr long) ntdll.memcmp
......
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