On 10/4/20 4:40 PM, Bruno Haible wrote:
AFAICS, this is relevant for code written directly into configure.ac. But
inside an AC_DEFUN it is irrelevant, because required macros are hoisted
before the body of the AC_DEFUN anyway.

I was playing it safe based on this NEWS item from Autoconf 2.69c:

   - Autoconf macros that use AC_REQUIRE internally, are not safe to
     use inside of hand-written shell control-flow constructs.  Use
     AS_IF, AS_CASE, AS_FOR, etc. instead.  (See the “Prerequisite
     Macros” section of the manual for further explanation.)

Since I didn't know whether the macros in question used AC_REQUIRE internally, I played it safe.

But now that you mention it, AS_IF isn't needed here and I installed the attached further patch. Also, to help prevent others from making a similar mistake, I plan to reword the Autoconf NEWS item to start with something like "Autoconf macros that use AC_REQUIRE are not safe to use in hand-written shell control-flow constructs that appear outside of macros defined by AC_DEFUN."
>From f636f37983b32d8db3abea7ecdda928f3a0f542e Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 4 Oct 2020 18:46:44 -0700
Subject: [PATCH] c-stack: avoid AS_IF

Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2020-10/msg00018.html
* m4/c-stack.m4 (gl_PREREQ_C_STACK): No need for AS_IF.
---
 ChangeLog     |  5 +++++
 m4/c-stack.m4 | 14 ++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e0c821f7d..4ec03efe4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2020-10-04  Paul Eggert  <egg...@cs.ucla.edu>
 
+	c-stack: avoid AS_IF
+	Problem reported by Bruno Haible in:
+	https://lists.gnu.org/r/bug-gnulib/2020-10/msg00018.html
+	* m4/c-stack.m4 (gl_PREREQ_C_STACK): No need for AS_IF.
+
 	c-stack: pacify GCC 9.3.1 when using libsigsegv
 	* lib/c-stack.c [USE_LIBSIGSEGV]: Disable --suggest-attribute=pure.
 
diff --git a/m4/c-stack.m4 b/m4/c-stack.m4
index 1523a724d..85107f465 100644
--- a/m4/c-stack.m4
+++ b/m4/c-stack.m4
@@ -7,7 +7,7 @@
 
 # Written by Paul Eggert.
 
-# serial 19
+# serial 20
 
 AC_DEFUN([AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC],
   [
@@ -360,11 +360,13 @@ AC_DEFUN([gl_PREREQ_C_STACK],
    AC_CHECK_TYPES([stack_t], , , [[#include <signal.h>]])
 
    dnl c-stack does not need -lsigsegv if the system has XSI heuristics.
-   AS_IF([test "$gl_cv_sys_xsi_stack_overflow_heuristic" != yes],
-     [gl_LIBSIGSEGV
-      AS_IF([test "$gl_cv_lib_sigsegv" = yes],
-        [AC_SUBST([LIBCSTACK], [$LIBSIGSEGV])
-         AC_SUBST([LTLIBCSTACK], [$LTLIBSIGSEGV])])])
+   if test "$gl_cv_sys_xsi_stack_overflow_heuristic" != yes; then
+     gl_LIBSIGSEGV
+     if test "$gl_cv_lib_sigsegv" = yes; then
+       AC_SUBST([LIBCSTACK], [$LIBSIGSEGV])
+       AC_SUBST([LTLIBCSTACK], [$LTLIBSIGSEGV])
+     fi
+   fi
 ])
 
 AC_DEFUN([gl_C_STACK],
-- 
2.25.1

Reply via email to