diff options
author | Keith Marshall <keithmarshall@@users.sf.net> | 2007-08-25 17:49:37 +0400 |
---|---|---|
committer | Keith Marshall <keithmarshall@@users.sf.net> | 2007-08-25 17:49:37 +0400 |
commit | 01cd95204efdc980ec2a0ad6bc58b37e2ac32f76 (patch) | |
tree | bf9a0f16686d5b842434e1884902e6a107fe05d0 /winsup | |
parent | 80bed8e0a40b0a42a4102abf0a38d1c49e38b7bb (diff) |
Make snprintf() and vsnprintf() conform to C99.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/mingw/ChangeLog | 19 | ||||
-rw-r--r-- | winsup/mingw/include/stdio.h | 10 | ||||
-rw-r--r-- | winsup/mingw/mingwex/Makefile.in | 8 | ||||
-rwxr-xr-x | winsup/mingw/mingwex/gdtoa/mingw_snprintf.c | 12 | ||||
-rw-r--r-- | winsup/mingw/mingwex/stdio/snprintf.c | 13 | ||||
-rw-r--r-- | winsup/mingw/mingwex/stdio/vsnprintf.c | 5 |
6 files changed, 41 insertions, 26 deletions
diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog index 1071dc75c..407431a71 100644 --- a/winsup/mingw/ChangeLog +++ b/winsup/mingw/ChangeLog @@ -1,4 +1,21 @@ -2007-03-25 Chris Sutcliffe <ir0nh34d@users.sourceforge.net> +2007-08-25 Keith Marshall <keithmarshall@users.sourceforge.net> + + Make snprintf() and vsnprintf() conform to C99. + + * include/stdio.h: Add note about incompatibility between... + (snprintf, vsnprintf): These two mingwex functions, and... + (_snprintf, _vsnprintf): these MSVCRT counterparts. + + * mingwex/Makefile.in (STDIO_OBJS): Remove snprintf.o and vsnprintf.o + (STDIO_DISTFILES): Remove snprintf.c and vsnprintf.c + + * mingwex/stdio/snprintf.c: Delete. + * mingwex/stdio/vsnprintf.c: Delete. + + * mingwex/gdtoa/mingw_snprintf.c (snprintf): Alias to __mingw_snprintf + (vsnprintf): Alias to __mingw_vsnprintf. + +2007-07-25 Chris Sutcliffe <ir0nh34d@users.sourceforge.net> * include/_mingw.h: Increment version to 3.13. * Makefile.in: Reset CYGRELEASE to 1 diff --git a/winsup/mingw/include/stdio.h b/winsup/mingw/include/stdio.h index 101dbe0f4..90a6ff584 100644 --- a/winsup/mingw/include/stdio.h +++ b/winsup/mingw/include/stdio.h @@ -206,6 +206,13 @@ _CRTIMP int __cdecl __MINGW_NOTHROW vsprintf (char*, const char*, __VALIST); _CRTIMP int __cdecl __MINGW_NOTHROW _vsnprintf (char*, size_t, const char*, __VALIST); #ifndef __NO_ISOCEXT /* externs in libmingwex.a */ +/* + * Microsoft does not provide implementations for the following, + * which are required by C99. Note in particular that the corresponding + * Microsoft implementations of _snprintf() and _vsnprintf() are *not* + * compatible with C99, but the following are; if you want the MSVCRT + * behaviour, you *must* use the Microsoft uglified names. + */ int __cdecl __MINGW_NOTHROW snprintf(char *, size_t, const char *, ...); int __cdecl __MINGW_NOTHROW vsnprintf (char *, size_t, const char *, __VALIST); @@ -214,7 +221,8 @@ int __cdecl __MINGW_NOTHROW vfscanf (FILE * __restrict__, const char * __restric __VALIST); int __cdecl __MINGW_NOTHROW vsscanf (const char * __restrict__, const char * __restrict__, __VALIST); -#endif + +#endif /* !__NO_ISOCEXT */ /* * Formatted Input diff --git a/winsup/mingw/mingwex/Makefile.in b/winsup/mingw/mingwex/Makefile.in index bc5db2162..3dd91a5b7 100644 --- a/winsup/mingw/mingwex/Makefile.in +++ b/winsup/mingw/mingwex/Makefile.in @@ -72,8 +72,8 @@ MATH_DISTFILES = \ STDIO_DISTFILES = \ fopen64.c fseeko64.c ftello64.c lseek64.c \ - snprintf.c snwprintf.c vsnprintf.c vsnwprintf.c \ - vfscanf.c vfwscanf.c vscanf.c vsscanf.c vswscanf.c vwscanf.c + vfscanf.c vfwscanf.c vscanf.c vsscanf.c vswscanf.c vwscanf.c \ + snwprintf.c vsnwprintf.c COMPLEX_DISTFILES = \ cabs.c cabsf.c cabsl.c cacos.c cacosf.c cacosl.c cacosh.c \ @@ -138,8 +138,8 @@ STDLIB_STUB_OBJS = \ _Exit.o STDIO_OBJS = \ fopen64.o fseeko64.o ftello64.o lseek64.o \ - snprintf.o vsnprintf.o snwprintf.o vsnwprintf.o \ - vfscanf.o vfwscanf.o vscanf.o vsscanf.o vswscanf.o vwscanf.o + vfscanf.o vfwscanf.o vscanf.o vsscanf.o vswscanf.o vwscanf.o \ + snwprintf.o vsnwprintf.o MATH_OBJS = \ acosf.o acosl.o asinf.o asinl.o atan2f.o atan2l.o \ atanf.o atanl.o cbrt.o cbrtf.o cbrtl.o ceilf.o ceill.o \ diff --git a/winsup/mingw/mingwex/gdtoa/mingw_snprintf.c b/winsup/mingw/mingwex/gdtoa/mingw_snprintf.c index cb827bf4c..f063d2c4b 100755 --- a/winsup/mingw/mingwex/gdtoa/mingw_snprintf.c +++ b/winsup/mingw/mingwex/gdtoa/mingw_snprintf.c @@ -96,8 +96,16 @@ THIS SOFTWARE. #include "gdtoa.h" -#define Snprintf __mingw_snprintf -#define Vsnprintf __mingw_vsnprintf +/* + * For a MinGW build, we provide the implementation dependent entries + * `__mingw_snprintf' and `__mingw_vsnprintf', then alias them to provide + * the C99 conforming implementations of `snprintf()' and `vsnprintf()'. + */ +# define Snprintf __mingw_snprintf +# define Vsnprintf __mingw_vsnprintf + +int __cdecl snprintf()__attribute__((alias("__mingw_snprintf"))); +int __cdecl vsnprintf()__attribute__((alias("__mingw_vsnprintf"))); static char* __ldtoa (long double ld, int mode, int ndig, int *decpt, diff --git a/winsup/mingw/mingwex/stdio/snprintf.c b/winsup/mingw/mingwex/stdio/snprintf.c deleted file mode 100644 index c8d2a7b20..000000000 --- a/winsup/mingw/mingwex/stdio/snprintf.c +++ /dev/null @@ -1,13 +0,0 @@ -#include <stdarg.h> -#include <stdio.h> - -int snprintf(char* buffer, size_t n, const char* format, ...) -{ - int retval; - va_list argptr; - - va_start( argptr, format ); - retval = _vsnprintf( buffer, n, format, argptr ); - va_end( argptr ); - return retval; -} diff --git a/winsup/mingw/mingwex/stdio/vsnprintf.c b/winsup/mingw/mingwex/stdio/vsnprintf.c deleted file mode 100644 index f3dce5b67..000000000 --- a/winsup/mingw/mingwex/stdio/vsnprintf.c +++ /dev/null @@ -1,5 +0,0 @@ -#include <stdarg.h> -#include <stdio.h> - -int vsnprintf (char* s, size_t n, const char* format, va_list arg) - { return _vsnprintf ( s, n, format, arg); } |