]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Use countof, part 3.
authorBruno Haible <bruno@clisp.org>
Tue, 12 May 2026 00:16:25 +0000 (02:16 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 12 May 2026 00:16:25 +0000 (02:16 +0200)
* m4/more-warnings.m4 (gt_MORE_WARNINGS): Update comment.
* gettext-tools/src/cldr-plural-exp.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(cldr_plural_rule_list_print): Use countof instead of SIZEOF.
* gettext-tools/src/format-kde-kuit.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(is_reference): Use countof instead of SIZEOF.
* gettext-tools/src/its.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(_its_is_valid_simple_gen_xml, is_valid_xhtml_element, is_valid_html_element):
Use countof instead of SIZEOF.
* gettext-tools/src/msginit.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(catalogname_for_locale, plural_forms, fill_header): Use countof instead of
SIZEOF.
* gettext-tools/src/msgl-check.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(check_header_entry): Use countof instead of SIZEOF.
* gettext-tools/src/msgl-header.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(msgdomain_list_set_header_field): Use countof instead of SIZEOF.
* gettext-tools/src/open-catalog.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(try_open_catalog_file): Use countof instead of SIZEOF.
* gettext-tools/src/po-charset.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(po_charset_canonicalize, po_is_charset_weird, po_is_charset_weird_cjk): Use
countof instead of SIZEOF.
* gettext-tools/src/write-mo.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(write_table): Use countof instead of SIZEOF.
* gettext-tools/src/x-awk.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(phase3_unget): Use countof instead of SIZEOF.
* gettext-tools/src/x-c.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(phase1_ungetc, phase2_ungetc, phase3_ungetc, phase5_unget, phase6_unget,
x_c_unlex): Use countof instead of SIZEOF.
* gettext-tools/src/x-csharp.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(phase1_ungetc, phase2_ungetc, phase3_ungetc, phase5_ungetc, phase6_unget,
phase7_unget): Use countof instead of SIZEOF.
* gettext-tools/src/x-java.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(phase1_ungetc, phase2_ungetc, phase3_ungetc, phase5_unget, phase6_unget): Use
countof instead of SIZEOF.
* gettext-tools/src/x-javascript.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(phase1_ungetc, phase2_ungetc, phase5_scan_xml_markup, phase5_unget): Use
countof instead of SIZEOF.
* gettext-tools/src/x-lua.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(phase1_ungetc, phase3_unget, phase4_unget): Use countof instead of SIZEOF.
* gettext-tools/src/x-modula2.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(phase2_ungetc, phase3_unget, phase4_unget): Use countof instead of SIZEOF.
* gettext-tools/src/x-php.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(phase1_ungetc, phase2_ungetc, phase3_ungetc, phase4_unget): Use countof instead
of SIZEOF.
* gettext-tools/src/x-python.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(phase1_ungetc, phase2_ungetc, phase5_unget): Use countof instead of SIZEOF.
* gettext-tools/src/x-scheme.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(phase1_ungetc, read_object): Use countof instead of SIZEOF.
* gettext-tools/src/x-sh.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(phase1_ungetc, phase2_ungetc): Use countof instead of SIZEOF.
* gettext-tools/src/x-smalltalk.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(phase2_unget, phase3_unget, phase4_unget): Use countof instead of SIZEOF.
* gettext-tools/src/x-tcl.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(phase1_ungetc, phase2_ungetc): Use countof instead of SIZEOF.
* gettext-tools/src/x-vala.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(phase1_ungetc, phase3_unget, phase4_unget): Use countof instead of SIZEOF.
* gettext-tools/src/x-ycp.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(phase2_ungetc, phase5_unget, phase8_unget): Use countof instead of SIZEOF.
* gettext-tools/src/xg-check.c: Include <stdcountof.h>
(SIZEOF): Remove macro.
(string_has_url): Use countof instead of SIZEOF.
* gettext-tools/src/xgettext.c (SIZEOF): Remove macro.

27 files changed:
gettext-tools/src/cldr-plural-exp.c
gettext-tools/src/format-kde-kuit.c
gettext-tools/src/its.c
gettext-tools/src/msginit.c
gettext-tools/src/msgl-check.c
gettext-tools/src/msgl-header.c
gettext-tools/src/open-catalog.c
gettext-tools/src/po-charset.c
gettext-tools/src/write-mo.c
gettext-tools/src/x-awk.c
gettext-tools/src/x-c.c
gettext-tools/src/x-csharp.c
gettext-tools/src/x-java.c
gettext-tools/src/x-javascript.c
gettext-tools/src/x-lua.c
gettext-tools/src/x-modula2.c
gettext-tools/src/x-php.c
gettext-tools/src/x-python.c
gettext-tools/src/x-scheme.c
gettext-tools/src/x-sh.c
gettext-tools/src/x-smalltalk.c
gettext-tools/src/x-tcl.c
gettext-tools/src/x-vala.c
gettext-tools/src/x-ycp.c
gettext-tools/src/xg-check.c
gettext-tools/src/xgettext.c
m4/more-warnings.m4

index 3ac3046f1cf1ac77aa74ca526b872ea1da5aa950..961d2ee909cb0b25aeafeec9276632e239e46420 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <config.h>
 
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -551,8 +552,6 @@ static print_condition_function_ty print_condition_functions[] =
     print_condition_greater
   };
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 void
 cldr_plural_rule_list_print (struct cldr_plural_rule_list_ty *rules, FILE *fp)
 {
@@ -641,7 +640,7 @@ cldr_plural_rule_list_print (struct cldr_plural_rule_list_ty *rules, FILE *fp)
           break;
 
       struct cldr_plural_condition_ty *condition = rules->items[i]->condition;
-      for (size_t j = 0; j < SIZEOF (print_condition_functions); j++)
+      for (size_t j = 0; j < countof (print_condition_functions); j++)
         if (print_condition_functions[j] (condition, fp))
           return;
     }
