ReactOS 0.4.16-dev-959-g2ec3a19
mbsnbicm.cpp File Reference
#include <corecrt_internal_mbstring.h>
#include <locale.h>
#include <string.h>
Include dependency graph for mbsnbicm.cpp:

Go to the source code of this file.

Functions

int __cdecl _mbsnbicmp_l (const unsigned char *s1, const unsigned char *s2, size_t n, _locale_t plocinfo)
 
 int (__cdecl _mbsnbicmp)(const unsigned char *s1
 

Variables

const unsigned chars2
 
const unsigned char size_t n
 

Function Documentation

◆ _mbsnbicmp_l()

int __cdecl _mbsnbicmp_l ( const unsigned char s1,
const unsigned char s2,
size_t  n,
_locale_t  plocinfo 
)

Definition at line 43 of file mbsnbicm.cpp.

49{
50 unsigned short c1, c2;
51 _LocaleUpdate _loc_update(plocinfo);
52
53 if (n==0)
54 return(0);
55
56 if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
57 return _strnicmp((const char *)s1, (const char *)s2, n);
58
59 /* validation section */
62
63 while (n--) {
64
65 c1 = *s1++;
66 if ( _ismbblead_l(c1, _loc_update.GetLocaleT()) )
67 {
68 if (n==0)
69 {
70 c1 = 0; /* 'naked' lead - end of string */
71 c2 = _ismbblead_l(*s2, _loc_update.GetLocaleT()) ? 0 : *s2;
72 goto test;
73 }
74 if (*s1 == '\0')
75 c1 = 0;
76 else {
77 c1 = ((c1<<8) | *s1++);
78
79 if ( ((c1 >= _MBUPPERLOW1_MT(_loc_update.GetLocaleT())) &&
80 (c1 <= _MBUPPERHIGH1_MT(_loc_update.GetLocaleT()))) )
81 c1 += _MBCASEDIFF1_MT(_loc_update.GetLocaleT());
82 else if ( ((c1 >= _MBUPPERLOW2_MT(_loc_update.GetLocaleT())) &&
83 (c1 <= _MBUPPERHIGH2_MT(_loc_update.GetLocaleT()))) )
84 c1 += _MBCASEDIFF2_MT(_loc_update.GetLocaleT());
85 }
86 }
87 else
88 c1 = _mbbtolower_l(c1, _loc_update.GetLocaleT());
89
90 c2 = *s2++;
91 if ( _ismbblead_l(c2, _loc_update.GetLocaleT()) )
92 {
93 if (n==0)
94 {
95 c2 = 0; /* 'naked' lead - end of string */
96 goto test;
97 }
98 n--;
99 if (*s2 == '\0')
100 c2 = 0;
101 else {
102 c2 = ((c2<<8) | *s2++);
103
104 if ( ((c2 >= _MBUPPERLOW1_MT(_loc_update.GetLocaleT())) &&
105 (c2 <= _MBUPPERHIGH1_MT(_loc_update.GetLocaleT()))) )
106 c2 += _MBCASEDIFF1_MT(_loc_update.GetLocaleT());
107 else if ( ((c2 >= _MBUPPERLOW2_MT(_loc_update.GetLocaleT())) &&
108 (c2 <= _MBUPPERHIGH2_MT(_loc_update.GetLocaleT()))) )
109 c2 += _MBCASEDIFF2_MT(_loc_update.GetLocaleT());
110 }
111 }
112 else
113 c2 = _mbbtolower_l(c2, _loc_update.GetLocaleT());
114
115test:
116 if (c1 != c2)
117 return( (c1 > c2) ? 1 : -1);
118
119 if (c1 == 0)
120 return(0);
121 }
122
123 return(0);
124}
#define EINVAL
Definition: acclib.h:90
#define _MBUPPERHIGH1_MT(p)
#define _MBCASEDIFF2_MT(p)
#define _MBUPPERLOW2_MT(p)
#define _mbbtolower_l(_c, p)
#define _MBUPPERHIGH2_MT(p)
#define _ismbblead_l(_c, p)
#define _MBCASEDIFF1_MT(p)
#define _MBUPPERLOW1_MT(p)
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
GLdouble n
Definition: glext.h:7729
_locale_t plocinfo
Definition: ismbbyte.cpp:75
const unsigned char * s2
Definition: mbsnbicm.cpp:128
struct S1 s1
#define test
Definition: rosglue.h:37
#define _NLSCMPERROR
Definition: string.h:19

◆ int()

int ( __cdecl  _mbsnbicmp) const

Variable Documentation

◆ n

Initial value:
{
return _mbsnbicmp_l(s1, s2, n, nullptr)
int __cdecl _mbsnbicmp_l(const unsigned char *s1, const unsigned char *s2, size_t n, _locale_t plocinfo)
Definition: mbsnbicm.cpp:43

Definition at line 129 of file mbsnbicm.cpp.

◆ s2

Definition at line 128 of file mbsnbicm.cpp.

Referenced by _mbsnbicmp_l().