ReactOS 0.4.16-dev-2102-g4cf8777
wcs.c
Go to the documentation of this file.
1/*
2 * msvcrt.dll wide-char functions
3 *
4 * Copyright 1999 Alexandre Julliard
5 * Copyright 2000 Jon Griffiths
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
22#define _NO_CRT_STDIO_INLINE
23#include <limits.h>
24#include <locale.h>
25#include <math.h>
26#include <assert.h>
27#include <wchar.h>
28#include <wctype.h>
29#include "msvcrt.h"
30#include "winnls.h"
31#include "wtypes.h"
32#include "wine/debug.h"
33
35
36#ifdef _MSC_VER
37#pragma function(_wcsset,wcscat,wcscmp,wcscpy,wcslen)
38#endif
39
40typedef struct
41{
42 enum { LEN_DEFAULT, LEN_SHORT, LEN_LONG } IntegerLength;
43 BOOLEAN IntegerDouble, IntegerNative, LeftAlign, Alternate, PadZero;
45 int FieldLength, Precision;
46 char Sign, Format;
47} pf_flags;
48
50
51#include "printf.h"
52#define PRINTF_WIDE
53#include "printf.h"
54#undef PRINTF_WIDE
55
56#if _MSVCR_VER>=80
57
58/*********************************************************************
59 * _get_printf_count_output (MSVCR80.@)
60 */
62{
63 return n_format_enabled ? 1 : 0;
64}
65
66/*********************************************************************
67 * _set_printf_count_output (MSVCR80.@)
68 */
70{
73 return old ? 1 : 0;
74}
75
76#endif /* _MSVCR_VER>=80 */
77
78/*********************************************************************
79 * _wcsdup (MSVCRT.@)
80 */
81wchar_t* CDECL _wcsdup( const wchar_t* str )
82{
83 wchar_t* ret = NULL;
84 if (str)
85 {
86 size_t size = (wcslen(str) + 1) * sizeof(wchar_t);
87 ret = malloc( size );
88 if (ret) memcpy( ret, str, size );
89 }
90 return ret;
91}
92
93/*********************************************************************
94 * _towlower_l (MSVCRT.@)
95 */
97{
99 wchar_t ret;
100
101 if(!locale)
103 else
104 locinfo = locale->locinfo;
105
106 if(!locinfo->lc_handle[LC_CTYPE]) {
107 if(c >= 'A' && c <= 'Z')
108 return c + 'a' - 'A';
109 return c;
110 }
111
112 if(!LCMapStringW(locinfo->lc_handle[LC_CTYPE], LCMAP_LOWERCASE, &c, 1, &ret, 1))
113 return c;
114 return ret;
115}
116
117/*********************************************************************
118 * towlower (MSVCRT.@)
119 */
121{
122 return _towlower_l(c, NULL);
123}
124
125INT CDECL _wcsicmp_l(const wchar_t *str1, const wchar_t *str2, _locale_t locale)
126{
127 _locale_tstruct tmp = {0};
128 wchar_t c1, c2;
129
130 if(!MSVCRT_CHECK_PMT(str1 != NULL) || !MSVCRT_CHECK_PMT(str2 != NULL))
131 return _NLSCMPERROR;
132
133 if(!locale)
135
136 do
137 {
138 c1 = _towlower_l(*str1++, locale);
139 c2 = _towlower_l(*str2++, locale);
140 } while(c1 && (c1 == c2));
141
143 return c1 - c2;
144}
145
146/*********************************************************************
147 * towctrans (MSVCR120.@)
148 */
150{
151 if(category == 1)
152 return _towupper_l(c, NULL);
153 return _towlower_l(c, NULL);
154}
155
156/*********************************************************************
157 * _wcsicmp (MSVCRT.@)
158 */
159INT CDECL _wcsicmp( const wchar_t* str1, const wchar_t* str2 )
160{
161 return _wcsicmp_l(str1, str2, NULL);
162}
163
164/*********************************************************************
165 * _wcsnicmp_l (MSVCRT.@)
166 */
167INT CDECL _wcsnicmp_l(const wchar_t *str1, const wchar_t *str2,
168 size_t n, _locale_t locale)
169{
170 _locale_tstruct tmp = {0};
171 wchar_t c1, c2;
172
173 if (!n)
174 return 0;
175
176 if(!MSVCRT_CHECK_PMT(str1 != NULL) || !MSVCRT_CHECK_PMT(str2 != NULL))
177 return _NLSCMPERROR;
178
179 if(!locale)
181
182 do
183 {
184 c1 = _towlower_l(*str1++, locale);
185 c2 = _towlower_l(*str2++, locale);
186 } while(--n && c1 && (c1 == c2));
187
189 return c1 - c2;
190}
191
192/*********************************************************************
193 * _wcsnicmp (MSVCRT.@)
194 */
195INT CDECL _wcsnicmp(const wchar_t *str1, const wchar_t *str2, size_t n)
196{
197 return _wcsnicmp_l(str1, str2, n, NULL);
198}
199
200/*********************************************************************
201 * _wcsicoll_l (MSVCRT.@)
202 */
203int CDECL _wcsicoll_l(const wchar_t* str1, const wchar_t* str2, _locale_t locale)
204{
206
207 if(!locale)
209 else
210 locinfo = locale->locinfo;
211
212 if(!locinfo->lc_handle[LC_COLLATE])
213 {
214 wchar_t c1, c2;
215
216 do
217 {
218 c1 = *str1++;
219 if (c1 >= 'A' && c1 <= 'Z')
220 c1 += 'a' - 'A';
221
222 c2 = *str2++;
223 if (c2 >= 'A' && c2 <= 'Z')
224 c2 += 'a' - 'A';
225 } while(c1 && (c1 == c2));
226 return c1 - c2;
227 }
228
230 str1, -1, str2, -1)-CSTR_EQUAL;
231}
232
233/*********************************************************************
234 * _wcsicoll (MSVCRT.@)
235 */
236INT CDECL _wcsicoll( const wchar_t* str1, const wchar_t* str2 )
237{
238 return _wcsicoll_l(str1, str2, NULL);
239}
240
241/*********************************************************************
242 * _wcsnicoll_l (MSVCRT.@)
243 */
244int CDECL _wcsnicoll_l(const wchar_t* str1, const wchar_t* str2,
245 size_t count, _locale_t locale)
246{
248
249 if(!locale)
251 else
252 locinfo = locale->locinfo;
253
254 if(!locinfo->lc_handle[LC_COLLATE])
255 {
256 wchar_t c1, c2;
257
258 if (!count)
259 return 0;
260
261 do
262 {
263 c1 = *str1++;
264 if (c1 >= 'A' && c1 <= 'Z')
265 c1 += 'a' - 'A';
266
267 c2 = *str2++;
268 if (c2 >= 'A' && c2 <= 'Z')
269 c2 += 'a' - 'A';
270 } while(--count && c1 && (c1 == c2));
271 return c1 - c2;
272 }
273
275 str1, wcsnlen(str1, count),
276 str2, wcsnlen(str2, count))-CSTR_EQUAL;
277}
278
279/*********************************************************************
280 * _wcsnicoll (MSVCRT.@)
281 */
282INT CDECL _wcsnicoll( const wchar_t* str1, const wchar_t* str2, size_t count )
283{
284 return _wcsnicoll_l(str1, str2, count, NULL);
285}
286
287/*********************************************************************
288 * _wcsnset (MSVCRT.@)
289 */
290wchar_t* CDECL _wcsnset( wchar_t* str, wchar_t c, size_t n )
291{
292 wchar_t* ret = str;
293 while ((n-- > 0) && *str) *str++ = c;
294 return ret;
295}
296
297/*********************************************************************
298 * _wcsnset_s (MSVCRT.@)
299 */
300int CDECL _wcsnset_s( wchar_t *str, size_t size, wchar_t c, size_t count )
301{
302 size_t i;
303
304 if(!str && !size && !count) return 0;
305 if(!MSVCRT_CHECK_PMT(str != NULL)) return EINVAL;
306 if(!MSVCRT_CHECK_PMT(size > 0)) return EINVAL;
307
308 for(i=0; i<size-1 && i<count; i++) {
309 if(!str[i]) return 0;
310 str[i] = c;
311 }
312 for(; i<size; i++)
313 if(!str[i]) return 0;
314
315 str[0] = 0;
317 *_errno() = EINVAL;
318 return EINVAL;
319}
320
321/*********************************************************************
322 * _wcsrev (MSVCRT.@)
323 */
324wchar_t* CDECL _wcsrev( wchar_t* str )
325{
326 wchar_t* ret = str;
327 wchar_t* end = str + wcslen(str) - 1;
328 while (end > str)
329 {
330 wchar_t t = *end;
331 *end-- = *str;
332 *str++ = t;
333 }
334 return ret;
335}
336
337/*********************************************************************
338 * _wcsset_s (MSVCRT.@)
339 */
340int CDECL _wcsset_s( wchar_t *str, size_t n, wchar_t c )
341{
342 wchar_t *p = str;
343
344 if(!MSVCRT_CHECK_PMT(str != NULL)) return EINVAL;
345 if(!MSVCRT_CHECK_PMT(n)) return EINVAL;
346
347 while(*p && --n) *p++ = c;
348 if(!n) {
349 str[0] = 0;
351 *_errno() = EINVAL;
352 return EINVAL;
353 }
354 return 0;
355}
356
357/*********************************************************************
358 * _wcsset (MSVCRT.@)
359 */
360wchar_t* CDECL _wcsset( wchar_t* str, wchar_t c )
361{
362 wchar_t* ret = str;
363 while (*str) *str++ = c;
364 return ret;
365}
366
367/******************************************************************
368 * _wcsupr_s_l (MSVCRT.@)
369 */
370int CDECL _wcsupr_s_l( wchar_t* str, size_t n, _locale_t locale )
371{
372 _locale_tstruct tmp = {0};
373 wchar_t* ptr = str;
374
375 if (!str || !n)
376 {
377 if (str) *str = '\0';
378 *_errno() = EINVAL;
379 return EINVAL;
380 }
381
382 if(!locale)
384
385 while (n--)
386 {
387 if (!*ptr)
388 {
390 return 0;
391 }
393 ptr++;
394 }
395
397
398 /* MSDN claims that the function should return and set errno to
399 * ERANGE, which doesn't seem to be true based on the tests. */
400 *str = '\0';
401 *_errno() = EINVAL;
402 return EINVAL;
403}
404
405/******************************************************************
406 * _wcsupr_s (MSVCRT.@)
407 *
408 */
409INT CDECL _wcsupr_s( wchar_t* str, size_t n )
410{
411 return _wcsupr_s_l( str, n, NULL );
412}
413
414/******************************************************************
415 * _wcsupr_l (MSVCRT.@)
416 */
417wchar_t* CDECL _wcsupr_l( wchar_t *str, _locale_t locale )
418{
419 _wcsupr_s_l( str, -1, locale);
420 return str;
421}
422
423/******************************************************************
424 * _wcsupr (MSVCRT.@)
425 */
426wchar_t* CDECL _wcsupr( wchar_t *str )
427{
428 return _wcsupr_l(str, NULL);
429}
430
431/******************************************************************
432 * _wcslwr_s_l (MSVCRT.@)
433 */
434int CDECL _wcslwr_s_l( wchar_t* str, size_t n, _locale_t locale )
435{
436 _locale_tstruct tmp = {0};
437 wchar_t* ptr = str;
438
439 if (!str || !n)
440 {
441 if (str) *str = '\0';
442 *_errno() = EINVAL;
443 return EINVAL;
444 }
445
446 if(!locale)
448
449 while (n--)
450 {
451 if (!*ptr)
452 {
454 return 0;
455 }
457 ptr++;
458 }
459
461
462 /* MSDN claims that the function should return and set errno to
463 * ERANGE, which doesn't seem to be true based on the tests. */
464 *str = '\0';
465 *_errno() = EINVAL;
466 return EINVAL;
467}
468
469/******************************************************************
470 * _wcslwr_s (MSVCRT.@)
471 */
472int CDECL _wcslwr_s( wchar_t* str, size_t n )
473{
474 return _wcslwr_s_l(str, n, NULL);
475}
476
477/******************************************************************
478 * _wcslwr_l (MSVCRT.@)
479 */
480wchar_t* CDECL _wcslwr_l( wchar_t* str, _locale_t locale )
481{
482 _wcslwr_s_l(str, -1, locale);
483 return str;
484}
485
486/******************************************************************
487 * _wcslwr (MSVCRT.@)
488 */
489wchar_t* CDECL _wcslwr( wchar_t* str )
490{
491 _wcslwr_s_l(str, -1, NULL);
492 return str;
493}
494
495/*********************************************************************
496 * wcscspn (MSVCRT.@)
497 */
498size_t __cdecl wcscspn(const wchar_t *str, const wchar_t *reject)
499{
500 const wchar_t *ptr;
501 for (ptr = str; *ptr; ptr++) if (wcschr( reject, *ptr )) break;
502 return ptr - str;
503}
504
505/*********************************************************************
506 * wcsspn (MSVCRT.@)
507 */
508size_t __cdecl wcsspn(const wchar_t *str, const wchar_t *accept)
509{
510 const wchar_t *ptr;
511 for (ptr = str; *ptr; ptr++) if (!wcschr( accept, *ptr )) break;
512 return ptr - str;
513}
514
515/*********************************************************************
516 * wcsncmp (MSVCRT.@)
517 */
518int CDECL wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t n)
519{
520 if (!n)
521 return 0;
522 while(--n && *str1 && (*str1 == *str2))
523 {
524 str1++;
525 str2++;
526 }
527 return *str1 - *str2;
528}
529
530/*********************************************************************
531 * _wcsncoll_l (MSVCRT.@)
532 */
533int CDECL _wcsncoll_l(const wchar_t* str1, const wchar_t* str2,
534 size_t count, _locale_t locale)
535{
537
538 if(!locale)
540 else
541 locinfo = locale->locinfo;
542
543 if(!locinfo->lc_handle[LC_COLLATE])
544 return wcsncmp(str1, str2, count);
546 str1, wcsnlen(str1, count),
547 str2, wcsnlen(str2, count))-CSTR_EQUAL;
548}
549
550/*********************************************************************
551 * _wcsncoll (MSVCRT.@)
552 */
553int CDECL _wcsncoll(const wchar_t* str1, const wchar_t* str2, size_t count)
554{
555 return _wcsncoll_l(str1, str2, count, NULL);
556}
557
558static wchar_t strtod_wstr_get(void *ctx)
559{
560 const wchar_t **p = ctx;
561 if (!**p) return WEOF;
562 return *(*p)++;
563}
564
565static void strtod_wstr_unget(void *ctx)
566{
567 const wchar_t **p = ctx;
568 (*p)--;
569}
570
571/*********************************************************************
572 * _wcstod_l (MSVCRT.@)
573 */
574double CDECL _wcstod_l(const wchar_t* str, wchar_t** end,
576{
578 const wchar_t *beg, *p;
579 struct fpnum fp;
580 double ret;
581 int err;
582
583 if (!MSVCRT_CHECK_PMT(str != NULL)) {
584 if (end) *end = NULL;
585 return 0;
586 }
587
588 if (!locale)
590 else
591 locinfo = locale->locinfo;
592
593 p = str;
594 while(_iswspace_l(*p, locale))
595 p++;
596 beg = p;
597
599 if (end) *end = (p == beg ? (wchar_t*)str : (wchar_t*)p);
600
601 err = fpnum_double(&fp, &ret);
602 if(err) *_errno() = err;
603 return ret;
604}
605
606/*********************************************************************
607 * wcsrtombs_l (INTERNAL)
608 */
609static size_t wcsrtombs_l(char *mbstr, const wchar_t **wcstr,
610 size_t count, _locale_t locale)
611{
613 size_t tmp = 0;
614 BOOL used_default = FALSE;
615 BOOL *pused_default;
616
617 if(!locale)
619 else
620 locinfo = locale->locinfo;
621
622 if(!locinfo->lc_codepage) {
623 size_t i;
624
625 if(!mbstr)
626 return wcslen(*wcstr);
627
628 for(i=0; i<count; i++) {
629 if((*wcstr)[i] > 255) {
630 *_errno() = EILSEQ;
631 return -1;
632 }
633
634 mbstr[i] = (*wcstr)[i];
635 if(!(*wcstr)[i]) break;
636 }
637
638 if(i < count) *wcstr = NULL;
639 else *wcstr += i;
640 return i;
641 }
642
643 pused_default = (locinfo->lc_codepage != CP_UTF8 ? &used_default : NULL);
644
645 if(!mbstr) {
647 *wcstr, -1, NULL, 0, NULL, pused_default);
648 if(!tmp || used_default) {
649 *_errno() = EILSEQ;
650 return -1;
651 }
652 return tmp-1;
653 }
654
655 while(**wcstr) {
656 char buf[3];
657 size_t i, size;
658
660 *wcstr, 1, buf, 3, NULL, pused_default);
661 if(!size || used_default) {
662 *_errno() = EILSEQ;
663 return -1;
664 }
665 if(tmp+size > count)
666 return tmp;
667
668 for(i=0; i<size; i++)
669 mbstr[tmp++] = buf[i];
670 (*wcstr)++;
671 }
672
673 if(tmp < count) {
674 mbstr[tmp] = '\0';
675 *wcstr = NULL;
676 }
677 return tmp;
678}
679
680/*********************************************************************
681 * _wcstombs_l (MSVCRT.@)
682 */
683size_t CDECL _wcstombs_l(char *mbstr, const wchar_t *wcstr,
684 size_t count, _locale_t locale)
685{
686 return wcsrtombs_l(mbstr, &wcstr, count, locale);
687}
688
689/*********************************************************************
690 * wcstombs (MSVCRT.@)
691 */
692size_t CDECL wcstombs(char *mbstr, const wchar_t *wcstr,
693 size_t count)
694{
695 return wcsrtombs_l(mbstr, &wcstr, count, NULL);
696}
697
698/*********************************************************************
699 * wcsrtombs (MSVCRT.@)
700 */
701size_t CDECL wcsrtombs(char *mbstr, const wchar_t **wcstr,
702 size_t count, mbstate_t *mbstate)
703{
704 if(mbstate)
705 *mbstate = 0;
706
707 return wcsrtombs_l(mbstr, wcstr, count, NULL);
708}
709
710/*********************************************************************
711 * wcsrtombs_s_l (INTERNAL)
712 */
713static int wcsrtombs_s_l(size_t *ret, char *mbstr, size_t size,
714 const wchar_t **wcstr, size_t count, _locale_t locale)
715{
716 size_t conv;
717 int err;
718
719 if(!mbstr && !size && wcstr) {
720 conv = wcsrtombs_l(NULL, wcstr, 0, locale);
721 if(ret)
722 *ret = conv+1;
723 if(conv == -1)
724 return *_errno();
725 return 0;
726 }
727
728 if (!MSVCRT_CHECK_PMT(mbstr != NULL)) return EINVAL;
729 if (size) mbstr[0] = '\0';
730 if (!MSVCRT_CHECK_PMT(wcstr != NULL)) return EINVAL;
731 if (!MSVCRT_CHECK_PMT(*wcstr != NULL)) return EINVAL;
732
733 if(count==_TRUNCATE || size<count)
734 conv = size;
735 else
736 conv = count;
737
738 err = 0;
739 conv = wcsrtombs_l(mbstr, wcstr, conv, locale);
740 if(conv == -1) {
741 conv = 0;
742 if(size)
743 mbstr[0] = '\0';
744 err = *_errno();
745 }else if(conv < size)
746 mbstr[conv++] = '\0';
747 else if(conv==size && (count==_TRUNCATE || mbstr[conv-1]=='\0')) {
748 mbstr[conv-1] = '\0';
749 if(count==_TRUNCATE)
750 err = STRUNCATE;
751 }else {
752 MSVCRT_INVALID_PMT("mbstr[size] is too small", ERANGE);
753 conv = 0;
754 if(size)
755 mbstr[0] = '\0';
756 err = ERANGE;
757 }
758
759 if(ret)
760 *ret = conv;
761 return err;
762}
763
764/*********************************************************************
765 * _wcstombs_s_l (MSVCRT.@)
766 */
767int CDECL _wcstombs_s_l(size_t *ret, char *mbstr, size_t size,
768 const wchar_t *wcstr, size_t count, _locale_t locale)
769{
770 return wcsrtombs_s_l(ret, mbstr, size, &wcstr,count, locale);
771}
772
773/*********************************************************************
774 * wcstombs_s (MSVCRT.@)
775 */
776int CDECL wcstombs_s(size_t *ret, char *mbstr, size_t size,
777 const wchar_t *wcstr, size_t count)
778{
779 return wcsrtombs_s_l(ret, mbstr, size, &wcstr, count, NULL);
780}
781
782/*********************************************************************
783 * wcsrtombs_s (MSVCRT.@)
784 */
785int CDECL wcsrtombs_s(size_t *ret, char *mbstr, size_t size,
786 const wchar_t **wcstr, size_t count, mbstate_t *mbstate)
787{
788 if(mbstate)
789 *mbstate = 0;
790
791 return wcsrtombs_s_l(ret, mbstr, size, wcstr, count, NULL);
792}
793
794/*********************************************************************
795 * wcstod (MSVCRT.@)
796 */
797double CDECL wcstod(const wchar_t* lpszStr, wchar_t** end)
798{
799 return _wcstod_l(lpszStr, end, NULL);
800}
801
802/*********************************************************************
803 * _wtof (MSVCRT.@)
804 */
805double CDECL _wtof(const wchar_t *str)
806{
807 return _wcstod_l(str, NULL, NULL);
808}
809
810/*********************************************************************
811 * _wtof_l (MSVCRT.@)
812 */
813double CDECL _wtof_l(const wchar_t *str, _locale_t locale)
814{
815 return _wcstod_l(str, NULL, locale);
816}
817
818#if _MSVCR_VER>=120
819
820/*********************************************************************
821 * _wcstof_l (MSVCR120.@)
822 */
823float CDECL _wcstof_l( const wchar_t *str, wchar_t **end, _locale_t locale )
824{
825 double ret = _wcstod_l(str, end, locale);
826 if (ret && isfinite(ret)) {
827 float f = ret;
828 if (!f || !isfinite(f))
829 *_errno() = ERANGE;
830 }
831 return ret;
832}
833
834/*********************************************************************
835 * wcstof (MSVCR120.@)
836 */
837float CDECL wcstof( const wchar_t *str, wchar_t **end )
838{
839 return _wcstof_l(str, end, NULL);
840}
841
842#endif /* _MSVCR_VER>=120 */
843
844/*********************************************************************
845 * arg_clbk_valist (INTERNAL)
846 */
848{
850
851 if(type == VT_I8)
852 ret.get_longlong = va_arg(*valist, LONGLONG);
853 else if(type == VT_INT)
854 ret.get_int = va_arg(*valist, int);
855 else if(type == VT_R8)
856 ret.get_double = va_arg(*valist, double);
857 else if(type == VT_PTR)
858 ret.get_ptr = va_arg(*valist, void*);
859 else {
860 ERR("Incorrect type\n");
861 ret.get_int = 0;
862 }
863
864 return ret;
865}
866
867/*********************************************************************
868 * arg_clbk_positional (INTERNAL)
869 */
871{
873 return args[pos];
874}
875
876#if _MSVCR_VER < 140
877
878/*********************************************************************
879 * _vsnprintf (MSVCRT.@)
880 */
881int CDECL _vsnprintf( char *str, size_t len, const char *format, va_list valist )
882{
883 static const char nullbyte = '\0';
884 struct _str_ctx_a ctx = {len, str};
885 int ret;
886
887 ret = pf_printf_a(puts_clbk_str_a, &ctx, format, NULL, 0,
889 puts_clbk_str_a(&ctx, 1, &nullbyte);
890 return ret;
891}
892
893#else
894
895static int puts_clbk_str_c99_a(void *ctx, int len, const char *str)
896{
897 struct _str_ctx_a *out = ctx;
898
899 if(!out->buf)
900 return len;
901
902 if(out->len < len) {
903 memmove(out->buf, str, out->len);
904 out->buf += out->len;
905 out->len = 0;
906 return len;
907 }
908
909 memmove(out->buf, str, len);
910 out->buf += len;
911 out->len -= len;
912 return len;
913}
914
915/*********************************************************************
916 * __stdio_common_vsprintf (UCRTBASE.@)
917 */
918int CDECL __stdio_common_vsprintf( unsigned __int64 options, char *str, size_t len, const char *format,
920{
921 static const char nullbyte = '\0';
922 struct _str_ctx_a ctx = {len, str};
923 int ret;
924
926 FIXME("options %#I64x not handled\n", options);
927 ret = pf_printf_a(puts_clbk_str_c99_a,
929 puts_clbk_str_a(&ctx, 1, &nullbyte);
930
931 if(!str)
932 return ret;
934 return ret>len ? -1 : ret;
935 if(ret>=len) {
936 if(len) str[len-1] = 0;
938 return ret;
939 return len > 0 ? -2 : -1;
940 }
941 return ret;
942}
943
944#endif /* _MSVCR_VER>=140 */
945
946/*********************************************************************
947 * _vsnprintf_l (MSVCRT.@)
948 */
949int CDECL _vsnprintf_l( char *str, size_t len, const char *format,
951{
952 static const char nullbyte = '\0';
953 struct _str_ctx_a ctx = {len, str};
954 int ret;
955
956 ret = pf_printf_a(puts_clbk_str_a, &ctx, format, locale, 0,
958 puts_clbk_str_a(&ctx, 1, &nullbyte);
959 return ret;
960}
961
962/*********************************************************************
963 * _vsprintf_l (MSVCRT.@)
964 */
965int CDECL _vsprintf_l( char *str, const char *format,
967{
969}
970
971/*********************************************************************
972 * _sprintf_l (MSVCRT.@)
973 */
974int WINAPIV _sprintf_l(char *str, const char *format,
975 _locale_t locale, ...)
976{
977 int retval;
981 va_end(valist);
982 return retval;
983}
984
985static int CDECL vsnprintf_s_l_opt( char *str, size_t sizeOfBuffer,
986 size_t count, const char *format, DWORD options,
988{
989 static const char nullbyte = '\0';
990 struct _str_ctx_a ctx;
991 int len, ret;
992
993 if(sizeOfBuffer<count+1 || count==-1)
995 else
996 len = count+1;
997
998 ctx.len = len;
999 ctx.buf = str;
1002 puts_clbk_str_a(&ctx, 1, &nullbyte);
1003
1004 if(ret<0 || ret==len) {
1006 MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small", ERANGE);
1007 memset(str, 0, sizeOfBuffer);
1008 } else
1009 str[len-1] = '\0';
1010
1011 return -1;
1012 }
1013
1014 return ret;
1015}
1016
1017static int vsnwprintf_s_l_opt( wchar_t *str, size_t sizeOfBuffer,
1018 size_t count, const wchar_t *format, DWORD options,
1020{
1021 struct _str_ctx_w ctx;
1022 int len, ret;
1023
1024 len = sizeOfBuffer;
1025 if(count!=-1 && len>count+1)
1026 len = count+1;
1027
1028 ctx.len = len;
1029 ctx.buf = str;
1032 puts_clbk_str_w(&ctx, 1, L"");
1033
1034 if(ret<0 || ret==len) {
1036 MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small", ERANGE);
1037 memset(str, 0, sizeOfBuffer*sizeof(wchar_t));
1038 } else
1039 str[len-1] = '\0';
1040
1041 return -1;
1042 }
1043
1044 return ret;
1045}
1046
1047/*********************************************************************
1048 * _vsnprintf_s_l (MSVCRT.@)
1049 */
1051 size_t count, const char *format,
1053{
1055}
1056
1057/*********************************************************************
1058 * _vsprintf_s_l (MSVCRT.@)
1059 */
1060int CDECL _vsprintf_s_l( char *str, size_t count, const char *format,
1062{
1064}
1065
1066/*********************************************************************
1067 * _sprintf_s_l (MSVCRT.@)
1068 */
1069int WINAPIV _sprintf_s_l( char *str, size_t count, const char *format,
1070 _locale_t locale, ...)
1071{
1072 int retval;
1076 va_end(valist);
1077 return retval;
1078}
1079
1080/*********************************************************************
1081 * _vsnprintf_s (MSVCRT.@)
1082 */
1084 size_t count, const char *format, va_list valist )
1085{
1087}
1088
1089/*********************************************************************
1090 * _vsnprintf_c_l (MSVCRT.@)
1091 */
1092int CDECL _vsnprintf_c_l(char *str, size_t len, const char *format,
1094{
1096}
1097
1098/*********************************************************************
1099 * _vsnprintf_c (MSVCRT.@)
1100 */
1101int CDECL _vsnprintf_c(char *str, size_t len,
1102 const char *format, va_list valist)
1103{
1104 return _vsnprintf_c_l(str, len, format, NULL, valist);
1105}
1106
1107#if _MSVCR_VER>=140
1108
1109/*********************************************************************
1110 * __stdio_common_vsnprintf_s (UCRTBASE.@)
1111 */
1113 char *str, size_t sizeOfBuffer, size_t count,
1114 const char *format, _locale_t locale, va_list valist )
1115{
1117 FIXME("options %#I64x not handled\n", options);
1119}
1120
1121/*********************************************************************
1122 * __stdio_common_vsnwprintf_s (UCRTBASE.@)
1123 */
1125 wchar_t *str, size_t sizeOfBuffer, size_t count,
1126 const wchar_t *format, _locale_t locale, va_list valist )
1127{
1129 FIXME("options %#I64x not handled\n", options);
1131}
1132
1133/*********************************************************************
1134 * __stdio_common_vswprintf_s (UCRTBASE.@)
1135 */
1137 wchar_t *str, size_t count, const wchar_t *format,
1139{
1141}
1142
1143/*********************************************************************
1144 * __stdio_common_vsprintf_s (UCRTBASE.@)
1145 */
1147 char *str, size_t count, const char *format,
1149{
1151 FIXME("options %#I64x not handled\n", options);
1153}
1154
1155#endif /* _MSVCR_VER>=140 */
1156
1157/*********************************************************************
1158 * vsprintf (MSVCRT.@)
1159 */
1160int CDECL vsprintf( char *str, const char *format, va_list valist)
1161{
1162 return vsnprintf(str, INT_MAX, format, valist);
1163}
1164
1165/*********************************************************************
1166 * vsprintf_s (MSVCRT.@)
1167 */
1168int CDECL vsprintf_s( char *str, size_t num, const char *format, va_list valist)
1169{
1170 return vsnprintf(str, num, format, valist);
1171}
1172
1173/*********************************************************************
1174 * _vscprintf (MSVCRT.@)
1175 */
1177{
1178 return _vsnprintf_l( NULL, INT_MAX, format, NULL, valist );
1179}
1180
1181/*********************************************************************
1182 * _vscprintf_l (MSVCRT.@)
1183 */
1184int CDECL _vscprintf_l(const char *format,
1186{
1188}
1189
1190/*********************************************************************
1191 * _vscprintf_p_l (MSVCRT.@)
1192 */
1195{
1196 printf_arg args_ctx[_ARGMAX+1];
1197 struct _str_ctx_a puts_ctx = {INT_MAX, NULL};
1198 int ret;
1199
1200 memset(args_ctx, 0, sizeof(args_ctx));
1201
1202 ret = create_positional_ctx_a(args_ctx, format, args);
1203 if(ret < 0) {
1205 *_errno() = EINVAL;
1206 return ret;
1207 } else if(ret == 0) {
1208 ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale,
1211 } else {
1212 ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale,
1214 arg_clbk_positional, args_ctx, NULL);
1215 }
1216
1217 return ret;
1218}
1219
1220/*********************************************************************
1221 * _vscprintf_p (MSVCR80.@)
1222 */
1223int CDECL _vscprintf_p(const char *format, va_list argptr)
1224{
1225 return _vscprintf_p_l(format, NULL, argptr);
1226}
1227
1228/*********************************************************************
1229 * _snprintf (MSVCRT.@)
1230 */
1231int WINAPIV _snprintf(char *str, size_t len, const char *format, ...)
1232{
1233 int retval;
1237 va_end(valist);
1238 return retval;
1239}
1240
1241/*********************************************************************
1242 * _snprintf_l (MSVCRT.@)
1243 */
1244int WINAPIV _snprintf_l(char *str, size_t count, const char *format,
1245 _locale_t locale, ...)
1246{
1247 int retval;
1251 va_end(valist);
1252 return retval;
1253}
1254
1255/*********************************************************************
1256 * _snprintf_c_l (MSVCRT.@)
1257 */
1258int WINAPIV _snprintf_c_l(char *str, size_t count, const char *format,
1259 _locale_t locale, ...)
1260{
1261 int retval;
1265 va_end(valist);
1266 return retval;
1267}
1268
1269/*********************************************************************
1270 * _snprintf_c (MSVCRT.@)
1271 */
1272int WINAPIV _snprintf_c(char *str, size_t count, const char *format, ...)
1273{
1274 int retval;
1278 va_end(valist);
1279 return retval;
1280}
1281
1282/*********************************************************************
1283 * _snprintf_s_l (MSVCRT.@)
1284 */
1285int WINAPIV _snprintf_s_l(char *str, size_t len, size_t count,
1286 const char *format, _locale_t locale, ...)
1287{
1288 int retval;
1292 va_end(valist);
1293 return retval;
1294}
1295
1296/*********************************************************************
1297 * _snprintf_s (MSVCRT.@)
1298 */
1299int WINAPIV _snprintf_s(char *str, size_t len, size_t count,
1300 const char *format, ...)
1301{
1302 int retval;
1306 va_end(valist);
1307 return retval;
1308}
1309
1310/*********************************************************************
1311 * _scprintf (MSVCRT.@)
1312 */
1313int WINAPIV _scprintf(const char *format, ...)
1314{
1315 int retval;
1319 va_end(valist);
1320 return retval;
1321}
1322
1323/*********************************************************************
1324 * _scprintf_l (MSVCRT.@)
1325 */
1327{
1328 int retval;
1332 va_end(valist);
1333 return retval;
1334}
1335
1336/*********************************************************************
1337 * _scprintf_p (MSVCRT.@)
1338 */
1339int WINAPIV _scprintf_p(const char *format, ...)
1340{
1341 int retval;
1345 va_end(valist);
1346 return retval;
1347}
1348
1349/*********************************************************************
1350 * _scprintf_p_l (MSVCRT.@)
1351 */
1353{
1354 int retval;
1358 va_end(valist);
1359 return retval;
1360}
1361
1362/*********************************************************************
1363 * _vsnwprintf (MSVCRT.@)
1364 */
1365int CDECL _vsnwprintf(wchar_t *str, size_t len,
1366 const wchar_t *format, va_list valist)
1367{
1368 struct _str_ctx_w ctx = {len, str};
1369 int ret;
1370
1371 ret = pf_printf_w(puts_clbk_str_w, &ctx, format, NULL, 0,
1373 puts_clbk_str_w(&ctx, 1, L"");
1374 return ret;
1375}
1376
1377/*********************************************************************
1378 * _vsnwprintf_l (MSVCRT.@)
1379 */
1380int CDECL _vsnwprintf_l(wchar_t *str, size_t len, const wchar_t *format,
1382{
1383 struct _str_ctx_w ctx = {len, str};
1384 int ret;
1385
1386 ret = pf_printf_w(puts_clbk_str_w, &ctx, format, locale, 0,
1388 puts_clbk_str_w(&ctx, 1, L"");
1389 return ret;
1390}
1391
1392/*********************************************************************
1393 * _vswprintf_c_l (MSVCRT.@)
1394 */
1395int CDECL _vswprintf_c_l(wchar_t *str, size_t len, const wchar_t *format,
1397{
1399}
1400
1401/*********************************************************************
1402 * _vswprintf_c (MSVCRT.@)
1403 */
1404int CDECL _vswprintf_c(wchar_t *str, size_t len,
1405 const wchar_t *format, va_list valist)
1406{
1407 return _vswprintf_c_l(str, len, format, NULL, valist);
1408}
1409
1410static int vswprintf_p_l_opt(wchar_t *buffer, size_t length,
1411 const wchar_t *format, DWORD options, _locale_t locale, va_list args)
1412{
1413 printf_arg args_ctx[_ARGMAX+1];
1414 struct _str_ctx_w puts_ctx = {length, buffer};
1415 int ret;
1416
1417 memset(args_ctx, 0, sizeof(args_ctx));
1418
1419 ret = create_positional_ctx_w(args_ctx, format, args);
1420 if(ret < 0) {
1422 *_errno() = EINVAL;
1423 return ret;
1424 } else if(ret == 0)
1427 else
1428 ret = pf_printf_w(puts_clbk_str_w, &puts_ctx, format, locale,
1430 arg_clbk_positional, args_ctx, NULL);
1431
1432 puts_clbk_str_w(&puts_ctx, 1, L"");
1433 return ret;
1434}
1435
1436/*********************************************************************
1437 * _vswprintf_p_l (MSVCRT.@)
1438 */
1439int CDECL _vswprintf_p_l(wchar_t *buffer, size_t length,
1440 const wchar_t *format, _locale_t locale, va_list args)
1441{
1443}
1444
1445#if _MSVCR_VER>=80
1446/*********************************************************************
1447 * _vswprintf_p (MSVCR80.@)
1448 */
1449int CDECL _vswprintf_p(wchar_t *buffer, size_t length,
1450 const wchar_t *format, va_list args)
1451{
1453}
1454#endif
1455
1456#if _MSVCR_VER>=140
1457/*********************************************************************
1458 * __stdio_common_vswprintf_p (UCRTBASE.@)
1459 */
1461 wchar_t *str, size_t count, const wchar_t *format,
1463{
1465 FIXME("options %#I64x not handled\n", options);
1467}
1468#endif
1469
1470/*********************************************************************
1471 * _vsnwprintf_s_l (MSVCRT.@)
1472 */
1474 size_t count, const wchar_t *format,
1476{
1478}
1479
1480/*********************************************************************
1481 * _vsnwprintf_s (MSVCRT.@)
1482 */
1484 size_t count, const wchar_t *format, va_list valist)
1485{
1487 format, NULL, valist);
1488}
1489
1490/*********************************************************************
1491 * _snwprintf (MSVCRT.@)
1492 */
1493int WINAPIV _snwprintf( wchar_t *str, size_t len, const wchar_t *format, ...)
1494{
1495 int retval;
1499 va_end(valist);
1500 return retval;
1501}
1502
1503/*********************************************************************
1504 * _snwprintf_l (MSVCRT.@)
1505 */
1506int WINAPIV _snwprintf_l( wchar_t *str, size_t len, const wchar_t *format,
1507 _locale_t locale, ...)
1508{
1509 int retval;
1513 va_end(valist);
1514 return retval;
1515}
1516
1517/*********************************************************************
1518 * _snwprintf_s (MSVCRT.@)
1519 */
1520int WINAPIV _snwprintf_s( wchar_t *str, size_t len, size_t count,
1521 const wchar_t *format, ...)
1522{
1523 int retval;
1527 va_end(valist);
1528 return retval;
1529}
1530
1531/*********************************************************************
1532 * _snwprintf_s_l (MSVCRT.@)
1533 */
1534int WINAPIV _snwprintf_s_l( wchar_t *str, size_t len, size_t count,
1535 const wchar_t *format, _locale_t locale, ... )
1536{
1537 int retval;
1541 va_end(valist);
1542 return retval;
1543}
1544
1545#if _MSVCR_VER>=140
1546
1547static int puts_clbk_str_c99_w(void *ctx, int len, const wchar_t *str)
1548{
1549 struct _str_ctx_w *out = ctx;
1550
1551 if(!out->buf)
1552 return len;
1553
1554 if(out->len < len) {
1555 memcpy(out->buf, str, out->len*sizeof(wchar_t));
1556 out->buf += out->len;
1557 out->len = 0;
1558 return len;
1559 }
1560
1561 memcpy(out->buf, str, len*sizeof(wchar_t));
1562 out->buf += len;
1563 out->len -= len;
1564 return len;
1565}
1566
1567/*********************************************************************
1568 * __stdio_common_vswprintf (UCRTBASE.@)
1569 */
1571 wchar_t *str, size_t len, const wchar_t *format,
1573{
1574 struct _str_ctx_w ctx = {len, str};
1575 int ret;
1576
1578 FIXME("options %#I64x not handled\n", options);
1579 ret = pf_printf_w(puts_clbk_str_c99_w,
1581 puts_clbk_str_w(&ctx, 1, L"");
1582
1583 if(!str)
1584 return ret;
1586 return ret>len ? -1 : ret;
1587 if(ret>=len) {
1588 if(len) str[len-1] = 0;
1590 return ret;
1591 return len > 0 ? -2 : -1;
1592 }
1593 return ret;
1594}
1595
1596#endif /* _MSVCR_VER>=140 */
1597
1598/*********************************************************************
1599 * sprintf (MSVCRT.@)
1600 */
1601int WINAPIV sprintf( char *str, const char *format, ... )
1602{
1603 va_list ap;
1604 int r;
1605
1606 va_start( ap, format );
1607 r = vsnprintf( str, INT_MAX, format, ap );
1608 va_end( ap );
1609 return r;
1610}
1611
1612/*********************************************************************
1613 * sprintf_s (MSVCRT.@)
1614 */
1615int WINAPIV sprintf_s( char *str, size_t num, const char *format, ... )
1616{
1617 va_list ap;
1618 int r;
1619
1620 va_start( ap, format );
1621 r = vsnprintf( str, num, format, ap );
1622 va_end( ap );
1623 return r;
1624}
1625
1626/*********************************************************************
1627 * _scwprintf_l (MSVCRT.@)
1628 */
1629int WINAPIV _scwprintf_l( const wchar_t *format, _locale_t locale, ... )
1630{
1631 va_list ap;
1632 int r;
1633
1634 va_start( ap, locale );
1636 va_end( ap );
1637 return r;
1638}
1639
1640/*********************************************************************
1641 * _scwprintf_p_l (MSVCRT.@)
1642 */
1643int WINAPIV _scwprintf_p_l( const wchar_t *format, _locale_t locale, ... )
1644{
1645 va_list ap;
1646 int r;
1647
1648 va_start( ap, locale );
1650 va_end( ap );
1651 return r;
1652}
1653
1654#if _MSVCR_VER>=80
1655/*********************************************************************
1656 * _scwprintf_p (MSVCRT.@)
1657 */
1658int WINAPIV _scwprintf_p( const wchar_t *format, ... )
1659{
1660 va_list ap;
1661 int r;
1662
1663 va_start( ap, format );
1665 va_end( ap );
1666 return r;
1667}
1668#endif
1669
1670/*********************************************************************
1671 * _scwprintf (MSVCRT.@)
1672 */
1673int WINAPIV _scwprintf( const wchar_t *format, ... )
1674{
1675 va_list ap;
1676 int r;
1677
1678 va_start( ap, format );
1680 va_end( ap );
1681 return r;
1682}
1683
1684/*********************************************************************
1685 * swprintf (MSVCRT.@)
1686 */
1687int WINAPIV _swprintf( wchar_t *str, const wchar_t *format, ... )
1688{
1689 va_list ap;
1690 int r;
1691
1692 va_start( ap, format );
1693 r = _vsnwprintf( str, INT_MAX, format, ap );
1694 va_end( ap );
1695 return r;
1696}
1697
1698/*********************************************************************
1699 * swprintf_s (MSVCRT.@)
1700 */
1702 const wchar_t *format, ... )
1703{
1704 va_list ap;
1705 int r;
1706
1707 va_start(ap, format);
1709 va_end(ap);
1710
1711 return r;
1712}
1713
1714/*********************************************************************
1715 * _swprintf_s_l (MSVCRT.@)
1716 */
1718 const wchar_t *format, _locale_t locale, ... )
1719{
1720 va_list ap;
1721 int r;
1722
1723 va_start(ap, locale);
1725 va_end(ap);
1726
1727 return r;
1728}
1729
1730/*********************************************************************
1731 * _swprintf_c_l (MSVCRT.@)
1732 */
1733int WINAPIV _swprintf_c_l(wchar_t *str, size_t len,
1734 const wchar_t *format, _locale_t locale, ... )
1735{
1736 va_list ap;
1737 int r;
1738
1739 va_start(ap, locale);
1741 va_end(ap);
1742
1743 return r;
1744}
1745
1746/*********************************************************************
1747 * _swprintf_c (MSVCRT.@)
1748 */
1749int WINAPIV _swprintf_c(wchar_t *str, size_t len,
1750 const wchar_t *format, ... )
1751{
1752 va_list ap;
1753 int r;
1754
1755 va_start(ap, format);
1756 r = _vswprintf_c(str, len, format, ap);
1757 va_end(ap);
1758
1759 return r;
1760}
1761
1762/*********************************************************************
1763 * _vswprintf (MSVCRT.@)
1764 */
1765int CDECL _vswprintf( wchar_t* str, const wchar_t* format, va_list args )
1766{
1767 return _vsnwprintf( str, INT_MAX, format, args );
1768}
1769
1770/*********************************************************************
1771 * _vswprintf (MSVCRT.@)
1772 */
1773int CDECL _vswprintf_l( wchar_t* str, const wchar_t* format,
1775{
1776 return _vsnwprintf_l( str, INT_MAX, format, locale, args );
1777}
1778
1779/*********************************************************************
1780 * _vscwprintf (MSVCRT.@)
1781 */
1782int CDECL _vscwprintf( const wchar_t *format, va_list args )
1783{
1784 return _vsnwprintf( NULL, INT_MAX, format, args );
1785}
1786
1787/*********************************************************************
1788 * _vscwprintf_l (MSVCRT.@)
1789 */
1791{
1793}
1794
1795/*********************************************************************
1796 * _vscwprintf_p_l (MSVCRT.@)
1797 */
1799{
1801}
1802
1803#if _MSVCR_VER>=80
1804/*********************************************************************
1805 * _vscwprintf_p (MSVCR80.@)
1806 */
1807int CDECL _vscwprintf_p(const wchar_t *format, va_list args)
1808{
1810}
1811#endif
1812
1813/*********************************************************************
1814 * vswprintf_s (MSVCRT.@)
1815 */
1817 const wchar_t* format, va_list args)
1818{
1820}
1821
1822/*********************************************************************
1823 * _vswprintf_s_l (MSVCRT.@)
1824 */
1826 const wchar_t* format, _locale_t locale, va_list args)
1827{
1829 format, locale, args );
1830}
1831
1832static int vsprintf_p_l_opt(char *buffer, size_t length, const char *format,
1834{
1835 static const char nullbyte = '\0';
1836 printf_arg args_ctx[_ARGMAX+1];
1837 struct _str_ctx_a puts_ctx = {length, buffer};
1838 int ret;
1839
1840 memset(args_ctx, 0, sizeof(args_ctx));
1841
1842 ret = create_positional_ctx_a(args_ctx, format, args);
1843 if(ret < 0) {
1845 *_errno() = EINVAL;
1846 return ret;
1847 } else if(ret == 0)
1848 ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale,
1850 else
1851 ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale,
1853 arg_clbk_positional, args_ctx, NULL);
1854
1855 puts_clbk_str_a(&puts_ctx, 1, &nullbyte);
1856 return ret;
1857}
1858
1859/*********************************************************************
1860 * _vsprintf_p_l (MSVCRT.@)
1861 */
1862int CDECL _vsprintf_p_l(char *buffer, size_t length, const char *format,
1864{
1866}
1867
1868/*********************************************************************
1869 * _vsprintf_p (MSVCRT.@)
1870 */
1871int CDECL _vsprintf_p(char *buffer, size_t length,
1872 const char *format, va_list args)
1873{
1875}
1876
1877#if _MSVCR_VER>=140
1878/*********************************************************************
1879 * __stdio_common_vsprintf_p (UCRTBASE.@)
1880 */
1881int CDECL __stdio_common_vsprintf_p(unsigned __int64 options, char *buffer, size_t length,
1882 const char *format, _locale_t locale, va_list args)
1883{
1885 FIXME("options %#I64x not handled\n", options);
1887}
1888#endif
1889
1890/*********************************************************************
1891 * _sprintf_p_l (MSVCRT.@)
1892 */
1894 const char *format, _locale_t locale, ...)
1895{
1897 int r;
1898
1901 va_end(valist);
1902
1903 return r;
1904}
1905
1906/*********************************************************************
1907 * __swprintf_l (MSVCRT.@)
1908 */
1909int WINAPIV __swprintf_l( wchar_t *str, const wchar_t *format,
1910 _locale_t locale, ...)
1911{
1912 int retval;
1916 va_end(valist);
1917 return retval;
1918}
1919
1920#if _MSVCR_VER>=80
1921/*********************************************************************
1922 * _sprintf_p (MSVCR80.@)
1923 */
1924int WINAPIV _sprintf_p(char *buffer, size_t length, const char *format, ...)
1925{
1927 int r;
1928
1931 va_end(valist);
1932
1933 return r;
1934}
1935#endif
1936
1937/*********************************************************************
1938 * _swprintf_p (MSVCRT.@)
1939 */
1940int WINAPIV _swprintf_p(wchar_t *buffer, size_t length,
1941 const wchar_t *format, ...)
1942{
1944 int r;
1945
1948 va_end(valist);
1949
1950 return r;
1951}
1952
1953/*********************************************************************
1954 * _swprintf_p_l (MSVCRT.@)
1955 */
1956int WINAPIV _swprintf_p_l(wchar_t *buffer, size_t length,
1957 const wchar_t *format, _locale_t locale, ...)
1958{
1960 int r;
1961
1964 va_end(valist);
1965
1966 return r;
1967}
1968
1969/*********************************************************************
1970 * wcscmp (MSVCRT.@)
1971 */
1972int CDECL wcscmp(const wchar_t *str1, const wchar_t *str2)
1973{
1974 while (*str1 && (*str1 == *str2))
1975 {
1976 str1++;
1977 str2++;
1978 }
1979
1980 if (*str1 < *str2)
1981 return -1;
1982 if (*str1 > *str2)
1983 return 1;
1984 return 0;
1985}
1986
1987/*********************************************************************
1988 * _wcscoll_l (MSVCRT.@)
1989 */
1990int CDECL _wcscoll_l(const wchar_t* str1, const wchar_t* str2, _locale_t locale)
1991{
1993
1994 if(!locale)
1995 locinfo = get_locinfo();
1996 else
1997 locinfo = locale->locinfo;
1998
1999 if(!locinfo->lc_handle[LC_COLLATE])
2000 return wcscmp(str1, str2);
2002 str1, -1, str2, -1)-CSTR_EQUAL;
2003}
2004
2005/*********************************************************************
2006 * wcscoll (MSVCRT.@)
2007 */
2008int CDECL wcscoll( const wchar_t* str1, const wchar_t* str2 )
2009{
2010 return _wcscoll_l(str1, str2, NULL);
2011}
2012
2013/*********************************************************************
2014 * wcspbrk (MSVCRT.@)
2015 */
2016wchar_t* CDECL wcspbrk( const wchar_t* str, const wchar_t* accept )
2017{
2018 const wchar_t* p;
2019
2020 while (*str)
2021 {
2022 for (p = accept; *p; p++) if (*p == *str) return (wchar_t*)str;
2023 str++;
2024 }
2025 return NULL;
2026}
2027
2028/*********************************************************************
2029 * wcstok_s (MSVCRT.@)
2030 */
2031wchar_t * CDECL wcstok_s( wchar_t *str, const wchar_t *delim,
2032 wchar_t **next_token )
2033{
2034 wchar_t *ret;
2035
2036 if (!MSVCRT_CHECK_PMT(delim != NULL)) return NULL;
2037 if (!MSVCRT_CHECK_PMT(next_token != NULL)) return NULL;
2038 if (!MSVCRT_CHECK_PMT(str != NULL || *next_token != NULL)) return NULL;
2039
2040 if (!str) str = *next_token;
2041
2042 while (*str && wcschr( delim, *str )) str++;
2043 if (!*str) ret = NULL;
2044 else
2045 {
2046 ret = str++;
2047 while (*str && !wcschr( delim, *str )) str++;
2048 if (*str) *str++ = 0;
2049 }
2050 *next_token = str;
2051 return ret;
2052}
2053
2054/*********************************************************************
2055 * wcstok (MSVCRT.@)
2056 */
2057#if _MSVCR_VER>=140
2058wchar_t * CDECL wcstok( wchar_t *str, const wchar_t *delim, wchar_t **ctx )
2059{
2060 if (!ctx)
2061 ctx = &msvcrt_get_thread_data()->wcstok_next;
2062 return wcstok_s(str, delim, ctx);
2063}
2064#else
2065wchar_t * CDECL wcstok( wchar_t *str, const wchar_t *delim )
2066{
2067 return wcstok_s(str, delim, &msvcrt_get_thread_data()->wcstok_next);
2068}
2069#endif
2070
2071/*********************************************************************
2072 * _wctomb_s_l (MSVCRT.@)
2073 */
2074int CDECL _wctomb_s_l(int *len, char *mbchar, size_t size,
2075 wchar_t wch, _locale_t locale)
2076{
2078 BOOL error = FALSE;
2079 BOOL *perror;
2080 int mblen;
2081
2082 if(!mbchar && size>0) {
2083 if(len)
2084 *len = 0;
2085 return 0;
2086 }
2087
2088 if(len)
2089 *len = -1;
2090
2092 return EINVAL;
2093
2094 if(!locale)
2095 locinfo = get_locinfo();
2096 else
2097 locinfo = locale->locinfo;
2098
2099 if(!locinfo->lc_codepage) {
2100 if(wch > 0xff) {
2101 if(mbchar && size>0)
2102 memset(mbchar, 0, size);
2103 *_errno() = EILSEQ;
2104 return EILSEQ;
2105 }
2106
2107 if(!MSVCRT_CHECK_PMT_ERR(size >= 1, ERANGE))
2108 return ERANGE;
2109
2110 *mbchar = wch;
2111 if(len)
2112 *len = 1;
2113 return 0;
2114 }
2115
2116 perror = (locinfo->lc_codepage != CP_UTF8 ? &error : NULL);
2117 mblen = WideCharToMultiByte(locinfo->lc_codepage, 0, &wch, 1, mbchar, size, NULL, perror);
2118 if(!mblen || error) {
2120 if(mbchar && size>0)
2121 memset(mbchar, 0, size);
2122
2123 MSVCRT_INVALID_PMT("insufficient buffer size", ERANGE);
2124 return ERANGE;
2125 }
2126
2127 *_errno() = EILSEQ;
2128 return EILSEQ;
2129 }
2130
2131 if(len)
2132 *len = mblen;
2133 return 0;
2134}
2135
2136/*********************************************************************
2137 * wctomb_s (MSVCRT.@)
2138 */
2139int CDECL wctomb_s(int *len, char *mbchar, size_t size, wchar_t wch)
2140{
2141 return _wctomb_s_l(len, mbchar, size, wch, NULL);
2142}
2143
2144/*********************************************************************
2145 * _wctomb_l (MSVCRT.@)
2146 */
2147int CDECL _wctomb_l(char *dst, wchar_t ch, _locale_t locale)
2148{
2149 int len;
2150#ifdef __REACTOS__
2151 int maxlen;
2152 if (locale)
2153 maxlen = locale->locinfo->mb_cur_max;
2154 else
2155 maxlen = get_locinfo()->mb_cur_max;
2156 if (_wctomb_s_l(&len, dst, maxlen, ch, locale) != 0)
2157 return -1;
2158#else
2160#endif
2161 return len;
2162}
2163
2164/*********************************************************************
2165 * wctomb (MSVCRT.@)
2166 */
2167INT CDECL wctomb( char *dst, wchar_t ch )
2168{
2169 return _wctomb_l(dst, ch, NULL);
2170}
2171
2172/*********************************************************************
2173 * wctob (MSVCRT.@)
2174 */
2176{
2177 char out;
2178 BOOL error = FALSE;
2179 BOOL *perror;
2180 UINT codepage = get_locinfo()->lc_codepage;
2181
2182 perror = (codepage != CP_UTF8 ? &error : NULL);
2183
2184 if(!codepage) {
2185 if (wchar < 0xff)
2186 return (signed char)wchar;
2187 else
2188 return EOF;
2189 } else if(WideCharToMultiByte( codepage, 0, &wchar, 1, &out, 1, NULL, perror ) && !error)
2190 return (INT)out;
2191 return EOF;
2192}
2193
2194/*********************************************************************
2195 * wcrtomb_s (MSVCRT.@)
2196 */
2197INT CDECL wcrtomb_s(size_t *len, char *mbchar,
2198 size_t size, wchar_t wch, mbstate_t *s)
2199{
2200 int ilen, ret;
2201
2202 if (s) *s = 0;
2203 ret = wctomb_s(&ilen, mbchar, size, wch);
2204 if (len) *len = ilen;
2205 return ret;
2206}
2207
2208/*********************************************************************
2209 * wcrtomb (MSVCRT.@)
2210 */
2211size_t CDECL wcrtomb( char *dst, wchar_t ch, mbstate_t *s)
2212{
2213 if(s)
2214 *s = 0;
2215 return wctomb(dst, ch);
2216}
2217
2218/*********************************************************************
2219 * _iswctype_l (MSVCRT.@)
2220 */
2222{
2223 WORD ct;
2224
2225 if (wc == WEOF) return 0;
2226 if (wc < 256) return MSVCRT__pwctype[wc] & type;
2227
2228 if (!GetStringTypeW(CT_CTYPE1, &wc, 1, &ct))
2229 {
2230 ERR("GetStringTypeW failed for %x\n", wc);
2231 return 0;
2232 }
2233 return ct & type;
2234}
2235
2236/*********************************************************************
2237 * iswctype (MSVCRT.@)
2238 */
2240{
2241 return _iswctype_l( wc, type, NULL );
2242}
2243
2244/*********************************************************************
2245 * _iswalnum_l (MSVCRT.@)
2246 */
2248{
2249 return _iswctype_l( wc, _ALPHA | _DIGIT, locale );
2250}
2251
2252/*********************************************************************
2253 * iswalnum (MSVCRT.@)
2254 */
2255INT CDECL iswalnum( wchar_t wc )
2256{
2257 return _iswalnum_l( wc, NULL );
2258}
2259
2260/*********************************************************************
2261 * iswalpha_l (MSVCRT.@)
2262 */
2264{
2265 return _iswctype_l( wc, _ALPHA, locale );
2266}
2267
2268/*********************************************************************
2269 * iswalpha (MSVCRT.@)
2270 */
2271INT CDECL iswalpha( wchar_t wc )
2272{
2273 return _iswalpha_l( wc, NULL );
2274}
2275
2276/*********************************************************************
2277 * _iswcntrl_l (MSVCRT.@)
2278 */
2280{
2281 return _iswctype_l( wc, _CONTROL, locale );
2282}
2283
2284/*********************************************************************
2285 * iswcntrl (MSVCRT.@)
2286 */
2287INT CDECL iswcntrl( wchar_t wc )
2288{
2289 return _iswcntrl_l( wc, NULL );
2290}
2291
2292/*********************************************************************
2293 * _iswdigit_l (MSVCRT.@)
2294 */
2296{
2297 return _iswctype_l( wc, _DIGIT, locale );
2298}
2299
2300/*********************************************************************
2301 * iswdigit (MSVCRT.@)
2302 */
2303INT CDECL iswdigit( wchar_t wc )
2304{
2305 return _iswdigit_l( wc, NULL );
2306}
2307
2308/*********************************************************************
2309 * _iswgraph_l (MSVCRT.@)
2310 */
2312{
2313 return _iswctype_l( wc, _ALPHA | _DIGIT | _PUNCT, locale );
2314}
2315
2316/*********************************************************************
2317 * iswgraph (MSVCRT.@)
2318 */
2319INT CDECL iswgraph( wchar_t wc )
2320{
2321 return _iswgraph_l( wc, NULL );
2322}
2323
2324/*********************************************************************
2325 * _iswlower_l (MSVCRT.@)
2326 */
2328{
2329 return _iswctype_l( wc, _LOWER, locale );
2330}
2331
2332/*********************************************************************
2333 * iswlower (MSVCRT.@)
2334 */
2335INT CDECL iswlower( wchar_t wc )
2336{
2337 return _iswlower_l( wc, NULL );
2338}
2339
2340/*********************************************************************
2341 * _iswprint_l (MSVCRT.@)
2342 */
2344{
2345 return _iswctype_l( wc, _ALPHA | _BLANK | _DIGIT | _PUNCT, locale );
2346}
2347
2348/*********************************************************************
2349 * iswprint (MSVCRT.@)
2350 */
2351INT CDECL iswprint( wchar_t wc )
2352{
2353 return _iswprint_l( wc, NULL );
2354}
2355
2356/*********************************************************************
2357 * _iswpunct_l (MSVCRT.@)
2358 */
2360{
2361 return _iswctype_l( wc, _PUNCT, locale );
2362}
2363
2364/*********************************************************************
2365 * iswpunct (MSVCRT.@)
2366 */
2367INT CDECL iswpunct( wchar_t wc )
2368{
2369 return _iswpunct_l( wc, NULL );
2370}
2371
2372/*********************************************************************
2373 * _iswspace_l (MSVCRT.@)
2374 */
2376{
2377 return _iswctype_l( wc, _SPACE, locale );
2378}
2379
2380/*********************************************************************
2381 * iswspace (MSVCRT.@)
2382 */
2383INT CDECL iswspace( wchar_t wc )
2384{
2385 return _iswspace_l( wc, NULL );
2386}
2387
2388/*********************************************************************
2389 * _iswupper_l (MSVCRT.@)
2390 */
2392{
2393 return _iswctype_l( wc, _UPPER, locale );
2394}
2395
2396/*********************************************************************
2397 * iswupper (MSVCRT.@)
2398 */
2399INT CDECL iswupper( wchar_t wc )
2400{
2401 return _iswupper_l( wc, NULL );
2402}
2403
2404/*********************************************************************
2405 * _iswxdigit_l (MSVCRT.@)
2406 */
2408{
2409 return _iswctype_l( wc, _HEX, locale );
2410}
2411
2412/*********************************************************************
2413 * iswxdigit (MSVCRT.@)
2414 */
2415INT CDECL iswxdigit( wchar_t wc )
2416{
2417 return _iswxdigit_l( wc, NULL );
2418}
2419
2420/*********************************************************************
2421 * _iswblank_l (MSVCRT.@)
2422 */
2424{
2425 return wc == '\t' || _iswctype_l( wc, _BLANK, locale );
2426}
2427
2428/*********************************************************************
2429 * iswblank (MSVCRT.@)
2430 */
2431INT CDECL iswblank( wchar_t wc )
2432{
2433 return wc == '\t' || _iswctype_l( wc, _BLANK, NULL );
2434}
2435
2436/*********************************************************************
2437 * wcscpy_s (MSVCRT.@)
2438 */
2439INT CDECL wcscpy_s( wchar_t* wcDest, size_t numElement, const wchar_t *wcSrc)
2440{
2441 size_t size = 0;
2442
2443 if(!MSVCRT_CHECK_PMT(wcDest)) return EINVAL;
2444 if(!MSVCRT_CHECK_PMT(numElement)) return EINVAL;
2445
2447 {
2448 wcDest[0] = 0;
2449 return EINVAL;
2450 }
2451
2452 size = wcslen(wcSrc) + 1;
2453
2454 if(!MSVCRT_CHECK_PMT_ERR(size <= numElement, ERANGE))
2455 {
2456 wcDest[0] = 0;
2457 return ERANGE;
2458 }
2459
2460 memmove( wcDest, wcSrc, size*sizeof(WCHAR) );
2461
2462 return 0;
2463}
2464
2465/***********************************************************************
2466 * wcscpy (MSVCRT.@)
2467 */
2468wchar_t* __cdecl wcscpy( wchar_t *dst, const wchar_t *src )
2469{
2470 WCHAR *p = dst;
2471 while ((*p++ = *src++));
2472 return dst;
2473}
2474
2475/******************************************************************
2476 * wcsncpy (MSVCRT.@)
2477 */
2478wchar_t* __cdecl wcsncpy( wchar_t* s1, const wchar_t *s2, size_t n )
2479{
2480 size_t i;
2481
2482 for(i=0; i<n; i++)
2483 if(!(s1[i] = s2[i])) break;
2484 for(; i<n; i++)
2485 s1[i] = 0;
2486 return s1;
2487}
2488
2489/******************************************************************
2490 * wcsncpy_s (MSVCRT.@)
2491 */
2492INT CDECL wcsncpy_s( wchar_t *dst, size_t elem, const wchar_t *src, size_t count )
2493{
2494 WCHAR *p = dst;
2495 BOOL truncate = (count == _TRUNCATE);
2496
2497 if (!count)
2498 {
2499 if (dst && elem) *dst = 0;
2500 return 0;
2501 }
2502
2503 if (!MSVCRT_CHECK_PMT(dst != NULL)) return EINVAL;
2504 if (!MSVCRT_CHECK_PMT(elem != 0)) return EINVAL;
2505 if (!MSVCRT_CHECK_PMT(src != NULL))
2506 {
2507 *dst = 0;
2508 return EINVAL;
2509 }
2510
2511 while (elem && count && *src)
2512 {
2513 *p++ = *src++;
2514 elem--;
2515 count--;
2516 }
2517 if (!elem && truncate)
2518 {
2519 *(p-1) = 0;
2520 return STRUNCATE;
2521 }
2522 else if (!elem)
2523 {
2524 *dst = 0;
2525 return ERANGE;
2526 }
2527 *p = 0;
2528 return 0;
2529}
2530
2531/******************************************************************
2532 * wcscat_s (MSVCRT.@)
2533 *
2534 */
2535INT CDECL wcscat_s(wchar_t* dst, size_t elem, const wchar_t* src)
2536{
2537 wchar_t* ptr = dst;
2538
2539 if (!dst || elem == 0) return EINVAL;
2540 if (!src)
2541 {
2542 dst[0] = '\0';
2543 return EINVAL;
2544 }
2545
2546 /* seek to end of dst string (or elem if no end of string is found */
2547 while (ptr < dst + elem && *ptr != '\0') ptr++;
2548 while (ptr < dst + elem)
2549 {
2550 if ((*ptr++ = *src++) == '\0') return 0;
2551 }
2552 /* not enough space */
2553 dst[0] = '\0';
2554 return ERANGE;
2555}
2556
2557/***********************************************************************
2558 * wcscat (MSVCRT.@)
2559 */
2560wchar_t* __cdecl wcscat( wchar_t *dst, const wchar_t *src )
2561{
2562 wcscpy( dst + wcslen(dst), src );
2563 return dst;
2564}
2565
2566/*********************************************************************
2567 * wcsncat_s (MSVCRT.@)
2568 */
2569errno_t CDECL wcsncat_s(wchar_t *dst, size_t elem, const wchar_t *src, size_t count)
2570{
2571 size_t i, j;
2572
2573 if (!MSVCRT_CHECK_PMT(dst != NULL)) return EINVAL;
2574 if (!MSVCRT_CHECK_PMT(elem > 0)) return EINVAL;
2575 if (count == 0) return 0;
2576 if (!MSVCRT_CHECK_PMT(src != NULL))
2577 {
2578 *dst = 0;
2579 return EINVAL;
2580 }
2581
2582 for (i = 0; i < elem; i++) if (!dst[i]) break;
2583
2584 if (i == elem)
2585 {
2586 MSVCRT_INVALID_PMT("dst[elem] is not NULL terminated\n", EINVAL);
2587 *dst = 0;
2588 return EINVAL;
2589 }
2590
2591 for (j = 0; (j + i) < elem; j++)
2592 {
2593 if(count == _TRUNCATE && j + i == elem - 1)
2594 {
2595 dst[j + i] = '\0';
2596 return STRUNCATE;
2597 }
2598 if(j == count || (dst[j + i] = src[j]) == '\0')
2599 {
2600 dst[j + i] = '\0';
2601 return 0;
2602 }
2603 }
2604
2605 MSVCRT_INVALID_PMT("dst[elem] is too small", ERANGE);
2606 dst[0] = '\0';
2607 return ERANGE;
2608}
2609
2610/*********************************************************************
2611 * wcsncat (NTDLL.@)
2612 */
2613wchar_t * __cdecl wcsncat(wchar_t *s1, const wchar_t *s2, size_t n)
2614{
2615 wchar_t *ret = s1;
2616 while (*s1) s1++;
2617 while (n-- > 0) if (!(*s1++ = *s2++)) return ret;
2618 *s1 = 0;
2619 return ret;
2620}
2621
2622/*********************************************************************
2623 * wctoint (INTERNAL)
2624 */
2625static int wctoint(WCHAR c, int base)
2626{
2627 int v = -1;
2628 if ('0' <= c && c <= '9')
2629 v = c - '0';
2630 else if ('A' <= c && c <= 'Z')
2631 v = c - 'A' + 10;
2632 else if ('a' <= c && c <= 'z')
2633 v = c - 'a' + 10;
2634 else {
2635 /* NOTE: MAP_FOLDDIGITS supports too many things. */
2636 /* Unicode points that contain digits 0-9; keep this sorted! */
2637 static const WCHAR zeros[] = {
2638 0x660, 0x6f0, 0x966, 0x9e6, 0xa66, 0xae6, 0xb66, 0xc66, 0xce6,
2639 0xd66, 0xe50, 0xed0, 0xf20, 0x1040, 0x17e0, 0x1810, 0xff10
2640 };
2641 int i;
2642 for (i = 0; i < ARRAY_SIZE(zeros) && c >= zeros[i]; ++i) {
2643 if (zeros[i] <= c && c <= zeros[i] + 9) {
2644 v = c - zeros[i];
2645 break;
2646 }
2647 }
2648 }
2649 return v < base ? v : -1;
2650}
2651
2652/*********************************************************************
2653 * _wcstoi64_l (MSVCRT.@)
2654 */
2655__int64 CDECL _wcstoi64_l(const wchar_t *nptr,
2656 wchar_t **endptr, int base, _locale_t locale)
2657{
2658 BOOL negative = FALSE, empty = TRUE;
2659 __int64 ret = 0;
2660
2661 TRACE("(%s %p %d %p)\n", debugstr_w(nptr), endptr, base, locale);
2662
2663 if (!MSVCRT_CHECK_PMT(nptr != NULL)) return 0;
2664 if (!MSVCRT_CHECK_PMT(base == 0 || base >= 2)) return 0;
2665 if (!MSVCRT_CHECK_PMT(base <= 36)) return 0;
2666
2667 if(endptr)
2668 *endptr = (wchar_t*)nptr;
2669
2670 while(_iswspace_l(*nptr, locale)) nptr++;
2671
2672 if(*nptr == '-') {
2673 negative = TRUE;
2674 nptr++;
2675 } else if(*nptr == '+')
2676 nptr++;
2677
2678 if((base==0 || base==16) && wctoint(*nptr, 1)==0 && (nptr[1]=='x' || nptr[1]=='X')) {
2679 base = 16;
2680 nptr += 2;
2681 }
2682
2683 if(base == 0) {
2684 if(wctoint(*nptr, 1)==0)
2685 base = 8;
2686 else
2687 base = 10;
2688 }
2689
2690 while(*nptr) {
2691 int v = wctoint(*nptr, base);
2692 if(v<0)
2693 break;
2694
2695 if(negative)
2696 v = -v;
2697
2698 nptr++;
2699 empty = FALSE;
2700
2701 if(!negative && (ret>I64_MAX/base || ret*base>I64_MAX-v)) {
2702 ret = I64_MAX;
2703 *_errno() = ERANGE;
2704 } else if(negative && (ret<I64_MIN/base || ret*base<I64_MIN-v)) {
2705 ret = I64_MIN;
2706 *_errno() = ERANGE;
2707 } else
2708 ret = ret*base + v;
2709 }
2710
2711 if(endptr && !empty)
2712 *endptr = (wchar_t*)nptr;
2713
2714 return ret;
2715}
2716
2717/*********************************************************************
2718 * _wcstoi64 (MSVCRT.@)
2719 */
2720__int64 CDECL _wcstoi64(const wchar_t *nptr,
2721 wchar_t **endptr, int base)
2722{
2723 return _wcstoi64_l(nptr, endptr, base, NULL);
2724}
2725
2726/*********************************************************************
2727 * _wcstol_l (MSVCRT.@)
2728 */
2730 wchar_t **end, int base, _locale_t locale)
2731{
2733
2734 if(ret > LONG_MAX) {
2735 ret = LONG_MAX;
2736 *_errno() = ERANGE;
2737 }else if(ret < LONG_MIN) {
2738 ret = LONG_MIN;
2739 *_errno() = ERANGE;
2740 }
2741 return ret;
2742}
2743
2744/*********************************************************************
2745 * wcstol (MSVCRT.@)
2746 */
2748 wchar_t **end, int base)
2749{
2750 return _wcstol_l(s, end, base, NULL);
2751}
2752
2753/*********************************************************************
2754 * _wtoi_l (MSVCRT.@)
2755 */
2756int __cdecl _wtoi_l(const wchar_t *str, _locale_t locale)
2757{
2759
2760 if(ret > INT_MAX) {
2761 ret = INT_MAX;
2762 *_errno() = ERANGE;
2763 } else if(ret < INT_MIN) {
2764 ret = INT_MIN;
2765 *_errno() = ERANGE;
2766 }
2767 return ret;
2768}
2769
2770/*********************************************************************
2771 * _wtoi (MSVCRT.@)
2772 */
2773int __cdecl _wtoi(const wchar_t *str)
2774{
2775 return _wtoi_l(str, NULL);
2776}
2777
2778/*********************************************************************
2779 * _wtol_l (MSVCRT.@)
2780 */
2782{
2784
2785 if(ret > LONG_MAX) {
2786 ret = LONG_MAX;
2787 *_errno() = ERANGE;
2788 } else if(ret < LONG_MIN) {
2789 ret = LONG_MIN;
2790 *_errno() = ERANGE;
2791 }
2792 return ret;
2793}
2794
2795/*********************************************************************
2796 * _wtol (MSVCRT.@)
2797 */
2799{
2800 return _wtol_l(str, NULL);
2801}
2802
2803#if _MSVCR_VER>=120
2804
2805/*********************************************************************
2806 * _wtoll_l (MSVCR120.@)
2807 */
2808__int64 __cdecl _wtoll_l(const wchar_t *str, _locale_t locale)
2809{
2810 return _wcstoi64_l(str, NULL, 10, locale);
2811}
2812
2813/*********************************************************************
2814 * _wtoll (MSVCR120.@)
2815 */
2816__int64 __cdecl _wtoll(const wchar_t *str)
2817{
2818 return _wtoll_l(str, NULL);
2819}
2820
2821#endif /* _MSVCR_VER>=120 */
2822
2823/*********************************************************************
2824 * _wcstoui64_l (MSVCRT.@)
2825 */
2826unsigned __int64 CDECL _wcstoui64_l(const wchar_t *nptr,
2827 wchar_t **endptr, int base, _locale_t locale)
2828{
2829 BOOL negative = FALSE, empty = TRUE;
2830 unsigned __int64 ret = 0;
2831
2832 TRACE("(%s %p %d %p)\n", debugstr_w(nptr), endptr, base, locale);
2833
2834 if (!MSVCRT_CHECK_PMT(nptr != NULL)) return 0;
2835 if (!MSVCRT_CHECK_PMT(base == 0 || base >= 2)) return 0;
2836 if (!MSVCRT_CHECK_PMT(base <= 36)) return 0;
2837
2838 if(endptr)
2839 *endptr = (wchar_t*)nptr;
2840
2841 while(_iswspace_l(*nptr, locale)) nptr++;
2842
2843 if(*nptr == '-') {
2844 negative = TRUE;
2845 nptr++;
2846 } else if(*nptr == '+')
2847 nptr++;
2848
2849 if((base==0 || base==16) && wctoint(*nptr, 1)==0 && (nptr[1]=='x' || nptr[1]=='X')) {
2850 base = 16;
2851 nptr += 2;
2852 }
2853
2854 if(base == 0) {
2855 if(wctoint(*nptr, 1)==0)
2856 base = 8;
2857 else
2858 base = 10;
2859 }
2860
2861 while(*nptr) {
2862 int v = wctoint(*nptr, base);
2863 if(v<0)
2864 break;
2865
2866 nptr++;
2867 empty = FALSE;
2868
2869 if(ret>UI64_MAX/base || ret*base>UI64_MAX-v) {
2870 ret = UI64_MAX;
2871 *_errno() = ERANGE;
2872 } else
2873 ret = ret*base + v;
2874 }
2875
2876 if(endptr && !empty)
2877 *endptr = (wchar_t*)nptr;
2878
2879 return negative ? -ret : ret;
2880}
2881
2882/*********************************************************************
2883 * _wcstoui64 (MSVCRT.@)
2884 */
2885unsigned __int64 CDECL _wcstoui64(const wchar_t *nptr,
2886 wchar_t **endptr, int base)
2887{
2888 return _wcstoui64_l(nptr, endptr, base, NULL);
2889}
2890
2891/*********************************************************************
2892 * _wcstoul_l (MSVCRT.@)
2893 */
2895 wchar_t **end, int base, _locale_t locale)
2896{
2898
2899 if(ret > ULONG_MAX) {
2900 ret = ULONG_MAX;
2901 *_errno() = ERANGE;
2902 }else if(ret < -(__int64)ULONG_MAX) {
2903 ret = 1;
2904 *_errno() = ERANGE;
2905 }
2906 return ret;
2907}
2908
2909/*********************************************************************
2910 * wcstoul (MSVCRT.@)
2911 */
2912__msvcrt_ulong __cdecl wcstoul(const wchar_t *s, wchar_t **end, int base)
2913{
2914 return _wcstoul_l(s, end, base, NULL);
2915}
2916
2917/******************************************************************
2918 * wcsnlen (MSVCRT.@)
2919 */
2920size_t CDECL wcsnlen(const wchar_t *s, size_t maxlen)
2921{
2922 size_t i;
2923
2924 for (i = 0; i < maxlen; i++)
2925 if (!s[i]) break;
2926 return i;
2927}
2928
2929/*********************************************************************
2930 * _towupper_l (MSVCRT.@)
2931 */
2933{
2935 wchar_t ret;
2936
2937 if(!locale)
2938 locinfo = get_locinfo();
2939 else
2940 locinfo = locale->locinfo;
2941
2942 if(!locinfo->lc_handle[LC_CTYPE]) {
2943 if(c >= 'a' && c <= 'z')
2944 return c + 'A' - 'a';
2945 return c;
2946 }
2947
2948 if(!LCMapStringW(locinfo->lc_handle[LC_CTYPE], LCMAP_UPPERCASE, &c, 1, &ret, 1))
2949 return c;
2950 return ret;
2951}
2952
2953/*********************************************************************
2954 * towupper (MSVCRT.@)
2955 */
2957{
2958 return _towupper_l(c, NULL);
2959}
2960
2961/*********************************************************************
2962 * wcschr (MSVCRT.@)
2963 */
2964wchar_t* CDECL wcschr(const wchar_t *str, wchar_t ch)
2965{
2966 do { if (*str == ch) return (WCHAR *)(ULONG_PTR)str; } while (*str++);
2967 return NULL;
2968}
2969
2970/*********************************************************************
2971 * wcsrchr (MSVCRT.@)
2972 */
2973wchar_t* CDECL wcsrchr(const wchar_t *str, wchar_t ch)
2974{
2975 WCHAR *ret = NULL;
2976 do { if (*str == ch) ret = (WCHAR *)(ULONG_PTR)str; } while (*str++);
2977 return ret;
2978}
2979
2980/***********************************************************************
2981 * wcslen (MSVCRT.@)
2982 */
2983size_t CDECL wcslen(const wchar_t *str)
2984{
2985 const wchar_t *s = str;
2986 while (*s) s++;
2987 return s - str;
2988}
2989
2990/*********************************************************************
2991 * wcsstr (MSVCRT.@)
2992 */
2993wchar_t* CDECL wcsstr(const wchar_t *str, const wchar_t *sub)
2994{
2995 while(*str)
2996 {
2997 const wchar_t *p1 = str, *p2 = sub;
2998 while(*p1 && *p2 && *p1 == *p2)
2999 {
3000 p1++;
3001 p2++;
3002 }
3003 if(!*p2)
3004 return (wchar_t*)str;
3005 str++;
3006 }
3007 return NULL;
3008}
3009
3010/*********************************************************************
3011 * _wtoi64_l (MSVCRT.@)
3012 */
3014{
3015 ULONGLONG RunningTotal = 0;
3016 BOOL bMinus = FALSE;
3017
3018 while (_iswspace_l(*str, locale)) {
3019 str++;
3020 } /* while */
3021
3022 if (*str == '+') {
3023 str++;
3024 } else if (*str == '-') {
3025 bMinus = TRUE;
3026 str++;
3027 } /* if */
3028
3029 while (*str >= '0' && *str <= '9') {
3030 RunningTotal = RunningTotal * 10 + *str - '0';
3031 str++;
3032 } /* while */
3033
3034 return bMinus ? -RunningTotal : RunningTotal;
3035}
3036
3037/*********************************************************************
3038 * _wtoi64 (MSVCRT.@)
3039 */
3040__int64 CDECL _wtoi64(const wchar_t *str)
3041{
3042 return _wtoi64_l(str, NULL);
3043}
3044
3045/*********************************************************************
3046 * _wcsxfrm_l (MSVCRT.@)
3047 */
3048size_t CDECL _wcsxfrm_l(wchar_t *dest, const wchar_t *src,
3049 size_t len, _locale_t locale)
3050{
3052 int i, ret;
3053
3054 if(!MSVCRT_CHECK_PMT(src)) return INT_MAX;
3055 if(!MSVCRT_CHECK_PMT(dest || !len)) return INT_MAX;
3056
3057 if(len > INT_MAX) {
3058 FIXME("len > INT_MAX not supported\n");
3059 len = INT_MAX;
3060 }
3061
3062 if(!locale)
3063 locinfo = get_locinfo();
3064 else
3065 locinfo = locale->locinfo;
3066
3067 if(!locinfo->lc_handle[LC_COLLATE]) {
3068 wcsncpy(dest, src, len);
3069 return wcslen(src);
3070 }
3071
3072 ret = LCMapStringW(locinfo->lc_handle[LC_COLLATE],
3073 LCMAP_SORTKEY, src, -1, NULL, 0);
3074 if(!ret) {
3075 if(len) dest[0] = 0;
3076 *_errno() = EILSEQ;
3077 return INT_MAX;
3078 }
3079 if(!len) return ret-1;
3080
3081 if(ret > len) {
3082 dest[0] = 0;
3083 *_errno() = ERANGE;
3084 return ret-1;
3085 }
3086
3087 ret = LCMapStringW(locinfo->lc_handle[LC_COLLATE],
3088 LCMAP_SORTKEY, src, -1, dest, len) - 1;
3089 for(i=ret; i>=0; i--)
3090 dest[i] = ((unsigned char*)dest)[i];
3091 return ret;
3092}
3093
3094/*********************************************************************
3095 * wcsxfrm (MSVCRT.@)
3096 */
3097size_t CDECL wcsxfrm(wchar_t *dest, const wchar_t *src, size_t len)
3098{
3099 return _wcsxfrm_l(dest, src, len, NULL);
3100}
unsigned char BOOLEAN
long long __cdecl _wtoll(wchar_t const *const string)
Definition: atox.cpp:89
long long __cdecl _wtoll_l(wchar_t const *const string, _locale_t const locale)
Definition: atox.cpp:94
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
Definition: _locale.h:75
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define malloc
Definition: debug_ros.c:4
int next_token(char **, FILE *)
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ Sign
Definition: msg.c:1064
static const WCHAR empty[]
Definition: main.c:47
#define CDECL
Definition: compat.h:29
#define wcschr
Definition: compat.h:17
#define wcsrchr
Definition: compat.h:16
#define WideCharToMultiByte
Definition: compat.h:111
@ VT_INT
Definition: compat.h:2316
@ VT_PTR
Definition: compat.h:2320
@ VT_R8
Definition: compat.h:2300
@ VT_I8
Definition: compat.h:2314
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: locale.c:4017
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
unsigned char ch[4][2]
Definition: console.c:118
WORD * MSVCRT__pwctype
Definition: ctype.c:128
void CDECL perror(const char *str)
Definition: errno.c:337
void __cdecl _invalid_parameter(const wchar_t *expr, const wchar_t *func, const wchar_t *file, unsigned int line, uintptr_t arg)
Definition: errno.c:461
int *CDECL _errno(void)
Definition: errno.c:215
int errno_t
Definition: corecrt.h:249
long __msvcrt_long
Definition: corecrt.h:167
#define __cdecl
Definition: corecrt.h:121
#define _ARGMAX
Definition: corecrt.h:157
unsigned short wint_t
Definition: corecrt.h:243
unsigned short wctype_t
Definition: corecrt.h:244
#define __int64
Definition: corecrt.h:72
unsigned long __msvcrt_ulong
Definition: corecrt.h:168
#define _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION
#define _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR
#define _BLANK
#define _PUNCT
#define _CONTROL
#define _LOWER
#define _SPACE
#define _ALPHA
#define _UPPER
#define _HEX
#define _DIGIT
#define WEOF
_ACRTIMP float __cdecl wcstof(const wchar_t *, wchar_t **)
Definition: strtod.cpp:114
_ACRTIMP float __cdecl _wcstof_l(const wchar_t *, wchar_t **, _locale_t)
Definition: strtod.cpp:122
#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 I64_MIN
Definition: limits.h:41
#define INT_MIN
Definition: limits.h:25
#define ULONG_MAX
Definition: limits.h:31
#define LONG_MAX
Definition: limits.h:30
#define I64_MAX
Definition: limits.h:42
#define UI64_MAX
Definition: limits.h:43
#define MB_LEN_MAX
Definition: limits.h:7
#define INT_MAX
Definition: limits.h:26
#define LONG_MIN
Definition: limits.h:29
#define LC_CTYPE
Definition: locale.h:27
#define LC_COLLATE
Definition: locale.h:26
#define isfinite(x)
Definition: math.h:363
#define _NLSCMPERROR
Definition: mbstring.h:28
#define va_end(v)
Definition: stdarg.h:28
#define va_arg(v, l)
Definition: stdarg.h:27
#define va_start(v, l)
Definition: stdarg.h:26
_ACRTIMP int __cdecl _set_printf_count_output(int)
Definition: stubs.c:10
#define EOF
Definition: stdio.h:33
_ACRTIMP int __cdecl _get_printf_count_output(void)
Definition: stubs.c:5
_ACRTIMP int __cdecl mblen(const char *, size_t)
Definition: mbcs.c:3087
#define _TRUNCATE
Definition: stdlib.h:45
char * va_list
Definition: vadefs.h:50
int mbstate_t
Definition: wchar.h:30
wchar_t wctrans_t
Definition: wctype.h:71
_locale_t CDECL get_current_locale_noalloc(_locale_t locale)
Definition: locale.c:1149
void CDECL free_locale_noalloc(_locale_t locale)
Definition: locale.c:1162
thread_data_t *CDECL msvcrt_get_thread_data(void)
Definition: thread.c:45
#define UCRTBASE_PRINTF_MASK
Definition: msvcrt.h:401
int create_positional_ctx_w(void *, const wchar_t *, va_list)
int pf_printf_a(puts_clbk_a, void *, const char *, _locale_t, DWORD, args_clbk, void *, va_list *)
#define MSVCRT_PRINTF_POSITIONAL_PARAMS
Definition: msvcrt.h:409
#define MSVCRT_INVALID_PMT(x, err)
Definition: msvcrt.h:376
int create_positional_ctx_a(void *, const char *, va_list)
struct fpnum fpnum_parse(wchar_t(*)(void *), void(*)(void *), void *, pthreadlocinfo, BOOL)
#define MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER
Definition: msvcrt.h:410
int pf_printf_w(puts_clbk_w, void *, const wchar_t *, _locale_t, DWORD, args_clbk, void *, va_list *)
#define MSVCRT_CHECK_PMT(x)
Definition: msvcrt.h:378
#define MSVCRT_CHECK_PMT_ERR(x, err)
Definition: msvcrt.h:377
int fpnum_double(struct fpnum *, double *)
Definition: string.c:365
else locinfo
Definition: scanf.h:225
int CDECL wcsrtombs_s(size_t *ret, char *mbstr, size_t size, const wchar_t **wcstr, size_t count, mbstate_t *mbstate)
Definition: wcs.c:785
int CDECL _vswprintf(wchar_t *str, const wchar_t *format, va_list args)
Definition: wcs.c:1765
int CDECL _wcsncoll_l(const wchar_t *str1, const wchar_t *str2, size_t count, _locale_t locale)
Definition: wcs.c:533
static BOOL n_format_enabled
Definition: wcs.c:49
int WINAPIV _snprintf_s_l(char *str, size_t len, size_t count, const char *format, _locale_t locale,...)
Definition: wcs.c:1285
int WINAPIV _scprintf_p_l(const char *format, _locale_t locale,...)
Definition: wcs.c:1352
int WINAPIV _snwprintf(wchar_t *str, size_t len, const wchar_t *format,...)
Definition: wcs.c:1493
wchar_t *CDECL wcstok_s(wchar_t *str, const wchar_t *delim, wchar_t **next_token)
Definition: wcs.c:2031
__msvcrt_long __cdecl _wtol(const wchar_t *str)
Definition: wcs.c:2798
INT CDECL _wcsnicmp(const wchar_t *str1, const wchar_t *str2, size_t n)
Definition: wcs.c:195
printf_arg arg_clbk_valist(void *ctx, int arg_pos, int type, va_list *valist)
Definition: wcs.c:847
INT CDECL _iswctype_l(wchar_t wc, wctype_t type, _locale_t locale)
Definition: wcs.c:2221
int WINAPIV _snprintf_c(char *str, size_t count, const char *format,...)
Definition: wcs.c:1272
__int64 CDECL _wtoi64_l(const wchar_t *str, _locale_t locale)
Definition: wcs.c:3013
static int wcsrtombs_s_l(size_t *ret, char *mbstr, size_t size, const wchar_t **wcstr, size_t count, _locale_t locale)
Definition: wcs.c:713
static void strtod_wstr_unget(void *ctx)
Definition: wcs.c:565
int CDECL wcstombs_s(size_t *ret, char *mbstr, size_t size, const wchar_t *wcstr, size_t count)
Definition: wcs.c:776
int CDECL _vsnprintf_s_l(char *str, size_t sizeOfBuffer, size_t count, const char *format, _locale_t locale, va_list valist)
Definition: wcs.c:1050
__msvcrt_ulong __cdecl _wcstoul_l(const wchar_t *s, wchar_t **end, int base, _locale_t locale)
Definition: wcs.c:2894
int CDECL vsprintf(char *str, const char *format, va_list valist)
Definition: wcs.c:1160
int CDECL _vscwprintf_p_l(const wchar_t *format, _locale_t locale, va_list args)
Definition: wcs.c:1798
wchar_t *CDECL _wcsrev(wchar_t *str)
Definition: wcs.c:324
int CDECL _vsnwprintf_s_l(wchar_t *str, size_t sizeOfBuffer, size_t count, const wchar_t *format, _locale_t locale, va_list valist)
Definition: wcs.c:1473
int WINAPIV _scwprintf(const wchar_t *format,...)
Definition: wcs.c:1673
size_t CDECL wcsrtombs(char *mbstr, const wchar_t **wcstr, size_t count, mbstate_t *mbstate)
Definition: wcs.c:701
size_t __cdecl wcsspn(const wchar_t *str, const wchar_t *accept)
Definition: wcs.c:508
INT CDECL wctob(wint_t wchar)
Definition: wcs.c:2175
double CDECL _wtof(const wchar_t *str)
Definition: wcs.c:805
int CDECL _wctomb_l(char *dst, wchar_t ch, _locale_t locale)
Definition: wcs.c:2147
int __cdecl _wtoi(const wchar_t *str)
Definition: wcs.c:2773
INT CDECL _wcsicoll(const wchar_t *str1, const wchar_t *str2)
Definition: wcs.c:236
int CDECL _vswprintf_p_l(wchar_t *buffer, size_t length, const wchar_t *format, _locale_t locale, va_list args)
Definition: wcs.c:1439
int WINAPIV sprintf_s(char *str, size_t num, const char *format,...)
Definition: wcs.c:1615
int WINAPIV _scprintf_p(const char *format,...)
Definition: wcs.c:1339
int CDECL _vsprintf_p(char *buffer, size_t length, const char *format, va_list args)
Definition: wcs.c:1871
INT CDECL iswctype(wchar_t wc, wctype_t type)
Definition: wcs.c:2239
int WINAPIV _snprintf_c_l(char *str, size_t count, const char *format, _locale_t locale,...)
Definition: wcs.c:1258
wint_t CDECL _towupper_l(wint_t c, _locale_t locale)
Definition: wcs.c:2932
__int64 CDECL _wcstoi64(const wchar_t *nptr, wchar_t **endptr, int base)
Definition: wcs.c:2720
int WINAPIV _scwprintf_p_l(const wchar_t *format, _locale_t locale,...)
Definition: wcs.c:1643
int CDECL _vsnwprintf_l(wchar_t *str, size_t len, const wchar_t *format, _locale_t locale, va_list valist)
Definition: wcs.c:1380
__msvcrt_long __cdecl _wtol_l(const wchar_t *str, _locale_t locale)
Definition: wcs.c:2781
unsigned __int64 CDECL _wcstoui64(const wchar_t *nptr, wchar_t **endptr, int base)
Definition: wcs.c:2885
int CDECL _vsprintf_p_l(char *buffer, size_t length, const char *format, _locale_t locale, va_list args)
Definition: wcs.c:1862
int WINAPIV swprintf_s(wchar_t *str, size_t numberOfElements, const wchar_t *format,...)
Definition: wcs.c:1701
int CDECL _vsprintf_l(char *str, const char *format, _locale_t locale, va_list valist)
Definition: wcs.c:965
int CDECL _vswprintf_c(wchar_t *str, size_t len, const wchar_t *format, va_list valist)
Definition: wcs.c:1404
int WINAPIV _snprintf_l(char *str, size_t count, const char *format, _locale_t locale,...)
Definition: wcs.c:1244
__msvcrt_long CDECL wcstol(const wchar_t *s, wchar_t **end, int base)
Definition: wcs.c:2747
int CDECL _vswprintf_l(wchar_t *str, const wchar_t *format, _locale_t locale, va_list args)
Definition: wcs.c:1773
int WINAPIV __swprintf_l(wchar_t *str, const wchar_t *format, _locale_t locale,...)
Definition: wcs.c:1909
int WINAPIV _snwprintf_s_l(wchar_t *str, size_t len, size_t count, const wchar_t *format, _locale_t locale,...)
Definition: wcs.c:1534
INT CDECL _wcsnicoll(const wchar_t *str1, const wchar_t *str2, size_t count)
Definition: wcs.c:282
INT CDECL _wcsicmp(const wchar_t *str1, const wchar_t *str2)
Definition: wcs.c:159
INT CDECL wcrtomb_s(size_t *len, char *mbchar, size_t size, wchar_t wch, mbstate_t *s)
Definition: wcs.c:2197
int WINAPIV _sprintf_l(char *str, const char *format, _locale_t locale,...)
Definition: wcs.c:974
int CDECL wcscoll(const wchar_t *str1, const wchar_t *str2)
Definition: wcs.c:2008
static wchar_t strtod_wstr_get(void *ctx)
Definition: wcs.c:558
int CDECL _vsnprintf_l(char *str, size_t len, const char *format, _locale_t locale, va_list valist)
Definition: wcs.c:949
int CDECL _wctomb_s_l(int *len, char *mbchar, size_t size, wchar_t wch, _locale_t locale)
Definition: wcs.c:2074
int __cdecl _wtoi_l(const wchar_t *str, _locale_t locale)
Definition: wcs.c:2756
static int vsprintf_p_l_opt(char *buffer, size_t length, const char *format, DWORD options, _locale_t locale, va_list args)
Definition: wcs.c:1832
int CDECL _wcsnicoll_l(const wchar_t *str1, const wchar_t *str2, size_t count, _locale_t locale)
Definition: wcs.c:244
int CDECL vsprintf_s(char *str, size_t num, const char *format, va_list valist)
Definition: wcs.c:1168
int CDECL _vswprintf_c_l(wchar_t *str, size_t len, const wchar_t *format, _locale_t locale, va_list valist)
Definition: wcs.c:1395
int WINAPIV _swprintf_p(wchar_t *buffer, size_t length, const wchar_t *format,...)
Definition: wcs.c:1940
size_t CDECL wcsnlen(const wchar_t *s, size_t maxlen)
Definition: wcs.c:2920
size_t CDECL wcsxfrm(wchar_t *dest, const wchar_t *src, size_t len)
Definition: wcs.c:3097
int WINAPIV _scwprintf_l(const wchar_t *format, _locale_t locale,...)
Definition: wcs.c:1629
int CDECL _vsnprintf_c_l(char *str, size_t len, const char *format, _locale_t locale, va_list valist)
Definition: wcs.c:1092
__int64 CDECL _wtoi64(const wchar_t *str)
Definition: wcs.c:3040
int CDECL _vscwprintf_l(const wchar_t *format, _locale_t locale, va_list args)
Definition: wcs.c:1790
INT CDECL _wcsnicmp_l(const wchar_t *str1, const wchar_t *str2, size_t n, _locale_t locale)
Definition: wcs.c:167
static int vswprintf_p_l_opt(wchar_t *buffer, size_t length, const wchar_t *format, DWORD options, _locale_t locale, va_list args)
Definition: wcs.c:1410
size_t __cdecl wcscspn(const wchar_t *str, const wchar_t *reject)
Definition: wcs.c:498
static size_t wcsrtombs_l(char *mbstr, const wchar_t **wcstr, size_t count, _locale_t locale)
Definition: wcs.c:609
int WINAPIV _snprintf_s(char *str, size_t len, size_t count, const char *format,...)
Definition: wcs.c:1299
wchar_t *CDECL wcspbrk(const wchar_t *str, const wchar_t *accept)
Definition: wcs.c:2016
int CDECL _vscprintf_l(const char *format, _locale_t locale, va_list valist)
Definition: wcs.c:1184
wint_t CDECL towctrans(wint_t c, wctrans_t category)
Definition: wcs.c:149
int WINAPIV _swprintf_c_l(wchar_t *str, size_t len, const wchar_t *format, _locale_t locale,...)
Definition: wcs.c:1733
printf_arg arg_clbk_positional(void *ctx, int pos, int type, va_list *valist)
Definition: wcs.c:870
wint_t CDECL _towlower_l(wint_t c, _locale_t locale)
Definition: wcs.c:96
double CDECL wcstod(const wchar_t *lpszStr, wchar_t **end)
Definition: wcs.c:797
__int64 CDECL _wcstoi64_l(const wchar_t *nptr, wchar_t **endptr, int base, _locale_t locale)
Definition: wcs.c:2655
int CDECL _wcsicoll_l(const wchar_t *str1, const wchar_t *str2, _locale_t locale)
Definition: wcs.c:203
int CDECL wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t n)
Definition: wcs.c:518
size_t CDECL _wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t len, _locale_t locale)
Definition: wcs.c:3048
int CDECL _wcsncoll(const wchar_t *str1, const wchar_t *str2, size_t count)
Definition: wcs.c:553
wchar_t *CDECL wcstok(wchar_t *str, const wchar_t *delim)
Definition: wcs.c:2065
int CDECL _vsnprintf_s(char *str, size_t sizeOfBuffer, size_t count, const char *format, va_list valist)
Definition: wcs.c:1083
int WINAPIV _snwprintf_l(wchar_t *str, size_t len, const wchar_t *format, _locale_t locale,...)
Definition: wcs.c:1506
int CDECL _vswprintf_s_l(wchar_t *str, size_t numberOfElements, const wchar_t *format, _locale_t locale, va_list args)
Definition: wcs.c:1825
int WINAPIV _sprintf_s_l(char *str, size_t count, const char *format, _locale_t locale,...)
Definition: wcs.c:1069
int WINAPIV _sprintf_p_l(char *buffer, size_t length, const char *format, _locale_t locale,...)
Definition: wcs.c:1893
int CDECL _wcslwr_s(wchar_t *str, size_t n)
Definition: wcs.c:472
static int CDECL vsnprintf_s_l_opt(char *str, size_t sizeOfBuffer, size_t count, const char *format, DWORD options, _locale_t locale, va_list valist)
Definition: wcs.c:985
double CDECL _wcstod_l(const wchar_t *str, wchar_t **end, _locale_t locale)
Definition: wcs.c:574
int CDECL _vscwprintf(const wchar_t *format, va_list args)
Definition: wcs.c:1782
static int wctoint(WCHAR c, int base)
Definition: wcs.c:2625
INT CDECL _wcsicmp_l(const wchar_t *str1, const wchar_t *str2, _locale_t locale)
Definition: wcs.c:125
int CDECL wctomb_s(int *len, char *mbchar, size_t size, wchar_t wch)
Definition: wcs.c:2139
INT CDECL _wcsupr_s(wchar_t *str, size_t n)
Definition: wcs.c:409
int CDECL _vscprintf_p_l(const char *format, _locale_t locale, va_list args)
Definition: wcs.c:1193
int CDECL vswprintf_s(wchar_t *str, size_t numberOfElements, const wchar_t *format, va_list args)
Definition: wcs.c:1816
int WINAPIV _scprintf(const char *format,...)
Definition: wcs.c:1313
int WINAPIV _swprintf_p_l(wchar_t *buffer, size_t length, const wchar_t *format, _locale_t locale,...)
Definition: wcs.c:1956
__msvcrt_ulong __cdecl wcstoul(const wchar_t *s, wchar_t **end, int base)
Definition: wcs.c:2912
size_t CDECL wcslen(const wchar_t *str)
Definition: wcs.c:2983
double CDECL _wtof_l(const wchar_t *str, _locale_t locale)
Definition: wcs.c:813
int CDECL wcscmp(const wchar_t *str1, const wchar_t *str2)
Definition: wcs.c:1972
int CDECL _vscprintf_p(const char *format, va_list argptr)
Definition: wcs.c:1223
int WINAPIV _swprintf(wchar_t *str, const wchar_t *format,...)
Definition: wcs.c:1687
__msvcrt_long CDECL _wcstol_l(const wchar_t *s, wchar_t **end, int base, _locale_t locale)
Definition: wcs.c:2729
int CDECL _vsnprintf_c(char *str, size_t len, const char *format, va_list valist)
Definition: wcs.c:1101
int CDECL _vsprintf_s_l(char *str, size_t count, const char *format, _locale_t locale, va_list valist)
Definition: wcs.c:1060
wchar_t *CDECL _wcsdup(const wchar_t *str)
Definition: wcs.c:81
static int vsnwprintf_s_l_opt(wchar_t *str, size_t sizeOfBuffer, size_t count, const wchar_t *format, DWORD options, _locale_t locale, va_list valist)
Definition: wcs.c:1017
unsigned __int64 CDECL _wcstoui64_l(const wchar_t *nptr, wchar_t **endptr, int base, _locale_t locale)
Definition: wcs.c:2826
int CDECL _wcscoll_l(const wchar_t *str1, const wchar_t *str2, _locale_t locale)
Definition: wcs.c:1990
wchar_t *CDECL wcsstr(const wchar_t *str, const wchar_t *sub)
Definition: wcs.c:2993
int WINAPIV _snwprintf_s(wchar_t *str, size_t len, size_t count, const wchar_t *format,...)
Definition: wcs.c:1520
INT CDECL wcscat_s(wchar_t *dst, size_t elem, const wchar_t *src)
Definition: wcs.c:2535
int WINAPIV _scprintf_l(const char *format, _locale_t locale,...)
Definition: wcs.c:1326
int WINAPIV _swprintf_c(wchar_t *str, size_t len, const wchar_t *format,...)
Definition: wcs.c:1749
int CDECL _vsnwprintf_s(wchar_t *str, size_t sizeOfBuffer, size_t count, const wchar_t *format, va_list valist)
Definition: wcs.c:1483
int WINAPIV _swprintf_s_l(wchar_t *str, size_t numberOfElements, const wchar_t *format, _locale_t locale,...)
Definition: wcs.c:1717
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
#define ULONG_PTR
Definition: config.h:101
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
const GLdouble * v
Definition: gl.h:2040
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
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble t
Definition: gl.h:2047
GLdouble n
Definition: glext.h:7729
GLenum src
Definition: glext.h:6340
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
const GLubyte * c
Definition: glext.h:8905
GLfloat f
Definition: glext.h:7540
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLenum dst
Definition: glext.h:6340
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLfloat GLfloat p
Definition: glext.h:8902
GLboolean enable
Definition: glext.h:11120
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 WC_NO_BEST_FIT_CHARS
Definition: unicode.h:46
#define c
Definition: ke_i.h:80
#define debugstr_w
Definition: kernel32.h:32
struct S1 s1
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define wcscpy_s(d, l, s)
Definition: utility.h:201
#define wcsncpy_s(d, l, s, n)
Definition: utility.h:202
static PVOID ptr
Definition: dispmode.c:27
#define _vscprintf
Definition: _vscprintf.c:25
#define _vsnwprintf
Definition: _vsnwprintf.c:28
#define sprintf
Definition: sprintf.c:45
#define wctomb
Definition: wctomb.c:31
static va_list valist
Definition: printf.c:46
static size_t sizeOfBuffer
Definition: printf.c:48
static const unsigned char *static size_t const wchar_t * wcSrc
Definition: string.c:76
static size_t numberOfElements
Definition: string.c:98
static size_t elem
Definition: string.c:71
static char * dest
Definition: rtl.c:135
unsigned int UINT
Definition: ndis.h:50
int __cdecl __stdio_common_vsprintf_s(unsigned __int64 const options, char *const buffer, size_t const buffer_count, char const *const format, _locale_t const locale, va_list const arglist)
Definition: output.cpp:292
int __cdecl __stdio_common_vsprintf(unsigned __int64 const options, char *const buffer, size_t const buffer_count, char const *const format, _locale_t const locale, va_list const arglist)
Definition: output.cpp:233
int __cdecl __stdio_common_vsprintf_p(unsigned __int64 const options, char *const buffer, size_t const buffer_count, char const *const format, _locale_t const locale, va_list const arglist)
Definition: output.cpp:421
int __cdecl __stdio_common_vswprintf(unsigned __int64 const options, wchar_t *const buffer, size_t const buffer_count, wchar_t const *const format, _locale_t const locale, va_list const arglist)
Definition: output.cpp:246
int __cdecl __stdio_common_vswprintf_s(unsigned __int64 const options, wchar_t *const buffer, size_t const buffer_count, wchar_t const *const format, _locale_t const locale, va_list const arglist)
Definition: output.cpp:305
int __cdecl __stdio_common_vswprintf_p(unsigned __int64 const options, wchar_t *const buffer, size_t const buffer_count, wchar_t const *const format, _locale_t const locale, va_list const arglist)
Definition: output.cpp:434
int __cdecl __stdio_common_vsnprintf_s(unsigned __int64 const options, char *const buffer, size_t const buffer_count, size_t const max_count, char const *const format, _locale_t const locale, va_list const arglist)
Definition: output.cpp:393
int __cdecl __stdio_common_vsnwprintf_s(unsigned __int64 const options, wchar_t *const buffer, size_t const buffer_count, size_t const max_count, wchar_t const *const format, _locale_t const locale, va_list const arglist)
Definition: output.cpp:407
#define err(...)
const WCHAR * str
#define WINAPIV
Definition: sdbpapi.h:64
#define iswgraph(_c)
Definition: ctype.h:673
#define _iswdigit_l(_c, _p)
Definition: ctype.h:679
#define _iswlower_l(_c, _p)
Definition: ctype.h:678
#define iswcntrl(_c)
Definition: ctype.h:674
#define iswspace(_c)
Definition: ctype.h:669
#define _iswupper_l(_c, _p)
Definition: ctype.h:677
#define iswupper(_c)
Definition: ctype.h:665
#define _iswspace_l(_c, _p)
Definition: ctype.h:681
#define _iswgraph_l(_c, _p)
Definition: ctype.h:685
#define iswdigit(_c)
Definition: ctype.h:667
#define iswalnum(_c)
Definition: ctype.h:671
#define iswlower(_c)
Definition: ctype.h:666
#define _iswxdigit_l(_c, _p)
Definition: ctype.h:680
#define _iswprint_l(_c, _p)
Definition: ctype.h:684
#define _iswalpha_l(_c, _p)
Definition: ctype.h:676
#define iswprint(_c)
Definition: ctype.h:672
#define _iswpunct_l(_c, _p)
Definition: ctype.h:682
#define _iswcntrl_l(_c, _p)
Definition: ctype.h:686
#define iswxdigit(_c)
Definition: ctype.h:668
#define _iswalnum_l(_c, _p)
Definition: ctype.h:683
#define iswpunct(_c)
Definition: ctype.h:670
#define iswalpha(_c)
Definition: ctype.h:664
_Check_return_opt_ _CRTIMP int __cdecl _vswprintf_p(_Out_writes_z_(_MaxCount) wchar_t *_DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const wchar_t *_Format, va_list _ArgList)
_Check_return_ _CRTIMP int __cdecl _vscwprintf_p(_In_z_ _Printf_format_string_ const wchar_t *_Format, va_list _ArgList)
_Check_return_ _CRTIMP int __cdecl _scwprintf_p(_In_z_ _Printf_format_string_ const wchar_t *_Format,...)
#define CP_UTF8
Definition: nls.h:20
#define iswblank(_c)
#define _iswblank_l(_c, _p)
_wcslwr
_wcsnset_s
wcsncat
_wcsupr_s_l
_wcsset
wcsncpy
_wcslwr_l
wcscat
_wcsupr
_wcsupr_l
_wcsnset
wcsncat_s
_wcsset_s
wcscpy
_wcslwr_s_l
_wcstombs_l
Definition: stdlib.h:1039
_wcstombs_s_l
Definition: stdlib.h:1039
wcstombs
Definition: stdlib.h:1013
#define memset(x, y, z)
Definition: compat.h:39
#define wcrtomb(cp, wc, sp)
Definition: wchar.h:163
#define towlower(c)
Definition: wctype.h:97
#define towupper(c)
Definition: wctype.h:99
PCWSTR s2
Definition: shell32_main.h:38
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
#define TRACE(s)
Definition: solgame.cpp:4
Definition: match.c:390
Definition: format.c:58
Definition: msvcrt.h:359
Definition: wcs.c:41
BOOLEAN Alternate
Definition: wcs.c:43
char Format
Definition: wcs.c:46
int FieldLength
Definition: wcs.c:45
BOOLEAN NaturalString
Definition: wcs.c:44
#define vsnprintf
Definition: tif_win32.c:406
int64_t LONGLONG
Definition: typedefs.h:68
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint64_t ULONGLONG
Definition: typedefs.h:67
size_t const wchar_t const wchar
Definition: wcrtomb.cpp:53
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
int retval
Definition: wcstombs.cpp:91
int codepage
Definition: win_iconv.c:156
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define get_locinfo()
Definition: winesup.h:25
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36
#define NORM_IGNORECASE
Definition: winnls.h:187
#define SORT_STRINGSORT
Definition: winnls.h:195
#define CT_CTYPE1
Definition: winnls.h:255
#define LCMAP_UPPERCASE
Definition: winnls.h:198
#define CSTR_EQUAL
Definition: winnls.h:500
#define LCMAP_SORTKEY
Definition: winnls.h:199
#define LCMAP_LOWERCASE
Definition: winnls.h:197
#define _vsnprintf
Definition: xmlstorage.h:202
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _snprintf
Definition: xmlstorage.h:200