diff options
-rw-r--r-- | src/include/port.h | 10 | ||||
-rw-r--r-- | src/pl/plperl/plperl.h | 40 | ||||
-rw-r--r-- | src/pl/plpython/plpython.h | 43 | ||||
-rw-r--r-- | src/port/snprintf.c | 10 |
4 files changed, 91 insertions, 12 deletions
diff --git a/src/include/port.h b/src/include/port.h index 0729c3fc2e..3a53bcf2e4 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -152,6 +152,9 @@ extern unsigned char pg_ascii_tolower(unsigned char ch); #ifdef snprintf #undef snprintf #endif +#ifdef vsprintf +#undef vsprintf +#endif #ifdef sprintf #undef sprintf #endif @@ -161,15 +164,20 @@ extern unsigned char pg_ascii_tolower(unsigned char ch); #ifdef fprintf #undef fprintf #endif +#ifdef vprintf +#undef vprintf +#endif #ifdef printf #undef printf #endif extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args); extern int pg_snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3, 4); +extern int pg_vsprintf(char *str, const char *fmt, va_list args); extern int pg_sprintf(char *str, const char *fmt,...) pg_attribute_printf(2, 3); extern int pg_vfprintf(FILE *stream, const char *fmt, va_list args); extern int pg_fprintf(FILE *stream, const char *fmt,...) pg_attribute_printf(2, 3); +extern int pg_vprintf(const char *fmt, va_list args); extern int pg_printf(const char *fmt,...) pg_attribute_printf(1, 2); /* @@ -182,9 +190,11 @@ extern int pg_printf(const char *fmt,...) pg_attribute_printf(1, 2); */ #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__) /* This is also provided by snprintf.c */ diff --git a/src/pl/plperl/plperl.h b/src/pl/plperl/plperl.h index 2b733546c3..12fbad9787 100644 --- a/src/pl/plperl/plperl.h +++ b/src/pl/plperl/plperl.h @@ -29,8 +29,14 @@ * Sometimes perl 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 /* * ActivePerl 5.18 and later are MinGW-built, and their headers use GCC's @@ -89,21 +95,45 @@ #undef socket #undef stat #undef unlink -#undef vfprintf #endif #include "XSUB.h" #endif -/* put back our snprintf and vsnprintf */ +/* put back our *printf macros ... this must match src/include/port.h */ +#ifdef vsnprintf +#undef vsnprintf +#endif #ifdef snprintf #undef snprintf #endif -#ifdef vsnprintf -#undef vsnprintf +#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__) /* perl version and platform portability */ #define NEED_eval_pv diff --git a/src/pl/plpython/plpython.h b/src/pl/plpython/plpython.h index eaf3e4a154..8cb922de72 100644 --- a/src/pl/plpython/plpython.h +++ b/src/pl/plpython/plpython.h @@ -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 */ +/* put back our *printf macros ... this must match src/include/port.h */ +#ifdef vsnprintf +#undef vsnprintf +#endif #ifdef snprintf #undef snprintf #endif -#ifdef vsnprintf -#undef vsnprintf +#ifdef vsprintf +#undef vsprintf #endif -#define vsnprintf pg_vsnprintf -#define snprintf pg_snprintf +#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 diff --git a/src/port/snprintf.c b/src/port/snprintf.c index 58300eab95..31438dded4 100644 --- a/src/port/snprintf.c +++ b/src/port/snprintf.c @@ -102,9 +102,11 @@ /* Prevent recursion */ #undef vsnprintf #undef snprintf +#undef vsprintf #undef sprintf #undef vfprintf #undef fprintf +#undef vprintf #undef printf /* @@ -208,7 +210,7 @@ pg_snprintf(char *str, size_t count, const char *fmt,...) return len; } -static int +int pg_vsprintf(char *str, const char *fmt, va_list args) { PrintfTarget target; @@ -271,6 +273,12 @@ pg_fprintf(FILE *stream, const char *fmt,...) } int +pg_vprintf(const char *fmt, va_list args) +{ + return pg_vfprintf(stdout, fmt, args); +} + +int pg_printf(const char *fmt,...) { int len; |