Permit use of vsprintf() in PostgreSQL code.
authorNoah Misch
Mon, 18 May 2015 14:02:31 +0000 (10:02 -0400)
committerNoah Misch
Mon, 18 May 2015 14:02:35 +0000 (10:02 -0400)
The next commit needs it.  Back-patch to 9.0 (all supported versions).

src/include/port.h
src/port/snprintf.c

index 86941f7ddd79d11c52dd3df2387ea86f3345b95a..dacc741fb0ef13adb04f8ed2b46b2df98a128001 100644 (file)
@@ -139,6 +139,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
@@ -157,6 +160,7 @@ extern int
 pg_snprintf(char *str, size_t count, const char *fmt,...)
 /* This extension allows gcc to check the format string */
 __attribute__((format(PG_PRINTF_ATTRIBUTE, 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 */
@@ -179,6 +183,7 @@ __attribute__((format(PG_PRINTF_ATTRIBUTE, 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__)
@@ -186,6 +191,7 @@ __attribute__((format(PG_PRINTF_ATTRIBUTE, 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
index 166374cabd6b7bf4a4b70afe5685f17b366ce231..0c779a601fcfc93b723f1a696adce8923565fde3 100644 (file)
@@ -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;