]> source.dussan.org Git - rspamd.git/commitdiff
Allow to print booleans with %b
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 29 Aug 2013 14:00:17 +0000 (15:00 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 29 Aug 2013 14:00:17 +0000 (15:00 +0100)
src/printf.c
src/printf.h

index 00730d16cdd916c3cfca179258a4ee3dcc157d72..b03e1475fff04935977ae02bae8d08c33ce1f12c 100644 (file)
@@ -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);
 
index ff0422d1702c55ea20ed89d763a7e872e8bc2108..9d3921c3ab2386d5f2b27c88cb719dda9e4bc909 100644 (file)
@@ -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 *