ReactOS 0.4.16-dev-2104-gb84fa49
mbcs.c File Reference
#include <stdio.h>
#include <limits.h>
#include <mbctype.h>
#include <mbstring.h>
#include "msvcrt.h"
#include "mtdll.h"
#include "winnls.h"
#include "wine/debug.h"
Include dependency graph for mbcs.c:

Go to the source code of this file.

Classes

struct  cp_extra_info_t
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (msvcrt)
 
static wchar_t msvcrt_mbc_to_wc_l (unsigned int ch, _locale_t locale)
 
static size_t u_strlen (const unsigned char *str)
 
static unsigned charu_strncat (unsigned char *dst, const unsigned char *src, size_t len)
 
static int u_strcmp (const unsigned char *s1, const unsigned char *s2)
 
static int u_strcasecmp (const unsigned char *s1, const unsigned char *s2)
 
static int u_strncmp (const unsigned char *s1, const unsigned char *s2, size_t len)
 
static int u_strncasecmp (const unsigned char *s1, const unsigned char *s2, size_t len)
 
static unsigned charu_strchr (const unsigned char *s, unsigned char x)
 
static unsigned charu_strpbrk (const unsigned char *str, const unsigned char *accept)
 
static unsigned charu_strrchr (const unsigned char *s, unsigned char x)
 
static unsigned charu__strrev (unsigned char *str)
 
static unsigned charu__strset (unsigned char *s, unsigned char c)
 
static unsigned charu__strnset (unsigned char *s, unsigned char c, size_t len)
 
unsigned char *CDECL __p__mbctype (void)
 
int *CDECL __p___mb_cur_max (void)
 
int CDECL ___mb_cur_max_func (void)
 
threadmbcinfocreate_mbcinfo (int cp, LCID lcid, threadmbcinfo *old_mbcinfo)
 
int CDECL _setmbcp (int cp)
 
int CDECL _getmbcp (void)
 
unsigned int CDECL _mbsnextc_l (const unsigned char *str, _locale_t locale)
 
unsigned int CDECL _mbsnextc (const unsigned char *str)
 
unsigned int CDECL _mbctolower_l (unsigned int c, _locale_t locale)
 
unsigned int CDECL _mbctolower (unsigned int c)
 
unsigned int CDECL _mbctoupper_l (unsigned int c, _locale_t locale)
 
unsigned int CDECL _mbctoupper (unsigned int c)
 
unsigned int CDECL _mbctombb_l (unsigned int c, _locale_t locale)
 
unsigned int CDECL _mbctombb (unsigned int c)
 
unsigned int CDECL _mbcjistojms_l (unsigned int c, _locale_t locale)
 
unsigned int CDECL _mbcjistojms (unsigned int c)
 
unsigned int CDECL _mbcjmstojis_l (unsigned int c, _locale_t locale)
 
unsigned int CDECL _mbcjmstojis (unsigned int c)
 
size_t CDECL _mbclen_l (const unsigned char *str, _locale_t locale)
 
size_t CDECL _mbclen (const unsigned char *str)
 
unsigned char *CDECL _mbsinc_l (const unsigned char *str, _locale_t locale)
 
unsigned char *CDECL _mbsinc (const unsigned char *str)
 
unsigned char *CDECL _mbsninc (const unsigned char *str, size_t num)
 
size_t CDECL _mbsnlen_l (const unsigned char *str, size_t maxsize, _locale_t locale)
 
size_t CDECL _mbslen (const unsigned char *str)
 
size_t CDECL _mbslen_l (const unsigned char *str, _locale_t locale)
 
size_t CDECL _mbsnlen (const unsigned char *str, size_t maxsize)
 
int CDECL _mbccpy_s_l (unsigned char *dest, size_t maxsize, int *copied, const unsigned char *src, _locale_t locale)
 
void CDECL _mbccpy (unsigned char *dest, const unsigned char *src)
 
void CDECL _mbccpy_l (unsigned char *dest, const unsigned char *src, _locale_t locale)
 
int CDECL _mbccpy_s (unsigned char *dest, size_t maxsize, int *copied, const unsigned char *src)
 
unsigned char *CDECL _mbsncpy_l (unsigned char *dst, const unsigned char *src, size_t n, _locale_t locale)
 
unsigned char *CDECL _mbsncpy (unsigned char *dst, const unsigned char *src, size_t n)
 
int CDECL _mbsnbcpy_s_l (unsigned char *dst, size_t size, const unsigned char *src, size_t n, _locale_t locale)
 
int CDECL _mbsnbcpy_s (unsigned char *dst, size_t size, const unsigned char *src, size_t n)
 
int CDECL _mbscpy_s_l (unsigned char *dst, size_t size, const unsigned char *src, _locale_t locale)
 
int CDECL _mbscpy_s (unsigned char *dst, size_t size, const unsigned char *src)
 
unsigned char *CDECL _mbsnbcpy_l (unsigned char *dst, const unsigned char *src, size_t n, _locale_t locale)
 
unsigned char *CDECL _mbsnbcpy (unsigned char *dst, const unsigned char *src, size_t n)
 
int CDECL _mbscmp_l (const unsigned char *str, const unsigned char *cmp, _locale_t locale)
 
int CDECL _mbscmp (const unsigned char *str, const unsigned char *cmp)
 
int CDECL _mbsnbicoll_l (const unsigned char *str1, const unsigned char *str2, size_t len, _locale_t locale)
 
int CDECL _mbsicoll_l (const unsigned char *str1, const unsigned char *str2, _locale_t locale)
 
int CDECL _mbsnbicoll (const unsigned char *str1, const unsigned char *str2, size_t len)
 
int CDECL _mbsicoll (const unsigned char *str, const unsigned char *cmp)
 
int CDECL _mbsnbcoll_l (const unsigned char *str1, const unsigned char *str2, size_t len, _locale_t locale)
 
int CDECL _mbscoll_l (const unsigned char *str1, const unsigned char *str2, _locale_t locale)
 
int CDECL _mbsnbcoll (const unsigned char *str1, const unsigned char *str2, size_t len)
 
int CDECL _mbscoll (const unsigned char *str, const unsigned char *cmp)
 
int CDECL _mbsicmp_l (const unsigned char *str, const unsigned char *cmp, _locale_t locale)
 
int CDECL _mbsicmp (const unsigned char *str, const unsigned char *cmp)
 
int CDECL _mbsncmp_l (const unsigned char *str, const unsigned char *cmp, size_t len, _locale_t locale)
 
int CDECL _mbsncmp (const unsigned char *str, const unsigned char *cmp, size_t len)
 
int CDECL _mbsnbcmp_l (const unsigned char *str, const unsigned char *cmp, size_t len, _locale_t locale)
 
int CDECL _mbsnbcmp (const unsigned char *str, const unsigned char *cmp, size_t len)
 
int CDECL _mbsnicmp_l (const unsigned char *str, const unsigned char *cmp, size_t len, _locale_t locale)
 
int CDECL _mbsnicmp (const unsigned char *str, const unsigned char *cmp, size_t len)
 
int CDECL _mbsnbicmp_l (const unsigned char *str, const unsigned char *cmp, size_t len, _locale_t locale)
 
int CDECL _mbsnbicmp (const unsigned char *str, const unsigned char *cmp, size_t len)
 
unsigned char *CDECL _mbscat (unsigned char *dst, const unsigned char *src)
 
int CDECL _mbscat_s_l (unsigned char *dst, size_t size, const unsigned char *src, _locale_t locale)
 
int CDECL _mbscat_s (unsigned char *dst, size_t size, const unsigned char *src)
 
unsigned char *CDECL _mbscpy (unsigned char *dst, const unsigned char *src)
 
unsigned char *CDECL _mbsstr (const unsigned char *haystack, const unsigned char *needle)
 
unsigned char *CDECL _mbschr_l (const unsigned char *s, unsigned int x, _locale_t locale)
 
unsigned char *CDECL _mbschr (const unsigned char *s, unsigned int x)
 
unsigned char *CDECL _mbsrchr_l (const unsigned char *s, unsigned int x, _locale_t locale)
 
unsigned char *CDECL _mbsrchr (const unsigned char *s, unsigned int x)
 
unsigned char *CDECL _mbstok_s_l (unsigned char *str, const unsigned char *delim, unsigned char **ctx, _locale_t locale)
 
unsigned char *CDECL _mbstok_s (unsigned char *str, const unsigned char *delim, unsigned char **ctx)
 
unsigned char *CDECL _mbstok_l (unsigned char *str, const unsigned char *delim, _locale_t locale)
 
unsigned char *CDECL _mbstok (unsigned char *str, const unsigned char *delim)
 
unsigned int CDECL _mbbtombc_l (unsigned int c, _locale_t locale)
 
unsigned int CDECL _mbbtombc (unsigned int c)
 
int CDECL _ismbbkana_l (unsigned int c, _locale_t locale)
 
int CDECL _ismbbkana (unsigned int c)
 
int CDECL _ismbcdigit_l (unsigned int ch, _locale_t locale)
 
int CDECL _ismbcdigit (unsigned int ch)
 
int CDECL _ismbcgraph_l (unsigned int ch, _locale_t locale)
 
int CDECL _ismbcgraph (unsigned int ch)
 
int CDECL _ismbcalpha_l (unsigned int ch, _locale_t locale)
 
int CDECL _ismbcalpha (unsigned int ch)
 
int CDECL _ismbclower_l (unsigned int ch, _locale_t locale)
 
int CDECL _ismbclower (unsigned int ch)
 
int CDECL _ismbcupper_l (unsigned int ch, _locale_t locale)
 
int CDECL _ismbcupper (unsigned int ch)
 
int CDECL _ismbcsymbol_l (unsigned int ch, _locale_t locale)
 
int CDECL _ismbcsymbol (unsigned int ch)
 
int CDECL _ismbcalnum_l (unsigned int ch, _locale_t locale)
 
int CDECL _ismbcalnum (unsigned int ch)
 
int CDECL _ismbcspace_l (unsigned int ch, _locale_t locale)
 
int CDECL _ismbcspace (unsigned int ch)
 
int CDECL _ismbcprint_l (unsigned int ch, _locale_t locale)
 
int CDECL _ismbcprint (unsigned int ch)
 
int CDECL _ismbcpunct_l (unsigned int ch, _locale_t locale)
 
int CDECL _ismbcpunct (unsigned int ch)
 
int CDECL _ismbchira_l (unsigned int c, _locale_t locale)
 
int CDECL _ismbchira (unsigned int c)
 
int CDECL _ismbckata_l (unsigned int c, _locale_t locale)
 
int CDECL _ismbckata (unsigned int c)
 
int CDECL _ismbblead_l (unsigned int c, _locale_t locale)
 
int CDECL _ismbblead (unsigned int c)
 
int CDECL _ismbbtrail_l (unsigned int c, _locale_t locale)
 
int CDECL _ismbbtrail (unsigned int c)
 
int CDECL _ismbclegal_l (unsigned int c, _locale_t locale)
 
int CDECL _ismbclegal (unsigned int c)
 
int CDECL _ismbslead_l (const unsigned char *start, const unsigned char *str, _locale_t locale)
 
int CDECL _ismbslead (const unsigned char *start, const unsigned char *str)
 
int CDECL _ismbstrail_l (const unsigned char *start, const unsigned char *str, _locale_t locale)
 
int CDECL _ismbstrail (const unsigned char *start, const unsigned char *str)
 
unsigned char *CDECL _mbsdec_l (const unsigned char *start, const unsigned char *cur, _locale_t locale)
 
unsigned char *CDECL _mbsdec (const unsigned char *start, const unsigned char *cur)
 
int CDECL _mbbtype_l (unsigned char c, int type, _locale_t locale)
 
int CDECL _mbbtype (unsigned char c, int type)
 
int CDECL _mbsbtype_l (const unsigned char *str, size_t count, _locale_t locale)
 
int CDECL _mbsbtype (const unsigned char *str, size_t count)
 
unsigned char *CDECL _mbsset_l (unsigned char *str, unsigned int c, _locale_t locale)
 
unsigned char *CDECL _mbsset (unsigned char *str, unsigned int c)
 
unsigned char *CDECL _mbsnbset_l (unsigned char *str, unsigned int c, size_t len, _locale_t locale)
 
unsigned char *CDECL _mbsnbset (unsigned char *str, unsigned int c, size_t len)
 
unsigned char *CDECL _mbsnset_l (unsigned char *str, unsigned int c, size_t len, _locale_t locale)
 
unsigned char *CDECL _mbsnset (unsigned char *str, unsigned int c, size_t len)
 
size_t CDECL _mbsnccnt_l (const unsigned char *str, size_t len, _locale_t locale)
 
size_t CDECL _mbsnccnt (const unsigned char *str, size_t len)
 
size_t CDECL _mbsnbcnt_l (const unsigned char *str, size_t len, _locale_t locale)
 
size_t CDECL _mbsnbcnt (const unsigned char *str, size_t len)
 
unsigned char *CDECL _mbsnbcat_l (unsigned char *dst, const unsigned char *src, size_t len, _locale_t locale)
 
unsigned char *CDECL _mbsnbcat (unsigned char *dst, const unsigned char *src, size_t len)
 
int CDECL _mbsnbcat_s_l (unsigned char *dst, size_t size, const unsigned char *src, size_t len, _locale_t locale)
 
int CDECL _mbsnbcat_s (unsigned char *dst, size_t size, const unsigned char *src, size_t len)
 
unsigned char *CDECL _mbsncat_l (unsigned char *dst, const unsigned char *src, size_t len, _locale_t locale)
 
unsigned char *CDECL _mbsncat (unsigned char *dst, const unsigned char *src, size_t len)
 
unsigned char *CDECL _mbslwr_l (unsigned char *s, _locale_t locale)
 
unsigned char *CDECL _mbslwr (unsigned char *s)
 
int CDECL _mbslwr_s_l (unsigned char *s, size_t len, _locale_t locale)
 
int CDECL _mbslwr_s (unsigned char *str, size_t len)
 
unsigned char *CDECL _mbsupr_l (unsigned char *s, _locale_t locale)
 
unsigned char *CDECL _mbsupr (unsigned char *s)
 
int CDECL _mbsupr_s_l (unsigned char *s, size_t len, _locale_t locale)
 
int CDECL _mbsupr_s (unsigned char *s, size_t len)
 
size_t CDECL _mbsspn_l (const unsigned char *string, const unsigned char *set, _locale_t locale)
 
size_t CDECL _mbsspn (const unsigned char *string, const unsigned char *set)
 
unsigned char *CDECL _mbsspnp_l (const unsigned char *string, const unsigned char *set, _locale_t locale)
 
unsigned char *CDECL _mbsspnp (const unsigned char *string, const unsigned char *set)
 
size_t CDECL _mbscspn_l (const unsigned char *str, const unsigned char *cmp, _locale_t locale)
 
size_t CDECL _mbscspn (const unsigned char *str, const unsigned char *cmp)
 
unsigned char *CDECL _mbsrev_l (unsigned char *str, _locale_t locale)
 
unsigned char *CDECL _mbsrev (unsigned char *str)
 
unsigned char *CDECL _mbspbrk_l (const unsigned char *str, const unsigned char *accept, _locale_t locale)
 
unsigned char *CDECL _mbspbrk (const unsigned char *str, const unsigned char *accept)
 
int CDECL _mblen_l (const char *str, size_t size, _locale_t locale)
 
int CDECL mblen (const char *str, size_t size)
 
size_t CDECL mbrlen (const char *str, size_t len, mbstate_t *state)
 
size_t CDECL _mbstrlen_l (const char *str, _locale_t locale)
 
size_t CDECL _mbstrlen (const char *str)
 
int CDECL _mbtowc_l (wchar_t *dst, const char *str, size_t n, _locale_t locale)
 
int CDECL mbtowc (wchar_t *dst, const char *str, size_t n)
 
wint_t CDECL btowc (int c)
 
size_t CDECL mbrtowc (wchar_t *dst, const char *str, size_t n, mbstate_t *state)
 
static int get_utf8_char_len (char ch)
 
size_t CDECL _mbstowcs_l (wchar_t *wcstr, const char *mbstr, size_t count, _locale_t locale)
 
size_t CDECL mbstowcs (wchar_t *wcstr, const char *mbstr, size_t count)
 
int CDECL _mbstowcs_s_l (size_t *ret, wchar_t *wcstr, size_t size, const char *mbstr, size_t count, _locale_t locale)
 
int CDECL _mbstowcs_s (size_t *ret, wchar_t *wcstr, size_t size, const char *mbstr, size_t count)
 
size_t CDECL mbsrtowcs (wchar_t *wcstr, const char **pmbstr, size_t count, mbstate_t *state)
 
int CDECL mbsrtowcs_s (size_t *ret, wchar_t *wcstr, size_t len, const char **mbstr, size_t count, mbstate_t *state)
 
unsigned int CDECL _mbctohira_l (unsigned int c, _locale_t locale)
 
unsigned int CDECL _mbctohira (unsigned int c)
 
unsigned int CDECL _mbctokata_l (unsigned int c, _locale_t locale)
 
unsigned int CDECL _mbctokata (unsigned int c)
 
int CDECL _ismbcl0_l (unsigned int c, _locale_t locale)
 
int CDECL _ismbcl0 (unsigned int c)
 
int CDECL _ismbcl1_l (unsigned int c, _locale_t locale)
 
int CDECL _ismbcl1 (unsigned int c)
 
int CDECL _ismbcl2_l (unsigned int c, _locale_t locale)
 
int CDECL _ismbcl2 (unsigned int c)
 

Variables

unsigned char MSVCRT_mbctype [257] = { 0 }
 
static struct cp_extra_info_t g_cpextrainfo []
 
static const unsigned char mbbtombc_932 []
 
static const unsigned char mbctombb_932_punct []
 
static const unsigned char mbctombb_932_kana []
 

Function Documentation

◆ ___mb_cur_max_func()

int CDECL ___mb_cur_max_func ( void  )

Definition at line 197 of file mbcs.c.

198{
199 return get_locinfo()->mb_cur_max;
200}
#define get_locinfo()
Definition: winesup.h:25

◆ __p___mb_cur_max()

int *CDECL __p___mb_cur_max ( void  )

Definition at line 189 of file mbcs.c.

190{
191 return &get_locinfo()->mb_cur_max;
192}

Referenced by Test___mb_cur_max().

◆ __p__mbctype()

unsigned char *CDECL __p__mbctype ( void  )

Definition at line 181 of file mbcs.c.

182{
183 return get_mbcinfo()->mbctype;
184}
pthreadmbcinfo CDECL get_mbcinfo(void)
Definition: locale.c:642
unsigned char mbctype[257]
Definition: msvcrt.h:138

