From: Vsevolod Stakhov Date: Thu, 29 Aug 2013 14:00:17 +0000 (+0100) Subject: Allow to print booleans with %b X-Git-Tag: 0.6.0~197 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=dc1196f1064a4bc19a8880c04e4c79a9cef54cc5;p=rspamd.git Allow to print booleans with %b --- 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); diff --git a/src/printf.h b/src/printf.h index ff0422d17..9d3921c3a 100644 --- a/src/printf.h +++ b/src/printf.h @@ -40,6 +40,7 @@ * %[0][width][.width]F long double * %[0][width][.width]g double * %[0][width][.width]G long double + * %b boolean (true or false) * %P pid_t * %r rlim_t * %p void *