| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #ifndef _MBCS
|
| #error This file should only be compiled with _MBCS defined
|
| #endif
|
|
|
| #include <corecrt_internal.h>
|
| #include <corecrt_internal_mbstring.h>
|
| #include <locale.h>
|
| #include <stddef.h>
|
| #include <string.h>
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| #ifndef _RETURN_PTR
|
|
|
| extern "C" size_t __cdecl _mbscspn_l(
|
| const unsigned char *string,
|
| const unsigned char *charset,
|
| _locale_t plocinfo
|
| )
|
| #else
|
|
|
| extern "C" const unsigned char * __cdecl _mbspbrk_l(
|
| const unsigned char *string,
|
| const unsigned char *charset,
|
| _locale_t plocinfo
|
| )
|
| #endif
|
|
|
| {
|
| unsigned char *p, *q;
|
| _LocaleUpdate _loc_update(plocinfo);
|
|
|
| if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
|
| #ifndef _RETURN_PTR
|
| return strcspn((const char *)string, (const char *)charset);
|
| #else
|
| return (const unsigned char *)strpbrk((const char *)string, (const char *)charset);
|
| #endif
|
|
|
|
|
| #ifndef _RETURN_PTR
|
| _VALIDATE_RETURN(string != nullptr, EINVAL, 0);
|
| _VALIDATE_RETURN(charset != nullptr, EINVAL, 0);
|
| #else
|
| _VALIDATE_RETURN(string != nullptr, EINVAL, nullptr);
|
| _VALIDATE_RETURN(charset != nullptr, EINVAL, nullptr);
|
| #endif
|
|
|
|
|
| for (q = (unsigned char *)string; *q ; q++) {
|
|
|
|
|
| for (p = (unsigned char *)charset; *p ; p++) {
|
|
|
| if ( _ismbblead_l(*p, _loc_update.GetLocaleT()) ) {
|
| if (((*p == *q) && (p[1] == q[1])) || p[1] == '\0')
|
| break;
|
| p++;
|
| }
|
| else
|
| if (*p == *q)
|
| break;
|
| }
|
|
|
| if (*p != '\0')
|
| break;
|
|
|
| if ( _ismbblead_l(*q, _loc_update.GetLocaleT()) )
|
| if (*++q == '\0')
|
| break;
|
| }
|
|
|
| #ifndef _RETURN_PTR
|
| return((size_t) (q - string));
|
| #else
|
| return((*q) ? q : nullptr);
|
| #endif
|
|
|
| }
|
|
|
| #ifndef _RETURN_PTR
|
|
|
| extern "C" size_t (__cdecl _mbscspn)(
|
| const unsigned char *string,
|
| const unsigned char *charset
|
| )
|
| #else
|
|
|
| extern "C" const unsigned char * (__cdecl _mbspbrk)(
|
| const unsigned char *string,
|
| const unsigned char *charset
|
| )
|
| #endif
|
|
|
| {
|
| #ifndef _RETURN_PTR
|
| return _mbscspn_l(string, charset, nullptr);
|
| #else
|
| return _mbspbrk_l(string, charset, nullptr);
|
| #endif
|
| }
|
|
|