bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] BASH_FUNC_STRTOIMAX: fix and simplify


From: Grisha Levit
Subject: [PATCH] BASH_FUNC_STRTOIMAX: fix and simplify
Date: Wed, 23 Oct 2024 12:39:51 -0400

Without an existing cache, if we run ./configure -C, we get the odd-
looking:

    checking for usable strtoimax... checking for strtoimax... yes
    checking whether strtoimax is declared... yes
    yes

config.h is correct though:

    #define HAVE_DECL_STRTOIMAX 1
    #define HAVE_STRTOIMAX 1

However, if we re-run ./configure -C, we get:

    checking for usable strtoimax... (cached) yes

and since AC_CHECK_FUNCS([strtoimax]) does not execute, config.h
changes to:

    #define HAVE_DECL_STRTOIMAX 1
    /* #undef HAVE_STRTOIMAX */

This is "fine" because HAVE_STRTOIMAX is not used anywhere but it
does cause `make` to rebuild most files since config.h has changed.

OTOH, if bash_cv_func_strtoimax=no, since AC_CHECK_DECLS([strtoimax])
does not execute, config.h ends up with:

    /* #undef HAVE_DECL_STRTOIMAX */

which means that externs.h checks the value of an undefined macro at:

    #if !HAVE_DECL_STRTOIMAX

I think this much simpler version avoids the weird output, non-
idempotency, and undefined macro issues while keeping the same
functionality.
---
 m4/strtoimax.m4 | 28 +++-------------------------
 1 file changed, 3 insertions(+), 25 deletions(-)

diff --git a/m4/strtoimax.m4 b/m4/strtoimax.m4
index 4d6cb3ba..94ecd5b4 100644
--- a/m4/strtoimax.m4
+++ b/m4/strtoimax.m4
@@ -7,31 +7,9 @@ dnl Make sure we replace strtoimax if we don't have a 
declaration
 dnl We can use this as a template for future function checks
 
 AC_DEFUN([BASH_FUNC_STRTOIMAX], [
-AC_MSG_CHECKING([for usable strtoimax])
-AC_CACHE_VAL(bash_cv_func_strtoimax,
-[
-  HAVE_STRTOIMAX=0 HAVE_DECL_STRTOIMAX=0
-
-  AC_CHECK_FUNCS([strtoimax])
-  AC_CHECK_DECLS([strtoimax])
-
-  if test "$ac_cv_func_strtoimax" = "yes" ; then
-    HAVE_STRTOIMAX=1
-  fi
-  if test "$ac_cv_have_decl_strtoimax" = "yes" ; then
-    HAVE_DECL_STRTOIMAX=1
-  fi
-  if test "$HAVE_STRTOIMAX" = 0 || test "$HAVE_DECL_STRTOIMAX" = 0 ; then
-    bash_cv_func_strtoimax=no REPLACE_STRTOIMAX=1
-  else
-    bash_cv_func_strtoimax=yes
-  fi
-])
-AC_MSG_RESULT($bash_cv_func_strtoimax)
-if test "$ac_cv_have_decl_strtoimax" = "yes" ; then
-AC_DEFINE([HAVE_DECL_STRTOIMAX], [1])
-fi
-if test $bash_cv_func_strtoimax = no; then
+AC_CHECK_FUNCS([strtoimax])
+AC_CHECK_DECLS([strtoimax])
+if test $ac_cv_func_strtoimax != yes || test $ac_cv_have_decl_strtoimax != 
yes; then
 AC_LIBOBJ(strtoimax)
 fi
 ])
-- 
2.47.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]