1 /* strcmp( const char *, const char * )
2 
3    This file is part of the Public Domain C Library (PDCLib).
4    Permission is granted to use, modify, and / or redistribute at will.
5 */
6 
7 #include <string.h>
8 
9 #ifndef REGTEST
10 
strcmp(const char * s1,const char * s2)11 int strcmp( const char * s1, const char * s2 )
12 {
13     while ( ( *s1 ) && ( *s1 == *s2 ) )
14     {
15         ++s1;
16         ++s2;
17     }
18 
19     return ( *( unsigned char * )s1 - * ( unsigned char * )s2 );
20 }
21 
22 #endif
23 
24 #ifdef TEST
25 
26 #include "_PDCLIB_test.h"
27 
main(void)28 int main( void )
29 {
30     char cmpabcde[] = "abcde";
31     char cmpabcd_[] = "abcd\xfc";
32     char empty[] = "";
33     TESTCASE( strcmp( abcde, cmpabcde ) == 0 );
34     TESTCASE( strcmp( abcde, abcdx ) < 0 );
35     TESTCASE( strcmp( abcdx, abcde ) > 0 );
36     TESTCASE( strcmp( empty, abcde ) < 0 );
37     TESTCASE( strcmp( abcde, empty ) > 0 );
38     TESTCASE( strcmp( abcde, cmpabcd_ ) < 0 );
39     return TEST_RESULTS;
40 }
41 
42 #endif
43