index b3980244bb915616565a372104757a94beea24fa..d012dcf711eee1ea304a967f8b0eb75d0b52076f 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <assert.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdlib.h>
 
 #include "format.h"
@@ -48,8 +49,6 @@
 
 #define _(str) gettext (str)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* KUIT (KDE User Interface Text) is an XML-like markup which augments
    translatable strings with semantic information:
@@ -153,7 +152,7 @@ is_reference (const char *input)
       /* EntityRef */
       {
         bool isNameStartChar = false;
-        for (int i = 0; i < SIZEOF (name_chars1); i++)
+        for (int i = 0; i < countof (name_chars1); i++)
           if (name_chars1[i].start <= uc && uc <= name_chars1[i].end)
             {
               isNameStartChar = true;
@@ -169,14 +168,14 @@ is_reference (const char *input)
           str += u8_mbtouc (&uc, (const unsigned char *) str, str_limit - str);
 
           bool isNameChar = false;
-          for (int i = 0; i < SIZEOF (name_chars1); i++)
+          for (int i = 0; i < countof (name_chars1); i++)
             if (name_chars1[i].start <= uc && uc <= name_chars1[i].end)
               {
                 isNameChar = true;
                 break;
               }
           if (!isNameChar)
-            for (int i = 0; i < SIZEOF (name_chars2); i++)
+            for (int i = 0; i < countof (name_chars2); i++)
               if (name_chars2[i].start <= uc && uc <= name_chars2[i].end)
                 {
                   isNameChar = true;
index bbd8c809d1a21a6030e8ba37352260783dd883e8..24481a38633a55ea017abcaa4a2d236a51c06f9c 100644 (file)
@@ -25,6 +25,7 @@
 #include <errno.h>
 #include <setjmp.h>
 #include <stdarg.h>
+#include <stdcountof.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
@@ -53,8 +54,6 @@
 
 #define _(str) gettext (str)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* The Internationalization Tag Set (ITS) 2.0 standard is available at:
    https://www.w3.org/TR/its20/
@@ -2257,7 +2256,7 @@ _its_is_valid_simple_gen_xml (const char *contents,
   /* Stack of open elements.  */
   string_desc_t open_elements[100];
   size_t open_elements_count = 0;
-  const size_t open_elements_max = SIZEOF (open_elements);
+  const size_t open_elements_max = countof (open_elements);
 
   const char *p = contents;
   const char *curr_text_segment_start = p;
@@ -2519,7 +2518,7 @@ _its_is_valid_simple_gen_xml (const char *contents,
                   if (set_doc_encoding_utf8 (add_to_node->doc))
                     {
                       uint8_t buf[6];
-                      int nbytes = u8_uctomb (buf, ucs, SIZEOF (buf));
+                      int nbytes = u8_uctomb (buf, ucs, countof (buf));
                       if (nbytes <= 0)
                         abort ();
                       xmlNodeSetContentLen (text_node, BAD_CAST buf, nbytes);
@@ -2640,7 +2639,7 @@ is_valid_xhtml_element (string_desc_t tag)
     };
   /* Use binary search.  */
   size_t lo = 0;
-  size_t hi = SIZEOF (allowed);
+  size_t hi = countof (allowed);
   while (lo < hi)
     {
       /* Invariant:
@@ -2738,7 +2737,7 @@ is_valid_html_element (string_desc_t tag)
     };
   /* Use binary search.  */
   size_t lo = 0;
-  size_t hi = SIZEOF (allowed);
+  size_t hi = countof (allowed);
   while (lo < hi)
     {
       /* Invariant:
index 78c88e671ff510c311c42013b6d09cd3e8d1c21c..9a572b4b87fe8f47c4d949086f63a9440ff92586 100644 (file)
@@ -25,6 +25,7 @@
 #include <fcntl.h>
 #include <limits.h>
 #include <locale.h>
+#include <stdcountof.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -95,8 +96,6 @@
 # define F_OK 0
 #endif
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 extern const char * _nl_expand_alias (const char *name);
 
 /* Locale name.  */
@@ -758,7 +757,7 @@ catalogname_for_locale (const char *locale)
   }
 
   /* If the territory is the language's principal territory, drop it.  */
-  for (size_t i = 0; i < SIZEOF (locales_with_principal_territory); i++)
+  for (size_t i = 0; i < countof (locales_with_principal_territory); i++)
     if (streq (locale, locales_with_principal_territory[i]))
       {
         const char *language_end = strchr (locale, '_');
@@ -1390,7 +1389,7 @@ plural_forms ()
         dirs[0] = "common";
         dirs[1] = "supplemental";
         dirs[2] = "plurals.xml";
-        for (size_t i = 0; i < SIZEOF (dirs); i++)
+        for (size_t i = 0; i < countof (dirs); i++)
           {
             char *dir = xconcatenated_filename (last_dir, dirs[i], NULL);
             free (last_dir);
@@ -1791,13 +1790,13 @@ fill_header (msgdomain_list_ty *mdlp, bool fresh)
   if (fresh)
     {
       fields = fresh_fields;
-      nfields = SIZEOF (fresh_fields);
+      nfields = countof (fresh_fields);
       field_last_translator = FRESH_FIELDS_LAST_TRANSLATOR;
     }
   else
     {
       fields = update_fields;
-      nfields = SIZEOF (update_fields);
+      nfields = countof (update_fields);
       field_last_translator = UPDATE_FIELDS_LAST_TRANSLATOR;
     }
 
@@ -1873,7 +1872,7 @@ fill_header (msgdomain_list_ty *mdlp, bool fresh)
                              (time (&now), (localtime (&now))->tm_year + 1900));
               }
 
-              subst_string_list (header_mp->comment, SIZEOF (subst), subst);
+              subst_string_list (header_mp->comment, countof (subst), subst);
             }
 
           /* Finally remove the fuzzy attribute.  */
index 72bbda54ab2fa6e1d5923724def9492c89fd1bc5..196a04aba8d2a4820d2fc7787f12c8f6c1416861 100644 (file)
@@ -22,6 +22,7 @@
 #include "msgl-check.h"
 
 #include <limits.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -41,8 +42,6 @@
 
 #define _(str) gettext (str)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* Evaluates the plural formula for min <= n <= max
    and returns the estimated number of times the value j was assumed.  */
@@ -723,7 +722,7 @@ check_header_entry (const message_ty *mp, const char *msgstr_string,
     "text/plain; charset=CHARSET", "ENCODING",
     ""
   };
-  const size_t nfields = SIZEOF (required_fields);
+  const size_t nfields = countof (required_fields);
   /* FIXME: We could check if a required header field is missing and
      report it as error.  However, it's could be too rigorous and
      break backward compatibility.  */
index 3e9241dee31c46cab9f0f8cbca11f859796331d1..8c024bb47bd507491ca54125cb0c3b354a4eb9c0 100644 (file)
 /* Specification.  */
 #include "msgl-header.h"
 
+#include <stdcountof.h>
 #include <string.h>
 
 #include "xalloc.h"
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 void
 header_set_charset (message_ty *header_mp, const char *charsetstr,
@@ -80,7 +79,7 @@ msgdomain_list_set_header_field (msgdomain_list_ty *mdlp,
 
   /* Search the field in known_fields[].  */
   int field_index = -1;
-  for (size_t k = 0; k < SIZEOF (known_fields); k++)
+  for (size_t k = 0; k < countof (known_fields); k++)
     if (streq (known_fields[k].name, field))
       {
         field_index = k;
@@ -149,11 +148,11 @@ msgdomain_list_set_header_field (msgdomain_list_ty *mdlp,
                     /* Test whether h starts with a field name whose index is
                        > field_index.  */
                     size_t k;
-                    for (k = field_index + 1; k < SIZEOF (known_fields); k++)
+                    for (k = field_index + 1; k < countof (known_fields); k++)
                       if (strncmp (h, known_fields[k].name, known_fields[k].len)
                           == 0)
                         break;
-                    if (k < SIZEOF (known_fields))
+                    if (k < countof (known_fields))
                       break;
                     h = strchr (h, '\n');
                     if (h == NULL)
index d6f114f53b7c7f6bf7fcd18a3c7bc790d5fcd035..59b89193ba5c0a27f589bfb4f553c73d9006519c 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <errno.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -37,9 +38,6 @@
 
 #define _(str) gettext (str)
 
-/* This macro is used to determine the number of elements in an array.  */
-#define SIZEOF(a) (sizeof(a)/sizeof(a[0]))
-
 static FILE *
 try_open_catalog_file (const char *input_name, char **real_file_name_p)
 {
@@ -59,7 +57,7 @@ try_open_catalog_file (const char *input_name, char **real_file_name_p)
          specified, the current directory is used.  */
       const char *dir;
       for (int j = 0; (dir = dir_list_nth (j)) != NULL; ++j)
-        for (size_t k = 0; k < SIZEOF (extension); ++k)
+        for (size_t k = 0; k < countof (extension); ++k)
           {
             char *file_name =
               xconcatenated_filename (dir, input_name, extension[k]);
@@ -79,7 +77,7 @@ try_open_catalog_file (const char *input_name, char **real_file_name_p)
     {
       /* The name is not relative.  Try the various extensions, but ignore the
          directory search list.  */
-      for (size_t k = 0; k < SIZEOF (extension); ++k)
+      for (size_t k = 0; k < countof (extension); ++k)
         {
           char *file_name =
             xconcatenated_filename ("", input_name, extension[k]);
index b67f214a649ba29cd8c8be75af41d0283f432d0f..56bffcbd50d1ab1898b968021dfb3c1779e02223 100644 (file)
@@ -23,6 +23,7 @@
 /* Specification.  */
 #include "po-charset.h"
 
+#include <stdcountof.h>
 #include <string.h>
 
 #include "c-strcase.h"
@@ -30,8 +31,6 @@
 
 #define _(str) gettext (str)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 static const char ascii[] = "ASCII";
 
 /* The canonicalized encoding name for ASCII.  */
@@ -96,7 +95,7 @@ po_charset_canonicalize (const char *charset)
     utf8
   };
 
-  for (size_t i = 0; i < SIZEOF (standard_charsets); i++)
+  for (size_t i = 0; i < countof (standard_charsets); i++)
     if (c_strcasecmp (charset, standard_charsets[i]) == 0)
       return standard_charsets[i < 3 ? 0 : i < 27 ? ((i - 3) & ~1) + 3 : i];
   return NULL;
@@ -129,7 +128,7 @@ bool po_is_charset_weird (const char *canon_charset)
     "JOHAB"
   };
 
-  for (size_t i = 0; i < SIZEOF (weird_charsets); i++)
+  for (size_t i = 0; i < countof (weird_charsets); i++)
     if (streq (canon_charset, weird_charsets[i]))
       return true;
   return false;
@@ -151,7 +150,7 @@ bool po_is_charset_weird_cjk (const char *canon_charset)
     "JOHAB"             /* 0x{00..7F},    0x{84..F9}{31..FE} */
   };
 
-  for (size_t i = 0; i < SIZEOF (weird_cjk_charsets); i++)
+  for (size_t i = 0; i < countof (weird_cjk_charsets); i++)
     if (streq (canon_charset, weird_cjk_charsets[i]))
       return true;
   return false;
index c7bd294bfcf51b8da3ea13e9f97e5be1f8623115..bd3105796c41bfc2da7893b6066170d115d6f142 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <errno.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -68,8 +69,6 @@
 # endif /* GNU CC2  */
 #endif /* roundup  */
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* True if no conversion to UTF-8 is desired.  */
 bool no_convert_to_utf8;
@@ -573,7 +572,7 @@ write_table (FILE *output_file, message_list_ty *mlp)
 
       for (size_t ss = 0; ss < n_sysdep_strings; ss++)
         {
-          for (size_t u = 0; u < SIZEOF (useful_instantiation_rules); u++)
+          for (size_t u = 0; u < countof (useful_instantiation_rules); u++)
             {
               const struct sysdep_instantiation_rule *instrule =
                 &useful_instantiation_rules[u];
index a63682b6ea3d87f2d25c2c813b93979769030523..8c1fa389b1b9f582541345b045752e0d4699f28a 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <errno.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -45,8 +46,6 @@
 
 #define _(s) gettext(s)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* The awk syntax is defined in the gawk manual page and documentation.
    See also gawk/awkgram.y.  */
@@ -642,7 +641,7 @@ phase3_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase3_pushback_length == SIZEOF (phase3_pushback))
+      if (phase3_pushback_length == countof (phase3_pushback))
         abort ();
       phase3_pushback[phase3_pushback_length++] = *tp;
     }
index c0f4b5c9bc71a77c776e9b89545972b82192385e..39e9bb059b76b6d96a2eaa7872fac36b99f7db06 100644 (file)
@@ -24,6 +24,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -51,8 +52,6 @@
 
 #define _(s) gettext(s)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* The ANSI C standard defines several phases of translation:
 
@@ -689,7 +688,7 @@ phase1_ungetc (int c)
       FALLTHROUGH;
 
     default:
-      if (phase1_pushback_length == SIZEOF (phase1_pushback))
+      if (phase1_pushback_length == countof (phase1_pushback))
         abort ();
       phase1_pushback[phase1_pushback_length++] = c;
       break;
@@ -758,7 +757,7 @@ phase2_ungetc (int c)
 {
   if (c != EOF)
     {
-      if (phase2_pushback_length == SIZEOF (phase2_pushback))
+      if (phase2_pushback_length == countof (phase2_pushback))
         abort ();
       phase2_pushback[phase2_pushback_length++] = c;
     }
@@ -799,7 +798,7 @@ phase3_ungetc (int c)
 {
   if (c != EOF)
     {
-      if (phase3_pushback_length == SIZEOF (phase3_pushback))
+      if (phase3_pushback_length == countof (phase3_pushback))
         abort ();
       phase3_pushback[phase3_pushback_length++] = c;
     }
@@ -1807,7 +1806,7 @@ phase5_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase5_pushback_length == SIZEOF (phase5_pushback))
+      if (phase5_pushback_length == countof (phase5_pushback))
         abort ();
       phase5_pushback[phase5_pushback_length++] = *tp;
     }
@@ -1948,7 +1947,7 @@ phase6_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase6_pushback_length == SIZEOF (phase6_pushback))
+      if (phase6_pushback_length == countof (phase6_pushback))
         abort ();
       phase6_pushback[phase6_pushback_length++] = *tp;
     }
@@ -2250,7 +2249,7 @@ x_c_unlex (xgettext_token_ty *tp)
 {
   if (tp->type != xgettext_token_type_eof)
     {
-      if (phase9_pushback_length == SIZEOF (phase9_pushback))
+      if (phase9_pushback_length == countof (phase9_pushback))
         abort ();
       phase9_pushback[phase9_pushback_length++] = *tp;
     }
index 513e8f13448e8a928be20e60711a4d6d3720ff46..cab3977a27db0cff39d66d8284f587d7b2e02e24 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <errno.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -52,8 +53,6 @@
 
 #define _(s) gettext(s)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* The C# syntax is defined in ECMA-334, second edition.
    Strings with embedded expressions are defined in
@@ -177,7 +176,7 @@ phase1_ungetc (int c)
     {
       if (c == '\n')
         --line_number;
-      if (phase1_pushback_length == SIZEOF (phase1_pushback))
+      if (phase1_pushback_length == countof (phase1_pushback))
         abort ();
       phase1_pushback[phase1_pushback_length++] = c;
     }
@@ -431,7 +430,7 @@ phase2_ungetc (int c)
 {
   if (c != UEOF)
     {
-      if (phase2_pushback_length == SIZEOF (phase2_pushback))
+      if (phase2_pushback_length == countof (phase2_pushback))
         abort ();
       phase2_pushback[phase2_pushback_length++] = c;
     }
@@ -507,7 +506,7 @@ phase3_ungetc (int c)
     {
       if (c == UNL)
         --logical_line_number;
-      if (phase3_pushback_length == SIZEOF (phase3_pushback))
+      if (phase3_pushback_length == countof (phase3_pushback))
         abort ();
       phase3_pushback[phase3_pushback_length++] = c;
     }
@@ -1226,7 +1225,7 @@ phase5_ungetc (int c)
 {
   if (c != UEOF)
     {
-      if (phase5_pushback_length == SIZEOF (phase5_pushback))
+      if (phase5_pushback_length == countof (phase5_pushback))
         abort ();
       phase5_pushback[phase5_pushback_length++] = c;
     }
@@ -1771,7 +1770,7 @@ phase6_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase6_pushback_length == SIZEOF (phase6_pushback))
+      if (phase6_pushback_length == countof (phase6_pushback))
         abort ();
       phase6_pushback[phase6_pushback_length++] = *tp;
     }
@@ -1841,7 +1840,7 @@ phase7_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase7_pushback_length == SIZEOF (phase7_pushback))
+      if (phase7_pushback_length == countof (phase7_pushback))
         abort ();
       phase7_pushback[phase7_pushback_length++] = *tp;
     }
index d11cb44c0411ad90c2fbc457266410b6b06c9a0b..cacdc9f6d59a180d3be7d547b3b6b52bcd77acaf 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <errno.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -51,8 +52,6 @@
 
 #define _(s) gettext(s)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* The Java syntax is defined in the
      Java Language Specification
@@ -218,14 +217,14 @@ phase1_ungetc (int c)
             phase1_pushback[phase1_pushback_length - 1]++;
           else
             {
-              if (phase1_pushback_length == SIZEOF (phase1_pushback))
+              if (phase1_pushback_length == countof (phase1_pushback))
                 abort ();
               phase1_pushback[phase1_pushback_length++] = MULTIPLE_U (1);
             }
         }
       else
         {
-          if (phase1_pushback_length == SIZEOF (phase1_pushback))
+          if (phase1_pushback_length == countof (phase1_pushback))
             abort ();
           phase1_pushback[phase1_pushback_length++] = c;
         }
@@ -323,7 +322,7 @@ phase2_ungetc (int c)
 {
   if (c != P2_EOF)
     {
-      if (phase2_pushback_length == SIZEOF (phase2_pushback))
+      if (phase2_pushback_length == countof (phase2_pushback))
         abort ();
       phase2_pushback[phase2_pushback_length++] = c;
     }
@@ -392,7 +391,7 @@ phase3_ungetc (int c)
     {
       if (c == '\n')
         --line_number;
-      if (phase3_pushback_length == SIZEOF (phase3_pushback))
+      if (phase3_pushback_length == countof (phase3_pushback))
         abort ();
       phase3_pushback[phase3_pushback_length++] = c;
     }
@@ -1525,7 +1524,7 @@ phase5_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase5_pushback_length == SIZEOF (phase5_pushback))
+      if (phase5_pushback_length == countof (phase5_pushback))
         abort ();
       phase5_pushback[phase5_pushback_length++] = *tp;
     }
@@ -1600,7 +1599,7 @@ phase6_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase6_pushback_length == SIZEOF (phase6_pushback))
+      if (phase6_pushback_length == countof (phase6_pushback))
         abort ();
       phase6_pushback[phase6_pushback_length++] = *tp;
     }
index 7c47262904a3198959925533f176c667e19b3ac5..9e4e1247943520bb358fee80691c4721411a6a8c 100644 (file)
@@ -24,6 +24,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -57,8 +58,6 @@
 
 #define _(s) gettext(s)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 /* The JavaScript aka ECMA-Script syntax is defined in ECMA-262
    specification:
    <https://www.ecma-international.org/publications/standards/Ecma-262.htm>
@@ -292,7 +291,7 @@ phase1_ungetc (int c)
       if (c == '\n')
         --line_number;
 
-      if (phase1_pushback_length == SIZEOF (phase1_pushback))
+      if (phase1_pushback_length == countof (phase1_pushback))
         abort ();
       phase1_pushback[phase1_pushback_length++] = c;
     }
@@ -541,7 +540,7 @@ phase2_ungetc (int c)
 {
   if (c != UEOF)
     {
-      if (phase2_pushback_length == SIZEOF (phase2_pushback))
+      if (phase2_pushback_length == countof (phase2_pushback))
         abort ();
       phase2_pushback[phase2_pushback_length++] = c;
     }
@@ -1211,7 +1210,7 @@ phase5_scan_xml_markup (token_ty *tp)
       { "?", "?" }
     };
 
-  for (int i = 0; i < SIZEOF (markers); i++)
+  for (int i = 0; i < countof (markers); i++)
     {
       const char *start = markers[i].start;
       const char *end = markers[i].end;
@@ -1220,7 +1219,7 @@ phase5_scan_xml_markup (token_ty *tp)
       /* Look for a start marker.  */
       for (j = 0; start[j] != '\0'; j++)
         {
-          assert (phase2_pushback_length + j < SIZEOF (phase2_pushback));
+          assert (phase2_pushback_length + j < countof (phase2_pushback));
           int c = phase2_getc ();
           if (c == UEOF)
             goto eof;
@@ -1243,7 +1242,7 @@ phase5_scan_xml_markup (token_ty *tp)
           {
             for (j = 0; end[j] != '\0'; j++)
               {
-                assert (phase2_pushback_length + 1 < SIZEOF (phase2_pushback));
+                assert (phase2_pushback_length + 1 < countof (phase2_pushback));
                 int c = phase2_getc ();
                 if (c == UEOF)
                   goto eof;
@@ -1702,7 +1701,7 @@ phase5_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase5_pushback_length == SIZEOF (phase5_pushback))
+      if (phase5_pushback_length == countof (phase5_pushback))
         abort ();
       phase5_pushback[phase5_pushback_length++] = *tp;
     }
index 61b54f681dbcad6b4d00ea384e2d8f5cf6cc49a9..166d86f4b5bafe0295c97ce7c9b7ab590379294f 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <errno.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -47,8 +48,6 @@
 
 #define _(s) gettext(s)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 /* The Lua syntax is defined in the Lua manual sections 3.1 and 9,
    which can be found at
    https://www.lua.org/manual/5.2/manual.html#3.1
@@ -192,7 +191,7 @@ phase1_ungetc (int c)
       if (c == '\n')
         --line_number;
 
-      if (phase1_pushback_length == SIZEOF (phase1_pushback))
+      if (phase1_pushback_length == countof (phase1_pushback))
         abort ();
       phase1_pushback[phase1_pushback_length++] = c;
     }
@@ -435,7 +434,7 @@ phase3_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase3_pushback_length == SIZEOF (phase3_pushback))
+      if (phase3_pushback_length == countof (phase3_pushback))
         abort ();
       phase3_pushback[phase3_pushback_length++] = *tp;
     }
@@ -858,7 +857,7 @@ phase4_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase4_pushback_length == SIZEOF (phase4_pushback))
+      if (phase4_pushback_length == countof (phase4_pushback))
         abort ();
       phase4_pushback[phase4_pushback_length++] = *tp;
     }
