ReactOS 0.4.16-dev-937-g7afcd2a
mbschr.cpp File Reference
#include <corecrt_internal_mbstring.h>
#include <locale.h>
#include <stddef.h>
#include <string.h>
Include dependency graph for mbschr.cpp:

Go to the source code of this file.

Functions

_CONST_RETURN unsigned char *__cdecl _mbschr_l (const unsigned char *string, unsigned int c, _locale_t plocinfo)
 
_CONST_RETURN unsigned char *__cdecl _mbschr (const unsigned char *string, unsigned int c)
 

Function Documentation

◆ _mbschr()

_CONST_RETURN unsigned char *__cdecl _mbschr ( const unsigned char string,
unsigned int  c 
)

Definition at line 78 of file mbschr.cpp.

82{
83 return _mbschr_l(string, c, nullptr);
84}
const GLubyte * c
Definition: glext.h:8905
_CONST_RETURN unsigned char *__cdecl _mbschr_l(const unsigned char *string, unsigned int c, _locale_t plocinfo)
Definition: mbschr.cpp:44

◆ _mbschr_l()

_CONST_RETURN unsigned char *__cdecl _mbschr_l ( const unsigned char string,
unsigned int  c,
_locale_t  plocinfo 
)

Definition at line 44 of file mbschr.cpp.

49{
50 unsigned short cc = '\0';
51 _LocaleUpdate _loc_update(plocinfo);
52
53 /* validation section */
54 _VALIDATE_RETURN(string != nullptr, EINVAL, nullptr);
55
56 if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
57 return (_CONST_RETURN unsigned char *)strchr((const char *)string, (int)c);
58
59 for (; (cc = *string) != '\0'; string++)
60 {
61 if ( _ismbblead_l(cc, _loc_update.GetLocaleT()) )
62 {
63 if (*++string == '\0')
64 return nullptr; /* error */
65 if ( c == (unsigned int)((cc << 8) | *string) ) /* DBCS match */
66 return (unsigned char *)(string - 1);
67 }
68 else if (c == (unsigned int)cc)
69 break; /* SBCS match */
70 }
71
72 if (c == (unsigned int)cc) /* check for SBCS match--handles NUL char */
73 return (unsigned char *)(string);
74
75 return nullptr;
76}
#define EINVAL
Definition: acclib.h:90
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define _ismbblead_l(_c, p)
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
_locale_t plocinfo
Definition: ismbbyte.cpp:75
uint32_t cc
Definition: isohybrid.c:75
char string[160]
Definition: util.h:11
#define _CONST_RETURN
Definition: memory.h:16

Referenced by _mbschr().