Referenced by Test__mbctype().

◆ _getmbcp()

int CDECL _getmbcp ( void  )

Definition at line 432 of file mbcs.c.

433{
434 return get_mbcinfo()->mbcodepage;
435}

◆ _ismbbkana()

int CDECL _ismbbkana ( unsigned int  c)

Definition at line 1831 of file mbcs.c.

1832{
1833 return _ismbbkana_l( c, NULL );
1834}
#define NULL
Definition: types.h:112
const GLubyte * c
Definition: glext.h:8905
int CDECL _ismbbkana_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:1811

◆ _ismbbkana_l()

int CDECL _ismbbkana_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 1811 of file mbcs.c.

1812{
1813 pthreadmbcinfo mbcinfo;
1814
1815 if(locale)
1816 mbcinfo = locale->mbcinfo;
1817 else
1818 mbcinfo = get_mbcinfo();
1819
1820 if(mbcinfo->mbcodepage == 932)
1821 {
1822 /* Japanese/Katakana, CP 932 */
1823 return (c >= 0xa1 && c <= 0xdf);
1824 }
1825 return 0;
1826}
Definition: _locale.h:75

Referenced by _ismbbkana().

◆ _ismbblead()

int CDECL _ismbblead ( unsigned int  c)

Definition at line 2077 of file mbcs.c.

2078{
2079 return _ismbblead_l(c, NULL);
2080}
#define _ismbblead_l(_c, p)

Referenced by _mbsnbcpy_s_l(), and _mbsninc().

◆ _ismbblead_l()

int CDECL _ismbblead_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 2062 of file mbcs.c.

2063{
2064 pthreadmbcinfo mbcinfo;
2065
2066 if(!locale)
2067 mbcinfo = get_mbcinfo();
2068 else
2069 mbcinfo = locale->mbcinfo;
2070
2071 return (mbcinfo->mbctype[(c&0xff) + 1] & _M1) != 0;
2072}
#define _M1
Definition: mbctype.h:38

◆ _ismbbtrail()

int CDECL _ismbbtrail ( unsigned int  c)

Definition at line 2100 of file mbcs.c.

2101{
2102 return _ismbbtrail_l(c, NULL);
2103}
#define _ismbbtrail_l(_c, p)

◆ _ismbbtrail_l()

int CDECL _ismbbtrail_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 2085 of file mbcs.c.

2086{
2087 pthreadmbcinfo mbcinfo;
2088
2089 if(!locale)
2090 mbcinfo = get_mbcinfo();
2091 else
2092 mbcinfo = locale->mbcinfo;
2093
2094 return (mbcinfo->mbctype[(c&0xff) + 1] & _M2) != 0;
2095}
#define _M2
Definition: mbctype.h:39

◆ _ismbcalnum()

int CDECL _ismbcalnum ( unsigned int  ch)

Definition at line 1950 of file mbcs.c.

1951{
1952 return _ismbcalnum_l( ch, NULL );
1953}
unsigned char ch[4][2]
Definition: console.c:118
int CDECL _ismbcalnum_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1942

◆ _ismbcalnum_l()

int CDECL _ismbcalnum_l ( unsigned int  ch,
_locale_t  locale 
)

Definition at line 1942 of file mbcs.c.

1943{
1945}
static wchar_t msvcrt_mbc_to_wc_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:90
#define _iswalnum_l(_c, _p)
Definition: ctype.h:683

Referenced by _ismbcalnum().

◆ _ismbcalpha()

int CDECL _ismbcalpha ( unsigned int  ch)

Definition at line 1879 of file mbcs.c.

1880{
1881 return _ismbcalpha_l( ch, NULL );
1882}
int CDECL _ismbcalpha_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1871

◆ _ismbcalpha_l()

int CDECL _ismbcalpha_l ( unsigned int  ch,
_locale_t  locale 
)

Definition at line 1871 of file mbcs.c.

1872{
1874}
#define _iswalpha_l(_c, _p)
Definition: ctype.h:676

Referenced by _ismbcalpha().

◆ _ismbcdigit()

int CDECL _ismbcdigit ( unsigned int  ch)

Definition at line 1847 of file mbcs.c.

1848{
1849 return _ismbcdigit_l( ch, NULL );
1850}
int CDECL _ismbcdigit_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1839

◆ _ismbcdigit_l()

int CDECL _ismbcdigit_l ( unsigned int  ch,
_locale_t  locale 
)

Definition at line 1839 of file mbcs.c.

1840{
1842}
#define _iswdigit_l(_c, _p)
Definition: ctype.h:679

Referenced by _ismbcdigit().

◆ _ismbcgraph()

int CDECL _ismbcgraph ( unsigned int  ch)

Definition at line 1863 of file mbcs.c.

1864{
1865 return _ismbcgraph_l( ch, NULL );
1866}
int CDECL _ismbcgraph_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1855

◆ _ismbcgraph_l()

int CDECL _ismbcgraph_l ( unsigned int  ch,
_locale_t  locale 
)

Definition at line 1855 of file mbcs.c.

1856{
1858}
#define _iswgraph_l(_c, _p)
Definition: ctype.h:685

Referenced by _ismbcgraph().

◆ _ismbchira()

int CDECL _ismbchira ( unsigned int  c)

Definition at line 2026 of file mbcs.c.

2027{
2028 return _ismbchira_l(c, NULL);
2029}
int CDECL _ismbchira_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:2006

◆ _ismbchira_l()

int CDECL _ismbchira_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 2006 of file mbcs.c.

2007{
2008 pthreadmbcinfo mbcinfo;
2009
2010 if(locale)
2011 mbcinfo = locale->mbcinfo;
2012 else
2013 mbcinfo = get_mbcinfo();
2014
2015 if(mbcinfo->mbcodepage == 932)
2016 {
2017 /* Japanese/Hiragana, CP 932 */
2018 return (c >= 0x829f && c <= 0x82f1);
2019 }
2020 return 0;
2021}

Referenced by _ismbchira(), and _mbctokata_l().

◆ _ismbckata()

int CDECL _ismbckata ( unsigned int  c)

Definition at line 2054 of file mbcs.c.

2055{
2056 return _ismbckata_l(c, NULL);
2057}
int CDECL _ismbckata_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:2034

◆ _ismbckata_l()

int CDECL _ismbckata_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 2034 of file mbcs.c.

2035{
2036 pthreadmbcinfo mbcinfo;
2037
2038 if(locale)
2039 mbcinfo = locale->mbcinfo;
2040 else
2041 mbcinfo = get_mbcinfo();
2042
2043 if(mbcinfo->mbcodepage == 932)
2044 {
2045 /* Japanese/Katakana, CP 932 */
2046 return (c >= 0x8340 && c <= 0x8396 && c != 0x837f);
2047 }
2048 return 0;
2049}

Referenced by _ismbckata(), and _mbctohira_l().

◆ _ismbcl0()

int CDECL _ismbcl0 ( unsigned int  c)

Definition at line 3551 of file mbcs.c.

3552{
3553 return _ismbcl0_l(c, NULL);
3554}
int CDECL _ismbcl0_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:3530

◆ _ismbcl0_l()

int CDECL _ismbcl0_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 3530 of file mbcs.c.

3531{
3532 pthreadmbcinfo mbcinfo;
3533
3534 if(!locale)
3535 mbcinfo = get_mbcinfo();
3536 else
3537 mbcinfo = locale->mbcinfo;
3538
3539 if(mbcinfo->mbcodepage == 932)
3540 {
3541 /* JIS non-Kanji */
3542 return _ismbclegal_l(c, locale) && c >= 0x8140 && c <= 0x889e;
3543 }
3544
3545 return 0;
3546}
int CDECL _ismbclegal_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:2108

Referenced by _ismbcl0().

◆ _ismbcl1()

int CDECL _ismbcl1 ( unsigned int  c)

Definition at line 3580 of file mbcs.c.

3581{
3582 return _ismbcl1_l(c, NULL);
3583}
int CDECL _ismbcl1_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:3559

◆ _ismbcl1_l()

int CDECL _ismbcl1_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 3559 of file mbcs.c.

3560{
3561 pthreadmbcinfo mbcinfo;
3562
3563 if(!locale)
3564 mbcinfo = get_mbcinfo();
3565 else
3566 mbcinfo = locale->mbcinfo;
3567
3568 if(mbcinfo->mbcodepage == 932)
3569 {
3570 /* JIS level-1 */
3571 return _ismbclegal_l(c, locale) && c >= 0x889f && c <= 0x9872;
3572 }
3573
3574 return 0;
3575}

Referenced by _ismbcl1().

◆ _ismbcl2()

int CDECL _ismbcl2 ( unsigned int  c)

Definition at line 3609 of file mbcs.c.

3610{
3611 return _ismbcl2_l(c, NULL);
3612}
int CDECL _ismbcl2_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:3588

◆ _ismbcl2_l()

int CDECL _ismbcl2_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 3588 of file mbcs.c.

3589{
3590 pthreadmbcinfo mbcinfo;
3591
3592 if(!locale)
3593 mbcinfo = get_mbcinfo();
3594 else
3595 mbcinfo = locale->mbcinfo;
3596
3597 if(mbcinfo->mbcodepage == 932)
3598 {
3599 /* JIS level-2 */
3600 return _ismbclegal_l(c, locale) && c >= 0x989f && c <= 0xeaa4;
3601 }
3602
3603 return 0;
3604}

Referenced by _ismbcl2().

◆ _ismbclegal()

int CDECL _ismbclegal ( unsigned int  c)

Definition at line 2116 of file mbcs.c.

2117{
2118 return _ismbclegal_l(c, NULL);
2119}

◆ _ismbclegal_l()

int CDECL _ismbclegal_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 2108 of file mbcs.c.

2109{
2111}
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486

Referenced by _ismbcl0_l(), _ismbcl1_l(), _ismbcl2_l(), _ismbclegal(), and _mbcjmstojis_l().

◆ _ismbclower()

int CDECL _ismbclower ( unsigned int  ch)

Definition at line 1895 of file mbcs.c.

1896{
1897 return _ismbclower_l( ch, NULL );
1898}
int CDECL _ismbclower_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1887

◆ _ismbclower_l()

int CDECL _ismbclower_l ( unsigned int  ch,
_locale_t  locale 
)

Definition at line 1887 of file mbcs.c.

1888{
1890}
#define _iswlower_l(_c, _p)
Definition: ctype.h:678

Referenced by _ismbclower().

◆ _ismbcprint()

int CDECL _ismbcprint ( unsigned int  ch)

Definition at line 1982 of file mbcs.c.

1983{
1984 return _ismbcprint_l( ch, NULL );
1985}
int CDECL _ismbcprint_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1974

◆ _ismbcprint_l()

int CDECL _ismbcprint_l ( unsigned int  ch,
_locale_t  locale 
)

Definition at line 1974 of file mbcs.c.

1975{
1977}
#define _iswprint_l(_c, _p)
Definition: ctype.h:684

Referenced by _ismbcprint().

◆ _ismbcpunct()

int CDECL _ismbcpunct ( unsigned int  ch)

Definition at line 1998 of file mbcs.c.

1999{
2000 return _ismbcpunct_l( ch, NULL );
2001}
int CDECL _ismbcpunct_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1990

◆ _ismbcpunct_l()

int CDECL _ismbcpunct_l ( unsigned int  ch,
_locale_t  locale 
)

Definition at line 1990 of file mbcs.c.

1991{
1993}
#define _iswpunct_l(_c, _p)
Definition: ctype.h:682

Referenced by _ismbcpunct().

◆ _ismbcspace()

int CDECL _ismbcspace ( unsigned int  ch)

Definition at line 1966 of file mbcs.c.

1967{
1968 return _ismbcspace_l( ch, NULL );
1969}
int CDECL _ismbcspace_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1958

◆ _ismbcspace_l()

int CDECL _ismbcspace_l ( unsigned int  ch,
_locale_t  locale 
)

Definition at line 1958 of file mbcs.c.

1959{
1961}
#define _iswspace_l(_c, _p)
Definition: ctype.h:681

Referenced by _ismbcspace().

◆ _ismbcsymbol()

int CDECL _ismbcsymbol ( unsigned int  ch)

Definition at line 1934 of file mbcs.c.

1935{
1936 return _ismbcsymbol_l(ch, NULL);
1937}
int CDECL _ismbcsymbol_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1919

◆ _ismbcsymbol_l()

int CDECL _ismbcsymbol_l ( unsigned int  ch,
_locale_t  locale 
)

Definition at line 1919 of file mbcs.c.

1920{
1921 wchar_t wch = msvcrt_mbc_to_wc_l( ch, locale );
1922 WORD ctype;
1923 if (!GetStringTypeW(CT_CTYPE3, &wch, 1, &ctype))
1924 {
1925 WARN("GetStringTypeW failed on %x\n", ch);
1926 return 0;
1927 }
1928 return ((ctype & C3_SYMBOL) != 0);
1929}
#define WARN(fmt,...)
Definition: precomp.h:61
Definition: _ctype.h:58
BOOL WINAPI GetStringTypeW(DWORD type, LPCWSTR src, INT count, LPWORD chartype)
Definition: locale.c:3098
unsigned short WORD
Definition: ntddk_ex.h:93
#define CT_CTYPE3
Definition: winnls.h:257
#define C3_SYMBOL
Definition: winnls.h:283

Referenced by _ismbcsymbol().

◆ _ismbcupper()

int CDECL _ismbcupper ( unsigned int  ch)

Definition at line 1911 of file mbcs.c.

1912{
1913 return _ismbcupper_l( ch, NULL );
1914}
int CDECL _ismbcupper_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1903

◆ _ismbcupper_l()

int CDECL _ismbcupper_l ( unsigned int  ch,
_locale_t  locale 
)

Definition at line 1903 of file mbcs.c.

1904{
1906}
#define _iswupper_l(_c, _p)
Definition: ctype.h:677

Referenced by _ismbcupper().

◆ _ismbslead()

int CDECL _ismbslead ( const unsigned char start,
const unsigned char str 
)

Definition at line 2156 of file mbcs.c.

2157{
2158 return _ismbslead_l(start, str, NULL);
2159}
GLuint start
Definition: gl.h:1545
int CDECL _ismbslead_l(const unsigned char *start, const unsigned char *str, _locale_t locale)
Definition: mbcs.c:2124
const WCHAR * str

◆ _ismbslead_l()

int CDECL _ismbslead_l ( const unsigned char start,
const unsigned char str,
_locale_t  locale 
)

Definition at line 2124 of file mbcs.c.

2125{
2126 pthreadmbcinfo mbcinfo;
2127 int lead = 0;
2128
2129 if (!MSVCRT_CHECK_PMT(start && str))
2130 return 0;
2131
2132 if(locale)
2133 mbcinfo = locale->mbcinfo;
2134 else
2135 mbcinfo = get_mbcinfo();
2136
2137 if(!mbcinfo->ismbcodepage)
2138 return 0;
2139
2140 /* Lead bytes can also be trail bytes so we need to analyse the string
2141 */
2142 while (start <= str)
2143 {
2144 if (!*start)
2145 return 0;
2146 lead = !lead && _ismbblead_l(*start, locale);
2147 start++;
2148 }
2149
2150 return lead ? -1 : 0;
2151}
#define MSVCRT_CHECK_PMT(x)
Definition: msvcrt.h:378

Referenced by _ismbslead(), _ismbstrail_l(), and _mbsncat_l().

◆ _ismbstrail()

int CDECL _ismbstrail ( const unsigned char start,
const unsigned char str 
)

Definition at line 2179 of file mbcs.c.

2180{
2181 return _ismbstrail_l(start, str, NULL);
2182}
int CDECL _ismbstrail_l(const unsigned char *start, const unsigned char *str, _locale_t locale)
Definition: mbcs.c:2164

◆ _ismbstrail_l()

int CDECL _ismbstrail_l ( const unsigned char start,
const unsigned char str,
_locale_t  locale 
)

Definition at line 2164 of file mbcs.c.

2165{
2166 if (!MSVCRT_CHECK_PMT(start && str))
2167 return 0;
2168
2169 /* Note: this function doesn't check _ismbbtrail */
2170 if ((str > start) && _ismbslead_l(start, str-1, locale))
2171 return -1;
2172 else
2173 return 0;
2174}

Referenced by _ismbstrail(), and _mbsdec_l().

◆ _mbbtombc()

unsigned int CDECL _mbbtombc ( unsigned int  c)

Definition at line 1803 of file mbcs.c.

1804{
1805 return _mbbtombc_l(c, NULL);
1806}
unsigned int CDECL _mbbtombc_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:1773

◆ _mbbtombc_l()

unsigned int CDECL _mbbtombc_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 1773 of file mbcs.c.

1774{
1775 pthreadmbcinfo mbcinfo;
1776
1777 if(locale)
1778 mbcinfo = locale->mbcinfo;
1779 else
1780 mbcinfo = get_mbcinfo();
1781
1782 if(mbcinfo->mbcodepage == 932)
1783 {
1784 if(c >= 0x20 && c <= 0x7e) {
1785 if((c >= 0x41 && c <= 0x5a) || (c >= 0x61 && c <= 0x7a) || (c >= 0x30 && c <= 0x39))
1786 return mbbtombc_932[c - 0x20] | 0x8200;
1787 else
1788 return mbbtombc_932[c - 0x20] | 0x8100;
1789 }
1790 else if(c >= 0xa1 && c <= 0xdf) {
1791 if(c >= 0xa6 && c <= 0xdd && c != 0xb0)
1792 return mbbtombc_932[c - 0xa1 + 0x5f] | 0x8300;
1793 else
1794 return mbbtombc_932[c - 0xa1 + 0x5f] | 0x8100;
1795 }
1796 }
1797 return c; /* not Japanese or no MB char */
1798}
#define c
Definition: ke_i.h:80
static const unsigned char mbbtombc_932[]
Definition: mbcs.c:60

Referenced by _mbbtombc().

◆ _mbbtype()

int CDECL _mbbtype ( unsigned char  c,
int  type 
)

Definition at line 2232 of file mbcs.c.

2233{
2234 return _mbbtype_l(c, type, NULL);
2235}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
int CDECL _mbbtype_l(unsigned char c, int type, _locale_t locale)
Definition: mbcs.c:2220

◆ _mbbtype_l()

int CDECL _mbbtype_l ( unsigned char  c,
int  type,
_locale_t  locale 
)

Definition at line 2220 of file mbcs.c.

2221{
2222 if (type == 1)
2224 else
2225 return _ismbblead_l(c, locale) ? _MBC_LEAD
2227}
#define _MBC_TRAIL
Definition: mbctype.h:46
#define _MBC_SINGLE
Definition: mbctype.h:44
#define _MBC_LEAD
Definition: mbctype.h:45
#define _MBC_ILLEGAL
Definition: mbctype.h:47
#define _isprint_l(_Char, _Locale)
Definition: ctype.h:651

