From 419762f3c5da2a601e3c7427e25ae01293a73223 Mon Sep 17 00:00:00 2001 From: solar Date: Sun, 18 Jan 2004 16:05:17 +0000 Subject: [PATCH] Reviewed. --- functions/string/strcmp.c | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/functions/string/strcmp.c b/functions/string/strcmp.c index 17e138c..e72e376 100644 --- a/functions/string/strcmp.c +++ b/functions/string/strcmp.c @@ -5,34 +5,12 @@ // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -int strcmp( const char * s1, const char * s2 ) { /* TODO */ }; - -/* Therx code -{ - while ((*s1 != '\0') && (*s1 == *s2)) - { - s1++; - s2++; - } - return (*(unsigned char *) s1) - (*(unsigned char *) s2); -} -*/ - -/* PDPC code - unreviewed +int strcmp( const char * src_1, const char * src_2 ) { - const unsigned char *p1; - const unsigned char *p2; - - p1 = (const unsigned char *)s1; - p2 = (const unsigned char *)s2; - while (*p1 != '\0') + while ( ( *src_1 != '\0' ) && ( *src_1 == *src_2 ) ) { - if (*p1 < *p2) return (-1); - else if (*p1 > *p2) return (1); - p1++; - p2++; + ++src_1; + ++src_2; } - if (*p2 == '\0') return (0); - else return (-1); + return ( *src_1 - *src_2 ); } -*/ -- 2.40.0