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