@@ -915,10 +915,10 @@ int vsprintf (char * __restrict__ __stream, const char * __restrict__ __format,
915
915
int __cdecl __mingw_snwprintf (wchar_t * __restrict__ s , size_t n , const wchar_t * __restrict__ format , ...);
916
916
/* __attribute__((__format__ (gnu_wprintf, 3, 0))) */ __MINGW_ATTRIB_NONNULL (3 )
917
917
int __cdecl __mingw_vsnwprintf (wchar_t * __restrict__ , size_t , const wchar_t * __restrict__ , va_list );
918
- /* __attribute__((__format__ (gnu_wprintf, 2, 3 ))) */ __MINGW_ATTRIB_NONNULL (2 )
919
- int __cdecl __mingw_swprintf (wchar_t * __restrict__ , const wchar_t * __restrict__ , ...);
920
- /* __attribute__((__format__ (gnu_wprintf, 2 , 0))) */ __MINGW_ATTRIB_NONNULL (2 )
921
- int __cdecl __mingw_vswprintf (wchar_t * __restrict__ , const wchar_t * __restrict__ ,va_list );
918
+ /* __attribute__((__format__ (gnu_wprintf, 3, 4 ))) */ __MINGW_ATTRIB_NONNULL (3 )
919
+ int __cdecl __mingw_swprintf (wchar_t * __restrict__ , size_t , const wchar_t * __restrict__ , ...);
920
+ /* __attribute__((__format__ (gnu_wprintf, 3 , 0))) */ __MINGW_ATTRIB_NONNULL (3 )
921
+ int __cdecl __mingw_vswprintf (wchar_t * __restrict__ , size_t , const wchar_t * __restrict__ ,va_list );
922
922
923
923
/* __attribute__((__format__ (ms_wscanf, 2, 3))) */ __MINGW_ATTRIB_NONNULL (2 )
924
924
int __cdecl __ms_swscanf (const wchar_t * __restrict__ _Src ,const wchar_t * __restrict__ _Format ,...);
@@ -935,10 +935,10 @@ int vsprintf (char * __restrict__ __stream, const char * __restrict__ __format,
935
935
int __cdecl __ms_vfwprintf (FILE * __restrict__ _File ,const wchar_t * __restrict__ _Format ,va_list _ArgList );
936
936
/*__attribute__((__format__ (ms_wprintf, 1, 0))) */ __MINGW_ATTRIB_NONNULL (1 )
937
937
int __cdecl __ms_vwprintf (const wchar_t * __restrict__ _Format ,va_list _ArgList );
938
- /* __attribute__((__format__ (ms_wprintf, 2, 3 ))) */ __MINGW_ATTRIB_NONNULL (2 )
939
- int __cdecl __ms_swprintf (wchar_t * __restrict__ , const wchar_t * __restrict__ , ...);
940
- /* __attribute__((__format__ (ms_wprintf, 2 , 0))) */ __MINGW_ATTRIB_NONNULL (2 )
941
- int __cdecl __ms_vswprintf (wchar_t * __restrict__ , const wchar_t * __restrict__ ,va_list );
938
+ /* __attribute__((__format__ (ms_wprintf, 3, 4 ))) */ __MINGW_ATTRIB_NONNULL (3 )
939
+ int __cdecl __ms_swprintf (wchar_t * __restrict__ , size_t , const wchar_t * __restrict__ , ...);
940
+ /* __attribute__((__format__ (ms_wprintf, 3 , 0))) */ __MINGW_ATTRIB_NONNULL (3 )
941
+ int __cdecl __ms_vswprintf (wchar_t * __restrict__ , size_t , const wchar_t * __restrict__ ,va_list );
942
942
943
943
#ifdef _UCRT
944
944
int __cdecl __stdio_common_vswprintf (unsigned __int64 options , wchar_t * str , size_t len , const wchar_t * format , _locale_t locale , va_list valist );
@@ -996,6 +996,32 @@ __MINGW_ASM_CALL(__mingw_vfwprintf);
996
996
int vwprintf (const wchar_t * __format , __builtin_va_list __local_argv )
997
997
__MINGW_ASM_CALL (__mingw_vwprintf );
998
998
999
+ /* __attribute__((__format__ (gnu_wprintf, 3, 4))) */ __MINGW_ATTRIB_NONNULL (3 )
1000
+ int swprintf (wchar_t * __stream , size_t __n , const wchar_t * __format , ...)
1001
+ __MINGW_ASM_CALL (__mingw_swprintf );
1002
+
1003
+ #if __MINGW_FORTIFY_VA_ARG
1004
+
1005
+ __mingw_bos_extern_ovr
1006
+ /* __attribute__((__format__ (gnu_wprintf, 3, 4))) */ __MINGW_ATTRIB_NONNULL (3 )
1007
+ int swprintf (wchar_t * __stream , size_t __n , const wchar_t * __format , ...)
1008
+ {
1009
+ __mingw_bos_ptr_chk_warn (__stream , __n * sizeof (wchar_t ), 1 );
1010
+ return __mingw_swprintf ( __stream , __n , __format , __builtin_va_arg_pack () );
1011
+ }
1012
+
1013
+ #endif /* __MINGW_FORTIFY_VA_ARG */
1014
+
1015
+ __mingw_bos_ovr
1016
+ /* __attribute__((__format__ (gnu_wprintf, 3, 0))) */ __MINGW_ATTRIB_NONNULL (3 )
1017
+ int vswprintf (wchar_t * __stream , size_t __n , const wchar_t * __format , __builtin_va_list __local_argv )
1018
+ {
1019
+ #if __MINGW_FORTIFY_LEVEL > 0
1020
+ __mingw_bos_ptr_chk_warn (__stream , __n * sizeof (wchar_t ), 1 );
1021
+ #endif
1022
+ return __mingw_vswprintf ( __stream , __n , __format , __local_argv );
1023
+ }
1024
+
999
1025
#ifndef __NO_ISOCEXT /* externs in libmingwex.a */
1000
1026
1001
1027
/* __attribute__((__format__ (gnu_wprintf, 3, 4))) */ __MINGW_ATTRIB_NONNULL (3 )
@@ -1023,6 +1049,7 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti
1023
1049
#endif
1024
1050
return __mingw_vsnwprintf ( __stream , __n , __format , __local_argv );
1025
1051
}
1052
+
1026
1053
#endif /* __NO_ISOCEXT */
1027
1054
1028
1055
#else /* !__USE_MINGW_ANSI_STDIO */
@@ -1170,7 +1197,45 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti
1170
1197
1171
1198
#if __USE_MINGW_ANSI_STDIO == 0
1172
1199
__mingw_ovr
1173
- int snwprintf (wchar_t * __restrict__ s , size_t n , const wchar_t * __restrict__ format , ...)
1200
+ int __cdecl swprintf (wchar_t * __restrict__ _Dest ,size_t _Count ,const wchar_t * __restrict__ _Format ,...)
1201
+ {
1202
+ __builtin_va_list __ap ;
1203
+ int __ret ;
1204
+ /*
1205
+ * __stdio_common_vswprintf() for case _Dest == NULL and _Count == 0 and
1206
+ * without _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR option, is
1207
+ * executed in "standard snprintf behavior" and returns number of (wide)
1208
+ * chars required to allocate. For all other cases it is executed in a way
1209
+ * that returns negative value on error. But C95+ compliant swprintf() for
1210
+ * case _Count == 0 returns negative value, so handle this case specially.
1211
+ */
1212
+ if (_Dest == NULL && _Count == 0 )
1213
+ return -1 ;
1214
+ __builtin_va_start (__ap , _Format );
1215
+ __ret = __stdio_common_vswprintf (_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS , _Dest , _Count , _Format , NULL , __ap );
1216
+ __builtin_va_end (__ap );
1217
+ return __ret < 0 ? -1 : __ret ;
1218
+ }
1219
+ __mingw_ovr
1220
+ int __cdecl vswprintf (wchar_t * __restrict__ _Dest ,size_t _Count ,const wchar_t * __restrict__ _Format ,va_list _Args )
1221
+ {
1222
+ int __ret ;
1223
+ /*
1224
+ * __stdio_common_vswprintf() for case _Dest == NULL and _Count == 0 and
1225
+ * without _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR option, is
1226
+ * executed in "standard snprintf behavior" and returns number of (wide)
1227
+ * chars required to allocate. For all other cases it is executed in a way
1228
+ * that returns negative value on error. But C95+ compliant vswprintf() for
1229
+ * case _Count == 0 returns negative value, so handle this case specially.
1230
+ */
1231
+ if (_Dest == NULL && _Count == 0 )
1232
+ return -1 ;
1233
+ __ret = __stdio_common_vswprintf (_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS , _Dest , _Count , _Format , NULL , _Args );
1234
+ return __ret < 0 ? -1 : __ret ;
1235
+ }
1236
+
1237
+ __mingw_ovr
1238
+ int __cdecl snwprintf (wchar_t * __restrict__ s , size_t n , const wchar_t * __restrict__ format , ...)
1174
1239
{
1175
1240
__builtin_va_list __ap ;
1176
1241
int __ret ;
@@ -1182,8 +1247,7 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti
1182
1247
__mingw_ovr
1183
1248
int __cdecl vsnwprintf (wchar_t * __restrict__ s , size_t n , const wchar_t * __restrict__ format , va_list arg )
1184
1249
{
1185
- int __ret = __stdio_common_vswprintf (_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS , s , n , format , NULL , arg );
1186
- return __ret < 0 ? -1 : __ret ;
1250
+ return __stdio_common_vswprintf (_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR , s , n , format , NULL , arg );
1187
1251
}
1188
1252
#endif
1189
1253
@@ -1222,26 +1286,16 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti
1222
1286
#if __USE_MINGW_ANSI_STDIO == 0
1223
1287
int __cdecl __ms_snwprintf (wchar_t * __restrict__ s , size_t n , const wchar_t * __restrict__ format , ...);
1224
1288
int __cdecl __ms_vsnwprintf (wchar_t * __restrict__ , size_t , const wchar_t * __restrict__ , va_list );
1225
- __mingw_ovr
1226
- int snwprintf (wchar_t * __restrict__ s , size_t n , const wchar_t * __restrict__ format , ...)
1227
- {
1228
- int r ;
1229
- va_list argp ;
1230
- __builtin_va_start (argp , format );
1231
- r = _vsnwprintf (s , n , format , argp );
1232
- __builtin_va_end (argp );
1233
- return r ;
1234
- }
1235
- __mingw_ovr
1236
- int __cdecl vsnwprintf (wchar_t * __restrict__ s , size_t n , const wchar_t * __restrict__ format , va_list arg )
1237
- {
1238
- return _vsnwprintf (s ,n ,format ,arg );
1239
- }
1289
+ int __cdecl snwprintf (wchar_t * __restrict__ s , size_t n , const wchar_t * __restrict__ format , ...) __MINGW_ASM_CALL (__ms_snwprintf );
1290
+ int __cdecl vsnwprintf (wchar_t * __restrict__ s , size_t n , const wchar_t * __restrict__ format , va_list arg ) __MINGW_ASM_CALL (__ms_vsnwprintf );
1240
1291
#endif
1241
1292
1242
1293
#endif /* ! __NO_ISOCEXT */
1243
1294
_CRTIMP int __cdecl _swprintf (wchar_t * __restrict__ _Dest ,const wchar_t * __restrict__ _Format ,...);
1244
1295
_CRTIMP int __cdecl _vswprintf (wchar_t * __restrict__ _Dest ,const wchar_t * __restrict__ _Format ,va_list _Args );
1296
+
1297
+ int __cdecl swprintf (wchar_t * __restrict__ _Dest ,size_t _Count ,const wchar_t * __restrict__ _Format ,...);
1298
+ int __cdecl vswprintf (wchar_t * __restrict__ _Dest ,size_t _Count ,const wchar_t * __restrict__ _Format ,va_list _Args );
1245
1299
#endif /* _UCRT */
1246
1300
1247
1301
#ifndef RC_INVOKED
0 commit comments