Referenced by _mbbtype().

◆ _mbccpy()

void CDECL _mbccpy ( unsigned char dest,
const unsigned char src 
)

Definition at line 829 of file mbcs.c.

830{
832}
GLenum src
Definition: glext.h:6340
int CDECL _mbccpy_s_l(unsigned char *dest, size_t maxsize, int *copied, const unsigned char *src, _locale_t locale)
Definition: mbcs.c:795
static char * dest
Definition: rtl.c:135

◆ _mbccpy_l()

void CDECL _mbccpy_l ( unsigned char dest,
const unsigned char src,
_locale_t  locale 
)

Definition at line 837 of file mbcs.c.

839{
841}

◆ _mbccpy_s()

int CDECL _mbccpy_s ( unsigned char dest,
size_t  maxsize,
int copied,
const unsigned char src 
)

Definition at line 846 of file mbcs.c.

848{
849 return _mbccpy_s_l(dest, maxsize, copied, src, NULL);
850}
_In_ size_t const maxsize
Definition: strftime.cpp:120

◆ _mbccpy_s_l()

int CDECL _mbccpy_s_l ( unsigned char dest,
size_t  maxsize,
int copied,
const unsigned char src,
_locale_t  locale 
)

Definition at line 795 of file mbcs.c.

797{
798 if(copied) *copied = 0;
799 if(!MSVCRT_CHECK_PMT(dest != NULL && maxsize >= 1)) return EINVAL;
800 dest[0] = 0;
801 if(!MSVCRT_CHECK_PMT(src != NULL)) return EINVAL;
802
803 if(_ismbblead_l(*src, locale)) {
804 if(!src[1]) {
805 if(copied) *copied = 1;
806 *_errno() = EILSEQ;
807 return EILSEQ;
808 }
809
810 if(maxsize < 2) {
811 MSVCRT_INVALID_PMT("dst buffer is too small", ERANGE);
812 return ERANGE;
813 }
814
815 *dest++ = *src++;
816 *dest = *src;
817 if(copied) *copied = 2;
818 }else {
819 *dest = *src;
820 if(copied) *copied = 1;
821 }
822
823 return 0;
824}
int *CDECL _errno(void)
Definition: errno.c:215
#define EINVAL
Definition: errno.h:44
#define ERANGE
Definition: errno.h:55
#define EILSEQ
Definition: errno.h:62
#define MSVCRT_INVALID_PMT(x, err)
Definition: msvcrt.h:376

Referenced by _mbccpy(), _mbccpy_l(), and _mbccpy_s().

◆ _mbcjistojms()

unsigned int CDECL _mbcjistojms ( unsigned int  c)

Definition at line 629 of file mbcs.c.

630{
631 return _mbcjistojms_l(c, NULL);
632}
unsigned int CDECL _mbcjistojms_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:590

◆ _mbcjistojms_l()

unsigned int CDECL _mbcjistojms_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 590 of file mbcs.c.

591{
592 pthreadmbcinfo mbcinfo;
593
594 if(locale)
595 mbcinfo = locale->mbcinfo;
596 else
597 mbcinfo = get_mbcinfo();
598
599 /* Conversion takes place only when codepage is 932.
600 In all other cases, c is returned unchanged */
601 if(mbcinfo->mbcodepage == 932)
602 {
603 if(HIBYTE(c) >= 0x21 && HIBYTE(c) <= 0x7e &&
604 LOBYTE(c) >= 0x21 && LOBYTE(c) <= 0x7e)
605 {
606 if(HIBYTE(c) % 2)
607 c += 0x1f;
608 else
609 c += 0x7d;
610
611 if(LOBYTE(c) >= 0x7F)
612 c += 0x1;
613
614 c = (((HIBYTE(c) - 0x21)/2 + 0x81) << 8) | LOBYTE(c);
615
616 if(HIBYTE(c) > 0x9f)
617 c += 0x4000;
618 }
619 else
620 return 0; /* Codepage is 932, but c can't be converted */
621 }
622
623 return c;
624}

Referenced by _mbcjistojms().

◆ _mbcjmstojis()

unsigned int CDECL _mbcjmstojis ( unsigned int  c)

Definition at line 677 of file mbcs.c.

678{
679 return _mbcjmstojis_l(c, NULL);
680}
unsigned int CDECL _mbcjmstojis_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:639

◆ _mbcjmstojis_l()

unsigned int CDECL _mbcjmstojis_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 639 of file mbcs.c.

640{
641 pthreadmbcinfo mbcinfo;
642
643 if(locale)
644 mbcinfo = locale->mbcinfo;
645 else
646 mbcinfo = get_mbcinfo();
647
648 /* Conversion takes place only when codepage is 932.
649 In all other cases, c is returned unchanged */
650 if(mbcinfo->mbcodepage == 932)
651 {
652 if(_ismbclegal_l(c, locale) && HIBYTE(c) < 0xf0)
653 {
654 if(HIBYTE(c) >= 0xe0)
655 c -= 0x4000;
656
657 c = (((HIBYTE(c) - 0x81)*2 + 0x21) << 8) | LOBYTE(c);
658
659 if(LOBYTE(c) > 0x7f)
660 c -= 0x1;
661
662 if(LOBYTE(c) > 0x9d)
663 c += 0x83;
664 else
665 c -= 0x1f;
666 }
667 else
668 return 0; /* Codepage is 932, but c can't be converted */
669 }
670
671 return c;
672}

Referenced by _mbcjmstojis().

◆ _mbclen()

size_t CDECL _mbclen ( const unsigned char str)

Definition at line 693 of file mbcs.c.

694{
695 return _mbclen_l(str, NULL);
696}
size_t CDECL _mbclen_l(const unsigned char *str, _locale_t locale)
Definition: mbcs.c:685

◆ _mbclen_l()

size_t CDECL _mbclen_l ( const unsigned char str,
_locale_t  locale 
)

Definition at line 685 of file mbcs.c.

686{
687 return _ismbblead_l(*str, locale) && str[1] ? 2 : 1;
688}

Referenced by _mbclen(), and _mbsinc_l().

◆ _mbctohira()

unsigned int CDECL _mbctohira ( unsigned int  c)

Definition at line 3501 of file mbcs.c.

3502{
3503 return _mbctohira_l(c, NULL);
3504}
unsigned int CDECL _mbctohira_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:3491

◆ _mbctohira_l()

unsigned int CDECL _mbctohira_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 3491 of file mbcs.c.

3492{
3493 if(_ismbckata_l(c, locale) && c <= 0x8393)
3494 return (c - 0x8340 - (c >= 0x837f ? 1 : 0)) + 0x829f;
3495 return c;
3496}

Referenced by _mbctohira().

◆ _mbctokata()

unsigned int CDECL _mbctokata ( unsigned int  c)

Definition at line 3522 of file mbcs.c.

3523{
3524 return _mbctokata_l(c, NULL);
3525}
unsigned int CDECL _mbctokata_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:3511

◆ _mbctokata_l()

unsigned int CDECL _mbctokata_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 3511 of file mbcs.c.

3512{
3513 if(_ismbchira_l(c, locale))
3514 return (c - 0x829f) + 0x8340 + (c >= 0x82de ? 1 : 0);
3515 return c;
3516}

Referenced by _mbctokata().

◆ _mbctolower()

unsigned int CDECL _mbctolower ( unsigned int  c)

Definition at line 493 of file mbcs.c.

494{
495 return _mbctolower_l(c, NULL);
496}
unsigned int CDECL _mbctolower_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:458

◆ _mbctolower_l()

unsigned int CDECL _mbctolower_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 458 of file mbcs.c.

459{
460 unsigned char str[2], ret[2];
461 pthreadmbcinfo mbcinfo;
462
463 if(!locale)
464 mbcinfo = get_mbcinfo();
465 else
466 mbcinfo = locale->mbcinfo;
467
468 if (c > 0xff)
469 {
470 if (!_ismbblead_l((c >> 8) & 0xff, locale))
471 return c;
472
473 str[0] = c >> 8;
474 str[1] = c;
476 (char*)str, 2, (char*)ret, 2, mbcinfo->mbcodepage, 0))
477 {
478 case 0:
479 return c;
480 case 1:
481 return ret[0];
482 default:
483 return ret[1] + (ret[0] << 8);
484 }
485 }
486
487 return mbcinfo->mbctype[c + 1] & _SBUP ? mbcinfo->mbcasemap[c] : c;
488}
#define _SBUP
Definition: mbctype.h:41
int CDECL __crtLCMapStringA(LCID lcid, DWORD mapflags, const char *src, int srclen, char *dst, int dstlen, unsigned int codepage, int xflag)
Definition: locale.c:877
return ret
Definition: mutex.c:146
unsigned char mbcasemap[256]
Definition: msvcrt.h:139
#define LCMAP_LOWERCASE
Definition: winnls.h:197

Referenced by _mbctolower(), _mbsicmp_l(), _mbslwr_l(), _mbslwr_s_l(), _mbsnbicmp_l(), and _mbsnicmp_l().

◆ _mbctombb()

unsigned int CDECL _mbctombb ( unsigned int  c)

Definition at line 578 of file mbcs.c.

579{
580 return _mbctombb_l(c, NULL);
581}
unsigned int CDECL _mbctombb_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:544

◆ _mbctombb_l()

unsigned int CDECL _mbctombb_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 544 of file mbcs.c.

545{
546 pthreadmbcinfo mbcinfo;
547 unsigned int value;
548
549 if(locale)
550 mbcinfo = locale->mbcinfo;
551 else
552 mbcinfo = get_mbcinfo();
553
554 if(mbcinfo->mbcodepage == 932)
555 {
556 if(c >= 0x829f && c <= 0x82f1) /* Hiragana */
557 return mbctombb_932_kana[c - 0x829f];
558 if(c >= 0x8340 && c <= 0x8396 && c != 0x837f) /* Katakana */
559 return mbctombb_932_kana[c - 0x8340 - (c >= 0x837f ? 1 : 0)];
560 if(c >= 0x8140 && c <= 0x8197) /* Punctuation */
561 {
562 value = mbctombb_932_punct[c - 0x8140];
563 return value ? value : c;
564 }
565 if((c >= 0x824f && c <= 0x8258) || /* Fullwidth digits */
566 (c >= 0x8260 && c <= 0x8279)) /* Fullwidth capitals letters */
567 return c - 0x821f;
568 if(c >= 0x8281 && c <= 0x829a) /* Fullwidth small letters */
569 return c - 0x8220;
570 /* all other cases return c */
571 }
572 return c;
573}
static const unsigned char mbctombb_932_kana[]
Definition: mbcs.c:82
static const unsigned char mbctombb_932_punct[]
Definition: mbcs.c:73
Definition: pdh_main.c:96

Referenced by _mbctombb().

◆ _mbctoupper()

unsigned int CDECL _mbctoupper ( unsigned int  c)

Definition at line 536 of file mbcs.c.

537{
538 return _mbctoupper_l(c, NULL);
539}
unsigned int CDECL _mbctoupper_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:501

◆ _mbctoupper_l()

unsigned int CDECL _mbctoupper_l ( unsigned int  c,
_locale_t  locale 
)

Definition at line 501 of file mbcs.c.

502{
503 unsigned char str[2], ret[2];
504 pthreadmbcinfo mbcinfo;
505
506 if(!locale)
507 mbcinfo = get_mbcinfo();
508 else
509 mbcinfo = locale->mbcinfo;
510
511 if (c > 0xff)
512 {
513 if (!_ismbblead_l((c >> 8) & 0xff, locale))
514 return c;
515
516 str[0] = c >> 8;
517 str[1] = c;
519 (char*)str, 2, (char*)ret, 2, mbcinfo->mbcodepage, 0))
520 {
521 case 0:
522 return c;
523 case 1:
524 return ret[0];
525 default:
526 return ret[1] + (ret[0] << 8);
527 }
528 }
529
530 return mbcinfo->mbctype[c + 1] & _SBLOW ? mbcinfo->mbcasemap[c] : c;
531}
#define _SBLOW
Definition: mbctype.h:42
#define LCMAP_UPPERCASE
Definition: winnls.h:198

Referenced by _mbctoupper(), _mbsupr_l(), and _mbsupr_s_l().

◆ _mblen_l()

int CDECL _mblen_l ( const char str,
size_t  size,
_locale_t  locale 
)

Definition at line 3067 of file mbcs.c.

3068{
3070
3071 if (!str || !*str || !size)
3072 return 0;
3073
3074 if (locale)
3075 locinfo = locale->locinfo;
3076 else
3077 locinfo = get_locinfo();
3078
3079 if (locinfo->mb_cur_max == 1)
3080 return 1; /* ASCII CP */
3081 return !_isleadbyte_l((unsigned char)*str, locale) ? 1 : (size > 1 ? 2 : -1);
3082}
#define _isleadbyte_l(_C, _L)
else locinfo
Definition: scanf.h:225
GLsizeiptr size
Definition: glext.h:5919

Referenced by mblen().

◆ _mbsbtype()

int CDECL _mbsbtype ( const unsigned char str,
size_t  count 
)

Definition at line 2284 of file mbcs.c.

2285{
2286 return _mbsbtype_l(str, count, NULL);
2287}
GLuint GLuint GLsizei count
Definition: gl.h:1545
int CDECL _mbsbtype_l(const unsigned char *str, size_t count, _locale_t locale)
Definition: mbcs.c:2240

◆ _mbsbtype_l()

int CDECL _mbsbtype_l ( const unsigned char str,
size_t  count,
_locale_t  locale 
)

Definition at line 2240 of file mbcs.c.

2241{
2242 int lead = 0;
2243 pthreadmbcinfo mbcinfo;
2244 const unsigned char *end = str + count;
2245
2246 if (!MSVCRT_CHECK_PMT(str))
2247 return _MBC_ILLEGAL;
2248
2249 if (locale)
2250 mbcinfo = locale->mbcinfo;
2251 else
2252 mbcinfo = get_mbcinfo();
2253
2254 /* Lead bytes can also be trail bytes so we need to analyse the string.
2255 * Also we must return _MBC_ILLEGAL for chars past the end of the string
2256 */
2257 while (str < end) /* Note: we skip the last byte - will check after the loop */
2258 {
2259 if (!*str)
2260 return _MBC_ILLEGAL;
2261 lead = mbcinfo->ismbcodepage && !lead && _ismbblead_l(*str, locale);
2262 str++;
2263 }
2264
2265 if (lead)
2266 {
2267 if (_ismbbtrail_l(*str, locale))
2268 return _MBC_TRAIL;
2269 else
2270 return _MBC_ILLEGAL;
2271 }
2272 else
2273 {
2274 if (_ismbblead_l(*str, locale))
2275 return _MBC_LEAD;
2276 else
2277 return _MBC_SINGLE;
2278 }
2279}
GLuint GLuint end
Definition: gl.h:1545

Referenced by _mbsbtype(), _mbsnbcat_l(), and _mbsncat_l().

◆ _mbscat()

unsigned char *CDECL _mbscat ( unsigned char dst,
const unsigned char src 
)

Definition at line 1540 of file mbcs.c.

1541{
1542 strcat( (char *)dst, (const char *)src );
1543 return dst;
1544}
GLenum GLenum dst
Definition: glext.h:6340
strcat
Definition: string.h:92

◆ _mbscat_s()

int CDECL _mbscat_s ( unsigned char dst,
size_t  size,
const unsigned char src 
)

Definition at line 1591 of file mbcs.c.

1592{
1593 return _mbscat_s_l(dst, size, src, NULL);
1594}
int CDECL _mbscat_s_l(unsigned char *dst, size_t size, const unsigned char *src, _locale_t locale)
Definition: mbcs.c:1549

◆ _mbscat_s_l()

int CDECL _mbscat_s_l ( unsigned char dst,
size_t  size,
const unsigned char src,
_locale_t  locale 
)

Definition at line 1549 of file mbcs.c.

1551{
1552 size_t i, j;
1553 int ret = 0;
1554
1555 if(!MSVCRT_CHECK_PMT(dst != NULL)) return EINVAL;
1556 if(!MSVCRT_CHECK_PMT(src != NULL)) return EINVAL;
1557
1558 for(i=0; i<size; i++)
1559 if(!dst[i]) break;
1560 if(i == size) {
1561 MSVCRT_INVALID_PMT("dst is not NULL-terminated", EINVAL);
1562 if(size) dst[0] = 0;
1563 return EINVAL;
1564 }
1565
1566 if(i && _ismbblead_l(dst[i-1], locale)) {
1567 ret = EILSEQ;
1568 i--;
1569 }
1570
1571 for(j=0; src[j] && i+j<size; j++)
1572 dst[i+j] = src[j];
1573 if(i+j == size) {
1574 MSVCRT_INVALID_PMT("dst buffer is too small", ERANGE);
1575 dst[0] = 0;
1576 return ERANGE;
1577 }
1578
1579 if(j && _ismbblead_l(src[j-1], locale)) {
1580 ret = EILSEQ;
1581 j--;
1582 }
1583
1584 dst[i+j] = 0;
1585 return ret;
1586}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250

Referenced by _mbscat_s().

◆ _mbschr()

unsigned char *CDECL _mbschr ( const unsigned char s,
unsigned int  x 
)

Definition at line 1646 of file mbcs.c.

1647{
1648 return _mbschr_l(s, x, NULL);
1649}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble s
Definition: gl.h:2039
unsigned char *CDECL _mbschr_l(const unsigned char *s, unsigned int x, _locale_t locale)
Definition: mbcs.c:1616

Referenced by _mbstok_s_l().

◆ _mbschr_l()

unsigned char *CDECL _mbschr_l ( const unsigned char s,
unsigned int  x,
_locale_t  locale 
)

Definition at line 1616 of file mbcs.c.

1617{
1618 pthreadmbcinfo mbcinfo;
1619
1620 if(!MSVCRT_CHECK_PMT(s))
1621 return NULL;
1622
1623 if(locale)
1624 mbcinfo = locale->mbcinfo;
1625 else
1626 mbcinfo = get_mbcinfo();
1627 if(mbcinfo->ismbcodepage)
1628 {
1629 unsigned int c;
1630 while (1)
1631 {
1632 c = _mbsnextc_l(s, locale);
1633 if (c == x)
1634 return (unsigned char*)s;
1635 if (!c)
1636 return NULL;
1637 s += c > 255 ? 2 : 1;
1638 }
1639 }
1640 return u_strchr(s, x); /* ASCII CP */
1641}
unsigned int CDECL _mbsnextc_l(const unsigned char *str, _locale_t locale)
Definition: mbcs.c:440
static unsigned char * u_strchr(const unsigned char *s, unsigned char x)
Definition: mbcs.c:148