index 02b3e12d806f3d2d12bfb8f1808e074870a16a81..0cb96ac2be1163b057651b2036d713d32181d4ce 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <errno.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -44,8 +45,6 @@
 
 #define _(s) gettext(s)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* The Modula-2 syntax is defined in the book
    "The Programming Language Modula-2" by Niklaus Wirth
@@ -275,7 +274,7 @@ phase2_ungetc (int c)
 {
   if (c != EOF)
     {
-      if (phase2_pushback_length == SIZEOF (phase2_pushback))
+      if (phase2_pushback_length == countof (phase2_pushback))
         abort ();
       phase2_pushback[phase2_pushback_length++] = c;
     }
@@ -495,7 +494,7 @@ phase3_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase3_pushback_length == SIZEOF (phase3_pushback))
+      if (phase3_pushback_length == countof (phase3_pushback))
         abort ();
       phase3_pushback[phase3_pushback_length++] = *tp;
     }
@@ -569,7 +568,7 @@ phase4_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase4_pushback_length == SIZEOF (phase4_pushback))
+      if (phase4_pushback_length == countof (phase4_pushback))
         abort ();
       phase4_pushback[phase4_pushback_length++] = *tp;
     }
index 497544afdd06cb452e3bc485c5e54b968ae60ce7..0220b16bfae996b6f3238eb4da0af06920c0b91d 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <errno.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -46,8 +47,6 @@
 
 #define _(s) gettext(s)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* The PHP syntax is defined in phpdoc/manual/langref.html.
    See also php-8.1.0/Zend/zend_language_scanner.l
