ReactOS 0.4.16-dev-927-g467dec4
mbsnextc.cpp
Go to the documentation of this file.
1/***
2*mbsnextc.c - Get the next character in an MBCS string.
3*
4* Copyright (c) Microsoft Corporation. All rights reserved.
5*
6*Purpose:
7* To return the value of the next character in an MBCS string.
8*
9*******************************************************************************/
10#ifndef _MBCS
11 #error This file should only be compiled with _MBCS defined
12#endif
13
15#include <locale.h>
16#include <stdlib.h>
17
18#pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26018
19
20/***
21*_mbsnextc: Returns the next character in a string.
22*
23*Purpose:
24* To return the value of the next character in an MBCS string.
25* Does not advance pointer to the next character.
26*
27*Entry:
28* unsigned char *s = string
29*
30*Exit:
31* unsigned int next = next character.
32*
33*Exceptions:
34* Input parameters are validated. Refer to the validation section of the function.
35*
36*******************************************************************************/
37
38extern "C" unsigned int __cdecl _mbsnextc_l(
39 const unsigned char *s,
41 )
42{
43 unsigned int next = 0;
44 _LocaleUpdate _loc_update(plocinfo);
45
46 /* validation section */
47 _VALIDATE_RETURN(s != nullptr, EINVAL, 0);
48
49 /* don't skip forward 2 if the leadbyte is followed by EOS (dud string)
50 also don't assert as we are too low-level
51 */
52 if ( _ismbblead_l(*s, _loc_update.GetLocaleT()) && s[1]!='\0')
53 next = ((unsigned int) *s++) << 8;
54
55 next += (unsigned int) *s;
56
57 return(next);
58}
59extern "C" unsigned int (__cdecl _mbsnextc)(
60 const unsigned char *s
61 )
62{
63 return _mbsnextc_l(s, nullptr);
64}
#define EINVAL
Definition: acclib.h:90
#define __cdecl
Definition: accygwin.h:79
#define _ismbblead_l(_c, p)
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLdouble s
Definition: gl.h:2039
_Check_return_ _CRTIMP unsigned int __cdecl _mbsnextc(_In_z_ const unsigned char *_Str)
_locale_t plocinfo
Definition: ismbbyte.cpp:75
unsigned int __cdecl _mbsnextc_l(const unsigned char *s, _locale_t plocinfo)
Definition: mbsnextc.cpp:38
static unsigned __int64 next
Definition: rand_nt.c:6