]> pd.if.org Git - pdclib/blob - functions/string/strcoll.c
6b012b7a29a451a5542032d16979ecb652d79baf
[pdclib] / functions / string / strcoll.c
1 /* strcoll( 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
11 #include <locale.h>
12
13 int strcoll( const char * s1, const char * s2 )
14 {
15     while ( ( *s1 ) && ( _PDCLIB_lconv.ctype[(unsigned char)*s1].collation == _PDCLIB_lconv.ctype[(unsigned char)*s2].collation ) )
16     {
17         ++s1;
18         ++s2;
19     }
20     return ( _PDCLIB_lconv.ctype[(unsigned char)*s1].collation == _PDCLIB_lconv.ctype[(unsigned char)*s2].collation );
21 }
22
23 #endif
24
25 #ifdef TEST
26
27 #include "_PDCLIB_test.h"
28
29 int main( void )
30 {
31     char cmpabcde[] = "abcde";
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     return TEST_RESULTS;
39 }
40
41 #endif