Skip to content

Commit 8e4580d

Browse files
gh-154070: 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. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4310f6b commit 8e4580d

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
@@ -7254,21 +7254,23 @@ dnl keeps the plain name (pkgsrc, macOS). Probe for the wide API and, if
72547254
dnl present, build the module wide by defining HAVE_NCURSESW. The "ncursesw"
72557255
dnl backend already defines it, so only the other backends are probed.
72567256
AS_CASE([$with_curses], [ncursesw|no], [], [
7257-
WITH_SAVE_ENV([
7258-
dnl Use the adjusted CURSES_CFLAGS (e.g. macOS's -D_XOPEN_SOURCE_EXTENDED)
7259-
dnl so the wide-character declarations are visible to the probe.
7260-
AS_VAR_APPEND([CPPFLAGS], [" $CURSES_CFLAGS"])
7261-
AC_CACHE_CHECK([whether curses supports wide characters],
7262-
[ac_cv_curses_wide],
7263-
[AC_LINK_IFELSE(
7264-
[AC_LANG_PROGRAM([_CURSES_INCLUDES], [[
7265-
cchar_t wcval;
7266-
setcchar(&wcval, L"x", A_NORMAL, 0, NULL);
7267-
add_wch(&wcval);
7268-
]])],
7269-
[ac_cv_curses_wide=yes],
7270-
[ac_cv_curses_wide=no])])
7271-
])
7257+
dnl Use the adjusted CURSES_CFLAGS (e.g. macOS's -D_XOPEN_SOURCE_EXTENDED)
7258+
dnl so the wide-character declarations are visible to the probe. This runs
7259+
dnl inside an outer WITH_SAVE_ENV, whose single CPPFLAGS save slot is not
7260+
dnl reentrant, so save and restore CPPFLAGS with a dedicated variable here.
7261+
save_curses_cppflags=$CPPFLAGS
7262+
AS_VAR_APPEND([CPPFLAGS], [" $CURSES_CFLAGS"])
7263+
AC_CACHE_CHECK([whether curses supports wide characters],
7264+
[ac_cv_curses_wide],
7265+
[AC_LINK_IFELSE(
7266+
[AC_LANG_PROGRAM([_CURSES_INCLUDES], [[
7267+
cchar_t wcval;
7268+
setcchar(&wcval, L"x", A_NORMAL, 0, NULL);
7269+
add_wch(&wcval);
7270+
]])],
7271+
[ac_cv_curses_wide=yes],
7272+
[ac_cv_curses_wide=no])])
7273+
CPPFLAGS=$save_curses_cppflags
72727274
dnl HAVE_NCURSESW marks the wide (cchar_t) curses API; its template comes
72737275
dnl from the ncursesw pkg-config check above, so no description here.
72747276
AS_VAR_IF([ac_cv_curses_wide], [yes], [AC_DEFINE([HAVE_NCURSESW], [1])])

0 commit comments

Comments
 (0)