Skip to content

Commit f841cf9

Browse files
[3.15] gh-154070: Build the curses module wide by capability, not by name (GH-154071)
configure built the module wide (HAVE_NCURSESW) only for a library found under the name ncursesw. Probe for the wide API too, so a widec-built ncurses keeping the plain name (pkgsrc, macOS) is built wide. 3.15 has no --with-curses, so the probe is guarded on curses being found rather than on the selected backend. (cherry picked from commit 2db8ca7) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent df66175 commit f841cf9

3 files changed

Lines changed: 106 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Build the :mod:`curses` module against a wide-character capable ncurses
2+
even when it is not named ``ncursesw`` -- for example the pkgsrc ncurses on
3+
NetBSD and illumos, or the system ncurses on macOS. Such a library
4+
previously produced a narrow build.

configure

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

configure.ac

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7194,6 +7194,31 @@ AS_VAR_IF([ac_sys_system], [Darwin], [
71947194
dnl pyconfig.h defines _XOPEN_SOURCE=700
71957195
PANEL_CFLAGS=$(echo $PANEL_CFLAGS | sed 's/-D_XOPEN_SOURCE=600//g')
71967196
7197+
dnl A curses that is not named "ncursesw" can still be wide-character capable:
7198+
dnl the system curses of NetBSD, or an ncurses built with --enable-widec that
7199+
dnl keeps the plain name (pkgsrc, macOS). Probe for the wide API and, if
7200+
dnl present, build the module wide by defining HAVE_NCURSESW.
7201+
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+
])
7217+
dnl HAVE_NCURSESW marks the wide (cchar_t) curses API; its template comes
7218+
dnl from the ncursesw pkg-config check above, so no description here.
7219+
AS_VAR_IF([ac_cv_curses_wide], [yes], [AC_DEFINE([HAVE_NCURSESW], [1])])
7220+
])
7221+
71977222
# On Solaris, term.h requires curses.h
71987223
AC_CHECK_HEADERS([term.h], [], [], _CURSES_INCLUDES)
71997224

0 commit comments

Comments
 (0)