Skip to content

Commit e62cb33

Browse files
gh-154070: Build the curses module wide by capability, not by name
configure built the module wide (HAVE_NCURSESW) only for a backend named ncursesw. Probe for the wide API in the ncurses and auto backends too, so a widec-built ncurses keeping the plain name (pkgsrc, macOS) is built wide. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 4b60b46 commit e62cb33

3 files changed

Lines changed: 49 additions & 24 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: 24 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7219,22 +7219,27 @@ AS_VAR_IF([ac_sys_system], [Darwin], [
72197219
dnl pyconfig.h defines _XOPEN_SOURCE=700
72207220
PANEL_CFLAGS=$(echo $PANEL_CFLAGS | sed 's/-D_XOPEN_SOURCE=600//g')
72217221
7222-
dnl Native curses ("curses") may be wide-character capable (e.g. on NetBSD)
7223-
dnl even though it is not ncursesw. Probe for the wide API; if present, build
7224-
dnl the module against it like ncursesw by defining HAVE_NCURSESW. ncursesw
7225-
dnl already defines HAVE_NCURSESW, and ncurses must stay narrow, so only the
7226-
dnl native backend is probed here.
7227-
AS_VAR_IF([with_curses], [curses], [
7228-
AC_CACHE_CHECK([whether curses supports wide characters],
7229-
[ac_cv_curses_wide],
7230-
[AC_LINK_IFELSE(
7231-
[AC_LANG_PROGRAM([_CURSES_INCLUDES], [[
7232-
cchar_t wcval;
7233-
setcchar(&wcval, L"x", A_NORMAL, 0, NULL);
7234-
add_wch(&wcval);
7235-
]])],
7236-
[ac_cv_curses_wide=yes],
7237-
[ac_cv_curses_wide=no])])
7222+
dnl A curses that is not named "ncursesw" can still be wide-character capable:
7223+
dnl the system curses of NetBSD, or an ncurses built with --enable-widec that
7224+
dnl keeps the plain name (pkgsrc, macOS). Probe for the wide API and, if
7225+
dnl present, build the module wide by defining HAVE_NCURSESW. The "ncursesw"
7226+
dnl backend already defines it, so only the other backends are probed.
7227+
AS_CASE([$with_curses], [ncursesw|no], [], [
7228+
WITH_SAVE_ENV([
7229+
dnl Use the adjusted CURSES_CFLAGS (e.g. macOS's -D_XOPEN_SOURCE_EXTENDED)
7230+
dnl so the wide-character declarations are visible to the probe.
7231+
AS_VAR_APPEND([CPPFLAGS], [" $CURSES_CFLAGS"])
7232+
AC_CACHE_CHECK([whether curses supports wide characters],
7233+
[ac_cv_curses_wide],
7234+
[AC_LINK_IFELSE(
7235+
[AC_LANG_PROGRAM([_CURSES_INCLUDES], [[
7236+
cchar_t wcval;
7237+
setcchar(&wcval, L"x", A_NORMAL, 0, NULL);
7238+
add_wch(&wcval);
7239+
]])],
7240+
[ac_cv_curses_wide=yes],
7241+
[ac_cv_curses_wide=no])])
7242+
])
72387243
dnl HAVE_NCURSESW marks the wide (cchar_t) curses API; its template comes
72397244
dnl from the ncursesw pkg-config check above, so no description here.
72407245
AS_VAR_IF([ac_cv_curses_wide], [yes], [AC_DEFINE([HAVE_NCURSESW], [1])])

0 commit comments

Comments
 (0)