Referenced by _mbschr().

◆ _mbscmp()

int CDECL _mbscmp ( const unsigned char str,
const unsigned char cmp 
)

Definition at line 1171 of file mbcs.c.

1172{
1173 return _mbscmp_l(str, cmp, NULL);
1174}
int CDECL _mbscmp_l(const unsigned char *str, const unsigned char *cmp, _locale_t locale)
Definition: mbcs.c:1140
#define cmp(status, error)
Definition: error.c:114

◆ _mbscmp_l()

int CDECL _mbscmp_l ( const unsigned char str,
const unsigned char cmp,
_locale_t  locale 
)

Definition at line 1140 of file mbcs.c.

1141{
1142 pthreadmbcinfo mbcinfo;
1143
1144 if (!MSVCRT_CHECK_PMT(str && cmp))
1145 return _NLSCMPERROR;
1146
1147 mbcinfo = locale ? locale->mbcinfo : get_mbcinfo();
1148
1149 if(mbcinfo->ismbcodepage)
1150 {
1151 unsigned int strc, cmpc;
1152 do {
1153 if(!*str)
1154 return *cmp ? -1 : 0;
1155 if(!*cmp)
1156 return 1;
1157 strc = _mbsnextc_l(str, locale);
1158 cmpc = _mbsnextc_l(cmp, locale);
1159 if(strc != cmpc)
1160 return strc < cmpc ? -1 : 1;
1161 str +=(strc > 255) ? 2 : 1;
1162 cmp +=(strc > 255) ? 2 : 1; /* equal, use same increment */
1163 } while(1);
1164 }
1165 return u_strcmp(str, cmp); /* ASCII CP */
1166}
#define _NLSCMPERROR
Definition: mbstring.h:28
static int u_strcmp(const unsigned char *s1, const unsigned char *s2)
Definition: mbcs.c:128

Referenced by _mbscmp().

◆ _mbscoll()

int CDECL _mbscoll ( const unsigned char str,
const unsigned char cmp 
)

Definition at line 1262 of file mbcs.c.

1263{
1264#if _MSVCR_VER>=60 && _MSVCR_VER<=71
1265 return CompareStringA(get_mbcinfo()->mblcid, 0,
1266 (const char*)str, -1, (const char*)cmp, -1)-CSTR_EQUAL;
1267#else
1268 return _mbsnbcoll_l(str, cmp, INT_MAX, NULL);
1269#endif
1270}
INT WINAPI CompareStringA(LCID lcid, DWORD flags, LPCSTR str1, INT len1, LPCSTR str2, INT len2)
Definition: locale.c:4086
#define INT_MAX
Definition: limits.h:26
int CDECL _mbsnbcoll_l(const unsigned char *str1, const unsigned char *str2, size_t len, _locale_t locale)
Definition: mbcs.c:1227
#define CSTR_EQUAL
Definition: winnls.h:500

◆ _mbscoll_l()

int CDECL _mbscoll_l ( const unsigned char str1,
const unsigned char str2,
_locale_t  locale 
)

Definition at line 1246 of file mbcs.c.

1247{
1248 return _mbsnbcoll_l(str1, str2, INT_MAX, locale);
1249}

◆ _mbscpy()

unsigned char *CDECL _mbscpy ( unsigned char dst,
const unsigned char src 
)

Definition at line 1599 of file mbcs.c.

1600{
1601 strcpy( (char *)dst, (const char *)src );
1602 return dst;
1603}
strcpy
Definition: string.h:131

◆ _mbscpy_s()

int CDECL _mbscpy_s ( unsigned char dst,
size_t  size,
const unsigned char src 
)

Definition at line 1077 of file mbcs.c.

1078{
1079 return _mbscpy_s_l(dst, size, src, NULL);
1080}
int CDECL _mbscpy_s_l(unsigned char *dst, size_t size, const unsigned char *src, _locale_t locale)
Definition: mbcs.c:1068

◆ _mbscpy_s_l()

int CDECL _mbscpy_s_l ( unsigned char dst,
size_t  size,
const unsigned char src,
_locale_t  locale 
)

Definition at line 1068 of file mbcs.c.

1070{
1071 return _mbsnbcpy_s_l(dst, size, src, -1, locale);
1072}
int CDECL _mbsnbcpy_s_l(unsigned char *dst, size_t size, const unsigned char *src, size_t n, _locale_t locale)
Definition: mbcs.c:997

Referenced by _mbscpy_s().

◆ _mbscspn()

size_t CDECL _mbscspn ( const unsigned char str,
const unsigned char cmp 
)

Definition at line 2963 of file mbcs.c.

2964{
2965 return _mbscspn_l(str, cmp, NULL);
2966}
size_t CDECL _mbscspn_l(const unsigned char *str, const unsigned char *cmp, _locale_t locale)
Definition: mbcs.c:2935

◆ _mbscspn_l()

size_t CDECL _mbscspn_l ( const unsigned char str,
const unsigned char cmp,
_locale_t  locale 
)

Definition at line 2935 of file mbcs.c.

2937{
2938 const unsigned char *p, *q;
2939
2940 for (p = str; *p; p++)
2941 {
2942 for (q = cmp; *q; q++)
2943 {
2944 if (_ismbblead_l(*q, locale))
2945 {
2946 /* duplicate a bug in native implementation */
2947 if (!q[1]) return 0;
2948
2949 if (p[0] == q[0] && p[1] == q[1])
2950 return p - str;
2951 q++;
2952 }
2953 else if (p[0] == q[0])
2954 return p - str;
2955 }
2956 }
2957 return p - str;
2958}
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by _mbscspn().

◆ _mbsdec()

unsigned char *CDECL _mbsdec ( const unsigned char start,
const unsigned char cur 
)

Definition at line 2211 of file mbcs.c.

2212{
2213 return _mbsdec_l(start, cur, NULL);
2214}
FxCollectionEntry * cur
unsigned char *CDECL _mbsdec_l(const unsigned char *start, const unsigned char *cur, _locale_t locale)
Definition: mbcs.c:2187

◆ _mbsdec_l()

unsigned char *CDECL _mbsdec_l ( const unsigned char start,
const unsigned char cur,
_locale_t  locale 
)

Definition at line 2187 of file mbcs.c.

2189{
2190 pthreadmbcinfo mbcinfo;
2191
2192 if (!MSVCRT_CHECK_PMT(start && cur))
2193 return NULL;
2194 if (start >= cur)
2195 return NULL;
2196
2197 if (!locale)
2198 mbcinfo = get_mbcinfo();
2199 else
2200 mbcinfo = locale->mbcinfo;
2201
2202 if (mbcinfo->ismbcodepage)
2203 return (unsigned char *)(_ismbstrail_l(start, cur - 1, locale) ? cur - 2 : cur - 1);
2204
2205 return (unsigned char *)cur - 1; /* ASCII CP or SB char */
2206}

Referenced by _mbsdec().

◆ _mbsicmp()

int CDECL _mbsicmp ( const unsigned char str,
const unsigned char cmp 
)

Definition at line 1308 of file mbcs.c.

1309{
1310 return _mbsicmp_l(str, cmp, NULL);
1311}
int CDECL _mbsicmp_l(const unsigned char *str, const unsigned char *cmp, _locale_t locale)
Definition: mbcs.c:1275

◆ _mbsicmp_l()

int CDECL _mbsicmp_l ( const unsigned char str,
const unsigned char cmp,
_locale_t  locale 
)

Definition at line 1275 of file mbcs.c.

1276{
1277 pthreadmbcinfo mbcinfo;
1278
1279 if(!MSVCRT_CHECK_PMT(str && cmp))
1280 return _NLSCMPERROR;
1281
1282 if(!locale)
1283 mbcinfo = get_mbcinfo();
1284 else
1285 mbcinfo = locale->mbcinfo;
1286 if(mbcinfo->ismbcodepage)
1287 {
1288 unsigned int strc, cmpc;
1289 do {
1290 if(!*str)
1291 return *cmp ? -1 : 0;
1292 if(!*cmp)
1293 return 1;
1296 if(strc != cmpc)
1297 return strc < cmpc ? -1 : 1;
1298 str +=(strc > 255) ? 2 : 1;
1299 cmp +=(strc > 255) ? 2 : 1; /* equal, use same increment */
1300 } while(1);
1301 }
1302 return u_strcasecmp(str, cmp); /* ASCII CP */
1303}
static int u_strcasecmp(const unsigned char *s1, const unsigned char *s2)
Definition: mbcs.c:133

Referenced by _mbsicmp().

◆ _mbsicoll()

int CDECL _mbsicoll ( const unsigned char str,
const unsigned char cmp 
)

Definition at line 1214 of file mbcs.c.

1215{
1216#if _MSVCR_VER>=60 && _MSVCR_VER<=71
1217 return CompareStringA(get_mbcinfo()->mblcid, NORM_IGNORECASE,
1218 (const char*)str, -1, (const char*)cmp, -1)-CSTR_EQUAL;
1219#else
1220 return _mbsnbicoll_l(str, cmp, INT_MAX, NULL);
1221#endif
1222}
int CDECL _mbsnbicoll_l(const unsigned char *str1, const unsigned char *str2, size_t len, _locale_t locale)
Definition: mbcs.c:1179
#define NORM_IGNORECASE
Definition: winnls.h:187

◆ _mbsicoll_l()

int CDECL _mbsicoll_l ( const unsigned char str1,
const unsigned char str2,
_locale_t  locale 
)

Definition at line 1198 of file mbcs.c.

1199{
1200 return _mbsnbicoll_l(str1, str2, INT_MAX, locale);
1201}

◆ _mbsinc()

unsigned char *CDECL _mbsinc ( const unsigned char str)

Definition at line 709 of file mbcs.c.

710{
711 return _mbsinc_l(str, NULL);
712}
unsigned char *CDECL _mbsinc_l(const unsigned char *str, _locale_t locale)
Definition: mbcs.c:701

◆ _mbsinc_l()

unsigned char *CDECL _mbsinc_l ( const unsigned char str,
_locale_t  locale 
)

Definition at line 701 of file mbcs.c.

702{
703 return (unsigned char *)(str + _mbclen_l(str, locale));
704}

Referenced by _mbsinc().

◆ _mbslen()

size_t CDECL _mbslen ( const unsigned char str)

Definition at line 771 of file mbcs.c.

772{
773 return _mbsnlen_l(str, -1, NULL);
774}
size_t CDECL _mbsnlen_l(const unsigned char *str, size_t maxsize, _locale_t locale)
Definition: mbcs.c:740

◆ _mbslen_l()

size_t CDECL _mbslen_l ( const unsigned char str,
_locale_t  locale 
)

Definition at line 779 of file mbcs.c.

780{
781 return _mbsnlen_l(str, -1, locale);
782}

◆ _mbslwr()

unsigned char *CDECL _mbslwr ( unsigned char s)

Definition at line 2712 of file mbcs.c.

2713{
2714 return _mbslwr_l(s, NULL);
2715}
unsigned char *CDECL _mbslwr_l(unsigned char *s, _locale_t locale)
Definition: mbcs.c:2673

◆ _mbslwr_l()

unsigned char *CDECL _mbslwr_l ( unsigned char s,
_locale_t  locale 
)

Definition at line 2673 of file mbcs.c.

2674{
2675 pthreadmbcinfo mbcinfo;
2676 unsigned char *ret = s;
2677
2678 if (!s)
2679 return NULL;
2680
2681 if (locale)
2682 mbcinfo = locale->mbcinfo;
2683 else
2684 mbcinfo = get_mbcinfo();
2685
2686 if (mbcinfo->ismbcodepage)
2687 {
2688 unsigned int c;
2689
2690 while (*s)
2691 {
2693 /* Note that I assume that the size of the character is unchanged */
2694 if (c > 255)
2695 {
2696 *s++ = (c >> 8);
2697 c = c & 0xff;
2698 }
2699 *s++ = c;
2700 }
2701 }
2702 else
2703 {
2704 for ( ; *s; s++) *s = _tolower_l(*s, locale);
2705 }
2706 return ret;
2707}
int CDECL _tolower_l(int c, _locale_t locale)
Definition: ctype.c:532

Referenced by _mbslwr().

◆ _mbslwr_s()

int CDECL _mbslwr_s ( unsigned char str,
size_t  len 
)

Definition at line 2768 of file mbcs.c.

2769{
2770 return _mbslwr_s_l(str, len, NULL);
2771}
GLenum GLsizei len
Definition: glext.h:6722
int CDECL _mbslwr_s_l(unsigned char *s, size_t len, _locale_t locale)
Definition: mbcs.c:2720

◆ _mbslwr_s_l()

int CDECL _mbslwr_s_l ( unsigned char s,
size_t  len,
_locale_t  locale 
)

Definition at line 2720 of file mbcs.c.

2721{
2722 unsigned char *p = s;
2723 pthreadmbcinfo mbcinfo;
2724
2725 if (!s && !len)
2726 return 0;
2727 if (!MSVCRT_CHECK_PMT(s && len))
2728 return EINVAL;
2729
2730 if (locale)
2731 mbcinfo = locale->mbcinfo;
2732 else
2733 mbcinfo = get_mbcinfo();
2734
2735 if (mbcinfo->ismbcodepage)
2736 {
2737 unsigned int c;
2738 for ( ; *s && len > 0; len--)
2739 {
2741 /* Note that I assume that the size of the character is unchanged */
2742 if (c > 255)
2743 {
2744 *s++=(c>>8);
2745 c=c & 0xff;
2746 }
2747 *s++=c;
2748 }
2749 }
2750 else
2751 {
2752 for ( ; *s && len > 0; s++, len--)
2753 *s = _tolower_l(*s, locale);
2754 }
2755
2756 if (!MSVCRT_CHECK_PMT(len))
2757 {
2758 *p = 0;
2759 return EINVAL;
2760 }
2761 *s = 0;
2762 return 0;
2763}

Referenced by _mbslwr_s().

◆ _mbsnbcat()

unsigned char *CDECL _mbsnbcat ( unsigned char dst,
const unsigned char src,
size_t  len 
)

Definition at line 2554 of file mbcs.c.

2555{
2556 return _mbsnbcat_l(dst, src, len, NULL);
2557}
unsigned char *CDECL _mbsnbcat_l(unsigned char *dst, const unsigned char *src, size_t len, _locale_t locale)
Definition: mbcs.c:2512

◆ _mbsnbcat_l()

unsigned char *CDECL _mbsnbcat_l ( unsigned char dst,
const unsigned char src,
size_t  len,
_locale_t  locale 
)

Definition at line 2512 of file mbcs.c.

2513{
2514 pthreadmbcinfo mbcinfo;
2515
2516 if (!MSVCRT_CHECK_PMT(dst && src))
2517 return NULL;
2518
2519 if (locale)
2520 mbcinfo = locale->mbcinfo;
2521 else
2522 mbcinfo = get_mbcinfo();
2523
2524 if (mbcinfo->ismbcodepage)
2525 {
2526 unsigned char *res = dst;
2527
2528 while (*dst)
2529 {
2530 if (_ismbblead_l(*dst++, locale))
2531 {
2532 if (*dst)
2533 {
2534 dst++;
2535 }
2536 else
2537 {
2538 /* as per msdn overwrite the lead byte in front of '\0' */
2539 dst--;
2540 break;
2541 }
2542 }
2543 }
2544 while (*src && len--) *dst++ = *src++;
2545 *dst = '\0';
2546 return res;
2547 }
2548 return u_strncat(dst, src, len); /* ASCII CP */
2549}
GLuint res
Definition: glext.h:9613
static unsigned char * u_strncat(unsigned char *dst, const unsigned char *src, size_t len)
Definition: mbcs.c:123

Referenced by _mbsnbcat().

◆ _mbsnbcat_s()

int CDECL _mbsnbcat_s ( unsigned char dst,
size_t  size,
const unsigned char src,
size_t  len 
)

Definition at line 2619 of file mbcs.c.

2620{
2621 return _mbsnbcat_s_l(dst, size, src, len, NULL);
2622}
int CDECL _mbsnbcat_s_l(unsigned char *dst, size_t size, const unsigned char *src, size_t len, _locale_t locale)
Definition: mbcs.c:2562

◆ _mbsnbcat_s_l()

int CDECL _mbsnbcat_s_l ( unsigned char dst,
size_t  size,
const unsigned char src,
size_t  len,
_locale_t  locale 
)

Definition at line 2562 of file mbcs.c.

2563{
2564 unsigned char *ptr = dst;
2565 size_t i;
2566 pthreadmbcinfo mbcinfo;
2567
2568 if (!dst && !size && !len)
2569 return 0;
2570
2571 if (!MSVCRT_CHECK_PMT(dst && size && src))
2572 {
2573 if (dst && size)
2574 *dst = '\0';
2575 return EINVAL;
2576 }
2577
2578 /* Find the null terminator of the destination buffer. */
2579 while (size && *ptr)
2580 size--, ptr++;
2581
2582 if (!size)
2583 {
2584 *dst = '\0';
2585 *_errno() = EINVAL;
2586 return EINVAL;
2587 }
2588
2589 if (locale)
2590 mbcinfo = locale->mbcinfo;
2591 else
2592 mbcinfo = get_mbcinfo();
2593
2594 /* If necessary, check that the character preceding the null terminator is
2595 * a lead byte and move the pointer back by one for later overwrite. */
2596 if (ptr != dst && mbcinfo->ismbcodepage && _ismbblead_l(*(ptr - 1), locale))
2597 size++, ptr--;
2598
2599 for (i = 0; *src && i < len; i++)
2600 {
2601 *ptr++ = *src++;
2602 size--;
2603
2604 if (!size)
2605 {
2606 *dst = '\0';
2607 *_errno() = ERANGE;
2608 return ERANGE;
2609 }
2610 }
2611
2612 *ptr = '\0';
2613 return 0;
2614}
static PVOID ptr
Definition: dispmode.c:27

Referenced by _mbsnbcat_s().

◆ _mbsnbcmp()

int CDECL _mbsnbcmp ( const unsigned char str,
const unsigned char cmp,
size_t  len 
)

Definition at line 1419 of file mbcs.c.

1420{
1421 return _mbsnbcmp_l(str, cmp, len, NULL);
1422}
int CDECL _mbsnbcmp_l(const unsigned char *str, const unsigned char *cmp, size_t len, _locale_t locale)
Definition: mbcs.c:1366

◆ _mbsnbcmp_l()

int CDECL _mbsnbcmp_l ( const unsigned char str,
const unsigned char cmp,
size_t  len,
_locale_t  locale 
)

Definition at line 1366 of file mbcs.c.

