| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #ifndef _MBCS
|
| #error This file should only be compiled with _MBCS defined
|
| #endif
|
|
|
| #include <corecrt_internal_mbstring.h>
|
| #include <locale.h>
|
| #include <stddef.h>
|
| #include <string.h>
|
|
|
| #pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED)
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
|
|
| extern "C" _CONST_RETURN unsigned char * __cdecl _mbschr_l(
|
| const unsigned char *string,
|
| unsigned int c,
|
| _locale_t plocinfo
|
| )
|
| {
|
| unsigned short cc = '\0';
|
| _LocaleUpdate _loc_update(plocinfo);
|
|
|
|
|
| _VALIDATE_RETURN(string != nullptr, EINVAL, nullptr);
|
|
|
| if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
|
| return (_CONST_RETURN unsigned char *)strchr((const char *)string, (int)c);
|
|
|
| for (; (cc = *string) != '\0'; string++)
|
| {
|
| if ( _ismbblead_l(cc, _loc_update.GetLocaleT()) )
|
| {
|
| if (*++string == '\0')
|
| return nullptr;
|
| if ( c == (unsigned int)((cc << 8) | *string) )
|
| return (unsigned char *)(string - 1);
|
| }
|
| else if (c == (unsigned int)cc)
|
| break;
|
| }
|
|
|
| if (c == (unsigned int)cc)
|
| return (unsigned char *)(string);
|
|
|
| return nullptr;
|
| }
|
|
|
| extern "C" _CONST_RETURN unsigned char * (__cdecl _mbschr)(
|
| const unsigned char *string,
|
| unsigned int c
|
| )
|
| {
|
| return _mbschr_l(string, c, nullptr);
|
| }
|
|
|