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