1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +03:00

Permit use of vsprintf() in PostgreSQL code.

The next commit needs it.  Back-patch to 9.0 (all supported versions).
This commit is contained in:
Noah Misch
2015-05-18 10:02:31 -04:00
parent 439ff9b6b9
commit 1e6652aea5
2 changed files with 8 additions and 1 deletions

View File

@ -169,6 +169,9 @@ extern unsigned char pg_ascii_tolower(unsigned char ch);
#ifdef snprintf #ifdef snprintf
#undef snprintf #undef snprintf
#endif #endif
#ifdef vsprintf
#undef vsprintf
#endif
#ifdef sprintf #ifdef sprintf
#undef sprintf #undef sprintf
#endif #endif
@ -187,6 +190,7 @@ extern int
pg_snprintf(char *str, size_t count, const char *fmt,...) pg_snprintf(char *str, size_t count, const char *fmt,...)
/* This extension allows gcc to check the format string */ /* This extension allows gcc to check the format string */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4))); __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
extern int pg_vsprintf(char *str, const char *fmt, va_list args);
extern int extern int
pg_sprintf(char *str, const char *fmt,...) pg_sprintf(char *str, const char *fmt,...)
/* This extension allows gcc to check the format string */ /* This extension allows gcc to check the format string */
@ -209,6 +213,7 @@ __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
#ifdef __GNUC__ #ifdef __GNUC__
#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__) #define vsnprintf(...) pg_vsnprintf(__VA_ARGS__)
#define snprintf(...) pg_snprintf(__VA_ARGS__) #define snprintf(...) pg_snprintf(__VA_ARGS__)
#define vsprintf(...) pg_vsprintf(__VA_ARGS__)
#define sprintf(...) pg_sprintf(__VA_ARGS__) #define sprintf(...) pg_sprintf(__VA_ARGS__)
#define vfprintf(...) pg_vfprintf(__VA_ARGS__) #define vfprintf(...) pg_vfprintf(__VA_ARGS__)
#define fprintf(...) pg_fprintf(__VA_ARGS__) #define fprintf(...) pg_fprintf(__VA_ARGS__)
@ -216,6 +221,7 @@ __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
#else #else
#define vsnprintf pg_vsnprintf #define vsnprintf pg_vsnprintf
#define snprintf pg_snprintf #define snprintf pg_snprintf
#define vsprintf pg_vsprintf
#define sprintf pg_sprintf #define sprintf pg_sprintf
#define vfprintf pg_vfprintf #define vfprintf pg_vfprintf
#define fprintf pg_fprintf #define fprintf pg_fprintf

View File

@ -99,6 +99,7 @@
/* Prevent recursion */ /* Prevent recursion */
#undef vsnprintf #undef vsnprintf
#undef snprintf #undef snprintf
#undef vsprintf
#undef sprintf #undef sprintf
#undef vfprintf #undef vfprintf
#undef fprintf #undef fprintf
@ -178,7 +179,7 @@ pg_snprintf(char *str, size_t count, const char *fmt,...)
return len; return len;
} }
static int int
pg_vsprintf(char *str, const char *fmt, va_list args) pg_vsprintf(char *str, const char *fmt, va_list args)
{ {
PrintfTarget target; PrintfTarget target;