X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fwchar%2Fwcsncat.c;h=633e54df6473e6aeb2adb3709888326b4daf5893;hp=b240009612f4ea1dd793bd955476c0aa5460c4aa;hb=abc15df6b9fae3374d24c7cf5c3ab94c605b2a6d;hpb=8894c921674bb116d0a7b8f23a55311e7a768019 diff --git a/functions/wchar/wcsncat.c b/functions/wchar/wcsncat.c index b240009..633e54d 100644 --- a/functions/wchar/wcsncat.c +++ b/functions/wchar/wcsncat.c @@ -1,60 +1,60 @@ -/* wcsncat( 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 - -wchar_t * wcsncat( wchar_t * _PDCLIB_restrict s1, - const wchar_t * _PDCLIB_restrict s2, - size_t n ) -{ - wchar_t * rc = s1; - while ( *s1 ) - { - ++s1; - } - while ( n && ( *s1++ = *s2++ ) ) - { - --n; - } - if ( n == 0 ) - { - *s1 = '\0'; - } - return rc; -} - -#endif - -#ifdef TEST -#include "_PDCLIB_test.h" - -int main( void ) -{ - wchar_t s[] = L"xx\0xxxxxx"; - TESTCASE( wcsncat( s, wabcde, 10 ) == s ); - TESTCASE( s[2] == L'a' ); - TESTCASE( s[6] == L'e' ); - TESTCASE( s[7] == L'\0' ); - TESTCASE( s[8] == L'x' ); - s[0] = L'\0'; - TESTCASE( wcsncat( s, wabcdx, 10 ) == s ); - TESTCASE( s[4] == L'x' ); - TESTCASE( s[5] == L'\0' ); - TESTCASE( wcsncat( s, L"\0", 10 ) == s ); - TESTCASE( s[5] == L'\0' ); - TESTCASE( s[6] == L'e' ); - TESTCASE( wcsncat( s, wabcde, 0 ) == s ); - TESTCASE( s[5] == L'\0' ); - TESTCASE( s[6] == L'e' ); - TESTCASE( wcsncat( s, wabcde, 3 ) == s ); - TESTCASE( s[5] == L'a' ); - TESTCASE( s[7] == L'c' ); - TESTCASE( s[8] == L'\0' ); - return TEST_RESULTS; -} -#endif +/* wcsncat( 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 + +wchar_t * wcsncat( wchar_t * _PDCLIB_restrict s1, + const wchar_t * _PDCLIB_restrict s2, + size_t n ) +{ + wchar_t * rc = s1; + while ( *s1 ) + { + ++s1; + } + while ( n && ( *s1++ = *s2++ ) ) + { + --n; + } + if ( n == 0 ) + { + *s1 = '\0'; + } + return rc; +} + +#endif + +#ifdef TEST +#include "_PDCLIB_test.h" + +int main( void ) +{ + wchar_t s[] = L"xx\0xxxxxx"; + TESTCASE( wcsncat( s, wabcde, 10 ) == s ); + TESTCASE( s[2] == L'a' ); + TESTCASE( s[6] == L'e' ); + TESTCASE( s[7] == L'\0' ); + TESTCASE( s[8] == L'x' ); + s[0] = L'\0'; + TESTCASE( wcsncat( s, wabcdx, 10 ) == s ); + TESTCASE( s[4] == L'x' ); + TESTCASE( s[5] == L'\0' ); + TESTCASE( wcsncat( s, L"\0", 10 ) == s ); + TESTCASE( s[5] == L'\0' ); + TESTCASE( s[6] == L'e' ); + TESTCASE( wcsncat( s, wabcde, 0 ) == s ); + TESTCASE( s[5] == L'\0' ); + TESTCASE( s[6] == L'e' ); + TESTCASE( wcsncat( s, wabcde, 3 ) == s ); + TESTCASE( s[5] == L'a' ); + TESTCASE( s[7] == L'c' ); + TESTCASE( s[8] == L'\0' ); + return TEST_RESULTS; +} +#endif