2 * msvcrt.dll wide-char functions
4 * Copyright 1999 Alexandre Julliard
5 * Copyright 2000 Jon Griffiths
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.
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.
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
22 #include "wine/port.h"
31 #include "wine/unicode.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt
);
36 static BOOL n_format_enabled
= TRUE
;
43 /*********************************************************************
44 * _get_printf_count_output (MSVCR80.@)
46 int CDECL
MSVCRT__get_printf_count_output( void )
48 return n_format_enabled
? 1 : 0;
51 /*********************************************************************
52 * _set_printf_count_output (MSVCR80.@)
54 int CDECL
MSVCRT__set_printf_count_output( int enable
)
56 BOOL old
= n_format_enabled
;
57 n_format_enabled
= enable
!= 0;
61 /*********************************************************************
64 MSVCRT_wchar_t
* CDECL
MSVCRT__wcsdup( const MSVCRT_wchar_t
* str
)
66 MSVCRT_wchar_t
* ret
= NULL
;
69 int size
= (strlenW(str
) + 1) * sizeof(MSVCRT_wchar_t
);
70 ret
= MSVCRT_malloc( size
);
71 if (ret
) memcpy( ret
, str
, size
);
76 INT CDECL
MSVCRT__wcsicmp_l(const MSVCRT_wchar_t
*str1
, const MSVCRT_wchar_t
*str2
, MSVCRT__locale_t locale
)
78 if(!MSVCRT_CHECK_PMT(str1
!= NULL
) || !MSVCRT_CHECK_PMT(str2
!= NULL
))
79 return MSVCRT__NLSCMPERROR
;
81 return strcmpiW(str1
, str2
);
84 /*********************************************************************
87 INT CDECL
MSVCRT__wcsicmp( const MSVCRT_wchar_t
* str1
, const MSVCRT_wchar_t
* str2
)
89 return strcmpiW( str1
, str2
);
92 /*********************************************************************
93 * _wcsnicmp_l (MSVCRT.@)
95 INT CDECL
MSVCRT__wcsnicmp_l(const MSVCRT_wchar_t
*str1
, const MSVCRT_wchar_t
*str2
, INT n
, MSVCRT__locale_t locale
)
97 return strncmpiW(str1
, str2
, n
);
100 /*********************************************************************
101 * _wcsnicmp (MSVCRT.@)
103 INT CDECL
MSVCRT__wcsnicmp(const MSVCRT_wchar_t
*str1
, const MSVCRT_wchar_t
*str2
, INT n
)
105 return MSVCRT__wcsnicmp_l(str1
, str2
, n
, NULL
);
108 /*********************************************************************
109 * _wcsicoll_l (MSVCRT.@)
111 int CDECL
MSVCRT__wcsicoll_l(const MSVCRT_wchar_t
* str1
, const MSVCRT_wchar_t
* str2
, MSVCRT__locale_t locale
)
113 MSVCRT_pthreadlocinfo locinfo
;
116 locinfo
= get_locinfo();
118 locinfo
= locale
->locinfo
;
120 if(!locinfo
->lc_handle
[MSVCRT_LC_COLLATE
])
121 return strcmpiW(str1
, str2
);
122 return CompareStringW(locinfo
->lc_handle
[MSVCRT_LC_COLLATE
], NORM_IGNORECASE
,
123 str1
, -1, str2
, -1)-CSTR_EQUAL
;
126 /*********************************************************************
127 * _wcsicoll (MSVCRT.@)
129 INT CDECL
MSVCRT__wcsicoll( const MSVCRT_wchar_t
* str1
, const MSVCRT_wchar_t
* str2
)
131 return MSVCRT__wcsicoll_l(str1
, str2
, NULL
);
134 /*********************************************************************
135 * _wcsnicoll_l (MSVCRT.@)
137 int CDECL
MSVCRT__wcsnicoll_l(const MSVCRT_wchar_t
* str1
, const MSVCRT_wchar_t
* str2
,
138 MSVCRT_size_t count
, MSVCRT__locale_t locale
)
140 MSVCRT_pthreadlocinfo locinfo
;
143 locinfo
= get_locinfo();
145 locinfo
= locale
->locinfo
;
147 if(!locinfo
->lc_handle
[MSVCRT_LC_COLLATE
])
148 return strncmpiW(str1
, str2
, count
);
149 return CompareStringW(locinfo
->lc_handle
[MSVCRT_LC_COLLATE
], NORM_IGNORECASE
,
150 str1
, count
, str2
, count
)-CSTR_EQUAL
;
153 /*********************************************************************
154 * _wcsnicoll (MSVCRT.@)
156 INT CDECL
MSVCRT__wcsnicoll( const MSVCRT_wchar_t
* str1
, const MSVCRT_wchar_t
* str2
, MSVCRT_size_t count
)
158 return MSVCRT__wcsnicoll_l(str1
, str2
, count
, NULL
);
161 /*********************************************************************
162 * _wcsnset (MSVCRT.@)
164 MSVCRT_wchar_t
* CDECL
MSVCRT__wcsnset( MSVCRT_wchar_t
* str
, MSVCRT_wchar_t c
, MSVCRT_size_t n
)
166 MSVCRT_wchar_t
* ret
= str
;
167 while ((n
-- > 0) && *str
) *str
++ = c
;
171 /*********************************************************************
174 MSVCRT_wchar_t
* CDECL
MSVCRT__wcsrev( MSVCRT_wchar_t
* str
)
176 MSVCRT_wchar_t
* ret
= str
;
177 MSVCRT_wchar_t
* end
= str
+ strlenW(str
) - 1;
180 MSVCRT_wchar_t t
= *end
;
187 /*********************************************************************
188 * _wcsset_s (MSVCRT.@)
190 int CDECL
MSVCRT__wcsset_s( MSVCRT_wchar_t
*str
, MSVCRT_size_t n
, MSVCRT_wchar_t c
)
192 MSVCRT_wchar_t
*p
= str
;
194 if(!MSVCRT_CHECK_PMT(str
!= NULL
)) return MSVCRT_EINVAL
;
195 if(!MSVCRT_CHECK_PMT(n
)) return MSVCRT_EINVAL
;
197 while(*p
&& --n
) *p
++ = c
;
200 MSVCRT__invalid_parameter(NULL
, NULL
, NULL
, 0, 0);
201 *MSVCRT__errno() = MSVCRT_EINVAL
;
202 return MSVCRT_EINVAL
;
207 /*********************************************************************
210 MSVCRT_wchar_t
* CDECL
MSVCRT__wcsset( MSVCRT_wchar_t
* str
, MSVCRT_wchar_t c
)
212 MSVCRT_wchar_t
* ret
= str
;
213 while (*str
) *str
++ = c
;
217 /******************************************************************
218 * _wcsupr_s_l (MSVCRT.@)
220 int CDECL
MSVCRT__wcsupr_s_l( MSVCRT_wchar_t
* str
, MSVCRT_size_t n
,
221 MSVCRT__locale_t locale
)
223 MSVCRT_wchar_t
* ptr
= str
;
227 if (str
) *str
= '\0';
228 *MSVCRT__errno() = MSVCRT_EINVAL
;
229 return MSVCRT_EINVAL
;
235 /* FIXME: add locale support */
236 *ptr
= toupperW(*ptr
);
240 /* MSDN claims that the function should return and set errno to
241 * ERANGE, which doesn't seem to be true based on the tests. */
243 *MSVCRT__errno() = MSVCRT_EINVAL
;
244 return MSVCRT_EINVAL
;
247 /******************************************************************
248 * _wcsupr_s (MSVCRT.@)
251 INT CDECL
MSVCRT__wcsupr_s( MSVCRT_wchar_t
* str
, MSVCRT_size_t n
)
253 return MSVCRT__wcsupr_s_l( str
, n
, NULL
);
256 /******************************************************************
257 * _wcsupr_l (MSVCRT.@)
259 MSVCRT_wchar_t
* CDECL
MSVCRT__wcsupr_l( MSVCRT_wchar_t
*str
, MSVCRT__locale_t locale
)
261 MSVCRT__wcsupr_s_l( str
, -1, locale
);
265 /******************************************************************
266 * _wcslwr_s_l (MSVCRT.@)
268 int CDECL
MSVCRT__wcslwr_s_l( MSVCRT_wchar_t
* str
, MSVCRT_size_t n
, MSVCRT__locale_t locale
)
270 MSVCRT_wchar_t
* ptr
= str
;
274 if (str
) *str
= '\0';
275 *MSVCRT__errno() = MSVCRT_EINVAL
;
276 return MSVCRT_EINVAL
;
282 *ptr
= tolowerW(*ptr
);
286 /* MSDN claims that the function should return and set errno to
287 * ERANGE, which doesn't seem to be true based on the tests. */
289 *MSVCRT__errno() = MSVCRT_EINVAL
;
290 return MSVCRT_EINVAL
;
293 /******************************************************************
294 * _wcslwr_s (MSVCRT.@)
296 int CDECL
MSVCRT__wcslwr_s( MSVCRT_wchar_t
* str
, MSVCRT_size_t n
)
298 return MSVCRT__wcslwr_s_l(str
, n
, NULL
);
301 /******************************************************************
302 * _wcslwr_l (MSVCRT.@)
304 MSVCRT_wchar_t
* CDECL
MSVCRT__wcslwr_l( MSVCRT_wchar_t
* str
, MSVCRT__locale_t locale
)
306 MSVCRT__wcslwr_s_l(str
, -1, locale
);
310 /******************************************************************
313 MSVCRT_wchar_t
* CDECL
MSVCRT__wcslwr( MSVCRT_wchar_t
* str
)
315 MSVCRT__wcslwr_s_l(str
, -1, NULL
);
319 /*********************************************************************
320 * _wcsncoll_l (MSVCRT.@)
322 int CDECL
MSVCRT__wcsncoll_l(const MSVCRT_wchar_t
* str1
, const MSVCRT_wchar_t
* str2
,
323 MSVCRT_size_t count
, MSVCRT__locale_t locale
)
325 MSVCRT_pthreadlocinfo locinfo
;
328 locinfo
= get_locinfo();
330 locinfo
= locale
->locinfo
;
332 if(!locinfo
->lc_handle
[MSVCRT_LC_COLLATE
])
333 return strncmpW(str1
, str2
, count
);
334 return CompareStringW(locinfo
->lc_handle
[MSVCRT_LC_COLLATE
], 0, str1
, count
, str2
, count
)-CSTR_EQUAL
;
337 /*********************************************************************
338 * _wcsncoll (MSVCRT.@)
340 int CDECL
MSVCRT__wcsncoll(const MSVCRT_wchar_t
* str1
, const MSVCRT_wchar_t
* str2
, MSVCRT_size_t count
)
342 return MSVCRT__wcsncoll_l(str1
, str2
, count
, NULL
);
345 /*********************************************************************
346 * _wcstod_l (MSVCRT.@)
348 double CDECL
MSVCRT__wcstod_l(const MSVCRT_wchar_t
* str
, MSVCRT_wchar_t
** end
,
349 MSVCRT__locale_t locale
)
351 MSVCRT_pthreadlocinfo locinfo
;
352 unsigned __int64 d
=0, hlp
;
355 const MSVCRT_wchar_t
*p
;
357 long double lret
=1, expcnt
= 10;
358 BOOL found_digit
= FALSE
, negexp
;
360 if (!MSVCRT_CHECK_PMT(str
!= NULL
)) return 0;
363 locinfo
= get_locinfo();
365 locinfo
= locale
->locinfo
;
377 while(isdigitW(*p
)) {
379 hlp
= d
*10+*(p
++)-'0';
380 if(d
>MSVCRT_UI64_MAX
/10 || hlp
<d
) {
386 while(isdigitW(*p
)) {
390 if(*p
== *locinfo
->lconv
->decimal_point
)
393 while(isdigitW(*p
)) {
395 hlp
= d
*10+*(p
++)-'0';
396 if(d
>MSVCRT_UI64_MAX
/10 || hlp
<d
)
407 *end
= (MSVCRT_wchar_t
*)str
;
411 if(*p
=='e' || *p
=='E' || *p
=='d' || *p
=='D') {
422 while(isdigitW(*p
)) {
423 if(e
>INT_MAX
/10 || (e
=e
*10+*p
-'0')<0)
429 if(exp
<0 && e
<0 && exp
+e
>=0) exp
= INT_MIN
;
430 else if(exp
>0 && e
>0 && exp
+e
<0) exp
= INT_MAX
;
433 if(*p
=='-' || *p
=='+')
439 fpcontrol
= _control87(0, 0);
440 _control87(MSVCRT__EM_DENORMAL
|MSVCRT__EM_INVALID
|MSVCRT__EM_ZERODIVIDE
441 |MSVCRT__EM_OVERFLOW
|MSVCRT__EM_UNDERFLOW
|MSVCRT__EM_INEXACT
, 0xffffffff);
450 expcnt
= expcnt
*expcnt
;
452 ret
= (long double)sign
* (negexp
? d
/lret
: d
*lret
);
454 _control87(fpcontrol
, 0xffffffff);
456 if((d
&& ret
==0.0) || isinf(ret
))
457 *MSVCRT__errno() = MSVCRT_ERANGE
;
460 *end
= (MSVCRT_wchar_t
*)p
;
465 /*********************************************************************
466 * wcsrtombs_l (INTERNAL)
468 static MSVCRT_size_t
MSVCRT_wcsrtombs_l(char *mbstr
, const MSVCRT_wchar_t
**wcstr
,
469 MSVCRT_size_t count
, MSVCRT__locale_t locale
)
471 MSVCRT_pthreadlocinfo locinfo
;
472 MSVCRT_size_t tmp
= 0;
476 locinfo
= get_locinfo();
478 locinfo
= locale
->locinfo
;
481 tmp
= WideCharToMultiByte(locinfo
->lc_codepage
, WC_NO_BEST_FIT_CHARS
,
482 *wcstr
, -1, NULL
, 0, NULL
, &used_default
)-1;
483 if(!tmp
|| used_default
) {
484 *MSVCRT__errno() = MSVCRT_EILSEQ
;
492 MSVCRT_size_t i
, size
;
494 size
= WideCharToMultiByte(locinfo
->lc_codepage
, WC_NO_BEST_FIT_CHARS
,
495 *wcstr
, 1, buf
, 3, NULL
, &used_default
);
496 if(!size
|| used_default
) {
497 *MSVCRT__errno() = MSVCRT_EILSEQ
;
503 for(i
=0; i
<size
; i
++)
504 mbstr
[tmp
++] = buf
[i
];
515 /*********************************************************************
516 * _wcstombs_l (MSVCRT.@)
518 MSVCRT_size_t CDECL
MSVCRT__wcstombs_l(char *mbstr
, const MSVCRT_wchar_t
*wcstr
,
519 MSVCRT_size_t count
, MSVCRT__locale_t locale
)
521 return MSVCRT_wcsrtombs_l(mbstr
, &wcstr
, count
, locale
);
524 /*********************************************************************
525 * wcstombs (MSVCRT.@)
527 MSVCRT_size_t CDECL
MSVCRT_wcstombs(char *mbstr
, const MSVCRT_wchar_t
*wcstr
,
530 return MSVCRT_wcsrtombs_l(mbstr
, &wcstr
, count
, NULL
);
533 /*********************************************************************
534 * wcsrtombs (MSVCRT.@)
536 MSVCRT_size_t CDECL
MSVCRT_wcsrtombs(char *mbstr
, const MSVCRT_wchar_t
**wcstr
,
537 MSVCRT_size_t count
, MSVCRT_mbstate_t
*mbstate
)
542 return MSVCRT_wcsrtombs_l(mbstr
, wcstr
, count
, NULL
);
545 /*********************************************************************
546 * MSVCRT_wcsrtombs_s_l (INTERNAL)
548 static int MSVCRT_wcsrtombs_s_l(MSVCRT_size_t
*ret
, char *mbstr
,
549 MSVCRT_size_t size
, const MSVCRT_wchar_t
**wcstr
,
550 MSVCRT_size_t count
, MSVCRT__locale_t locale
)
554 if(!mbstr
&& !size
&& wcstr
) {
555 conv
= MSVCRT_wcsrtombs_l(NULL
, wcstr
, 0, locale
);
557 return *MSVCRT__errno();
563 if (!MSVCRT_CHECK_PMT(mbstr
!= NULL
)) return MSVCRT_EINVAL
;
564 if (size
) mbstr
[0] = '\0';
565 if (!MSVCRT_CHECK_PMT(wcstr
!= NULL
)) return MSVCRT_EINVAL
;
566 if (!MSVCRT_CHECK_PMT(*wcstr
!= NULL
)) return MSVCRT_EINVAL
;
568 if(count
==MSVCRT__TRUNCATE
|| size
<count
)
573 conv
= MSVCRT_wcsrtombs_l(mbstr
, wcstr
, conv
, locale
);
577 return *MSVCRT__errno();
578 }else if(conv
< size
)
579 mbstr
[conv
++] = '\0';
580 else if(conv
==size
&& (count
==MSVCRT__TRUNCATE
|| mbstr
[conv
-1]=='\0'))
581 mbstr
[conv
-1] = '\0';
583 MSVCRT_INVALID_PMT("mbstr[size] is too small", MSVCRT_ERANGE
);
586 return MSVCRT_ERANGE
;
594 /*********************************************************************
595 * _wcstombs_s_l (MSVCRT.@)
597 int CDECL
MSVCRT__wcstombs_s_l(MSVCRT_size_t
*ret
, char *mbstr
,
598 MSVCRT_size_t size
, const MSVCRT_wchar_t
*wcstr
,
599 MSVCRT_size_t count
, MSVCRT__locale_t locale
)
601 return MSVCRT_wcsrtombs_s_l(ret
, mbstr
, size
, &wcstr
,count
, locale
);
604 /*********************************************************************
605 * wcstombs_s (MSVCRT.@)
607 int CDECL
MSVCRT_wcstombs_s(MSVCRT_size_t
*ret
, char *mbstr
,
608 MSVCRT_size_t size
, const MSVCRT_wchar_t
*wcstr
, MSVCRT_size_t count
)
610 return MSVCRT_wcsrtombs_s_l(ret
, mbstr
, size
, &wcstr
, count
, NULL
);
613 /*********************************************************************
614 * wcsrtombs_s (MSVCRT.@)
616 int CDECL
MSVCRT_wcsrtombs_s(MSVCRT_size_t
*ret
, char *mbstr
, MSVCRT_size_t size
,
617 const MSVCRT_wchar_t
**wcstr
, MSVCRT_size_t count
, MSVCRT_mbstate_t
*mbstate
)
622 return MSVCRT_wcsrtombs_s_l(ret
, mbstr
, size
, wcstr
, count
, NULL
);
625 /*********************************************************************
628 double CDECL
MSVCRT_wcstod(const MSVCRT_wchar_t
* lpszStr
, MSVCRT_wchar_t
** end
)
630 return MSVCRT__wcstod_l(lpszStr
, end
, NULL
);
633 /*********************************************************************
636 double CDECL
MSVCRT__wtof(const MSVCRT_wchar_t
*str
)
638 return MSVCRT__wcstod_l(str
, NULL
, NULL
);
641 /*********************************************************************
644 double CDECL
MSVCRT__wtof_l(const MSVCRT_wchar_t
*str
, MSVCRT__locale_t locale
)
646 return MSVCRT__wcstod_l(str
, NULL
, locale
);
649 /*********************************************************************
650 * arg_clbk_valist (INTERNAL)
652 printf_arg
arg_clbk_valist(void *ctx
, int arg_pos
, int type
, __ms_va_list
*valist
)
657 ret
.get_longlong
= va_arg(*valist
, LONGLONG
);
658 else if(type
== VT_INT
)
659 ret
.get_int
= va_arg(*valist
, int);
660 else if(type
== VT_R8
)
661 ret
.get_double
= va_arg(*valist
, double);
662 else if(type
== VT_PTR
)
663 ret
.get_ptr
= va_arg(*valist
, void*);
665 ERR("Incorrect type\n");
672 /*********************************************************************
673 * arg_clbk_positional (INTERNAL)
675 static printf_arg
arg_clbk_positional(void *ctx
, int pos
, int type
, __ms_va_list
*valist
)
677 printf_arg
*args
= ctx
;
681 /*********************************************************************
682 * _vsnprintf (MSVCRT.@)
684 int CDECL
MSVCRT_vsnprintf( char *str
, MSVCRT_size_t len
,
685 const char *format
, __ms_va_list valist
)
687 static const char nullbyte
= '\0';
688 struct _str_ctx_a ctx
= {len
, str
};
691 ret
= pf_printf_a(puts_clbk_str_a
, &ctx
, format
, NULL
, 0,
692 arg_clbk_valist
, NULL
, &valist
);
693 puts_clbk_str_a(&ctx
, 1, &nullbyte
);
697 static int puts_clbk_str_c99_a(void *ctx
, int len
, const char *str
)
699 struct _str_ctx_a
*out
= ctx
;
705 memcpy(out
->buf
, str
, out
->len
);
706 out
->buf
+= out
->len
;
711 memcpy(out
->buf
, str
, len
);
717 /*********************************************************************
718 * __stdio_common_vsprintf (MSVCRT.@)
720 int CDECL
MSVCRT__stdio_common_vsprintf( unsigned __int64 options
, char *str
, MSVCRT_size_t len
, const char *format
,
721 MSVCRT__locale_t locale
, __ms_va_list valist
)
723 static const char nullbyte
= '\0';
724 struct _str_ctx_a ctx
= {len
, str
};
727 if (options
& ~UCRTBASE_PRINTF_MASK
)
728 FIXME("options %s not handled\n", wine_dbgstr_longlong(options
));
729 ret
= pf_printf_a(puts_clbk_str_c99_a
,
730 &ctx
, format
, locale
, options
& UCRTBASE_PRINTF_MASK
, arg_clbk_valist
, NULL
, &valist
);
731 puts_clbk_str_a(&ctx
, 1, &nullbyte
);
733 if(options
& UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION
)
734 return ret
>len
? -1 : ret
;
736 if(len
) str
[len
-1] = 0;
737 return (options
& UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR
) ? ret
: -2;
742 /*********************************************************************
743 * _vsnprintf_l (MSVCRT.@)
745 int CDECL
MSVCRT_vsnprintf_l( char *str
, MSVCRT_size_t len
, const char *format
,
746 MSVCRT__locale_t locale
, __ms_va_list valist
)
748 static const char nullbyte
= '\0';
749 struct _str_ctx_a ctx
= {len
, str
};
752 ret
= pf_printf_a(puts_clbk_str_a
, &ctx
, format
, locale
, 0,
753 arg_clbk_valist
, NULL
, &valist
);
754 puts_clbk_str_a(&ctx
, 1, &nullbyte
);
758 /*********************************************************************
759 * _vsprintf_l (MSVCRT.@)
761 int CDECL
MSVCRT_vsprintf_l( char *str
, const char *format
,
762 MSVCRT__locale_t locale
, __ms_va_list valist
)
764 return MSVCRT_vsnprintf_l(str
, INT_MAX
, format
, locale
, valist
);
767 /*********************************************************************
768 * _sprintf_l (MSVCRT.@)
770 int CDECL
MSVCRT_sprintf_l(char *str
, const char *format
,
771 MSVCRT__locale_t locale
, ...)
775 __ms_va_start(valist
, locale
);
776 retval
= MSVCRT_vsnprintf_l(str
, INT_MAX
, format
, locale
, valist
);
781 static int CDECL
MSVCRT_vsnprintf_s_l_opt( char *str
, MSVCRT_size_t sizeOfBuffer
,
782 MSVCRT_size_t count
, const char *format
, DWORD options
,
783 MSVCRT__locale_t locale
, __ms_va_list valist
)
785 static const char nullbyte
= '\0';
786 struct _str_ctx_a ctx
;
789 if(sizeOfBuffer
<count
+1 || count
==-1)
796 ret
= pf_printf_a(puts_clbk_str_a
, &ctx
, format
, locale
, MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER
| options
,
797 arg_clbk_valist
, NULL
, &valist
);
798 puts_clbk_str_a(&ctx
, 1, &nullbyte
);
800 if(ret
<0 || ret
==len
) {
801 if(count
!=MSVCRT__TRUNCATE
&& count
>sizeOfBuffer
) {
802 MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small", MSVCRT_ERANGE
);
803 memset(str
, 0, sizeOfBuffer
);
813 /*********************************************************************
814 * _vsnprintf_s_l (MSVCRT.@)
816 int CDECL
MSVCRT_vsnprintf_s_l( char *str
, MSVCRT_size_t sizeOfBuffer
,
817 MSVCRT_size_t count
, const char *format
,
818 MSVCRT__locale_t locale
, __ms_va_list valist
)
820 return MSVCRT_vsnprintf_s_l_opt(str
, sizeOfBuffer
, count
, format
, 0, locale
, valist
);
823 /*********************************************************************
824 * _vsprintf_s_l (MSVCRT.@)
826 int CDECL
MSVCRT_vsprintf_s_l( char *str
, MSVCRT_size_t count
, const char *format
,
827 MSVCRT__locale_t locale
, __ms_va_list valist
)
829 return MSVCRT_vsnprintf_s_l(str
, INT_MAX
, count
, format
, locale
, valist
);
832 /*********************************************************************
833 * _sprintf_s_l (MSVCRT.@)
835 int CDECL
MSVCRT_sprintf_s_l( char *str
, MSVCRT_size_t count
, const char *format
,
836 MSVCRT__locale_t locale
, ...)
840 __ms_va_start(valist
, locale
);
841 retval
= MSVCRT_vsnprintf_s_l(str
, INT_MAX
, count
, format
, locale
, valist
);
846 /*********************************************************************
847 * _vsnprintf_s (MSVCRT.@)
849 int CDECL
MSVCRT_vsnprintf_s( char *str
, MSVCRT_size_t sizeOfBuffer
,
850 MSVCRT_size_t count
, const char *format
, __ms_va_list valist
)
852 return MSVCRT_vsnprintf_s_l(str
,sizeOfBuffer
, count
, format
, NULL
, valist
);
855 /*********************************************************************
856 * __stdio_common_vsnprintf_s (MSVCRT.@)
858 int CDECL
MSVCRT__stdio_common_vsnprintf_s( unsigned __int64 options
,
859 char *str
, MSVCRT_size_t sizeOfBuffer
, MSVCRT_size_t count
,
860 const char *format
, MSVCRT__locale_t locale
, __ms_va_list valist
)
862 if (options
& ~UCRTBASE_PRINTF_MASK
)
863 FIXME("options %s not handled\n", wine_dbgstr_longlong(options
));
864 return MSVCRT_vsnprintf_s_l_opt(str
, sizeOfBuffer
, count
, format
, options
& UCRTBASE_PRINTF_MASK
, locale
, valist
);
867 /*********************************************************************
868 * __stdio_common_vsprintf_s (MSVCRT.@)
870 int CDECL
MSVCRT__stdio_common_vsprintf_s( unsigned __int64 options
,
871 char *str
, MSVCRT_size_t count
, const char *format
,
872 MSVCRT__locale_t locale
, __ms_va_list valist
)
874 if (options
& ~UCRTBASE_PRINTF_MASK
)
875 FIXME("options %s not handled\n", wine_dbgstr_longlong(options
));
876 return MSVCRT_vsnprintf_s_l_opt(str
, INT_MAX
, count
, format
, options
& UCRTBASE_PRINTF_MASK
, locale
, valist
);
879 /*********************************************************************
880 * vsprintf (MSVCRT.@)
882 int CDECL
MSVCRT_vsprintf( char *str
, const char *format
, __ms_va_list valist
)
884 return MSVCRT_vsnprintf(str
, INT_MAX
, format
, valist
);
887 /*********************************************************************
888 * vsprintf_s (MSVCRT.@)
890 int CDECL
MSVCRT_vsprintf_s( char *str
, MSVCRT_size_t num
, const char *format
, __ms_va_list valist
)
892 return MSVCRT_vsnprintf(str
, num
, format
, valist
);
895 /*********************************************************************
896 * _vscprintf (MSVCRT.@)
898 int CDECL
MSVCRT__vscprintf( const char *format
, __ms_va_list valist
)
900 return MSVCRT_vsnprintf( NULL
, INT_MAX
, format
, valist
);
903 /*********************************************************************
904 * _vscprintf_p_l (MSVCRT.@)
906 int CDECL
MSVCRT__vscprintf_p_l(const char *format
,
907 MSVCRT__locale_t locale
, __ms_va_list args
)
909 printf_arg args_ctx
[MSVCRT__ARGMAX
+1];
910 struct _str_ctx_a puts_ctx
= {INT_MAX
, NULL
};
913 memset(args_ctx
, 0, sizeof(args_ctx
));
915 ret
= create_positional_ctx_a(args_ctx
, format
, args
);
917 MSVCRT__invalid_parameter(NULL
, NULL
, NULL
, 0, 0);
918 *MSVCRT__errno() = MSVCRT_EINVAL
;
920 } else if(ret
== 0) {
921 ret
= pf_printf_a(puts_clbk_str_a
, &puts_ctx
, format
, locale
,
922 MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER
,
923 arg_clbk_valist
, NULL
, &args
);
925 ret
= pf_printf_a(puts_clbk_str_a
, &puts_ctx
, format
, locale
,
926 MSVCRT_PRINTF_POSITIONAL_PARAMS
| MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER
,
927 arg_clbk_positional
, args_ctx
, NULL
);
933 /*********************************************************************
934 * _vscprintf_p (MSVCR80.@)
936 int CDECL
MSVCRT__vscprintf_p(const char *format
, __ms_va_list argptr
)
938 return MSVCRT__vscprintf_p_l(format
, NULL
, argptr
);
941 /*********************************************************************
942 * _snprintf (MSVCRT.@)
944 int CDECL
MSVCRT__snprintf(char *str
, unsigned int len
, const char *format
, ...)
948 __ms_va_start(valist
, format
);
949 retval
= MSVCRT_vsnprintf(str
, len
, format
, valist
);
954 /*********************************************************************
955 * _snprintf_l (MSVCRT.@)
957 int CDECL
MSVCRT__snprintf_l(char *str
, unsigned int count
, MSVCRT__locale_t locale
,
958 const char *format
, ...)
962 __ms_va_start(valist
, format
);
963 retval
= MSVCRT_vsnprintf_l(str
, count
, format
, locale
, valist
);
968 /*********************************************************************
969 * _snprintf_s (MSVCRT.@)
971 int CDECL
MSVCRT__snprintf_s(char *str
, unsigned int len
, unsigned int count
,
972 const char *format
, ...)
976 __ms_va_start(valist
, format
);
977 retval
= MSVCRT_vsnprintf_s_l(str
, len
, count
, format
, NULL
, valist
);
982 /*********************************************************************
983 * _scprintf (MSVCRT.@)
985 int CDECL
MSVCRT__scprintf(const char *format
, ...)
989 __ms_va_start(valist
, format
);
990 retval
= MSVCRT__vscprintf(format
, valist
);
995 /*********************************************************************
996 * _vsnwprintf (MSVCRT.@)
998 int CDECL
MSVCRT_vsnwprintf(MSVCRT_wchar_t
*str
, MSVCRT_size_t len
,
999 const MSVCRT_wchar_t
*format
, __ms_va_list valist
)
1001 static const MSVCRT_wchar_t nullbyte
= '\0';
1002 struct _str_ctx_w ctx
= {len
, str
};
1005 ret
= pf_printf_w(puts_clbk_str_w
, &ctx
, format
, NULL
, 0,
1006 arg_clbk_valist
, NULL
, &valist
);
1007 puts_clbk_str_w(&ctx
, 1, &nullbyte
);
1011 /*********************************************************************
1012 * _vsnwprintf_l (MSVCRT.@)
1014 int CDECL
MSVCRT_vsnwprintf_l(MSVCRT_wchar_t
*str
, MSVCRT_size_t len
,
1015 const MSVCRT_wchar_t
*format
, MSVCRT__locale_t locale
,
1016 __ms_va_list valist
)
1018 static const MSVCRT_wchar_t nullbyte
= '\0';
1019 struct _str_ctx_w ctx
= {len
, str
};
1022 ret
= pf_printf_w(puts_clbk_str_w
, &ctx
, format
, locale
, 0,
1023 arg_clbk_valist
, NULL
, &valist
);
1024 puts_clbk_str_w(&ctx
, 1, &nullbyte
);
1028 /*********************************************************************
1029 * _vswprintf_p_l (MSVCRT.@)
1031 int CDECL
MSVCRT_vswprintf_p_l(MSVCRT_wchar_t
*buffer
, MSVCRT_size_t length
,
1032 const MSVCRT_wchar_t
*format
, MSVCRT__locale_t locale
, __ms_va_list args
)
1034 static const MSVCRT_wchar_t nullbyte
= '\0';
1035 printf_arg args_ctx
[MSVCRT__ARGMAX
+1];
1036 struct _str_ctx_w puts_ctx
= {length
, buffer
};
1039 memset(args_ctx
, 0, sizeof(args_ctx
));
1041 ret
= create_positional_ctx_w(args_ctx
, format
, args
);
1043 MSVCRT__invalid_parameter(NULL
, NULL
, NULL
, 0, 0);
1044 *MSVCRT__errno() = MSVCRT_EINVAL
;
1047 ret
= pf_printf_w(puts_clbk_str_w
, &puts_ctx
, format
, locale
, MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER
,
1048 arg_clbk_valist
, NULL
, &args
);
1050 ret
= pf_printf_w(puts_clbk_str_w
, &puts_ctx
, format
, locale
,
1051 MSVCRT_PRINTF_POSITIONAL_PARAMS
| MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER
,
1052 arg_clbk_positional
, args_ctx
, NULL
);
1054 puts_clbk_str_w(&puts_ctx
, 1, &nullbyte
);
1058 /*********************************************************************
1059 * _vswprintf_p (MSVCR100.@)
1061 int CDECL
MSVCRT__vswprintf_p(MSVCRT_wchar_t
*buffer
, MSVCRT_size_t length
,
1062 const MSVCRT_wchar_t
*format
, __ms_va_list args
)
1064 return MSVCRT_vswprintf_p_l(buffer
, length
, format
, NULL
, args
);
1067 /*********************************************************************
1068 * _vsnwprintf_s_l (MSVCRT.@)
1070 int CDECL
MSVCRT_vsnwprintf_s_l( MSVCRT_wchar_t
*str
, MSVCRT_size_t sizeOfBuffer
,
1071 MSVCRT_size_t count
, const MSVCRT_wchar_t
*format
,
1072 MSVCRT__locale_t locale
, __ms_va_list valist
)
1074 static const MSVCRT_wchar_t nullbyte
= '\0';
1075 struct _str_ctx_w ctx
;
1079 if(count
!=-1 && len
>count
+1)
1084 ret
= pf_printf_w(puts_clbk_str_w
, &ctx
, format
, locale
, MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER
,
1085 arg_clbk_valist
, NULL
, &valist
);
1086 puts_clbk_str_w(&ctx
, 1, &nullbyte
);
1088 if(ret
<0 || ret
==len
) {
1089 if(count
!=MSVCRT__TRUNCATE
&& count
>sizeOfBuffer
) {
1090 MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small", MSVCRT_ERANGE
);
1091 memset(str
, 0, sizeOfBuffer
*sizeof(MSVCRT_wchar_t
));
1101 /*********************************************************************
1102 * _vsnwprintf_s (MSVCRT.@)
1104 int CDECL
MSVCRT_vsnwprintf_s(MSVCRT_wchar_t
*str
, MSVCRT_size_t sizeOfBuffer
,
1105 MSVCRT_size_t count
, const MSVCRT_wchar_t
*format
, __ms_va_list valist
)
1107 return MSVCRT_vsnwprintf_s_l(str
, sizeOfBuffer
, count
,
1108 format
, NULL
, valist
);
1111 /*********************************************************************
1112 * _snwprintf (MSVCRT.@)
1114 int CDECL
MSVCRT__snwprintf( MSVCRT_wchar_t
*str
, unsigned int len
, const MSVCRT_wchar_t
*format
, ...)
1117 __ms_va_list valist
;
1118 __ms_va_start(valist
, format
);
1119 retval
= MSVCRT_vsnwprintf(str
, len
, format
, valist
);
1120 __ms_va_end(valist
);
1124 /*********************************************************************
1125 * _snwprintf_l (MSVCRT.@)
1127 int CDECL
MSVCRT__snwprintf_l( MSVCRT_wchar_t
*str
, unsigned int len
, const MSVCRT_wchar_t
*format
,
1128 MSVCRT__locale_t locale
, ...)
1131 __ms_va_list valist
;
1132 __ms_va_start(valist
, locale
);
1133 retval
= MSVCRT_vsnwprintf_l(str
, len
, format
, locale
, valist
);
1134 __ms_va_end(valist
);
1138 /*********************************************************************
1139 * _snwprintf_s (MSVCRT.@)
1141 int CDECL
MSVCRT__snwprintf_s( MSVCRT_wchar_t
*str
, unsigned int len
, unsigned int count
,
1142 const MSVCRT_wchar_t
*format
, ...)
1145 __ms_va_list valist
;
1146 __ms_va_start(valist
, format
);
1147 retval
= MSVCRT_vsnwprintf_s_l(str
, len
, count
, format
, NULL
, valist
);
1148 __ms_va_end(valist
);
1152 /*********************************************************************
1153 * _snwprintf_s_l (MSVCRT.@)
1155 int CDECL
MSVCRT__snwprintf_s_l( MSVCRT_wchar_t
*str
, unsigned int len
, unsigned int count
,
1156 const MSVCRT_wchar_t
*format
, MSVCRT__locale_t locale
, ... )
1159 __ms_va_list valist
;
1160 __ms_va_start(valist
, locale
);
1161 retval
= MSVCRT_vsnwprintf_s_l(str
, len
, count
, format
, locale
, valist
);
1162 __ms_va_end(valist
);
1166 static int puts_clbk_str_c99_w(void *ctx
, int len
, const MSVCRT_wchar_t
*str
)
1168 struct _str_ctx_w
*out
= ctx
;
1173 if(out
->len
< len
) {
1174 memcpy(out
->buf
, str
, out
->len
*sizeof(MSVCRT_wchar_t
));
1175 out
->buf
+= out
->len
;
1180 memcpy(out
->buf
, str
, len
*sizeof(MSVCRT_wchar_t
));
1186 /*********************************************************************
1187 * __stdio_common_vswprintf (MSVCRT.@)
1189 int CDECL
MSVCRT__stdio_common_vswprintf( unsigned __int64 options
,
1190 MSVCRT_wchar_t
*str
, MSVCRT_size_t len
, const MSVCRT_wchar_t
*format
,
1191 MSVCRT__locale_t locale
, __ms_va_list valist
)
1193 static const MSVCRT_wchar_t nullbyte
= '\0';
1194 struct _str_ctx_w ctx
= {len
, str
};
1197 if (options
& ~UCRTBASE_PRINTF_MASK
)
1198 FIXME("options %s not handled\n", wine_dbgstr_longlong(options
));
1199 ret
= pf_printf_w(puts_clbk_str_c99_w
,
1200 &ctx
, format
, locale
, options
& UCRTBASE_PRINTF_MASK
, arg_clbk_valist
, NULL
, &valist
);
1201 puts_clbk_str_w(&ctx
, 1, &nullbyte
);
1203 if(options
& UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION
)
1204 return ret
>len
? -1 : ret
;
1206 if(len
) str
[len
-1] = 0;
1207 return (options
& UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR
) ? ret
: -2;
1212 /*********************************************************************
1213 * sprintf (MSVCRT.@)
1215 int CDECL
MSVCRT_sprintf( char *str
, const char *format
, ... )
1220 __ms_va_start( ap
, format
);
1221 r
= MSVCRT_vsnprintf( str
, INT_MAX
, format
, ap
);
1226 /*********************************************************************
1227 * sprintf_s (MSVCRT.@)
1229 int CDECL
MSVCRT_sprintf_s( char *str
, MSVCRT_size_t num
, const char *format
, ... )
1234 __ms_va_start( ap
, format
);
1235 r
= MSVCRT_vsnprintf( str
, num
, format
, ap
);
1240 /*********************************************************************
1241 * _scwprintf (MSVCRT.@)
1243 int CDECL
MSVCRT__scwprintf( const MSVCRT_wchar_t
*format
, ... )
1248 __ms_va_start( ap
, format
);
1249 r
= MSVCRT_vsnwprintf( NULL
, INT_MAX
, format
, ap
);
1254 /*********************************************************************
1255 * swprintf (MSVCRT.@)
1257 int CDECL
MSVCRT_swprintf( MSVCRT_wchar_t
*str
, const MSVCRT_wchar_t
*format
, ... )
1262 __ms_va_start( ap
, format
);
1263 r
= MSVCRT_vsnwprintf( str
, INT_MAX
, format
, ap
);
1268 /*********************************************************************
1269 * swprintf_s (MSVCRT.@)
1271 int CDECL
MSVCRT_swprintf_s(MSVCRT_wchar_t
*str
, MSVCRT_size_t numberOfElements
,
1272 const MSVCRT_wchar_t
*format
, ... )
1277 __ms_va_start(ap
, format
);
1278 r
= MSVCRT_vsnwprintf_s(str
, numberOfElements
, INT_MAX
, format
, ap
);
1284 /*********************************************************************
1285 * _swprintf_s_l (MSVCRT.@)
1287 int CDECL
MSVCRT__swprintf_s_l(MSVCRT_wchar_t
*str
, MSVCRT_size_t numberOfElements
,
1288 const MSVCRT_wchar_t
*format
, MSVCRT__locale_t locale
, ... )
1293 __ms_va_start(ap
, locale
);
1294 r
= MSVCRT_vsnwprintf_s_l(str
, numberOfElements
, INT_MAX
, format
, locale
, ap
);
1300 /*********************************************************************
1301 * _vswprintf (MSVCRT.@)
1303 int CDECL
MSVCRT_vswprintf( MSVCRT_wchar_t
* str
, const MSVCRT_wchar_t
* format
, __ms_va_list args
)
1305 return MSVCRT_vsnwprintf( str
, INT_MAX
, format
, args
);
1308 /*********************************************************************
1309 * _vswprintf (MSVCRT.@)
1311 int CDECL
MSVCRT_vswprintf_l( MSVCRT_wchar_t
* str
, const MSVCRT_wchar_t
* format
,
1312 MSVCRT__locale_t locale
, __ms_va_list args
)
1314 return MSVCRT_vsnwprintf_l( str
, INT_MAX
, format
, locale
, args
);
1317 /*********************************************************************
1318 * _vscwprintf (MSVCRT.@)
1320 int CDECL
MSVCRT__vscwprintf( const MSVCRT_wchar_t
*format
, __ms_va_list args
)
1322 return MSVCRT_vsnwprintf( NULL
, INT_MAX
, format
, args
);
1325 /*********************************************************************
1326 * _vscwprintf_l (MSVCRT.@)
1328 int CDECL
MSVCRT__vscwprintf_l( const MSVCRT_wchar_t
*format
, MSVCRT__locale_t locale
, __ms_va_list args
)
1330 return MSVCRT_vsnwprintf_l( NULL
, INT_MAX
, format
, locale
, args
);
1333 /*********************************************************************
1334 * _vscwprintf_p_l (MSVCRT.@)
1336 int CDECL
MSVCRT__vscwprintf_p_l( const MSVCRT_wchar_t
*format
, MSVCRT__locale_t locale
, __ms_va_list args
)
1338 return MSVCRT_vswprintf_p_l( NULL
, INT_MAX
, format
, locale
, args
);
1341 /*********************************************************************
1342 * _vscwprintf_p (MSVCR100.@)
1344 int CDECL
MSVCRT__vscwprintf_p(const MSVCRT_wchar_t
*format
, __ms_va_list args
)
1346 return MSVCRT_vswprintf_p_l(NULL
, INT_MAX
, format
, NULL
, args
);
1349 /*********************************************************************
1350 * vswprintf_s (MSVCRT.@)
1352 int CDECL
MSVCRT_vswprintf_s(MSVCRT_wchar_t
* str
, MSVCRT_size_t numberOfElements
,
1353 const MSVCRT_wchar_t
* format
, __ms_va_list args
)
1355 return MSVCRT_vsnwprintf_s(str
, numberOfElements
, INT_MAX
, format
, args
);
1358 /*********************************************************************
1359 * _vswprintf_s_l (MSVCRT.@)
1361 int CDECL
MSVCRT_vswprintf_s_l(MSVCRT_wchar_t
* str
, MSVCRT_size_t numberOfElements
,
1362 const MSVCRT_wchar_t
* format
, MSVCRT__locale_t locale
, __ms_va_list args
)
1364 return MSVCRT_vsnwprintf_s_l(str
, numberOfElements
, INT_MAX
,
1365 format
, locale
, args
);
1368 /*********************************************************************
1369 * _vsprintf_p_l (MSVCRT.@)
1371 int CDECL
MSVCRT_vsprintf_p_l(char *buffer
, MSVCRT_size_t length
, const char *format
,
1372 MSVCRT__locale_t locale
, __ms_va_list args
)
1374 static const char nullbyte
= '\0';
1375 printf_arg args_ctx
[MSVCRT__ARGMAX
+1];
1376 struct _str_ctx_a puts_ctx
= {length
, buffer
};
1379 memset(args_ctx
, 0, sizeof(args_ctx
));
1381 ret
= create_positional_ctx_a(args_ctx
, format
, args
);
1383 MSVCRT__invalid_parameter(NULL
, NULL
, NULL
, 0, 0);
1384 *MSVCRT__errno() = MSVCRT_EINVAL
;
1387 ret
= pf_printf_a(puts_clbk_str_a
, &puts_ctx
, format
, locale
, MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER
,
1388 arg_clbk_valist
, NULL
, &args
);
1390 ret
= pf_printf_a(puts_clbk_str_a
, &puts_ctx
, format
, locale
,
1391 MSVCRT_PRINTF_POSITIONAL_PARAMS
| MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER
,
1392 arg_clbk_positional
, args_ctx
, NULL
);
1394 puts_clbk_str_a(&puts_ctx
, 1, &nullbyte
);
1398 /*********************************************************************
1399 * _vsprintf_p (MSVCRT.@)
1401 int CDECL
MSVCRT_vsprintf_p(char *buffer
, MSVCRT_size_t length
,
1402 const char *format
, __ms_va_list args
)
1404 return MSVCRT_vsprintf_p_l(buffer
, length
, format
, NULL
, args
);
1407 /*********************************************************************
1408 * _sprintf_p_l (MSVCRT.@)
1410 int CDECL
MSVCRT_sprintf_p_l(char *buffer
, MSVCRT_size_t length
,
1411 const char *format
, MSVCRT__locale_t locale
, ...)
1413 __ms_va_list valist
;
1416 __ms_va_start(valist
, locale
);
1417 r
= MSVCRT_vsprintf_p_l(buffer
, length
, format
, locale
, valist
);
1418 __ms_va_end(valist
);
1423 /*********************************************************************
1424 * __swprintf_l (MSVCRT.@)
1426 int CDECL
MSVCRT___swprintf_l( MSVCRT_wchar_t
*str
, const MSVCRT_wchar_t
*format
,
1427 MSVCRT__locale_t locale
, ...)
1430 __ms_va_list valist
;
1431 __ms_va_start(valist
, locale
);
1432 retval
= MSVCRT_vswprintf_l(str
, format
, locale
, valist
);
1433 __ms_va_end(valist
);
1437 /*********************************************************************
1438 * _sprintf_p (MSVCR100.@)
1440 int CDECL
MSVCRT__sprintf_p(char *buffer
, MSVCRT_size_t length
, const char *format
, ...)
1442 __ms_va_list valist
;
1445 __ms_va_start(valist
, format
);
1446 r
= MSVCRT_vsprintf_p_l(buffer
, length
, format
, NULL
, valist
);
1447 __ms_va_end(valist
);
1452 /*********************************************************************
1453 * _swprintf_p_l (MSVCRT.@)
1455 int CDECL
MSVCRT_swprintf_p_l(MSVCRT_wchar_t
*buffer
, MSVCRT_size_t length
,
1456 const MSVCRT_wchar_t
*format
, MSVCRT__locale_t locale
, ...)
1458 __ms_va_list valist
;
1461 __ms_va_start(valist
, locale
);
1462 r
= MSVCRT_vswprintf_p_l(buffer
, length
, format
, locale
, valist
);
1463 __ms_va_end(valist
);
1468 /*********************************************************************
1469 * _wcscoll_l (MSVCRT.@)
1471 int CDECL
MSVCRT__wcscoll_l(const MSVCRT_wchar_t
* str1
, const MSVCRT_wchar_t
* str2
, MSVCRT__locale_t locale
)
1473 MSVCRT_pthreadlocinfo locinfo
;
1476 locinfo
= get_locinfo();
1478 locinfo
= locale
->locinfo
;
1480 if(!locinfo
->lc_handle
[MSVCRT_LC_COLLATE
])
1481 return strcmpW(str1
, str2
);
1482 return CompareStringW(locinfo
->lc_handle
[MSVCRT_LC_COLLATE
], 0, str1
, -1, str2
, -1)-CSTR_EQUAL
;
1485 /*********************************************************************
1486 * wcscoll (MSVCRT.@)
1488 int CDECL
MSVCRT_wcscoll( const MSVCRT_wchar_t
* str1
, const MSVCRT_wchar_t
* str2
)
1490 return MSVCRT__wcscoll_l(str1
, str2
, NULL
);
1493 /*********************************************************************
1494 * wcspbrk (MSVCRT.@)
1496 MSVCRT_wchar_t
* CDECL
MSVCRT_wcspbrk( const MSVCRT_wchar_t
* str
, const MSVCRT_wchar_t
* accept
)
1498 const MSVCRT_wchar_t
* p
;
1502 for (p
= accept
; *p
; p
++) if (*p
== *str
) return (MSVCRT_wchar_t
*)str
;
1508 /*********************************************************************
1509 * wcstok_s (MSVCRT.@)
1511 MSVCRT_wchar_t
* CDECL
MSVCRT_wcstok_s( MSVCRT_wchar_t
*str
, const MSVCRT_wchar_t
*delim
,
1512 MSVCRT_wchar_t
**next_token
)
1514 MSVCRT_wchar_t
*ret
;
1516 if (!MSVCRT_CHECK_PMT(delim
!= NULL
)) return NULL
;
1517 if (!MSVCRT_CHECK_PMT(next_token
!= NULL
)) return NULL
;
1518 if (!MSVCRT_CHECK_PMT(str
!= NULL
|| *next_token
!= NULL
)) return NULL
;
1520 if (!str
) str
= *next_token
;
1522 while (*str
&& strchrW( delim
, *str
)) str
++;
1523 if (!*str
) return NULL
;
1525 while (*str
&& !strchrW( delim
, *str
)) str
++;
1526 if (*str
) *str
++ = 0;
1531 /*********************************************************************
1534 MSVCRT_wchar_t
* CDECL
MSVCRT_wcstok( MSVCRT_wchar_t
*str
, const MSVCRT_wchar_t
*delim
)
1536 return MSVCRT_wcstok_s(str
, delim
, &msvcrt_get_thread_data()->wcstok_next
);
1539 /*********************************************************************
1540 * _wctomb_s_l (MSVCRT.@)
1542 int CDECL
MSVCRT__wctomb_s_l(int *len
, char *mbchar
, MSVCRT_size_t size
,
1543 MSVCRT_wchar_t wch
, MSVCRT__locale_t locale
)
1545 MSVCRT_pthreadlocinfo locinfo
;
1549 if(!mbchar
&& size
>0) {
1558 if(!MSVCRT_CHECK_PMT(size
<= INT_MAX
))
1559 return MSVCRT_EINVAL
;
1562 locinfo
= get_locinfo();
1564 locinfo
= locale
->locinfo
;
1566 if(!locinfo
->lc_codepage
) {
1568 if(mbchar
&& size
>0)
1569 memset(mbchar
, 0, size
);
1570 *MSVCRT__errno() = MSVCRT_EILSEQ
;
1571 return MSVCRT_EILSEQ
;
1574 if(!MSVCRT_CHECK_PMT_ERR(size
>= 1, MSVCRT_ERANGE
))
1575 return MSVCRT_ERANGE
;
1583 mblen
= WideCharToMultiByte(locinfo
->lc_codepage
, 0, &wch
, 1, mbchar
, size
, NULL
, &error
);
1584 if(!mblen
|| error
) {
1585 if(!mblen
&& GetLastError()==ERROR_INSUFFICIENT_BUFFER
) {
1586 if(mbchar
&& size
>0)
1587 memset(mbchar
, 0, size
);
1589 MSVCRT_INVALID_PMT("insufficient buffer size", MSVCRT_ERANGE
);
1590 return MSVCRT_ERANGE
;
1593 *MSVCRT__errno() = MSVCRT_EILSEQ
;
1594 return MSVCRT_EILSEQ
;
1602 /*********************************************************************
1603 * wctomb_s (MSVCRT.@)
1605 int CDECL
MSVCRT_wctomb_s(int *len
, char *mbchar
, MSVCRT_size_t size
, MSVCRT_wchar_t wch
)
1607 return MSVCRT__wctomb_s_l(len
, mbchar
, size
, wch
, NULL
);
1610 /*********************************************************************
1611 * _wctomb_l (MSVCRT.@)
1613 int CDECL
MSVCRT__wctomb_l(char *dst
, MSVCRT_wchar_t ch
, MSVCRT__locale_t locale
)
1617 MSVCRT__wctomb_s_l(&len
, dst
, dst
? MSVCRT_MB_LEN_MAX
: 0, ch
, locale
);
1621 /*********************************************************************
1624 INT CDECL
MSVCRT_wctomb( char *dst
, MSVCRT_wchar_t ch
)
1626 return MSVCRT__wctomb_l(dst
, ch
, NULL
);
1629 /*********************************************************************
1632 INT CDECL
MSVCRT_wctob( MSVCRT_wint_t wchar
)
1636 UINT codepage
= get_locinfo()->lc_codepage
;
1640 return (signed char)wchar
;
1643 } else if(WideCharToMultiByte( codepage
, 0, &wchar
, 1, &out
, 1, NULL
, &error
) && !error
)
1648 /*********************************************************************
1649 * wcrtomb (MSVCRT.@)
1651 MSVCRT_size_t CDECL
MSVCRT_wcrtomb( char *dst
, MSVCRT_wchar_t ch
, MSVCRT_mbstate_t
*s
)
1655 return MSVCRT_wctomb(dst
, ch
);
1658 /*********************************************************************
1659 * iswalnum (MSVCRT.@)
1661 INT CDECL
MSVCRT_iswalnum( MSVCRT_wchar_t wc
)
1663 return isalnumW( wc
);
1666 /*********************************************************************
1667 * iswalpha (MSVCRT.@)
1669 INT CDECL
MSVCRT_iswalpha( MSVCRT_wchar_t wc
)
1671 return isalphaW( wc
);
1674 /*********************************************************************
1675 * iswalpha_l (MSVCRT.@)
1677 INT CDECL
MSVCRT__iswalpha_l( MSVCRT_wchar_t wc
, MSVCRT__locale_t locale
)
1679 return isalphaW( wc
);
1682 /*********************************************************************
1683 * iswcntrl (MSVCRT.@)
1685 INT CDECL
MSVCRT_iswcntrl( MSVCRT_wchar_t wc
)
1687 return iscntrlW( wc
);
1690 /*********************************************************************
1691 * iswdigit (MSVCRT.@)
1693 INT CDECL
MSVCRT_iswdigit( MSVCRT_wchar_t wc
)
1695 return isdigitW( wc
);
1698 /*********************************************************************
1699 * _iswdigit_l (MSVCRT.@)
1701 INT CDECL
MSVCRT__iswdigit_l( MSVCRT_wchar_t wc
, MSVCRT__locale_t locale
)
1703 return isdigitW( wc
);
1706 /*********************************************************************
1707 * iswgraph (MSVCRT.@)
1709 INT CDECL
MSVCRT_iswgraph( MSVCRT_wchar_t wc
)
1711 return isgraphW( wc
);
1714 /*********************************************************************
1715 * iswlower (MSVCRT.@)
1717 INT CDECL
MSVCRT_iswlower( MSVCRT_wchar_t wc
)
1719 return islowerW( wc
);
1722 /*********************************************************************
1723 * iswprint (MSVCRT.@)
1725 INT CDECL
MSVCRT_iswprint( MSVCRT_wchar_t wc
)
1727 return isprintW( wc
);
1730 /*********************************************************************
1731 * _iswpunct_l (MSVCRT.@)
1733 INT CDECL
MSVCRT__iswpunct_l( MSVCRT_wchar_t wc
, MSVCRT__locale_t locale
)
1735 return ispunctW( wc
);
1738 /*********************************************************************
1739 * iswpunct (MSVCRT.@)
1741 INT CDECL
MSVCRT_iswpunct( MSVCRT_wchar_t wc
)
1743 return ispunctW( wc
);
1746 /*********************************************************************
1747 * _iswspace_l (MSVCRT.@)
1749 INT CDECL
MSVCRT__iswspace_l( MSVCRT_wchar_t wc
, MSVCRT__locale_t locale
)
1751 return isspaceW( wc
);
1754 /*********************************************************************
1755 * iswspace (MSVCRT.@)
1757 INT CDECL
MSVCRT_iswspace( MSVCRT_wchar_t wc
)
1759 return isspaceW( wc
);
1762 /*********************************************************************
1763 * iswupper (MSVCRT.@)
1765 INT CDECL
MSVCRT_iswupper( MSVCRT_wchar_t wc
)
1767 return isupperW( wc
);
1770 /*********************************************************************
1771 * iswxdigit (MSVCRT.@)
1773 INT CDECL
MSVCRT_iswxdigit( MSVCRT_wchar_t wc
)
1775 return isxdigitW( wc
);
1778 /*********************************************************************
1779 * wcscpy_s (MSVCRT.@)
1781 INT CDECL
MSVCRT_wcscpy_s( MSVCRT_wchar_t
* wcDest
, MSVCRT_size_t numElement
, const MSVCRT_wchar_t
*wcSrc
)
1783 MSVCRT_size_t size
= 0;
1785 if(!MSVCRT_CHECK_PMT(wcDest
)) return MSVCRT_EINVAL
;
1786 if(!MSVCRT_CHECK_PMT(numElement
)) return MSVCRT_EINVAL
;
1790 if(!MSVCRT_CHECK_PMT(wcSrc
)) return MSVCRT_EINVAL
;
1792 size
= strlenW(wcSrc
) + 1;
1794 if(!MSVCRT_CHECK_PMT_ERR(size
<= numElement
, MSVCRT_ERANGE
))
1795 return MSVCRT_ERANGE
;
1797 memcpy( wcDest
, wcSrc
, size
*sizeof(WCHAR
) );
1802 /******************************************************************
1803 * wcsncpy (MSVCRT.@)
1805 MSVCRT_wchar_t
* __cdecl
MSVCRT_wcsncpy( MSVCRT_wchar_t
* s1
,
1806 const MSVCRT_wchar_t
*s2
, MSVCRT_size_t n
)
1811 if(!(s1
[i
] = s2
[i
])) break;
1817 /******************************************************************
1818 * wcsncpy_s (MSVCRT.@)
1820 INT CDECL
MSVCRT_wcsncpy_s( MSVCRT_wchar_t
* wcDest
, MSVCRT_size_t numElement
, const MSVCRT_wchar_t
*wcSrc
,
1821 MSVCRT_size_t count
)
1824 BOOL truncate
= (count
== MSVCRT__TRUNCATE
);
1826 if(!wcDest
&& !numElement
&& !count
)
1829 if (!wcDest
|| !numElement
)
1830 return MSVCRT_EINVAL
;
1835 return count
? MSVCRT_EINVAL
: 0;
1838 while (numElement
&& count
&& *wcSrc
)
1844 if (!numElement
&& truncate
)
1847 return MSVCRT_STRUNCATE
;
1849 else if (!numElement
)
1852 return MSVCRT_ERANGE
;
1859 /******************************************************************
1860 * wcscat_s (MSVCRT.@)
1863 INT CDECL
MSVCRT_wcscat_s(MSVCRT_wchar_t
* dst
, MSVCRT_size_t elem
, const MSVCRT_wchar_t
* src
)
1865 MSVCRT_wchar_t
* ptr
= dst
;
1867 if (!dst
|| elem
== 0) return MSVCRT_EINVAL
;
1871 return MSVCRT_EINVAL
;
1874 /* seek to end of dst string (or elem if no end of string is found */
1875 while (ptr
< dst
+ elem
&& *ptr
!= '\0') ptr
++;
1876 while (ptr
< dst
+ elem
)
1878 if ((*ptr
++ = *src
++) == '\0') return 0;
1880 /* not enough space */
1882 return MSVCRT_ERANGE
;
1885 /*********************************************************************
1886 * wcsncat_s (MSVCRT.@)
1889 INT CDECL
MSVCRT_wcsncat_s(MSVCRT_wchar_t
*dst
, MSVCRT_size_t elem
,
1890 const MSVCRT_wchar_t
*src
, MSVCRT_size_t count
)
1892 MSVCRT_size_t srclen
;
1893 MSVCRT_wchar_t dststart
;
1896 if (!MSVCRT_CHECK_PMT(dst
!= NULL
)) return MSVCRT_EINVAL
;
1897 if (!MSVCRT_CHECK_PMT(elem
> 0)) return MSVCRT_EINVAL
;
1898 if (!MSVCRT_CHECK_PMT(src
!= NULL
|| count
== 0)) return MSVCRT_EINVAL
;
1903 for (dststart
= 0; dststart
< elem
; dststart
++)
1905 if (dst
[dststart
] == '\0')
1908 if (dststart
== elem
)
1910 MSVCRT_INVALID_PMT("dst[elem] is not NULL terminated\n", MSVCRT_EINVAL
);
1911 return MSVCRT_EINVAL
;
1914 if (count
== MSVCRT__TRUNCATE
)
1916 srclen
= strlenW(src
);
1917 if (srclen
>= (elem
- dststart
))
1919 srclen
= elem
- dststart
- 1;
1920 ret
= MSVCRT_STRUNCATE
;
1924 srclen
= min(strlenW(src
), count
);
1925 if (srclen
< (elem
- dststart
))
1927 memcpy(&dst
[dststart
], src
, srclen
*sizeof(MSVCRT_wchar_t
));
1928 dst
[dststart
+srclen
] = '\0';
1931 MSVCRT_INVALID_PMT("dst[elem] is too small", MSVCRT_ERANGE
);
1933 return MSVCRT_ERANGE
;
1936 /*********************************************************************
1937 * _wcstoi64_l (MSVCRT.@)
1939 * FIXME: locale parameter is ignored
1941 __int64 CDECL
MSVCRT__wcstoi64_l(const MSVCRT_wchar_t
*nptr
,
1942 MSVCRT_wchar_t
**endptr
, int base
, MSVCRT__locale_t locale
)
1944 BOOL negative
= FALSE
;
1947 TRACE("(%s %p %d %p)\n", debugstr_w(nptr
), endptr
, base
, locale
);
1949 if (!MSVCRT_CHECK_PMT(nptr
!= NULL
)) return 0;
1950 if (!MSVCRT_CHECK_PMT(base
== 0 || base
>= 2)) return 0;
1951 if (!MSVCRT_CHECK_PMT(base
<= 36)) return 0;
1953 while(isspaceW(*nptr
)) nptr
++;
1958 } else if(*nptr
== '+')
1961 if((base
==0 || base
==16) && *nptr
=='0' && tolowerW(*(nptr
+1))=='x') {
1974 MSVCRT_wchar_t cur
= tolowerW(*nptr
);
1982 if(cur
<'a' || cur
>='a'+base
-10)
1992 if(!negative
&& (ret
>MSVCRT_I64_MAX
/base
|| ret
*base
>MSVCRT_I64_MAX
-v
)) {
1993 ret
= MSVCRT_I64_MAX
;
1994 *MSVCRT__errno() = MSVCRT_ERANGE
;
1995 } else if(negative
&& (ret
<MSVCRT_I64_MIN
/base
|| ret
*base
<MSVCRT_I64_MIN
-v
)) {
1996 ret
= MSVCRT_I64_MIN
;
1997 *MSVCRT__errno() = MSVCRT_ERANGE
;
2003 *endptr
= (MSVCRT_wchar_t
*)nptr
;
2008 /*********************************************************************
2009 * _wcstoi64 (MSVCRT.@)
2011 __int64 CDECL
MSVCRT__wcstoi64(const MSVCRT_wchar_t
*nptr
,
2012 MSVCRT_wchar_t
**endptr
, int base
)
2014 return MSVCRT__wcstoi64_l(nptr
, endptr
, base
, NULL
);
2017 /*********************************************************************
2018 * _wcstol_l (MSVCRT.@)
2020 MSVCRT_long CDECL
MSVCRT__wcstol_l(const MSVCRT_wchar_t
*s
,
2021 MSVCRT_wchar_t
**end
, int base
, MSVCRT__locale_t locale
)
2023 __int64 ret
= MSVCRT__wcstoi64_l(s
, end
, base
, locale
);
2025 if(ret
> MSVCRT_LONG_MAX
) {
2026 ret
= MSVCRT_LONG_MAX
;
2027 *MSVCRT__errno() = MSVCRT_ERANGE
;
2028 }else if(ret
< MSVCRT_LONG_MIN
) {
2029 ret
= MSVCRT_LONG_MIN
;
2030 *MSVCRT__errno() = MSVCRT_ERANGE
;
2035 /*********************************************************************
2036 * _wtoi_l (MSVCRT.@)
2038 int __cdecl
MSVCRT__wtoi_l(const MSVCRT_wchar_t
*str
, MSVCRT__locale_t locale
)
2040 __int64 ret
= MSVCRT__wcstoi64_l(str
, NULL
, 10, locale
);
2044 *MSVCRT__errno() = MSVCRT_ERANGE
;
2045 } else if(ret
< INT_MIN
) {
2047 *MSVCRT__errno() = MSVCRT_ERANGE
;
2052 /*********************************************************************
2055 int __cdecl
MSVCRT__wtoi(const MSVCRT_wchar_t
*str
)
2057 return MSVCRT__wtoi_l(str
, NULL
);
2060 /*********************************************************************
2061 * _wtol_l (MSVCRT.@)
2063 MSVCRT_long __cdecl
MSVCRT__wtol_l(const MSVCRT_wchar_t
*str
, MSVCRT__locale_t locale
)
2065 __int64 ret
= MSVCRT__wcstoi64_l(str
, NULL
, 10, locale
);
2067 if(ret
> MSVCRT_LONG_MAX
) {
2068 ret
= MSVCRT_LONG_MAX
;
2069 *MSVCRT__errno() = MSVCRT_ERANGE
;
2070 } else if(ret
< MSVCRT_LONG_MIN
) {
2071 ret
= MSVCRT_LONG_MIN
;
2072 *MSVCRT__errno() = MSVCRT_ERANGE
;
2077 /*********************************************************************
2080 MSVCRT_long __cdecl
MSVCRT__wtol(const MSVCRT_wchar_t
*str
)
2082 return MSVCRT__wtol_l(str
, NULL
);
2085 /*********************************************************************
2086 * _wcstoui64_l (MSVCRT.@)
2088 * FIXME: locale parameter is ignored
2090 unsigned __int64 CDECL
MSVCRT__wcstoui64_l(const MSVCRT_wchar_t
*nptr
,
2091 MSVCRT_wchar_t
**endptr
, int base
, MSVCRT__locale_t locale
)
2093 BOOL negative
= FALSE
;
2094 unsigned __int64 ret
= 0;
2096 TRACE("(%s %p %d %p)\n", debugstr_w(nptr
), endptr
, base
, locale
);
2098 if (!MSVCRT_CHECK_PMT(nptr
!= NULL
)) return 0;
2099 if (!MSVCRT_CHECK_PMT(base
== 0 || base
>= 2)) return 0;
2100 if (!MSVCRT_CHECK_PMT(base
<= 36)) return 0;
2102 while(isspaceW(*nptr
)) nptr
++;
2107 } else if(*nptr
== '+')
2110 if((base
==0 || base
==16) && *nptr
=='0' && tolowerW(*(nptr
+1))=='x') {
2123 MSVCRT_wchar_t cur
= tolowerW(*nptr
);
2131 if(cur
<'a' || cur
>='a'+base
-10)
2138 if(ret
>MSVCRT_UI64_MAX
/base
|| ret
*base
>MSVCRT_UI64_MAX
-v
) {
2139 ret
= MSVCRT_UI64_MAX
;
2140 *MSVCRT__errno() = MSVCRT_ERANGE
;
2146 *endptr
= (MSVCRT_wchar_t
*)nptr
;
2148 return negative
? -ret
: ret
;
2151 /*********************************************************************
2152 * _wcstoui64 (MSVCRT.@)
2154 unsigned __int64 CDECL
MSVCRT__wcstoui64(const MSVCRT_wchar_t
*nptr
,
2155 MSVCRT_wchar_t
**endptr
, int base
)
2157 return MSVCRT__wcstoui64_l(nptr
, endptr
, base
, NULL
);
2160 /*********************************************************************
2161 * _wcstoul_l (MSVCRT.@)
2163 MSVCRT_ulong __cdecl
MSVCRT__wcstoul_l(const MSVCRT_wchar_t
*s
,
2164 MSVCRT_wchar_t
**end
, int base
, MSVCRT__locale_t locale
)
2166 __int64 ret
= MSVCRT__wcstoui64_l(s
, end
, base
, locale
);
2168 if(ret
> MSVCRT_ULONG_MAX
) {
2169 ret
= MSVCRT_ULONG_MAX
;
2170 *MSVCRT__errno() = MSVCRT_ERANGE
;
2175 /*********************************************************************
2176 * wcstoul (MSVCRT.@)
2178 MSVCRT_ulong __cdecl
MSVCRT_wcstoul(const MSVCRT_wchar_t
*s
, MSVCRT_wchar_t
**end
, int base
)
2180 return MSVCRT__wcstoul_l(s
, end
, base
, NULL
);
2183 /******************************************************************
2184 * wcsnlen (MSVCRT.@)
2186 MSVCRT_size_t CDECL
MSVCRT_wcsnlen(const MSVCRT_wchar_t
*s
, MSVCRT_size_t maxlen
)
2190 for (i
= 0; i
< maxlen
; i
++)
2195 /*********************************************************************
2196 * _towupper_l (MSVCRT.@)
2198 int CDECL
MSVCRT__towupper_l(MSVCRT_wint_t c
, MSVCRT__locale_t locale
)
2203 /*********************************************************************
2204 * towupper (MSVCRT.@)
2206 int CDECL
MSVCRT_towupper(MSVCRT_wint_t c
)
2208 return MSVCRT__towupper_l(c
, NULL
);
2211 /*********************************************************************
2212 * _towlower_l (MSVCRT.@)
2214 int CDECL
MSVCRT__towlower_l(MSVCRT_wint_t c
, MSVCRT__locale_t locale
)
2219 /*********************************************************************
2220 * towlower (MSVCRT.@)
2222 int CDECL
MSVCRT_towlower(MSVCRT_wint_t c
)
2224 return MSVCRT__towlower_l(c
, NULL
);
2227 /*********************************************************************
2230 MSVCRT_wchar_t
* CDECL
MSVCRT_wcschr(const MSVCRT_wchar_t
*str
, MSVCRT_wchar_t ch
)
2232 return strchrW(str
, ch
);
2235 /***********************************************************************
2238 int CDECL
MSVCRT_wcslen(const MSVCRT_wchar_t
*str
)
2240 return strlenW(str
);
2243 /*********************************************************************
2246 MSVCRT_wchar_t
* CDECL
MSVCRT_wcsstr(const MSVCRT_wchar_t
*str
, const MSVCRT_wchar_t
*sub
)
2248 return strstrW(str
, sub
);
2251 /*********************************************************************
2252 * _wtoi64_l (MSVCRT.@)
2254 __int64 CDECL
MSVCRT__wtoi64_l(const MSVCRT_wchar_t
*str
, MSVCRT__locale_t locale
)
2256 ULONGLONG RunningTotal
= 0;
2257 BOOL bMinus
= FALSE
;
2259 while (isspaceW(*str
)) {
2265 } else if (*str
== '-') {
2270 while (*str
>= '0' && *str
<= '9') {
2271 RunningTotal
= RunningTotal
* 10 + *str
- '0';
2275 return bMinus
? -RunningTotal
: RunningTotal
;
2278 /*********************************************************************
2279 * _wtoi64 (MSVCRT.@)
2281 __int64 CDECL
MSVCRT__wtoi64(const MSVCRT_wchar_t
*str
)
2283 return MSVCRT__wtoi64_l(str
, NULL
);
2286 /*********************************************************************
2287 * wcsncmp (MSVCRT.@)
2289 int CDECL
MSVCRT_wcsncmp(const MSVCRT_wchar_t
*str1
, const MSVCRT_wchar_t
*str2
, int n
)
2291 return strncmpW(str1
, str2
, n
);
2294 /*********************************************************************
2295 * _wcsxfrm_l (MSVCRT.@)
2297 MSVCRT_size_t CDECL
MSVCRT__wcsxfrm_l(MSVCRT_wchar_t
*dest
, const MSVCRT_wchar_t
*src
,
2298 MSVCRT_size_t len
, MSVCRT__locale_t locale
)
2300 MSVCRT_pthreadlocinfo locinfo
;
2303 if(!MSVCRT_CHECK_PMT(src
)) return INT_MAX
;
2304 if(!MSVCRT_CHECK_PMT(dest
|| !len
)) return INT_MAX
;
2307 FIXME("len > INT_MAX not supported\n");
2312 locinfo
= get_locinfo();
2314 locinfo
= locale
->locinfo
;
2316 if(!locinfo
->lc_handle
[MSVCRT_LC_COLLATE
]) {
2317 MSVCRT_wcsncpy(dest
, src
, len
);
2318 return strlenW(src
);
2321 ret
= LCMapStringW(locinfo
->lc_handle
[MSVCRT_LC_COLLATE
],
2322 LCMAP_SORTKEY
, src
, -1, NULL
, 0);
2324 if(len
) dest
[0] = 0;
2325 *MSVCRT__errno() = MSVCRT_EILSEQ
;
2328 if(!len
) return ret
-1;
2332 *MSVCRT__errno() = MSVCRT_ERANGE
;
2336 ret
= LCMapStringW(locinfo
->lc_handle
[MSVCRT_LC_COLLATE
],
2337 LCMAP_SORTKEY
, src
, -1, dest
, len
) - 1;
2338 for(i
=ret
; i
>=0; i
--)
2339 dest
[i
] = ((unsigned char*)dest
)[i
];
2343 /*********************************************************************
2344 * wcsxfrm (MSVCRT.@)
2346 MSVCRT_size_t CDECL
MSVCRT_wcsxfrm(MSVCRT_wchar_t
*dest
,
2347 const MSVCRT_wchar_t
*src
, MSVCRT_size_t len
)
2349 return MSVCRT__wcsxfrm_l(dest
, src
, len
, NULL
);