@@ -286,7 +285,7 @@ phase1_ungetc (struct php_extractor *xp, int c)
       if (c == '\n')
         --(xp->line_number);
 
-      if (xp->phase1_pushback_length == SIZEOF (xp->phase1_pushback))
+      if (xp->phase1_pushback_length == countof (xp->phase1_pushback))
         abort ();
       xp->phase1_pushback[xp->phase1_pushback_length++] = c;
     }
@@ -610,7 +609,7 @@ phase2_ungetc (struct php_extractor *xp, int c)
 {
   if (c != EOF)
     {
-      if (xp->phase2_pushback_length == SIZEOF (xp->phase2_pushback))
+      if (xp->phase2_pushback_length == countof (xp->phase2_pushback))
         abort ();
       xp->phase2_pushback[xp->phase2_pushback_length++] = c;
     }
@@ -793,7 +792,7 @@ phase3_ungetc (struct php_extractor *xp, int c)
 {
   if (c != EOF)
     {
-      if (xp->phase3_pushback_length == SIZEOF (xp->phase3_pushback))
+      if (xp->phase3_pushback_length == countof (xp->phase3_pushback))
         abort ();
       xp->phase3_pushback[xp->phase3_pushback_length++] = c;
     }
@@ -1548,7 +1547,7 @@ phase4_unget (struct php_extractor *xp, token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (xp->phase4_pushback_length == SIZEOF (xp->phase4_pushback))
+      if (xp->phase4_pushback_length == countof (xp->phase4_pushback))
         abort ();
       xp->phase4_pushback[xp->phase4_pushback_length++] = *tp;
     }
index 92615209d767b145aa7f0fd835b983e5340a0024..72baf97c74b0f8c7bf880a545c3324cdc3845066 100644 (file)
@@ -24,6 +24,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -61,8 +62,6 @@
 #undef max /* clean up after MSVC's <stdlib.h> */
 #define max(a,b) ((a) > (b) ? (a) : (b))
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* The Python syntax is defined in the Python Reference Manual
    /usr/share/doc/packages/python/html/ref/index.html.
@@ -236,7 +235,7 @@ phase1_ungetc (int c)
       if (c == '\n')
         --line_number;
 
-      if (phase1_pushback_length == SIZEOF (phase1_pushback))
+      if (phase1_pushback_length == countof (phase1_pushback))
         abort ();
       phase1_pushback[phase1_pushback_length++] = c;
     }
@@ -520,7 +519,7 @@ phase2_ungetc (int c)
 {
   if (c != UEOF)
     {
-      if (phase2_pushback_length == SIZEOF (phase2_pushback))
+      if (phase2_pushback_length == countof (phase2_pushback))
         abort ();
       phase2_pushback[phase2_pushback_length++] = c;
     }
@@ -1603,7 +1602,7 @@ phase5_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase5_pushback_length == SIZEOF (phase5_pushback))
+      if (phase5_pushback_length == countof (phase5_pushback))
         abort ();
       phase5_pushback[phase5_pushback_length++] = *tp;
     }
