ReactOS 0.4.16-dev-927-g467dec4
mbsnbcmp.cpp File Reference
#include <corecrt_internal_mbstring.h>
#include <locale.h>
Include dependency graph for mbsnbcmp.cpp:

Go to the source code of this file.

Functions

int __cdecl _mbsnbcmp_l (const unsigned char *s1, const unsigned char *s2, size_t n, _locale_t plocinfo)
 
 int (__cdecl _mbsnbcmp)(const unsigned char *s1
 

Variables

const unsigned chars2
 
const unsigned char size_t n
 

Function Documentation

◆ _mbsnbcmp_l()

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

Definition at line 43 of file mbsnbcmp.cpp.

49{
50 unsigned short c1, c2;
51
52 if (n==0)
53 return(0);
54
55 _LocaleUpdate _loc_update(plocinfo);
56
57 if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
58 return strncmp((const char *)s1, (const char *)s2, n);
59
60 /* validation section */
63
64 while (n--) {
65
66 c1 = *s1++;
67 if ( _ismbblead_l(c1, _loc_update.GetLocaleT()) )
68 {
69 if (n==0)
70 {
71 c1 = 0; /* 'naked' lead - end of string */
72 c2 = _ismbblead_l(*s2, _loc_update.GetLocaleT()) ? 0 : *s2;
73 goto test;
74 }
75 c1 = ( (*s1 == '\0') ? 0 : ((c1<<8) | *s1++) );
76 }
77
78 c2 = *s2++;
79 if ( _ismbblead_l(c2, _loc_update.GetLocaleT()) )
80 {
81 if (n==0)
82 {
83 c2 = 0; /* 'naked' lead - end of string */
84 goto test;
85 }
86 --n;
87 c2 = ( (*s2 == '\0') ? 0 : ((c2<<8) | *s2++) );
88 }
89test:
90 if (c1 != c2)
91 return( (c1 > c2) ? 1 : -1);
92
93 if (c1 == 0)
94 return(0);
95 }
96
97 return(0);
98}
#define EINVAL
Definition: acclib.h:90
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define _ismbblead_l(_c, p)
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
GLdouble n
Definition: glext.h:7729
_locale_t plocinfo
Definition: ismbbyte.cpp:75
const unsigned char * s2
Definition: mbsnbcmp.cpp:102
const unsigned char size_t n
Definition: mbsnbcmp.cpp:105
struct S1 s1
#define test
Definition: rosglue.h:37
#define _NLSCMPERROR
Definition: string.h:19

◆ int()

int ( __cdecl  _mbsnbcmp) const

Variable Documentation

◆ n

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

Definition at line 103 of file mbsnbcmp.cpp.

Referenced by _mbsnbcmp_l().

◆ s2

Definition at line 102 of file mbsnbcmp.cpp.

Referenced by _mbsnbcmp_l().