Author: akhaldi Date: Sun May 18 18:35:45 2014 New Revision: 63358
URL: http://svn.reactos.org/svn/reactos?rev=63358&view=rev Log: [CRT] * Import _isleadbyte_l(). * Import _mbtowc_l(). * Import mbtowc() instead of our own. * Fixes some msvcrt tests. CORE-8080
Modified: trunk/reactos/lib/sdk/crt/stdlib/mbtowc.c trunk/reactos/lib/sdk/crt/string/ctype.c
Modified: trunk/reactos/lib/sdk/crt/stdlib/mbtowc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdlib/mbtowc.c... ============================================================================== --- trunk/reactos/lib/sdk/crt/stdlib/mbtowc.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/stdlib/mbtowc.c [iso-8859-1] Sun May 18 18:35:45 2014 @@ -10,36 +10,39 @@
#include <precomp.h>
+/********************************************************************* + * _mbtowc_l(MSVCRT.@) + */ +int CDECL _mbtowc_l(wchar_t *dst, const char* str, size_t n, _locale_t locale) +{ + MSVCRT_pthreadlocinfo locinfo; + wchar_t tmpdst = '\0';
-/* - * @implemented + if(!locale) + locinfo = get_locinfo(); + else + locinfo = (MSVCRT_pthreadlocinfo)(locale->locinfo); + + if(n <= 0 || !str) + return 0; + if(!locinfo->lc_codepage) + tmpdst = (unsigned char)*str; + else 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 && _isleadbyte_l((unsigned char)*str, locale) && str[1]) + return 2; + return 1; +} + +/********************************************************************* + * mbtowc(MSVCRT.@) */ - -int mbtowc (wchar_t *charptr, const char *address, size_t number) +int CDECL mbtowc(wchar_t *dst, const char* str, size_t n) { - int bytes; - - if (address == 0) - return 0; - - if ((bytes = mblen (address, number)) < 0) - return bytes; - - if (charptr) { - switch (bytes) { - case 0: - if (number > 0) - *charptr = (wchar_t) '\0'; - break; - case 1: - *charptr = (wchar_t) ((unsigned char) address[0]); - break; - case 2: - *charptr = (wchar_t) (((unsigned char) address[0] << 8) - | (unsigned char) address[1]); - break; - } - } - - return bytes; + return _mbtowc_l(dst, str, n, NULL); }
Modified: trunk/reactos/lib/sdk/crt/string/ctype.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/ctype.c?... ============================================================================== --- trunk/reactos/lib/sdk/crt/string/ctype.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/string/ctype.c [iso-8859-1] Sun May 18 18:35:45 2014 @@ -614,6 +614,15 @@ { return _isctype_l(c, ctypeFlags, NULL); } + +/********************************************************************* + * _isleadbyte_l (MSVCRT.@) + */ +int __cdecl _isleadbyte_l(int c, _locale_t locale) +{ + return _isctype_l( c, _LEADBYTE, locale ); +} + #endif /* _LIBCNT_ */
/*