ReactOS 0.4.16-dev-959-g2ec3a19
wcsnicmp.cpp File Reference
#include <corecrt_internal.h>
#include <ctype.h>
#include <corecrt_internal_securecrt.h>
#include <locale.h>
#include <string.h>
Include dependency graph for wcsnicmp.cpp:

Go to the source code of this file.

Functions

int __cdecl _wcsnicmp_l (wchar_t const *const lhs, wchar_t const *const rhs, size_t const count, _locale_t const plocinfo)
 
int __cdecl __ascii_wcsnicmp (wchar_t const *const lhs, wchar_t const *const rhs, size_t const count)
 
int __cdecl _wcsnicmp (wchar_t const *const lhs, wchar_t const *const rhs, size_t const count)
 

Function Documentation

◆ __ascii_wcsnicmp()

int __cdecl __ascii_wcsnicmp ( wchar_t const *const  lhs,
wchar_t const *const  rhs,
size_t const  count 
)

Definition at line 87 of file wcsnicmp.cpp.

92{
93 if (count == 0)
94 {
95 return 0;
96 }
97
98 unsigned short const * lhs_ptr = reinterpret_cast<unsigned short const *>(lhs);
99 unsigned short const * rhs_ptr = reinterpret_cast<unsigned short const *>(rhs);
100
101 int result;
102 int lhs_value;
103 int rhs_value;
104 size_t remaining = count;
105 do
106 {
107 lhs_value = __ascii_towlower(*lhs_ptr++);
108 rhs_value = __ascii_towlower(*rhs_ptr++);
109 result = lhs_value - rhs_value;
110 }
111 while (result == 0 && lhs_value != 0 && --remaining != 0);
112
113 return result;
114}
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint64EXT * result
Definition: glext.h:11304
__forceinline int __CRTDECL __ascii_towlower(int const _C)
Definition: ctype.h:180

Referenced by _wcsnicmp(), and _wcsnicmp_l().

◆ _wcsnicmp()

int __cdecl _wcsnicmp ( wchar_t const *const  lhs,
wchar_t const *const  rhs,
size_t const  count 
)

Definition at line 116 of file wcsnicmp.cpp.

121{
122 if (!__acrt_locale_changed())
123 {
124 /* validation section */
125 _VALIDATE_RETURN(lhs != nullptr, EINVAL, _NLSCMPERROR);
126 _VALIDATE_RETURN(rhs != nullptr, EINVAL, _NLSCMPERROR);
127
128 return __ascii_wcsnicmp(lhs, rhs, count);
129 }
130
131 return _wcsnicmp_l(lhs, rhs, count, nullptr);
132}
#define EINVAL
Definition: acclib.h:90
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
#define _NLSCMPERROR
Definition: string.h:19
int __cdecl __ascii_wcsnicmp(wchar_t const *const lhs, wchar_t const *const rhs, size_t const count)
Definition: wcsnicmp.cpp:87
int __cdecl _wcsnicmp_l(wchar_t const *const lhs, wchar_t const *const rhs, size_t const count, _locale_t const plocinfo)
Definition: wcsnicmp.cpp:44

◆ _wcsnicmp_l()

int __cdecl _wcsnicmp_l ( wchar_t const *const  lhs,
wchar_t const *const  rhs,
size_t const  count,
_locale_t const  plocinfo 
)

Definition at line 44 of file wcsnicmp.cpp.

50{
51 /* validation section */
52 _VALIDATE_RETURN(lhs != nullptr, EINVAL, _NLSCMPERROR);
53 _VALIDATE_RETURN(rhs != nullptr, EINVAL, _NLSCMPERROR);
54
55 if (count == 0)
56 {
57 return 0;
58 }
59
60 _LocaleUpdate _loc_update(plocinfo);
61
62 // This check is still worth doing for wide but not narrow because
63 // we need to consult the UTF-16 ctype map for towlower operations.
64 if (_loc_update.GetLocaleT()->locinfo->locale_name[LC_CTYPE] == nullptr)
65 {
66 return __ascii_wcsnicmp(lhs, rhs, count);
67 }
68
69 unsigned short const * lhs_ptr = reinterpret_cast<unsigned short const *>(lhs);
70 unsigned short const * rhs_ptr = reinterpret_cast<unsigned short const *>(rhs);
71
72 int result;
73 int lhs_value;
74 int rhs_value;
75 size_t remaining = count;
76 do
77 {
78 lhs_value = _towlower_internal(*lhs_ptr++, _loc_update.GetLocaleT());
79 rhs_value = _towlower_internal(*rhs_ptr++, _loc_update.GetLocaleT());
80 result = lhs_value - rhs_value;
81 }
82 while (result == 0 && lhs_value != 0 && --remaining != 0);
83
84 return result;
85}
_Check_return_ wint_t _towlower_internal(_In_ unsigned short const c, _In_ _locale_t const locale)
#define LC_CTYPE
Definition: locale.h:19
_locale_t plocinfo
Definition: ismbbyte.cpp:75

Referenced by _wcsnicmp().