mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +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>
|
#include <precomp.h>
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
/*
|
* _mbtowc_l(MSVCRT.@)
|
||||||
* @implemented
|
|
||||||
*/
|
*/
|
||||||
|
int CDECL _mbtowc_l(wchar_t *dst, const char* str, size_t n, _locale_t locale)
|
||||||
int mbtowc (wchar_t *charptr, const char *address, size_t number)
|
|
||||||
{
|
{
|
||||||
int bytes;
|
MSVCRT_pthreadlocinfo locinfo;
|
||||||
|
wchar_t tmpdst = '\0';
|
||||||
|
|
||||||
if (address == 0)
|
if(!locale)
|
||||||
return 0;
|
locinfo = get_locinfo();
|
||||||
|
else
|
||||||
|
locinfo = (MSVCRT_pthreadlocinfo)(locale->locinfo);
|
||||||
|
|
||||||
if ((bytes = mblen (address, number)) < 0)
|
if(n <= 0 || !str)
|
||||||
return bytes;
|
return 0;
|
||||||
|
if(!locinfo->lc_codepage)
|
||||||
if (charptr) {
|
tmpdst = (unsigned char)*str;
|
||||||
switch (bytes) {
|
else if(!MultiByteToWideChar(locinfo->lc_codepage, 0, str, n, &tmpdst, 1))
|
||||||
case 0:
|
return -1;
|
||||||
if (number > 0)
|
if(dst)
|
||||||
*charptr = (wchar_t) '\0';
|
*dst = tmpdst;
|
||||||
break;
|
/* return the number of bytes from src that have been used */
|
||||||
case 1:
|
if(!*str)
|
||||||
*charptr = (wchar_t) ((unsigned char) address[0]);
|
return 0;
|
||||||
break;
|
if(n >= 2 && _isleadbyte_l((unsigned char)*str, locale) && str[1])
|
||||||
case 2:
|
return 2;
|
||||||
*charptr = (wchar_t) (((unsigned char) address[0] << 8)
|
return 1;
|
||||||
| (unsigned char) address[1]);
|
}
|
||||||
break;
|
|
||||||
}
|
/*********************************************************************
|
||||||
}
|
* mbtowc(MSVCRT.@)
|
||||||
|
*/
|
||||||
return bytes;
|
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);
|
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_ */
|
#endif /* _LIBCNT_ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue