https://github.com/python/cpython/commit/167cf3ace0db553dce50b2068dfae1f9eae4da6e
commit: 167cf3ace0db553dce50b2068dfae1f9eae4da6e
branch: main
author: Erlend E. Aasland <[email protected]>
committer: encukou <[email protected]>
date: 2025-02-08T15:38:11+01:00
summary:

gh-115806: Don't mangle gdbm header dependency detection output (#129390)

Replace AC_CACHE_VAL/AC_CHECK_HEADER with a cleaner variant using
AC_CACHE_CHECK/AC_PREPROC_IFELSE.

The former would produce garbled output when config.cache was reused. It
also required directly manipulating GNU Autoconf cache variables.

files:
M configure
M configure.ac

diff --git a/configure b/configure
index 65b8e711cdccae..d46bc563a67245 100755
--- a/configure
+++ b/configure
@@ -17162,26 +17162,28 @@ esac
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_ndbm ($dbm_ndbm)" 
>&5
 printf "%s\n" "$have_ndbm ($dbm_ndbm)" >&6; }
 
-{ ac_cv_header_gdbm_ndbm_h=; unset ac_cv_header_gdbm_ndbm_h;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gdbm/ndbm.h" >&5
+printf %s "checking for gdbm/ndbm.h... " >&6; }
 if test ${ac_cv_header_gdbm_slash_ndbm_h+y}
 then :
   printf %s "(cached) " >&6
 else case e in #(
-  e)
-  ac_fn_c_check_header_compile "$LINENO" "gdbm/ndbm.h" 
"ac_cv_header_gdbm_ndbm_h" "$ac_includes_default"
-if test "x$ac_cv_header_gdbm_ndbm_h" = xyes
+  e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <gdbm/ndbm.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"
 then :
   ac_cv_header_gdbm_slash_ndbm_h=yes
 else case e in #(
-  e) ac_cv_header_gdbm_slash_ndbm_h=no
-   ;;
+  e) ac_cv_header_gdbm_slash_ndbm_h=no ;;
 esac
 fi
-
- ;;
+rm -f conftest.err conftest.i conftest.$ac_ext ;;
 esac
 fi
-
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: 
$ac_cv_header_gdbm_slash_ndbm_h" >&5
+printf "%s\n" "$ac_cv_header_gdbm_slash_ndbm_h" >&6; }
 if test "x$ac_cv_header_gdbm_slash_ndbm_h" = xyes
 then :
 
@@ -17191,26 +17193,28 @@ printf "%s\n" "#define HAVE_GDBM_NDBM_H 1" 
>>confdefs.h
 
 fi
 
-{ ac_cv_header_gdbm_ndbm_h=; unset ac_cv_header_gdbm_ndbm_h;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gdbm-ndbm.h" >&5
+printf %s "checking for gdbm-ndbm.h... " >&6; }
 if test ${ac_cv_header_gdbm_dash_ndbm_h+y}
 then :
   printf %s "(cached) " >&6
 else case e in #(
-  e)
-  ac_fn_c_check_header_compile "$LINENO" "gdbm-ndbm.h" 
"ac_cv_header_gdbm_ndbm_h" "$ac_includes_default"
-if test "x$ac_cv_header_gdbm_ndbm_h" = xyes
+  e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <gdbm-ndbm.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"
 then :
   ac_cv_header_gdbm_dash_ndbm_h=yes
 else case e in #(
-  e) ac_cv_header_gdbm_dash_ndbm_h=no
-   ;;
+  e) ac_cv_header_gdbm_dash_ndbm_h=no ;;
 esac
 fi
-
- ;;
+rm -f conftest.err conftest.i conftest.$ac_ext ;;
 esac
 fi
-
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: 
$ac_cv_header_gdbm_dash_ndbm_h" >&5
+printf "%s\n" "$ac_cv_header_gdbm_dash_ndbm_h" >&6; }
 if test "x$ac_cv_header_gdbm_dash_ndbm_h" = xyes
 then :
 
@@ -17219,7 +17223,6 @@ printf "%s\n" "#define HAVE_GDBM_DASH_NDBM_H 1" 
>>confdefs.h
 
 
 fi
-{ ac_cv_header_gdbm_ndbm_h=; unset ac_cv_header_gdbm_ndbm_h;}
 
 if test "$ac_cv_header_gdbm_slash_ndbm_h" = yes -o 
"$ac_cv_header_gdbm_dash_ndbm_h" = yes; then
   { ac_cv_search_dbm_open=; unset ac_cv_search_dbm_open;}
diff --git a/configure.ac b/configure.ac
index 0c6063d87d654a..faa8909530389d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4430,29 +4430,21 @@ AS_CASE([$ac_cv_search_dbm_open],
 AC_MSG_RESULT([$have_ndbm ($dbm_ndbm)])
 
 dnl "gdbm-ndbm.h" and "gdbm/ndbm.h" are both normalized to "gdbm_ndbm_h"
-dnl unset ac_cv_header_gdbm_ndbm_h to prevent false positive cache hits.
-AS_UNSET([ac_cv_header_gdbm_ndbm_h])
-AC_CACHE_VAL([ac_cv_header_gdbm_slash_ndbm_h], [
-  AC_CHECK_HEADER(
-    [gdbm/ndbm.h],
-    [ac_cv_header_gdbm_slash_ndbm_h=yes], [ac_cv_header_gdbm_slash_ndbm_h=no]
-  )
-])
+AC_CACHE_CHECK([for gdbm/ndbm.h], [ac_cv_header_gdbm_slash_ndbm_h],
+               [AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include 
<gdbm/ndbm.h>])],
+                                  [ac_cv_header_gdbm_slash_ndbm_h=yes],
+                                  [ac_cv_header_gdbm_slash_ndbm_h=no])])
 AS_VAR_IF([ac_cv_header_gdbm_slash_ndbm_h], [yes], [
   AC_DEFINE([HAVE_GDBM_NDBM_H], [1], [Define to 1 if you have the 
<gdbm/ndbm.h> header file.])
 ])
 
-AS_UNSET([ac_cv_header_gdbm_ndbm_h])
-AC_CACHE_VAL([ac_cv_header_gdbm_dash_ndbm_h], [
-  AC_CHECK_HEADER(
-    [gdbm-ndbm.h],
-    [ac_cv_header_gdbm_dash_ndbm_h=yes], [ac_cv_header_gdbm_dash_ndbm_h=no]
-  )
-])
+AC_CACHE_CHECK([for gdbm-ndbm.h], [ac_cv_header_gdbm_dash_ndbm_h],
+               [AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include 
<gdbm-ndbm.h>])],
+                                  [ac_cv_header_gdbm_dash_ndbm_h=yes],
+                                  [ac_cv_header_gdbm_dash_ndbm_h=no])])
 AS_VAR_IF([ac_cv_header_gdbm_dash_ndbm_h], [yes], [
   AC_DEFINE([HAVE_GDBM_DASH_NDBM_H], [1], [Define to 1 if you have the 
<gdbm-ndbm.h> header file.])
 ])
-AS_UNSET([ac_cv_header_gdbm_ndbm_h])
 
 if test "$ac_cv_header_gdbm_slash_ndbm_h" = yes -o 
"$ac_cv_header_gdbm_dash_ndbm_h" = yes; then
   AS_UNSET([ac_cv_search_dbm_open])

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to