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
, FALSE
, FALSE
,
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_TERMINATION_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
, FALSE
, FALSE
, 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
, FALSE
, FALSE
,
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 /*********************************************************************
782 * _vsnprintf_s_l (MSVCRT.@)
784 int CDECL
MSVCRT_vsnprintf_s_l( char *str
, MSVCRT_size_t sizeOfBuffer
,
785 MSVCRT_size_t count
, const char *format
,
786 MSVCRT__locale_t locale
, __ms_va_list valist
)
788 static const char nullbyte
= '\0';
789 struct _str_ctx_a ctx
;
792 if(sizeOfBuffer
<count
+1 || count
==-1)
799 ret
= pf_printf_a(puts_clbk_str_a
, &ctx
, format
, locale
, FALSE
, TRUE
,
800 arg_clbk_valist
, NULL
, &valist
);
801 puts_clbk_str_a(&ctx
, 1, &nullbyte
);
803 if(ret
<0 || ret
==len
) {
804 if(count
!=MSVCRT__TRUNCATE
&& count
>sizeOfBuffer
) {
805 MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small", MSVCRT_ERANGE
);
806 memset(str
, 0, sizeOfBuffer
);
816 /*********************************************************************
817 * _vsprintf_s_l (MSVCRT.@)
819 int CDECL
MSVCRT_vsprintf_s_l( char *str
, MSVCRT_size_t count
, const char *format
,
820 MSVCRT__locale_t locale
, __ms_va_list valist
)
822 return MSVCRT_vsnprintf_s_l(str
, INT_MAX
, count
, format
, locale
, valist
);
825 /*********************************************************************
826 * _sprintf_s_l (MSVCRT.@)
828 int CDECL
MSVCRT_sprintf_s_l( char *str
, MSVCRT_size_t count
, const char *format
,
829 MSVCRT__locale_t locale
, ...)
833 __ms_va_start(valist
, locale
);
834 retval
= MSVCRT_vsnprintf_s_l(str
, INT_MAX
, count
, format
, locale
, valist
);
839 /*********************************************************************
840 * _vsnprintf_s (MSVCRT.@)
842 int CDECL
MSVCRT_vsnprintf_s( char *str
, MSVCRT_size_t sizeOfBuffer
,
843 MSVCRT_size_t count
, const char *format
, __ms_va_list valist
)
845 return MSVCRT_vsnprintf_s_l(str
,sizeOfBuffer
, count
, format
, NULL
, valist
);
848 /*********************************************************************
849 * __stdio_common_vsnprintf_s (MSVCRT.@)
851 int CDECL
MSVCRT__stdio_common_vsnprintf_s( unsigned __int64 options
, char *str
, MSVCRT_size_t sizeOfBuffer
, MSVCRT_size_t count
, const char *format
,
852 MSVCRT__locale_t locale
, __ms_va_list valist
)
854 return MSVCRT_vsnprintf_s_l(str
, sizeOfBuffer
, count
, format
, locale
, valist
);
857 /*********************************************************************
858 * __stdio_common_vsprintf_s (MSVCRT.@)
860 int CDECL
MSVCRT__stdio_common_vsprintf_s( unsigned __int64 options
, char *str
, MSVCRT_size_t count
, const char *format
,
861 MSVCRT__locale_t locale
, __ms_va_list valist
)
863 return MSVCRT_vsnprintf_s_l(str
, INT_MAX
, count
, format
, locale
, valist
);
866 /*********************************************************************
867 * vsprintf (MSVCRT.@)
869 int CDECL
MSVCRT_vsprintf( char *str
, const char *format
, __ms_va_list valist
)
871 return MSVCRT_vsnprintf(str
, INT_MAX
, format
, valist
);
874 /*********************************************************************
875 * vsprintf_s (MSVCRT.@)
877 int CDECL
MSVCRT_vsprintf_s( char *str
, MSVCRT_size_t num
, const char *format
, __ms_va_list valist
)
879 return MSVCRT_vsnprintf(str
, num
, format
, valist
);
882 /*********************************************************************
883 * _vscprintf (MSVCRT.@)
885 int CDECL
MSVCRT__vscprintf( const char *format
, __ms_va_list valist
)
887 return MSVCRT_vsnprintf( NULL
, INT_MAX
, format
, valist
);
890 /*********************************************************************
891 * _vscprintf_p_l (MSVCRT.@)
893 int CDECL
MSVCRT__vscprintf_p_l(const char *format
,
894 MSVCRT__locale_t locale
, __ms_va_list args
)
896 printf_arg args_ctx
[MSVCRT__ARGMAX
+1];
897 struct _str_ctx_a puts_ctx
= {INT_MAX
, NULL
};
900 memset(args_ctx
, 0, sizeof(args_ctx
));
902 ret
= create_positional_ctx_a(args_ctx
, format
, args
);
904 MSVCRT__invalid_parameter(NULL
, NULL
, NULL
, 0, 0);
905 *MSVCRT__errno() = MSVCRT_EINVAL
;
907 } else if(ret
== 0) {
908 ret
= pf_printf_a(puts_clbk_str_a
, &puts_ctx
, format
, locale
, FALSE
, TRUE
,
909 arg_clbk_valist
, NULL
, &args
);
911 ret
= pf_printf_a(puts_clbk_str_a
, &puts_ctx
, format
, locale
, TRUE
, TRUE
,
912 arg_clbk_positional
, args_ctx
, NULL
);
918 /*********************************************************************
919 * _vscprintf_p (MSVCR80.@)
921 int CDECL
MSVCRT__vscprintf_p(const char *format
, __ms_va_list argptr
)
923 return MSVCRT__vscprintf_p_l(format
, NULL
, argptr
);
926 /*********************************************************************
927 * _snprintf (MSVCRT.@)
929 int CDECL
MSVCRT__snprintf(char *str
, unsigned int len
, const char *format
, ...)
933 __ms_va_start(valist
, format
);
934 retval
= MSVCRT_vsnprintf(str
, len
, format
, valist
);
939 /*********************************************************************
940 * _snprintf_l (MSVCRT.@)
942 int CDECL
MSVCRT__snprintf_l(char *str
, unsigned int count
, MSVCRT__locale_t locale
,
943 const char *format
, ...)
947 __ms_va_start(valist
, format
);
948 retval
= MSVCRT_vsnprintf_l(str
, count
, format
, locale
, valist
);
953 /*********************************************************************
954 * _snprintf_s (MSVCRT.@)
956 int CDECL
MSVCRT__snprintf_s(char *str
, unsigned int len
, unsigned int count
,
957 const char *format
, ...)
961 __ms_va_start(valist
, format
);
962 retval
= MSVCRT_vsnprintf_s_l(str
, len
, count
, format
, NULL
, valist
);
967 /*********************************************************************
968 * _scprintf (MSVCRT.@)
970 int CDECL
MSVCRT__scprintf(const char *format
, ...)
974 __ms_va_start(valist
, format
);
975 retval
= MSVCRT__vscprintf(format
, valist
);
980 /*********************************************************************
981 * _vsnwprintf (MSVCRT.@)
983 int CDECL
MSVCRT_vsnwprintf(MSVCRT_wchar_t
*str
, MSVCRT_size_t len
,
984 const MSVCRT_wchar_t
*format
, __ms_va_list valist
)
986 static const MSVCRT_wchar_t nullbyte
= '\0';
987 struct _str_ctx_w ctx
= {len
, str
};
990 ret
= pf_printf_w(puts_clbk_str_w
, &ctx
, format
, NULL
, FALSE
, FALSE
,
991 arg_clbk_valist
, NULL
, &valist
);
992 puts_clbk_str_w(&ctx
, 1, &nullbyte
);
996 /*********************************************************************
997 * _vsnwprintf_l (MSVCRT.@)
999 int CDECL
MSVCRT_vsnwprintf_l(MSVCRT_wchar_t
*str
, MSVCRT_size_t len
,
1000 const MSVCRT_wchar_t
*format
, MSVCRT__locale_t locale
,
1001 __ms_va_list valist
)
1003 static const MSVCRT_wchar_t nullbyte
= '\0';
1004 struct _str_ctx_w ctx
= {len
, str
};
1007 ret
= pf_printf_w(puts_clbk_str_w
, &ctx
, format
, locale
, FALSE
, FALSE
,
1008 arg_clbk_valist
, NULL
, &valist
);
1009 puts_clbk_str_w(&ctx
, 1, &nullbyte
);
1013 /*********************************************************************
1014 * _vswprintf_p_l (MSVCRT.@)
1016 int CDECL
MSVCRT_vswprintf_p_l(MSVCRT_wchar_t
*buffer
, MSVCRT_size_t length
,
1017 const MSVCRT_wchar_t
*format
, MSVCRT__locale_t locale
, __ms_va_list args
)
1019 static const MSVCRT_wchar_t nullbyte
= '\0';
1020 printf_arg args_ctx
[MSVCRT__ARGMAX
+1];
1021 struct _str_ctx_w puts_ctx
= {length
, buffer
};
1024 memset(args_ctx
, 0, sizeof(args_ctx
));
1026 ret
= create_positional_ctx_w(args_ctx
, format
, args
);
1028 MSVCRT__invalid_parameter(NULL
, NULL
, NULL
, 0, 0);
1029 *MSVCRT__errno() = MSVCRT_EINVAL
;
1032 ret
= pf_printf_w(puts_clbk_str_w
, &puts_ctx
, format
, locale
, FALSE
, TRUE
,
1033 arg_clbk_valist
, NULL
, &args
);
1035 ret
= pf_printf_w(puts_clbk_str_w
, &puts_ctx
, format
, locale
, TRUE
, TRUE
,
1036 arg_clbk_positional
, args_ctx
, NULL
);
1038 puts_clbk_str_w(&puts_ctx
, 1, &nullbyte
);
1042 /*********************************************************************
1043 * _vswprintf_p (MSVCR100.@)
1045 int CDECL
MSVCRT__vswprintf_p(MSVCRT_wchar_t
*buffer
, MSVCRT_size_t length
,
1046 const MSVCRT_wchar_t
*format
, __ms_va_list args
)
1048 return MSVCRT_vswprintf_p_l(buffer
, length
, format
, NULL
, args
);
1051 /*********************************************************************
1052 * _vsnwprintf_s_l (MSVCRT.@)
1054 int CDECL
MSVCRT_vsnwprintf_s_l( MSVCRT_wchar_t
*str
, MSVCRT_size_t sizeOfBuffer
,
1055 MSVCRT_size_t count
, const MSVCRT_wchar_t
*format
,
1056 MSVCRT__locale_t locale
, __ms_va_list valist
)
1058 static const MSVCRT_wchar_t nullbyte
= '\0';
1059 struct _str_ctx_w ctx
;
1063 if(count
!=-1 && len
>count
+1)
1068 ret
= pf_printf_w(puts_clbk_str_w
, &ctx
, format
, locale
, FALSE
, TRUE
,
1069 arg_clbk_valist
, NULL
, &valist
);
1070 puts_clbk_str_w(&ctx
, 1, &nullbyte
);
1072 if(ret
<0 || ret
==len
) {
1073 if(count
!=MSVCRT__TRUNCATE
&& count
>sizeOfBuffer
) {
1074 MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small", MSVCRT_ERANGE
);
1075 memset(str
, 0, sizeOfBuffer
*sizeof(MSVCRT_wchar_t
));
1085 /*********************************************************************
1086 * _vsnwprintf_s (MSVCRT.@)
1088 int CDECL
MSVCRT_vsnwprintf_s(MSVCRT_wchar_t
*str
, MSVCRT_size_t sizeOfBuffer
,
1089 MSVCRT_size_t count
, const MSVCRT_wchar_t
*format
, __ms_va_list valist
)
1091 return MSVCRT_vsnwprintf_s_l(str
, sizeOfBuffer
, count
,
1092 format
, NULL
, valist
);
1095 /*********************************************************************
1096 * _snwprintf (MSVCRT.@)
1098 int CDECL
MSVCRT__snwprintf( MSVCRT_wchar_t
*str
, unsigned int len
, const MSVCRT_wchar_t
*format
, ...)
1101 __ms_va_list valist
;
1102 __ms_va_start(valist
, format
);
1103 retval
= MSVCRT_vsnwprintf(str
, len
, format
, valist
);
1104 __ms_va_end(valist
);
1108 /*********************************************************************
1109 * _snwprintf_l (MSVCRT.@)
1111 int CDECL
MSVCRT__snwprintf_l( MSVCRT_wchar_t
*str
, unsigned int len
, const MSVCRT_wchar_t
*format
,
1112 MSVCRT__locale_t locale
, ...)
1115 __ms_va_list valist
;
1116 __ms_va_start(valist
, locale
);
1117 retval
= MSVCRT_vsnwprintf_l(str
, len
, format
, locale
, valist
);
1118 __ms_va_end(valist
);
1122 /*********************************************************************
1123 * _snwprintf_s (MSVCRT.@)
1125 int CDECL
MSVCRT__snwprintf_s( MSVCRT_wchar_t
*str
, unsigned int len
, unsigned int count
,
1126 const MSVCRT_wchar_t
*format
, ...)
1129 __ms_va_list valist
;
1130 __ms_va_start(valist
, format
);
1131 retval
= MSVCRT_vsnwprintf_s_l(str
, len
, count
, format
, NULL
, valist
);
1132 __ms_va_end(valist
);
1136 /*********************************************************************
1137 * _snwprintf_s_l (MSVCRT.@)
1139 int CDECL
MSVCRT__snwprintf_s_l( MSVCRT_wchar_t
*str
, unsigned int len
, unsigned int count
,
1140 const MSVCRT_wchar_t
*format
, MSVCRT__locale_t locale
, ... )
1143 __ms_va_list valist
;
1144 __ms_va_start(valist
, locale
);
1145 retval
= MSVCRT_vsnwprintf_s_l(str
, len
, count
, format
, locale
, valist
);
1146 __ms_va_end(valist
);
1150 static int puts_clbk_str_c99_w(void *ctx
, int len
, const MSVCRT_wchar_t
*str
)
1152 struct _str_ctx_w
*out
= ctx
;
1157 if(out
->len
< len
) {
1158 memcpy(out
->buf
, str
, out
->len
*sizeof(MSVCRT_wchar_t
));
1159 out
->buf
+= out
->len
;
1164 memcpy(out
->buf
, str
, len
*sizeof(MSVCRT_wchar_t
));
1170 /*********************************************************************
1171 * __stdio_common_vswprintf (MSVCRT.@)
1173 int CDECL
MSVCRT__stdio_common_vswprintf( unsigned __int64 options
, MSVCRT_wchar_t
*str
, MSVCRT_size_t len
, const MSVCRT_wchar_t
*format
,
1174 MSVCRT__locale_t locale
, __ms_va_list valist
)
1176 static const MSVCRT_wchar_t nullbyte
= '\0';
1177 struct _str_ctx_w ctx
= {len
, str
};
1180 if (options
& ~UCRTBASE_PRINTF_TERMINATION_MASK
)
1181 FIXME("options %s not handled\n", wine_dbgstr_longlong(options
));
1182 ret
= pf_printf_w(puts_clbk_str_c99_w
,
1183 &ctx
, format
, locale
, FALSE
, FALSE
, arg_clbk_valist
, NULL
, &valist
);
1184 puts_clbk_str_w(&ctx
, 1, &nullbyte
);
1186 if(options
& UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION
)
1187 return ret
>len
? -1 : ret
;
1189 if(len
) str
[len
-1] = 0;
1190 return (options
& UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR
) ? ret
: -2;
1195 /*********************************************************************
1196 * sprintf (MSVCRT.@)
1198 int CDECL
MSVCRT_sprintf( char *str
, const char *format
, ... )
1203 __ms_va_start( ap
, format
);
1204 r
= MSVCRT_vsnprintf( str
, INT_MAX
, format
, ap
);
1209 /*********************************************************************
1210 * sprintf_s (MSVCRT.@)
1212 int CDECL
MSVCRT_sprintf_s( char *str
, MSVCRT_size_t num
, const char *format
, ... )
1217 __ms_va_start( ap
, format
);
1218 r
= MSVCRT_vsnprintf( str
, num
, format
, ap
);
1223 /*********************************************************************
1224 * _scwprintf (MSVCRT.@)
1226 int CDECL
MSVCRT__scwprintf( const MSVCRT_wchar_t
*format
, ... )
1231 __ms_va_start( ap
, format
);
1232 r
= MSVCRT_vsnwprintf( NULL
, INT_MAX
, format
, ap
);
1237 /*********************************************************************
1238 * swprintf (MSVCRT.@)
1240 int CDECL
MSVCRT_swprintf( MSVCRT_wchar_t
*str
, const MSVCRT_wchar_t
*format
, ... )
1245 __ms_va_start( ap
, format
);
1246 r
= MSVCRT_vsnwprintf( str
, INT_MAX
, format
, ap
);
1251 /*********************************************************************
1252 * swprintf_s (MSVCRT.@)
1254 int CDECL
MSVCRT_swprintf_s(MSVCRT_wchar_t
*str
, MSVCRT_size_t numberOfElements
,
1255 const MSVCRT_wchar_t
*format
, ... )
1260 __ms_va_start(ap
, format
);
1261 r
= MSVCRT_vsnwprintf_s(str
, numberOfElements
, INT_MAX
, format
, ap
);
1267 /*********************************************************************
1268 * _swprintf_s_l (MSVCRT.@)
1270 int CDECL
MSVCRT__swprintf_s_l(MSVCRT_wchar_t
*str
, MSVCRT_size_t numberOfElements
,
1271 const MSVCRT_wchar_t
*format
, MSVCRT__locale_t locale
, ... )
1276 __ms_va_start(ap
, locale
);
1277 r
= MSVCRT_vsnwprintf_s_l(str
, numberOfElements
, INT_MAX
, format
, locale
, ap
);
1283 /*********************************************************************
1284 * _vswprintf (MSVCRT.@)
1286 int CDECL
MSVCRT_vswprintf( MSVCRT_wchar_t
* str
, const MSVCRT_wchar_t
* format
, __ms_va_list args
)
1288 return MSVCRT_vsnwprintf( str
, INT_MAX
, format
, args
);
1291 /*********************************************************************
1292 * _vswprintf (MSVCRT.@)
1294 int CDECL
MSVCRT_vswprintf_l( MSVCRT_wchar_t
* str
, const MSVCRT_wchar_t
* format
,
1295 MSVCRT__locale_t locale
, __ms_va_list args
)
1297 return MSVCRT_vsnwprintf_l( str
, INT_MAX
, format
, locale
, args
);
1300 /*********************************************************************
1301 * _vscwprintf (MSVCRT.@)
1303 int CDECL
MSVCRT__vscwprintf( const MSVCRT_wchar_t
*format
, __ms_va_list args
)
1305 return MSVCRT_vsnwprintf( NULL
, INT_MAX
, format
, args
);
1308 /*********************************************************************
1309 * _vscwprintf_l (MSVCRT.@)
1311 int CDECL
MSVCRT__vscwprintf_l( const MSVCRT_wchar_t
*format
, MSVCRT__locale_t locale
, __ms_va_list args
)
1313 return MSVCRT_vsnwprintf_l( NULL
, INT_MAX
, format
, locale
, args
);
1316 /*********************************************************************
1317 * _vscwprintf_p_l (MSVCRT.@)
1319 int CDECL
MSVCRT__vscwprintf_p_l( const MSVCRT_wchar_t
*format
, MSVCRT__locale_t locale
, __ms_va_list args
)
1321 return MSVCRT_vswprintf_p_l( NULL
, INT_MAX
, format
, locale
, args
);
1324 /*********************************************************************
1325 * _vscwprintf_p (MSVCR100.@)
1327 int CDECL
MSVCRT__vscwprintf_p(const MSVCRT_wchar_t
*format
, __ms_va_list args
)
1329 return MSVCRT_vswprintf_p_l(NULL
, INT_MAX
, format
, NULL
, args
);
1332 /*********************************************************************
1333 * vswprintf_s (MSVCRT.@)
1335 int CDECL
MSVCRT_vswprintf_s(MSVCRT_wchar_t
* str
, MSVCRT_size_t numberOfElements
,
1336 const MSVCRT_wchar_t
* format
, __ms_va_list args
)
1338 return MSVCRT_vsnwprintf_s(str
, numberOfElements
, INT_MAX
, format
, args
);
1341 /*********************************************************************
1342 * _vswprintf_s_l (MSVCRT.@)
1344 int CDECL
MSVCRT_vswprintf_s_l(MSVCRT_wchar_t
* str
, MSVCRT_size_t numberOfElements
,
1345 const MSVCRT_wchar_t
* format
, MSVCRT__locale_t locale
, __ms_va_list args
)
1347 return MSVCRT_vsnwprintf_s_l(str
, numberOfElements
, INT_MAX
,
1348 format
, locale
, args
);
1351 /*********************************************************************
1352 * _vsprintf_p_l (MSVCRT.@)
1354 int CDECL
MSVCRT_vsprintf_p_l(char *buffer
, MSVCRT_size_t length
, const char *format
,
1355 MSVCRT__locale_t locale
, __ms_va_list args
)
1357 static const char nullbyte
= '\0';
1358 printf_arg args_ctx
[MSVCRT__ARGMAX
+1];
1359 struct _str_ctx_a puts_ctx
= {length
, buffer
};
1362 memset(args_ctx
, 0, sizeof(args_ctx
));
1364 ret
= create_positional_ctx_a(args_ctx
, format
, args
);
1366 MSVCRT__invalid_parameter(NULL
, NULL
, NULL
, 0, 0);
1367 *MSVCRT__errno() = MSVCRT_EINVAL
;
1370 ret
= pf_printf_a(puts_clbk_str_a
, &puts_ctx
, format
, locale
, FALSE
, TRUE
,
1371 arg_clbk_valist
, NULL
, &args
);
1373 ret
= pf_printf_a(puts_clbk_str_a
, &puts_ctx
, format
, locale
, TRUE
, TRUE
,
1374 arg_clbk_positional
, args_ctx
, NULL
);
1376 puts_clbk_str_a(&puts_ctx
, 1, &nullbyte
);
1380 /*********************************************************************
1381 * _vsprintf_p (MSVCRT.@)
1383 int CDECL
MSVCRT_vsprintf_p(char *buffer
, MSVCRT_size_t length
,
1384 const char *format
, __ms_va_list args
)
1386 return MSVCRT_vsprintf_p_l(buffer
, length
, format
, NULL
, args
);
1389 /*********************************************************************
1390 * _sprintf_p_l (MSVCRT.@)
1392 int CDECL
MSVCRT_sprintf_p_l(char *buffer
, MSVCRT_size_t length
,
1393 const char *format
, MSVCRT__locale_t locale
, ...)
1395 __ms_va_list valist
;
1398 __ms_va_start(valist
, locale
);
1399 r
= MSVCRT_vsprintf_p_l(buffer
, length
, format
, locale
, valist
);
1400 __ms_va_end(valist
);
1405 /*********************************************************************
1406 * __swprintf_l (MSVCRT.@)
1408 int CDECL
MSVCRT___swprintf_l( MSVCRT_wchar_t
*str
, const MSVCRT_wchar_t
*format
,
1409 MSVCRT__locale_t locale
, ...)
1412 __ms_va_list valist
;
1413 __ms_va_start(valist
, locale
);
1414 retval
= MSVCRT_vswprintf_l(str
, format
, locale
, valist
);
1415 __ms_va_end(valist
);
1419 /*********************************************************************
1420 * _sprintf_p (MSVCR100.@)
1422 int CDECL
MSVCRT__sprintf_p(char *buffer
, MSVCRT_size_t length
, const char *format
, ...)
1424 __ms_va_list valist
;
1427 __ms_va_start(valist
, format
);
1428 r
= MSVCRT_vsprintf_p_l(buffer
, length
, format
, NULL
, valist
);
1429 __ms_va_end(valist
);
1434 /*********************************************************************
1435 * _swprintf_p_l (MSVCRT.@)
1437 int CDECL
MSVCRT_swprintf_p_l(MSVCRT_wchar_t
*buffer
, MSVCRT_size_t length
,
1438 const MSVCRT_wchar_t
*format
, MSVCRT__locale_t locale
, ...)
1440 __ms_va_list valist
;
1443 __ms_va_start(valist
, locale
);
1444 r
= MSVCRT_vswprintf_p_l(buffer
, length
, format
, locale
, valist
);
1445 __ms_va_end(valist
);
1450 /*********************************************************************
1451 * _wcscoll_l (MSVCRT.@)
1453 int CDECL
MSVCRT__wcscoll_l(const MSVCRT_wchar_t
* str1
, const MSVCRT_wchar_t
* str2
, MSVCRT__locale_t locale
)
1455 MSVCRT_pthreadlocinfo locinfo
;
1458 locinfo
= get_locinfo();
1460 locinfo
= locale
->locinfo
;
1462 if(!locinfo
->lc_handle
[MSVCRT_LC_COLLATE
])
1463 return strcmpW(str1
, str2
);
1464 return CompareStringW(locinfo
->lc_handle
[MSVCRT_LC_COLLATE
], 0, str1
, -1, str2
, -1)-CSTR_EQUAL
;
1467 /*********************************************************************
1468 * wcscoll (MSVCRT.@)
1470 int CDECL
MSVCRT_wcscoll( const MSVCRT_wchar_t
* str1
, const MSVCRT_wchar_t
* str2
)
1472 return MSVCRT__wcscoll_l(str1
, str2
, NULL
);
1475 /*********************************************************************
1476 * wcspbrk (MSVCRT.@)
1478 MSVCRT_wchar_t
* CDECL
MSVCRT_wcspbrk( const MSVCRT_wchar_t
* str
, const MSVCRT_wchar_t
* accept
)
1480 const MSVCRT_wchar_t
* p
;
1484 for (p
= accept
; *p
; p
++) if (*p
== *str
) return (MSVCRT_wchar_t
*)str
;
1490 /*********************************************************************
1491 * wcstok_s (MSVCRT.@)
1493 MSVCRT_wchar_t
* CDECL
MSVCRT_wcstok_s( MSVCRT_wchar_t
*str
, const MSVCRT_wchar_t
*delim
,
1494 MSVCRT_wchar_t
**next_token
)
1496 MSVCRT_wchar_t
*ret
;
1498 if (!MSVCRT_CHECK_PMT(delim
!= NULL
)) return NULL
;
1499 if (!MSVCRT_CHECK_PMT(next_token
!= NULL
)) return NULL
;
1500 if (!MSVCRT_CHECK_PMT(str
!= NULL
|| *next_token
!= NULL
)) return NULL
;
1502 if (!str
) str
= *next_token
;
1504 while (*str
&& strchrW( delim
, *str
)) str
++;
1505 if (!*str
) return NULL
;
1507 while (*str
&& !strchrW( delim
, *str
)) str
++;
1508 if (*str
) *str
++ = 0;
1513 /*********************************************************************
1516 MSVCRT_wchar_t
* CDECL
MSVCRT_wcstok( MSVCRT_wchar_t
*str
, const MSVCRT_wchar_t
*delim
)
1518 return MSVCRT_wcstok_s(str
, delim
, &msvcrt_get_thread_data()->wcstok_next
);
1521 /*********************************************************************
1522 * _wctomb_s_l (MSVCRT.@)
1524 int CDECL
MSVCRT__wctomb_s_l(int *len
, char *mbchar
, MSVCRT_size_t size
,
1525 MSVCRT_wchar_t wch
, MSVCRT__locale_t locale
)
1527 MSVCRT_pthreadlocinfo locinfo
;
1531 if(!mbchar
&& size
>0) {
1540 if(!MSVCRT_CHECK_PMT(size
<= INT_MAX
))
1541 return MSVCRT_EINVAL
;
1544 locinfo
= get_locinfo();
1546 locinfo
= locale
->locinfo
;
1548 if(!locinfo
->lc_codepage
) {
1550 if(mbchar
&& size
>0)
1551 memset(mbchar
, 0, size
);
1552 *MSVCRT__errno() = MSVCRT_EILSEQ
;
1553 return MSVCRT_EILSEQ
;
1556 if(!MSVCRT_CHECK_PMT_ERR(size
>= 1, MSVCRT_ERANGE
))
1557 return MSVCRT_ERANGE
;
1565 mblen
= WideCharToMultiByte(locinfo
->lc_codepage
, 0, &wch
, 1, mbchar
, size
, NULL
, &error
);
1566 if(!mblen
|| error
) {
1567 if(!mblen
&& GetLastError()==ERROR_INSUFFICIENT_BUFFER
) {
1568 if(mbchar
&& size
>0)
1569 memset(mbchar
, 0, size
);
1571 MSVCRT_INVALID_PMT("insufficient buffer size", MSVCRT_ERANGE
);
1572 return MSVCRT_ERANGE
;
1575 *MSVCRT__errno() = MSVCRT_EILSEQ
;
1576 return MSVCRT_EILSEQ
;
1584 /*********************************************************************
1585 * wctomb_s (MSVCRT.@)
1587 int CDECL
MSVCRT_wctomb_s(int *len
, char *mbchar
, MSVCRT_size_t size
, MSVCRT_wchar_t wch
)
1589 return MSVCRT__wctomb_s_l(len
, mbchar
, size
, wch
, NULL
);
1592 /*********************************************************************
1593 * _wctomb_l (MSVCRT.@)
1595 int CDECL
MSVCRT__wctomb_l(char *dst
, MSVCRT_wchar_t ch
, MSVCRT__locale_t locale
)
1599 MSVCRT__wctomb_s_l(&len
, dst
, dst
? MSVCRT_MB_LEN_MAX
: 0, ch
, locale
);
1603 /*********************************************************************
1606 INT CDECL
MSVCRT_wctomb( char *dst
, MSVCRT_wchar_t ch
)
1608 return MSVCRT__wctomb_l(dst
, ch
, NULL
);
1611 /*********************************************************************
1614 INT CDECL
MSVCRT_wctob( MSVCRT_wint_t wchar
)
1618 UINT codepage
= get_locinfo()->lc_codepage
;
1622 return (signed char)wchar
;
1625 } else if(WideCharToMultiByte( codepage
, 0, &wchar
, 1, &out
, 1, NULL
, &error
) && !error
)
1630 /*********************************************************************
1631 * wcrtomb (MSVCRT.@)
1633 MSVCRT_size_t CDECL
MSVCRT_wcrtomb( char *dst
, MSVCRT_wchar_t ch
, MSVCRT_mbstate_t
*s
)
1637 return MSVCRT_wctomb(dst
, ch
);
1640 /*********************************************************************
1641 * iswalnum (MSVCRT.@)
1643 INT CDECL
MSVCRT_iswalnum( MSVCRT_wchar_t wc
)
1645 return isalnumW( wc
);
1648 /*********************************************************************
1649 * iswalpha (MSVCRT.@)
1651 INT CDECL
MSVCRT_iswalpha( MSVCRT_wchar_t wc
)
1653 return isalphaW( wc
);
1656 /*********************************************************************
1657 * iswalpha_l (MSVCRT.@)
1659 INT CDECL
MSVCRT__iswalpha_l( MSVCRT_wchar_t wc
, MSVCRT__locale_t locale
)
1661 return isalphaW( wc
);
1664 /*********************************************************************
1665 * iswcntrl (MSVCRT.@)
1667 INT CDECL
MSVCRT_iswcntrl( MSVCRT_wchar_t wc
)
1669 return iscntrlW( wc
);
1672 /*********************************************************************
1673 * iswdigit (MSVCRT.@)
1675 INT CDECL
MSVCRT_iswdigit( MSVCRT_wchar_t wc
)
1677 return isdigitW( wc
);
1680 /*********************************************************************
1681 * _iswdigit_l (MSVCRT.@)
1683 INT CDECL
MSVCRT__iswdigit_l( MSVCRT_wchar_t wc
, MSVCRT__locale_t locale
)
1685 return isdigitW( wc
);
1688 /*********************************************************************
1689 * iswgraph (MSVCRT.@)
1691 INT CDECL
MSVCRT_iswgraph( MSVCRT_wchar_t wc
)
1693 return isgraphW( wc
);
1696 /*********************************************************************
1697 * iswlower (MSVCRT.@)
1699 INT CDECL
MSVCRT_iswlower( MSVCRT_wchar_t wc
)
1701 return islowerW( wc
);
1704 /*********************************************************************
1705 * iswprint (MSVCRT.@)
1707 INT CDECL
MSVCRT_iswprint( MSVCRT_wchar_t wc
)
1709 return isprintW( wc
);
1712 /*********************************************************************
1713 * _iswpunct_l (MSVCRT.@)
1715 INT CDECL
MSVCRT__iswpunct_l( MSVCRT_wchar_t wc
, MSVCRT__locale_t locale
)
1717 return ispunctW( wc
);
1720 /*********************************************************************
1721 * iswpunct (MSVCRT.@)
1723 INT CDECL
MSVCRT_iswpunct( MSVCRT_wchar_t wc
)
1725 return ispunctW( wc
);
1728 /*********************************************************************
1729 * _iswspace_l (MSVCRT.@)
1731 INT CDECL
MSVCRT__iswspace_l( MSVCRT_wchar_t wc
, MSVCRT__locale_t locale
)
1733 return isspaceW( wc
);
1736 /*********************************************************************
1737 * iswspace (MSVCRT.@)
1739 INT CDECL
MSVCRT_iswspace( MSVCRT_wchar_t wc
)
1741 return isspaceW( wc
);
1744 /*********************************************************************
1745 * iswupper (MSVCRT.@)
1747 INT CDECL
MSVCRT_iswupper( MSVCRT_wchar_t wc
)
1749 return isupperW( wc
);
1752 /*********************************************************************
1753 * iswxdigit (MSVCRT.@)
1755 INT CDECL
MSVCRT_iswxdigit( MSVCRT_wchar_t wc
)
1757 return isxdigitW( wc
);
1760 /*********************************************************************
1761 * wcscpy_s (MSVCRT.@)
1763 INT CDECL
MSVCRT_wcscpy_s( MSVCRT_wchar_t
* wcDest
, MSVCRT_size_t numElement
, const MSVCRT_wchar_t
*wcSrc
)
1765 MSVCRT_size_t size
= 0;
1767 if(!MSVCRT_CHECK_PMT(wcDest
)) return MSVCRT_EINVAL
;
1768 if(!MSVCRT_CHECK_PMT(numElement
)) return MSVCRT_EINVAL
;
1772 if(!MSVCRT_CHECK_PMT(wcSrc
)) return MSVCRT_EINVAL
;
1774 size
= strlenW(wcSrc
) + 1;
1776 if(!MSVCRT_CHECK_PMT_ERR(size
<= numElement
, MSVCRT_ERANGE
))
1777 return MSVCRT_ERANGE
;
1779 memcpy( wcDest
, wcSrc
, size
*sizeof(WCHAR
) );
1784 /******************************************************************
1785 * wcsncpy (MSVCRT.@)
1787 MSVCRT_wchar_t
* __cdecl
MSVCRT_wcsncpy( MSVCRT_wchar_t
* s1
,
1788 const MSVCRT_wchar_t
*s2
, MSVCRT_size_t n
)
1793 if(!(s1
[i
] = s2
[i
])) break;
1799 /******************************************************************
1800 * wcsncpy_s (MSVCRT.@)
1802 INT CDECL
MSVCRT_wcsncpy_s( MSVCRT_wchar_t
* wcDest
, MSVCRT_size_t numElement
, const MSVCRT_wchar_t
*wcSrc
,
1803 MSVCRT_size_t count
)
1806 BOOL truncate
= (count
== MSVCRT__TRUNCATE
);
1808 if(!wcDest
&& !numElement
&& !count
)
1811 if (!wcDest
|| !numElement
)
1812 return MSVCRT_EINVAL
;
1817 return count
? MSVCRT_EINVAL
: 0;
1820 while (numElement
&& count
&& *wcSrc
)
1826 if (!numElement
&& truncate
)
1829 return MSVCRT_STRUNCATE
;
1831 else if (!numElement
)
1834 return MSVCRT_ERANGE
;
1841 /******************************************************************
1842 * wcscat_s (MSVCRT.@)
1845 INT CDECL
MSVCRT_wcscat_s(MSVCRT_wchar_t
* dst
, MSVCRT_size_t elem
, const MSVCRT_wchar_t
* src
)
1847 MSVCRT_wchar_t
* ptr
= dst
;
1849 if (!dst
|| elem
== 0) return MSVCRT_EINVAL
;
1853 return MSVCRT_EINVAL
;
1856 /* seek to end of dst string (or elem if no end of string is found */
1857 while (ptr
< dst
+ elem
&& *ptr
!= '\0') ptr
++;
1858 while (ptr
< dst
+ elem
)
1860 if ((*ptr
++ = *src
++) == '\0') return 0;
1862 /* not enough space */
1864 return MSVCRT_ERANGE
;
1867 /*********************************************************************
1868 * wcsncat_s (MSVCRT.@)
1871 INT CDECL
MSVCRT_wcsncat_s(MSVCRT_wchar_t
*dst
, MSVCRT_size_t elem
,
1872 const MSVCRT_wchar_t
*src
, MSVCRT_size_t count
)
1874 MSVCRT_size_t srclen
;
1875 MSVCRT_wchar_t dststart
;
1878 if (!MSVCRT_CHECK_PMT(dst
!= NULL
)) return MSVCRT_EINVAL
;
1879 if (!MSVCRT_CHECK_PMT(elem
> 0)) return MSVCRT_EINVAL
;
1880 if (!MSVCRT_CHECK_PMT(src
!= NULL
|| count
== 0)) return MSVCRT_EINVAL
;
1885 for (dststart
= 0; dststart
< elem
; dststart
++)
1887 if (dst
[dststart
] == '\0')
1890 if (dststart
== elem
)
1892 MSVCRT_INVALID_PMT("dst[elem] is not NULL terminated\n", MSVCRT_EINVAL
);
1893 return MSVCRT_EINVAL
;
1896 if (count
== MSVCRT__TRUNCATE
)
1898 srclen
= strlenW(src
);
1899 if (srclen
>= (elem
- dststart
))
1901 srclen
= elem
- dststart
- 1;
1902 ret
= MSVCRT_STRUNCATE
;
1906 srclen
= min(strlenW(src
), count
);
1907 if (srclen
< (elem
- dststart
))
1909 memcpy(&dst
[dststart
], src
, srclen
*sizeof(MSVCRT_wchar_t
));
1910 dst
[dststart
+srclen
] = '\0';
1913 MSVCRT_INVALID_PMT("dst[elem] is too small", MSVCRT_ERANGE
);
1915 return MSVCRT_ERANGE
;
1918 /*********************************************************************
1919 * _wcstoi64_l (MSVCRT.@)
1921 * FIXME: locale parameter is ignored
1923 __int64 CDECL
MSVCRT__wcstoi64_l(const MSVCRT_wchar_t
*nptr
,
1924 MSVCRT_wchar_t
**endptr
, int base
, MSVCRT__locale_t locale
)
1926 BOOL negative
= FALSE
;
1929 TRACE("(%s %p %d %p)\n", debugstr_w(nptr
), endptr
, base
, locale
);
1931 if (!MSVCRT_CHECK_PMT(nptr
!= NULL
)) return 0;
1932 if (!MSVCRT_CHECK_PMT(base
== 0 || base
>= 2)) return 0;
1933 if (!MSVCRT_CHECK_PMT(base
<= 36)) return 0;
1935 while(isspaceW(*nptr
)) nptr
++;
1940 } else if(*nptr
== '+')
1943 if((base
==0 || base
==16) && *nptr
=='0' && tolowerW(*(nptr
+1))=='x') {
1956 MSVCRT_wchar_t cur
= tolowerW(*nptr
);
1964 if(cur
<'a' || cur
>='a'+base
-10)
1974 if(!negative
&& (ret
>MSVCRT_I64_MAX
/base
|| ret
*base
>MSVCRT_I64_MAX
-v
)) {
1975 ret
= MSVCRT_I64_MAX
;
1976 *MSVCRT__errno() = MSVCRT_ERANGE
;
1977 } else if(negative
&& (ret
<MSVCRT_I64_MIN
/base
|| ret
*base
<MSVCRT_I64_MIN
-v
)) {
1978 ret
= MSVCRT_I64_MIN
;
1979 *MSVCRT__errno() = MSVCRT_ERANGE
;
1985 *endptr
= (MSVCRT_wchar_t
*)nptr
;
1990 /*********************************************************************
1991 * _wcstoi64 (MSVCRT.@)
1993 __int64 CDECL
MSVCRT__wcstoi64(const MSVCRT_wchar_t
*nptr
,
1994 MSVCRT_wchar_t
**endptr
, int base
)
1996 return MSVCRT__wcstoi64_l(nptr
, endptr
, base
, NULL
);
1999 /*********************************************************************
2000 * _wcstol_l (MSVCRT.@)
2002 MSVCRT_long CDECL
MSVCRT__wcstol_l(const MSVCRT_wchar_t
*s
,
2003 MSVCRT_wchar_t
**end
, int base
, MSVCRT__locale_t locale
)
2005 __int64 ret
= MSVCRT__wcstoi64_l(s
, end
, base
, locale
);
2007 if(ret
> MSVCRT_LONG_MAX
) {
2008 ret
= MSVCRT_LONG_MAX
;
2009 *MSVCRT__errno() = MSVCRT_ERANGE
;
2010 }else if(ret
< MSVCRT_LONG_MIN
) {
2011 ret
= MSVCRT_LONG_MIN
;
2012 *MSVCRT__errno() = MSVCRT_ERANGE
;
2017 /*********************************************************************
2018 * _wtoi_l (MSVCRT.@)
2020 int __cdecl
MSVCRT__wtoi_l(const MSVCRT_wchar_t
*str
, MSVCRT__locale_t locale
)
2022 __int64 ret
= MSVCRT__wcstoi64_l(str
, NULL
, 10, locale
);
2026 *MSVCRT__errno() = MSVCRT_ERANGE
;
2027 } else if(ret
< INT_MIN
) {
2029 *MSVCRT__errno() = MSVCRT_ERANGE
;
2034 /*********************************************************************
2037 int __cdecl
MSVCRT__wtoi(const MSVCRT_wchar_t
*str
)
2039 return MSVCRT__wtoi_l(str
, NULL
);
2042 /*********************************************************************
2043 * _wtol_l (MSVCRT.@)
2045 MSVCRT_long __cdecl
MSVCRT__wtol_l(const MSVCRT_wchar_t
*str
, MSVCRT__locale_t locale
)
2047 __int64 ret
= MSVCRT__wcstoi64_l(str
, NULL
, 10, locale
);
2049 if(ret
> MSVCRT_LONG_MAX
) {
2050 ret
= MSVCRT_LONG_MAX
;
2051 *MSVCRT__errno() = MSVCRT_ERANGE
;
2052 } else if(ret
< MSVCRT_LONG_MIN
) {
2053 ret
= MSVCRT_LONG_MIN
;
2054 *MSVCRT__errno() = MSVCRT_ERANGE
;
2059 /*********************************************************************
2062 MSVCRT_long __cdecl
MSVCRT__wtol(const MSVCRT_wchar_t
*str
)
2064 return MSVCRT__wtol_l(str
, NULL
);
2067 /*********************************************************************
2068 * _wcstoui64_l (MSVCRT.@)
2070 * FIXME: locale parameter is ignored
2072 unsigned __int64 CDECL
MSVCRT__wcstoui64_l(const MSVCRT_wchar_t
*nptr
,
2073 MSVCRT_wchar_t
**endptr
, int base
, MSVCRT__locale_t locale
)
2075 BOOL negative
= FALSE
;
2076 unsigned __int64 ret
= 0;
2078 TRACE("(%s %p %d %p)\n", debugstr_w(nptr
), endptr
, base
, locale
);
2080 if (!MSVCRT_CHECK_PMT(nptr
!= NULL
)) return 0;
2081 if (!MSVCRT_CHECK_PMT(base
== 0 || base
>= 2)) return 0;
2082 if (!MSVCRT_CHECK_PMT(base
<= 36)) return 0;
2084 while(isspaceW(*nptr
)) nptr
++;
2089 } else if(*nptr
== '+')
2092 if((base
==0 || base
==16) && *nptr
=='0' && tolowerW(*(nptr
+1))=='x') {
2105 MSVCRT_wchar_t cur
= tolowerW(*nptr
);
2113 if(cur
<'a' || cur
>='a'+base
-10)
2120 if(ret
>MSVCRT_UI64_MAX
/base
|| ret
*base
>MSVCRT_UI64_MAX
-v
) {
2121 ret
= MSVCRT_UI64_MAX
;
2122 *MSVCRT__errno() = MSVCRT_ERANGE
;
2128 *endptr
= (MSVCRT_wchar_t
*)nptr
;
2130 return negative
? -ret
: ret
;
2133 /*********************************************************************
2134 * _wcstoui64 (MSVCRT.@)
2136 unsigned __int64 CDECL
MSVCRT__wcstoui64(const MSVCRT_wchar_t
*nptr
,
2137 MSVCRT_wchar_t
**endptr
, int base
)
2139 return MSVCRT__wcstoui64_l(nptr
, endptr
, base
, NULL
);
2142 /*********************************************************************
2143 * _wcstoul_l (MSVCRT.@)
2145 MSVCRT_ulong __cdecl
MSVCRT__wcstoul_l(const MSVCRT_wchar_t
*s
,
2146 MSVCRT_wchar_t
**end
, int base
, MSVCRT__locale_t locale
)
2148 __int64 ret
= MSVCRT__wcstoui64_l(s
, end
, base
, locale
);
2150 if(ret
> MSVCRT_ULONG_MAX
) {
2151 ret
= MSVCRT_ULONG_MAX
;
2152 *MSVCRT__errno() = MSVCRT_ERANGE
;
2157 /*********************************************************************
2158 * wcstoul (MSVCRT.@)
2160 MSVCRT_ulong __cdecl
MSVCRT_wcstoul(const MSVCRT_wchar_t
*s
, MSVCRT_wchar_t
**end
, int base
)
2162 return MSVCRT__wcstoul_l(s
, end
, base
, NULL
);
2165 /******************************************************************
2166 * wcsnlen (MSVCRT.@)
2168 MSVCRT_size_t CDECL
MSVCRT_wcsnlen(const MSVCRT_wchar_t
*s
, MSVCRT_size_t maxlen
)
2172 for (i
= 0; i
< maxlen
; i
++)
2177 /*********************************************************************
2178 * _towupper_l (MSVCRT.@)
2180 int CDECL
MSVCRT__towupper_l(MSVCRT_wint_t c
, MSVCRT__locale_t locale
)
2185 /*********************************************************************
2186 * towupper (MSVCRT.@)
2188 int CDECL
MSVCRT_towupper(MSVCRT_wint_t c
)
2190 return MSVCRT__towupper_l(c
, NULL
);
2193 /*********************************************************************
2194 * _towlower_l (MSVCRT.@)
2196 int CDECL
MSVCRT__towlower_l(MSVCRT_wint_t c
, MSVCRT__locale_t locale
)
2201 /*********************************************************************
2202 * towlower (MSVCRT.@)
2204 int CDECL
MSVCRT_towlower(MSVCRT_wint_t c
)
2206 return MSVCRT__towlower_l(c
, NULL
);
2209 /*********************************************************************
2212 MSVCRT_wchar_t
* CDECL
MSVCRT_wcschr(const MSVCRT_wchar_t
*str
, MSVCRT_wchar_t ch
)
2214 return strchrW(str
, ch
);
2217 /***********************************************************************
2220 int CDECL
MSVCRT_wcslen(const MSVCRT_wchar_t
*str
)
2222 return strlenW(str
);
2225 /*********************************************************************
2228 MSVCRT_wchar_t
* CDECL
MSVCRT_wcsstr(const MSVCRT_wchar_t
*str
, const MSVCRT_wchar_t
*sub
)
2230 return strstrW(str
, sub
);
2233 /*********************************************************************
2234 * _wtoi64_l (MSVCRT.@)
2236 __int64 CDECL
MSVCRT__wtoi64_l(const MSVCRT_wchar_t
*str
, MSVCRT__locale_t locale
)
2238 ULONGLONG RunningTotal
= 0;
2239 BOOL bMinus
= FALSE
;
2241 while (isspaceW(*str
)) {
2247 } else if (*str
== '-') {
2252 while (*str
>= '0' && *str
<= '9') {
2253 RunningTotal
= RunningTotal
* 10 + *str
- '0';
2257 return bMinus
? -RunningTotal
: RunningTotal
;
2260 /*********************************************************************
2261 * _wtoi64 (MSVCRT.@)
2263 __int64 CDECL
MSVCRT__wtoi64(const MSVCRT_wchar_t
*str
)
2265 return MSVCRT__wtoi64_l(str
, NULL
);
2268 /*********************************************************************
2269 * wcsncmp (MSVCRT.@)
2271 int CDECL
MSVCRT_wcsncmp(const MSVCRT_wchar_t
*str1
, const MSVCRT_wchar_t
*str2
, int n
)
2273 return strncmpW(str1
, str2
, n
);
2276 /*********************************************************************
2277 * _wcsxfrm_l (MSVCRT.@)
2279 MSVCRT_size_t CDECL
MSVCRT__wcsxfrm_l(MSVCRT_wchar_t
*dest
, const MSVCRT_wchar_t
*src
,
2280 MSVCRT_size_t len
, MSVCRT__locale_t locale
)
2282 MSVCRT_pthreadlocinfo locinfo
;
2285 if(!MSVCRT_CHECK_PMT(src
)) return INT_MAX
;
2286 if(!MSVCRT_CHECK_PMT(dest
|| !len
)) return INT_MAX
;
2289 FIXME("len > INT_MAX not supported\n");
2294 locinfo
= get_locinfo();
2296 locinfo
= locale
->locinfo
;
2298 if(!locinfo
->lc_handle
[MSVCRT_LC_COLLATE
]) {
2299 MSVCRT_wcsncpy(dest
, src
, len
);
2300 return strlenW(src
);
2303 ret
= LCMapStringW(locinfo
->lc_handle
[MSVCRT_LC_COLLATE
],
2304 LCMAP_SORTKEY
, src
, -1, NULL
, 0);
2306 if(len
) dest
[0] = 0;
2307 *MSVCRT__errno() = MSVCRT_EILSEQ
;
2310 if(!len
) return ret
-1;
2314 *MSVCRT__errno() = MSVCRT_ERANGE
;
2318 ret
= LCMapStringW(locinfo
->lc_handle
[MSVCRT_LC_COLLATE
],
2319 LCMAP_SORTKEY
, src
, -1, dest
, len
) - 1;
2320 for(i
=ret
; i
>=0; i
--)
2321 dest
[i
] = ((unsigned char*)dest
)[i
];
2325 /*********************************************************************
2326 * wcsxfrm (MSVCRT.@)
2328 MSVCRT_size_t CDECL
MSVCRT_wcsxfrm(MSVCRT_wchar_t
*dest
,
2329 const MSVCRT_wchar_t
*src
, MSVCRT_size_t len
)
2331 return MSVCRT__wcsxfrm_l(dest
, src
, len
, NULL
);