ReactOS 0.4.16-dev-2284-g3529151
mbcs.c
Go to the documentation of this file.
1/*
2 * msvcrt.dll mbcs functions
3 *
4 * Copyright 1999 Alexandre Julliard
5 * Copyright 2000 Jon Griffths
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 *
21 * FIXME
22 * Not currently binary compatible with win32. MSVCRT_mbctype must be
23 * populated correctly and the ismb* functions should reference it.
24 */
25
26#include <stdio.h>
27#include <limits.h>
28#include <mbctype.h>
29#include <mbstring.h>
30
31#include "msvcrt.h"
32#include "mtdll.h"
33#include "winnls.h"
34#include "wine/debug.h"
35
37
38unsigned char MSVCRT_mbctype[257] = { 0 };
39
40/* It seems that the data about valid trail bytes is not available from kernel32
41 * so we have to store is here. The format is the same as for lead bytes in CPINFO */
43{
44 int cp;
46};
47
49{
50 {932, {0x40, 0x7e, 0x80, 0xfc, 0, 0}},
51 {936, {0x40, 0xfe, 0, 0}},
52 {949, {0x41, 0xfe, 0, 0}},
53 {950, {0x40, 0x7e, 0xa1, 0xfe, 0, 0}},
54 {1361, {0x31, 0x7e, 0x81, 0xfe, 0, 0}},
55 {20932, {1, 255, 0, 0}}, /* seems to give different results on different systems */
56 {0, {1, 255, 0, 0}} /* match all with FIXME */
57};
58
59/* Maps cp932 single byte character to multi byte character */
60static const unsigned char mbbtombc_932[] = {
61 0x40,0x49,0x68,0x94,0x90,0x93,0x95,0x66,0x69,0x6a,0x96,0x7b,0x43,0x7c,0x44,0x5e,
62 0x4f,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x46,0x47,0x83,0x81,0x84,0x48,
63 0x97,0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,
64 0x6f,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x6d,0x8f,0x6e,0x4f,0x76,
65 0x77,0x78,0x79,0x6d,0x8f,0x6e,0x4f,0x51,0x65,0x81,0x82,0x83,0x84,0x85,0x86,0x87,
66 0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,0x95,0x50,
67 0x42,0x75,0x76,0x41,0x45,0x92,0x40,0x42,0x44,0x46,0x48,0x83,0x85,0x87,0x62,
68 0x5b,0x41,0x43,0x45,0x47,0x49,0x4a,0x4c,0x4e,0x50,0x52,0x54,0x56,0x58,0x5a,0x5c,
69 0x5e,0x60,0x63,0x65,0x67,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x71,0x74,0x77,0x7a,0x7d,
70 0x7e,0x80,0x81,0x82,0x84,0x86,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8f,0x93,0x4a,0x4b };
71
72/* Maps multibyte cp932 punctuation marks to single byte equivalents */
73static const unsigned char mbctombb_932_punct[] = {
74 0x20,0xa4,0xa1,0x2c,0x2e,0xa5,0x3a,0x3b,0x3f,0x21,0xde,0xdf,0x00,0x00,0x00,0x5e,
75 0x7e,0x5f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x00,0x00,0x2f,0x00,
76 0x00,0x00,0x7c,0x00,0x00,0x60,0x27,0x00,0x22,0x28,0x29,0x00,0x00,0x5b,0x5d,0x7b,
77 0x7d,0x00,0x00,0x00,0x00,0xa2,0xa3,0x00,0x00,0x00,0x00,0x2b,0x2d,0x00,0x00,0x00,
78 0x00,0x3d,0x00,0x3c,0x3e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5c,
79 0x24,0x00,0x00,0x25,0x23,0x26,0x2a,0x40};
80
81/* Maps multibyte cp932 hiragana/katakana to single-byte equivalents */
82static const unsigned char mbctombb_932_kana[] = {
83 0xa7,0xb1,0xa8,0xb2,0xa9,0xb3,0xaa,0xb4,0xab,0xb5,0xb6,0xb6,0xb7,0xb7,0xb8,0xb8,
84 0xb9,0xb9,0xba,0xba,0xbb,0xbb,0xbc,0xbc,0xbd,0xbd,0xbe,0xbe,0xbf,0xbf,0xc0,0xc0,
85 0xc1,0xc1,0xaf,0xc2,0xc2,0xc3,0xc3,0xc4,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xca,
86 0xca,0xcb,0xcb,0xcb,0xcc,0xcc,0xcc,0xcd,0xcd,0xcd,0xce,0xce,0xce,0xcf,0xd0,0xd1,
87 0xd2,0xd3,0xac,0xd4,0xad,0xd5,0xae,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdc,0xb2,
88 0xb4,0xa6,0xdd,0xb3,0xb6,0xb9};
89
90static wchar_t msvcrt_mbc_to_wc_l(unsigned int ch, _locale_t locale)
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}
117
118static inline size_t u_strlen( const unsigned char *str )
119{
120 return strlen( (const char*) str );
121}
122
123static inline unsigned char* u_strncat( unsigned char* dst, const unsigned char* src, size_t len )
124{
125 return (unsigned char*)strncat( (char*)dst, (const char*)src, len);
126}
127
128static inline int u_strcmp( const unsigned char *s1, const unsigned char *s2 )
129{
130 return strcmp( (const char*)s1, (const char*)s2 );
131}
132
133static inline int u_strcasecmp( const unsigned char *s1, const unsigned char *s2 )
134{
135 return _stricmp( (const char*)s1, (const char*)s2 );
136}
137
138static inline int u_strncmp( const unsigned char *s1, const unsigned char *s2, size_t len )
139{
140 return strncmp( (const char*)s1, (const char*)s2, len );
141}
142
143static inline int u_strncasecmp( const unsigned char *s1, const unsigned char *s2, size_t len )
144{
145 return _strnicmp( (const char*)s1, (const char*)s2, len );
146}
147
148static inline unsigned char *u_strchr( const unsigned char *s, unsigned char x )
149{
150 return (unsigned char*) strchr( (const char*)s, x );
151}
152
153static inline unsigned char* u_strpbrk(const unsigned char *str, const unsigned char *accept)
154{
155 return (unsigned char*)strpbrk((const char*)str, (const char*)accept);
156}
157
158static inline unsigned char *u_strrchr( const unsigned char *s, unsigned char x )
159{
160 return (unsigned char*) strrchr( (const char*)s, x );
161}
162
163static inline unsigned char* u__strrev(unsigned char *str)
164{
165 return (unsigned char*)_strrev((char *)str);
166}
167
168static inline unsigned char *u__strset( unsigned char *s, unsigned char c )
169{
170 return (unsigned char*) _strset( (char*)s, c);
171}
172
173static inline unsigned char *u__strnset( unsigned char *s, unsigned char c, size_t len )
174{
175 return (unsigned char*) _strnset( (char*)s, c, len );
176}
177
178/*********************************************************************
179 * __p__mbctype (MSVCRT.@)
180 */
181unsigned char* CDECL __p__mbctype(void)
182{
183 return get_mbcinfo()->mbctype;
184}
185
186/*********************************************************************
187 * __p___mb_cur_max(MSVCRT.@)
188 */
190{
191 return &get_locinfo()->mb_cur_max;
192}
193
194/*********************************************************************
195 * ___mb_cur_max_func(MSVCRT.@)
196 */
198{
199 return get_locinfo()->mb_cur_max;
200}
201
202#if _MSVCR_VER>=80
203/*********************************************************************
204 * ___mb_cur_max_l_func (MSVCR80.@)
205 */
207{
209
210 if(!locale)
212 else
213 locinfo = locale->locinfo;
214
215 return locinfo->mb_cur_max;
216}
217#endif
218
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}
396
397/*********************************************************************
398 * _setmbcp (MSVCRT.@)
399 */
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}
428
429/*********************************************************************
430 * _getmbcp (MSVCRT.@)
431 */
433{
434 return get_mbcinfo()->mbcodepage;
435}
436
437/*********************************************************************
438 * _mbsnextc_l(MSVCRT.@)
439 */
440unsigned int CDECL _mbsnextc_l(const unsigned char* str, _locale_t locale)
441{
442 if(_ismbblead_l(*str, locale))
443 return *str << 8 | str[1];
444 return *str;
445}
446
447/*********************************************************************
448 * _mbsnextc(MSVCRT.@)
449 */
450unsigned int CDECL _mbsnextc(const unsigned char* str)
451{
452 return _mbsnextc_l(str, NULL);
453}
454
455/*********************************************************************
456 * _mbctolower_l(MSVCRT.@)
457 */
458unsigned int CDECL _mbctolower_l(unsigned int c, _locale_t locale)
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}
489
490/*********************************************************************
491 * _mbctolower(MSVCRT.@)
492 */
493unsigned int CDECL _mbctolower(unsigned int c)
494{
495 return _mbctolower_l(c, NULL);
496}
497
498/*********************************************************************
499 * _mbctoupper_l(MSVCRT.@)
500 */
501unsigned int CDECL _mbctoupper_l(unsigned int c, _locale_t locale)
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}
532
533/*********************************************************************
534 * _mbctoupper(MSVCRT.@)
535 */
536unsigned int CDECL _mbctoupper(unsigned int c)
537{
538 return _mbctoupper_l(c, NULL);
539}
540
541/*********************************************************************
542 * _mbctombb_l (MSVCRT.@)
543 */
544unsigned int CDECL _mbctombb_l(unsigned int c, _locale_t locale)
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}
574
575/*********************************************************************
576 * _mbctombb (MSVCRT.@)
577 */
578unsigned int CDECL _mbctombb(unsigned int c)
579{
580 return _mbctombb_l(c, NULL);
581}
582
583/*********************************************************************
584 * _mbcjistojms_l(MSVCRT.@)
585 *
586 * Converts a jis character to sjis.
587 * Based on description from
588 * http://www.slayers.ne.jp/~oouchi/code/jistosjis.html
589 */
590unsigned int CDECL _mbcjistojms_l(unsigned int c, _locale_t locale)
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}
625
626/*********************************************************************
627 * _mbcjistojms(MSVCRT.@)
628 */
629unsigned int CDECL _mbcjistojms(unsigned int c)
630{
631 return _mbcjistojms_l(c, NULL);
632}
633
634/*********************************************************************
635 * _mbcjmstojis_l(MSVCRT.@)
636 *
637 * Converts a sjis character to jis.
638 */
639unsigned int CDECL _mbcjmstojis_l(unsigned int c, _locale_t locale)
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}
673
674/*********************************************************************
675 * _mbcjmstojis(MSVCRT.@)
676 */
677unsigned int CDECL _mbcjmstojis(unsigned int c)
678{
679 return _mbcjmstojis_l(c, NULL);
680}
681
682/*********************************************************************
683 * _mbclen_l(MSVCRT.@)
684 */
685size_t CDECL _mbclen_l(const unsigned char* str, _locale_t locale)
686{
687 return _ismbblead_l(*str, locale) && str[1] ? 2 : 1;
688}
689
690/*********************************************************************
691 * _mbclen(MSVCRT.@)
692 */
693size_t CDECL _mbclen(const unsigned char* str)
694{
695 return _mbclen_l(str, NULL);
696}
697
698/*********************************************************************
699 * _mbsinc_l(MSVCRT.@)
700 */
701unsigned char* CDECL _mbsinc_l(const unsigned char* str, _locale_t locale)
702{
703 return (unsigned char *)(str + _mbclen_l(str, locale));
704}
705
706/*********************************************************************
707 * _mbsinc(MSVCRT.@)
708 */
709unsigned char* CDECL _mbsinc(const unsigned char* str)
710{
711 return _mbsinc_l(str, NULL);
712}
713
714/*********************************************************************
715 * _mbsninc(MSVCRT.@)
716 */
717unsigned char* CDECL _mbsninc(const unsigned char* str, size_t num)
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}
736
737/*********************************************************************
738 * _mbsnlen_l(MSVCRT.@)
739 */
740size_t CDECL _mbsnlen_l(const unsigned char *str,
741 size_t maxsize, _locale_t locale)
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}
767
768/*********************************************************************
769 * _mbslen(MSVCRT.@)
770 */
771size_t CDECL _mbslen(const unsigned char* str)
772{
773 return _mbsnlen_l(str, -1, NULL);
774}
775
776/*********************************************************************
777 * _mbslen_l(MSVCRT.@)
778 */
779size_t CDECL _mbslen_l(const unsigned char* str, _locale_t locale)
780{
781 return _mbsnlen_l(str, -1, locale);
782}
783
784/*********************************************************************
785 * _mbsnlen(MSVCRT.@)
786 */
787size_t CDECL _mbsnlen(const unsigned char* str, size_t maxsize)
788{
789 return _mbsnlen_l(str, maxsize, NULL);
790}
791
792/*********************************************************************
793 * _mbccpy_s_l(MSVCRT.@)
794 */
795int CDECL _mbccpy_s_l(unsigned char* dest, size_t maxsize,
796 int *copied, const unsigned char* src, _locale_t locale)
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}
825
826/*********************************************************************
827 * _mbccpy(MSVCRT.@)
828 */
829void CDECL _mbccpy(unsigned char* dest, const unsigned char* src)
830{
832}
833
834/*********************************************************************
835 * _mbccpy_l(MSVCRT.@)
836 */
837void CDECL _mbccpy_l(unsigned char* dest, const unsigned char* src,
839{
841}
842
843/*********************************************************************
844 * _mbccpy_s(MSVCRT.@)
845 */
846int CDECL _mbccpy_s(unsigned char* dest, size_t maxsize,
847 int *copied, const unsigned char* src)
848{
849 return _mbccpy_s_l(dest, maxsize, copied, src, NULL);
850}
851
852
853/*********************************************************************
854 * _mbsncpy_l(MSVCRT.@)
855 * REMARKS
856 * The parameter n is the number or characters to copy, not the size of
857 * the buffer. Use _mbsnbcpy_l for a function analogical to strncpy
858 */
859unsigned char* CDECL _mbsncpy_l(unsigned char* dst, const unsigned char* src, size_t n, _locale_t locale)
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}
902
903#if _MSVCR_VER>=80
904errno_t CDECL _mbsncpy_s_l(unsigned char* dst, size_t maxsize, const unsigned char* src, size_t n, _locale_t locale)
905{
906 BOOL truncate = (n == _TRUNCATE);
907 unsigned char *start = dst, *last;
908 pthreadmbcinfo mbcinfo;
909 unsigned int curlen;
910
911 if (!dst && !maxsize && !n)
912 return 0;
913
914 if (!MSVCRT_CHECK_PMT(dst != NULL)) return EINVAL;
915 if (!MSVCRT_CHECK_PMT(maxsize != 0)) return EINVAL;
916 if (!MSVCRT_CHECK_PMT(src != NULL))
917 {
918 *start = 0;
919 return EINVAL;
920 }
921
922 if (!n)
923 {
924 *start = 0;
925 return 0;
926 }
927
928 if (locale)
929 mbcinfo = locale->mbcinfo;
930 else
931 mbcinfo = get_mbcinfo();
932
933 curlen = 0;
934 last = dst;
935 while (*src && n && maxsize)
936 {
937 if (curlen)
938 {
939 --maxsize;
940 *dst++ = *src++;
941 if (!--curlen) --n;
942 continue;
943 }
944 last = dst;
945 if (!(mbcinfo->ismbcodepage && _ismbblead_l(*src, locale)))
946 {
947 curlen = 1;
948 continue;
949 }
950 curlen = 2;
951 if (!truncate && maxsize <= curlen) maxsize = 0;
952 }
953
954 if (!maxsize && truncate)
955 {
956 *last = 0;
957 return STRUNCATE;
958 }
959 if (!truncate && curlen && !src[curlen - 1])
960 {
961 *_errno() = EILSEQ;
962 *start = 0;
963 return EILSEQ;
964 }
965 if (!maxsize)
966 {
967 *start = 0;
969 }
970 *dst = 0;
971 return 0;
972}
973
974errno_t CDECL _mbsncpy_s(unsigned char* dst, size_t maxsize, const unsigned char* src, size_t n)
975{
976 return _mbsncpy_s_l(dst, maxsize, src, n, NULL);
977}
978#endif
979
980/*********************************************************************
981 * _mbsncpy(MSVCRT.@)
982 * REMARKS
983 * The parameter n is the number or characters to copy, not the size of
984 * the buffer. Use _mbsnbcpy for a function analogical to strncpy
985 */
986unsigned char* CDECL _mbsncpy(unsigned char* dst, const unsigned char* src, size_t n)
987{
988 return _mbsncpy_l(dst, src, n, NULL);
989}
990
991/*********************************************************************
992 * _mbsnbcpy_s_l(MSVCRT.@)
993 * REMARKS
994 * Unlike _mbsnbcpy this function does not pad the rest of the dest
995 * string with 0
996 */
997int CDECL _mbsnbcpy_s_l(unsigned char* dst, size_t size,
998 const unsigned char* src, size_t n, _locale_t locale)
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}
1056
1057/*********************************************************************
1058 * _mbsnbcpy_s(MSVCRT.@)
1059 */
1060int CDECL _mbsnbcpy_s(unsigned char* dst, size_t size, const unsigned char* src, size_t n)
1061{
1062 return _mbsnbcpy_s_l(dst, size, src, n, NULL);
1063}
1064
1065/*********************************************************************
1066 * _mbscpy_s_l(MSVCRT.@)
1067 */
1068int CDECL _mbscpy_s_l(unsigned char *dst, size_t size,
1069 const unsigned char *src, _locale_t locale)
1070{
1071 return _mbsnbcpy_s_l(dst, size, src, -1, locale);
1072}
1073
1074/*********************************************************************
1075 * _mbscpy_s(MSVCRT.@)
1076 */
1077int CDECL _mbscpy_s(unsigned char *dst, size_t size, const unsigned char *src)
1078{
1079 return _mbscpy_s_l(dst, size, src, NULL);
1080}
1081
1082/*********************************************************************
1083 * _mbsnbcpy_l(MSVCRT.@)
1084 * REMARKS
1085 * Like strncpy this function doesn't enforce the string to be
1086 * NUL-terminated
1087 */
1088unsigned char* CDECL _mbsnbcpy_l(unsigned char* dst, const unsigned char* src, size_t n, _locale_t locale)
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}
1125
1126/*********************************************************************
1127 * _mbsnbcpy(MSVCRT.@)
1128 * REMARKS
1129 * Like strncpy this function doesn't enforce the string to be
1130 * NUL-terminated
1131 */
1132unsigned char* CDECL _mbsnbcpy(unsigned char* dst, const unsigned char* src, size_t n)
1133{
1134 return _mbsnbcpy_l(dst, src, n, NULL);
1135}
1136
1137/*********************************************************************
1138 * _mbscmp_l(MSVCRT.@)
1139 */
1140int CDECL _mbscmp_l(const unsigned char* str, const unsigned char* cmp, _locale_t locale)
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}
1167
1168/*********************************************************************
1169 * _mbscmp(MSVCRT.@)
1170 */
1171int CDECL _mbscmp(const unsigned char* str, const unsigned char* cmp)
1172{
1173 return _mbscmp_l(str, cmp, NULL);
1174}
1175
1176/*********************************************************************
1177 * _mbsnbicoll_l(MSVCRT.@)
1178 */
1179int CDECL _mbsnbicoll_l(const unsigned char *str1, const unsigned char *str2, size_t len, _locale_t locale)
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}
1194
1195/*********************************************************************
1196 * _mbsicoll_l(MSVCRT.@)
1197 */
1198int CDECL _mbsicoll_l(const unsigned char *str1, const unsigned char *str2, _locale_t locale)
1199{
1201}
1202
1203/*********************************************************************
1204 * _mbsnbicoll(MSVCRT.@)
1205 */
1206int CDECL _mbsnbicoll(const unsigned char *str1, const unsigned char *str2, size_t len)
1207{
1208 return _mbsnbicoll_l(str1, str2, len, NULL);
1209}
1210
1211/*********************************************************************
1212 * _mbsicoll(MSVCRT.@)
1213 */
1214int CDECL _mbsicoll(const unsigned char* str, const unsigned char* cmp)
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}
1223
1224/*********************************************************************
1225 * _mbsnbcoll_l(MSVCRT.@)
1226 */
1227int CDECL _mbsnbcoll_l(const unsigned char *str1, const unsigned char *str2, size_t len, _locale_t locale)
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}
1242
1243/*********************************************************************
1244 * _mbscoll_l(MSVCRT.@)
1245 */
1246int CDECL _mbscoll_l(const unsigned char *str1, const unsigned char *str2, _locale_t locale)
1247{
1248 return _mbsnbcoll_l(str1, str2, INT_MAX, locale);
1249}
1250
1251/*********************************************************************
1252 * _mbsnbcoll(MSVCRT.@)
1253 */
1254int CDECL _mbsnbcoll(const unsigned char *str1, const unsigned char *str2, size_t len)
1255{
1256 return _mbsnbcoll_l(str1, str2, len, NULL);
1257}
1258
1259/*********************************************************************
1260 * _mbscoll(MSVCRT.@)
1261 */
1262int CDECL _mbscoll(const unsigned char* str, const unsigned char* cmp)
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}
1271
1272/*********************************************************************
1273 * _mbsicmp_l(MSVCRT.@)
1274 */
1275int CDECL _mbsicmp_l(const unsigned char* str, const unsigned char* cmp, _locale_t locale)
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}
1304
1305/*********************************************************************
1306 * _mbsicmp(MSVCRT.@)
1307 */
1308int CDECL _mbsicmp(const unsigned char* str, const unsigned char* cmp)
1309{
1310 return _mbsicmp_l(str, cmp, NULL);
1311}
1312
1313/*********************************************************************
1314 * _mbsncmp_l(MSVCRT.@)
1315 */
1316int CDECL _mbsncmp_l(const unsigned char* str, const unsigned char* cmp,
1317 size_t len, _locale_t locale)
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}
1354
1355/*********************************************************************
1356 * _mbsncmp(MSVCRT.@)
1357 */
1358int CDECL _mbsncmp(const unsigned char* str, const unsigned char* cmp, size_t len)
1359{
1360 return _mbsncmp_l(str, cmp, len, NULL);
1361}
1362
1363/*********************************************************************
1364 * _mbsnbcmp_l(MSVCRT.@)
1365 */
1366int CDECL _mbsnbcmp_l(const unsigned char* str, const unsigned char* cmp, size_t len, _locale_t locale)
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}
1415
1416/*********************************************************************
1417 * _mbsnbcmp(MSVCRT.@)
1418 */
1419int CDECL _mbsnbcmp(const unsigned char* str, const unsigned char* cmp, size_t len)
1420{
1421 return _mbsnbcmp_l(str, cmp, len, NULL);
1422}
1423
1424/*********************************************************************
1425 * _mbsnicmp(MSVCRT.@)
1426 *
1427 * Compare two multibyte strings case insensitively to 'len' characters.
1428 */
1429int CDECL _mbsnicmp_l(const unsigned char* str, const unsigned char* cmp, size_t len, _locale_t locale)
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}
1463
1464/*********************************************************************
1465 * _mbsnicmp(MSVCRT.@)
1466 *
1467 * Compare two multibyte strings case insensitively to 'len' characters.
1468 */
1469int CDECL _mbsnicmp(const unsigned char* str, const unsigned char* cmp, size_t len)
1470{
1471 return _mbsnicmp_l(str, cmp, len, NULL);
1472}
1473
1474/*********************************************************************
1475 * _mbsnbicmp_l(MSVCRT.@)
1476 */
1477int CDECL _mbsnbicmp_l(const unsigned char* str, const unsigned char* cmp, size_t len, _locale_t locale)
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}
1528
1529/*********************************************************************
1530 * _mbsnbicmp(MSVCRT.@)
1531 */
1532int CDECL _mbsnbicmp(const unsigned char* str, const unsigned char* cmp, size_t len)
1533{
1534 return _mbsnbicmp_l(str, cmp, len, NULL);
1535}
1536
1537/*********************************************************************
1538 * _mbscat (MSVCRT.@)
1539 */
1540unsigned char * CDECL _mbscat( unsigned char *dst, const unsigned char *src )
1541{
1542 strcat( (char *)dst, (const char *)src );
1543 return dst;
1544}
1545
1546/*********************************************************************
1547 * _mbscat_s_l (MSVCRT.@)
1548 */
1549int CDECL _mbscat_s_l( unsigned char *dst, size_t size,
1550 const unsigned char *src, _locale_t locale )
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}
1587
1588/*********************************************************************
1589 * _mbscat_s (MSVCRT.@)
1590 */
1591int CDECL _mbscat_s( unsigned char *dst, size_t size, const unsigned char *src )
1592{
1593 return _mbscat_s_l(dst, size, src, NULL);
1594}
1595
1596/*********************************************************************
1597 * _mbscpy (MSVCRT.@)
1598 */
1599unsigned char* CDECL _mbscpy( unsigned char *dst, const unsigned char *src )
1600{
1601 strcpy( (char *)dst, (const char *)src );
1602 return dst;
1603}
1604
1605/*********************************************************************
1606 * _mbsstr (MSVCRT.@)
1607 */
1608unsigned char * CDECL _mbsstr(const unsigned char *haystack, const unsigned char *needle)
1609{
1610 return (unsigned char *)strstr( (const char *)haystack, (const char *)needle );
1611}
1612
1613/*********************************************************************
1614 * _mbschr_l(MSVCRT.@)
1615 */
1616unsigned char* CDECL _mbschr_l(const unsigned char* s, unsigned int x, _locale_t locale)
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}
1642
1643/*********************************************************************
1644 * _mbschr(MSVCRT.@)
1645 */
1646unsigned char* CDECL _mbschr(const unsigned char* s, unsigned int x)
1647{
1648 return _mbschr_l(s, x, NULL);
1649}
1650
1651/*********************************************************************
1652 * _mbsrchr_l(MSVCRT.@)
1653 */
1654unsigned char* CDECL _mbsrchr_l(const unsigned char *s, unsigned int x, _locale_t locale)
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}
1683
1684/*********************************************************************
1685 * _mbsrchr(MSVCRT.@)
1686 */
1687unsigned char* CDECL _mbsrchr(const unsigned char* s, unsigned int x)
1688{
1689 return _mbsrchr_l(s, x, NULL);
1690}
1691
1692/*********************************************************************
1693 * _mbstok_s_l(MSVCRT.@)
1694 */
1695unsigned char* CDECL _mbstok_s_l(unsigned char *str, const unsigned char *delim,
1696 unsigned char **ctx, _locale_t locale)
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}
1735
1736
1737/*********************************************************************
1738 * _mbstok_s(MSVCRT.@)
1739 */
1740unsigned char* CDECL _mbstok_s(unsigned char *str,
1741 const unsigned char *delim, unsigned char **ctx)
1742{
1743 return _mbstok_s_l(str, delim, ctx, NULL);
1744}
1745
1746/*********************************************************************
1747 * _mbstok_l(MSVCRT.@)
1748 */
1749unsigned char* CDECL _mbstok_l(unsigned char *str,
1750 const unsigned char *delim, _locale_t locale)
1751{
1752 return _mbstok_s_l(str, delim, &msvcrt_get_thread_data()->mbstok_next, locale);
1753}
1754
1755/*********************************************************************
1756 * _mbstok(MSVCRT.@)
1757 */
1758unsigned char* CDECL _mbstok(unsigned char *str, const unsigned char *delim)
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}
1769
1770/*********************************************************************
1771 * _mbbtombc_l(MSVCRT.@)
1772 */
1773unsigned int CDECL _mbbtombc_l(unsigned int c, _locale_t locale)
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}
1799
1800/*********************************************************************
1801 * _mbbtombc(MSVCRT.@)
1802 */
1803unsigned int CDECL _mbbtombc(unsigned int c)
1804{
1805 return _mbbtombc_l(c, NULL);
1806}
1807
1808/*********************************************************************
1809 * _ismbbkana_l(MSVCRT.@)
1810 */
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}
1827
1828/*********************************************************************
1829 * _ismbbkana(MSVCRT.@)
1830 */
1831int CDECL _ismbbkana(unsigned int c)
1832{
1833 return _ismbbkana_l( c, NULL );
1834}
1835
1836/*********************************************************************
1837 * _ismbcdigit_l(MSVCRT.@)
1838 */
1840{
1842}
1843
1844/*********************************************************************
1845 * _ismbcdigit(MSVCRT.@)
1846 */
1847int CDECL _ismbcdigit(unsigned int ch)
1848{
1849 return _ismbcdigit_l( ch, NULL );
1850}
1851
1852/*********************************************************************
1853 * _ismbcgraph_l(MSVCRT.@)
1854 */
1856{
1858}
1859
1860/*********************************************************************
1861 * _ismbcgraph(MSVCRT.@)
1862 */
1863int CDECL _ismbcgraph(unsigned int ch)
1864{
1865 return _ismbcgraph_l( ch, NULL );
1866}
1867
1868/*********************************************************************
1869 * _ismbcalpha_l (MSVCRT.@)
1870 */
1872{
1874}
1875
1876/*********************************************************************
1877 * _ismbcalpha (MSVCRT.@)
1878 */
1879int CDECL _ismbcalpha(unsigned int ch)
1880{
1881 return _ismbcalpha_l( ch, NULL );
1882}
1883
1884/*********************************************************************
1885 * _ismbclower_l (MSVCRT.@)
1886 */
1888{
1890}
1891
1892/*********************************************************************
1893 * _ismbclower (MSVCRT.@)
1894 */
1895int CDECL _ismbclower(unsigned int ch)
1896{
1897 return _ismbclower_l( ch, NULL );
1898}
1899
1900/*********************************************************************
1901 * _ismbcupper_l (MSVCRT.@)
1902 */
1904{
1906}
1907
1908/*********************************************************************
1909 * _ismbcupper (MSVCRT.@)
1910 */
1911int CDECL _ismbcupper(unsigned int ch)
1912{
1913 return _ismbcupper_l( ch, NULL );
1914}
1915
1916/*********************************************************************
1917 * _ismbcsymbol_l(MSVCRT.@)
1918 */
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}
1930
1931/*********************************************************************
1932 * _ismbcsymbol(MSVCRT.@)
1933 */
1934int CDECL _ismbcsymbol(unsigned int ch)
1935{
1936 return _ismbcsymbol_l(ch, NULL);
1937}
1938
1939/*********************************************************************
1940 * _ismbcalnum_l (MSVCRT.@)
1941 */
1943{
1945}
1946
1947/*********************************************************************
1948 * _ismbcalnum (MSVCRT.@)
1949 */
1950int CDECL _ismbcalnum(unsigned int ch)
1951{
1952 return _ismbcalnum_l( ch, NULL );
1953}
1954
1955/*********************************************************************
1956 * _ismbcspace_l (MSVCRT.@)
1957 */
1959{
1961}
1962
1963/*********************************************************************
1964 * _ismbcspace (MSVCRT.@)
1965 */
1966int CDECL _ismbcspace(unsigned int ch)
1967{
1968 return _ismbcspace_l( ch, NULL );
1969}
1970
1971/*********************************************************************
1972 * _ismbcprint_l (MSVCRT.@)
1973 */
1975{
1977}
1978
1979/*********************************************************************
1980 * _ismbcprint (MSVCRT.@)
1981 */
1982int CDECL _ismbcprint(unsigned int ch)
1983{
1984 return _ismbcprint_l( ch, NULL );
1985}
1986
1987/*********************************************************************
1988 * _ismbcpunct_l (MSVCRT.@)
1989 */
1991{
1993}
1994
1995/*********************************************************************
1996 * _ismbcpunct(MSVCRT.@)
1997 */
1998int CDECL _ismbcpunct(unsigned int ch)
1999{
2000 return _ismbcpunct_l( ch, NULL );
2001}
2002
2003/*********************************************************************
2004 * _ismbchira_l(MSVCRT.@)
2005 */
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}
2022
2023/*********************************************************************
2024 * _ismbchira(MSVCRT.@)
2025 */
2026int CDECL _ismbchira(unsigned int c)
2027{
2028 return _ismbchira_l(c, NULL);
2029}
2030
2031/*********************************************************************
2032 * _ismbckata_l(MSVCRT.@)
2033 */
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}
2050
2051/*********************************************************************
2052 * _ismbckata(MSVCRT.@)
2053 */
2054int CDECL _ismbckata(unsigned int c)
2055{
2056 return _ismbckata_l(c, NULL);
2057}
2058
2059/*********************************************************************
2060 * _ismbblead_l(MSVCRT.@)
2061 */
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}
2073
2074/*********************************************************************
2075 * _ismbblead(MSVCRT.@)
2076 */
2077int CDECL _ismbblead(unsigned int c)
2078{
2079 return _ismbblead_l(c, NULL);
2080}
2081
2082/*********************************************************************
2083 * _ismbbtrail_l(MSVCRT.@)
2084 */
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}
2096
2097/*********************************************************************
2098 * _ismbbtrail(MSVCRT.@)
2099 */
2100int CDECL _ismbbtrail(unsigned int c)
2101{
2102 return _ismbbtrail_l(c, NULL);
2103}
2104
2105/*********************************************************************
2106 * _ismbclegal_l(MSVCRT.@)
2107 */
2109{
2111}
2112
2113/*********************************************************************
2114 * _ismbclegal(MSVCRT.@)
2115 */
2116int CDECL _ismbclegal(unsigned int c)
2117{
2118 return _ismbclegal_l(c, NULL);
2119}
2120
2121/*********************************************************************
2122 * _ismbslead_l(MSVCRT.@)
2123 */
2124int CDECL _ismbslead_l(const unsigned char* start, const unsigned char* str, _locale_t locale)
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}
2152
2153/*********************************************************************
2154 * _ismbslead(MSVCRT.@)
2155 */
2156int CDECL _ismbslead(const unsigned char* start, const unsigned char* str)
2157{
2158 return _ismbslead_l(start, str, NULL);
2159}
2160
2161/*********************************************************************
2162 * _ismbstrail_l(MSVCRT.@)
2163 */
2164int CDECL _ismbstrail_l(const unsigned char* start, const unsigned char* str, _locale_t locale)
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}
2175
2176/*********************************************************************
2177 * _ismbstrail(MSVCRT.@)
2178 */
2179int CDECL _ismbstrail(const unsigned char* start, const unsigned char* str)
2180{
2181 return _ismbstrail_l(start, str, NULL);
2182}
2183
2184/*********************************************************************
2185 * _mbsdec_l(MSVCRT.@)
2186 */
2187unsigned char* CDECL _mbsdec_l(const unsigned char *start,
2188 const unsigned char *cur, _locale_t locale)
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}
2207
2208/*********************************************************************
2209 * _mbsdec(MSVCRT.@)
2210 */
2211unsigned char* CDECL _mbsdec(const unsigned char *start, const unsigned char *cur)
2212{
2213 return _mbsdec_l(start, cur, NULL);
2214}
2215
2216
2217/*********************************************************************
2218 * _mbbtype_l(MSVCRT.@)
2219 */
2220int CDECL _mbbtype_l(unsigned char c, int type, _locale_t locale)
2221{
2222 if (type == 1)
2224 else
2225 return _ismbblead_l(c, locale) ? _MBC_LEAD
2227}
2228
2229/*********************************************************************
2230 * _mbbtype(MSVCRT.@)
2231 */
2232int CDECL _mbbtype(unsigned char c, int type)
2233{
2234 return _mbbtype_l(c, type, NULL);
2235}
2236
2237/*********************************************************************
2238 * _mbsbtype_l (MSVCRT.@)
2239 */
2240int CDECL _mbsbtype_l(const unsigned char *str, size_t count, _locale_t locale)
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}
2280
2281/*********************************************************************
2282 * _mbsbtype (MSVCRT.@)
2283 */
2284int CDECL _mbsbtype(const unsigned char *str, size_t count)
2285{
2286 return _mbsbtype_l(str, count, NULL);
2287}
2288
2289
2290/*********************************************************************
2291 * _mbsset_l(MSVCRT.@)
2292 */
2293unsigned char* CDECL _mbsset_l(unsigned char* str, unsigned int c, _locale_t locale)
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}
2321
2322/*********************************************************************
2323 * _mbsset(MSVCRT.@)
2324 */
2325unsigned char* CDECL _mbsset(unsigned char* str, unsigned int c)
2326{
2327 return _mbsset_l(str, c, NULL);
2328}
2329
2330/*********************************************************************
2331 * _mbsnbset_l(MSVCRT.@)
2332 */
2333unsigned char* CDECL _mbsnbset_l(unsigned char *str, unsigned int c, size_t len, _locale_t locale)
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}
2368
2369/*********************************************************************
2370 * _mbsnbset(MSVCRT.@)
2371 */
2372unsigned char* CDECL _mbsnbset(unsigned char *str, unsigned int c, size_t len)
2373{
2374 return _mbsnbset_l(str, c, len, NULL);
2375}
2376
2377/*********************************************************************
2378 * _mbsnset(MSVCRT.@)
2379 */
2380unsigned char* CDECL _mbsnset_l(unsigned char* str, unsigned int c, size_t len, _locale_t locale)
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}
2410
2411/*********************************************************************
2412 * _mbsnset(MSVCRT.@)
2413 */
2414unsigned char* CDECL _mbsnset(unsigned char* str, unsigned int c, size_t len)
2415{
2416 return _mbsnset_l(str, c, len, NULL);
2417}
2418
2419/*********************************************************************
2420 * _mbsnccnt_l(MSVCRT.@)
2421 * 'c' is for 'character'.
2422 */
2423size_t CDECL _mbsnccnt_l(const unsigned char* str, size_t len, _locale_t locale)
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}
2458
2459/*********************************************************************
2460 * _mbsnccnt(MSVCRT.@)
2461 * 'c' is for 'character'.
2462 */
2463size_t CDECL _mbsnccnt(const unsigned char* str, size_t len)
2464{
2465 return _mbsnccnt_l(str, len, NULL);
2466}
2467
2468/*********************************************************************
2469 * _mbsnbcnt_l(MSVCRT.@)
2470 * 'b' is for byte count.
2471 */
2472size_t CDECL _mbsnbcnt_l(const unsigned char* str, size_t len, _locale_t locale)
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}
2499
2500/*********************************************************************
2501 * _mbsnbcnt(MSVCRT.@)
2502 * 'b' is for byte count.
2503 */
2504size_t CDECL _mbsnbcnt(const unsigned char* str, size_t len)
2505{
2506 return _mbsnbcnt_l(str, len, NULL);
2507}
2508
2509/*********************************************************************
2510 * _mbsnbcat_l(MSVCRT.@)
2511 */
2512unsigned char* CDECL _mbsnbcat_l(unsigned char *dst, const unsigned char *src, size_t len, _locale_t locale)
2513{
2514 pthreadmbcinfo mbcinfo;
2515
2516#ifdef __REACTOS__
2517 if (!len)
2518 return dst;
2519#endif
2520
2521 if (!MSVCRT_CHECK_PMT(dst && src))
2522 return NULL;
2523
2524 if (locale)
2525 mbcinfo = locale->mbcinfo;
2526 else
2527 mbcinfo = get_mbcinfo();
2528
2529 if (mbcinfo->ismbcodepage)
2530 {
2531 unsigned char *res = dst;
2532
2533 while (*dst)
2534 {
2535 if (_ismbblead_l(*dst++, locale))
2536 {
2537 if (*dst)
2538 {
2539 dst++;
2540 }
2541 else
2542 {
2543 /* as per msdn overwrite the lead byte in front of '\0' */
2544 dst--;
2545 break;
2546 }
2547 }
2548 }
2549 while (*src && len--) *dst++ = *src++;
2550 *dst = '\0';
2551 return res;
2552 }
2553 return u_strncat(dst, src, len); /* ASCII CP */
2554}
2555
2556/*********************************************************************
2557 * _mbsnbcat(MSVCRT.@)
2558 */
2559unsigned char* CDECL _mbsnbcat(unsigned char *dst, const unsigned char *src, size_t len)
2560{
2561 return _mbsnbcat_l(dst, src, len, NULL);
2562}
2563
2564/*********************************************************************
2565 * _mbsnbcat_s_l(MSVCRT.@)
2566 */
2567int CDECL _mbsnbcat_s_l(unsigned char *dst, size_t size, const unsigned char *src, size_t len, _locale_t locale)
2568{
2569 unsigned char *ptr = dst;
2570 size_t i;
2571 pthreadmbcinfo mbcinfo;
2572
2573 if (!dst && !size && !len)
2574 return 0;
2575
2576 if (!MSVCRT_CHECK_PMT(dst && size && src))
2577 {
2578 if (dst && size)
2579 *dst = '\0';
2580 return EINVAL;
2581 }
2582
2583 /* Find the null terminator of the destination buffer. */
2584 while (size && *ptr)
2585 size--, ptr++;
2586
2587 if (!size)
2588 {
2589 *dst = '\0';
2590 *_errno() = EINVAL;
2591 return EINVAL;
2592 }
2593
2594 if (locale)
2595 mbcinfo = locale->mbcinfo;
2596 else
2597 mbcinfo = get_mbcinfo();
2598
2599 /* If necessary, check that the character preceding the null terminator is
2600 * a lead byte and move the pointer back by one for later overwrite. */
2601 if (ptr != dst && mbcinfo->ismbcodepage && _ismbblead_l(*(ptr - 1), locale))
2602 size++, ptr--;
2603
2604 for (i = 0; *src && i < len; i++)
2605 {
2606 *ptr++ = *src++;
2607 size--;
2608
2609 if (!size)
2610 {
2611 *dst = '\0';
2612 *_errno() = ERANGE;
2613 return ERANGE;
2614 }
2615 }
2616
2617 *ptr = '\0';
2618 return 0;
2619}
2620
2621/*********************************************************************
2622 * _mbsnbcat_s(MSVCRT.@)
2623 */
2624int CDECL _mbsnbcat_s(unsigned char *dst, size_t size, const unsigned char *src, size_t len)
2625{
2626 return _mbsnbcat_s_l(dst, size, src, len, NULL);
2627}
2628
2629/*********************************************************************
2630 * _mbsncat_l(MSVCRT.@)
2631 */
2632unsigned char* CDECL _mbsncat_l(unsigned char* dst, const unsigned char* src, size_t len, _locale_t locale)
2633{
2634 pthreadmbcinfo mbcinfo;
2635
2636 if (!len)
2637 return dst;
2638
2639 if (!MSVCRT_CHECK_PMT(dst && src))
2640 return NULL;
2641
2642 if (locale)
2643 mbcinfo = locale->mbcinfo;
2644 else
2645 mbcinfo = get_mbcinfo();
2646
2647 if (mbcinfo->ismbcodepage)
2648 {
2649 unsigned char *res = dst;
2650 while (*dst)
2651 {
2652 if (_ismbblead_l(*dst++, locale))
2653 dst++;
2654 }
2655 while (*src && len--)
2656 {
2657 *dst++ = *src;
2658 if (_ismbblead_l(*src++, locale))
2659 *dst++ = *src++;
2660 }
2661 *dst = '\0';
2662 return res;
2663 }
2664 return u_strncat(dst, src, len); /* ASCII CP */
2665}
2666
2667/*********************************************************************
2668 * _mbsncat(MSVCRT.@)
2669 */
2670unsigned char* CDECL _mbsncat(unsigned char* dst, const unsigned char* src, size_t len)
2671{
2672 return _mbsncat_l(dst, src, len, NULL);
2673}
2674
2675/*********************************************************************
2676 * _mbslwr_l(MSVCRT.@)
2677 */
2678unsigned char* CDECL _mbslwr_l(unsigned char *s, _locale_t locale)
2679{
2680 pthreadmbcinfo mbcinfo;
2681 unsigned char *ret = s;
2682
2683 if (!s)
2684 return NULL;
2685
2686 if (locale)
2687 mbcinfo = locale->mbcinfo;
2688 else
2689 mbcinfo = get_mbcinfo();
2690
2691 if (mbcinfo->ismbcodepage)
2692 {
2693 unsigned int c;
2694
2695 while (*s)
2696 {
2698 /* Note that I assume that the size of the character is unchanged */
2699 if (c > 255)
2700 {
2701 *s++ = (c >> 8);
2702 c = c & 0xff;
2703 }
2704 *s++ = c;
2705 }
2706 }
2707 else
2708 {
2709 for ( ; *s; s++) *s = _tolower_l(*s, locale);
2710 }
2711 return ret;
2712}
2713
2714/*********************************************************************
2715 * _mbslwr(MSVCRT.@)
2716 */
2717unsigned char* CDECL _mbslwr(unsigned char *s)
2718{
2719 return _mbslwr_l(s, NULL);
2720}
2721
2722/*********************************************************************
2723 * _mbslwr_s_l(MSVCRT.@)
2724 */
2725int CDECL _mbslwr_s_l(unsigned char* s, size_t len, _locale_t locale)
2726{
2727 unsigned char *p = s;
2728 pthreadmbcinfo mbcinfo;
2729
2730 if (!s && !len)
2731 return 0;
2732 if (!MSVCRT_CHECK_PMT(s && len))
2733 return EINVAL;
2734
2735 if (locale)
2736 mbcinfo = locale->mbcinfo;
2737 else
2738 mbcinfo = get_mbcinfo();
2739
2740 if (mbcinfo->ismbcodepage)
2741 {
2742 unsigned int c;
2743 for ( ; *s && len > 0; len--)
2744 {
2746 /* Note that I assume that the size of the character is unchanged */
2747 if (c > 255)
2748 {
2749 *s++=(c>>8);
2750 c=c & 0xff;
2751 }
2752 *s++=c;
2753 }
2754 }
2755 else
2756 {
2757 for ( ; *s && len > 0; s++, len--)
2758 *s = _tolower_l(*s, locale);
2759 }
2760
2761 if (!MSVCRT_CHECK_PMT(len))
2762 {
2763 *p = 0;
2764 return EINVAL;
2765 }
2766 *s = 0;
2767 return 0;
2768}
2769
2770/*********************************************************************
2771 * _mbslwr_s(MSVCRT.@)
2772 */
2773int CDECL _mbslwr_s(unsigned char* str, size_t len)
2774{
2775 return _mbslwr_s_l(str, len, NULL);
2776}
2777
2778/*********************************************************************
2779 * _mbsupr_l(MSVCRT.@)
2780 */
2781unsigned char* CDECL _mbsupr_l(unsigned char* s, _locale_t locale)
2782{
2783 unsigned char *ret = s;
2784 pthreadmbcinfo mbcinfo;
2785
2786 if (!MSVCRT_CHECK_PMT(s))
2787 return NULL;
2788
2789 if (locale)
2790 mbcinfo = locale->mbcinfo;
2791 else
2792 mbcinfo = get_mbcinfo();
2793
2794 if (mbcinfo->ismbcodepage)
2795 {
2796 unsigned int c;
2797 while (*s)
2798 {
2800 /* Note that I assume that the size of the character is unchanged */
2801 if (c > 255)
2802 {
2803 *s++ = (c >> 8);
2804 c = c & 0xff;
2805 }
2806 *s++ = c;
2807 }
2808 }
2809 else
2810 for ( ; *s; s++) *s = _toupper_l(*s, locale);
2811 return ret;
2812}
2813
2814/*********************************************************************
2815 * _mbsupr(MSVCRT.@)
2816 */
2817unsigned char* CDECL _mbsupr(unsigned char* s)
2818{
2819 return _mbsupr_l(s, NULL);
2820}
2821
2822/*********************************************************************
2823 * _mbsupr_s_l(MSVCRT.@)
2824 */
2825int CDECL _mbsupr_s_l(unsigned char* s, size_t len, _locale_t locale)
2826{
2827 unsigned char *p = s;
2828
2829 if (!s && !len)
2830 return 0;
2831 if (!MSVCRT_CHECK_PMT(s && len))
2832 return EINVAL;
2833
2834 if (get_mbcinfo()->ismbcodepage)
2835 {
2836 unsigned int c;
2837 for ( ; *s && len > 0; len--)
2838 {
2840 /* Note that I assume that the size of the character is unchanged */
2841 if (c > 255)
2842 {
2843 *s++=(c>>8);
2844 c=c & 0xff;
2845 }
2846 *s++=c;
2847 }
2848 }
2849 else
2850 {
2851 for ( ; *s && len > 0; s++, len--)
2852 *s = _toupper_l(*s, locale);
2853 }
2854
2855 if (!MSVCRT_CHECK_PMT(len))
2856 {
2857 *p = 0;
2858 return EINVAL;
2859 }
2860 *s = 0;
2861 return 0;
2862}
2863
2864/*********************************************************************
2865 * _mbsupr_s(MSVCRT.@)
2866 */
2867int CDECL _mbsupr_s(unsigned char* s, size_t len)
2868{
2869 return _mbsupr_s_l(s, len, NULL);
2870}
2871
2872/*********************************************************************
2873 * _mbsspn_l (MSVCRT.@)
2874 */
2875size_t CDECL _mbsspn_l(const unsigned char* string,
2876 const unsigned char* set, _locale_t locale)
2877{
2878 const unsigned char *p, *q;
2879
2880 if (!MSVCRT_CHECK_PMT(string && set))
2881 return 0;
2882
2883 for (p = string; *p; p++)
2884 {
2885 for (q = set; *q; q++)
2886 {
2887 if (_ismbblead_l(*q, locale))
2888 {
2889 /* duplicate a bug in native implementation */
2890 if (!q[1]) break;
2891
2892 if (p[0] == q[0] && p[1] == q[1])
2893 {
2894 p++;
2895 break;
2896 }
2897 q++;
2898 }
2899 else
2900 {
2901 if (p[0] == q[0]) break;
2902 }
2903 }
2904 if (!*q) break;
2905 }
2906 return p - string;
2907}
2908
2909/*********************************************************************
2910 * _mbsspn (MSVCRT.@)
2911 */
2912size_t CDECL _mbsspn(const unsigned char* string, const unsigned char* set)
2913{
2914 return _mbsspn_l(string, set, NULL);
2915}
2916
2917/*********************************************************************
2918 * _mbsspnp_l (MSVCRT.@)
2919 */
2920unsigned char* CDECL _mbsspnp_l(const unsigned char* string, const unsigned char* set, _locale_t locale)
2921{
2922 if (!MSVCRT_CHECK_PMT(string && set))
2923 return 0;
2924
2925 string += _mbsspn_l(string, set, locale);
2926 return *string ? (unsigned char*)string : NULL;
2927}
2928
2929/*********************************************************************
2930 * _mbsspnp (MSVCRT.@)
2931 */
2932unsigned char* CDECL _mbsspnp(const unsigned char* string, const unsigned char* set)
2933{
2934 return _mbsspnp_l(string, set, NULL);
2935}
2936
2937/*********************************************************************
2938 * _mbscspn_l (MSVCRT.@)
2939 */
2940size_t CDECL _mbscspn_l(const unsigned char* str,
2941 const unsigned char* cmp, _locale_t locale)
2942{
2943 const unsigned char *p, *q;
2944
2945 for (p = str; *p; p++)
2946 {
2947 for (q = cmp; *q; q++)
2948 {
2949 if (_ismbblead_l(*q, locale))
2950 {
2951 /* duplicate a bug in native implementation */
2952 if (!q[1]) return 0;
2953
2954 if (p[0] == q[0] && p[1] == q[1])
2955 return p - str;
2956 q++;
2957 }
2958 else if (p[0] == q[0])
2959 return p - str;
2960 }
2961 }
2962 return p - str;
2963}
2964
2965/*********************************************************************
2966 * _mbscspn (MSVCRT.@)
2967 */
2968size_t CDECL _mbscspn(const unsigned char* str, const unsigned char* cmp)
2969{
2970 return _mbscspn_l(str, cmp, NULL);
2971}
2972
2973/*********************************************************************
2974 * _mbsrev_l (MSVCRT.@)
2975 */
2976unsigned char* CDECL _mbsrev_l(unsigned char* str, _locale_t locale)
2977{
2978 pthreadmbcinfo mbcinfo;
2979 unsigned char *p, tmp;
2980
2981 if (!MSVCRT_CHECK_PMT(str))
2982 return NULL;
2983
2984 if (locale)
2985 mbcinfo = locale->mbcinfo;
2986 else
2987 mbcinfo = get_mbcinfo();
2988
2989 if (!mbcinfo->ismbcodepage)
2990 return u__strrev(str);
2991
2992 for (p = str; *p; p++)
2993 {
2994 if (_ismbblead_l(*p, locale))
2995 {
2996 if (p[1])
2997 {
2998 tmp = p[0];
2999 p[0] = p[1];
3000 p[1] = tmp;
3001 p++;
3002 }
3003 else
3004 {
3005 /* drop trailing lead char */
3006 p[0] = 0;
3007 }
3008 }
3009 }
3010 return u__strrev(str);
3011}
3012
3013/*********************************************************************
3014 * _mbsrev (MSVCRT.@)
3015 */
3016unsigned char* CDECL _mbsrev(unsigned char* str)
3017{
3018 return _mbsrev_l(str, NULL);
3019}
3020
3021/*********************************************************************
3022 * _mbspbrk_l (MSVCRT.@)
3023 */
3024unsigned char* CDECL _mbspbrk_l(const unsigned char *str,
3025 const unsigned char *accept, _locale_t locale)
3026{
3027 const unsigned char* p;
3028 pthreadmbcinfo mbcinfo;
3029
3030 if (locale)
3031 mbcinfo = locale->mbcinfo;
3032 else
3033 mbcinfo = get_mbcinfo();
3034
3035 if (!mbcinfo->ismbcodepage)
3036 return u_strpbrk(str, accept);
3037
3038 if (!MSVCRT_CHECK_PMT(str && accept))
3039 return NULL;
3040
3041 while (*str)
3042 {
3043 for (p = accept; *p; p += (_ismbblead_l(*p, locale) ? 2 : 1))
3044 {
3045 if (*p == *str)
3046 if (!_ismbblead_l(*p, locale) || p[1] == str[1])
3047 return (unsigned char*)str;
3048 }
3049 str += (_ismbblead_l(*str, locale) ? 2 : 1);
3050 }
3051 return NULL;
3052}
3053
3054/*********************************************************************
3055 * _mbspbrk (MSVCRT.@)
3056 */
3057unsigned char* CDECL _mbspbrk(const unsigned char *str, const unsigned char *accept)
3058{
3059 return _mbspbrk_l(str, accept, NULL);
3060}
3061
3062/*
3063 * Functions depending on locale codepage
3064 */
3065
3066/*********************************************************************
3067 * _mblen_l(MSVCRT.@)
3068 * REMARKS
3069 * Unlike most of the multibyte string functions this function uses
3070 * the locale codepage, not the codepage set by _setmbcp
3071 */
3072int CDECL _mblen_l(const char* str, size_t size, _locale_t locale)
3073{
3075
3076 if (!str || !*str || !size)
3077 return 0;
3078
3079 if (locale)
3080 locinfo = locale->locinfo;
3081 else
3082 locinfo = get_locinfo();
3083
3084 if (locinfo->mb_cur_max == 1)
3085 return 1; /* ASCII CP */
3086 return !_isleadbyte_l((unsigned char)*str, locale) ? 1 : (size > 1 ? 2 : -1);
3087}
3088
3089/*********************************************************************
3090 * mblen(MSVCRT.@)
3091 */
3092int CDECL mblen(const char* str, size_t size)
3093{
3094 return _mblen_l(str, size, NULL);
3095}
3096
3097/*********************************************************************
3098 * mbrlen(MSVCRT.@)
3099 */
3100size_t CDECL mbrlen(const char *str, size_t len, mbstate_t *state)
3101{
3102 mbstate_t s = (state ? *state : 0);
3103 size_t ret;
3104
3105 if(!len || !str || !*str)
3106 return 0;
3107
3108 if(get_locinfo()->mb_cur_max == 1) {
3109 return 1;
3110 }else if(!s && isleadbyte((unsigned char)*str)) {
3111 if(len == 1) {
3112 s = (unsigned char)*str;
3113 ret = -2;
3114 }else {
3115 ret = 2;
3116 }
3117 }else if(!s) {
3118 ret = 1;
3119 }else {
3120 s = 0;
3121 ret = 2;
3122 }
3123
3124 if(state)
3125 *state = s;
3126 return ret;
3127}
3128
3129/*********************************************************************
3130 * _mbstrlen_l(MSVCRT.@)
3131 */
3133{
3135
3136 if(!locale)
3137 locinfo = get_locinfo();
3138 else
3139 locinfo = locale->locinfo;
3140
3141 if(locinfo->mb_cur_max > 1) {
3142 size_t len;
3144 str, -1, NULL, 0);
3145 if (!len) {
3146 *_errno() = EILSEQ;
3147 return -1;
3148 }
3149 return len - 1;
3150 }
3151
3152 return strlen(str);
3153}
3154
3155/*********************************************************************
3156 * _mbstrlen(MSVCRT.@)
3157 */
3158size_t CDECL _mbstrlen(const char* str)
3159{
3160 return _mbstrlen_l(str, NULL);
3161}
3162
3163/*********************************************************************
3164 * _mbtowc_l(MSVCRT.@)
3165 */
3166int CDECL _mbtowc_l(wchar_t *dst, const char* str, size_t n, _locale_t locale)
3167{
3169 wchar_t tmpdst;
3170
3171 if(!locale)
3172 locinfo = get_locinfo();
3173 else
3174 locinfo = locale->locinfo;
3175
3176 if(n <= 0 || !str)
3177 return 0;
3178
3179 if(!*str) {
3180 if(dst) *dst = 0;
3181 return 0;
3182 }
3183
3184 if(!locinfo->lc_codepage) {
3185 if(dst) *dst = (unsigned char)*str;
3186 return 1;
3187 }
3188 if(n>=2 && _isleadbyte_l((unsigned char)*str, locale)) {
3189 if(!MultiByteToWideChar(locinfo->lc_codepage, 0, str, 2, &tmpdst, 1))
3190 return -1;
3191 if(dst) *dst = tmpdst;
3192 return 2;
3193 }
3194 if(!MultiByteToWideChar(locinfo->lc_codepage, 0, str, 1, &tmpdst, 1))
3195 return -1;
3196 if(dst) *dst = tmpdst;
3197 return 1;
3198}
3199
3200/*********************************************************************
3201 * mbtowc(MSVCRT.@)
3202 */
3203int CDECL mbtowc(wchar_t *dst, const char* str, size_t n)
3204{
3205 return _mbtowc_l(dst, str, n, NULL);
3206}
3207
3208/*********************************************************************
3209 * btowc(MSVCRT.@)
3210 */
3212{
3213 unsigned char letter = c;
3214 wchar_t ret;
3215
3216 if(c == EOF)
3217 return WEOF;
3218 if(!get_locinfo()->lc_codepage)
3219 return c & 255;
3220 if(!MultiByteToWideChar(get_locinfo()->lc_codepage,
3221 MB_ERR_INVALID_CHARS, (LPCSTR)&letter, 1, &ret, 1))
3222 return WEOF;
3223
3224 return ret;
3225}
3226
3227/*********************************************************************
3228 * mbrtowc(MSVCRT.@)
3229 */
3230size_t CDECL mbrtowc(wchar_t *dst, const char *str,
3231 size_t n, mbstate_t *state)
3232{
3234 mbstate_t s = (state ? *state : 0);
3235 char tmpstr[2];
3236 int len = 0;
3237
3238 if(dst)
3239 *dst = 0;
3240
3241 if(!n || !str || !*str)
3242 return 0;
3243
3244 if(locinfo->mb_cur_max == 1) {
3245 tmpstr[len++] = *str;
3246 }else if(!s && isleadbyte((unsigned char)*str)) {
3247 if(n == 1) {
3248 s = (unsigned char)*str;
3249 len = -2;
3250 }else {
3251 tmpstr[0] = str[0];
3252 tmpstr[1] = str[1];
3253 len = 2;
3254 }
3255 }else if(!s) {
3256 tmpstr[len++] = *str;
3257 }else {
3258 tmpstr[0] = s;
3259 tmpstr[1] = *str;
3260 len = 2;
3261 s = 0;
3262 }
3263
3264 if(len > 0) {
3265 if(!MultiByteToWideChar(locinfo->lc_codepage, 0, tmpstr, len, dst, dst ? 1 : 0))
3266 len = -1;
3267 }
3268
3269 if(state)
3270 *state = s;
3271 return len;
3272}
3273
3274static inline int get_utf8_char_len(char ch)
3275{
3276 if((ch&0xf8) == 0xf0)
3277 return 4;
3278 else if((ch&0xf0) == 0xe0)
3279 return 3;
3280 else if((ch&0xe0) == 0xc0)
3281 return 2;
3282 return 1;
3283}
3284
3285/*********************************************************************
3286 * _mbstowcs_l(MSVCRT.@)
3287 */
3288size_t CDECL _mbstowcs_l(wchar_t *wcstr, const char *mbstr,
3289 size_t count, _locale_t locale)
3290{
3292 size_t i, size;
3293
3294 if(!mbstr) {
3295 *_errno() = EINVAL;
3296 return -1;
3297 }
3298
3299 if(!locale)
3300 locinfo = get_locinfo();
3301 else
3302 locinfo = locale->locinfo;
3303
3304 if(!locinfo->lc_codepage) {
3305 if(!wcstr)
3306 return strlen(mbstr);
3307
3308 for(i=0; i<count; i++) {
3309 wcstr[i] = (unsigned char)mbstr[i];
3310 if(!wcstr[i]) break;
3311 }
3312 return i;
3313 }
3314
3315 /* Ignore count parameter */
3316 if(!wcstr) {
3317 size = MultiByteToWideChar(locinfo->lc_codepage,
3318 MB_ERR_INVALID_CHARS, mbstr, -1, NULL, 0);
3319 if(!size) {
3320 *_errno() = EILSEQ;
3321 return -1;
3322 }
3323 return size - 1;
3324 }
3325
3326 for(i=0, size=0; i<count; i++) {
3327 if(mbstr[size] == '\0')
3328 break;
3329
3330 if(locinfo->lc_codepage == CP_UTF8) {
3331 int j, chlen = get_utf8_char_len(mbstr[size]);
3332
3333 for(j = 1; j < chlen; j++)
3334 {
3335 if(!mbstr[size + j])
3336 {
3337 if(count) wcstr[0] = '\0';
3338 *_errno() = EILSEQ;
3339 return -1;
3340 }
3341 }
3342 size += chlen;
3343 }
3344 else
3345 size += (_isleadbyte_l((unsigned char)mbstr[size], locale) ? 2 : 1);
3346 }
3347
3348 if(size) {
3349 size = MultiByteToWideChar(locinfo->lc_codepage,
3350 MB_ERR_INVALID_CHARS, mbstr, size, wcstr, count);
3351 if(!size) {
3352 if(count) wcstr[0] = '\0';
3353 *_errno() = EILSEQ;
3354 return -1;
3355 }
3356 }
3357
3358 if(size<count)
3359 wcstr[size] = '\0';
3360
3361 return size;
3362}
3363
3364/*********************************************************************
3365 * mbstowcs(MSVCRT.@)
3366 */
3367size_t CDECL mbstowcs(wchar_t *wcstr,
3368 const char *mbstr, size_t count)
3369{
3370 return _mbstowcs_l(wcstr, mbstr, count, NULL);
3371}
3372
3373/*********************************************************************
3374 * _mbstowcs_s_l(MSVCRT.@)
3375 */
3376int CDECL _mbstowcs_s_l(size_t *ret, wchar_t *wcstr,
3377 size_t size, const char *mbstr, size_t count, _locale_t locale)
3378{
3379 size_t conv;
3380 int err = 0;
3381
3382 if(!wcstr && !size) {
3383 conv = _mbstowcs_l(NULL, mbstr, 0, locale);
3384 if(ret)
3385 *ret = conv+1;
3386 return 0;
3387 }
3388
3389 if (!MSVCRT_CHECK_PMT(wcstr != NULL)) return EINVAL;
3390 if (!MSVCRT_CHECK_PMT(mbstr != NULL)) {
3391 if(size) wcstr[0] = '\0';
3392 return EINVAL;
3393 }
3394
3395 if(count==_TRUNCATE || size<count)
3396 conv = size;
3397 else
3398 conv = count;
3399
3400 conv = _mbstowcs_l(wcstr, mbstr, conv, locale);
3401 if(conv<size)
3402 wcstr[conv++] = '\0';
3403 else if(conv==size && count==_TRUNCATE && wcstr[conv-1]!='\0') {
3404 wcstr[conv-1] = '\0';
3405 err = STRUNCATE;
3406 }else if(conv==size && wcstr[conv-1]!='\0') {
3407 MSVCRT_INVALID_PMT("wcstr[size] is too small", ERANGE);
3408 if(size)
3409 wcstr[0] = '\0';
3410 return ERANGE;
3411 }
3412
3413 if(ret)
3414 *ret = conv;
3415 return err;
3416}
3417
3418/*********************************************************************
3419 * mbstowcs_s(MSVCRT.@)
3420 */
3421int CDECL _mbstowcs_s(size_t *ret, wchar_t *wcstr,
3422 size_t size, const char *mbstr, size_t count)
3423{
3424 return _mbstowcs_s_l(ret, wcstr, size, mbstr, count, NULL);
3425}
3426
3427/*********************************************************************
3428 * mbsrtowcs(MSVCRT.@)
3429 */
3430size_t CDECL mbsrtowcs(wchar_t *wcstr,
3431 const char **pmbstr, size_t count, mbstate_t *state)
3432{
3433 mbstate_t s = (state ? *state : 0);
3434 wchar_t tmpdst;
3435 size_t ret = 0;
3436 const char *p;
3437
3438 if(!MSVCRT_CHECK_PMT(pmbstr != NULL))
3439 return -1;
3440
3441 p = *pmbstr;
3442 while(!wcstr || count>ret) {
3443 int ch_len = mbrtowc(&tmpdst, p, 2, &s);
3444 if(wcstr)
3445 wcstr[ret] = tmpdst;
3446
3447 if(ch_len < 0) {
3448 return -1;
3449 }else if(ch_len == 0) {
3450 if(wcstr) *pmbstr = NULL;
3451 return ret;
3452 }
3453
3454 p += ch_len;
3455 ret++;
3456 }
3457
3458 if(wcstr) *pmbstr = p;
3459 return ret;
3460}
3461
3462/*********************************************************************
3463 * mbsrtowcs_s(MSVCRT.@)
3464 */
3465int CDECL mbsrtowcs_s(size_t *ret, wchar_t *wcstr, size_t len,
3466 const char **mbstr, size_t count, mbstate_t *state)
3467{
3468 size_t tmp;
3469
3470 if(!ret) ret = &tmp;
3471 if(!MSVCRT_CHECK_PMT(!!wcstr == !!len)) {
3472 *ret = -1;
3473 return EINVAL;
3474 }
3475
3476 *ret = mbsrtowcs(wcstr, mbstr, count>len ? len : count, state);
3477 if(*ret == -1) {
3478 if(wcstr) *wcstr = 0;
3479 return *_errno();
3480 }
3481 (*ret)++;
3482 if(*ret > len) {
3483 /* no place for terminating '\0' */
3484 if(wcstr) *wcstr = 0;
3485 return 0;
3486 }
3487 if(wcstr) wcstr[(*ret)-1] = 0;
3488 return 0;
3489}
3490
3491/*********************************************************************
3492 * _mbctohira_l (MSVCRT.@)
3493 *
3494 * Converts a sjis katakana character to hiragana.
3495 */
3496unsigned int CDECL _mbctohira_l(unsigned int c, _locale_t locale)
3497{
3498 if(_ismbckata_l(c, locale) && c <= 0x8393)
3499 return (c - 0x8340 - (c >= 0x837f ? 1 : 0)) + 0x829f;
3500 return c;
3501}
3502
3503/*********************************************************************
3504 * _mbctohira (MSVCRT.@)
3505 */
3506unsigned int CDECL _mbctohira(unsigned int c)
3507{
3508 return _mbctohira_l(c, NULL);
3509}
3510
3511/*********************************************************************
3512 * _mbctokata_l (MSVCRT.@)
3513 *
3514 * Converts a sjis hiragana character to katakana.
3515 */
3516unsigned int CDECL _mbctokata_l(unsigned int c, _locale_t locale)
3517{
3518 if(_ismbchira_l(c, locale))
3519 return (c - 0x829f) + 0x8340 + (c >= 0x82de ? 1 : 0);
3520 return c;
3521}
3522
3523
3524/*********************************************************************
3525 * _mbctokata (MSVCRT.@)
3526 */
3527unsigned int CDECL _mbctokata(unsigned int c)
3528{
3529 return _mbctokata_l(c, NULL);
3530}
3531
3532/*********************************************************************
3533 * _ismbcl0_l (MSVCRT.@)
3534 */
3536{
3537 pthreadmbcinfo mbcinfo;
3538
3539 if(!locale)
3540 mbcinfo = get_mbcinfo();
3541 else
3542 mbcinfo = locale->mbcinfo;
3543
3544 if(mbcinfo->mbcodepage == 932)
3545 {
3546 /* JIS non-Kanji */
3547 return _ismbclegal_l(c, locale) && c >= 0x8140 && c <= 0x889e;
3548 }
3549
3550 return 0;
3551}
3552
3553/*********************************************************************
3554 * _ismbcl0 (MSVCRT.@)
3555 */
3556int CDECL _ismbcl0(unsigned int c)
3557{
3558 return _ismbcl0_l(c, NULL);
3559}
3560
3561/*********************************************************************
3562 * _ismbcl1_l (MSVCRT.@)
3563 */
3565{
3566 pthreadmbcinfo mbcinfo;
3567
3568 if(!locale)
3569 mbcinfo = get_mbcinfo();
3570 else
3571 mbcinfo = locale->mbcinfo;
3572
3573 if(mbcinfo->mbcodepage == 932)
3574 {
3575 /* JIS level-1 */
3576 return _ismbclegal_l(c, locale) && c >= 0x889f && c <= 0x9872;
3577 }
3578
3579 return 0;
3580}
3581
3582/*********************************************************************
3583 * _ismbcl1 (MSVCRT.@)
3584 */
3585int CDECL _ismbcl1(unsigned int c)
3586{
3587 return _ismbcl1_l(c, NULL);
3588}
3589
3590/*********************************************************************
3591 * _ismbcl2_l (MSVCRT.@)
3592 */
3594{
3595 pthreadmbcinfo mbcinfo;
3596
3597 if(!locale)
3598 mbcinfo = get_mbcinfo();
3599 else
3600 mbcinfo = locale->mbcinfo;
3601
3602 if(mbcinfo->mbcodepage == 932)
3603 {
3604 /* JIS level-2 */
3605 return _ismbclegal_l(c, locale) && c >= 0x989f && c <= 0xeaa4;
3606 }
3607
3608 return 0;
3609}
3610
3611/*********************************************************************
3612 * _ismbcl2 (MSVCRT.@)
3613 */
3614int CDECL _ismbcl2(unsigned int c)
3615{
3616 return _ismbcl2_l(c, NULL);
3617}
#define _mbsnbcat
#define _mbsncat
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
static int state
Definition: maze.c:121
#define InterlockedIncrement
Definition: armddk.h:53
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
#define _stricmp
Definition: cat.c:22
Definition: _ctype.h:58
Definition: _locale.h:75
Definition: _set.h:50
#define _isleadbyte_l(_C, _L)
#define _ismbblead_l(_c, p)
#define _ismbbtrail_l(_c, p)
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CDECL
Definition: compat.h:29
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
LCID WINAPI LocaleNameToLCID(_In_ LPCWSTR lpName, _In_ DWORD dwFlags)
UINT WINAPI GetACP(void)
Definition: locale.c:2023
INT WINAPI CompareStringA(LCID lcid, DWORD flags, LPCSTR str1, INT len1, LPCSTR str2, INT len2)
Definition: locale.c:4015
BOOL WINAPI GetCPInfo(UINT codepage, LPCPINFO cpinfo)
Definition: locale.c:2146
BOOL WINAPI GetStringTypeW(DWORD type, LPCWSTR src, INT count, LPWORD chartype)
Definition: locale.c:3098
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
unsigned char ch[4][2]
Definition: console.c:118
int CDECL _tolower_l(int c, _locale_t locale)
Definition: ctype.c:532
int CDECL _toupper_l(int c, _locale_t locale)
Definition: ctype.c:474
int *CDECL _errno(void)
Definition: errno.c:215
int errno_t
Definition: corecrt.h:249
unsigned short wint_t
Definition: corecrt.h:243
#define WEOF
#define EINVAL
Definition: errno.h:44
#define STRUNCATE
Definition: errno.h:64
#define ERANGE
Definition: errno.h:55
#define EILSEQ
Definition: errno.h:62
#define INT_MAX
Definition: limits.h:26
#define _MBC_TRAIL
Definition: mbctype.h:46
#define _M2
Definition: mbctype.h:39
#define _MBC_SINGLE
Definition: mbctype.h:44
#define _MP
Definition: mbctype.h:37
#define _MB_CP_OEM
Definition: mbctype.h:52
#define _MB_CP_ANSI
Definition: mbctype.h:53
#define _MBC_LEAD
Definition: mbctype.h:45
#define _MBC_ILLEGAL
Definition: mbctype.h:47
#define _MB_CP_LOCALE
Definition: mbctype.h:54
#define _M1
Definition: mbctype.h:38
#define _SBLOW
Definition: mbctype.h:42
#define _SBUP
Definition: mbctype.h:41
#define _MS
Definition: mbctype.h:36
#define _MB_CP_SBCS
Definition: mbctype.h:51
_ACRTIMP errno_t __cdecl _mbsncpy_s_l(unsigned char *, size_t, const unsigned char *, size_t, _locale_t)
#define _NLSCMPERROR
Definition: mbstring.h:28
_ACRTIMP errno_t __cdecl _mbsncpy_s(unsigned char *, size_t, const unsigned char *, size_t)
#define EOF
Definition: stdio.h:33
#define _TRUNCATE
Definition: stdlib.h:45
_ACRTIMP int __cdecl ___mb_cur_max_l_func(_locale_t)
Definition: initctype.cpp:289
_ACRTIMP int __cdecl _strnicoll_l(const char *, const char *, size_t, _locale_t)
Definition: string.c:1249
_ACRTIMP char *__cdecl strchr(const char *, int)
Definition: string.c:3286
_ACRTIMP char *__cdecl _strrev(char *)
Definition: string.c:254
_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
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
_ACRTIMP char *__cdecl strtok_s(char *, const char *, char **)
Definition: string.c:309
_ACRTIMP char *__cdecl strstr(const char *, const char *)
Definition: string.c:3415
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
_ACRTIMP char *__cdecl strpbrk(const char *, const char *)
Definition: string.c:3525
_ACRTIMP int __cdecl strncmp(const char *, const char *, size_t)
Definition: string.c:3330
_ACRTIMP char *__cdecl strrchr(const char *, int)
Definition: string.c:3298
int mbstate_t
Definition: wchar.h:30
void free_mbcinfo(pthreadmbcinfo mbcinfo)
Definition: locale.c:1138
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
pthreadmbcinfo CDECL get_mbcinfo(void)
Definition: locale.c:642
BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_match, WCHAR *sname)
Definition: locale.c:335
void CDECL _lock(int locknum)
Definition: lock.c:85
void CDECL _unlock(int locknum)
Definition: lock.c:114
thread_data_t *CDECL msvcrt_get_thread_data(void)
Definition: ucrt_tls_sup.c:59
#define MSVCRT_INVALID_PMT(x, err)
Definition: msvcrt.h:376
#define LOCALE_FREE
Definition: msvcrt.h:172
#define LOCALE_THREAD
Definition: msvcrt.h:173
#define MSVCRT_CHECK_PMT(x)
Definition: msvcrt.h:378
#define MSVCRT_CHECK_PMT_ERR(x, err)
Definition: msvcrt.h:377
#define _MB_CP_LOCK
Definition: mtdll.h:49
else locinfo
Definition: scanf.h:225
unsigned char
Definition: typeof.h:29
return ret
Definition: mutex.c:146
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
FxCollectionEntry * cur
GLuint start
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLuint GLuint end
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLdouble n
Definition: glext.h:7729
GLuint res
Definition: glext.h:9613
GLenum src
Definition: glext.h:6340
GLsizeiptr size
Definition: glext.h:5919
const GLubyte * c
Definition: glext.h:8905
GLenum GLenum dst
Definition: glext.h:6340
GLfloat GLfloat p
Definition: glext.h:8902
GLuint GLuint num
Definition: glext.h:9618
GLenum GLsizei len
Definition: glext.h:6722
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
#define MB_ERR_INVALID_CHARS
Definition: unicode.h:41
#define C1_LOWER
Definition: unicode.h:32
#define C1_UPPER
Definition: unicode.h:31
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
#define c
Definition: ke_i.h:80
POINT cp
Definition: magnifier.c:59
int CDECL _mbsnicmp_l(const unsigned char *str, const unsigned char *cmp, size_t len, _locale_t locale)
Definition: mbcs.c:1429
int CDECL _mbsnbcmp(const unsigned char *str, const unsigned char *cmp, size_t len)
Definition: mbcs.c:1419
int CDECL _mbscat_s_l(unsigned char *dst, size_t size, const unsigned char *src, _locale_t locale)
Definition: mbcs.c:1549
int CDECL _ismbbkana_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:1811
static int u_strcmp(const unsigned char *s1, const unsigned char *s2)
Definition: mbcs.c:128
unsigned int CDECL _mbctolower_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:458
unsigned char *CDECL _mbsspnp(const unsigned char *string, const unsigned char *set)
Definition: mbcs.c:2932
unsigned int CDECL _mbctokata_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:3516
static unsigned char * u__strset(unsigned char *s, unsigned char c)
Definition: mbcs.c:168
size_t CDECL _mbsnlen_l(const unsigned char *str, size_t maxsize, _locale_t locale)
Definition: mbcs.c:740
int CDECL _ismbcprint(unsigned int ch)
Definition: mbcs.c:1982
unsigned char *CDECL _mbsset_l(unsigned char *str, unsigned int c, _locale_t locale)
Definition: mbcs.c:2293
int CDECL _mbsbtype_l(const unsigned char *str, size_t count, _locale_t locale)
Definition: mbcs.c:2240
unsigned char *CDECL _mbsncpy(unsigned char *dst, const unsigned char *src, size_t n)
Definition: mbcs.c:986
int CDECL _mbsicmp_l(const unsigned char *str, const unsigned char *cmp, _locale_t locale)
Definition: mbcs.c:1275
unsigned char *CDECL _mbstok_l(unsigned char *str, const unsigned char *delim, _locale_t locale)
Definition: mbcs.c:1749
size_t CDECL _mbstrlen(const char *str)
Definition: mbcs.c:3158
int CDECL _ismbckata_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:2034
int CDECL _ismbcupper(unsigned int ch)
Definition: mbcs.c:1911
static int u_strncasecmp(const unsigned char *s1, const unsigned char *s2, size_t len)
Definition: mbcs.c:143
int CDECL _ismbcl0_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:3535
static const unsigned char mbctombb_932_kana[]
Definition: mbcs.c:82
int CDECL _mbsicmp(const unsigned char *str, const unsigned char *cmp)
Definition: mbcs.c:1308
int CDECL _ismbstrail(const unsigned char *start, const unsigned char *str)
Definition: mbcs.c:2179
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
unsigned char *CDECL __p__mbctype(void)
Definition: mbcs.c:181
int CDECL _mbsnbcat_s_l(unsigned char *dst, size_t size, const unsigned char *src, size_t len, _locale_t locale)
Definition: mbcs.c:2567
unsigned char *CDECL _mbsnbcpy_l(unsigned char *dst, const unsigned char *src, size_t n, _locale_t locale)
Definition: mbcs.c:1088
unsigned int CDECL _mbsnextc_l(const unsigned char *str, _locale_t locale)
Definition: mbcs.c:440
int CDECL _mbsnbcpy_s(unsigned char *dst, size_t size, const unsigned char *src, size_t n)
Definition: mbcs.c:1060
int CDECL _mbccpy_s_l(unsigned char *dest, size_t maxsize, int *copied, const unsigned char *src, _locale_t locale)
Definition: mbcs.c:795
size_t CDECL _mbsnccnt_l(const unsigned char *str, size_t len, _locale_t locale)
Definition: mbcs.c:2423
int CDECL _mbsnbcoll_l(const unsigned char *str1, const unsigned char *str2, size_t len, _locale_t locale)
Definition: mbcs.c:1227
int CDECL _getmbcp(void)
Definition: mbcs.c:432
size_t CDECL _mbsspn_l(const unsigned char *string, const unsigned char *set, _locale_t locale)
Definition: mbcs.c:2875
size_t CDECL mbsrtowcs(wchar_t *wcstr, const char **pmbstr, size_t count, mbstate_t *state)
Definition: mbcs.c:3430
unsigned char *CDECL _mbscat(unsigned char *dst, const unsigned char *src)
Definition: mbcs.c:1540
int CDECL _mbslwr_s_l(unsigned char *s, size_t len, _locale_t locale)
Definition: mbcs.c:2725
int CDECL _mbscpy_s(unsigned char *dst, size_t size, const unsigned char *src)
Definition: mbcs.c:1077
unsigned char *CDECL _mbstok(unsigned char *str, const unsigned char *delim)
Definition: mbcs.c:1758
int CDECL mblen(const char *str, size_t size)
Definition: mbcs.c:3092
unsigned char *CDECL _mbschr_l(const unsigned char *s, unsigned int x, _locale_t locale)
Definition: mbcs.c:1616
int CDECL _ismbchira(unsigned int c)
Definition: mbcs.c:2026
unsigned char *CDECL _mbslwr_l(unsigned char *s, _locale_t locale)
Definition: mbcs.c:2678
int CDECL _ismbcupper_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1903
int CDECL _mblen_l(const char *str, size_t size, _locale_t locale)
Definition: mbcs.c:3072
int CDECL _mbsbtype(const unsigned char *str, size_t count)
Definition: mbcs.c:2284
int CDECL _mbccpy_s(unsigned char *dest, size_t maxsize, int *copied, const unsigned char *src)
Definition: mbcs.c:846
size_t CDECL _mbscspn_l(const unsigned char *str, const unsigned char *cmp, _locale_t locale)
Definition: mbcs.c:2940
int CDECL _ismbcprint_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1974
unsigned char *CDECL _mbsnbcat_l(unsigned char *dst, const unsigned char *src, size_t len, _locale_t locale)
Definition: mbcs.c:2512
size_t CDECL mbrlen(const char *str, size_t len, mbstate_t *state)
Definition: mbcs.c:3100
int CDECL _mbbtype(unsigned char c, int type)
Definition: mbcs.c:2232
int CDECL mbsrtowcs_s(size_t *ret, wchar_t *wcstr, size_t len, const char **mbstr, size_t count, mbstate_t *state)
Definition: mbcs.c:3465
unsigned char *CDECL _mbsstr(const unsigned char *haystack, const unsigned char *needle)
Definition: mbcs.c:1608
static const unsigned char mbctombb_932_punct[]
Definition: mbcs.c:73
static struct cp_extra_info_t g_cpextrainfo[]
Definition: mbcs.c:48
unsigned char *CDECL _mbsrev(unsigned char *str)
Definition: mbcs.c:3016
int CDECL _mbsupr_s_l(unsigned char *s, size_t len, _locale_t locale)
Definition: mbcs.c:2825
size_t CDECL _mbslen(const unsigned char *str)
Definition: mbcs.c:771
int CDECL _mbsnbcoll(const unsigned char *str1, const unsigned char *str2, size_t len)
Definition: mbcs.c:1254
unsigned int CDECL _mbcjistojms_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:590
int CDECL _mbsupr_s(unsigned char *s, size_t len)
Definition: mbcs.c:2867
int CDECL _ismbslead(const unsigned char *start, const unsigned char *str)
Definition: mbcs.c:2156
void CDECL _mbccpy_l(unsigned char *dest, const unsigned char *src, _locale_t locale)
Definition: mbcs.c:837
unsigned char *CDECL _mbscpy(unsigned char *dst, const unsigned char *src)
Definition: mbcs.c:1599
unsigned int CDECL _mbbtombc(unsigned int c)
Definition: mbcs.c:1803
unsigned int CDECL _mbcjistojms(unsigned int c)
Definition: mbcs.c:629
unsigned int CDECL _mbctoupper_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:501
int CDECL _ismbcdigit_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1839
static int u_strncmp(const unsigned char *s1, const unsigned char *s2, size_t len)
Definition: mbcs.c:138
int CDECL _ismbcspace_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1958
unsigned char *CDECL _mbsnset(unsigned char *str, unsigned int c, size_t len)
Definition: mbcs.c:2414
unsigned int CDECL _mbctohira_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:3496
int CDECL _ismbcgraph_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1855
size_t CDECL _mbscspn(const unsigned char *str, const unsigned char *cmp)
Definition: mbcs.c:2968
unsigned char *CDECL _mbsnbset(unsigned char *str, unsigned int c, size_t len)
Definition: mbcs.c:2372
int CDECL _ismbcl2_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:3593
size_t CDECL _mbsspn(const unsigned char *string, const unsigned char *set)
Definition: mbcs.c:2912
int CDECL _ismbcalnum_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1942
int CDECL _mbsnbcat_s(unsigned char *dst, size_t size, const unsigned char *src, size_t len)
Definition: mbcs.c:2624
int CDECL _mbbtype_l(unsigned char c, int type, _locale_t locale)
Definition: mbcs.c:2220
int CDECL _ismbblead(unsigned int c)
Definition: mbcs.c:2077
int CDECL _mbslwr_s(unsigned char *str, size_t len)
Definition: mbcs.c:2773
int CDECL _mbsnbicmp(const unsigned char *str, const unsigned char *cmp, size_t len)
Definition: mbcs.c:1532
int CDECL _mbsnbicmp_l(const unsigned char *str, const unsigned char *cmp, size_t len, _locale_t locale)
Definition: mbcs.c:1477
int CDECL _mbsnbcmp_l(const unsigned char *str, const unsigned char *cmp, size_t len, _locale_t locale)
Definition: mbcs.c:1366
int CDECL _ismbcalpha_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1871
static size_t u_strlen(const unsigned char *str)
Definition: mbcs.c:118
static wchar_t msvcrt_mbc_to_wc_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:90
unsigned char *CDECL _mbstok_s_l(unsigned char *str, const unsigned char *delim, unsigned char **ctx, _locale_t locale)
Definition: mbcs.c:1695
int CDECL ___mb_cur_max_func(void)
Definition: mbcs.c:197
int CDECL _mbsncmp_l(const unsigned char *str, const unsigned char *cmp, size_t len, _locale_t locale)
Definition: mbcs.c:1316
unsigned int CDECL _mbctombb_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:544
int CDECL _ismbclegal(unsigned int c)
Definition: mbcs.c:2116
unsigned char *CDECL _mbsrchr_l(const unsigned char *s, unsigned int x, _locale_t locale)
Definition: mbcs.c:1654
unsigned char *CDECL _mbsspnp_l(const unsigned char *string, const unsigned char *set, _locale_t locale)
Definition: mbcs.c:2920
void CDECL _mbccpy(unsigned char *dest, const unsigned char *src)
Definition: mbcs.c:829
int CDECL _mbsnbicoll(const unsigned char *str1, const unsigned char *str2, size_t len)
Definition: mbcs.c:1206
static unsigned char * u__strnset(unsigned char *s, unsigned char c, size_t len)
Definition: mbcs.c:173
int CDECL _mbsnicmp(const unsigned char *str, const unsigned char *cmp, size_t len)
Definition: mbcs.c:1469
int CDECL _ismbcl1_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:3564
int CDECL _mbtowc_l(wchar_t *dst, const char *str, size_t n, _locale_t locale)
Definition: mbcs.c:3166
int CDECL _ismbslead_l(const unsigned char *start, const unsigned char *str, _locale_t locale)
Definition: mbcs.c:2124
unsigned char *CDECL _mbsinc_l(const unsigned char *str, _locale_t locale)
Definition: mbcs.c:701
unsigned char *CDECL _mbspbrk_l(const unsigned char *str, const unsigned char *accept, _locale_t locale)
Definition: mbcs.c:3024
unsigned char *CDECL _mbsdec_l(const unsigned char *start, const unsigned char *cur, _locale_t locale)
Definition: mbcs.c:2187
size_t CDECL _mbclen(const unsigned char *str)
Definition: mbcs.c:693
size_t CDECL _mbclen_l(const unsigned char *str, _locale_t locale)
Definition: mbcs.c:685
size_t CDECL _mbslen_l(const unsigned char *str, _locale_t locale)
Definition: mbcs.c:779
unsigned int CDECL _mbctolower(unsigned int c)
Definition: mbcs.c:493
unsigned char *CDECL _mbsninc(const unsigned char *str, size_t num)
Definition: mbcs.c:717
size_t CDECL _mbsnbcnt_l(const unsigned char *str, size_t len, _locale_t locale)
Definition: mbcs.c:2472
int CDECL _mbsicoll(const unsigned char *str, const unsigned char *cmp)
Definition: mbcs.c:1214
unsigned char *CDECL _mbsncpy_l(unsigned char *dst, const unsigned char *src, size_t n, _locale_t locale)
Definition: mbcs.c:859
int CDECL _mbsnbicoll_l(const unsigned char *str1, const unsigned char *str2, size_t len, _locale_t locale)
Definition: mbcs.c:1179
size_t CDECL _mbstrlen_l(const char *str, _locale_t locale)
Definition: mbcs.c:3132
unsigned char *CDECL _mbsset(unsigned char *str, unsigned int c)
Definition: mbcs.c:2325
int CDECL _ismbclegal_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:2108
unsigned char *CDECL _mbsncat_l(unsigned char *dst, const unsigned char *src, size_t len, _locale_t locale)
Definition: mbcs.c:2632
int CDECL _mbscmp(const unsigned char *str, const unsigned char *cmp)
Definition: mbcs.c:1171
int CDECL _ismbcspace(unsigned int ch)
Definition: mbcs.c:1966
unsigned char *CDECL _mbsupr(unsigned char *s)
Definition: mbcs.c:2817
unsigned char *CDECL _mbspbrk(const unsigned char *str, const unsigned char *accept)
Definition: mbcs.c:3057
wint_t CDECL btowc(int c)
Definition: mbcs.c:3211
unsigned char *CDECL _mbsnbcpy(unsigned char *dst, const unsigned char *src, size_t n)
Definition: mbcs.c:1132
int CDECL _mbscmp_l(const unsigned char *str, const unsigned char *cmp, _locale_t locale)
Definition: mbcs.c:1140
int CDECL _ismbcgraph(unsigned int ch)
Definition: mbcs.c:1863
int CDECL _ismbbtrail(unsigned int c)
Definition: mbcs.c:2100
int CDECL _mbscoll(const unsigned char *str, const unsigned char *cmp)
Definition: mbcs.c:1262
unsigned int CDECL _mbctokata(unsigned int c)
Definition: mbcs.c:3527
int CDECL _ismbclower(unsigned int ch)
Definition: mbcs.c:1895
int CDECL _ismbcl2(unsigned int c)
Definition: mbcs.c:3614
int CDECL _ismbcl0(unsigned int c)
Definition: mbcs.c:3556
unsigned char *CDECL _mbsrchr(const unsigned char *s, unsigned int x)
Definition: mbcs.c:1687
int CDECL _ismbcpunct(unsigned int ch)
Definition: mbcs.c:1998
int CDECL _mbsncmp(const unsigned char *str, const unsigned char *cmp, size_t len)
Definition: mbcs.c:1358
int CDECL _mbscpy_s_l(unsigned char *dst, size_t size, const unsigned char *src, _locale_t locale)
Definition: mbcs.c:1068
int CDECL _mbscat_s(unsigned char *dst, size_t size, const unsigned char *src)
Definition: mbcs.c:1591
unsigned char *CDECL _mbstok_s(unsigned char *str, const unsigned char *delim, unsigned char **ctx)
Definition: mbcs.c:1740
unsigned int CDECL _mbctombb(unsigned int c)
Definition: mbcs.c:578
unsigned int CDECL _mbctoupper(unsigned int c)
Definition: mbcs.c:536
unsigned int CDECL _mbctohira(unsigned int c)
Definition: mbcs.c:3506
int CDECL _ismbckata(unsigned int c)
Definition: mbcs.c:2054
static const unsigned char mbbtombc_932[]
Definition: mbcs.c:60
int CDECL _mbstowcs_s(size_t *ret, wchar_t *wcstr, size_t size, const char *mbstr, size_t count)
Definition: mbcs.c:3421
unsigned char *CDECL _mbslwr(unsigned char *s)
Definition: mbcs.c:2717
unsigned char *CDECL _mbsupr_l(unsigned char *s, _locale_t locale)
Definition: mbcs.c:2781
size_t CDECL _mbsnbcnt(const unsigned char *str, size_t len)
Definition: mbcs.c:2504
unsigned char *CDECL _mbschr(const unsigned char *s, unsigned int x)
Definition: mbcs.c:1646
int CDECL _ismbcalpha(unsigned int ch)
Definition: mbcs.c:1879
unsigned int CDECL _mbsnextc(const unsigned char *str)
Definition: mbcs.c:450
int CDECL _ismbstrail_l(const unsigned char *start, const unsigned char *str, _locale_t locale)
Definition: mbcs.c:2164
int CDECL _ismbcdigit(unsigned int ch)
Definition: mbcs.c:1847
unsigned char MSVCRT_mbctype[257]
Definition: mbcs.c:38
int CDECL _ismbcsymbol_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1919
static unsigned char * u_strncat(unsigned char *dst, const unsigned char *src, size_t len)
Definition: mbcs.c:123
int CDECL _ismbbkana(unsigned int c)
Definition: mbcs.c:1831
static int get_utf8_char_len(char ch)
Definition: mbcs.c:3274
size_t CDECL _mbsnlen(const unsigned char *str, size_t maxsize)
Definition: mbcs.c:787
unsigned char *CDECL _mbsnset_l(unsigned char *str, unsigned int c, size_t len, _locale_t locale)
Definition: mbcs.c:2380
static unsigned char * u_strpbrk(const unsigned char *str, const unsigned char *accept)
Definition: mbcs.c:153
int CDECL _setmbcp(int cp)
Definition: mbcs.c:400
int CDECL _ismbchira_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:2006
int CDECL _ismbcpunct_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1990
unsigned int CDECL _mbbtombc_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:1773
int CDECL _mbscoll_l(const unsigned char *str1, const unsigned char *str2, _locale_t locale)
Definition: mbcs.c:1246
unsigned int CDECL _mbcjmstojis(unsigned int c)
Definition: mbcs.c:677
int CDECL _ismbcl1(unsigned int c)
Definition: mbcs.c:3585
int CDECL _ismbcalnum(unsigned int ch)
Definition: mbcs.c:1950
unsigned char *CDECL _mbsdec(const unsigned char *start, const unsigned char *cur)
Definition: mbcs.c:2211
int CDECL _ismbcsymbol(unsigned int ch)
Definition: mbcs.c:1934
unsigned char *CDECL _mbsnbset_l(unsigned char *str, unsigned int c, size_t len, _locale_t locale)
Definition: mbcs.c:2333
static unsigned char * u_strrchr(const unsigned char *s, unsigned char x)
Definition: mbcs.c:158
threadmbcinfo * create_mbcinfo(int cp, LCID lcid, threadmbcinfo *old_mbcinfo)
Definition: mbcs.c:219
int CDECL _ismbclower_l(unsigned int ch, _locale_t locale)
Definition: mbcs.c:1887
static unsigned char * u__strrev(unsigned char *str)
Definition: mbcs.c:163
int CDECL _mbsicoll_l(const unsigned char *str1, const unsigned char *str2, _locale_t locale)
Definition: mbcs.c:1198
int *CDECL __p___mb_cur_max(void)
Definition: mbcs.c:189
unsigned int CDECL _mbcjmstojis_l(unsigned int c, _locale_t locale)
Definition: mbcs.c:639
size_t CDECL _mbsnccnt(const unsigned char *str, size_t len)
Definition: mbcs.c:2463
static int u_strcasecmp(const unsigned char *s1, const unsigned char *s2)
Definition: mbcs.c:133
unsigned char *CDECL _mbsrev_l(unsigned char *str, _locale_t locale)
Definition: mbcs.c:2976
static unsigned char * u_strchr(const unsigned char *s, unsigned char x)
Definition: mbcs.c:148
unsigned char *CDECL _mbsinc(const unsigned char *str)
Definition: mbcs.c:709
struct S1 s1
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define for
Definition: utility.h:88
char string[160]
Definition: util.h:11
static PVOID ptr
Definition: dispmode.c:27
#define sprintf
Definition: sprintf.c:45
static UINT UINT last
Definition: font.c:45
#define cmp(status, error)
Definition: error.c:114
static char * dest
Definition: rtl.c:135
static const char haystack[]
Definition: editor.c:190
#define min(a, b)
Definition: monoChain.cc:55
#define LOCALE_NAME_MAX_LENGTH
#define err(...)
const WCHAR * str
#define _iswdigit_l(_c, _p)
Definition: ctype.h:679
#define _iswlower_l(_c, _p)
Definition: ctype.h:678
#define _isprint_l(_Char, _Locale)
Definition: ctype.h:651
#define _iswupper_l(_c, _p)
Definition: ctype.h:677
#define _iswspace_l(_c, _p)
Definition: ctype.h:681
#define _iswgraph_l(_c, _p)
Definition: ctype.h:685
#define _iswprint_l(_c, _p)
Definition: ctype.h:684
#define _iswalpha_l(_c, _p)
Definition: ctype.h:676
#define _iswpunct_l(_c, _p)
Definition: ctype.h:682
#define _iswalnum_l(_c, _p)
Definition: ctype.h:683
#define isleadbyte(_c)
Definition: wchar.h:598
DWORD LCID
Definition: nls.h:13
#define CP_UTF8
Definition: nls.h:20
_mbstowcs_s_l
Definition: stdlib.h:951
_mbstowcs_l
Definition: stdlib.h:951
mbstowcs
Definition: stdlib.h:925
strcat
Definition: string.h:92
_strset
Definition: string.h:424
strcpy
Definition: string.h:131
_In_opt_ _Locale strncat
Definition: string.h:263
_strnset
Definition: string.h:393
XML_HIDDEN void xmlParserErrors const char const xmlChar const xmlChar * str2
Definition: parser.h:35
XML_HIDDEN void xmlParserErrors const char const xmlChar * str1
Definition: parser.h:35
#define MSVCRT_locale
Definition: locale.h:80
#define memset(x, y, z)
Definition: compat.h:39
#define mbrtowc(wp, cp, len, sp)
Definition: wchar.h:158
#define mbtowc(wp, cp, len)
Definition: wchar.h:155
PCWSTR s2
Definition: shell32_main.h:38
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
_In_ size_t const maxsize
Definition: strftime.cpp:120
BYTE LeadByte[MAX_LEADBYTES]
Definition: winnls.h:652
UINT MaxCharSize
Definition: winnls.h:650
BYTE TrailBytes[MAX_LEADBYTES]
Definition: mbcs.c:45
Definition: match.c:28
unsigned char mbcasemap[256]
Definition: msvcrt.h:139
unsigned char mbctype[257]
Definition: msvcrt.h:138
Definition: pdh_main.c:96
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define get_locinfo()
Definition: winesup.h:25
#define NORM_IGNORECASE
Definition: winnls.h:187
#define LOCALE_ALLOW_NEUTRAL_NAMES
Definition: winnls.h:25
#define CT_CTYPE3
Definition: winnls.h:257
#define CT_CTYPE1
Definition: winnls.h:255
#define C3_SYMBOL
Definition: winnls.h:283
#define LCMAP_UPPERCASE
Definition: winnls.h:198
#define CSTR_EQUAL
Definition: winnls.h:500
#define LCMAP_LOWERCASE
Definition: winnls.h:197
#define MAX_LEADBYTES
Definition: winnls.h:14
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193