X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fwchar%2Fwcscmp.c;fp=functions%2Fwchar%2Fwcscmp.c;h=810fac2fed739fa000f9b227d68d3a4e697d060c;hb=507d3eccbf4c74e4694165f9e00ab79d894b4f66;hp=0000000000000000000000000000000000000000;hpb=0150bb9ffe66236b6a47c5800d8beef669d5c047;p=pdclib.old 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