index 6b7a50b9f3e335143ecd8b803c83e4fffb0ae7c7..a104fc464af94927ffd56819a048fa618b51bc3f 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <errno.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -46,8 +47,6 @@
 
 #define _(s) gettext(s)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* The Scheme syntax is described in R5RS and following standards:
      - R5RS: https://conservatory.scheme.org/schemers/Documents/Standards/R5RS/HTML/
@@ -232,7 +231,7 @@ phase1_ungetc (int c)
       if (c == '\n')
         --line_number;
 
-      if (phase1_pushback_length == SIZEOF (phase1_pushback))
+      if (phase1_pushback_length == countof (phase1_pushback))
         abort ();
       phase1_pushback[phase1_pushback_length++] = c;
     }
@@ -1408,7 +1407,7 @@ read_object (struct object *op, flag_region_ty *outer_region)
                       "curly-infix",
                       "curly-infix-and-bracket-lists"
                     };
-                  int num_directives = SIZEOF (directives);
+                  int num_directives = countof (directives);
                   enum { max_directive_len = 29 };
                   bool seen_directive = false;
                   for (int d = 0; d < num_directives; d++)
index 80c22a13095168225ebee2d29e8b01ac80feea5c..d20de84a19855bb83c074066fc9a3d36fba63de8 100644 (file)
@@ -24,6 +24,7 @@
 #include <errno.h>
 #include <limits.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -46,8 +47,6 @@
 
 #define _(s) gettext(s)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* The sh syntax is defined in POSIX:2001, see
      http://www.opengroup.org/onlinepubs/007904975/utilities/xcu_chap02.html
