ReactOS  0.4.13-dev-99-g7e18b6d
mbsicmp.c File Reference
#include <precomp.h>
#include <mbstring.h>
Include dependency graph for mbsicmp.c:

Go to the source code of this file.

Functions

int _mbsicmp (const unsigned char *str1, const unsigned char *str2)
 

Function Documentation

◆ _mbsicmp()

int _mbsicmp ( const unsigned char str1,
const unsigned char str2 
)

Definition at line 16 of file mbsicmp.c.

17 {
18  unsigned char *s1 = (unsigned char *)str1;
19  unsigned char *s2 = (unsigned char *)str2;
20 
21  unsigned short *short_s1, *short_s2;
22 
23  int l1, l2;
24 
25  do {
26 
27  if (*s1 == 0)
28  break;
29 
30  l1 = _ismbblead(*s1);
31  l2 = _ismbblead(*s2);
32  if ( !l1 && !l2 ) {
33 
34  if (toupper(*s1) != toupper(*s2))
35  return toupper(*s1) - toupper(*s2);
36  else {
37  s1 += 1;
38  s2 += 1;
39  }
40  }
41  else if ( l1 && l2 ){
42  short_s1 = (unsigned short *)s1;
43  short_s2 = (unsigned short *)s2;
44  if ( _mbctoupper(*short_s1) != _mbctoupper(*short_s2 ))
45  return _mbctoupper(*short_s1) - _mbctoupper(*short_s2);
46  else {
47  s1 += 2;
48  s2 += 2;
49  }
50  }
51  else
52  return *s1 - *s2;
53  } while (*s1 != 0);
54  return 0;
55 
56  while (toupper(*s1) == toupper(*s2))
57  {
58  if (*s1 == 0)
59  return 0;
60  s1++;
61  s2++;
62  }
63  return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)(s2));
64 }
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