X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstring%2Fstrcmp.c;h=17e138cdf2b989a389e385982112bbda9e6cd42f;hb=e5456e3c2697c4e17fc9aa3439f2e305517b4d96;hp=9906f49aa07b140883fc420c0c2dd1b91e50c285;hpb=dcc8a8e99f69e090a03b7b868443addbc0817820;p=pdclib.old 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); +} +*/