@@ -233,7 +232,7 @@ phase1_ungetc (int c)
       FALLTHROUGH;
 
     default:
-      if (phase1_pushback_length == SIZEOF (phase1_pushback))
+      if (phase1_pushback_length == countof (phase1_pushback))
         abort ();
       phase1_pushback[phase1_pushback_length++] = c;
       break;
@@ -643,7 +642,7 @@ phase2_ungetc (int c)
       FALLTHROUGH;
 
     default:
-      if (phase2_pushback_length == SIZEOF (phase2_pushback))
+      if (phase2_pushback_length == countof (phase2_pushback))
         abort ();
       phase2_pushback[phase2_pushback_length++] = c;
       break;
index 4f5520060d79326bb62bb5a486bae458e4a2b5a7..352175f14f80d6a9de7cce703d1389cfc90d1605 100644 (file)
@@ -22,6 +22,7 @@
 #include "x-smalltalk.h"
 
 #include <errno.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -39,8 +40,6 @@
 
 #define _(s) gettext(s)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* The relevant parts of the Smalltalk syntax are:
 
@@ -428,7 +427,7 @@ phase2_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase2_pushback_length == SIZEOF (phase2_pushback))
+      if (phase2_pushback_length == countof (phase2_pushback))
         abort ();
       phase2_pushback[phase2_pushback_length++] = *tp;
     }
