postgres.git / summary / log / commit / refs
commit 19f7adc0137fdd1fb20f1e59d4ced1ac19b67ecf
Author: Noah Misch <noah@leadboat.com>
Date: Mon May 18 14:02:31 2015 +0000
First released in: 9.5.0, 9.0.20, 9.1.16, 9.2.11, 9.3.7, 9.4.2
Permit use of vsprintf() in PostgreSQL code.
The next commit needs it. Back-patch to 9.0 (all supported versions).
src/include/port.h | 6 ++++++
src/port/snprintf.c | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/include/port.h b/src/include/port.h
index 74da77ca39e..6bcb8ae7e81 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -161,6 +161,9 @@ extern unsigned char pg_tolower(unsigned char ch);
#ifdef snprintf
#undef snprintf
#endif
+#ifdef vsprintf
+#undef vsprintf
+#endif
#ifdef sprintf
#undef sprintf
#endif
@@ -179,6 +182,7 @@ extern int
pg_snprintf(char *str, size_t count, const char *fmt,...)
/* This extension allows gcc to check the format string */
__attribute__((format(printf, 3, 4)));
+extern int pg_vsprintf(char *str, const char *fmt, va_list args);
extern int
pg_sprintf(char *str, const char *fmt,...)
/* This extension allows gcc to check the format string */
@@ -201,6 +205,7 @@ __attribute__((format(printf, 1, 2)));
#ifdef __GNUC__
#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__)
#define snprintf(...) pg_snprintf(__VA_ARGS__)
+#define vsprintf(...) pg_vsprintf(__VA_ARGS__)
#define sprintf(...) pg_sprintf(__VA_ARGS__)
#define vfprintf(...) pg_vfprintf(__VA_ARGS__)
#define fprintf(...) pg_fprintf(__VA_ARGS__)
@@ -208,6 +213,7 @@ __attribute__((format(printf, 1, 2)));
#else
#define vsnprintf pg_vsnprintf
#define snprintf pg_snprintf
+#define vsprintf pg_vsprintf
#define sprintf pg_sprintf
#define vfprintf pg_vfprintf
#define fprintf pg_fprintf
diff --git a/src/port/snprintf.c b/src/port/snprintf.c
index 5c03ea6fd2e..1fd91a36e8f 100644
--- a/src/port/snprintf.c
+++ b/src/port/snprintf.c
@@ -99,6 +99,7 @@
/* Prevent recursion */
#undef vsnprintf
#undef snprintf
+#undef vsprintf
#undef sprintf
#undef vfprintf
#undef fprintf
@@ -178,7 +179,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;
[parent: 648e41a6e480]