1367{
1368 pthreadmbcinfo mbcinfo;
1369
1370 if (!len)
1371 return 0;
1372
1373 if (!MSVCRT_CHECK_PMT(str && cmp))
1374 return _NLSCMPERROR;
1375
1376 if (locale)
1377 mbcinfo = locale->mbcinfo;
1378 else
1379 mbcinfo = get_mbcinfo();
1380
1381 if (mbcinfo->ismbcodepage)
1382 {
1383 unsigned int strc, cmpc;
1384 while (len)
1385 {
1386 int clen;
1387 if (!*str)
1388 return *cmp ? -1 : 0;
1389 if (!*cmp)
1390 return 1;
1391 if (_ismbblead_l(*str, locale))
1392 {
1393 strc = (len >= 2) ? _mbsnextc_l(str, locale) : 0;
1394 clen = 2;
1395 }
1396 else
1397 {
1398 strc = *str;
1399 clen = 1;
1400 }
1401 if (_ismbblead_l(*cmp, locale))
1402 cmpc = (len >= 2) ? _mbsnextc_l(cmp, locale) : 0;
1403 else
1404 cmpc = *cmp;
1405 if(strc != cmpc)
1406 return strc < cmpc ? -1 : 1;
1407 len -= clen;
1408 str += clen;
1409 cmp += clen;
1410 }
1411 return 0; /* Matched len chars */
1412 }
1413 return u_strncmp(str, cmp, len);
1414}
static int u_strncmp(const unsigned char *s1, const unsigned char *s2, size_t len)
Definition: mbcs.c:138

Referenced by _mbsnbcmp().

◆ _mbsnbcnt()

size_t CDECL _mbsnbcnt ( const unsigned char str,
size_t  len 
)

Definition at line 2504 of file mbcs.c.

2505{
2506 return _mbsnbcnt_l(str, len, NULL);
2507}
size_t CDECL _mbsnbcnt_l(const unsigned char *str, size_t len, _locale_t locale)
Definition: mbcs.c:2472

◆ _mbsnbcnt_l()

size_t CDECL _mbsnbcnt_l ( const unsigned char str,
size_t  len,
_locale_t  locale 
)

Definition at line 2472 of file mbcs.c.

2473{
2474 size_t ret;
2475 pthreadmbcinfo mbcinfo;
2476
2477 if (!len)
2478 return 0;
2479 if (!MSVCRT_CHECK_PMT(str))
2480 return 0;
2481
2482 if (locale)
2483 mbcinfo = locale->mbcinfo;
2484 else
2485 mbcinfo = get_mbcinfo();
2486 if (mbcinfo->ismbcodepage)
2487 {
2488 const unsigned char* xstr = str;
2489 while (*xstr && len-- > 0)
2490 {
2491 if (_ismbblead_l(*xstr++, locale))
2492 xstr++;
2493 }
2494 return xstr - str;
2495 }
2496 ret = u_strlen(str);
2497 return min(ret, len); /* ASCII CP */
2498}
static size_t u_strlen(const unsigned char *str)
Definition: mbcs.c:118
#define min(a, b)
Definition: monoChain.cc:55

Referenced by _mbsnbcnt(), _mbsncoll_l(), _mbsnicoll_l(), and _mbsninc_l().

◆ _mbsnbcoll()

int CDECL _mbsnbcoll ( const unsigned char str1,
const unsigned char str2,
size_t  len 
)

Definition at line 1254 of file mbcs.c.

1255{
1256 return _mbsnbcoll_l(str1, str2, len, NULL);
1257}

◆ _mbsnbcoll_l()

int CDECL _mbsnbcoll_l ( const unsigned char str1,
const unsigned char str2,
size_t  len,
_locale_t  locale 
)

Definition at line 1227 of file mbcs.c.

1228{
1229 pthreadmbcinfo mbcinfo;
1230
1231 if(!locale)
1232 mbcinfo = get_mbcinfo();
1233 else
1234 mbcinfo = locale->mbcinfo;
1235
1236 if(!mbcinfo->ismbcodepage)
1237 return _strncoll_l((const char*)str1, (const char*)str2, len, locale);
1238 return CompareStringA(mbcinfo->mblcid, 0,
1239 (const char*)str1, strnlen((const char*)str1, len),
1240 (const char*)str2, strnlen((const char*)str2, len)) - CSTR_EQUAL;
1241}
_ACRTIMP size_t __cdecl strnlen(const char *, size_t)
Definition: string.c:1602
_ACRTIMP int __cdecl _strncoll_l(const char *, const char *, size_t, _locale_t)
Definition: string.c:1222

Referenced by _mbscoll(), _mbscoll_l(), and _mbsnbcoll().

◆ _mbsnbcpy()

unsigned char *CDECL _mbsnbcpy ( unsigned char dst,
const unsigned char src,
size_t  n 
)

Definition at line 1132 of file mbcs.c.

1133{
1134 return _mbsnbcpy_l(dst, src, n, NULL);
1135}
GLdouble n
Definition: glext.h:7729
unsigned char *CDECL _mbsnbcpy_l(unsigned char *dst, const unsigned char *src, size_t n, _locale_t locale)
Definition: mbcs.c:1088

◆ _mbsnbcpy_l()

unsigned char *CDECL _mbsnbcpy_l ( unsigned char dst,
const unsigned char src,
size_t  n,
_locale_t  locale 
)

Definition at line 1088 of file mbcs.c.

1089{
1090 unsigned char* ret = dst;
1091 pthreadmbcinfo mbcinfo;
1092
1093 if (!n)
1094 return dst;
1095 if (!MSVCRT_CHECK_PMT(dst && src))
1096 return NULL;
1097 if (locale)
1098 mbcinfo = locale->mbcinfo;
1099 else
1100 mbcinfo = get_mbcinfo();
1101 if (mbcinfo->ismbcodepage)
1102 {
1103 BOOL is_lead = FALSE;
1104 while (*src && n)
1105 {
1106 is_lead = (!is_lead && _ismbblead_l(*src, locale));
1107 n--;
1108 *dst++ = *src++;
1109 }
1110
1111 if (is_lead) /* if string ends with a lead, remove it */
1112 *(dst - 1) = 0;
1113 }
1114 else
1115 {
1116 while (n)
1117 {
1118 n--;
1119 if (!(*dst++ = *src++)) break;
1120 }
1121 }
1122 while (n--) *dst++ = 0;
1123 return ret;
1124}
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94

Referenced by _mbsnbcpy().

◆ _mbsnbcpy_s()

int CDECL _mbsnbcpy_s ( unsigned char dst,
size_t  size,
const unsigned char src,
size_t  n 
)

Definition at line 1060 of file mbcs.c.

1061{
1062 return _mbsnbcpy_s_l(dst, size, src, n, NULL);
1063}

◆ _mbsnbcpy_s_l()

int CDECL _mbsnbcpy_s_l ( unsigned char dst,
size_t  size,
const unsigned char src,
size_t  n,
_locale_t  locale 
)

Definition at line 997 of file mbcs.c.

999{
1000 size_t pos = 0;
1001
1002 if(!dst || size == 0)
1003 return EINVAL;
1004 if(!src)
1005 {
1006 dst[0] = '\0';
1007 return EINVAL;
1008 }
1009 if(!n)
1010 return 0;
1011
1012 if((locale ? locale->mbcinfo : get_mbcinfo())->ismbcodepage)
1013 {
1014 BOOL is_lead = FALSE;
1015 while (*src && n)
1016 {
1017 if(pos == size)
1018 {
1019 dst[0] = '\0';
1020 return ERANGE;
1021 }
1022 is_lead = (!is_lead && _ismbblead(*src));
1023 n--;
1024 dst[pos++] = *src++;
1025 }
1026
1027 if (is_lead) /* if string ends with a lead, remove it */
1028 dst[pos - 1] = 0;
1029 }
1030 else
1031 {
1032 while (n)
1033 {
1034 n--;
1035 if(pos == size)
1036 {
1037 dst[0] = '\0';
1038 return ERANGE;
1039 }
1040
1041 if(!(*src)) break;
1042 dst[pos++] = *src++;
1043 }
1044 }
1045
1046 if(pos < size)
1047 dst[pos] = '\0';
1048 else
1049 {
1050 dst[0] = '\0';
1051 return ERANGE;
1052 }
1053
1054 return 0;
1055}
int CDECL _ismbblead(unsigned int c)
Definition: mbcs.c:2077

Referenced by _mbscpy_s_l(), and _mbsnbcpy_s().

◆ _mbsnbicmp()

int CDECL _mbsnbicmp ( const unsigned char str,
const unsigned char cmp,
size_t  len 
)

Definition at line 1532 of file mbcs.c.

1533{
1534 return _mbsnbicmp_l(str, cmp, len, NULL);
1535}
int CDECL _mbsnbicmp_l(const unsigned char *str, const unsigned char *cmp, size_t len, _locale_t locale)
Definition: mbcs.c:1477

◆ _mbsnbicmp_l()

int CDECL _mbsnbicmp_l ( const unsigned char str,
const unsigned char cmp,
size_t  len,
_locale_t  locale 
)

Definition at line 1477 of file mbcs.c.

1478{
1479
1480 pthreadmbcinfo mbcinfo;
1481
1482 if (!len)
1483 return 0;
1484 if (!MSVCRT_CHECK_PMT(str && cmp))
1485 return _NLSCMPERROR;
1486
1487 if (locale)
1488 mbcinfo = locale->mbcinfo;
1489 else
1490 mbcinfo = get_mbcinfo();
1491
1492 if (mbcinfo->ismbcodepage)
1493 {
1494 unsigned int strc, cmpc;
1495 while (len)
1496 {
1497 int clen;
1498 if (!*str)
1499 return *cmp ? -1 : 0;
1500 if (!*cmp)
1501 return 1;
1502 if (_ismbblead_l(*str, locale))
1503 {
1504 strc = (len >= 2) ? _mbsnextc_l(str, locale) : 0;
1505 clen = 2;
1506 }
1507 else
1508 {
1509 strc = *str;
1510 clen = 1;
1511 }
1512 if (_ismbblead_l(*cmp, locale))
1513 cmpc = (len >= 2) ? _mbsnextc_l(cmp, locale) : 0;
1514 else
1515 cmpc = *cmp;
1516 strc = _mbctolower_l(strc, locale);
1517 cmpc = _mbctolower_l(cmpc, locale);
1518 if (strc != cmpc)
1519 return strc < cmpc ? -1 : 1;
1520 len -= clen;
1521 str += clen;
1522 cmp += clen;
1523 }
1524 return 0; /* Matched len bytes */
1525 }
1526 return u_strncasecmp(str, cmp, len);
1527}
static int u_strncasecmp(const unsigned char *s1, const unsigned char *s2, size_t len)
Definition: mbcs.c:143

Referenced by _mbsnbicmp().

◆ _mbsnbicoll()

int CDECL _mbsnbicoll ( const unsigned char str1,
const unsigned char str2,
size_t  len 
)

Definition at line 1206 of file mbcs.c.

1207{
1208 return _mbsnbicoll_l(str1, str2, len, NULL);
1209}

◆ _mbsnbicoll_l()

int CDECL _mbsnbicoll_l ( const unsigned char str1,
const unsigned char str2,
size_t  len,
_locale_t  locale 
)

Definition at line 1179 of file mbcs.c.

1180{
1181 pthreadmbcinfo mbcinfo;
1182
1183 if(!locale)
1184 mbcinfo = get_mbcinfo();
1185 else
1186 mbcinfo = locale->mbcinfo;
1187
1188 if(!mbcinfo->ismbcodepage)
1189 return _strnicoll_l((const char*)str1, (const char*)str2, len, locale);
1190 return CompareStringA(mbcinfo->mblcid, NORM_IGNORECASE,
1191 (const char*)str1, strnlen((const char*)str1, len),
1192 (const char*)str2, strnlen((const char*)str2, len)) - CSTR_EQUAL;
1193}
_ACRTIMP int __cdecl _strnicoll_l(const char *, const char *, size_t, _locale_t)
Definition: string.c:1249

Referenced by _mbsicoll(), _mbsicoll_l(), and _mbsnbicoll().

◆ _mbsnbset()

unsigned char *CDECL _mbsnbset ( unsigned char str,
unsigned int  c,
size_t  len 
)

Definition at line 2372 of file mbcs.c.

2373{
2374 return _mbsnbset_l(str, c, len, NULL);
2375}
unsigned char *CDECL _mbsnbset_l(unsigned char *str, unsigned int c, size_t len, _locale_t locale)
Definition: mbcs.c:2333

◆ _mbsnbset_l()

unsigned char *CDECL _mbsnbset_l ( unsigned char str,
unsigned int  c,
size_t  len,
_locale_t  locale 
)

Definition at line 2333 of file mbcs.c.

2334{
2335 unsigned char *ret = str;
2336 pthreadmbcinfo mbcinfo;
2337
2338 if (!len)
2339 return ret;
2340 if (!MSVCRT_CHECK_PMT(str))
2341 return NULL;
2342
2343 if (locale)
2344 mbcinfo = locale->mbcinfo;
2345 else
2346 mbcinfo = get_mbcinfo();
2347
2348 if (!mbcinfo->ismbcodepage || c < 256)
2349 return u__strnset(str, c, len); /* ASCII CP or SB char */
2350
2351 c &= 0xffff; /* Strip high bits */
2352
2353 while (str[0] && str[1] && (len > 1))
2354 {
2355 *str++ = c >> 8;
2356 len--;
2357 *str++ = c & 0xff;
2358 len--;
2359 }
2360 if (len && str[0])
2361 {
2362 /* as per msdn pad with a blank character */
2363 str[0] = ' ';
2364 }
2365
2366 return ret;
2367}
static unsigned char * u__strnset(unsigned char *s, unsigned char c, size_t len)
Definition: mbcs.c:173

Referenced by _mbsnbset().

◆ _mbsncat()

unsigned char *CDECL _mbsncat ( unsigned char dst,
const unsigned char src,
size_t  len 
)

Definition at line 2665 of file mbcs.c.

2666{
2667 return _mbsncat_l(dst, src, len, NULL);
2668}
unsigned char *CDECL _mbsncat_l(unsigned char *dst, const unsigned char *src, size_t len, _locale_t locale)
Definition: mbcs.c:2627

◆ _mbsncat_l()

unsigned char *CDECL _mbsncat_l ( unsigned char dst,
const unsigned char src,
size_t  len,
_locale_t  locale 
)

Definition at line 2627 of file mbcs.c.

2628{
2629 pthreadmbcinfo mbcinfo;
2630
2631 if (!len)
2632 return dst;
2633
2634 if (!MSVCRT_CHECK_PMT(dst && src))
2635 return NULL;
2636
2637 if (locale)
2638 mbcinfo = locale->mbcinfo;
2639 else
2640 mbcinfo = get_mbcinfo();
2641
2642 if (mbcinfo->ismbcodepage)
2643 {
2644 unsigned char *res = dst;
2645 while (*dst)
2646 {
2647 if (_ismbblead_l(*dst++, locale))
2648 dst++;
2649 }
2650 while (*src && len--)
2651 {
2652 *dst++ = *src;
2653 if (_ismbblead_l(*src++, locale))
2654 *dst++ = *src++;
2655 }
2656 *dst = '\0';
2657 return res;
2658 }
2659 return u_strncat(dst, src, len); /* ASCII CP */
2660}

Referenced by _mbsncat().

◆ _mbsnccnt()

size_t CDECL _mbsnccnt ( const unsigned char str,
size_t  len 
)

Definition at line 2463 of file mbcs.c.

2464{
2465 return _mbsnccnt_l(str, len, NULL);
2466}
size_t CDECL _mbsnccnt_l(const unsigned char *str, size_t len, _locale_t locale)
Definition: mbcs.c:2423

◆ _mbsnccnt_l()

size_t CDECL _mbsnccnt_l ( const unsigned char str,
size_t  len,
_locale_t  locale 
)

Definition at line 2423 of file mbcs.c.

2424{
2425 size_t ret;
2426 pthreadmbcinfo mbcinfo;
2427
2428 if (!len)
2429 return 0;
2430 if (!MSVCRT_CHECK_PMT(str))
2431 return 0;
2432
2433 if (locale)
2434 mbcinfo = locale->mbcinfo;
2435 else
2436 mbcinfo = get_mbcinfo();
2437
2438 if (mbcinfo->ismbcodepage)
2439 {
2440 ret = 0;
2441 while (*str && len-- > 0)
2442 {
2443 if (_ismbblead_l(*str, locale))
2444 {
2445 if (!len)
2446 break;
2447 len--;
2448 str++;
2449 }
2450 str++;
2451 ret++;
2452 }
2453 return ret;
2454 }
2455 ret = u_strlen(str);
2456 return min(ret, len); /* ASCII CP */
2457}

Referenced by _mbsnccnt().

◆ _mbsncmp()

int CDECL _mbsncmp ( const unsigned char str,
const unsigned char cmp,
size_t  len 
)

Definition at line 1358 of file mbcs.c.

1359{
1360 return _mbsncmp_l(str, cmp, len, NULL);
1361}
int CDECL _mbsncmp_l(const unsigned char *str, const unsigned char *cmp, size_t len, _locale_t locale)
Definition: mbcs.c:1316

◆ _mbsncmp_l()

int CDECL _mbsncmp_l ( const unsigned char str,
const unsigned char cmp,
size_t  len,
_locale_t  locale 
)

Definition at line 1316 of file mbcs.c.

1318{
1319 pthreadmbcinfo mbcinfo;
1320 unsigned int strc, cmpc;
1321
1322 if (!len)
1323 return 0;
1324
1325 if (locale)
1326 mbcinfo = locale->mbcinfo;
1327 else
1328 mbcinfo = get_mbcinfo();
1329
1330 if (!mbcinfo->ismbcodepage)
1331 return u_strncmp(str, cmp, len); /* ASCII CP */
1332
1333 if (!MSVCRT_CHECK_PMT(str && cmp))
1334 return _NLSCMPERROR;
1335
1336 while (len--)
1337 {
1338 int inc;
1339
1340 if (!*str)
1341 return *cmp ? -1 : 0;
1342 if (!*cmp)
1343 return 1;
1344 strc = _mbsnextc_l(str, locale);
1345 cmpc = _mbsnextc_l(cmp, locale);
1346 if (strc != cmpc)
1347 return strc < cmpc ? -1 : 1;
1348 inc = (strc > 255) ? 2 : 1; /* Equal, use same increment */
1349 str += inc;
1350 cmp += inc;
1351 }
1352 return 0; /* Matched len chars */
1353}

Referenced by _mbsncmp().

◆ _mbsncpy()

