X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstring%2Fstrcmp.c;h=17e138cdf2b989a389e385982112bbda9e6cd42f;hp=9906f49aa07b140883fc420c0c2dd1b91e50c285;hb=0a5395faab237ba9008352b0f4bee9659bbd3d5f;hpb=34893ecc2200dc7017c36a54cb6c5f4c2378b5ec diff --git a/functions/string/strcmp.c b/functions/string/strcmp.c index 9906f49..17e138c 100644 --- a/functions/string/strcmp.c +++ b/functions/string/strcmp.c @@ -6,3 +6,33 @@ // ---------------------------------------------------------------------------- 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 +{ + const unsigned char *p1; + const unsigned char *p2; + + p1 = (const unsigned char *)s1; + p2 = (const unsigned char *)s2; + while (*p1 != '\0') + { + if (*p1 < *p2) return (-1); + else if (*p1 > *p2) return (1); + p1++; + p2++; + } + if (*p2 == '\0') return (0); + else return (-1); +} +*/