This is a minor cleanup, as quotearg can assume
* modules/quotearg (Depends-on): Add limits-h.
* lib/quotearg.c (SIZE_MAX): Remove; <stdint.h> defines this now.
(INT_BITS): Remove.  All uses replaced by UINT_WIDTH,
which <limits.h> defines.
---
 ChangeLog        |  9 +++++++++
 lib/quotearg.c   | 14 ++++----------
 modules/quotearg |  1 +
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d7b55eb615..30ddcbdbf1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-05-31  Paul Eggert  <[email protected]>
+
+       quotearg: remove SIZE_MAX, INT_BITS
+       This is a minor cleanup, as quotearg can assume
+       * modules/quotearg (Depends-on): Add limits-h.
+       * lib/quotearg.c (SIZE_MAX): Remove; <stdint.h> defines this now.
+       (INT_BITS): Remove.  All uses replaced by UINT_WIDTH,
+       which <limits.h> defines.
+
 2026-05-30  Paul Eggert  <[email protected]>
 
        free-posix: remove stray wchar-h dependency
diff --git a/lib/quotearg.c b/lib/quotearg.c
index d0a516a60d..259af57dc1 100644
--- a/lib/quotearg.c
+++ b/lib/quotearg.c
@@ -73,12 +73,6 @@
 #define _(msgid) dgettext (GNULIB_TEXT_DOMAIN, msgid)
 #define N_(msgid) msgid
 
-#ifndef SIZE_MAX
-# define SIZE_MAX ((size_t) -1)
-#endif
-
-#define INT_BITS (sizeof (int) * CHAR_BIT)
-
 struct quoting_options
 {
   /* Basic quoting style.  */
@@ -89,7 +83,7 @@ struct quoting_options
 
   /* Quote the characters indicated by this bit vector even if the
      quoting style would not normally require them to be quoted.  */
-  unsigned int quote_these_too[(UCHAR_MAX / INT_BITS) + 1];
+  unsigned int quote_these_too[(UCHAR_MAX / UINT_WIDTH) + 1];
 
   /* The left quote for custom_quoting_style.  */
   char const *left_quote;
@@ -170,8 +164,8 @@ set_char_quoting (struct quoting_options *o, char c, int i)
 {
   unsigned char uc = c;
   unsigned int *p =
-    (o ? o : &default_quoting_options)->quote_these_too + uc / INT_BITS;
-  int shift = uc % INT_BITS;
+    (o ? o : &default_quoting_options)->quote_these_too + uc / UINT_WIDTH;
+  int shift = uc % UINT_WIDTH;
   unsigned int r = (*p >> shift) & 1;
   *p ^= ((i & 1U) ^ r) << shift;
   return r;
@@ -728,7 +722,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
       if (! (((backslash_escapes && quoting_style != 
shell_always_quoting_style)
               || elide_outer_quotes)
              && quote_these_too
-             && quote_these_too[c / INT_BITS] >> (c % INT_BITS) & 1)
+             && quote_these_too[c / UINT_WIDTH] >> (c % UINT_WIDTH) & 1)
           && !is_right_quote)
         goto store_c;
 
diff --git a/modules/quotearg b/modules/quotearg
index 17a7c1314c..f08dc9bec0 100644
--- a/modules/quotearg
+++ b/modules/quotearg
@@ -13,6 +13,7 @@ c32isprint
 extensions
 gettext-h
 gnulib-i18n
+limits-h
 mbszero
 mbrtoc32
 mbsinit
-- 
2.53.0


Reply via email to