summaryrefslogtreecommitdiff
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2026-05-26 17:51:44 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2026-05-26 21:57:20 -0700
commit225876e97999664a075eb6f1489b4b4c8e515ded (patch)
tree87ef4401231a27883205d68c05b8abf76986436d /lib-src
parent834ff524f98024cbf30771df3849a5d9241ab2e2 (diff)
ARRAYELTS → countof
C2y will standardize countof as the macro that Emacs uses the name ARRAYELTS for. Switch to the standard name, which is supported by GCC 16+, by Clang 21, and by the Gnulib stdcountof-h module already in use for compilers that do not support countof. Also, use countof in a few places where we missed using ARRAYELTS. * admin/coccinelle/arrayelts.cocci: Suggest countof, not ARRAYELTS. * admin/merge-gnulib (GNULIB_MODULES): Add stdcountof-h, as it is now a direct rather than an indirect dependency. * exec/trace.c, src/lisp.h, src/sfnt.c: Include <stdcountof.h>. (ARRAYELTS): Remove. All uses replaced by countof. * lib-src/ebrowse.c, lib-src/etags.c, lib-src/make-docfile.c: * lib-src/seccomp-filter.c, lwlib/lwlib-Xaw.c: Prefer <stdcountof.h> and countof to doing things by hand.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/ebrowse.c4
-rw-r--r--lib-src/etags.c3
-rw-r--r--lib-src/make-docfile.c3
-rw-r--r--lib-src/seccomp-filter.c3
4 files changed, 9 insertions, 4 deletions
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c
index 3bb6bd88d79..93c0b52b950 100644
--- a/lib-src/ebrowse.c
+++ b/lib-src/ebrowse.c
@@ -19,6 +19,8 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
+
+#include <stdcountof.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -3612,7 +3614,7 @@ static _Noreturn void
usage (int error)
{
int i;
- for (i = 0; i < sizeof usage_message / sizeof *usage_message; i++)
+ for (i = 0; i < countof (usage_message); i++)
fputs (usage_message[i], stdout);
exit (error ? EXIT_FAILURE : EXIT_SUCCESS);
}
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 4114ba6b655..977484e4a67 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -110,6 +110,7 @@ University of California, as described above. */
#include <unistd.h>
#include <stdarg.h>
#include <stdckdint.h>
+#include <stdcountof.h>
#include <stdlib.h>
#include <string.h>
#include <sysstdio.h>
@@ -6693,7 +6694,7 @@ mercury_decl (char *s, size_t pos)
}
else
{
- for (int j = 0; j < sizeof (Mercury_decl_tags) / sizeof (char*); ++j)
+ for (int j = 0; j < countof (Mercury_decl_tags); ++j)
{
if (memstreq (decl_type, decl_type_length, Mercury_decl_tags[j]))
{
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index f6e321d876a..f13ade84244 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -37,6 +37,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include <stdarg.h>
+#include <stdcountof.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
@@ -651,7 +652,7 @@ compare_globals (const void *a, const void *b)
/* Common symbols in decreasing popularity order. */
static char const commonsym[][8]
= { "nil", "t", "unbound", "error", "lambda" };
- int ncommonsym = sizeof commonsym / sizeof *commonsym;
+ int ncommonsym = countof (commonsym);
int ai = ncommonsym, bi = ncommonsym;
for (int i = 0; i < ncommonsym; i++)
{
diff --git a/lib-src/seccomp-filter.c b/lib-src/seccomp-filter.c
index a8cdc6e06f9..f58afbf272d 100644
--- a/lib-src/seccomp-filter.c
+++ b/lib-src/seccomp-filter.c
@@ -39,6 +39,7 @@ variants of those files that can be used to sandbox Emacs before
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
+#include <stdcountof.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
@@ -119,7 +120,7 @@ set_attribute (enum scmp_filter_attr attr, uint32_t value)
do \
{ \
const struct scmp_arg_cmp arg_array[] = {__VA_ARGS__}; \
- enum { arg_cnt = sizeof arg_array / sizeof *arg_array }; \
+ enum { arg_cnt = countof (arg_array) }; \
int status = seccomp_rule_add_array (ctx, action, syscall, \
arg_cnt, arg_array); \
if (status < 0) \