]> pd.if.org Git - pdclib/blob - functions/string/strcmp.c
Merged PDPCLIB and Therx code.
[pdclib] / functions / string / strcmp.c
1 // ----------------------------------------------------------------------------
2 // $Id$
3 // ----------------------------------------------------------------------------
4 // Public Domain C Library - http://pdclib.sourceforge.net
5 // This code is Public Domain. Use, modify, and redistribute at will.
6 // ----------------------------------------------------------------------------
7
8 int strcmp( const char * s1, const char * s2 ) { /* TODO */ };
9
10 /* Therx code
11 {
12     while ((*s1 != '\0') && (*s1 == *s2))
13     {
14         s1++;
15         s2++;
16     }
17     return (*(unsigned char *) s1) - (*(unsigned char *) s2);
18 }
19 */
20
21 /* PDPC code - unreviewed
22 {
23     const unsigned char *p1;
24     const unsigned char *p2;
25     
26     p1 = (const unsigned char *)s1;
27     p2 = (const unsigned char *)s2;
28     while (*p1 != '\0')
29     {
30         if (*p1 < *p2) return (-1);
31         else if (*p1 > *p2) return (1);
32         p1++;
33         p2++;
34     }
35     if (*p2 == '\0') return (0);
36     else return (-1);
37 }
38 */