X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fwchar%2Fwcscmp.c;fp=functions%2Fwchar%2Fwcscmp.c;h=810fac2fed739fa000f9b227d68d3a4e697d060c;hb=14b5b78e19a79f590233caee7848e7cb19084088;hp=0000000000000000000000000000000000000000;hpb=41777e3d5dc655f59a8c3bcd071639e6878e853a;p=pdclib diff --git a/functions/wchar/wcscmp.c b/functions/wchar/wcscmp.c new file mode 100644 index 0000000..810fac2 --- /dev/null +++ b/functions/wchar/wcscmp.c @@ -0,0 +1,39 @@ +/* wcscmp( 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 + +int wcscmp( const wchar_t * s1, const wchar_t * s2 ) +{ + while ( ( *s1 ) && ( *s1 == *s2 ) ) + { + ++s1; + ++s2; + } + return ( *(wchar_t *)s1 - *(wchar_t *)s2 ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + wchar_t cmpabcde[] = L"abcde"; + wchar_t cmpabcd_[] = L"abcd\xfc"; + wchar_t empty[] = L""; + TESTCASE( wcscmp( wabcde, cmpabcde ) == 0 ); + TESTCASE( wcscmp( wabcde, wabcdx ) < 0 ); + TESTCASE( wcscmp( wabcdx, wabcde ) > 0 ); + TESTCASE( wcscmp( empty, wabcde ) < 0 ); + TESTCASE( wcscmp( wabcde, empty ) > 0 ); + TESTCASE( wcscmp( wabcde, cmpabcd_ ) < 0 ); + return TEST_RESULTS; +} +#endif