ReactOS 0.4.16-dev-959-g2ec3a19
ismbsle.cpp
Go to the documentation of this file.
1/***
2*ismbslead.c - True _ismbslead function
3*
4* Copyright (c) Microsoft Corporation. All rights reserved.
5*
6*Purpose:
7* Contains the function _ismbslead, which is a true context-sensitive
8* MBCS lead-byte function. While much less efficient than _ismbblead,
9* it is also much more sophisticated, in that it determines whether a
10* given sub-string pointer points to a lead byte or not, taking into
11* account the context in the string.
12*
13*******************************************************************************/
14#ifndef _MBCS
15 #error This file should only be compiled with _MBCS defined
16#endif
17
19#include <locale.h>
20
21
22/***
23* int _ismbslead(const unsigned char *string, const unsigned char *current);
24*
25*Purpose:
26*
27* _ismbslead - Check, in context, for MBCS lead byte
28*
29*Entry:
30* unsigned char *string - ptr to start of string or previous known lead byte
31* unsigned char *current - ptr to position in string to be tested
32*
33*Exit:
34* TRUE : -1
35* FALSE : 0
36*
37*Exceptions:
38* Input parameters are validated. Refer to the validation section of the function.
39*
40*******************************************************************************/
41
42extern "C" int __cdecl _ismbslead_l(
43 const unsigned char *string,
44 const unsigned char *current,
46 )
47{
48 /* validation section */
49 _VALIDATE_RETURN(string != nullptr, EINVAL, 0);
50 _VALIDATE_RETURN(current != nullptr, EINVAL, 0);
51
52 _LocaleUpdate _loc_update(plocinfo);
53
54 if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
55 return 0;
56
57 while (string <= current && *string) {
58 if ( _ismbblead_l((*string), _loc_update.GetLocaleT()) ) {
59 if (string++ == current) /* check lead byte */
60 return -1;
61 if (!(*string))
62 return 0;
63 }
64 ++string;
65 }
66
67 return 0;
68}
69
70extern "C" int (__cdecl _ismbslead)(
71 const unsigned char *string,
72 const unsigned char *current
73 )
74{
75 return _ismbslead_l(string, current, nullptr);
76}
#define EINVAL
Definition: acclib.h:90
#define __cdecl
Definition: accygwin.h:79
#define _ismbblead_l(_c, p)
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
_Check_return_ _CRTIMP int __cdecl _ismbslead(_In_reads_z_(_Pos - _Str+1) const unsigned char *_Str, _In_z_ const unsigned char *_Pos)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
_locale_t plocinfo
Definition: ismbbyte.cpp:75
const unsigned char * current
Definition: ismbsle.cpp:74
int __cdecl _ismbslead_l(const unsigned char *string, const unsigned char *current, _locale_t plocinfo)
Definition: ismbsle.cpp:42
char string[160]
Definition: util.h:11