X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fwchar%2Fwcspbrk.c;fp=functions%2Fwchar%2Fwcspbrk.c;h=73bf721312cdc4707ebe6fb46d43368ef13e725c;hb=507d3eccbf4c74e4694165f9e00ab79d894b4f66;hp=0000000000000000000000000000000000000000;hpb=0150bb9ffe66236b6a47c5800d8beef669d5c047;p=pdclib.old diff --git a/functions/wchar/wcspbrk.c b/functions/wchar/wcspbrk.c new file mode 100644 index 0000000..73bf721 --- /dev/null +++ b/functions/wchar/wcspbrk.c @@ -0,0 +1,47 @@ +/* wcspbrk( 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 + +wchar_t * wcspbrk( const wchar_t * s1, const wchar_t * s2 ) +{ + const wchar_t * p1 = s1; + const wchar_t * p2; + while ( *p1 ) + { + p2 = s2; + while ( *p2 ) + { + if ( *p1 == *p2++ ) + { + return (wchar_t *) p1; + } + } + ++p1; + } + return NULL; +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE( wcspbrk( wabcde, L"x" ) == NULL ); + TESTCASE( wcspbrk( wabcde, L"xyz" ) == NULL ); + TESTCASE( wcspbrk( wabcdx, L"x" ) == &wabcdx[4] ); + TESTCASE( wcspbrk( wabcdx, L"xyz" ) == &wabcdx[4] ); + TESTCASE( wcspbrk( wabcdx, L"zyx" ) == &wabcdx[4] ); + TESTCASE( wcspbrk( wabcde, L"a" ) == &wabcde[0] ); + TESTCASE( wcspbrk( wabcde, L"abc" ) == &wabcde[0] ); + TESTCASE( wcspbrk( wabcde, L"cba" ) == &wabcde[0] ); + return TEST_RESULTS; +} +#endif