]> pd.if.org Git - pdclib/blob - functions/wchar/wcscat.c
dos2unix
[pdclib] / functions / wchar / wcscat.c
1 /* wcscat( wchar_t *, const wchar_t * )
2
3    This file is part of the Public Domain C Library (PDCLib).
4    Permission is granted to use, modify, and / or redistribute at will.
5 */
6
7 #include <wchar.h>
8
9 #ifndef REGTEST
10
11 wchar_t * wcscat( wchar_t * _PDCLIB_restrict s1, 
12                   const wchar_t * _PDCLIB_restrict s2 )
13 {
14     wchar_t * rc = s1;
15     if ( *s1 )
16     {
17         while ( *++s1 );
18     }
19     while ( (*s1++ = *s2++) );
20     return rc;
21 }
22
23 #endif
24
25 #ifdef TEST
26 #include "_PDCLIB_test.h"
27
28 int main( void )
29 {
30     wchar_t s[] = L"xx\0xxxxxx";
31     TESTCASE( wcscat( s, wabcde ) == s );
32     TESTCASE( s[2] == L'a' );
33     TESTCASE( s[6] == L'e' );
34     TESTCASE( s[7] == L'\0' );
35     TESTCASE( s[8] == L'x' );
36     s[0] = L'\0';
37     TESTCASE( wcscat( s, wabcdx ) == s );
38     TESTCASE( s[4] == L'x' );
39     TESTCASE( s[5] == L'\0' );
40     TESTCASE( wcscat( s, L"\0" ) == s );
41     TESTCASE( s[5] == L'\0' );
42     TESTCASE( s[6] == L'e' );
43     return TEST_RESULTS;
44 }
45 #endif