X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstring%2Fstrcat.c;h=eab90c15b212a187bad807a59d9735fbdc0fa132;hb=c8f799d852e3698468a78954d82588e841cc0b70;hp=a0cef0e04267c24607c14e48394f7cadbcb036e7;hpb=e5456e3c2697c4e17fc9aa3439f2e305517b4d96;p=pdclib.old diff --git a/functions/string/strcat.c b/functions/string/strcat.c index a0cef0e..eab90c1 100644 --- a/functions/string/strcat.c +++ b/functions/string/strcat.c @@ -1,36 +1,23 @@ -// ---------------------------------------------------------------------------- -// $Id$ -// ---------------------------------------------------------------------------- -// Public Domain C Library - http://pdclib.sourceforge.net -// This code is Public Domain. Use, modify, and redistribute at will. -// ---------------------------------------------------------------------------- +/* ---------------------------------------------------------------------------- + * $Id$ + * ---------------------------------------------------------------------------- + * Public Domain C Library - http://pdclib.sourceforge.net + * This code is Public Domain. Use, modify, and redistribute at will. + * --------------------------------------------------------------------------*/ -char * strcat( char * restrict s1, const char * restrict s2 ) { /* TODO */ }; - -/* Therx code +char * strcat( char * restrict dest, const char * restrict src ) { - while (*s1) - { - s1++; - } - while (*s1++ = *s2++) + char * dest_p = dest; + if ( *dest_p != '\0' ) { - // EMPTY + while ( *++dest_p != '\0' ) + { + /* EMPTY */ + } } - return s1; -} -*/ - -/* PDPC code - unreviewed -{ - char *p = s1; - - while (*p != '\0') p++; - while ((*p = *s2) != '\0') + while ( (*dest_p++ = *src++) != '\0' ) { - p++; - s2++; + /* EMPTY */ } - return (s1); + return dest; } -*/