From 780d6ec95e331102cbad21776e424f0978e9c409 Mon Sep 17 00:00:00 2001 From: keithmarshall Date: Mon, 11 Aug 2008 22:41:55 +0000 Subject: [PATCH] Add replacements for remaining members of printf() family. --- winsup/mingw/ChangeLog | 14 ++++++++ winsup/mingw/mingwex/Makefile.in | 6 ++-- winsup/mingw/mingwex/stdio/fprintf.c | 68 +++++++++++++++++++++++++++++++++++ winsup/mingw/mingwex/stdio/printf.c | 68 +++++++++++++++++++++++++++++++++++ winsup/mingw/mingwex/stdio/sprintf.c | 68 +++++++++++++++++++++++++++++++++++ winsup/mingw/mingwex/stdio/vfprintf.c | 64 +++++++++++++++++++++++++++++++++ winsup/mingw/mingwex/stdio/vprintf.c | 64 +++++++++++++++++++++++++++++++++ winsup/mingw/mingwex/stdio/vsprintf.c | 66 ++++++++++++++++++++++++++++++++++ 8 files changed, 416 insertions(+), 2 deletions(-) create mode 100644 winsup/mingw/mingwex/stdio/fprintf.c create mode 100644 winsup/mingw/mingwex/stdio/printf.c create mode 100644 winsup/mingw/mingwex/stdio/sprintf.c create mode 100644 winsup/mingw/mingwex/stdio/vfprintf.c create mode 100644 winsup/mingw/mingwex/stdio/vprintf.c create mode 100644 winsup/mingw/mingwex/stdio/vsprintf.c diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog index 0107cdab22..184fa5698f 100644 --- a/winsup/mingw/ChangeLog +++ b/winsup/mingw/ChangeLog @@ -1,3 +1,17 @@ +2008-08-11 Keith Marshall + + Add replacements for remaining members of printf() family. + + * mingwex/stdio/printf.c: New file. + * mingwex/stdio/fprintf.c: New file. + * mingwex/stdio/sprintf.c: New file. + * mingwex/stdio/vprintf.c: New file. + * mingwex/stdio/vfprintf.c: New file. + * mingwex/stdio/vsprintf.c: New file. + + * mingwex/Makefile.in (STDIO_DISTFILES): Add them. + (STDIO_OBJS): Add their corresponding object files. + 2008-07-29 Keith Marshall Replace __mingw_snprintf() with new generic family implementation; diff --git a/winsup/mingw/mingwex/Makefile.in b/winsup/mingw/mingwex/Makefile.in index 9142576a4c..3d67b9d243 100644 --- a/winsup/mingw/mingwex/Makefile.in +++ b/winsup/mingw/mingwex/Makefile.in @@ -74,7 +74,8 @@ MATH_DISTFILES = \ STDIO_DISTFILES = \ fopen64.c fseeko64.c ftello64.c lseek64.c \ vfscanf.c vfwscanf.c vscanf.c vsscanf.c vswscanf.c vwscanf.c \ - pformat.c pformat.h snprintf.c vsnprintf.c \ + pformat.c pformat.h printf.c fprintf.c sprintf.c snprintf.c \ + vprintf.c vfprintf.c vsprintf.c vsnprintf.c \ snwprintf.c vsnwprintf.c COMPLEX_DISTFILES = \ @@ -142,7 +143,8 @@ STDLIB_STUB_OBJS = \ STDIO_OBJS = \ fopen64.o fseeko64.o ftello64.o lseek64.o \ vfscanf.o vfwscanf.o vscanf.o vsscanf.o vswscanf.o vwscanf.o \ - pformat.o snprintf.o vsnprintf.o snwprintf.o vsnwprintf.o + pformat.o snprintf.o vsnprintf.o snwprintf.o vsnwprintf.o \ + printf.o fprintf.o sprintf.o vprintf.o vfprintf.o vsprintf.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/stdio/fprintf.c b/winsup/mingw/mingwex/stdio/fprintf.c new file mode 100644 index 0000000000..8e0582cb89 --- /dev/null +++ b/winsup/mingw/mingwex/stdio/fprintf.c @@ -0,0 +1,68 @@ +/* fprintf.c + * + * $Id$ + * + * Provides an implementation of the "fprintf" function, conforming + * generally to C99 and SUSv3/POSIX specifications, with extensions + * to support Microsoft's non-standard format specifications. This + * is included in libmingwex.a, whence it may replace the Microsoft + * function of the same name. + * + * Written by Keith Marshall + * + * This implementation of "fprintf" will normally be invoked by calling + * "__mingw_fprintf()" in preference to a direct reference to "fprintf()" + * itself; this leaves the MSVCRT implementation as the default, which + * will be deployed when user code invokes "fprint()". Users who then + * wish to use this implementation may either call "__mingw_fprintf()" + * directly, or may use conditional preprocessor defines, to redirect + * references to "fprintf()" to "__mingw_fprintf()". + * + * Compiling this module with "-D INSTALL_AS_DEFAULT" will change this + * recommended convention, such that references to "fprintf()" in user + * code will ALWAYS be redirected to "__mingw_fprintf()"; if this option + * is adopted, then users wishing to use the MSVCRT implementation of + * "fprintf()" will be forced to use a "back-door" mechanism to do so. + * Such a "back-door" mechanism is provided with MinGW, allowing the + * MSVCRT implementation to be called as "__msvcrt_fprintf()"; however, + * since users may not expect this behaviour, a standard libmingwex.a + * installation does not employ this option. + * + * + * This is free software. You may redistribute and/or modify it as you + * see fit, without restriction of copyright. + * + * This software is provided "as is", in the hope that it may be useful, + * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of + * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no + * time will the author accept any form of liability for any damages, + * however caused, resulting from the use of this software. + * + */ +#include +#include + +#include "pformat.h" + +int __cdecl __fprintf (FILE *, const char *, ...) __MINGW_NOTHROW; + +#ifdef INSTALL_AS_DEFAULT +/* + * This implementation is to become the default for calls to fprintf(); + * establish the alias to make this so, forcing users to use the back-door + * __msvcrt_fprintf() reference, to access the original MSVCRT function. + */ +int __cdecl __mingw_alias(fprintf) (FILE *, const char *, ...) __MINGW_NOTHROW; + +#endif + +int __cdecl __fprintf( FILE *stream, const char *fmt, ... ) +{ + register int retval; + va_list argv; va_start( argv, fmt ); + retval = __pformat( PFORMAT_TO_FILE | PFORMAT_NOLIMIT, stream, 0, fmt, argv ); + va_end( argv ); + return retval; +} + +/* $RCSfile$Revision$: end of file */ diff --git a/winsup/mingw/mingwex/stdio/printf.c b/winsup/mingw/mingwex/stdio/printf.c new file mode 100644 index 0000000000..98b4e62e3d --- /dev/null +++ b/winsup/mingw/mingwex/stdio/printf.c @@ -0,0 +1,68 @@ +/* printf.c + * + * $Id$ + * + * Provides an implementation of the "printf" function, conforming + * generally to C99 and SUSv3/POSIX specifications, with extensions + * to support Microsoft's non-standard format specifications. This + * is included in libmingwex.a, whence it may replace the Microsoft + * function of the same name. + * + * Written by Keith Marshall + * + * This implementation of "printf" will normally be invoked by calling + * "__mingw_printf()" in preference to a direct reference to "printf()" + * itself; this leaves the MSVCRT implementation as the default, which + * will be deployed when user code invokes "print()". Users who then + * wish to use this implementation may either call "__mingw_printf()" + * directly, or may use conditional preprocessor defines, to redirect + * references to "printf()" to "__mingw_printf()". + * + * Compiling this module with "-D INSTALL_AS_DEFAULT" will change this + * recommended convention, such that references to "printf()" in user + * code will ALWAYS be redirected to "__mingw_printf()"; if this option + * is adopted, then users wishing to use the MSVCRT implementation of + * "printf()" will be forced to use a "back-door" mechanism to do so. + * Such a "back-door" mechanism is provided with MinGW, allowing the + * MSVCRT implementation to be called as "__msvcrt_printf()"; however, + * since users may not expect this behaviour, a standard libmingwex.a + * installation does not employ this option. + * + * + * This is free software. You may redistribute and/or modify it as you + * see fit, without restriction of copyright. + * + * This software is provided "as is", in the hope that it may be useful, + * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of + * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no + * time will the author accept any form of liability for any damages, + * however caused, resulting from the use of this software. + * + */ +#include +#include + +#include "pformat.h" + +int __cdecl __printf( const char *, ... ) __MINGW_NOTHROW; + +#ifdef INSTALL_AS_DEFAULT +/* + * This implementation is to become the default for calls to printf(); + * establish the alias to make this so, forcing users to use the back-door + * __msvcrt_printf() reference, to access the original MSVCRT function. + */ +int __cdecl __mingw_alias(printf) (const char *, ...) __MINGW_NOTHROW; + +#endif + +int __cdecl __printf( const char *fmt, ... ) +{ + register int retval; + va_list argv; va_start( argv, fmt ); + retval = __pformat( PFORMAT_TO_FILE | PFORMAT_NOLIMIT, stdout, 0, fmt, argv ); + va_end( argv ); + return retval; +} + +/* $RCSfile$Revision$: end of file */ diff --git a/winsup/mingw/mingwex/stdio/sprintf.c b/winsup/mingw/mingwex/stdio/sprintf.c new file mode 100644 index 0000000000..c3381d3ef3 --- /dev/null +++ b/winsup/mingw/mingwex/stdio/sprintf.c @@ -0,0 +1,68 @@ +/* sprintf.c + * + * $Id$ + * + * Provides an implementation of the "sprintf" function, conforming + * generally to C99 and SUSv3/POSIX specifications, with extensions + * to support Microsoft's non-standard format specifications. This + * is included in libmingwex.a, whence it may replace the Microsoft + * function of the same name. + * + * Written by Keith Marshall + * + * This implementation of "sprintf" will normally be invoked by calling + * "__mingw_sprintf()" in preference to a direct reference to "sprintf()" + * itself; this leaves the MSVCRT implementation as the default, which + * will be deployed when user code invokes "sprint()". Users who then + * wish to use this implementation may either call "__mingw_sprintf()" + * directly, or may use conditional preprocessor defines, to redirect + * references to "sprintf()" to "__mingw_sprintf()". + * + * Compiling this module with "-D INSTALL_AS_DEFAULT" will change this + * recommended convention, such that references to "sprintf()" in user + * code will ALWAYS be redirected to "__mingw_sprintf()"; if this option + * is adopted, then users wishing to use the MSVCRT implementation of + * "sprintf()" will be forced to use a "back-door" mechanism to do so. + * Such a "back-door" mechanism is provided with MinGW, allowing the + * MSVCRT implementation to be called as "__msvcrt_sprintf()"; however, + * since users may not expect this behaviour, a standard libmingwex.a + * installation does not employ this option. + * + * + * This is free software. You may redistribute and/or modify it as you + * see fit, without restriction of copyright. + * + * This software is provided "as is", in the hope that it may be useful, + * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of + * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no + * time will the author accept any form of liability for any damages, + * however caused, resulting from the use of this software. + * + */ +#include +#include + +#include "pformat.h" + +int __cdecl __sprintf (char *, const char *, ...) __MINGW_NOTHROW; + +#ifdef INSTALL_AS_DEFAULT +/* + * This implementation is to become the default for calls to sprintf(); + * establish the alias to make this so, forcing users to use the back-door + * __msvcrt_sprintf() reference, to access the original MSVCRT function. + */ +int __cdecl __mingw_alias(sprintf) (char *, const char *, ...) __MINGW_NOTHROW; + +#endif + +int __cdecl __sprintf( char *buf, const char *fmt, ... ) +{ + register int retval; + va_list argv; va_start( argv, fmt ); + buf[retval = __pformat( PFORMAT_NOLIMIT, buf, 0, fmt, argv )] = '\0'; + va_end( argv ); + return retval; +} + +/* $RCSfile$Revision$: end of file */ diff --git a/winsup/mingw/mingwex/stdio/vfprintf.c b/winsup/mingw/mingwex/stdio/vfprintf.c new file mode 100644 index 0000000000..19de7ae8c6 --- /dev/null +++ b/winsup/mingw/mingwex/stdio/vfprintf.c @@ -0,0 +1,64 @@ +/* vfprintf.c + * + * $Id$ + * + * Provides an implementation of the "vfprintf" function, conforming + * generally to C99 and SUSv3/POSIX specifications, with extensions + * to support Microsoft's non-standard format specifications. This + * is included in libmingwex.a, whence it may replace the Microsoft + * function of the same name. + * + * Written by Keith Marshall + * + * This implementation of "vfprintf" will normally be invoked by calling + * "__mingw_vfprintf()" in preference to a direct reference to "vfprintf()" + * itself; this leaves the MSVCRT implementation as the default, which + * will be deployed when user code invokes "vfprint()". Users who then + * wish to use this implementation may either call "__mingw_vfprintf()" + * directly, or may use conditional preprocessor defines, to redirect + * references to "vfprintf()" to "__mingw_vfprintf()". + * + * Compiling this module with "-D INSTALL_AS_DEFAULT" will change this + * recommended convention, such that references to "vfprintf()" in user + * code will ALWAYS be redirected to "__mingw_vfprintf()"; if this option + * is adopted, then users wishing to use the MSVCRT implementation of + * "vfprintf()" will be forced to use a "back-door" mechanism to do so. + * Such a "back-door" mechanism is provided with MinGW, allowing the + * MSVCRT implementation to be called as "__msvcrt_vfprintf()"; however, + * since users may not expect this behaviour, a standard libmingwex.a + * installation does not employ this option. + * + * + * This is free software. You may redistribute and/or modify it as you + * see fit, without restriction of copyright. + * + * This software is provided "as is", in the hope that it may be useful, + * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of + * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no + * time will the author accept any form of liability for any damages, + * however caused, resulting from the use of this software. + * + */ +#include +#include + +#include "pformat.h" + +int __cdecl __vfprintf (FILE *, const char *, va_list) __MINGW_NOTHROW; + +#ifdef INSTALL_AS_DEFAULT +/* + * This implementation is to become the default for calls to vfprintf(); + * establish the alias to make this so, forcing users to use the back-door + * __msvcrt_vfprintf() reference, to access the original MSVCRT function. + */ +int __cdecl __mingw_alias(vfprintf) (FILE *, const char *, va_list) __MINGW_NOTHROW; + +#endif + +int __cdecl __vfprintf( FILE *stream, const char *fmt, va_list argv ) +{ + return __pformat( PFORMAT_TO_FILE | PFORMAT_NOLIMIT, stream, 0, fmt, argv ); +} + +/* $RCSfile$Revision$: end of file */ diff --git a/winsup/mingw/mingwex/stdio/vprintf.c b/winsup/mingw/mingwex/stdio/vprintf.c new file mode 100644 index 0000000000..20d4385aeb --- /dev/null +++ b/winsup/mingw/mingwex/stdio/vprintf.c @@ -0,0 +1,64 @@ +/* vprintf.c + * + * $Id$ + * + * Provides an implementation of the "vprintf" function, conforming + * generally to C99 and SUSv3/POSIX specifications, with extensions + * to support Microsoft's non-standard format specifications. This + * is included in libmingwex.a, whence it may replace the Microsoft + * function of the same name. + * + * Written by Keith Marshall + * + * This implementation of "vprintf" will normally be invoked by calling + * "__mingw_vprintf()" in preference to a direct reference to "vprintf()" + * itself; this leaves the MSVCRT implementation as the default, which + * will be deployed when user code invokes "vprint()". Users who then + * wish to use this implementation may either call "__mingw_vprintf()" + * directly, or may use conditional preprocessor defines, to redirect + * references to "vprintf()" to "__mingw_vprintf()". + * + * Compiling this module with "-D INSTALL_AS_DEFAULT" will change this + * recommended convention, such that references to "vprintf()" in user + * code will ALWAYS be redirected to "__mingw_vprintf()"; if this option + * is adopted, then users wishing to use the MSVCRT implementation of + * "vprintf()" will be forced to use a "back-door" mechanism to do so. + * Such a "back-door" mechanism is provided with MinGW, allowing the + * MSVCRT implementation to be called as "__msvcrt_vprintf()"; however, + * since users may not expect this behaviour, a standard libmingwex.a + * installation does not employ this option. + * + * + * This is free software. You may redistribute and/or modify it as you + * see fit, without restriction of copyright. + * + * This software is provided "as is", in the hope that it may be useful, + * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of + * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no + * time will the author accept any form of liability for any damages, + * however caused, resulting from the use of this software. + * + */ +#include +#include + +#include "pformat.h" + +int __cdecl __vprintf (const char *, va_list) __MINGW_NOTHROW; + +#ifdef INSTALL_AS_DEFAULT +/* + * This implementation is to become the default for calls to vprintf(); + * establish the alias to make this so, forcing users to use the back-door + * __msvcrt_vprintf() reference, to access the original MSVCRT function. + */ +int __cdecl __mingw_alias(vprintf) (const char *, va_list) __MINGW_NOTHROW; + +#endif + +int __cdecl __vprintf( const char *fmt, va_list argv ) +{ + return __pformat( PFORMAT_TO_FILE | PFORMAT_NOLIMIT, stdout, 0, fmt, argv ); +} + +/* $RCSfile$Revision$: end of file */ diff --git a/winsup/mingw/mingwex/stdio/vsprintf.c b/winsup/mingw/mingwex/stdio/vsprintf.c new file mode 100644 index 0000000000..babfebd4ed --- /dev/null +++ b/winsup/mingw/mingwex/stdio/vsprintf.c @@ -0,0 +1,66 @@ +/* vsprintf.c + * + * $Id$ + * + * Provides an implementation of the "vsprintf" function, conforming + * generally to C99 and SUSv3/POSIX specifications, with extensions + * to support Microsoft's non-standard format specifications. This + * is included in libmingwex.a, whence it may replace the Microsoft + * function of the same name. + * + * Written by Keith Marshall + * + * This implementation of "vsprintf" will normally be invoked by calling + * "__mingw_vsprintf()" in preference to a direct reference to "vsprintf()" + * itself; this leaves the MSVCRT implementation as the default, which + * will be deployed when user code invokes "vsprint()". Users who then + * wish to use this implementation may either call "__mingw_vsprintf()" + * directly, or may use conditional preprocessor defines, to redirect + * references to "vsprintf()" to "__mingw_vsprintf()". + * + * Compiling this module with "-D INSTALL_AS_DEFAULT" will change this + * recommended convention, such that references to "vsprintf()" in user + * code will ALWAYS be redirected to "__mingw_vsprintf()"; if this option + * is adopted, then users wishing to use the MSVCRT implementation of + * "vsprintf()" will be forced to use a "back-door" mechanism to do so. + * Such a "back-door" mechanism is provided with MinGW, allowing the + * MSVCRT implementation to be called as "__msvcrt_vsprintf()"; however, + * since users may not expect this behaviour, a standard libmingwex.a + * installation does not employ this option. + * + * + * This is free software. You may redistribute and/or modify it as you + * see fit, without restriction of copyright. + * + * This software is provided "as is", in the hope that it may be useful, + * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of + * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no + * time will the author accept any form of liability for any damages, + * however caused, resulting from the use of this software. + * + */ +#include +#include + +#include "pformat.h" + +int __cdecl __vsprintf (char *, const char *, va_list) __MINGW_NOTHROW; + +#ifdef INSTALL_AS_DEFAULT +/* + * This implementation is to become the default for calls to vsprintf(); + * establish the alias to make this so, forcing users to use the back-door + * __msvcrt_vsprintf() reference, to access the original MSVCRT function. + */ +int __cdecl __mingw_alias(vsprintf) (char *, const char *, va_list) __MINGW_NOTHROW; + +#endif + +int __cdecl __vsprintf( char *buf, const char *fmt, va_list argv ) +{ + register int retval; + buf[retval = __pformat( PFORMAT_NOLIMIT, buf, 0, fmt, argv )] = '\0'; + return retval; +} + +/* $RCSfile$Revision$: end of file */ -- 2.11.0