From: Paul Eggert Date: Fri, 1 Nov 2024 01:29:54 +0000 (-0700) Subject: Fix use of $3 in _AC_FUNC_MALLOC_IF etc X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f8c82d292699fbce6d60abb46259a3781578f7fc;p=thirdparty%2Fautoconf.git Fix use of $3 in _AC_FUNC_MALLOC_IF etc Use m4_default in case $3 is omitted. Problem reported by Bruno Haible in: https://lists.gnu.org/r/bug-gnulib/2024-10/msg00284.html Also, use AS_CASE to defend against $3 containing macros that might be expaned. --- diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4 index c12e19877..9d5f5bb8c 100644 --- a/lib/autoconf/functions.m4 +++ b/lib/autoconf/functions.m4 @@ -968,11 +968,11 @@ fi ]) -# _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT, UNKNOWN-ASSUME) -# ---------------------------------------------------- +# _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT[, UNKNOWN-ASSUME]) +# ------------------------------------------------------ # If 'malloc (0, 0)' returns nonnull, run IF-WORKS, otherwise, IF-NOT. # If it is not known whether it works, assume the shell word UNKNOWN-ASSUME, -# which should end in "yes" or in something else. +# which should end in "yes" or in something else (the latter is the default). AC_DEFUN([_AC_FUNC_MALLOC_IF], [ AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles @@ -987,21 +987,17 @@ AC_DEFUN([_AC_FUNC_MALLOC_IF], [[void *p = pmalloc (0); int result = !p; free (p); - return result;]]) - ], + return result;]])], [ac_cv_func_malloc_0_nonnull=yes], [ac_cv_func_malloc_0_nonnull=no], - [case "$host_os" in - # Guess yes on platforms where we know the result. - *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ - | gnu* | *-musl* | midipix* | midnightbsd* \ - | hpux* | solaris* | cygwin* | mingw* | windows* | msys* ) - ac_cv_func_malloc_0_nonnull="guessing yes" ;; - # Guess as follows if we don't know. - *) ac_cv_func_malloc_0_nonnull=$3 ;; - esac - ]) - ]) + [AS_CASE([$host_os], + [# Guess yes on platforms where we know the result. + *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ + | gnu* | *-musl* | midipix* | midnightbsd* \ + | hpux* | solaris* | cygwin* | mingw* | windows* | msys*], + [ac_cv_func_malloc_0_nonnull="guessing yes"], + [# Guess as follows if we don't know. + ac_cv_func_malloc_0_nonnull=m4_default([$3], ["guessing no"])])])]) AS_CASE([$ac_cv_func_malloc_0_nonnull], [*yes], [$1], [$2]) ])# _AC_FUNC_MALLOC_IF @@ -1484,11 +1480,11 @@ AU_ALIAS([AM_FUNC_OBSTACK], [AC_FUNC_OBSTACK]) -# _AC_FUNC_REALLOC_IF(IF-WORKS, IF-NOT, UNKNOWN-ASSUME) -# ----------------------------------------------------- +# _AC_FUNC_REALLOC_IF(IF-WORKS, IF-NOT[, UNKNOWN-ASSUME]) +# ------------------------------------------------------- # If 'realloc (0, 0)' returns nonnull, run IF-WORKS, otherwise, IF-NOT. # If it is not known whether it works, assume the shell word UNKNOWN-ASSUME, -# which should end in "yes" or in something else. +# which should end in "yes" or in something else (the latter is the default). AC_DEFUN([_AC_FUNC_REALLOC_IF], [ AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles @@ -1503,21 +1499,17 @@ AC_DEFUN([_AC_FUNC_REALLOC_IF], [[void *p = prealloc (0, 0); int result = !p; free (p); - return result;]]) - ], + return result;]])], [ac_cv_func_realloc_0_nonnull=yes], [ac_cv_func_realloc_0_nonnull=no], - [case "$host_os" in - # Guess yes on platforms where we know the result. - *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ - | gnu* | *-musl* | midipix* | midnightbsd* \ - | hpux* | solaris* | cygwin* | mingw* | windows* | msys* ) - ac_cv_func_realloc_0_nonnull="guessing yes" ;; - # Guess as follows if we don't know. - *) ac_cv_func_realloc_0_nonnull=$3 ;; - esac - ]) - ]) + [AS_CASE([$host_os], + [# Guess yes on platforms where we know the result. + *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ + | gnu* | *-musl* | midipix* | midnightbsd* \ + | hpux* | solaris* | cygwin* | mingw* | windows* | msys*], + [ac_cv_func_realloc_0_nonnull="guessing yes"], + [# Guess as follows if we don't know. + ac_cv_func_realloc_0_nonnull=m4_default([$3], ["guessing no"])])])]) AS_CASE([$ac_cv_func_realloc_0_nonnull], [*yes], [$1], [$2]) ])# _AC_FUNC_REALLOC_IF