On 11/6/2012 16:57, JonY wrote:
> 
> Actually, according to
> http://msdn.microsoft.com/en-us/library/28d5ce15%28v=vs.80%29.aspx
> 
> In Visual C++ 2005, vswprintf conforms to the ISO C Standard, which
> requires the second parameter, count, of type size_t. To force the old
> nonstandard behavior, define _CRT_NON_CONFORMING_SWPRINTFS. The old
> behavior may not be in a future version, so code should be changed to
> use the new conformant behavior.
> 
> We do that to mingw-w64 too? MSVC has this behavior since 2005.
> 
> Obviously it will break if user defines _CRT_NON_CONFORMING_SWPRINTFS
> and C++11 at the same time, but that would be PEBCAK.
> 
> 

Alright new patch attached.

Tested with _CRT_NON_CONFORMING_SWPRINTFS and __USE_MINGW_ANSI_STDIO on
and off.

Comments?

Index: stdio.h
===================================================================
--- stdio.h     (revision 5439)
+++ stdio.h     (working copy)
@@ -632,6 +632,10 @@
 #define __mingw_ovr static __cdecl
 #endif
 
+#if defined(_CRT_NON_CONFORMING_SWPRINTFS) && defined(__cplusplus) && 
(__cplusplus >= 201103L)
+#error "_CRT_NON_CONFORMING_SWPRINTFS cannot be used with C++11 or later."
+#endif /* defined(_CRT_NON_CONFORMING_SWPRINTFS) && defined(__cplusplus) && 
(__cplusplus >= 201103L) */
+
 #if __USE_MINGW_ANSI_STDIO
 /*
  * User has expressed a preference for C99 conformance...
@@ -742,8 +746,7 @@
   return __mingw_vwprintf( __format, __local_argv );
 }
 
-/* For libstdc++ */
-#if defined(__cplusplus) && (__cplusplus >= 201103L) && 
!defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)
+#if !defined(_CRT_NON_CONFORMING_SWPRINTFS)
 __mingw_ovr
 /* __attribute__((__format__ (gnu_wprintf, 3, 0))) */ __MINGW_ATTRIB_NONNULL(3)
 int vswprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, 
__builtin_va_list __local_argv)
@@ -757,7 +760,7 @@
 {
   return __mingw_vswprintf( __stream, __format, __local_argv );
 }
-#endif /* defined(__cplusplus) && (__cplusplus >= 201103L) && 
!defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF) */
+#endif /* !defined(_CRT_NON_CONFORMING_SWPRINTFS) */
 
 #ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
 __mingw_ovr
@@ -816,7 +819,9 @@
   int __cdecl vfwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ 
