]> pd.if.org Git - pdclib/blob - functions/string/strcat.c
PDCLib includes with quotes, not <>.
[pdclib] / functions / string / strcat.c
1 /* strcat( char *, const char * )
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 <string.h>
8
9 #ifndef REGTEST
10
11 char * strcat( char * _PDCLIB_restrict s1, const char * _PDCLIB_restrict s2 )
12 {
13     char * rc = s1;
14     if ( *s1 )
15     {
16         while ( *++s1 );
17     }
18     while ( (*s1++ = *s2++) );
19     return rc;
20 }
21
22 #endif
23
24 #ifdef TEST
25 #include "_PDCLIB_test.h"
26
27 int main( void )
28 {
29     char s[] = "xx\0xxxxxx";
30     TESTCASE( strcat( s, abcde ) == s );
31     TESTCASE( s[2] == 'a' );
32     TESTCASE( s[6] == 'e' );
33     TESTCASE( s[7] == '\0' );
34     TESTCASE( s[8] == 'x' );
35     s[0] = '\0';
36     TESTCASE( strcat( s, abcdx ) == s );
37     TESTCASE( s[4] == 'x' );
38     TESTCASE( s[5] == '\0' );
39     TESTCASE( strcat( s, "\0" ) == s );
40     TESTCASE( s[5] == '\0' );
41     TESTCASE( s[6] == 'e' );
42     return TEST_RESULTS;
43 }
44 #endif