diff options
Diffstat (limited to 'src/include/port.h')
-rw-r--r-- | src/include/port.h | 80 |
1 files changed, 24 insertions, 56 deletions
diff --git a/src/include/port.h b/src/include/port.h index 3f187159cb3..71113c03944 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -126,11 +126,12 @@ extern unsigned char pg_tolower(unsigned char ch); extern unsigned char pg_ascii_toupper(unsigned char ch); extern unsigned char pg_ascii_tolower(unsigned char ch); +#ifdef USE_REPL_SNPRINTF + /* - * Capture macro-compatible calls to printf() and friends, and redirect them - * to wrappers that throw errors in lieu of reporting failure in a return - * value. Versions of libintl >= 0.13 similarly redirect to versions that - * understand the %$ format, so disable libintl macros first. + * Versions of libintl >= 0.13 try to replace printf() and friends with + * macros to their own versions that understand the %$ format. We do the + * same, so disable their macros, if they exist. */ #ifdef vsnprintf #undef vsnprintf @@ -138,9 +139,6 @@ extern unsigned char pg_ascii_tolower(unsigned char ch); #ifdef snprintf #undef snprintf #endif -#ifdef vsprintf -#undef vsprintf -#endif #ifdef sprintf #undef sprintf #endif @@ -154,63 +152,33 @@ extern unsigned char pg_ascii_tolower(unsigned char ch); #undef printf #endif -extern int -vsnprintf_throw_on_fail(char *str, size_t count, const char *fmt, va_list args) -pg_attribute_printf(3, 0); -extern int -snprintf_throw_on_fail(char *str, size_t count, const char *fmt,...) -pg_attribute_printf(3, 4); -extern int -vsprintf_throw_on_fail(char *str, const char *fmt, va_list args) -pg_attribute_printf(2, 0); -extern int -sprintf_throw_on_fail(char *str, const char *fmt,...) -pg_attribute_printf(2, 3); -extern int -vfprintf_throw_on_fail(FILE *stream, const char *fmt, va_list args) -pg_attribute_printf(2, 0); -extern int -fprintf_throw_on_fail(FILE *stream, const char *fmt,...) -pg_attribute_printf(2, 3); -extern int -printf_throw_on_fail(const char *fmt,...) -pg_attribute_printf(1, 2); +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_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_printf(const char *fmt,...) pg_attribute_printf(1, 2); /* * The GCC-specific code below prevents the pg_attribute_printf above from * being replaced, and this is required because gcc doesn't know anything - * about printf_throw_on_fail. + * about pg_printf. */ #ifdef __GNUC__ -#define vsnprintf(...) vsnprintf_throw_on_fail(__VA_ARGS__) -#define snprintf(...) snprintf_throw_on_fail(__VA_ARGS__) -#define vsprintf(...) vsprintf_throw_on_fail(__VA_ARGS__) -#define sprintf(...) sprintf_throw_on_fail(__VA_ARGS__) -#define vfprintf(...) vfprintf_throw_on_fail(__VA_ARGS__) -#define fprintf(...) fprintf_throw_on_fail(__VA_ARGS__) -#define printf(...) printf_throw_on_fail(__VA_ARGS__) +#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__) +#define snprintf(...) pg_snprintf(__VA_ARGS__) +#define sprintf(...) pg_sprintf(__VA_ARGS__) +#define vfprintf(...) pg_vfprintf(__VA_ARGS__) +#define fprintf(...) pg_fprintf(__VA_ARGS__) +#define printf(...) pg_printf(__VA_ARGS__) #else -#define vsnprintf vsnprintf_throw_on_fail -#define snprintf snprintf_throw_on_fail -#define vsprintf vsprintf_throw_on_fail -#define sprintf sprintf_throw_on_fail -#define vfprintf vfprintf_throw_on_fail -#define fprintf fprintf_throw_on_fail -#define printf printf_throw_on_fail +#define vsnprintf pg_vsnprintf +#define snprintf pg_snprintf +#define sprintf pg_sprintf +#define vfprintf pg_vfprintf +#define fprintf pg_fprintf +#define printf pg_printf #endif - -#ifdef USE_REPL_SNPRINTF - -/* Code outside syswrap.c should not call these. */ - -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_printf(const char *fmt,...) pg_attribute_printf(1, 2); - #endif /* USE_REPL_SNPRINTF */ #if defined(WIN32) |