Browse Source

Allow to print booleans with %b

tags/0.6.0
Vsevolod Stakhov 10 years ago
parent
commit
dc1196f106
2 changed files with 16 additions and 0 deletions
  1. 15
    0
      src/printf.c
  2. 1
    0
      src/printf.h

+ 15
- 0
src/printf.c View 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);


+ 1
- 0
src/printf.h View 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 *

Loading…
Cancel
Save