@@ -475,7 +474,7 @@ phase3_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase3_pushback_length == SIZEOF (phase3_pushback))
+      if (phase3_pushback_length == countof (phase3_pushback))
         abort ();
       phase3_pushback[phase3_pushback_length++] = *tp;
     }
@@ -550,7 +549,7 @@ phase4_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase4_pushback_length == SIZEOF (phase4_pushback))
+      if (phase4_pushback_length == countof (phase4_pushback))
         abort ();
       phase4_pushback[phase4_pushback_length++] = *tp;
     }
index 4e3be4c9e83d5baeb64bdf839faea195d81c5b63..e566978305c466c4c9c1e60139a2fef8f99acfba 100644 (file)
@@ -25,6 +25,7 @@
 #include <errno.h>
 #include <limits.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -50,8 +51,6 @@
 
 #define _(s) gettext(s)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* The Tcl syntax is defined in the Tcl.n manual page, see
    https://www.tcl-lang.org/man/tcl8.6/TclCmd/Tcl.htm .
@@ -225,7 +224,7 @@ phase1_ungetc (int c)
       FALLTHROUGH;
 
     default:
-      if (phase1_pushback_length == SIZEOF (phase1_pushback))
+      if (phase1_pushback_length == countof (phase1_pushback))
         abort ();
       phase1_pushback[phase1_pushback_length++] = c;
       break;
