| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #include <corecrt_internal.h>
|
| #include <ctype.h>
|
| #include <locale.h>
|
| #include <string.h>
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| extern "C" int __cdecl _memicmp_l (
|
| void const * const lhs,
|
| void const * const rhs,
|
| size_t const count,
|
| _locale_t const plocinfo
|
| )
|
| {
|
|
|
| _VALIDATE_RETURN(lhs != nullptr || count == 0, EINVAL, _NLSCMPERROR);
|
| _VALIDATE_RETURN(rhs != nullptr || count == 0, EINVAL, _NLSCMPERROR);
|
|
|
| if (count == 0)
|
| {
|
| return 0;
|
| }
|
|
|
| unsigned char const * lhs_ptr = static_cast<unsigned char const *>(lhs);
|
| unsigned char const * rhs_ptr = static_cast<unsigned char const *>(rhs);
|
|
|
| _LocaleUpdate _loc_update(plocinfo);
|
|
|
| int result;
|
| size_t remaining = count;
|
| do
|
| {
|
| result = _tolower_fast_internal(*lhs_ptr++, _loc_update.GetLocaleT())
|
| - _tolower_fast_internal(*rhs_ptr++, _loc_update.GetLocaleT());
|
| }
|
| while (result == 0 && --remaining != 0);
|
|
|
| return result;
|
| }
|
|
|
|
|
| #if !defined(_M_IX86) || defined(_M_HYBRID_X86_ARM64)
|
|
|
| extern "C" int __cdecl __ascii_memicmp (
|
| void const * const lhs,
|
| void const * const rhs,
|
| size_t const count
|
| )
|
| {
|
| if (count == 0)
|
| {
|
| return 0;
|
| }
|
|
|
| unsigned char const * lhs_ptr = static_cast<unsigned char const *>(lhs);
|
| unsigned char const * rhs_ptr = static_cast<unsigned char const *>(rhs);
|
|
|
| int result;
|
| size_t remaining = count;
|
| do
|
| {
|
| result = __ascii_tolower(*lhs_ptr++) - __ascii_tolower(*rhs_ptr++);
|
| }
|
| while (result == 0 && --remaining != 0);
|
|
|
| return result;
|
| }
|
|
|
| #endif
|
|
|
| extern "C" int __cdecl _memicmp (
|
| void const * const lhs,
|
| void const * const rhs,
|
| size_t const count
|
| )
|
| {
|
| if (!__acrt_locale_changed())
|
| {
|
|
|
| _VALIDATE_RETURN(lhs != nullptr || count == 0, EINVAL, _NLSCMPERROR);
|
| _VALIDATE_RETURN(rhs != nullptr || count == 0, EINVAL, _NLSCMPERROR);
|
|
|
| return __ascii_memicmp(lhs, rhs, count);
|
| }
|
|
|
| return _memicmp_l(lhs, rhs, count, nullptr);
|
| }
|
|
|