mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
Fix omissions in snprintf.c's coverage of standard *printf functions.
A warning on a NetBSD box revealed to me that pg_waldump/compat.c is using vprintf(), which snprintf.c did not provide coverage for. This is not good if we want to have uniform *printf behavior, and it's pretty silly to omit when it's a one-line function. I also noted that snprintf.c has pg_vsprintf() but for some reason it was not exposed to the outside world, creating another way in which code might accidentally invoke the platform *printf family. Let's just make sure that we replace all eight of the POSIX-standard printf family. Also, upgrade plperl.h and plpython.h to make sure that they do their undefine/redefine rain dance for all eight, not some random maybe-sufficient subset thereof.
This commit is contained in:
@ -33,8 +33,14 @@
|
||||
* Sometimes python carefully scribbles on our *printf macros.
|
||||
* So we undefine them here and redefine them after it's done its dirty deed.
|
||||
*/
|
||||
#undef snprintf
|
||||
#undef vsnprintf
|
||||
#undef snprintf
|
||||
#undef vsprintf
|
||||
#undef sprintf
|
||||
#undef vfprintf
|
||||
#undef fprintf
|
||||
#undef vprintf
|
||||
#undef printf
|
||||
|
||||
#if defined(_MSC_VER) && defined(_DEBUG)
|
||||
/* Python uses #pragma to bring in a non-default libpython on VC++ if
|
||||
@ -120,15 +126,40 @@ typedef int Py_ssize_t;
|
||||
#include <compile.h>
|
||||
#include <eval.h>
|
||||
|
||||
/* put back our snprintf and vsnprintf */
|
||||
#ifdef snprintf
|
||||
#undef snprintf
|
||||
#endif
|
||||
/* put back our *printf macros ... this must match src/include/port.h */
|
||||
#ifdef vsnprintf
|
||||
#undef vsnprintf
|
||||
#endif
|
||||
#define vsnprintf pg_vsnprintf
|
||||
#define snprintf pg_snprintf
|
||||
#ifdef snprintf
|
||||
#undef snprintf
|
||||
#endif
|
||||
#ifdef vsprintf
|
||||
#undef vsprintf
|
||||
#endif
|
||||
#ifdef sprintf
|
||||
#undef sprintf
|
||||
#endif
|
||||
#ifdef vfprintf
|
||||
#undef vfprintf
|
||||
#endif
|
||||
#ifdef fprintf
|
||||
#undef fprintf
|
||||
#endif
|
||||
#ifdef vprintf
|
||||
#undef vprintf
|
||||
#endif
|
||||
#ifdef printf
|
||||
#undef printf
|
||||
#endif
|
||||
|
||||
#define vsnprintf pg_vsnprintf
|
||||
#define snprintf pg_snprintf
|
||||
#define vsprintf pg_vsprintf
|
||||
#define sprintf pg_sprintf
|
||||
#define vfprintf pg_vfprintf
|
||||
#define fprintf pg_fprintf
|
||||
#define vprintf pg_vprintf
|
||||
#define printf(...) pg_printf(__VA_ARGS__)
|
||||
|
||||
/*
|
||||
* Used throughout, and also by the Python 2/3 porting layer, so it's easier to
|
||||
|
Reference in New Issue
Block a user