Make snprintf() and vsnprintf() conform to C99.

This commit is contained in:
Keith Marshall 2007-08-25 13:49:37 +00:00
parent 80bed8e0a4
commit 01cd95204e
6 changed files with 41 additions and 26 deletions

View File

@ -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

View File

@ -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

View File

@ -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 \

View File

@ -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,

View File

@ -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;
}

View File

@ -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); }