From dc1196f1064a4bc19a8880c04e4c79a9cef54cc5 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 29 Aug 2013 15:00:17 +0100 Subject: Allow to print booleans with %b --- src/printf.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/printf.c') diff --git a/src/printf.c b/src/printf.c index 00730d16c..b03e1475f 100644 --- a/src/printf.c +++ b/src/printf.c @@ -296,6 +296,7 @@ rspamd_vsnprintf (gchar *buf, glong max, const gchar *fmt, va_list args) guint width, sign, hex, humanize, bytes, frac_width, i; f_str_t *v; GString *gs; + gboolean bv; if (max <= 0) { return buf; @@ -594,6 +595,20 @@ rspamd_vsnprintf (gchar *buf, glong max, const gchar *fmt, va_list args) continue; + case 'b': + bv = (gboolean) va_arg (args, double); + if (bv) { + len = MIN (last - buf, 4); + memcpy (buf, "true", len); + } + else { + len = MIN (last - buf, 5); + memcpy (buf, "false", len); + } + fmt++; + + continue; + case 'G': f = (long double) va_arg (args, long double); -- cgit v1.2.3