diff th_printf.c @ 735:31bc1ed07cf5

Renaming BOOL->bool and TRUE/FALSE to true/false, and using stdbool.h if available.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 07 Dec 2022 12:14:39 +0200
parents 29e44a58bc73
children c9a6fe116453
line wrap: on
line diff
--- a/th_printf.c	Wed Dec 07 11:58:54 2022 +0200
+++ b/th_printf.c	Wed Dec 07 12:14:39 2022 +0200
@@ -8,7 +8,7 @@
 
 
 #ifdef TH_PRINTF_DEBUG
-BOOL th_printf_debug = FALSE;
+bool th_printf_debug = false;
 char *th_printf_debug_prefix = NULL;
 
 
@@ -152,7 +152,7 @@
 
 int th_vprintf_put_int_format(th_vprintf_ctx *ctx, th_vprintf_putch vputch,
     th_char_t *buf, int f_flags, int f_width, int f_prec, int f_len, int vret,
-    BOOL f_neg, BOOL f_unsig, th_vprintf_altfmt_func f_alt)
+    bool f_neg, bool f_unsig, th_vprintf_altfmt_func f_alt)
 {
     int ret = 0, nspacepad, nzeropad, f_altstr_len = 0;
     th_char_t f_sign, *f_altstr;
@@ -252,11 +252,11 @@
 
 int th_vprintf_put_int(th_vprintf_ctx *ctx, th_vprintf_putch vputch,
     va_list ap, const int f_radix, int f_flags, int f_width, int f_prec,
-    const BOOL f_unsig, th_vprintf_altfmt_func f_alt)
+    const bool f_unsig, th_vprintf_altfmt_func f_alt)
 {
     th_char_t buf[32];
     int f_len = 0, vret;
-    BOOL f_neg = FALSE;
+    bool f_neg = false;
 
     if (f_flags & TH_PF_LONGLONG)
     {
@@ -326,7 +326,7 @@
     memcpy(&val, &pval, sizeof(int64_t));
 
     // We have sign, exponent and mantissa
-    BOOL f_sign    = (val >> 63) & 0x01;
+    bool f_sign    = (val >> 63) & 0x01;
     int64_t d_exp  = (val >> 52) & 0x7ff;
     uint64_t d_man = val & 0x0fffffffffffff;
 
@@ -358,7 +358,7 @@
             return th_printf_pad_post(ctx, vputch, f_width - 1, f_flags);
 
         case 'o':
-            return th_vprintf_put_int(ctx, vputch, ap, 8, f_flags, f_width, f_prec, TRUE, th_vprintf_altfmt_oct);
+            return th_vprintf_put_int(ctx, vputch, ap, 8, f_flags, f_width, f_prec, true, th_vprintf_altfmt_oct);
 
         case 'u':
         case 'i':
@@ -370,7 +370,7 @@
             if (fmt == 'X')
                 f_flags |= TH_PF_UPCASE;
 
-            return th_vprintf_put_int(ctx, vputch, ap, 16, f_flags, f_width, f_prec, TRUE, th_vprintf_altfmt_hex);
+            return th_vprintf_put_int(ctx, vputch, ap, 16, f_flags, f_width, f_prec, true, th_vprintf_altfmt_hex);
 
         case 'p':
             // Check for invalid flags
@@ -384,7 +384,7 @@
 #endif
             f_flags |= TH_PF_ALT | TH_PF_POINTER;
 
-            return th_vprintf_put_int(ctx, vputch, ap, 16, f_flags, f_width, f_prec, TRUE, th_vprintf_altfmt_hex);
+            return th_vprintf_put_int(ctx, vputch, ap, 16, f_flags, f_width, f_prec, true, th_vprintf_altfmt_hex);
 
 #ifdef TH_WIP_FLOAT_SUPPORT
         case 'f':
@@ -418,7 +418,7 @@
         else
         {
             int f_width = -1, f_prec = -1, f_flags = 0;
-            BOOL end = FALSE;
+            bool end = false;
 
             fmt++;
 
@@ -452,7 +452,7 @@
                         break;
 
                     default:
-                        end = TRUE;
+                        end = true;
                         break;
                 }
                 if (!end) fmt++;