mirror of
https://github.com/reactos/reactos.git
synced 2025-07-30 18:01:36 +00:00
[SDK][STDLIB][STRING] Wine-sync wcsrtombs_l and _mbstowcs_l
This is a partial sync of the CRT library with wcsrtombs_l and _mbstowcs_l functions from WINE. The _wctomb_s_l implementation of WINE which is used by _wctomb_s, _wctomb_l and wctomb brings failed results of the wctomb unit testcase and at the same time it crashes the whole testcase after. Therefore I will not address the wctomb function for the moment being.
This commit is contained in:
parent
4d8a5e921e
commit
d8eeb31b8a
2 changed files with 55 additions and 9 deletions
|
@ -257,7 +257,8 @@ INT CDECL wctomb( char *dst, wchar_t ch )
|
|||
/*********************************************************************
|
||||
* wcsrtombs_l (INTERNAL)
|
||||
*/
|
||||
static size_t CDECL wcsrtombs_l(char *mbstr, const wchar_t **wcstr, size_t count, _locale_t locale)
|
||||
static size_t CDECL wcsrtombs_l(char *mbstr, const wchar_t **wcstr,
|
||||
size_t count, _locale_t locale)
|
||||
{
|
||||
MSVCRT_pthreadlocinfo locinfo;
|
||||
size_t tmp = 0;
|
||||
|
@ -268,12 +269,32 @@ static size_t CDECL wcsrtombs_l(char *mbstr, const wchar_t **wcstr, size_t count
|
|||
else
|
||||
locinfo = ((MSVCRT__locale_t)locale)->locinfo;
|
||||
|
||||
if(!locinfo->lc_codepage) {
|
||||
size_t i;
|
||||
|
||||
if(!mbstr)
|
||||
return strlenW(*wcstr);
|
||||
|
||||
for(i=0; i<count; i++) {
|
||||
if((*wcstr)[i] > 255) {
|
||||
_set_errno(EILSEQ);
|
||||
return -1;
|
||||
}
|
||||
|
||||
mbstr[i] = (*wcstr)[i];
|
||||
if(!(*wcstr)[i]) break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
if(!mbstr) {
|
||||
tmp = WideCharToMultiByte(locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
|
||||
*wcstr, -1, NULL, 0, NULL, &used_default)-1;
|
||||
if(used_default)
|
||||
*wcstr, -1, NULL, 0, NULL, &used_default);
|
||||
if(!tmp || used_default) {
|
||||
_set_errno(EILSEQ);
|
||||
return -1;
|
||||
return tmp;
|
||||
}
|
||||
return tmp-1;
|
||||
}
|
||||
|
||||
while(**wcstr) {
|
||||
|
@ -282,8 +303,10 @@ static size_t CDECL wcsrtombs_l(char *mbstr, const wchar_t **wcstr, size_t count
|
|||
|
||||
size = WideCharToMultiByte(locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
|
||||
*wcstr, 1, buf, 3, NULL, &used_default);
|
||||
if(used_default)
|
||||
if(!size || used_default) {
|
||||
_set_errno(EILSEQ);
|
||||
return -1;
|
||||
}
|
||||
if(tmp+size > count)
|
||||
return tmp;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue