ReactOS  0.4.13-dev-247-g0f29b3f
mbsicoll.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS system libraries
4  * FILE: lib/sdk/crt/mbstring/mbsicoll.c
5  * PURPOSE:
6  * PROGRAMER: Ariadne
7  * UPDATE HISTORY:
8  * 12/04/99: Created
9  */
10 #include <mbstring.h>
11 #include <mbctype.h>
12 #include <ctype.h>
13 
14 int colldif(unsigned short c1, unsigned short c2);
15 /*
16  * @implemented
17  */
18 int _mbsicoll(const unsigned char *str1, const unsigned char *str2)
19 {
20  unsigned char *s1 = (unsigned char *)str1;
21  unsigned char *s2 = (unsigned char *)str2;
22 
23  unsigned short *short_s1, *short_s2;
24 
25  int l1, l2;
26 
27  while ( *s1 != 0 ) {
28 
29  if (*s1 == 0)
30  break;
31 
32  l1 = _ismbblead(*s1);
33  l2 = _ismbblead(*s2);
34  if ( !l1 && !l2 ) {
35 
36  if (toupper(*s1) != toupper(*s2))
37  return colldif(*s1, *s2);
38  else {
39  s1 += 1;
40  s2 += 1;
41  }
42  }
43  else if ( l1 && l2 ){
44  short_s1 = (unsigned short *)s1;
45  short_s2 = (unsigned short *)s2;
46  if ( _mbctoupper(*short_s1) != _mbctoupper(*short_s2 ))
47  return colldif(*short_s1, *short_s2);
48  else {
49  s1 += 2;
50  s2 += 2;
51 
52  }
53  }
54  else
55  return colldif(*s1, *s2);
56  } ;
57  return 0;
58 }
struct S2 s2
int toupper(int c)
Definition: utclib.c:881
_Check_return_ _CRTIMP unsigned int __cdecl _mbctoupper(_In_ unsigned int _Ch)
struct S1 s1
int __cdecl _ismbblead(unsigned int)
Definition: ismblead.c:20
int colldif(unsigned short c1, unsigned short c2)
Definition: mbsncoll.c:13
int _mbsicoll(const unsigned char *str1, const unsigned char *str2)
Definition: mbsicoll.c:18