Skip to content

Commit 6b8451f

Browse files
miss-islingtonserhiy-storchakaclaude
authored
[3.14] gh-154070: Build the curses module wide by capability, not by name (GH-154071) (GH-154765) (GH-154799)
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. (cherry picked from commit 2db8ca7) (cherry picked from commit 383c7bd) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent b667262 commit 6b8451f

3 files changed

Lines changed: 97 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: 66 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: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6991,6 +6991,33 @@ AS_VAR_IF([ac_sys_system], [Darwin], [
69916991
dnl pyconfig.h defines _XOPEN_SOURCE=700
69926992
PANEL_CFLAGS=$(echo $PANEL_CFLAGS | sed 's/-D_XOPEN_SOURCE=600//g')
69936993
6994+
dnl A curses that is not named "ncursesw" can still be wide-character capable:
6995+
dnl the system curses of NetBSD, or an ncurses built with --enable-widec that
6996+
dnl keeps the plain name (pkgsrc, macOS). Probe for the wide API and, if
6997+
dnl present, build the module wide by defining HAVE_NCURSESW.
6998+
AS_VAR_IF([have_curses], [no], [], [
6999+
dnl Use the adjusted CURSES_CFLAGS (e.g. macOS's -D_XOPEN_SOURCE_EXTENDED)
7000+
dnl so the wide-character declarations are visible to the probe. This runs
7001+
dnl inside an outer WITH_SAVE_ENV, whose single CPPFLAGS save slot is not
7002+
dnl reentrant, so save and restore CPPFLAGS with a dedicated variable here.
7003+
save_curses_cppflags=$CPPFLAGS
7004+
AS_VAR_APPEND([CPPFLAGS], [" $CURSES_CFLAGS"])
7005+
AC_CACHE_CHECK([whether curses supports wide characters],
7006+
[ac_cv_curses_wide],
7007+
[AC_LINK_IFELSE(
7008+
[AC_LANG_PROGRAM([_CURSES_INCLUDES], [[
7009+
cchar_t wcval;
7010+
setcchar(&wcval, L"x", A_NORMAL, 0, NULL);
7011+
add_wch(&wcval);
7012+
]])],
7013+
[ac_cv_curses_wide=yes],
7014+
[ac_cv_curses_wide=no])])
7015+
CPPFLAGS=$save_curses_cppflags
7016+
dnl HAVE_NCURSESW marks the wide (cchar_t) curses API; its template comes
7017+
dnl from the ncursesw pkg-config check above, so no description here.
7018+
AS_VAR_IF([ac_cv_curses_wide], [yes], [AC_DEFINE([HAVE_NCURSESW], [1])])
7019+
])
7020+
69947021
# On Solaris, term.h requires curses.h
69957022
AC_CHECK_HEADERS([term.h], [], [], _CURSES_INCLUDES)
69967023

0 commit comments

Comments
 (0)