Thanks for the bug report and analysis. I installed into Autoconf the attached, which should fix the problem in the way you suggested.
From 30bf5c49825ec2092c63b8519678e3e06148a8b5 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sat, 17 Sep 2022 19:43:04 -0700
Subject: [PATCH 1/2] Allow users to clear BINSH

Problem and solution reported by Roger Crew in:
https://lists.gnu.org/r/bug-autoconf/2022-09/msg00005.html
* lib/m4sugar/m4sh.m4 (_m4_divert(BINSH)): Change from 0 to 1,
and add 2 to HEADER-REVISION, HEADER-COMMENT, HEADER-COPYRIGHT,
M4SH-SANITIZE, M4SH-INIT-FN, and M4SH-INIT.
Copyright-paperwork-exempt: yes
---
 lib/m4sugar/m4sh.m4 | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index fc46f6d4..b6714356 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -59,13 +59,13 @@
 # DIVERSION-NAME which is supposed to be an actual diversion number.
 # Of course it would be nicer to use m4_case here, instead of zillions
 # of little macros, but it then takes twice longer to run 'autoconf'!
-m4_define([_m4_divert(BINSH)],             0)
-m4_define([_m4_divert(HEADER-REVISION)],   1)
-m4_define([_m4_divert(HEADER-COMMENT)],    2)
-m4_define([_m4_divert(HEADER-COPYRIGHT)],  3)
-m4_define([_m4_divert(M4SH-SANITIZE)],     4)
-m4_define([_m4_divert(M4SH-INIT-FN)],      5)
-m4_define([_m4_divert(M4SH-INIT)],         6)
+m4_define([_m4_divert(BINSH)],             1)
+m4_define([_m4_divert(HEADER-REVISION)],   3)
+m4_define([_m4_divert(HEADER-COMMENT)],    4)
+m4_define([_m4_divert(HEADER-COPYRIGHT)],  5)
+m4_define([_m4_divert(M4SH-SANITIZE)],     6)
+m4_define([_m4_divert(M4SH-INIT-FN)],      7)
+m4_define([_m4_divert(M4SH-INIT)],         8)
 m4_define([_m4_divert(BODY)],           1000)
 
 # Aaarg.  Yet it starts with compatibility issues...  Libtool wants to
-- 
2.37.3

From df62fad153142de953372a5744995ee3bfae5a02 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sat, 17 Sep 2022 19:43:46 -0700
Subject: [PATCH 2/2] Improve comment in previous change

---
 lib/m4sugar/m4sh.m4 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index b6714356..01d3b5d6 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -59,6 +59,10 @@
 # DIVERSION-NAME which is supposed to be an actual diversion number.
 # Of course it would be nicer to use m4_case here, instead of zillions
 # of little macros, but it then takes twice longer to run 'autoconf'!
+# BINSH is 1, not 0, so that user code can m4_cleardivert([BINSH]) and
+# then generate its own BINSH; m4's special treatment of diversion 0
+# would not allow that if BINSH were 0.  Leave an undocumented gap
+# between BINSH and HEADER-REVISION for possible future extensions.
 m4_define([_m4_divert(BINSH)],             1)
 m4_define([_m4_divert(HEADER-REVISION)],   3)
 m4_define([_m4_divert(HEADER-COMMENT)],    4)
-- 
2.37.3

Reply via email to