ReactOS 0.4.15-dev-7907-g95bf896
mbsicmp.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/mbsicmp.c
5 * PURPOSE: Duplicates a multi byte string
6 * PROGRAMER: Ariadne
7 * UPDATE HISTORY:
8 * 12/04/99: Created
9 */
10#include <precomp.h>
11#include <mbstring.h>
12
13/*
14 * @implemented
15 */
16int _mbsicmp(const unsigned char *str1, const unsigned char *str2)
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}
int toupper(int c)
Definition: utclib.c:881
_Check_return_ _CRTIMP unsigned int __cdecl _mbctoupper(_In_ unsigned int _Ch)
int _mbsicmp(const unsigned char *str1, const unsigned char *str2)
Definition: mbsicmp.c:16
struct S1 s1
struct S2 s2
int __cdecl _ismbblead(unsigned int)
Definition: ismblead.c:20