X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fwchar%2Fwmemcmp.c;fp=functions%2Fwchar%2Fwmemcmp.c;h=2d58914de3de7aa6798c1c14931cfe9e848f0f10;hb=507d3eccbf4c74e4694165f9e00ab79d894b4f66;hp=0000000000000000000000000000000000000000;hpb=0150bb9ffe66236b6a47c5800d8beef669d5c047;p=pdclib.old diff --git a/functions/wchar/wmemcmp.c b/functions/wchar/wmemcmp.c new file mode 100644 index 0000000..2d58914 --- /dev/null +++ b/functions/wchar/wmemcmp.c @@ -0,0 +1,39 @@ +/* wmemcmp( const wchar_t *, const wchar_t *, size_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 wmemcmp( const wchar_t * p1, const wchar_t * p2, size_t n ) +{ + while ( n-- ) + { + if ( *p1 != *p2 ) + { + return *p1 - *p2; + } + ++p1; + ++p2; + } + return 0; +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + wchar_t const xxxxx[] = L"xxxxx"; + TESTCASE( wmemcmp( wabcde, wabcdx, 5 ) < 0 ); + TESTCASE( wmemcmp( wabcde, wabcdx, 4 ) == 0 ); + TESTCASE( wmemcmp( wabcde, xxxxx, 0 ) == 0 ); + TESTCASE( wmemcmp( xxxxx, wabcde, 1 ) > 0 ); + return 0; +} +#endif