From 1bbfe2727157d9e62af68d0ec89d558e5b5d179b Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@meta.com>
Date: Fri, 9 Jun 2023 10:15:30 -0700
Subject: [PATCH] maint.mk: sc_prohibit_xalloc_without_use: also match
 alloc_die
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* top/maint.mk (sc_prohibit_xalloc_without_use):
Adjust in-comment command's regexp so it also finds alloc_die,
whose declaration has a prefix of "_Noreturn" .
Also delete some now-obsolete commentary.
(_xa1): Regenerate the regexp using that command.
Reported by Pádraig Brady in
<https://lists.gnu.org/r/bug-gnulib/2023-06/msg00062.html>.
---
 ChangeLog    | 11 +++++++++++
 top/maint.mk | 17 ++++-------------
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 16853a30ab..2f4a7f1158 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-06-09  Jim Meyering  <meyering@meta.com>
+
+	maint.mk: sc_prohibit_xalloc_without_use: also match alloc_die
+	* top/maint.mk (sc_prohibit_xalloc_without_use):
+	Adjust in-comment command's regexp so it also finds alloc_die,
+	whose declaration has a prefix of "/*extern*/ _Noreturn".
+	Also delete some now-obsolete commentary.
+	(_xa1): Regenerate the regexp using that command.
+	Reported by Pádraig Brady in
+	<https://lists.gnu.org/r/bug-gnulib/2023-06/msg00062.html>.
+
 2023-06-09  Paul Eggert  <eggert@cs.ucla.edu>

 	xalloc-die: omit /*extern*/
diff --git a/top/maint.mk b/top/maint.mk
index 598c4939a6..eb5868d650 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -180,7 +180,7 @@ no-vc-detected:
 endif
 .PHONY: $(local-checks-available)

-# Arrange to print the name of each syntax-checking rule just before running it.
+# Arrange to prine the name of each syntax-checking rule just before running it.
 $(syntax-check-rules): %: %.m
 sc_m_rules_ = $(patsubst %, %.m, $(syntax-check-rules))
 .PHONY: $(sc_m_rules_)
@@ -598,23 +598,14 @@ sc_prohibit_error_without_use:
 	re='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\
 	  $(_sc_header_without_use)

-# Don't include xalloc.h unless you use one of its functions.
+# Don't include xalloc.h unless you use one of its symbols.
 # Consider these symbols:
 # perl -lne '/^# *define (\w+)\(/ and print $1' lib/xalloc.h|grep -v '^__';
-# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/xalloc.h
+# perl -lne 'm{^(?:_Noreturn )?(?:void|char) \*?(\w+) *\(} and print $1' lib/xalloc.h
 # Divide into two sets on case, and filter each through this:
 # | sort | perl -MRegexp::Assemble -le \
 #  'print Regexp::Assemble->new(file => "/dev/stdin")->as_string'|sed 's/\?://g'
-# Note this was produced by the above:
-# _xa1 = \
-#x(((2n?)?re|c(har)?|n(re|m)|z)alloc|alloc_(oversized|die)|m(alloc|emdup)|strdup)
-# But we can do better, in at least two ways:
-# 1) take advantage of two "dup"-suffixed strings:
-# x(((2n?)?re|c(har)?|n(re|m)|[mz])alloc|alloc_(oversized|die)|(mem|str)dup)
-# 2) notice that "c(har)?|[mz]" is equivalent to the shorter and more readable
-# "char|[cmz]"
-# x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup)
-_xa1 = x(i(m(emdup0?|alloc)|realloc(array)?|([cz]|nm)alloc)|([pz]|c(har)?|2n?re|nm)alloc|realloc(array)?|m(alloc|emdup)|strdup)
+_xa1 = x(i(m(emdup0?|alloc)|realloc(array)?|([cz]|nm)alloc)|([pz]|c(har)?|2n?re|nm)alloc|realloc(array)?|m(alloc|emdup)|alloc_die|strdup)
 _xa2 = X([CZ]|N?M)ALLOC
 sc_prohibit_xalloc_without_use:
 	@h='xalloc.h' \
-- 
2.41.0

