mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[CRT]
* Import _isleadbyte_l(). * Import _mbtowc_l(). * Import mbtowc() instead of our own. * Fixes some msvcrt tests. CORE-8080 svn path=/trunk/; revision=63358
This commit is contained in:
parent
8d02368e52
commit
8926b7a72e
2 changed files with 40 additions and 28 deletions
|
@ -10,36 +10,39 @@
|
|||
|
||||
#include <precomp.h>
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
/*********************************************************************
|
||||
* _mbtowc_l(MSVCRT.@)
|
||||
*/
|
||||
|
||||
int mbtowc (wchar_t *charptr, const char *address, size_t number)
|
||||
int CDECL _mbtowc_l(wchar_t *dst, const char* str, size_t n, _locale_t locale)
|
||||
{
|
||||
int bytes;
|
||||
MSVCRT_pthreadlocinfo locinfo;
|
||||
wchar_t tmpdst = '\0';
|
||||
|
||||
if (address == 0)
|
||||
return 0;
|
||||
if(!locale)
|
||||
locinfo = get_locinfo();
|
||||
else
|
||||
locinfo = (MSVCRT_pthreadlocinfo)(locale->locinfo);
|
||||
|
||||
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;
|
||||
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 CDECL mbtowc(wchar_t *dst, const char* str, size_t n)
|
||||
{
|
||||
return _mbtowc_l(dst, str, n, NULL);
|
||||
}
|
||||
|
|
|
@ -614,6 +614,15 @@ int __cdecl _isctype (int c, int ctypeFlags)
|
|||
{
|
||||
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_ */
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue