diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-08-29 15:00:17 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-08-29 15:00:17 +0100 |
commit | dc1196f1064a4bc19a8880c04e4c79a9cef54cc5 (patch) | |
tree | 2f2d90c653202acb67071ddf86723af8727d8296 | |
parent | ecfc58fc43afcd36399f8d1fe5d8512b8a59598e (diff) | |
download | rspamd-dc1196f1064a4bc19a8880c04e4c79a9cef54cc5.tar.gz rspamd-dc1196f1064a4bc19a8880c04e4c79a9cef54cc5.zip |
Allow to print booleans with %b
-rw-r--r-- | src/printf.c | 15 | ||||
-rw-r--r-- | src/printf.h | 1 |
2 files changed, 16 insertions, 0 deletions
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 * |