Skip to content

Commit aedf590

Browse files
miss-islingtonserhiy-storchakaclaude
authored
[3.13] gh-154070: Build the curses module wide by capability, not by name (GH-154071) (GH-154765) (GH-154800)
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 d1eefcb commit aedf590

3 files changed

Lines changed: 94 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: 63 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
@@ -6881,6 +6881,33 @@ AS_VAR_IF([ac_sys_system], [Darwin], [
68816881
dnl pyconfig.h defines _XOPEN_SOURCE=700
68826882
PANEL_CFLAGS=$(echo $PANEL_CFLAGS | sed 's/-D_XOPEN_SOURCE=600//g')
68836883
6884+
dnl A curses that is not named "ncursesw" can still be wide-character capable:
6885+
dnl the system curses of NetBSD, or an ncurses built with --enable-widec that
6886+
dnl keeps the plain name (pkgsrc, macOS). Probe for the wide API and, if
6887+
dnl present, build the module wide by defining HAVE_NCURSESW.
6888+
AS_VAR_IF([have_curses], [no], [], [
6889+
dnl Use the adjusted CURSES_CFLAGS (e.g. macOS's -D_XOPEN_SOURCE_EXTENDED)
6890+
dnl so the wide-character declarations are visible to the probe. This runs
6891+
dnl inside an outer WITH_SAVE_ENV, whose single CPPFLAGS save slot is not
6892+
dnl reentrant, so save and restore CPPFLAGS with a dedicated variable here.
6893+
save_curses_cppflags=$CPPFLAGS
6894+
AS_VAR_APPEND([CPPFLAGS], [" $CURSES_CFLAGS"])
6895+
AC_CACHE_CHECK([whether curses supports wide characters],
6896+
[ac_cv_curses_wide],
6897+
[AC_LINK_IFELSE(
6898+
[AC_LANG_PROGRAM([_CURSES_INCLUDES], [[
6899+
cchar_t wcval;
6900+
setcchar(&wcval, L"x", A_NORMAL, 0, NULL);
6901+
add_wch(&wcval);
6902+
]])],
6903+
[ac_cv_curses_wide=yes],
6904+
[ac_cv_curses_wide=no])])
6905+
CPPFLAGS=$save_curses_cppflags
6906+
dnl HAVE_NCURSESW marks the wide (cchar_t) curses API; its template comes
6907+
dnl from the ncursesw pkg-config check above, so no description here.
6908+
AS_VAR_IF([ac_cv_curses_wide], [yes], [AC_DEFINE([HAVE_NCURSESW], [1])])
6909+
])
6910+
68846911
# On Solaris, term.h requires curses.h
68856912
AC_CHECK_HEADERS([term.h], [], [], _CURSES_INCLUDES)
68866913

0 commit comments

Comments
 (0)