unsigned char *CDECL _mbsncpy ( unsigned char dst,
const unsigned char src,
size_t  n 
)

Definition at line 986 of file mbcs.c.

987{
988 return _mbsncpy_l(dst, src, n, NULL);
989}
unsigned char *CDECL _mbsncpy_l(unsigned char *dst, const unsigned char *src, size_t n, _locale_t locale)
Definition: mbcs.c:859

◆ _mbsncpy_l()

unsigned char *CDECL _mbsncpy_l ( unsigned char dst,
const unsigned char src,
size_t  n,
_locale_t  locale 
)

Definition at line 859 of file mbcs.c.

860{
861 unsigned char* ret = dst;
862 pthreadmbcinfo mbcinfo;
863
864 if (!n)
865 return dst;
866 if (!MSVCRT_CHECK_PMT(dst && src))
867 return NULL;
868 if (locale)
869 mbcinfo = locale->mbcinfo;
870 else
871 mbcinfo = get_mbcinfo();
872
873 if (mbcinfo->ismbcodepage)
874 {
875 while (*src && n)
876 {
877 n--;
878 if (_ismbblead_l(*src, locale))
879 {
880 if (!*(src + 1))
881 {
882 *dst++ = 0;
883 *dst++ = 0;
884 break;
885 }
886 *dst++ = *src++;
887 }
888 *dst++ = *src++;
889 }
890 }
891 else
892 {
893 while (n)
894 {
895 n--;
896 if (!(*dst++ = *src++)) break;
897 }
898 }
899 while (n--) *dst++ = 0;
900 return ret;
901}

Referenced by _mbsncpy().

◆ _mbsnextc()

unsigned int CDECL _mbsnextc ( const unsigned char str)

Definition at line 450 of file mbcs.c.

451{
452 return _mbsnextc_l(str, NULL);
453}

Referenced by _mbstok_s_l().

◆ _mbsnextc_l()

unsigned int CDECL _mbsnextc_l ( const unsigned char str,
_locale_t  locale 
)

Definition at line 440 of file mbcs.c.

441{
442 if(_ismbblead_l(*str, locale))
443 return *str << 8 | str[1];
444 return *str;
445}

Referenced by _mbschr_l(), _mbscmp_l(), _mbsicmp_l(), _mbslwr_l(), _mbslwr_s_l(), _mbsnbcmp_l(), _mbsnbicmp_l(), _mbsncmp_l(), _mbsnextc(), _mbsnicmp_l(), _mbsrchr_l(), _mbsupr_l(), and _mbsupr_s_l().

◆ _mbsnicmp()

int CDECL _mbsnicmp ( const unsigned char str,
const unsigned char cmp,
size_t  len 
)

Definition at line 1469 of file mbcs.c.

1470{
1471 return _mbsnicmp_l(str, cmp, len, NULL);
1472}
int CDECL _mbsnicmp_l(const unsigned char *str, const unsigned char *cmp, size_t len, _locale_t locale)
Definition: mbcs.c:1429

◆ _mbsnicmp_l()

int CDECL _mbsnicmp_l ( const unsigned char str,
const unsigned char cmp,
size_t  len,
_locale_t  locale 
)

Definition at line 1429 of file mbcs.c.

1430{
1431 pthreadmbcinfo mbcinfo;
1432
1433 if (!len)
1434 return 0;
1435 if (!MSVCRT_CHECK_PMT(str && cmp))
1436 return _NLSCMPERROR;
1437
1438 if (locale)
1439 mbcinfo = locale->mbcinfo;
1440 else
1441 mbcinfo = get_mbcinfo();
1442 /* FIXME: No tolower() for mb strings yet */
1443 if (mbcinfo->ismbcodepage)
1444 {
1445 unsigned int strc, cmpc;
1446 while (len--)
1447 {
1448 if (!*str)
1449 return *cmp ? -1 : 0;
1450 if (!*cmp)
1451 return 1;
1454 if (strc != cmpc)
1455 return strc < cmpc ? -1 : 1;
1456 str += (strc > 255) ? 2 : 1;
1457 cmp += (strc > 255) ? 2 : 1; /* Equal, use same increment */
1458 }
1459 return 0; /* Matched len chars */
1460 }
1461 return u_strncasecmp(str, cmp, len); /* ASCII CP */
1462}

Referenced by _mbsnicmp().

◆ _mbsninc()

unsigned char *CDECL _mbsninc ( const unsigned char str,
size_t  num 
)

Definition at line 717 of file mbcs.c.

718{
719 if(!str)
720 return NULL;
721
722 while (num > 0 && *str)
723 {
724 if (_ismbblead(*str))
725 {
726 if (!*(str+1))
727 break;
728 str++;
729 }
730 str++;
731 num--;
732 }
733
734 return (unsigned char*)str;
735}
GLuint GLuint num
Definition: glext.h:9618

◆ _mbsnlen()

size_t CDECL _mbsnlen ( const unsigned char str,
size_t  maxsize 
)

Definition at line 787 of file mbcs.c.

788{
789 return _mbsnlen_l(str, maxsize, NULL);
790}

Referenced by _Success_().

◆ _mbsnlen_l()

size_t CDECL _mbsnlen_l ( const unsigned char str,
size_t  maxsize,
_locale_t  locale 
)

Definition at line 740 of file mbcs.c.

742{
743 pthreadmbcinfo mbcinfo;
744 size_t i = 0, len = 0;
745
746 if(!locale)
747 mbcinfo = get_mbcinfo();
748 else
749 mbcinfo = locale->mbcinfo;
750
751 if(!mbcinfo->ismbcodepage)
752 return strnlen((const char*)str, maxsize);
753
754 while(i<maxsize && str[i])
755 {
756 if (_ismbblead_l(str[i], locale))
757 {
758 i++;
759 if (!str[i]) /* count only full chars */
760 break;
761 }
762 i++;
763 len++;
764 }
765 return i < maxsize ? len : maxsize;
766}

Referenced by _mbslen(), _mbslen_l(), and _mbsnlen().

◆ _mbsnset()

unsigned char *CDECL _mbsnset ( unsigned char str,
unsigned int  c,
size_t  len 
)

Definition at line 2414 of file mbcs.c.

2415{
2416 return _mbsnset_l(str, c, len, NULL);
2417}
unsigned char *CDECL _mbsnset_l(unsigned char *str, unsigned int c, size_t len, _locale_t locale)
Definition: mbcs.c:2380

◆ _mbsnset_l()

unsigned char *CDECL _mbsnset_l ( unsigned char str,
unsigned int  c,
size_t  len,
_locale_t  locale 
)

Definition at line 2380 of file mbcs.c.

2381{
2382 unsigned char *ret = str;
2383 pthreadmbcinfo mbcinfo;
2384
2385 if (!len)
2386 return ret;
2387 if (!MSVCRT_CHECK_PMT(str))
2388 return NULL;
2389
2390 if (locale)
2391 mbcinfo = locale->mbcinfo;
2392 else
2393 mbcinfo = get_mbcinfo();
2394
2395 if (!mbcinfo->ismbcodepage || c < 256)
2396 return u__strnset(str, c, len); /* ASCII CP or SB char */
2397
2398 c &= 0xffff; /* Strip high bits */
2399
2400 while (str[0] && str[1] && len--)
2401 {
2402 *str++ = c >> 8;
2403 *str++ = c & 0xff;
2404 }
2405 if (len && str[0])
2406 str[0] = '\0'; /* FIXME: OK to shorten? */
2407
2408 return ret;
2409}

Referenced by _mbsnset().

◆ _mbspbrk()

unsigned char *CDECL _mbspbrk ( const unsigned char str,
const unsigned char accept 
)

Definition at line 3052 of file mbcs.c.

3053{
3054 return _mbspbrk_l(str, accept, NULL);
3055}
unsigned char *CDECL _mbspbrk_l(const unsigned char *str, const unsigned char *accept, _locale_t locale)
Definition: mbcs.c:3019
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23

◆ _mbspbrk_l()

unsigned char *CDECL _mbspbrk_l ( const unsigned char str,
const unsigned char accept,
_locale_t  locale 
)

Definition at line 3019 of file mbcs.c.

3021{
3022 const unsigned char* p;
3023 pthreadmbcinfo mbcinfo;
3024
3025 if (locale)
3026 mbcinfo = locale->mbcinfo;
3027 else
3028 mbcinfo = get_mbcinfo();
3029
3030 if (!mbcinfo->ismbcodepage)
3031 return u_strpbrk(str, accept);
3032
3033 if (!MSVCRT_CHECK_PMT(str && accept))
3034 return NULL;
3035
3036 while (*str)
3037 {
3038 for (p = accept; *p; p += (_ismbblead_l(*p, locale) ? 2 : 1))
3039 {
3040 if (*p == *str)
3041 if (!_ismbblead_l(*p, locale) || p[1] == str[1])
3042 return (unsigned char*)str;
3043 }
3044 str += (_ismbblead_l(*str, locale) ? 2 : 1);
3045 }
3046 return NULL;
3047}
static unsigned char * u_strpbrk(const unsigned char *str, const unsigned char *accept)
Definition: mbcs.c:153

Referenced by _mbspbrk().

◆ _mbsrchr()

unsigned char *CDECL _mbsrchr ( const unsigned char s,
unsigned int  x 
)

Definition at line 1687 of file mbcs.c.

1688{
1689 return _mbsrchr_l(s, x, NULL);
1690}
unsigned char *CDECL _mbsrchr_l(const unsigned char *s, unsigned int x, _locale_t locale)
Definition: mbcs.c:1654

◆ _mbsrchr_l()

unsigned char *CDECL _mbsrchr_l ( const unsigned char s,
unsigned int  x,
_locale_t  locale 
)

Definition at line 1654 of file mbcs.c.

1655{
1656 pthreadmbcinfo mbcinfo;
1657
1658 if (!MSVCRT_CHECK_PMT(s))
1659 return NULL;
1660
1661 if (locale)
1662 mbcinfo = locale->mbcinfo;
1663 else
1664 mbcinfo = get_mbcinfo();
1665
1666 if (mbcinfo->ismbcodepage)
1667 {
1668 unsigned char *match = NULL;
1669 unsigned int c;
1670
1671 while (1)
1672 {
1673 c = _mbsnextc_l(s, locale);
1674 if (c == x)
1675 match = (unsigned char *)s;
1676 if (!c)
1677 return match;
1678 s += (c > 255) ? 2 : 1;
1679 }
1680 }
1681 return u_strrchr(s, x);
1682}
static unsigned char * u_strrchr(const unsigned char *s, unsigned char x)
Definition: mbcs.c:158
Definition: match.c:28

Referenced by _mbsrchr().

◆ _mbsrev()

unsigned char *CDECL _mbsrev ( unsigned char str)

Definition at line 3011 of file mbcs.c.

3012{
3013 return _mbsrev_l(str, NULL);
3014}
unsigned char *CDECL _mbsrev_l(unsigned char *str, _locale_t locale)
Definition: mbcs.c:2971

◆ _mbsrev_l()

unsigned char *CDECL _mbsrev_l ( unsigned char str,
_locale_t  locale 
)

Definition at line 2971 of file mbcs.c.

2972{
2973 pthreadmbcinfo mbcinfo;
2974 unsigned char *p, tmp;
2975
2976 if (!MSVCRT_CHECK_PMT(str))
2977 return NULL;
2978
2979 if (locale)
2980 mbcinfo = locale->mbcinfo;
2981 else
2982 mbcinfo = get_mbcinfo();
2983
2984 if (!mbcinfo->ismbcodepage)
2985 return u__strrev(str);
2986
2987 for (p = str; *p; p++)
2988 {
2989 if (_ismbblead_l(*p, locale))
2990 {
2991 if (p[1])
2992 {
2993 tmp = p[0];
2994 p[0] = p[1];
2995 p[1] = tmp;
2996 p++;
2997 }
2998 else
2999 {
3000 /* drop trailing lead char */
3001 p[0] = 0;
3002 }
3003 }
3004 }
3005 return u__strrev(str);
3006}
static unsigned char * u__strrev(unsigned char *str)
Definition: mbcs.c:163

Referenced by _mbsrev().

◆ _mbsset()

unsigned char *CDECL _mbsset ( unsigned char str,
unsigned int  c 
)

Definition at line 2325 of file mbcs.c.

2326{
2327 return _mbsset_l(str, c, NULL);
2328}
unsigned char *CDECL _mbsset_l(unsigned char *str, unsigned int c, _locale_t locale)
Definition: mbcs.c:2293

◆ _mbsset_l()

unsigned char *CDECL _mbsset_l ( unsigned char str,
unsigned int  c,
_locale_t  locale 
)

Definition at line 2293 of file mbcs.c.

2294{
2295 unsigned char* ret = str;
2296 pthreadmbcinfo mbcinfo;
2297
2298 if (!MSVCRT_CHECK_PMT(str))
2299 return NULL;
2300
2301 if (locale)
2302 mbcinfo = locale->mbcinfo;
2303 else
2304 mbcinfo = get_mbcinfo();
2305
2306 if (!mbcinfo->ismbcodepage || c < 256)
2307 return u__strset(str, c); /* ASCII CP or SB char */
2308
2309 c &= 0xffff; /* Strip high bits */
2310
2311 while (str[0] && str[1])
2312 {
2313 *str++ = c >> 8;
2314 *str++ = c & 0xff;
2315 }
2316 if (str[0])
2317 str[0] = '\0'; /* FIXME: OK to shorten? */
2318
2319 return ret;
2320}
static unsigned char * u__strset(unsigned char *s, unsigned char c)
Definition: mbcs.c:168

Referenced by _mbsset().

◆ _mbsspn()

size_t CDECL _mbsspn ( const unsigned char string,
const unsigned char set 
)

Definition at line 2907 of file mbcs.c.

2908{
2909 return _mbsspn_l(string, set, NULL);
2910}
Definition: _set.h:50
size_t CDECL _mbsspn_l(const unsigned char *string, const unsigned char *set, _locale_t locale)
Definition: mbcs.c:2870

◆ _mbsspn_l()

size_t CDECL _mbsspn_l ( const unsigned char string,
const unsigned char set,
_locale_t  locale 
)

Definition at line 2870 of file mbcs.c.

2872{
2873 const unsigned char *p, *q;
2874
2875 if (!MSVCRT_CHECK_PMT(string && set))
2876 return 0;
2877
2878 for (p = string; *p; p++)
2879 {
2880 for (q = set; *q; q++)
2881 {
2882 if (_ismbblead_l(*q, locale))
2883 {
2884 /* duplicate a bug in native implementation */
2885 if (!q[1]) break;
2886
2887 if (p[0] == q[0] && p[1] == q[1])
2888 {
2889 p++;
2890 break;
2891 }
2892 q++;
2893 }
2894 else
2895 {
2896 if (p[0] == q[0]) break;
2897 }
2898 }
2899 if (!*q) break;
2900 }
2901 return p - string;
2902}
char string[160]
Definition: util.h:11

Referenced by _mbsspn(), and _mbsspnp_l().

◆ _mbsspnp()

unsigned char *CDECL _mbsspnp ( const unsigned char string,
const unsigned char set 
)

Definition at line 2927 of file mbcs.c.

2928{
2929 return _mbsspnp_l(string, set, NULL);
2930}
unsigned char *CDECL _mbsspnp_l(const unsigned char *string, const unsigned char *set, _locale_t locale)
Definition: mbcs.c:2915

◆ _mbsspnp_l()

unsigned char *CDECL _mbsspnp_l ( const unsigned char string,
const unsigned char set,
_locale_t  locale 
)

Definition at line 2915 of file mbcs.c.

2916{
2917 if (!MSVCRT_CHECK_PMT(string && set))
2918 return 0;
2919
2920 string += _mbsspn_l(string, set, locale);
2921 return *string ? (unsigned char*)string : NULL;
2922}

Referenced by _mbsspnp().

◆ _mbsstr()

unsigned char *CDECL _mbsstr ( const unsigned char haystack,
const unsigned char needle 
)

Definition at line 1608 of file mbcs.c.

1609{
1610 return (unsigned char *)strstr( (const char *)haystack, (const char *)needle );
1611}
_ACRTIMP char *__cdecl strstr(const char *, const char *)
Definition: string.c:3415
static const char haystack[]
Definition: editor.c:190

◆ _mbstok()

unsigned char *CDECL _mbstok ( unsigned char str,
const unsigned char delim 
)

Definition at line 1758 of file mbcs.c.

1759{
1761
1762#if _MSVCR_VER == 0
1763 if(!str && !data->mbstok_next)
1764 return NULL;
1765#endif
1766
1767 return _mbstok_s_l(str, delim, &data->mbstok_next, NULL);
1768}
thread_data_t *CDECL msvcrt_get_thread_data(void)
Definition: thread.c:45
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned char *CDECL _mbstok_s_l(unsigned char *str, const unsigned char *delim, unsigned char **ctx, _locale_t locale)
Definition: mbcs.c:1695

◆ _mbstok_l()

unsigned char *CDECL _mbstok_l ( unsigned char str,
const unsigned char delim,
_locale_t  locale 
)

Definition at line 1749 of file mbcs.c.

1751{
1752 return _mbstok_s_l(str, delim, &msvcrt_get_thread_data()->mbstok_next, locale);
1753}

◆ _mbstok_s()

unsigned char *CDECL _mbstok_s ( unsigned char str,
const unsigned char delim,
unsigned char **  ctx 
)

Definition at line 1740 of file mbcs.c.

1742{
1743 return _mbstok_s_l(str, delim, ctx, NULL);
1744}

◆ _mbstok_s_l()

unsigned char *CDECL _mbstok_s_l ( unsigned char str,
const unsigned char delim,
unsigned char **  ctx,
_locale_t  locale 
)

Definition at line 1695 of file mbcs.c.

1697{
1698 pthreadmbcinfo mbcinfo;
1699 unsigned int c;
1700
1701 if(!MSVCRT_CHECK_PMT(delim != NULL)) return NULL;
1702 if(!MSVCRT_CHECK_PMT(ctx != NULL)) return NULL;
1703 if(!MSVCRT_CHECK_PMT(str || *ctx)) return NULL;
1704
1705 if(locale)
1706 mbcinfo = locale->mbcinfo;
1707 else
1708 mbcinfo = get_mbcinfo();
1709
1710 if(!mbcinfo->ismbcodepage)
1711 return (unsigned char*)strtok_s((char*)str, (const char*)delim, (char**)ctx);
1712
1713 if(!str)
1714 str = *ctx;
1715
1716 while((c=_mbsnextc(str)) && _mbschr(delim, c))
1717 str += c>255 ? 2 : 1;
1718 if(!*str)
1719 {
1720 *ctx = str;
1721 return NULL;
1722 }
1723
1724 *ctx = str + (c>255 ? 2 : 1);
1725 while((c=_mbsnextc(*ctx)) && !_mbschr(delim, c))
1726 *ctx += c>255 ? 2 : 1;
1727 if (**ctx) {
1728 *(*ctx)++ = 0;
1729 if(c > 255)
1730 *(*ctx)++ = 0;
1731 }
1732
1733 return str;
1734}
_ACRTIMP char *__cdecl strtok_s(char *, const char *, char **)
Definition: string.c:309
unsigned char *CDECL _mbschr(const unsigned char *s, unsigned int x)
Definition: mbcs.c:1646
unsigned int CDECL _mbsnextc(const unsigned char *str)
Definition: mbcs.c:450

