ReactOS 0.4.16-dev-835-gd769f56
mbsnbico.cpp
Go to the documentation of this file.
1/***
2*mbsnbico.c - Collate n bytes of strings, ignoring case (MBCS)
3*
4* Copyright (c) Microsoft Corporation. All rights reserved.
5*
6*Purpose:
7* Collate n bytes of strings, ignoring case (MBCS)
8*
9*******************************************************************************/
10#ifndef _MBCS
11 #error This file should only be compiled with _MBCS defined
12#endif
13
15#include <locale.h>
16
17
18/***
19* _mbsnbicoll - Collate n bytes of strings, ignoring case (MBCS)
20*
21*Purpose:
22* Collates up to n bytes of two strings for lexical order.
23* Strings are collated on a character basis, not a byte basis.
24* Case of characters is not considered.
25*
26*Entry:
27* unsigned char *s1, *s2 = strings to collate
28* size_t n = maximum number of bytes to collate
29*
30*Exit:
31* Returns <0 if s1 < s2
32* Returns 0 if s1 == s2
33* Returns >0 if s1 > s2
34* Returns _NLSCMPERROR is something went wrong
35*
36*Exceptions:
37* Input parameters are validated. Refer to the validation section of the function.
38*
39*******************************************************************************/
40
41extern "C" int __cdecl _mbsnbicoll_l(
42 const unsigned char *s1,
43 const unsigned char *s2,
44 size_t n,
46 )
47{
48 int ret;
49 _LocaleUpdate _loc_update(plocinfo);
50
51 if (n == 0)
52 return 0;
53
54 /* validation section */
58
59 if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
60 return _strnicoll_l((const char *)s1, (const char *)s2, n, plocinfo);
61
62 if ( 0 == (ret = __acrt_CompareStringA(_loc_update.GetLocaleT(),
63 _loc_update.GetLocaleT()->mbcinfo->mblocalename,
65 (const char *)s1,
66 (int)n,
67 (char *)s2,
68 (int)n,
69 _loc_update.GetLocaleT()->mbcinfo->mbcodepage )) )
70 return _NLSCMPERROR;
71
72 return ret - 2;
73
74}
75extern "C" int __cdecl _mbsnbicoll(
76 const unsigned char *s1,
77 const unsigned char *s2,
78 size_t n
79 )
80{
81 return _mbsnbicoll_l(s1, s2, n, nullptr);
82}
#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 _strnicoll_l(_In_z_ const char *str1, _In_z_ const char *str2, _In_ size_t maxcount, _In_opt_ _locale_t locale)
Definition: stubs.c:564
GLdouble n
Definition: glext.h:7729
#define INT_MAX
Definition: intsafe.h:150
_locale_t plocinfo
Definition: ismbbyte.cpp:75
int __cdecl _mbsnbicoll(const unsigned char *s1, const unsigned char *s2, size_t n)
Definition: mbsnbico.cpp:75
int __cdecl _mbsnbicoll_l(const unsigned char *s1, const unsigned char *s2, size_t n, _locale_t plocinfo)
Definition: mbsnbico.cpp:41
struct S1 s1
struct S2 s2
#define _NLSCMPERROR
Definition: string.h:19
int ret
#define NORM_IGNORECASE
Definition: winnls.h:178
#define SORT_STRINGSORT
Definition: winnls.h:185