aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Misch <noah@leadboat.com>2015-05-18 10:02:31 -0400
committerNoah Misch <noah@leadboat.com>2015-05-18 10:02:35 -0400
commitf7c4fe7d95a3f323df3b0dc3bffff5fa9d708a0c (patch)
tree19ba0a69c34a50b1838240828d3703573da08f4b
parent7a0d48ac7f5ad660414f1b0b6a36cb2b2b7a3667 (diff)
downloadpostgresql-f7c4fe7d95a3f323df3b0dc3bffff5fa9d708a0c.tar.gz
postgresql-f7c4fe7d95a3f323df3b0dc3bffff5fa9d708a0c.zip
Permit use of vsprintf() in PostgreSQL code.
The next commit needs it. Back-patch to 9.0 (all supported versions).
-rw-r--r--src/include/port.h6
-rw-r--r--src/port/snprintf.c3
2 files changed, 8 insertions, 1 deletions
diff --git a/src/include/port.h b/src/include/port.h
index 86941f7ddd7..dacc741fb0e 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -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
diff --git a/src/port/snprintf.c b/src/port/snprintf.c
index 166374cabd6..0c779a601fc 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;