ReactOS 0.4.16-dev-927-g467dec4
mbsspn.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 mbsspn.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

size_t __cdecl _mbsspn_l (const unsigned char *string, const unsigned char *charset, _locale_t plocinfo)
 
 size_t (__cdecl _mbsspn)(const unsigned char *string
 

Variables

const unsigned charcharset
 

Function Documentation

◆ _mbsspn_l()

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

Definition at line 51 of file mbsspn.cpp.

60{
61 unsigned char *p, *q;
62 _LocaleUpdate _loc_update(plocinfo);
63
64 if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
65#ifndef _RETURN_PTR
66 return strspn((const char *)string, (const char *)charset);
67#else /* _RETURN_PTR */
68 {
69 size_t retval;
70 retval = strspn((const char *)string, (const char *)charset);
71 return (unsigned char *)(*(string + retval) ? string + retval : nullptr);
72 }
73#endif /* _RETURN_PTR */
74
75 /* validation section */
76#ifndef _RETURN_PTR
77 _VALIDATE_RETURN(string != nullptr, EINVAL, 0);
78 _VALIDATE_RETURN(charset != nullptr, EINVAL, 0);
79#else /* _RETURN_PTR */
80 _VALIDATE_RETURN(string != nullptr, EINVAL, nullptr);
81 _VALIDATE_RETURN(charset != nullptr, EINVAL, nullptr);
82#endif /* _RETURN_PTR */
83
84 /* loop through the string to be inspected */
85 for (q = (unsigned char *)string; *q; q++) {
86
87 /* loop through the charset */
88 for (p = (unsigned char *)charset; *p; p++) {
89 if ( _ismbblead_l(*p, _loc_update.GetLocaleT()) ) {
90 if (((*p == *q) && (p[1] == q[1])) || p[1] == '\0')
91 break;
92 p++;
93 }
94 else
95 if (*p == *q)
96 break;
97 }
98
99 if (*p == '\0') /* end of charset? */
100 break; /* yes, no match on this char */
101
102 if ( _ismbblead_l(*q, _loc_update.GetLocaleT()) )
103 if (*++q == '\0')
104 break;
105 }
106
107#ifndef _RETURN_PTR
108 return((size_t) (q - string)); /* index */
109#else /* _RETURN_PTR */
110 return((*q) ? q : nullptr); /* pointer */
111#endif /* _RETURN_PTR */
112
113}
#define EINVAL
Definition: acclib.h:90
#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: mbsspn.cpp:124
_Check_return_ _CRTIMP size_t __cdecl strspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
int retval
Definition: wcstombs.cpp:91

◆ size_t()

size_t ( __cdecl  _mbsspn) const

Variable Documentation

◆ charset

const unsigned char* charset
Initial value:
{
return _mbsspn_l(string, charset, nullptr)
size_t __cdecl _mbsspn_l(const unsigned char *string, const unsigned char *charset, _locale_t plocinfo)
Definition: mbsspn.cpp:55

Definition at line 122 of file mbsspn.cpp.

Referenced by _mbsspn_l().