]> pd.if.org Git - pdclib/blob - functions/string/strcoll.c
PDCLib includes with quotes, not <>.
[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 "_PDCLIB_locale.h"
12
13 int strcoll( const char * s1, const char * s2 )
14 {
15     const _PDCLIB_ctype_t * ctype = _PDCLIB_threadlocale()->_CType;
16
17     while ( ( *s1 ) && ( ctype[(unsigned char)*s1].collation == ctype[(unsigned char)*s2].collation ) )
18     {
19         ++s1;
20         ++s2;
21     }
22     return ( ctype[(unsigned char)*s1].collation == ctype[(unsigned char)*s2].collation );
23 }
24
25 #endif
26
27 #ifdef TEST
28 #include "_PDCLIB_test.h"
29
30 int main( void )
31 {
32     char cmpabcde[] = "abcde";
33     char empty[] = "";
34     TESTCASE( strcmp( abcde, cmpabcde ) == 0 );
35     TESTCASE( strcmp( abcde, abcdx ) < 0 );
36     TESTCASE( strcmp( abcdx, abcde ) > 0 );
37     TESTCASE( strcmp( empty, abcde ) < 0 );
38     TESTCASE( strcmp( abcde, empty ) > 0 );
39     return TEST_RESULTS;
40 }
41 #endif