ReactOS 0.4.16-dev-822-gbcedb53
mbsicoll.cpp
Go to the documentation of this file.
1/***
2*mbsicoll.c - Collate MBCS strings, ignoring case
3*
4* Copyright (c) Microsoft Corporation. All rights reserved.
5*
6*Purpose:
7* Collate MBCS strings, ignoring case
8*
9*******************************************************************************/
10#ifndef _MBCS
11 #error This file should only be compiled with _MBCS defined
12#endif
13
14#include <corecrt_internal.h>
16#include <locale.h>
17
18/***
19* _mbsicoll - Collate MBCS strings, ignoring case
20*
21*Purpose:
22* Collates two strings for lexical order (ignoring case).
23* Strings are collated on a character basis, not a byte basis.
24*
25*Entry:
26* char *s1, *s2 = strings to collate
27*
28*Exit:
29* Returns <0 if s1 < s2
30* Returns 0 if s1 == s2
31* Returns >0 if s1 > s2
32* Returns _NLSCMPERROR is something went wrong
33*
34*Exceptions:
35* Input parameters are validated. Refer to the validation section of the function.
36*
37*******************************************************************************/
38
39extern "C" int __cdecl _mbsicoll_l(
40 const unsigned char *s1,
41 const unsigned char *s2,
43 )
44{
45 int ret;
46 _LocaleUpdate _loc_update(plocinfo);
47
48 /* validation section */
51
52 if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
53 return _stricoll_l((const char *)s1, (const char *)s2, plocinfo);
54
55 if ( 0 == (ret = __acrt_CompareStringA(
56 _loc_update.GetLocaleT(),
57 _loc_update.GetLocaleT()->mbcinfo->mblocalename,
59 (LPCSTR)s1,
60 -1,
61 (LPSTR)s2,
62 -1,
63 _loc_update.GetLocaleT()->mbcinfo->mbcodepage )) )
64 {
65 errno = EINVAL;
66 return _NLSCMPERROR;
67 }
68
69 return ret - 2;
70
71}
72
73extern "C" int (__cdecl _mbsicoll)(
74 const unsigned char *s1,
75 const unsigned char *s2
76 )
77{
78 return _mbsicoll_l(s1, s2, nullptr);
79}
#define EINVAL
Definition: acclib.h:90
#define __cdecl
Definition: accygwin.h:79
int __cdecl __acrt_CompareStringA(_In_opt_ _locale_t _Plocinfo, _In_ LPCWSTR _LocaleName, _In_ DWORD _DwCmpFlags, _In_CRT_NLS_string_(_CchCount1) PCCH _LpString1, _In_ int _CchCount1, _In_CRT_NLS_string_(_CchCount2) PCCH _LpString2, _In_ int _CchCount2, _In_ int _CodePage)
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
_Check_return_ _CRTIMP int __cdecl _stricoll_l(_In_z_ const char *str1, _In_z_ const char *str2, _In_opt_ _locale_t locale)
Definition: stubs.c:498
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
_Check_return_ _CRTIMP int __cdecl _mbsicoll(_In_z_ const unsigned char *_Str1, _In_z_ const unsigned char *_Str2)
_locale_t plocinfo
Definition: ismbbyte.cpp:75
int __cdecl _mbsicoll_l(const unsigned char *s1, const unsigned char *s2, _locale_t plocinfo)
Definition: mbsicoll.cpp:39
const unsigned char * s2
Definition: mbsicoll.cpp:77
struct S1 s1
#define errno
Definition: errno.h:18
#define _NLSCMPERROR
Definition: string.h:19
int ret
#define NORM_IGNORECASE
Definition: winnls.h:178
#define SORT_STRINGSORT
Definition: winnls.h:185
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182