2026-05-05 Paul Eggert <eggert@cs.ucla.edu>
+ localeinfo: use countof
+ * lib/localeinfo.c: Include stdcountof.h.
+ Simplify by using countof.
+ * modules/localeinfo (Depends-on): Add stdcountof-h.
+
localeinfo: new module
This is so regex can use localeinfo.[ch].
* modules/dfa (Files): Remove lib/localeinfo.c, lib/localeinfo.h.
#include <limits.h>
#include <locale.h>
+#include <stdcountof.h>
#include <stdlib.h>
#include <string.h>
#include <uchar.h>
0x03F5, 0x1E9B, 0x1FBE,
};
-/* Verify that the worst case fits. This is 1 for c32toupper, 1 for
+/* Verify that the worst multibyte case fits. This is 1 for c32toupper, 1 for
c32tolower, and 1 for each entry in LONESOME_LOWER. */
-verify (1 + 1 + sizeof lonesome_lower / sizeof *lonesome_lower
- <= CASE_FOLDED_BUFSIZE);
+verify (1 + 1 + countof (lonesome_lower) <= CASE_FOLDED_BUFSIZE);
/* Find the characters equal to C after case-folding, other than C
itself, and store them into FOLDED. Return the number of characters
folded[n++] = uc;
if (lc != uc && lc != c && c32toupper (lc) == uc)
folded[n++] = lc;
- for (int i = 0; i < sizeof lonesome_lower / sizeof *lonesome_lower; i++)
+ for (int i = 0; i < countof (lonesome_lower); i++)
{
wint_t li = lonesome_lower[i];
if (li != lc && li != uc && li != c && c32toupper (li) == uc)