ReactOS 0.4.16-dev-927-g467dec4
wcsspn.cpp
Go to the documentation of this file.
1//
2// wcsspn.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// Defines wcsspn(), which finds the length of the initial substring of 'string'
7// that consists entirely of characters in 'control'. This function returns the
8// index of the first character in the string that does not belong to the set of
9// characters in the control string. If there is no such character, the length
10// of the string is returned.
11//
12#include <string.h>
13
14
15
16extern "C" size_t __cdecl wcsspn(
17 wchar_t const* const string,
18 wchar_t const* const control
19 )
20{
21 wchar_t const* string_it = string;
22 for (; *string_it; ++string_it)
23 {
24 for (wchar_t const* control_it = control; *string_it != *control_it; ++control_it)
25 {
26 // Reached the end of the control string without finding a match:
27 if (*control_it == 0)
28 {
29 return static_cast<size_t>(string_it - string);
30 }
31 }
32 }
33
34 // The whole string consisted of characters from the control:
35 return static_cast<size_t>(string_it - string);
36}
#define __cdecl
Definition: accygwin.h:79
char string[160]
Definition: util.h:11
Definition: dialog.c:52
size_t __cdecl wcsspn(wchar_t const *const string, wchar_t const *const control)
Definition: wcsspn.cpp:16