There still some code around that uses 'int' where modern C prefers to see
a 'bool'.


2026-09-13  Bruno Haible  <[email protected]>

        setlocale: Use bool.
        * lib/setlocale.c (setlocale_improved): Change type of local variable
        'warn' to bool.
        * modules/setlocale (Depends-on): Add bool.

diff --git a/lib/setlocale.c b/lib/setlocale.c
index f40b6295d4..5b65a42307 100644
--- a/lib/setlocale.c
+++ b/lib/setlocale.c
@@ -1503,7 +1503,7 @@ setlocale_improved (int category, const char *locale)
                        language or an existing locale with the same territory.
                        If we can't, print a warning, to limit user
                        expectations.  */
-                    int warn = 0;
+                    bool warn = false;
 
                     if (cat == LC_CTYPE)
                       warn = (setlocale_single (cat, "UTF-8") == NULL);
@@ -1551,7 +1551,7 @@ setlocale_improved (int category, const char *locale)
 
                                         if (last_try == NULL
                                             || setlocale_single (cat, 
last_try) == NULL)
-                                          warn = 1;
+                                          warn = true;
                                       }
                                   }
                               }
@@ -1566,7 +1566,7 @@ setlocale_improved (int category, const char *locale)
 
                         if (last_try == NULL
                             || setlocale_single (cat, last_try) == NULL)
-                          warn = 1;
+                          warn = true;
 #   endif
                       }
                     else
@@ -1590,7 +1590,7 @@ setlocale_improved (int category, const char *locale)
 
                         if (last_try == NULL
                             || setlocale_single (cat, last_try) == NULL)
-                          warn = 1;
+                          warn = true;
                       }
 
                     if (warn)
diff --git a/modules/setlocale b/modules/setlocale
index aff365ac95..e08a1fb3a3 100644
--- a/modules/setlocale
+++ b/modules/setlocale
@@ -8,6 +8,7 @@ m4/setlocale.m4
 Depends-on:
 locale-h
 stdcountof-h
+bool
 streq
 setlocale-fixes    [test $NEED_SETLOCALE_IMPROVED = 1]
 localename         [test $NEED_SETLOCALE_IMPROVED = 1]




Reply via email to