diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-07-23 12:53:08 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-07-23 12:53:08 +0100 |
commit | fe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b (patch) | |
tree | c84e6a5d4c5cd78a7a2cc3c7adbc7af5d0541682 /src/libutil/printf.c | |
parent | e0483657ff6cf1adc828ccce457814d61fe90a0d (diff) | |
download | rspamd-fe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b.tar.gz rspamd-fe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b.zip |
Revert "Unify code style."
This reverts commit e0483657ff6cf1adc828ccce457814d61fe90a0d.
Diffstat (limited to 'src/libutil/printf.c')
-rw-r--r-- | src/libutil/printf.c | 89 |
1 files changed, 43 insertions, 46 deletions
diff --git a/src/libutil/printf.c b/src/libutil/printf.c index d40b74bca..ba30587fc 100644 --- a/src/libutil/printf.c +++ b/src/libutil/printf.c @@ -21,9 +21,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "printf.h" #include "fstring.h" #include "main.h" -#include "printf.h" /** * From FreeBSD libutil code @@ -90,13 +90,13 @@ rspamd_humanize_number (gchar *buf, gchar *last, gint64 num, gboolean bytes) static gchar * rspamd_sprintf_num (gchar *buf, gchar *last, guint64 ui64, gchar zero, - guint hexadecimal, guint width) + guint hexadecimal, guint width) { - gchar *p, temp[sizeof ("18446744073709551615")]; - size_t len; - guint32 ui32; - static gchar hex[] = "0123456789abcdef"; - static gchar HEX[] = "0123456789ABCDEF"; + gchar *p, temp[sizeof ("18446744073709551615")]; + size_t len; + guint32 ui32; + static gchar hex[] = "0123456789abcdef"; + static gchar HEX[] = "0123456789ABCDEF"; p = temp + sizeof(temp); @@ -220,7 +220,7 @@ rspamd_printf_append_gstring (const gchar *buf, glong buflen, gpointer ud) glong rspamd_fprintf (FILE *f, const gchar *fmt, ...) { - va_list args; + va_list args; glong r; va_start (args, fmt); @@ -233,7 +233,7 @@ rspamd_fprintf (FILE *f, const gchar *fmt, ...) glong rspamd_printf (const gchar *fmt, ...) { - va_list args; + va_list args; glong r; va_start (args, fmt); @@ -246,7 +246,7 @@ rspamd_printf (const gchar *fmt, ...) glong rspamd_log_fprintf (FILE *f, const gchar *fmt, ...) { - va_list args; + va_list args; glong r; va_start (args, fmt); @@ -299,34 +299,31 @@ rspamd_printf_gstring (GString *s, const gchar *fmt, ...) return r; } -#define RSPAMD_PRINTF_APPEND(buf, len) \ - do { \ - wr = func ((buf), (len), apd); \ - if (wr < (__typeof (wr))(len)) { \ - goto oob; \ - } \ - written += wr; \ - fmt++; \ - buf_start = fmt; \ - } while (0) +#define RSPAMD_PRINTF_APPEND(buf, len) \ + do { \ + wr = func ((buf), (len), apd); \ + if (wr < (__typeof(wr))(len)) { \ + goto oob; \ + } \ + written += wr; \ + fmt ++; \ + buf_start = fmt; \ + } while(0) glong -rspamd_vprintf_common (rspamd_printf_append_func func, - gpointer apd, - const gchar *fmt, - va_list args) +rspamd_vprintf_common (rspamd_printf_append_func func, gpointer apd, const gchar *fmt, va_list args) { - gchar zero, numbuf[G_ASCII_DTOSTR_BUF_SIZE], *p, *last, c; - const gchar *buf_start = fmt; - gint d; - long double f, scale; - glong written = 0, wr, slen; - gint64 i64; - guint64 ui64; - guint width, sign, hex, humanize, bytes, frac_width, i; - f_str_t *v; - GString *gs; - gboolean bv; + gchar zero, numbuf[G_ASCII_DTOSTR_BUF_SIZE], *p, *last, c; + const gchar *buf_start = fmt; + gint d; + long double f, scale; + glong written = 0, wr, slen; + gint64 i64; + guint64 ui64; + guint width, sign, hex, humanize, bytes, frac_width, i; + f_str_t *v; + GString *gs; + gboolean bv; while (*fmt) { @@ -363,7 +360,7 @@ rspamd_vprintf_common (rspamd_printf_append_func func, } - for (;; ) { + for ( ;; ) { switch (*fmt) { case 'u': @@ -390,12 +387,12 @@ rspamd_vprintf_common (rspamd_printf_append_func func, humanize = 1; bytes = 1; sign = 0; - fmt++; + fmt ++; continue; case 'h': humanize = 1; sign = 0; - fmt++; + fmt ++; continue; case '.': fmt++; @@ -485,17 +482,17 @@ rspamd_vprintf_common (rspamd_printf_append_func func, case 'l': if (sign) { - i64 = (gint64) va_arg (args, glong); + i64 = (gint64) va_arg(args, glong); } else { - ui64 = (guint64) va_arg (args, gulong); + ui64 = (guint64) va_arg(args, gulong); } break; case 'D': if (sign) { - i64 = (gint64) va_arg (args, gint32); + i64 = (gint64) va_arg(args, gint32); } else { - ui64 = (guint64) va_arg (args, guint32); + ui64 = (guint64) va_arg(args, guint32); } break; @@ -543,9 +540,9 @@ rspamd_vprintf_common (rspamd_printf_append_func func, } /* - * (gint64) cast is required for msvc6: - * it can not convert guint64 to double - */ + * (gint64) cast is required for msvc6: + * it can not convert guint64 to double + */ ui64 = (guint64) ((f - (gint64) ui64) * scale); p = rspamd_sprintf_num (p, last, ui64, '0', 0, frac_width); @@ -623,7 +620,7 @@ rspamd_vprintf_common (rspamd_printf_append_func func, if (sign) { if (i64 < 0) { *p++ = '-'; - ui64 = (guint64) - i64; + ui64 = (guint64) -i64; } else { ui64 = (guint64) i64; |