diff th_string.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 4181d43f91f9
line wrap: on
line diff
--- a/th_string.c	Wed Dec 07 11:58:54 2022 +0200
+++ b/th_string.c	Wed Dec 07 12:14:39 2022 +0200
@@ -594,7 +594,7 @@
 int th_split_string_elems(const th_char_t *str, th_strelems_t *ctx, const th_char_t *sep)
 {
     size_t start = 0, end;
-    BOOL match = FALSE;
+    bool match = false;
 
     if (str == NULL || ctx == NULL || sep == NULL)
         return THERR_NULLPTR;
@@ -605,12 +605,12 @@
     do
     {
         // Split foremost str element out
-        match = FALSE;
+        match = false;
         for (end = start; str[end] != 0; end++)
         {
             if (th_strchr(sep, str[end]))
             {
-                match = TRUE;
+                match = true;
                 break;
             }
         }
@@ -786,7 +786,7 @@
 #include "th_strglob.c"
 
 
-BOOL th_get_hex_triplet(const th_char_t *str, unsigned int *value)
+bool th_get_hex_triplet(const th_char_t *str, unsigned int *value)
 {
     const th_char_t *p = str;
     int len;
@@ -812,22 +812,22 @@
             (*value) |= (*p - 'a') + 10;
         }
         else
-            return FALSE;
+            return false;
     }
 
     return (len >= 3 * 2 && len <= 4 * 2);
 }
 
 
-BOOL th_get_boolean(const th_char_t *str, BOOL *value)
+bool th_get_boolean(const th_char_t *str, bool *value)
 {
     if (!th_strcasecmp(str, "yes") ||
         !th_strcasecmp(str, "on") ||
         !th_strcasecmp(str, "true") ||
         !th_strcasecmp(str, "1"))
     {
-        *value = TRUE;
-        return TRUE;
+        *value = true;
+        return true;
     }
     else
     if (!th_strcasecmp(str, "no") ||
@@ -835,42 +835,42 @@
         !th_strcasecmp(str, "false") ||
         !th_strcasecmp(str, "0"))
     {
-        *value = FALSE;
-        return TRUE;
+        *value = false;
+        return true;
     }
     else
-        return FALSE;
+        return false;
 }
 
 
-BOOL th_get_int(const th_char_t *str, unsigned int *value, BOOL *neg)
+bool th_get_int(const th_char_t *str, unsigned int *value, bool *neg)
 {
     int ch;
-    BOOL hex = FALSE;
+    bool hex = false;
 
     // Is the value negative?
     if (*str == '-')
     {
         if (neg == NULL)
-            return FALSE;
+            return false;
 
-        *neg = TRUE;
+        *neg = true;
         str++;
     }
     else
     if (neg != NULL)
-        *neg = FALSE;
+        *neg = false;
 
     // Is it hexadecimal?
     if (*str == '$')
     {
-        hex = TRUE;
+        hex = true;
         str++;
     }
     else
     if (str[0] == '0' && str[1] == 'x')
     {
-        hex = TRUE;
+        hex = true;
         str += 2;
     }
 
@@ -898,7 +898,7 @@
                 *value |= ch - 'a' + 10;
             }
             else
-                return FALSE;
+                return false;
         }
     }
     else
@@ -911,8 +911,8 @@
                 *value += ch - '0';
             }
             else
-                return FALSE;
+                return false;
         }
     }
-    return TRUE;
+    return true;
 }