From fedb223525324e7ce171f5fe6903430fbd9557bb Mon Sep 17 00:00:00 2001 From: solar Date: Sun, 18 Jan 2004 15:47:39 +0000 Subject: [PATCH] Reviewed. --- functions/string/strcat.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/functions/string/strcat.c b/functions/string/strcat.c index a0cef0e..dfbc135 100644 --- a/functions/string/strcat.c +++ b/functions/string/strcat.c @@ -5,32 +5,19 @@ // 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) + char * dest_p = dest; + if ( *dest_p != '\0' ) { - s1++; + while ( *++dest_p != '\0' ) + { + // EMPTY + } } - while (*s1++ = *s2++) + while ( (*dest_p++ = *src++) != '\0' ) { // EMPTY } - return s1; -} -*/ - -/* PDPC code - unreviewed -{ - char *p = s1; - - while (*p != '\0') p++; - while ((*p = *s2) != '\0') - { - p++; - s2++; - } - return (s1); + return dest; } -*/ -- 2.40.0