# HG changeset patch # User Timo Sirainen # Date 1036388028 -7200 # Node ID 703bbeceb248ec831a6a0e56013dfff2df0d10e5 # Parent c96607edbcb025eaef7680de6ab38b8c4edfb305 Added printf_string_fix_format() which currently just replaces %m with strerror(errno). i_panic, i_fatal, i_error and i_warning didn't expand the %m before when not writing to syslog. diff -r c96607edbcb0 -r 703bbeceb248 src/lib/failures.c --- a/src/lib/failures.c Mon Nov 04 07:23:47 2002 +0200 +++ b/src/lib/failures.c Mon Nov 04 07:33:48 2002 +0200 @@ -64,7 +64,7 @@ write_prefix(); fputs("Panic: ", log_fd); - vfprintf(log_fd, format, args); + vfprintf(log_fd, printf_string_fix_format(format), args); fputc('\n', log_fd); abort(); @@ -75,7 +75,7 @@ write_prefix(); fputs("Fatal: ", log_fd); - vfprintf(log_fd, format, args); + vfprintf(log_fd, printf_string_fix_format(format), args); fputc('\n', log_fd); exit(98); @@ -87,9 +87,11 @@ write_prefix(); + t_push(); fputs("Error: ", log_fd); - vfprintf(log_fd, format, args); + vfprintf(log_fd, printf_string_fix_format(format), args); fputc('\n', log_fd); + t_pop(); fflush(log_fd); @@ -102,9 +104,11 @@ write_prefix(); + t_push(); fputs("Warning: ", log_fd); - vfprintf(log_fd, format, args); - fputc('\n', log_fd); + vfprintf(log_fd, printf_string_fix_format(format), args); + fputc('\n', log_fd); + t_pop(); fflush(log_fd); diff -r c96607edbcb0 -r 703bbeceb248 src/lib/strfuncs.c --- a/src/lib/strfuncs.c Mon Nov 04 07:23:47 2002 +0200 +++ b/src/lib/strfuncs.c Mon Nov 04 07:33:48 2002 +0200 @@ -373,7 +373,7 @@ } /* replace %m with strerror() */ -static const char *fix_format(const char *fmt) +const char *printf_string_fix_format(const char *fmt) { const char *p; @@ -397,7 +397,7 @@ t_push(); va_start(args, format); - ret = vsnprintf(str, max_chars, fix_format(format), args); + ret = vsnprintf(str, max_chars, printf_string_fix_format(format), args); va_end(args); t_pop(); @@ -419,7 +419,7 @@ t_push(); va_start(args, format); - format = fix_format(format); + format = printf_string_fix_format(format); buf = t_buffer_get(printf_string_upper_bound(format, args)); va_end(args); @@ -601,7 +601,7 @@ if (format == NULL) return NULL; - format = fix_format(format); + format = printf_string_fix_format(format); VA_COPY(temp_args, args); diff -r c96607edbcb0 -r 703bbeceb248 src/lib/strfuncs.h --- a/src/lib/strfuncs.h Mon Nov 04 07:23:47 2002 +0200 +++ b/src/lib/strfuncs.h Mon Nov 04 07:33:48 2002 +0200 @@ -5,6 +5,7 @@ ((str) == NULL || (str)[0] == '\0') size_t printf_string_upper_bound(const char *format, va_list args); +const char *printf_string_fix_format(const char *fmt); int i_snprintf(char *str, size_t max_chars, const char *format, ...) __attr_format__(3, 4);