Referenced by _mbstok(), _mbstok_l(), and _mbstok_s().

◆ _mbstowcs_l()

size_t CDECL _mbstowcs_l ( wchar_t wcstr,
const char mbstr,
size_t  count,
_locale_t  locale 
)

Definition at line 3283 of file mbcs.c.

3285{
3287 size_t i, size;
3288
3289 if(!mbstr) {
3290 *_errno() = EINVAL;
3291 return -1;
3292 }
3293
3294 if(!locale)
3295 locinfo = get_locinfo();
3296 else
3297 locinfo = locale->locinfo;
3298
3299 if(!locinfo->lc_codepage) {
3300 if(!wcstr)
3301 return strlen(mbstr);
3302
3303 for(i=0; i<count; i++) {
3304 wcstr[i] = (unsigned char)mbstr[i];
3305 if(!wcstr[i]) break;
3306 }
3307 return i;
3308 }
3309
3310 /* Ignore count parameter */
3311 if(!wcstr) {
3312 size = MultiByteToWideChar(locinfo->lc_codepage,
3313 MB_ERR_INVALID_CHARS, mbstr, -1, NULL, 0);
3314 if(!size) {
3315 *_errno() = EILSEQ;
3316 return -1;
3317 }
3318 return size - 1;
3319 }
3320
3321 for(i=0, size=0; i<count; i++) {
3322 if(mbstr[size] == '\0')
3323 break;
3324
3325 if(locinfo->lc_codepage == CP_UTF8) {
3326 int j, chlen = get_utf8_char_len(mbstr[size]);
3327
3328 for(j = 1; j < chlen; j++)
3329 {
3330 if(!mbstr[size + j])
3331 {
3332 if(count) wcstr[0] = '\0';
3333 *_errno() = EILSEQ;
3334 return -1;
3335 }
3336 }
3337 size += chlen;
3338 }
3339 else
3340 size += (_isleadbyte_l((unsigned char)mbstr[size], locale) ? 2 : 1);
3341 }
3342
3343 if(size) {
3344 size = MultiByteToWideChar(locinfo->lc_codepage,
3345 MB_ERR_INVALID_CHARS, mbstr, size, wcstr, count);
3346 if(!size) {
3347 if(count) wcstr[0] = '\0';
3348 *_errno() = EILSEQ;
3349 return -1;
3350 }
3351 }
3352
3353 if(size<count)
3354 wcstr[size] = '\0';
3355
3356 return size;
3357}
#define MultiByteToWideChar
Definition: compat.h:110
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
unsigned char
Definition: typeof.h:29
#define MB_ERR_INVALID_CHARS
Definition: unicode.h:41
static int get_utf8_char_len(char ch)
Definition: mbcs.c:3269
#define CP_UTF8
Definition: nls.h:20

◆ _mbstowcs_s()

int CDECL _mbstowcs_s ( size_t ret,
wchar_t wcstr,
size_t  size,
const char mbstr,
size_t  count 
)

Definition at line 3416 of file mbcs.c.

3418{
3419 return _mbstowcs_s_l(ret, wcstr, size, mbstr, count, NULL);
3420}
_mbstowcs_s_l
Definition: stdlib.h:951

◆ _mbstowcs_s_l()

int CDECL _mbstowcs_s_l ( size_t ret,
wchar_t wcstr,
size_t  size,
const char mbstr,
size_t  count,
_locale_t  locale 
)

Definition at line 3371 of file mbcs.c.

3373{
3374 size_t conv;
3375 int err = 0;
3376
3377 if(!wcstr && !size) {
3378 conv = _mbstowcs_l(NULL, mbstr, 0, locale);
3379 if(ret)
3380 *ret = conv+1;
3381 return 0;
3382 }
3383
3384 if (!MSVCRT_CHECK_PMT(wcstr != NULL)) return EINVAL;
3385 if (!MSVCRT_CHECK_PMT(mbstr != NULL)) {
3386 if(size) wcstr[0] = '\0';
3387 return EINVAL;
3388 }
3389
3390 if(count==_TRUNCATE || size<count)
3391 conv = size;
3392 else
3393 conv = count;
3394
3395 conv = _mbstowcs_l(wcstr, mbstr, conv, locale);
3396 if(conv<size)
3397 wcstr[conv++] = '\0';
3398 else if(conv==size && count==_TRUNCATE && wcstr[conv-1]!='\0') {
3399 wcstr[conv-1] = '\0';
3400 err = STRUNCATE;
3401 }else if(conv==size && wcstr[conv-1]!='\0') {
3402 MSVCRT_INVALID_PMT("wcstr[size] is too small", ERANGE);
3403 if(size)
3404 wcstr[0] = '\0';
3405 return ERANGE;
3406 }
3407
3408 if(ret)
3409 *ret = conv;
3410 return err;
3411}
#define STRUNCATE
Definition: errno.h:64
#define _TRUNCATE
Definition: stdlib.h:45
#define err(...)
_mbstowcs_l
Definition: stdlib.h:951

◆ _mbstrlen()

size_t CDECL _mbstrlen ( const char str)

Definition at line 3153 of file mbcs.c.

3154{
3155 return _mbstrlen_l(str, NULL);
3156}
size_t CDECL _mbstrlen_l(const char *str, _locale_t locale)
Definition: mbcs.c:3127

◆ _mbstrlen_l()

size_t CDECL _mbstrlen_l ( const char str,
_locale_t  locale 
)

Definition at line 3127 of file mbcs.c.

3128{
3130
3131 if(!locale)
3132 locinfo = get_locinfo();
3133 else
3134 locinfo = locale->locinfo;
3135
3136 if(locinfo->mb_cur_max > 1) {
3137 size_t len;
3139 str, -1, NULL, 0);
3140 if (!len) {
3141 *_errno() = EILSEQ;
3142 return -1;
3143 }
3144 return len - 1;
3145 }
3146
3147 return strlen(str);
3148}

Referenced by _mbstrlen().

◆ _mbsupr()

unsigned char *CDECL _mbsupr ( unsigned char s)

Definition at line 2812 of file mbcs.c.

2813{
2814 return _mbsupr_l(s, NULL);
2815}
unsigned char *CDECL _mbsupr_l(unsigned char *s, _locale_t locale)
Definition: mbcs.c:2776

◆ _mbsupr_l()

unsigned char *CDECL _mbsupr_l ( unsigned char s,
_locale_t  locale 
)

Definition at line 2776 of file mbcs.c.

2777{
2778 unsigned char *ret = s;
2779 pthreadmbcinfo mbcinfo;
2780
2781 if (!MSVCRT_CHECK_PMT(s))
2782 return NULL;
2783
2784 if (locale)
2785 mbcinfo = locale->mbcinfo;
2786 else
2787 mbcinfo = get_mbcinfo();
2788
2789 if (mbcinfo->ismbcodepage)
2790 {
2791 unsigned int c;
2792 while (*s)
2793 {
2795 /* Note that I assume that the size of the character is unchanged */
2796 if (c > 255)
2797 {
2798 *s++ = (c >> 8);
2799 c = c & 0xff;
2800 }
2801 *s++ = c;
2802 }
2803 }
2804 else
2805 for ( ; *s; s++) *s = _toupper_l(*s, locale);
2806 return ret;
2807}
int CDECL _toupper_l(int c, _locale_t locale)
Definition: ctype.c:474

Referenced by _mbsupr().

◆ _mbsupr_s()

int CDECL _mbsupr_s ( unsigned char s,
size_t  len 
)

Definition at line 2862 of file mbcs.c.

2863{
2864 return _mbsupr_s_l(s, len, NULL);
2865}
int CDECL _mbsupr_s_l(unsigned char *s, size_t len, _locale_t locale)
Definition: mbcs.c:2820

◆ _mbsupr_s_l()

int CDECL _mbsupr_s_l ( unsigned char s,
size_t  len,
_locale_t  locale 
)

Definition at line 2820 of file mbcs.c.

2821{
2822 unsigned char *p = s;
2823
2824 if (!s && !len)
2825 return 0;
2826 if (!MSVCRT_CHECK_PMT(s && len))
2827 return EINVAL;
2828
2829 if (get_mbcinfo()->ismbcodepage)
2830 {
2831 unsigned int c;
2832 for ( ; *s && len > 0; len--)
2833 {
2835 /* Note that I assume that the size of the character is unchanged */
2836 if (c > 255)
2837 {
2838 *s++=(c>>8);
2839 c=c & 0xff;
2840 }
2841 *s++=c;
2842 }
2843 }
2844 else
2845 {
2846 for ( ; *s && len > 0; s++, len--)
2847 *s = _toupper_l(*s, locale);
2848 }
2849
2850 if (!MSVCRT_CHECK_PMT(len))
2851 {
2852 *p = 0;
2853 return EINVAL;
2854 }
2855 *s = 0;
2856 return 0;
2857}

Referenced by _mbsupr_s().

◆ _mbtowc_l()

int CDECL _mbtowc_l ( wchar_t dst,
const char str,
size_t  n,
_locale_t  locale 
)

Definition at line 3161 of file mbcs.c.

3162{
3164 wchar_t tmpdst;
3165
3166 if(!locale)
3167 locinfo = get_locinfo();
3168 else
3169 locinfo = locale->locinfo;
3170
3171 if(n <= 0 || !str)
3172 return 0;
3173
3174 if(!*str) {
3175 if(dst) *dst = 0;
3176 return 0;
3177 }
3178
3179 if(!locinfo->lc_codepage) {
3180 if(dst) *dst = (unsigned char)*str;
3181 return 1;
3182 }
3183 if(n>=2 && _isleadbyte_l((unsigned char)*str, locale)) {
3184 if(!MultiByteToWideChar(locinfo->lc_codepage, 0, str, 2, &tmpdst, 1))
3185 return -1;
3186 if(dst) *dst = tmpdst;
3187 return 2;
3188 }
3189 if(!MultiByteToWideChar(locinfo->lc_codepage, 0, str, 1, &tmpdst, 1))
3190 return -1;
3191 if(dst) *dst = tmpdst;
3192 return 1;
3193}

Referenced by mbtowc().

◆ _setmbcp()

int CDECL _setmbcp ( int  cp)

Definition at line 400 of file mbcs.c.

401{
403 threadmbcinfo *mbcinfo;
404
405 mbcinfo = create_mbcinfo(cp, -1, get_mbcinfo());
406 if(!mbcinfo)
407 {
408 *_errno() = EINVAL;
409 return -1;
410 }
411
412 if(data->locale_flags & LOCALE_THREAD)
413 {
414 if(data->locale_flags & LOCALE_FREE)
415 free_mbcinfo(data->mbcinfo);
416 data->mbcinfo = mbcinfo;
417 }
418 else
419 {
421 free_mbcinfo(MSVCRT_locale->mbcinfo);
422 MSVCRT_locale->mbcinfo = mbcinfo;
423 memcpy(MSVCRT_mbctype, MSVCRT_locale->mbcinfo->mbctype, sizeof(MSVCRT_mbctype));
425 }
426 return 0;
427}
void free_mbcinfo(pthreadmbcinfo mbcinfo)
Definition: locale.c:1138
void CDECL _lock(int locknum)
Definition: lock.c:85
void CDECL _unlock(int locknum)
Definition: lock.c:114
#define LOCALE_FREE
Definition: msvcrt.h:172
#define LOCALE_THREAD
Definition: msvcrt.h:173
#define _MB_CP_LOCK
Definition: mtdll.h:49
POINT cp
Definition: magnifier.c:59
unsigned char MSVCRT_mbctype[257]
Definition: mbcs.c:38
threadmbcinfo * create_mbcinfo(int cp, LCID lcid, threadmbcinfo *old_mbcinfo)
Definition: mbcs.c:219
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define MSVCRT_locale
Definition: locale.h:80

◆ btowc()

wint_t CDECL btowc ( int  c)

Definition at line 3206 of file mbcs.c.

3207{
3208 unsigned char letter = c;
3209 wchar_t ret;
3210
3211 if(c == EOF)
3212 return WEOF;
3213 if(!get_locinfo()->lc_codepage)
3214 return c & 255;
3215 if(!MultiByteToWideChar(get_locinfo()->lc_codepage,
3216 MB_ERR_INVALID_CHARS, (LPCSTR)&letter, 1, &ret, 1))
3217 return WEOF;
3218
3219 return ret;
3220}
#define WEOF
#define EOF
Definition: stdio.h:33
const char * LPCSTR
Definition: xmlstorage.h:183

◆ create_mbcinfo()

threadmbcinfo * create_mbcinfo ( int  cp,
LCID  lcid,
threadmbcinfo old_mbcinfo 
)

Definition at line 219 of file mbcs.c.

220{
221 threadmbcinfo *mbcinfo;
222 int newcp;
223 CPINFO cpi;
224 BYTE *bytes;
225 WORD chartypes[256];
226 char bufA[256];
227 WCHAR bufW[256], lowW[256], upW[256];
228 int charcount, maxchar;
229 int ret;
230 int i;
231
232 if(old_mbcinfo && cp==old_mbcinfo->mbcodepage
233 && (lcid==-1 || lcid==old_mbcinfo->mblcid)) {
234 InterlockedIncrement(&old_mbcinfo->refcount);
235 return old_mbcinfo;
236 }
237
238 mbcinfo = malloc(sizeof(threadmbcinfo));
239 if(!mbcinfo)
240 return NULL;
241 mbcinfo->refcount = 1;
242
243 switch (cp)
244 {
245 case _MB_CP_ANSI:
246 newcp = GetACP();
247 break;
248 case _MB_CP_OEM:
249 newcp = GetOEMCP();
250 break;
251 case _MB_CP_LOCALE:
252 newcp = get_locinfo()->lc_codepage;
253 if(newcp)
254 break;
255 /* fall through (C locale) */
256 case _MB_CP_SBCS:
257 newcp = 20127; /* ASCII */
258 break;
259 default:
260 newcp = cp;
261 break;
262 }
263
264 if(lcid == -1) {
266 sprintf(bufA, ".%d", newcp);
267 mbcinfo->mblcid = locale_to_sname(bufA, NULL, NULL, wbuf) ? LocaleNameToLCID(wbuf, LOCALE_ALLOW_NEUTRAL_NAMES) : -1;
268 } else {
269 mbcinfo->mblcid = lcid;
270 }
271
272 if(mbcinfo->mblcid == -1)
273 {
274 WARN("Can't assign LCID to codepage (%d)\n", mbcinfo->mblcid);
275 mbcinfo->mblcid = 0;
276 }
277
278 if (!GetCPInfo(newcp, &cpi))
279 {
280 WARN("Codepage %d not found\n", newcp);
281 free(mbcinfo);
282 return NULL;
283 }
284
285 /* setup the _mbctype */
286 memset(mbcinfo->mbctype, 0, sizeof(unsigned char[257]));
287 memset(mbcinfo->mbcasemap, 0, sizeof(unsigned char[256]));
288
289 bytes = cpi.LeadByte;
290 while (bytes[0] || bytes[1])
291 {
292 for (i = bytes[0]; i <= bytes[1]; i++)
293 mbcinfo->mbctype[i + 1] |= _M1;
294 bytes += 2;
295 }
296
297 if (cpi.MaxCharSize == 2)
298 {
299 /* trail bytes not available through kernel32 but stored in a structure in msvcrt */
300 struct cp_extra_info_t *cpextra = g_cpextrainfo;
301
302 mbcinfo->ismbcodepage = 1;
303 while (TRUE)
304 {
305 if (cpextra->cp == 0 || cpextra->cp == newcp)
306 {
307 if (cpextra->cp == 0)
308 FIXME("trail bytes data not available for DBCS codepage %d - assuming all bytes\n", newcp);
309
310 bytes = cpextra->TrailBytes;
311 while (bytes[0] || bytes[1])
312 {
313 for (i = bytes[0]; i <= bytes[1]; i++)
314 mbcinfo->mbctype[i + 1] |= _M2;
315 bytes += 2;
316 }
317 break;
318 }
319 cpextra++;
320 }
321 }
322 else
323 mbcinfo->ismbcodepage = 0;
324
325 maxchar = (newcp == CP_UTF8) ? 128 : 256;
326
327 /* we can't use GetStringTypeA directly because we don't have a locale - only a code page
328 */
329 charcount = 0;
330 for (i = 0; i < maxchar; i++)
331 if (!(mbcinfo->mbctype[i + 1] & _M1))
332 bufA[charcount++] = i;
333
334 ret = MultiByteToWideChar(newcp, 0, bufA, charcount, bufW, charcount);
335 if (ret != charcount)
336 {
337 ERR("MultiByteToWideChar of chars failed for cp %d, ret=%d (exp %d), error=%ld\n",
338 newcp, ret, charcount, GetLastError());
339 }
340
341 GetStringTypeW(CT_CTYPE1, bufW, charcount, chartypes);
342 LCMapStringW(mbcinfo->mblcid, LCMAP_LOWERCASE, bufW, charcount, lowW, charcount);
343 LCMapStringW(mbcinfo->mblcid, LCMAP_UPPERCASE, bufW, charcount, upW, charcount);
344
345 charcount = 0;
346 for (i = 0; i < maxchar; i++)
347 if (!(mbcinfo->mbctype[i + 1] & _M1))
348 {
349 if (chartypes[charcount] & C1_UPPER)
350 {
351 mbcinfo->mbctype[i + 1] |= _SBUP;
352 bufW[charcount] = lowW[charcount];
353 }
354 else if (chartypes[charcount] & C1_LOWER)
355 {
356 mbcinfo->mbctype[i + 1] |= _SBLOW;
357 bufW[charcount] = upW[charcount];
358 }
359 charcount++;
360 }
361
362 ret = WideCharToMultiByte(newcp, 0, bufW, charcount, bufA, charcount, NULL, NULL);
363 if (ret != charcount)
364 {
365 ERR("WideCharToMultiByte failed for cp %d, ret=%d (exp %d), error=%ld\n",
366 newcp, ret, charcount, GetLastError());
367 }
368
369 charcount = 0;
370 for (i = 0; i < maxchar; i++)
371 {
372 if(!(mbcinfo->mbctype[i + 1] & _M1))
373 {
374 if(mbcinfo->mbctype[i + 1] & (_SBUP | _SBLOW))
375 mbcinfo->mbcasemap[i] = bufA[charcount];
376 charcount++;
377 }
378 }
379
380 if (newcp == 932) /* CP932 only - set _MP and _MS */
381 {
382 /* On Windows it's possible to calculate the _MP and _MS from CT_CTYPE1
383 * and CT_CTYPE3. But as of Wine 0.9.43 we return wrong values what makes
384 * it hard. As this is set only for codepage 932 we hardcode it what gives
385 * also faster execution.
386 */
387 for (i = 161; i <= 165; i++)
388 mbcinfo->mbctype[i + 1] |= _MP;
389 for (i = 166; i <= 223; i++)
390 mbcinfo->mbctype[i + 1] |= _MS;
391 }
392
393 mbcinfo->mbcodepage = newcp;
394 return mbcinfo;
395}
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define InterlockedIncrement
Definition: armddk.h:53
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define TRUE
Definition: types.h:120
#define WideCharToMultiByte
Definition: compat.h:111
LCID WINAPI LocaleNameToLCID(_In_ LPCWSTR lpName, _In_ DWORD dwFlags)
UINT WINAPI GetACP(void)
Definition: locale.c:2023
BOOL WINAPI GetCPInfo(UINT codepage, LPCPINFO cpinfo)
Definition: locale.c:2146
INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen, LPWSTR dst, INT dstlen)
Definition: locale.c:3808
UINT WINAPI GetOEMCP(void)
Definition: locale.c:2062
LCID lcid
Definition: locale.c:5656
#define _MP
Definition: mbctype.h:37
#define _MB_CP_OEM
Definition: mbctype.h:52
#define _MB_CP_ANSI
Definition: mbctype.h:53
#define _MB_CP_LOCALE
Definition: mbctype.h:54
#define _MS
Definition: mbctype.h:36
#define _MB_CP_SBCS
Definition: mbctype.h:51
BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_match, WCHAR *sname)
Definition: locale.c:335
#define C1_LOWER
Definition: unicode.h:32
#define C1_UPPER
Definition: unicode.h:31
static struct cp_extra_info_t g_cpextrainfo[]
Definition: mbcs.c:48
#define for
Definition: utility.h:88
#define sprintf
Definition: sprintf.c:45
#define LOCALE_NAME_MAX_LENGTH
#define memset(x, y, z)
Definition: compat.h:39
BYTE LeadByte[MAX_LEADBYTES]
Definition: winnls.h:652
UINT MaxCharSize
Definition: winnls.h:650
BYTE TrailBytes[MAX_LEADBYTES]
Definition: mbcs.c:45
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define LOCALE_ALLOW_NEUTRAL_NAMES
Definition: winnls.h:25
#define CT_CTYPE1
Definition: winnls.h:255
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

