ReactOS 0.4.16-dev-927-g467dec4
wcstok_s.cpp File Reference
#include <corecrt_internal_securecrt.h>
#include <string.h>
Include dependency graph for wcstok_s.cpp:

Go to the source code of this file.

Functions

wchar_t *__cdecl __acrt_wcstok_s_novalidation (_Inout_opt_z_ wchar_t *string, _In_z_ wchar_t const *control, _Inout_ _Deref_prepost_opt_z_ wchar_t **context)
 
wchar_t *__cdecl wcstok_s (wchar_t *const string, wchar_t const *const control, wchar_t **const context)
 

Function Documentation

◆ __acrt_wcstok_s_novalidation()

wchar_t *__cdecl __acrt_wcstok_s_novalidation ( _Inout_opt_z_ wchar_t string,
_In_z_ wchar_t const control,
_Inout_ _Deref_prepost_opt_z_ wchar_t **  context 
)

Definition at line 16 of file wcstok_s.cpp.

21{
22 // If string is null, set the iterator to the saved pointer (i.e., continue
23 // breaking tokens out of the string from the last strtok call):
24 wchar_t* string_it = string != nullptr
25 ? string
26 : *context;
27
28
29 // Find beginning of token (skip over leading delimiters). Note that
30 // there is no token iff this loop sets string to point to the terminal
31 // null (*string == '\0')
32 while (*string_it)
33 {
34 wchar_t const* control_it = control;
35 for (; *control_it && *control_it != *string_it; ++control_it)
36 {
37 }
38
39 if (!*control_it)
40 break;
41
42 ++string_it;
43 }
44
45 wchar_t* const token_first = string_it;
46
47 // Find the end of the token. If it is not the end of the string, put a
48 // null character there:
49 for (; *string_it; ++string_it)
50 {
51 wchar_t const* control_it = control;
52 for (; *control_it && *control_it != *string_it; ++control_it)
53 {
54 }
55
56 if (*control_it)
57 {
58 *string_it++ = '\0';
59 break;
60 }
61 }
62
63 // Update the saved pointer:
64 *context = string_it;
65
66 // Determine if a token has been found.
67 return string_it != token_first ? token_first : nullptr;
68}
char string[160]
Definition: util.h:11
Definition: http.c:7252
Definition: dialog.c:52

Referenced by wcstok(), and wcstok_s().

◆ wcstok_s()

wchar_t *__cdecl wcstok_s ( wchar_t *const  string,
wchar_t const *const  control,
wchar_t **const  context 
)

Definition at line 72 of file wcstok_s.cpp.

77{
80 _VALIDATE_CONDITION_ERROR_RETURN(string != nullptr || *context != nullptr, EINVAL, nullptr);
81
83}
#define EINVAL
Definition: acclib.h:90
#define _VALIDATE_CONDITION_ERROR_RETURN(_Condition, _ErrorCode, _Ret)
#define _VALIDATE_POINTER_ERROR_RETURN(_Pointer, _ErrorCode, _Ret)
wchar_t *__cdecl __acrt_wcstok_s_novalidation(_Inout_opt_z_ wchar_t *string, _In_z_ wchar_t const *control, _Inout_ _Deref_prepost_opt_z_ wchar_t **context)
Definition: wcstok_s.cpp:16