ReactOS 0.4.16-dev-814-g656a5dc
mbstok_s.cpp File Reference
Include dependency graph for mbstok_s.cpp:

Go to the source code of this file.

Functions

unsigned char *__cdecl _mbstok_s_l (unsigned char *_String, const unsigned char *_Control, unsigned char **_Context, _LOCALE_ARG_DECL)
 

Function Documentation

◆ _mbstok_s_l()

unsigned char *__cdecl _mbstok_s_l ( unsigned char _String,
const unsigned char _Control,
unsigned char **  _Context,
_LOCALE_ARG_DECL   
)

Definition at line 17 of file mbstok_s.cpp.

18{
19 unsigned char *token;
20 const unsigned char *ctl;
21 int dbc;
22
23 /* validation section */
25 _VALIDATE_POINTER_ERROR_RETURN(_Control, EINVAL, nullptr);
26 _VALIDATE_CONDITION_ERROR_RETURN(_String != nullptr || *_Context != nullptr, EINVAL, nullptr);
27
30 {
31 return (unsigned char*)strtok_s((char *)_String, (const char *)_Control, (char **)_Context);
32 }
33
34 /* If string==nullptr, continue with previous string */
35 if (!_String)
36 {
38 }
39
40 /* Find beginning of token (skip over leading delimiters). Note that
41 * there is no token iff this loop sets string to point to the terminal null. */
42 for ( ; *_String != 0; _String++)
43 {
44 for (ctl = _Control; *ctl != 0; ctl++)
45 {
46 if (_ISMBBLEAD(*ctl))
47 {
48 if (ctl[1] == 0)
49 {
50 ctl++;
52 break;
53 }
54 if (*ctl == *_String && ctl[1] == _String[1])
55 {
56 break;
57 }
58 ctl++;
59 }
60 else
61 {
62 if (*ctl == *_String)
63 {
64 break;
65 }
66 }
67 }
68 if (*ctl == 0)
69 {
70 break;
71 }
72 if (_ISMBBLEAD(*_String))
73 {
74 _String++;
75 if (*_String == 0)
76 {
78 break;
79 }
80 }
81 }
82
83 token = _String;
84
85 /* Find the end of the token. If it is not the end of the string,
86 * put a null there. */
87 for ( ; *_String != 0; _String++)
88 {
89 for (ctl = _Control, dbc = 0; *ctl != 0; ctl++)
90 {
91 if (_ISMBBLEAD(*ctl))
92 {
93 if (ctl[1] == 0)
94 {
95 ctl++;
96 break;
97 }
98 if (ctl[0] == _String[0] && ctl[1] == _String[1])
99 {
100 dbc = 1;
101 break;
102 }
103 ctl++;
104 }
105 else
106 {
107 if (*ctl == *_String)
108 {
109 break;
110 }
111 }
112 }
113 if (*ctl != 0)
114 {
115 *_String++ = 0;
116 if (dbc)
117 {
118 *_String++ = 0;
119 }
120 break;
121 }
122 if (_ISMBBLEAD(_String[0]))
123 {
124 if (_String[1] == 0)
125 {
126 *_String = 0;
127 break;
128 }
129 _String++;
130 }
131 }
132
133 /* Update the context */
134 *_Context = _String;
135
136 /* Determine if a token has been found. */
137 if (token == _String)
138 {
139 return nullptr;
140 }
141 else
142 {
143 return token;
144 }
145}
#define EINVAL
Definition: acclib.h:90
#define _VALIDATE_CONDITION_ERROR_RETURN(_Condition, _ErrorCode, _Ret)
#define _LOCALE_SHORTCUT_TEST
#define _SET_MBCS_ERROR
#define _LOCALE_UPDATE
#define _VALIDATE_POINTER_ERROR_RETURN(_Pointer, _ErrorCode, _Ret)
#define _ISMBBLEAD(_Character)
_Check_return_ _In_z_ wchar_t const _Inout_opt_ _Deref_prepost_opt_z_ wchar_t ** _Context
_String
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
char *CDECL strtok_s(char *str, const char *delim, char **ctx)
Definition: strtok_s.c:9

Referenced by _mbstok_l().