X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fwchar%2Fwcscspn.c;h=248c20072ba5bed9c23426f69debce64212e76fe;hp=853b06a698f4ef0ae2457fa52543acb276eaed09;hb=abc15df6b9fae3374d24c7cf5c3ab94c605b2a6d;hpb=8894c921674bb116d0a7b8f23a55311e7a768019 diff --git a/functions/wchar/wcscspn.c b/functions/wchar/wcscspn.c index 853b06a..248c200 100644 --- a/functions/wchar/wcscspn.c +++ b/functions/wchar/wcscspn.c @@ -1,48 +1,48 @@ -/* wcscspn( const wchar_t *, const wchar_t * ) - - This file is part of the Public Domain C Library (PDCLib). - Permission is granted to use, modify, and / or redistribute at will. -*/ - -#include - -#ifndef REGTEST - -size_t wcscspn( const wchar_t * s1, const wchar_t * s2 ) -{ - size_t len = 0; - const wchar_t * p; - while ( s1[len] ) - { - p = s2; - while ( *p ) - { - if ( s1[len] == *p++ ) - { - return len; - } - } - ++len; - } - return len; -} - -#endif - -#ifdef TEST -#include "_PDCLIB_test.h" - -int main( void ) -{ - TESTCASE( wcscspn( wabcde, L"x" ) == 5 ); - TESTCASE( wcscspn( wabcde, L"xyz" ) == 5 ); - TESTCASE( wcscspn( wabcde, L"zyx" ) == 5 ); - TESTCASE( wcscspn( wabcdx, L"x" ) == 4 ); - TESTCASE( wcscspn( wabcdx, L"xyz" ) == 4 ); - TESTCASE( wcscspn( wabcdx, L"zyx" ) == 4 ); - TESTCASE( wcscspn( wabcde, L"a" ) == 0 ); - TESTCASE( wcscspn( wabcde, L"abc" ) == 0 ); - TESTCASE( wcscspn( wabcde, L"cba" ) == 0 ); - return TEST_RESULTS; -} -#endif +/* wcscspn( const wchar_t *, const wchar_t * ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +size_t wcscspn( const wchar_t * s1, const wchar_t * s2 ) +{ + size_t len = 0; + const wchar_t * p; + while ( s1[len] ) + { + p = s2; + while ( *p ) + { + if ( s1[len] == *p++ ) + { + return len; + } + } + ++len; + } + return len; +} + +#endif + +#ifdef TEST +#include "_PDCLIB_test.h" + +int main( void ) +{ + TESTCASE( wcscspn( wabcde, L"x" ) == 5 ); + TESTCASE( wcscspn( wabcde, L"xyz" ) == 5 ); + TESTCASE( wcscspn( wabcde, L"zyx" ) == 5 ); + TESTCASE( wcscspn( wabcdx, L"x" ) == 4 ); + TESTCASE( wcscspn( wabcdx, L"xyz" ) == 4 ); + TESTCASE( wcscspn( wabcdx, L"zyx" ) == 4 ); + TESTCASE( wcscspn( wabcde, L"a" ) == 0 ); + TESTCASE( wcscspn( wabcde, L"abc" ) == 0 ); + TESTCASE( wcscspn( wabcde, L"cba" ) == 0 ); + return TEST_RESULTS; +} +#endif