update for HEAD-2003021201
[reactos.git] / lib / msvcrt / mbstring / mbsnicmp.c
1 #include <msvcrt/mbstring.h>
2
3
4 size_t _mbclen2(const unsigned int s);
5 unsigned int _mbbtoupper(unsigned int c);
6
7
8 int _mbsnicmp(const unsigned char *s1, const unsigned char *s2, size_t n)
9 {
10   if (n == 0)
11     return 0;
12   do {
13     if (_mbbtoupper(*s1) != _mbbtoupper(*s2))
14       return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2);
15     s1 += _mbclen2(*s1);
16     s2 += _mbclen2(*s2);
17
18     if (*s1 == 0)
19       break;
20     if (!_ismbblead(*s1))
21       n--;
22   } while (n > 0);
23   return 0;
24 }
25
26 int _mbsnbicmp(const unsigned char *s1, const unsigned char *s2, size_t n)
27 {
28   if (n == 0)
29     return 0;
30   do {
31     if (_mbbtoupper(*s1) != _mbbtoupper(*s2))
32       return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2);
33     s1 += _mbclen2(*s1);
34     s2 += _mbclen2(*s2);
35
36     if (*s1 == 0)
37       break;
38     n--;
39   } while (n > 0);
40   return 0;
41 }