Commit 6457163b authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Add _wctomb_s_l implementation.

parent 029aec19
......@@ -1520,8 +1520,8 @@
@ stub _wctime32_s
@ cdecl _wctime64(ptr) msvcrt._wctime64
@ stub _wctime64_s
@ stub _wctomb_l
@ stub _wctomb_s_l
@ cdecl _wctomb_l(ptr long ptr) msvcrt._wctomb_l
@ cdecl _wctomb_s_l(ptr ptr long long ptr) msvcrt._wctomb_s_l
# extern _wctype
@ cdecl _wdupenv_s(ptr ptr wstr) msvcrt._wdupenv_s
@ extern _wenviron msvcrt._wenviron
......@@ -1877,7 +1877,7 @@
@ cdecl wcsxfrm(ptr wstr long) msvcrt.wcsxfrm
@ cdecl wctob(long) msvcrt.wctob
@ cdecl wctomb(ptr long) msvcrt.wctomb
@ stub wctomb_s
@ cdecl wctomb_s(ptr ptr long long) msvcrt.wctomb_s
@ cdecl wmemcpy_s(ptr long ptr long)
@ cdecl wmemmove_s(ptr long ptr long)
@ varargs wprintf(wstr) msvcrt.wprintf
......
......@@ -1883,8 +1883,8 @@
@ stub _wctime32_s
@ cdecl _wctime64(ptr) msvcrt._wctime64
@ stub _wctime64_s
@ stub _wctomb_l
@ stub _wctomb_s_l
@ cdecl _wctomb_l(ptr long ptr) msvcrt._wctomb_l
@ cdecl _wctomb_s_l(ptr ptr long long ptr) msvcrt._wctomb_s_l
# extern _wctype
@ cdecl _wdupenv_s(ptr ptr wstr) msvcrt._wdupenv_s
@ extern _wenviron msvcrt._wenviron
......@@ -2240,7 +2240,7 @@
@ cdecl wcsxfrm(ptr wstr long) msvcrt.wcsxfrm
@ cdecl wctob(long) msvcrt.wctob
@ cdecl wctomb(ptr long) msvcrt.wctomb
@ stub wctomb_s
@ cdecl wctomb_s(ptr ptr long long) msvcrt.wctomb_s
@ cdecl wmemcpy_s(ptr long ptr long) msvcr100.wmemcpy_s
@ cdecl wmemmove_s(ptr long ptr long) msvcr100.wmemmove_s
@ varargs wprintf(wstr) msvcrt.wprintf
......
......@@ -1198,8 +1198,8 @@
@ stub _wctime32_s
@ cdecl _wctime64(ptr) msvcrt._wctime64
@ stub _wctime64_s
@ stub _wctomb_l
@ stub _wctomb_s_l
@ cdecl _wctomb_l(ptr long ptr) msvcrt._wctomb_l
@ cdecl _wctomb_s_l(ptr ptr long long ptr) msvcrt._wctomb_s_l
# extern _wctype
@ cdecl _wdupenv_s(ptr ptr wstr) msvcrt._wdupenv_s
@ extern _wenviron msvcrt._wenviron
......@@ -1556,7 +1556,7 @@
@ cdecl wcsxfrm(ptr wstr long) msvcrt.wcsxfrm
@ cdecl wctob(long) msvcrt.wctob
@ cdecl wctomb(ptr long) msvcrt.wctomb
@ stub wctomb_s
@ cdecl wctomb_s(ptr ptr long long) msvcrt.wctomb_s
@ varargs wprintf(wstr) msvcrt.wprintf
@ varargs wprintf_s(wstr) msvcrt.wprintf_s
@ varargs wscanf(wstr) msvcrt.wscanf
......
......@@ -1174,8 +1174,8 @@
@ stub _wctime32_s
@ cdecl _wctime64(ptr) msvcrt._wctime64
@ stub _wctime64_s
@ stub _wctomb_l
@ stub _wctomb_s_l
@ cdecl _wctomb_l(ptr long ptr) msvcrt._wctomb_l
@ cdecl _wctomb_s_l(ptr ptr long long ptr) msvcrt._wctomb_s_l
# extern _wctype
@ cdecl _wdupenv_s(ptr ptr wstr) msvcrt._wdupenv_s
@ extern _wenviron msvcrt._wenviron
......@@ -1529,7 +1529,7 @@
@ cdecl wcsxfrm(ptr wstr long) msvcrt.wcsxfrm
@ cdecl wctob(long) msvcrt.wctob
@ cdecl wctomb(ptr long) msvcrt.wctomb
@ stub wctomb_s
@ cdecl wctomb_s(ptr ptr long long) msvcrt.wctomb_s
@ varargs wprintf(wstr) msvcrt.wprintf
@ varargs wprintf_s(wstr) msvcrt.wprintf_s
@ varargs wscanf(wstr) msvcrt.wscanf
......
......@@ -1139,8 +1139,8 @@
# stub _wctime32_s(ptr long ptr)
@ cdecl _wctime64(ptr) MSVCRT__wctime64
# stub _wctime64_s(ptr long ptr)
# stub _wctomb_l(ptr long ptr)
# stub _wctomb_s_l(ptr ptr long long ptr)
@ cdecl _wctomb_l(ptr long ptr) MSVCRT__wctomb_l
@ cdecl _wctomb_s_l(ptr ptr long long ptr) MSVCRT__wctomb_s_l
# extern _wctype
@ extern _wenviron MSVCRT__wenviron
@ varargs _wexecl(wstr wstr)
......@@ -1510,7 +1510,7 @@
@ stub wcsxfrm(ptr wstr long)
@ cdecl wctob(long) MSVCRT_wctob
@ cdecl wctomb(ptr long) MSVCRT_wctomb
# stub wctomb_s(ptr ptr long long)
@ cdecl wctomb_s(ptr ptr long long) MSVCRT_wctomb_s
@ varargs wprintf(wstr) MSVCRT_wprintf
@ varargs wprintf_s(wstr) MSVCRT_wprintf_s
@ varargs wscanf(wstr) MSVCRT_wscanf
......
......@@ -2356,7 +2356,7 @@ static void test_wctomb(void)
ret = p_wcrtomb((char*)dst, 0xffff, NULL);
ok(ret == -1, "wcrtomb did not return -1\n");
ok(dst[0] == 0x3f, "dst[0] = %x, expected 0x20\n", dst[0]);
ok(dst[0] == 0x3f, "dst[0] = %x, expected 0x3f\n", dst[0]);
setlocale(LC_ALL, "C");
}
......
......@@ -1146,6 +1146,96 @@ MSVCRT_wchar_t * CDECL MSVCRT_wcstok( MSVCRT_wchar_t *str, const MSVCRT_wchar_t
}
/*********************************************************************
* _wctomb_s_l (MSVCRT.@)
*/
int CDECL MSVCRT__wctomb_s_l(int *len, char *mbchar, MSVCRT_size_t size,
MSVCRT_wchar_t wch, MSVCRT__locale_t locale)
{
MSVCRT_pthreadlocinfo locinfo;
BOOL error;
int mblen;
if(!mbchar && size>0) {
if(len)
*len = 0;
return 0;
}
if(len)
*len = -1;
if(!MSVCRT_CHECK_PMT(size <= INT_MAX))
return MSVCRT_EINVAL;
if(!locale)
locinfo = get_locinfo();
else
locinfo = locale->locinfo;
if(!locinfo->lc_codepage) {
if(wch > 0xff) {
if(mbchar && size>0)
memset(mbchar, 0, size);
*MSVCRT__errno() = MSVCRT_EILSEQ;
return MSVCRT_EILSEQ;
}
if(!MSVCRT_CHECK_PMT_ERR(size >= 1, MSVCRT_ERANGE))
return MSVCRT_ERANGE;
*mbchar = wch;
if(len)
*len = 1;
return 0;
}
mblen = WideCharToMultiByte(locinfo->lc_codepage, 0, &wch, 1, mbchar, size, NULL, &error);
if(!mblen || error) {
if(!mblen && GetLastError()==ERROR_INSUFFICIENT_BUFFER) {
if(mbchar && size>0)
memset(mbchar, 0, size);
MSVCRT_INVALID_PMT("insufficient buffer size", MSVCRT_ERANGE);
return MSVCRT_ERANGE;
}
*MSVCRT__errno() = MSVCRT_EILSEQ;
return MSVCRT_EILSEQ;
}
if(len)
*len = mblen;
return 0;
}
/*********************************************************************
* wctomb_s (MSVCRT.@)
*/
int CDECL MSVCRT_wctomb_s(int *len, char *mbchar, MSVCRT_size_t size, MSVCRT_wchar_t wch)
{
return MSVCRT__wctomb_s_l(len, mbchar, size, wch, NULL);
}
/*********************************************************************
* _wctomb_l (MSVCRT.@)
*/
int CDECL MSVCRT__wctomb_l(char *dst, MSVCRT_wchar_t ch, MSVCRT__locale_t locale)
{
int len;
MSVCRT__wctomb_s_l(&len, dst, dst ? 6 : 0, ch, locale);
return len;
}
/*********************************************************************
* wctomb (MSVCRT.@)
*/
INT CDECL MSVCRT_wctomb( char *dst, MSVCRT_wchar_t ch )
{
return MSVCRT__wctomb_l(dst, ch, NULL);
}
/*********************************************************************
* wctob (MSVCRT.@)
*/
INT CDECL MSVCRT_wctob( MSVCRT_wint_t wchar )
......@@ -1165,22 +1255,6 @@ INT CDECL MSVCRT_wctob( MSVCRT_wint_t wchar )
}
/*********************************************************************
* wctomb (MSVCRT.@)
*/
INT CDECL MSVCRT_wctomb( char *dst, MSVCRT_wchar_t ch )
{
BOOL error;
INT size;
size = WideCharToMultiByte(get_locinfo()->lc_codepage, 0, &ch, 1, dst, dst ? 6 : 0, NULL, &error);
if(!size || error) {
*MSVCRT__errno() = MSVCRT_EINVAL;
return MSVCRT_EOF;
}
return size;
}
/*********************************************************************
* wcrtomb (MSVCRT.@)
*/
MSVCRT_size_t CDECL MSVCRT_wcrtomb( char *dst, MSVCRT_wchar_t ch, MSVCRT_mbstate_t *s)
......
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