reactos/sdk/lib/crt
Bișoc George 8266f62ff6
[CRT][STDLIB] Wine-sync _mbtowc_l function code
The current _mbtowc_l code directly passes the string count size argument to cbMultiByte argument parameter to MultiByteToWideChar(). As the size of lpMultiByteStr expressed in bytes by cbMultiByte is dependent of the actual given string, the size of lpWideCharStr expressed in characters by cchWideChar is always 1.

The resulting parameters to MultiByteToWideChar() will lead to a failure as lpWideCharStr cannot accommodate the converted string if the size pointed by lpMultiByteStr is larger than the buffer wide string to receive the converted output, a Win32 error code of ERROR_INSUFFICIENT_BUFFER in other words. The fact that _mbtowc_l never fails without WINE Gecko package installed is because the codepage pointed by lc_codepage is CP_ACP and the converted output is directly given to the destination wide string parameter thus never calling MultiByteToWideChar(). Installing WINE Gecko merely unhides this problem.

As _mbtowc_l is imported from WINE and that they have updated their code (which at the same time this fixes the aforementioned problem), the following commit syncs the updated code from WINE.

CORE-16885
2020-04-28 22:41:57 +02:00
..
conio
direct
except [CRT] Implement __chkstk function for ARM (#1595) 2020-04-26 19:58:53 +03:00
float
include [CRT] Import wine exception handling code 2020-02-09 15:56:30 +01:00
locale
math [SDK] Use HEX macro, like elsewhere in the file 2020-01-22 20:57:04 +01:00
mbstring
mem
misc [CRT] Implement _CrtDbgReport and _CrtDbgReportW 2020-04-04 19:55:24 +02:00
printf
process
search
setjmp
signal
startup [CRT] ARM & ARM64 Windows do not have initenv in their CRTs (#1597) 2020-04-26 19:56:34 +03:00
stdio [MSVCRT] Export __acrt_iob_func to fix GCC build with latest RosBE 2.2 (#1835) 2019-10-20 12:44:17 +02:00
stdlib [CRT][STDLIB] Wine-sync _mbtowc_l function code 2020-04-28 22:41:57 +02:00
string [MSVCRT] Add _snwscanf 2020-03-15 13:12:20 +01:00
sys_stat
time
wine [CRT] Import wine exception handling code 2020-02-09 15:56:30 +01:00
wstring
CMakeLists.txt [CMAKE] Replace custom functions to built-in ones 2020-04-16 15:59:38 +03:00
crt.cmake [CMAKE] Replace custom functions to built-in ones 2020-04-16 15:59:38 +03:00
libcntpr.cmake [CMAKE] Replace custom functions to built-in ones 2020-04-16 15:59:38 +03:00
moldname-msvcrt.def
msvcrtex.cmake [CMAKE] Replace custom functions to built-in ones 2020-04-16 15:59:38 +03:00
oldnames-msvcrt.S
oldnames.cmake
precomp.h
README.txt

Big chunks of this CRT library are taken from Wine's msvcrt implementation,
you can find a list of synced files in README.WINE file.

Notes:
1. When syncing, omit MSVCRT_ prefix where possible, Wine has to keep this
because they are linking with *both* original crt, and ms crt implementation.
ReactOS has the only CRT, so no need to make distinct functions.
2. ReactOS compiles two versions of the CRT library, one for usermode
(called just "crt"), and one version for kernelmode usage (called "libcntpr").
In order to separate the code, you can use #ifdef _LIBCNT_ for libcntpr code.