ReactOS 0.4.16-dev-927-g467dec4
mbscspn.cpp File Reference
#include <corecrt_internal.h>
#include <corecrt_internal_mbstring.h>
#include <locale.h>
#include <stddef.h>
#include <string.h>
Include dependency graph for mbscspn.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

size_t __cdecl _mbscspn_l (const unsigned char *string, const unsigned char *charset, _locale_t plocinfo)
 
 size_t (__cdecl _mbscspn)(const unsigned char *string
 

Variables

const unsigned charcharset
 

Function Documentation

◆ _mbscspn_l()

size_t __cdecl _mbscspn_l ( const unsigned char string,
const unsigned char charset,
_locale_t  plocinfo 
)

Definition at line 57 of file mbscspn.cpp.

71{
72 unsigned char *p, *q;
73 _LocaleUpdate _loc_update(plocinfo);
74
75 if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
76#ifndef _RETURN_PTR
77 return strcspn((const char *)string, (const char *)charset);
78#else /* _RETURN_PTR */
79 return (const unsigned char *)strpbrk((const char *)string, (const char *)charset);
80#endif /* _RETURN_PTR */
81
82 /* validation section */
83#ifndef _RETURN_PTR
84 _VALIDATE_RETURN(string != nullptr, EINVAL, 0);
85 _VALIDATE_RETURN(charset != nullptr, EINVAL, 0);
86#else /* _RETURN_PTR */
87 _VALIDATE_RETURN(string != nullptr, EINVAL, nullptr);
88 _VALIDATE_RETURN(charset != nullptr, EINVAL, nullptr);
89#endif /* _RETURN_PTR */
90
91 /* loop through the string to be inspected */
92 for (q = (unsigned char *)string; *q ; q++) {
93
94 /* loop through the charset */
95 for (p = (unsigned char *)charset; *p ; p++) {
96
97 if ( _ismbblead_l(*p, _loc_update.GetLocaleT()) ) {
98 if (((*p == *q) && (p[1] == q[1])) || p[1] == '\0')
99 break;
100 p++;
101 }
102 else
103 if (*p == *q)
104 break;
105 }
106
107 if (*p != '\0') /* end of charset? */
108 break; /* no, match on this char */
109
110 if ( _ismbblead_l(*q, _loc_update.GetLocaleT()) )
111 if (*++q == '\0')
112 break;
113 }
114
115#ifndef _RETURN_PTR
116 return((size_t) (q - string)); /* index */
117#else /* _RETURN_PTR */
118 return((*q) ? q : nullptr); /* pointer */
119#endif /* _RETURN_PTR */
120
121}
#define EINVAL
Definition: acclib.h:90
char * strpbrk(const char *String, const char *Delimiters)
Definition: utclib.c:302
#define _ismbblead_l(_c, p)
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat GLfloat p
Definition: glext.h:8902
_locale_t plocinfo
Definition: ismbbyte.cpp:75
const unsigned char * charset
Definition: mbscspn.cpp:137
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)

◆ size_t()

size_t ( __cdecl  _mbscspn) const

Variable Documentation

◆ charset

const unsigned char* charset
Initial value:
{
return _mbscspn_l(string, charset, nullptr)
size_t __cdecl _mbscspn_l(const unsigned char *string, const unsigned char *charset, _locale_t plocinfo)
Definition: mbscspn.cpp:57

Definition at line 127 of file mbscspn.cpp.

Referenced by _mbscspn_l().