Referenced by _create_locale(), and _setmbcp().

◆ get_utf8_char_len()

static int get_utf8_char_len ( char  ch)
inlinestatic

Definition at line 3269 of file mbcs.c.

3270{
3271 if((ch&0xf8) == 0xf0)
3272 return 4;
3273 else if((ch&0xf0) == 0xe0)
3274 return 3;
3275 else if((ch&0xe0) == 0xc0)
3276 return 2;
3277 return 1;
3278}

Referenced by _mbstowcs_l().

◆ mblen()

int CDECL mblen ( const char str,
size_t  size 
)

Definition at line 3087 of file mbcs.c.

3088{
3089 return _mblen_l(str, size, NULL);
3090}
int CDECL _mblen_l(const char *str, size_t size, _locale_t locale)
Definition: mbcs.c:3067

◆ mbrlen()

size_t CDECL mbrlen ( const char str,
size_t  len,
mbstate_t state 
)

Definition at line 3095 of file mbcs.c.

3096{
3097 mbstate_t s = (state ? *state : 0);
3098 size_t ret;
3099
3100 if(!len || !str || !*str)
3101 return 0;
3102
3103 if(get_locinfo()->mb_cur_max == 1) {
3104 return 1;
3105 }else if(!s && isleadbyte((unsigned char)*str)) {
3106 if(len == 1) {
3107 s = (unsigned char)*str;
3108 ret = -2;
3109 }else {
3110 ret = 2;
3111 }
3112 }else if(!s) {
3113 ret = 1;
3114 }else {
3115 s = 0;
3116 ret = 2;
3117 }
3118
3119 if(state)
3120 *state = s;
3121 return ret;
3122}
static int state
Definition: maze.c:121
int mbstate_t
Definition: wchar.h:30
#define isleadbyte(_c)
Definition: wchar.h:598

◆ mbrtowc()

size_t CDECL mbrtowc ( wchar_t dst,
const char str,
size_t  n,
mbstate_t state 
)

Definition at line 3225 of file mbcs.c.

3227{
3229 mbstate_t s = (state ? *state : 0);
3230 char tmpstr[2];
3231 int len = 0;
3232
3233 if(dst)
3234 *dst = 0;
3235
3236 if(!n || !str || !*str)
3237 return 0;
3238
3239 if(locinfo->mb_cur_max == 1) {
3240 tmpstr[len++] = *str;
3241 }else if(!s && isleadbyte((unsigned char)*str)) {
3242 if(n == 1) {
3243 s = (unsigned char)*str;
3244 len = -2;
3245 }else {
3246 tmpstr[0] = str[0];
3247 tmpstr[1] = str[1];
3248 len = 2;
3249 }
3250 }else if(!s) {
3251 tmpstr[len++] = *str;
3252 }else {
3253 tmpstr[0] = s;
3254 tmpstr[1] = *str;
3255 len = 2;
3256 s = 0;
3257 }
3258
3259 if(len > 0) {
3260 if(!MultiByteToWideChar(locinfo->lc_codepage, 0, tmpstr, len, dst, dst ? 1 : 0))
3261 len = -1;
3262 }
3263
3264 if(state)
3265 *state = s;
3266 return len;
3267}

◆ mbsrtowcs()

size_t CDECL mbsrtowcs ( wchar_t wcstr,
const char **  pmbstr,
size_t  count,
mbstate_t state 
)

Definition at line 3425 of file mbcs.c.

3427{
3428 mbstate_t s = (state ? *state : 0);
3429 wchar_t tmpdst;
3430 size_t ret = 0;
3431 const char *p;
3432
3433 if(!MSVCRT_CHECK_PMT(pmbstr != NULL))
3434 return -1;
3435
3436 p = *pmbstr;
3437 while(!wcstr || count>ret) {
3438 int ch_len = mbrtowc(&tmpdst, p, 2, &s);
3439 if(wcstr)
3440 wcstr[ret] = tmpdst;
3441
3442 if(ch_len < 0) {
3443 return -1;
3444 }else if(ch_len == 0) {
3445 if(wcstr) *pmbstr = NULL;
3446 return ret;
3447 }
3448
3449 p += ch_len;
3450 ret++;
3451 }
3452
3453 if(wcstr) *pmbstr = p;
3454 return ret;
3455}
#define mbrtowc(wp, cp, len, sp)
Definition: wchar.h:158

Referenced by mbsrtowcs_s().

◆ mbsrtowcs_s()

int CDECL mbsrtowcs_s ( size_t ret,
wchar_t wcstr,
size_t  len,
const char **  mbstr,
size_t  count,
mbstate_t state 
)

Definition at line 3460 of file mbcs.c.

3462{
3463 size_t tmp;
3464
3465 if(!ret) ret = &tmp;
3466 if(!MSVCRT_CHECK_PMT(!!wcstr == !!len)) {
3467 *ret = -1;
3468 return EINVAL;
3469 }
3470
3471 *ret = mbsrtowcs(wcstr, mbstr, count>len ? len : count, state);
3472 if(*ret == -1) {
3473 if(wcstr) *wcstr = 0;
3474 return *_errno();
3475 }
3476 (*ret)++;
3477 if(*ret > len) {
3478 /* no place for terminating '\0' */
3479 if(wcstr) *wcstr = 0;
3480 return 0;
3481 }
3482 if(wcstr) wcstr[(*ret)-1] = 0;
3483 return 0;
3484}
size_t CDECL mbsrtowcs(wchar_t *wcstr, const char **pmbstr, size_t count, mbstate_t *state)
Definition: mbcs.c:3425

◆ mbstowcs()

size_t CDECL mbstowcs ( wchar_t wcstr,
const char mbstr,
size_t  count 
)

Definition at line 3362 of file mbcs.c.

3364{
3365 return _mbstowcs_l(wcstr, mbstr, count, NULL);
3366}

◆ mbtowc()

int CDECL mbtowc ( wchar_t dst,
const char str,
size_t  n 
)

Definition at line 3198 of file mbcs.c.

3199{
3200 return _mbtowc_l(dst, str, n, NULL);
3201}
int CDECL _mbtowc_l(wchar_t *dst, const char *str, size_t n, _locale_t locale)
Definition: mbcs.c:3161

◆ msvcrt_mbc_to_wc_l()

static wchar_t msvcrt_mbc_to_wc_l ( unsigned int  ch,
_locale_t  locale 
)
static

Definition at line 90 of file mbcs.c.

91{
92 pthreadmbcinfo mbcinfo;
93 wchar_t chW;
94 char mbch[2];
95 int n_chars;
96
97 if(locale)
98 mbcinfo = locale->mbcinfo;
99 else
100 mbcinfo = get_mbcinfo();
101
102 if (ch <= 0xff) {
103 mbch[0] = ch;
104 n_chars = 1;
105 } else {
106 mbch[0] = (ch >> 8) & 0xff;
107 mbch[1] = ch & 0xff;
108 n_chars = 2;
109 }
110 if (!MultiByteToWideChar(mbcinfo->mbcodepage, 0, mbch, n_chars, &chW, 1))
111 {
112 WARN("MultiByteToWideChar failed on %x\n", ch);
113 return 0;
114 }
115 return chW;
116}

Referenced by _ismbcalnum_l(), _ismbcalpha_l(), _ismbcdigit_l(), _ismbcgraph_l(), _ismbclower_l(), _ismbcprint_l(), _ismbcpunct_l(), _ismbcspace_l(), _ismbcsymbol_l(), and _ismbcupper_l().

◆ u__strnset()

static unsigned char * u__strnset ( unsigned char s,
unsigned char  c,
size_t  len 
)
inlinestatic

Definition at line 173 of file mbcs.c.

174{
175 return (unsigned char*) _strnset( (char*)s, c, len );
176}
_strnset
Definition: string.h:393

Referenced by _mbsnbset_l(), and _mbsnset_l().

◆ u__strrev()

static unsigned char * u__strrev ( unsigned char str)
inlinestatic

Definition at line 163 of file mbcs.c.

164{
165 return (unsigned char*)_strrev((char *)str);
166}
_ACRTIMP char *__cdecl _strrev(char *)
Definition: string.c:254

Referenced by _mbsrev_l().

◆ u__strset()

static unsigned char * u__strset ( unsigned char s,
unsigned char  c 
)
inlinestatic

Definition at line 168 of file mbcs.c.

169{
170 return (unsigned char*) _strset( (char*)s, c);
171}
_strset
Definition: string.h:424

Referenced by _mbsset_l().

◆ u_strcasecmp()

static int u_strcasecmp ( const unsigned char s1,
const unsigned char s2 
)
inlinestatic

Definition at line 133 of file mbcs.c.

134{
135 return _stricmp( (const char*)s1, (const char*)s2 );
136}
#define _stricmp
Definition: cat.c:22
struct S1 s1
PCWSTR s2
Definition: shell32_main.h:38

Referenced by _mbsicmp_l().

◆ u_strchr()

static unsigned char * u_strchr ( const unsigned char s,
unsigned char  x 
)
inlinestatic

Definition at line 148 of file mbcs.c.

149{
150 return (unsigned char*) strchr( (const char*)s, x );
151}
_ACRTIMP char *__cdecl strchr(const char *, int)
Definition: string.c:3286

Referenced by _mbschr_l().

◆ u_strcmp()

static int u_strcmp ( const unsigned char s1,
const unsigned char s2 
)
inlinestatic

Definition at line 128 of file mbcs.c.

129{
130 return strcmp( (const char*)s1, (const char*)s2 );
131}
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319

Referenced by _mbscmp_l().

◆ u_strlen()

static size_t u_strlen ( const unsigned char str)
inlinestatic

Definition at line 118 of file mbcs.c.

119{
120 return strlen( (const char*) str );
121}

Referenced by _mbsnbcnt_l(), and _mbsnccnt_l().

◆ u_strncasecmp()

static int u_strncasecmp ( const unsigned char s1,
const unsigned char s2,
size_t  len 
)
inlinestatic

Definition at line 143 of file mbcs.c.

144{
145 return _strnicmp( (const char*)s1, (const char*)s2, len );
146}
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23

Referenced by _mbsnbicmp_l(), and _mbsnicmp_l().

◆ u_strncat()

static unsigned char * u_strncat ( unsigned char dst,
const unsigned char src,
size_t  len 
)
inlinestatic

Definition at line 123 of file mbcs.c.

124{
125 return (unsigned char*)strncat( (char*)dst, (const char*)src, len);
126}
_In_opt_ _Locale strncat
Definition: string.h:263

Referenced by _mbsnbcat_l(), and _mbsncat_l().

◆ u_strncmp()

static int u_strncmp ( const unsigned char s1,
const unsigned char s2,
size_t  len 
)
inlinestatic

Definition at line 138 of file mbcs.c.

139{
140 return strncmp( (const char*)s1, (const char*)s2, len );
141}
_ACRTIMP int __cdecl strncmp(const char *, const char *, size_t)
Definition: string.c:3330

Referenced by _mbsnbcmp_l(), and _mbsncmp_l().

◆ u_strpbrk()

static unsigned char * u_strpbrk ( const unsigned char str,
const unsigned char accept 
)
inlinestatic

Definition at line 153 of file mbcs.c.

154{
155 return (unsigned char*)strpbrk((const char*)str, (const char*)accept);
156}
_ACRTIMP char *__cdecl strpbrk(const char *, const char *)
Definition: string.c:3525

Referenced by _mbspbrk_l().

◆ u_strrchr()

static unsigned char * u_strrchr ( const unsigned char s,
unsigned char  x 
)
inlinestatic

Definition at line 158 of file mbcs.c.

159{
160 return (unsigned char*) strrchr( (const char*)s, x );
161}
_ACRTIMP char *__cdecl strrchr(const char *, int)
Definition: string.c:3298

Referenced by _mbsrchr_l().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msvcrt  )

Variable Documentation

◆ g_cpextrainfo

struct cp_extra_info_t g_cpextrainfo[]
static
Initial value:
=
{
{932, {0x40, 0x7e, 0x80, 0xfc, 0, 0}},
{936, {0x40, 0xfe, 0, 0}},
{949, {0x41, 0xfe, 0, 0}},
{950, {0x40, 0x7e, 0xa1, 0xfe, 0, 0}},
{1361, {0x31, 0x7e, 0x81, 0xfe, 0, 0}},
{20932, {1, 255, 0, 0}},
{0, {1, 255, 0, 0}}
}

Definition at line 48 of file mbcs.c.

Referenced by create_mbcinfo().

◆ mbbtombc_932

const unsigned char mbbtombc_932[]
static
Initial value:
= {
0x40,0x49,0x68,0x94,0x90,0x93,0x95,0x66,0x69,0x6a,0x96,0x7b,0x43,0x7c,0x44,0x5e,
0x4f,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x46,0x47,0x83,0x81,0x84,0x48,
0x97,0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,
0x6f,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x6d,0x8f,0x6e,0x4f,0x76,
0x77,0x78,0x79,0x6d,0x8f,0x6e,0x4f,0x51,0x65,0x81,0x82,0x83,0x84,0x85,0x86,0x87,
0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,0x95,0x50,
0x42,0x75,0x76,0x41,0x45,0x92,0x40,0x42,0x44,0x46,0x48,0x83,0x85,0x87,0x62,
0x5b,0x41,0x43,0x45,0x47,0x49,0x4a,0x4c,0x4e,0x50,0x52,0x54,0x56,0x58,0x5a,0x5c,
0x5e,0x60,0x63,0x65,0x67,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x71,0x74,0x77,0x7a,0x7d,
0x7e,0x80,0x81,0x82,0x84,0x86,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8f,0x93,0x4a,0x4b }

Definition at line 60 of file mbcs.c.

Referenced by _mbbtombc_l().

◆ mbctombb_932_kana

const unsigned char mbctombb_932_kana[]
static
Initial value:
= {
0xa7,0xb1,0xa8,0xb2,0xa9,0xb3,0xaa,0xb4,0xab,0xb5,0xb6,0xb6,0xb7,0xb7,0xb8,0xb8,
0xb9,0xb9,0xba,0xba,0xbb,0xbb,0xbc,0xbc,0xbd,0xbd,0xbe,0xbe,0xbf,0xbf,0xc0,0xc0,
0xc1,0xc1,0xaf,0xc2,0xc2,0xc3,0xc3,0xc4,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xca,
0xca,0xcb,0xcb,0xcb,0xcc,0xcc,0xcc,0xcd,0xcd,0xcd,0xce,0xce,0xce,0xcf,0xd0,0xd1,
0xd2,0xd3,0xac,0xd4,0xad,0xd5,0xae,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdc,0xb2,
0xb4,0xa6,0xdd,0xb3,0xb6,0xb9}

Definition at line 82 of file mbcs.c.

Referenced by _mbctombb_l().

◆ mbctombb_932_punct

const unsigned char mbctombb_932_punct[]
static
Initial value:
= {
0x20,0xa4,0xa1,0x2c,0x2e,0xa5,0x3a,0x3b,0x3f,0x21,0xde,0xdf,0x00,0x00,0x00,0x5e,
0x7e,0x5f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x00,0x00,0x2f,0x00,
0x00,0x00,0x7c,0x00,0x00,0x60,0x27,0x00,0x22,0x28,0x29,0x00,0x00,0x5b,0x5d,0x7b,
0x7d,0x00,0x00,0x00,0x00,0xa2,0xa3,0x00,0x00,0x00,0x00,0x2b,0x2d,0x00,0x00,0x00,
0x00,0x3d,0x00,0x3c,0x3e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5c,
0x24,0x00,0x00,0x25,0x23,0x26,0x2a,0x40}

Definition at line 73 of file mbcs.c.

Referenced by _mbctombb_l().

◆ MSVCRT_mbctype

unsigned char MSVCRT_mbctype[257] = { 0 }

Definition at line 38 of file mbcs.c.

Referenced by _setmbcp().