Skip to content

Commit 603c80f

Browse files
Don't leak curses CPPFLAGS into the whole-interpreter build
The wide-character probe ran inside a nested WITH_SAVE_ENV, whose single CPPFLAGS save slot is not reentrant, so the outer restore leaked $CURSES_CFLAGS and $PANEL_CFLAGS (-D_XOPEN_SOURCE=600) into CONFIGURE_CPPFLAGS and thus into every translation unit, producing a '_XOPEN_SOURCE' redefined warning against pyconfig.h on every file. Save and restore CPPFLAGS with a dedicated variable around the probe, as on the main branch.
1 parent f841cf9 commit 603c80f

2 files changed

Lines changed: 24 additions & 33 deletions

File tree

configure

Lines changed: 7 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7199,21 +7199,23 @@ dnl the system curses of NetBSD, or an ncurses built with --enable-widec that
71997199
dnl keeps the plain name (pkgsrc, macOS). Probe for the wide API and, if
72007200
dnl present, build the module wide by defining HAVE_NCURSESW.
72017201
AS_VAR_IF([have_curses], [no], [], [
7202-
WITH_SAVE_ENV([
7203-
dnl Use the adjusted CURSES_CFLAGS (e.g. macOS's -D_XOPEN_SOURCE_EXTENDED)
7204-
dnl so the wide-character declarations are visible to the probe.
7205-
AS_VAR_APPEND([CPPFLAGS], [" $CURSES_CFLAGS"])
7206-
AC_CACHE_CHECK([whether curses supports wide characters],
7207-
[ac_cv_curses_wide],
7208-
[AC_LINK_IFELSE(
7209-
[AC_LANG_PROGRAM([_CURSES_INCLUDES], [[
7210-
cchar_t wcval;
7211-
setcchar(&wcval, L"x", A_NORMAL, 0, NULL);
7212-
add_wch(&wcval);
7213-
]])],
7214-
[ac_cv_curses_wide=yes],
7215-
[ac_cv_curses_wide=no])])
7216-
])
7202+
dnl Use the adjusted CURSES_CFLAGS (e.g. macOS's -D_XOPEN_SOURCE_EXTENDED)
7203+
dnl so the wide-character declarations are visible to the probe. This runs
7204+
dnl inside an outer WITH_SAVE_ENV, whose single CPPFLAGS save slot is not
7205+
dnl reentrant, so save and restore CPPFLAGS with a dedicated variable here.
7206+
save_curses_cppflags=$CPPFLAGS
7207+
AS_VAR_APPEND([CPPFLAGS], [" $CURSES_CFLAGS"])
7208+
AC_CACHE_CHECK([whether curses supports wide characters],
7209+
[ac_cv_curses_wide],
7210+
[AC_LINK_IFELSE(
7211+
[AC_LANG_PROGRAM([_CURSES_INCLUDES], [[
7212+
cchar_t wcval;
7213+
setcchar(&wcval, L"x", A_NORMAL, 0, NULL);
7214+
add_wch(&wcval);
7215+
]])],
7216+
[ac_cv_curses_wide=yes],
7217+
[ac_cv_curses_wide=no])])
7218+
CPPFLAGS=$save_curses_cppflags
72177219
dnl HAVE_NCURSESW marks the wide (cchar_t) curses API; its template comes
72187220
dnl from the ncursesw pkg-config check above, so no description here.
72197221
AS_VAR_IF([ac_cv_curses_wide], [yes], [AC_DEFINE([HAVE_NCURSESW], [1])])

0 commit comments

Comments
 (0)