Reactos
at master 36 lines 1.0 kB view raw
1// 2// wcscspn.cpp 3// 4// Copyright (c) Microsoft Corporation. All rights reserved. 5// 6// Defines wcscspn(), which searches a string for an initial substring that does 7// not contain any of the specified control characters. 8// 9// This function returns the index of the first character in the string that 10// belongs to the set of characters specified by 'control'. This is equivalent 11// to the length of the initial substring of 'string' composed entirely of 12// characters that are not in 'control'. 13// 14#include <string.h> 15 16 17 18extern "C" size_t __cdecl wcscspn( 19 wchar_t const* const string, 20 wchar_t const* const control 21 ) 22{ 23 wchar_t const* string_it = string; 24 for (; *string_it; ++string_it) 25 { 26 for (wchar_t const* control_it = control; *control_it; ++control_it) 27 { 28 if (*string_it == *control_it) 29 { 30 return static_cast<size_t>(string_it - string); 31 } 32 } 33 } 34 35 return static_cast<size_t>(string_it - string); 36}