_Format,va_list _ArgList);
   int __cdecl vwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList);
   _CRTIMP int __cdecl swprintf(wchar_t * __restrict__ , const wchar_t * 
__restrict__ , ...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+#if defined(_CRT_NON_CONFORMING_SWPRINTFS)
   _CRTIMP int __cdecl vswprintf(wchar_t * __restrict__ , const wchar_t * 
__restrict__ ,va_list) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+#endif /*!_CRT_NON_CONFORMING_SWPRINTFS*/
 #endif /* __USE_MINGW_ANSI_STDIO */
 
 #ifndef WEOF
@@ -850,6 +855,11 @@
   _CRTIMP int __cdecl _snwprintf(wchar_t * __restrict__ _Dest,size_t 
_Count,const wchar_t * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP int __cdecl _vsnwprintf(wchar_t * __restrict__ _Dest,size_t 
_Count,const wchar_t * __restrict__ _Format,va_list _Args) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
 
+#if !defined(_CRT_NON_CONFORMING_SWPRINTFS) && !defined(__USE_MINGW_ANSI_STDIO)
+  __mingw_ovr int __cdecl vswprintf(wchar_t * __restrict__ _Dest,size_t 
_Count,const wchar_t * __restrict__ _Format,va_list _Args) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN{
+    return _vsnwprintf(_Dest,_Count,_Format,_Args);
+  }
+#endif /* !defined(_CRT_NON_CONFORMING_SWPRINTFS) */
 #ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
 
 #if !defined (__USE_MINGW_ANSI_STDIO) || __USE_MINGW_ANSI_STDIO == 0
@@ -913,7 +923,6 @@
 #ifdef _CRT_NON_CONFORMING_SWPRINTFS
 #ifndef __cplusplus
 #define swprintf _swprintf
-#define vswprintf _vswprintf
 #define _swprintf_l __swprintf_l
 #define _vswprintf_l __vswprintf_l
 #endif
Index: wchar.h
===================================================================
--- wchar.h     (revision 5439)
+++ wchar.h     (working copy)
@@ -458,6 +458,10 @@
 #define __mingw_ovr static __cdecl
 #endif
 
+#if defined(_CRT_NON_CONFORMING_SWPRINTFS) && defined(__cplusplus) && 
(__cplusplus >= 201103L)
+#error "_CRT_NON_CONFORMING_SWPRINTFS cannot be used with C++11 or later."
+#endif /* defined(_CRT_NON_CONFORMING_SWPRINTFS) && defined(__cplusplus) && 
(__cplusplus >= 201103L) */
+
 #if __USE_MINGW_ANSI_STDIO
 
 /*
@@ -568,8 +572,7 @@
   return __mingw_vwprintf( __format, __local_argv );
 }
 
-/* For libstdc++ */
-#if defined(__cplusplus) && (__cplusplus >= 201103L) && 
!defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)
+#if !defined(_CRT_NON_CONFORMING_SWPRINTFS)
 __mingw_ovr
 /* __attribute__((__format__ (gnu_wprintf, 3, 0))) */ __MINGW_ATTRIB_NONNULL(3)
 int vswprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, 
__builtin_va_list __local_argv)
@@ -583,7 +586,7 @@
 {
   return __mingw_vswprintf( __stream, __format, __local_argv );
 }
-#endif /* defined(__cplusplus) && (__cplusplus >= 201103L) && 
!defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF) */
+#endif /* !defined(_CRT_NON_CONFORMING_SWPRINTFS) */
 
 /*#ifndef __NO_ISOCEXT */  /* externs in libmingwex.a */
 __mingw_ovr
@@ -642,7 +645,9 @@
   int __cdecl vfwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ 
_Format,va_list _ArgList);
   int __cdecl vwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList);
   _CRTIMP int __cdecl swprintf(wchar_t * __restrict__ , const wchar_t * 
__restrict__ , ...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+#if defined(_CRT_NON_CONFORMING_SWPRINTFS)
   _CRTIMP int __cdecl vswprintf(wchar_t * __restrict__ , const wchar_t * 
__restrict__ ,va_list) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+#endif /*_CRT_NON_CONFORMING_SWPRINTFS*/
 #endif /* __USE_MINGW_ANSI_STDIO */
 
 
@@ -676,6 +681,11 @@
   _CRTIMP int __cdecl _snwprintf(wchar_t * __restrict__ _Dest,size_t 
_Count,const wchar_t * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP int __cdecl _vsnwprintf(wchar_t * __restrict__ _Dest,size_t 
_Count,const wchar_t * __restrict__ _Format,va_list _Args) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
 
+#if !defined(_CRT_NON_CONFORMING_SWPRINTFS) && !defined(__USE_MINGW_ANSI_STDIO)
+  __mingw_ovr int __cdecl vswprintf(wchar_t * __restrict__ _Dest,size_t 
_Count,const wchar_t * __restrict__ _Format,va_list _Args) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN{
+    return _vsnwprintf(_Dest,_Count,_Format,_Args);
+  }
+#endif /* !defined(_CRT_NON_CONFORMING_SWPRINTFS) && 
!defined(__USE_MINGW_ANSI_STDIO) */
 #ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
 
 #if !defined (__USE_MINGW_ANSI_STDIO) || __USE_MINGW_ANSI_STDIO == 0
@@ -740,7 +750,6 @@
 #ifdef _CRT_NON_CONFORMING_SWPRINTFS
 #ifndef __cplusplus
 #define swprintf _swprintf
-#define vswprintf _vswprintf
 #define _swprintf_l __swprintf_l
 #define _vswprintf_l __vswprintf_l
 #endif

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to