@@ -311,7 +310,7 @@ phase2_ungetc (int c)
           ++brace_depth;
           break;
         }
-      if (phase2_pushback_length == SIZEOF (phase2_pushback))
+      if (phase2_pushback_length == countof (phase2_pushback))
         abort ();
       phase2_pushback[phase2_pushback_length++] = c;
     }
index b3905e39607b820ea688b009e5a92c5adede34ea..3dc9338aeb2e18f45209f901c443d510f3de62b5 100644 (file)
@@ -24,6 +24,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -51,8 +52,6 @@
 
 #define _(s) gettext(s)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 /* The Vala syntax is defined in the Vala Reference Manual
    https://gnome.pages.gitlab.gnome.org/vala/manual/index.html.
    See also vala/valascanner.vala.
@@ -244,7 +243,7 @@ phase1_ungetc (int c)
       if (c == '\n')
         --line_number;
 
-      if (phase1_pushback_length == SIZEOF (phase1_pushback))
+      if (phase1_pushback_length == countof (phase1_pushback))
         abort ();
       phase1_pushback[phase1_pushback_length++] = c;
     }
@@ -1232,7 +1231,7 @@ phase3_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase3_pushback_length == SIZEOF (phase3_pushback))
+      if (phase3_pushback_length == countof (phase3_pushback))
         abort ();
       phase3_pushback[phase3_pushback_length++] = *tp;
     }
@@ -1290,7 +1289,7 @@ phase4_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase4_pushback_length == SIZEOF (phase4_pushback))
+      if (phase4_pushback_length == countof (phase4_pushback))
         abort ();
       phase4_pushback[phase4_pushback_length++] = *tp;
     }
index 96a0cc0cf43916466a231a3a6c7a258a4fc8ef58..f916b7592158a3b1e1e9a977d8e4785db2e6510c 100644 (file)
@@ -24,6 +24,7 @@
 #include <errno.h>
 #include <limits.h>
 #include <stdbool.h>
+#include <stdcountof.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -43,8 +44,6 @@
 
 #define _(s) gettext(s)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* The YCP syntax is defined in libycp/doc/syntax.html.
    See also libycp/src/scanner.ll.
@@ -274,7 +273,7 @@ phase2_ungetc (int c)
 {
   if (c != EOF)
     {
-      if (phase2_pushback_length == SIZEOF (phase2_pushback))
+      if (phase2_pushback_length == countof (phase2_pushback))
         abort ();
       phase2_pushback[phase2_pushback_length++] = c;
     }
@@ -533,7 +532,7 @@ phase5_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase5_pushback_length == SIZEOF (phase5_pushback))
+      if (phase5_pushback_length == countof (phase5_pushback))
         abort ();
       phase5_pushback[phase5_pushback_length++] = *tp;
     }
@@ -581,7 +580,7 @@ phase8_unget (token_ty *tp)
 {
   if (tp->type != token_type_eof)
     {
-      if (phase8_pushback_length == SIZEOF (phase8_pushback))
+      if (phase8_pushback_length == countof (phase8_pushback))
         abort ();
       phase8_pushback[phase8_pushback_length++] = *tp;
     }
index 0da4203f2f4f0424a85a36852a1fed3c70f25d29..ba6a97f00a9d37c82ede3503f1aba738b3ee2456 100644 (file)
@@ -21,6 +21,7 @@
 /* Specification.  */
 #include "xg-check.h"
 
+#include <stdcountof.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -40,8 +41,6 @@
 
 #define _(str) gettext (str)
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-
 
 /* Function that implements a single syntax check.
    MP is a message.
@@ -372,7 +371,7 @@ string_has_url (const char *string)
     "irc://", "ircs://"
   };
 
-  for (size_t i = 0; i < SIZEOF (patterns); i++)
+  for (size_t i = 0; i < countof (patterns); i++)
     {
       const char *pattern = patterns[i];
       /* msgid and msgid_plural are typically entirely ASCII.  Therefore here
index b9aeec3c125fb47a1a089752d70af7aca3086fc3..02aea45fa32213b9694f2ca2c033a17bd4182c70 100644 (file)
 #include "x-appdata.h"
 
 
-#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-#define ENDOF(a) ((a) + SIZEOF(a))
+#define ENDOF(a) ((a) + countof (a))
 
 
 /* If true, add all comments immediately preceding one of the keywords. */
index f239a96d5d135a297ac391c2785c864f22862554..e0ba29b9ba1e34fee66bc13cadabdf43ec3db155 100644 (file)
@@ -1,5 +1,5 @@
 # more-warnings.m4
-# serial 6 (gettext-1.1)
+# serial 7 (gettext-1.1)
 dnl Copyright (C) 2023-2026 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
@@ -87,7 +87,7 @@ AS_HELP_STRING([[--disable-more-warnings]], [obey exactly the warning options sp
     dnl are worth eliminating; see below.
     nw="$nw -Wshadow"
     dnl Too many warnings. We often use signed types like 'int' or 'idx_t'
-    dnl for counter variables, yet SIZEOF(array) is an unsigned value.
+    dnl for counter variables, yet countof(array) is an unsigned value.
     nw="$nw -Wsign-compare"
     dnl This warning is based on older ISO C standards. It warns, in particular,
     dnl about function definitions that are valid in ISO C 23 (static and