X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstring%2Fstrcat.c;h=eab90c15b212a187bad807a59d9735fbdc0fa132;hp=a0cef0e04267c24607c14e48394f7cadbcb036e7;hb=1d9d92ba957a0b8307c9a65c35867fde68e6533b;hpb=0a5395faab237ba9008352b0f4bee9659bbd3d5f 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; } -*/