diff --git a/Include/py_curses.h b/Include/py_curses.h --- a/Include/py_curses.h +++ b/Include/py_curses.h @@ -39,35 +39,32 @@ #endif #ifndef _WINT_T #define _WINT_T #endif #endif #endif #endif -#ifdef HAVE_NCURSES_H +#ifdef HAVE_NCURSESW_NCURSES_H +#include +#elif defined(HAVE_NCURSES_NCURSES_H) +#include +#elif HAVE_NCURSES_H #include #else #include #ifdef HAVE_TERM_H /* for tigetstr, which is not declared in SysV curses */ #include #endif #endif -#ifdef HAVE_NCURSES_H -/* configure was checking , but we will - use , which has all these features. */ -#ifndef WINDOW_HAS_FLAGS -#define WINDOW_HAS_FLAGS 1 -#endif -#ifndef MVWDELCH_IS_EXPRESSION -#define MVWDELCH_IS_EXPRESSION 1 -#endif +#if defined(HAVE_NCURSESW_NCURSES_H) || defined(HAVE_NCURSES_NCURSES_H) || defined(HAVE_NCURSES_H) +#define HAVE_NCURSES #endif #ifdef __cplusplus extern "C" { #endif #define PyCurses_API_pointers 4 diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -9,17 +9,23 @@ static const char PyCursesVersion[] = "2.1"; /* Includes */ #include "Python.h" #include "py_curses.h" +#ifdef HAVE_NCURSESW_PANEL_H +#include +#elif defined(HAVE_NCURSES_PANEL_H) +#include +#else #include +#endif typedef struct { PyObject *PyCursesError; PyObject *PyCursesPanel_Type; } _curses_panelstate; #define _curses_panelstate(o) ((_curses_panelstate *)PyModule_GetState(o)) diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -120,17 +120,17 @@ extern int setupterm(char *,int,int *); #ifdef __sgi #include #endif #ifdef HAVE_LANGINFO_H #include #endif -#if !defined(HAVE_NCURSES_H) && (defined(sgi) || defined(__sun) || defined(SCO5)) +#if !defined(HAVE_NCURSES) && (defined(sgi) || defined(__sun) || defined(SCO5)) #define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ typedef chtype attr_t; /* No attr_t type is available */ #endif #if defined(_AIX) #define STRICT_SYSV_CURSES #endif @@ -913,17 +913,17 @@ PyCursesWindow_Box(PyCursesWindowObject if (!PyArg_ParseTuple(args,"ll;vertint,horint", &ch1, &ch2)) return NULL; } box(self->win,ch1,ch2); Py_INCREF(Py_None); return Py_None; } -#if defined(HAVE_NCURSES_H) || defined(MVWDELCH_IS_EXPRESSION) +#ifdef MVWDELCH_IS_EXPRESSION #define py_mvwdelch mvwdelch #else int py_mvwdelch(WINDOW *w, int y, int x) { mvwdelch(w,y,x); /* On HP/UX, mvwdelch already returns. On other systems, we may well run into this return statement. */ return 0; @@ -2449,17 +2449,17 @@ PyCurses_InitScr(PyObject *self) SetDictInt("ACS_LRCORNER", (ACS_LRCORNER)); SetDictInt("ACS_LTEE", (ACS_LTEE)); SetDictInt("ACS_RTEE", (ACS_RTEE)); SetDictInt("ACS_BTEE", (ACS_BTEE)); SetDictInt("ACS_TTEE", (ACS_TTEE)); SetDictInt("ACS_HLINE", (ACS_HLINE)); SetDictInt("ACS_VLINE", (ACS_VLINE)); SetDictInt("ACS_PLUS", (ACS_PLUS)); -#if !defined(__hpux) || defined(HAVE_NCURSES_H) +#if !defined(__hpux) || defined(HAVE_NCURSES) /* On HP/UX 11, these are of type cchar_t, which is not an integral type. If this is a problem on more platforms, a configure test should be added to determine whether ACS_S1 is of integral type. */ SetDictInt("ACS_S1", (ACS_S1)); SetDictInt("ACS_S9", (ACS_S9)); SetDictInt("ACS_DIAMOND", (ACS_DIAMOND)); SetDictInt("ACS_CKBOARD", (ACS_CKBOARD)); diff --git a/configure b/configure --- a/configure +++ b/configure @@ -15757,20 +15745,17 @@ fi if test "$ac_cv_stat_tv_nsec2" = yes then $as_echo "#define HAVE_STAT_TV_NSEC2 1" >>confdefs.h fi # first curses header check -ac_save_cppflags="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" - -for ac_header in curses.h ncurses.h +for ac_header in curses.h ncurses.h ncursesw/ncurses.h ncurses/ncurses.h panel.h ncursesw/panel.h ncurses/panel.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -15793,25 +15778,35 @@ if test "x$ac_cv_header_term_h" = xyes; #define HAVE_TERM_H 1 _ACEOF fi done + + # On HP/UX 11.0, mvwdelch is a block with a return statement { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mvwdelch is an expression" >&5 $as_echo_n "checking whether mvwdelch is an expression... " >&6; } if ${ac_cv_mvwdelch_is_expression+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#ifdef HAVE_NCURSESW_NCURSES_H +#include +#elif defined(HAVE_NCURSES_NCURSES_H) +#include +#elif defined(HAVE_NCURSES_H) +#include +#else #include +#endif int main () { int rtn; rtn = mvwdelch(0,0,0); ; @@ -15838,17 +15833,25 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether WINDOW has _flags" >&5 $as_echo_n "checking whether WINDOW has _flags... " >&6; } if ${ac_cv_window_has_flags+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#ifdef HAVE_NCURSESW_NCURSES_H +#include +#elif defined(HAVE_NCURSES_NCURSES_H) +#include +#elif defined(HAVE_NCURSES_H) +#include +#else #include +#endif int main () { WINDOW *w; w->_flags = 0; ; @@ -15873,17 +15876,25 @@ then $as_echo "#define WINDOW_HAS_FLAGS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for is_term_resized" >&5 $as_echo_n "checking for is_term_resized... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#ifdef HAVE_NCURSESW_NCURSES_H +#include +#elif defined(HAVE_NCURSES_NCURSES_H) +#include +#elif defined(HAVE_NCURSES_H) +#include +#else #include +#endif int main () { void *x=is_term_resized ; return 0; } _ACEOF @@ -15899,17 +15910,25 @@ else fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for resize_term" >&5 $as_echo_n "checking for resize_term... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#ifdef HAVE_NCURSESW_NCURSES_H +#include +#elif defined(HAVE_NCURSES_NCURSES_H) +#include +#elif defined(HAVE_NCURSES_H) +#include +#else #include +#endif int main () { void *x=resize_term ; return 0; } _ACEOF @@ -15925,17 +15944,25 @@ else fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for resizeterm" >&5 $as_echo_n "checking for resizeterm... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#ifdef HAVE_NCURSESW_NCURSES_H +#include +#elif defined(HAVE_NCURSES_NCURSES_H) +#include +#elif defined(HAVE_NCURSES_H) +#include +#else #include +#endif int main () { void *x=resizeterm ; return 0; } _ACEOF @@ -15947,17 +15974,16 @@ if ac_fn_c_try_compile "$LINENO"; then : $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # last curses configure check -CPPFLAGS=$ac_save_cppflags { $as_echo "$as_me:${as_lineno-$LINENO}: checking for device files" >&5 $as_echo "$as_me: checking for device files" >&6;} if test "x$cross_compiling" = xyes; then if test "${ac_cv_file__dev_ptmx+set}" != set; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/ptmx" >&5 $as_echo_n "checking for /dev/ptmx... " >&6; } diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -4917,84 +4917,90 @@ st.st_mtimespec.tv_nsec = 1; AC_MSG_RESULT($ac_cv_stat_tv_nsec2) if test "$ac_cv_stat_tv_nsec2" = yes then AC_DEFINE(HAVE_STAT_TV_NSEC2, 1, [Define if you have struct stat.st_mtimensec]) fi # first curses header check -ac_save_cppflags="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" - -AC_CHECK_HEADERS(curses.h ncurses.h) +AC_CHECK_HEADERS(curses.h ncurses.h ncursesw/ncurses.h ncurses/ncurses.h panel.h ncursesw/panel.h ncurses/panel.h) # On Solaris, term.h requires curses.h AC_CHECK_HEADERS(term.h,,,[ #ifdef HAVE_CURSES_H #include #endif ]) +AC_DEFUN([AC_LANG_CURSES_PROGRAM], [AC_LANG_PROGRAM([[#ifdef HAVE_NCURSESW_NCURSES_H +#include +#elif defined(HAVE_NCURSES_NCURSES_H) +#include +#elif defined(HAVE_NCURSES_H) +#include +#else +#include +#endif]],[$1])]) + # On HP/UX 11.0, mvwdelch is a block with a return statement AC_MSG_CHECKING(whether mvwdelch is an expression) AC_CACHE_VAL(ac_cv_mvwdelch_is_expression, -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +AC_COMPILE_IFELSE([AC_LANG_CURSES_PROGRAM([[ int rtn; rtn = mvwdelch(0,0,0); ]])], [ac_cv_mvwdelch_is_expression=yes], [ac_cv_mvwdelch_is_expression=no])) AC_MSG_RESULT($ac_cv_mvwdelch_is_expression) if test "$ac_cv_mvwdelch_is_expression" = yes then AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1, [Define if mvwdelch in curses.h is an expression.]) fi AC_MSG_CHECKING(whether WINDOW has _flags) AC_CACHE_VAL(ac_cv_window_has_flags, -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +AC_COMPILE_IFELSE([AC_LANG_CURSES_PROGRAM([[ WINDOW *w; w->_flags = 0; ]])], [ac_cv_window_has_flags=yes], [ac_cv_window_has_flags=no])) AC_MSG_RESULT($ac_cv_window_has_flags) if test "$ac_cv_window_has_flags" = yes then AC_DEFINE(WINDOW_HAS_FLAGS, 1, [Define if WINDOW in curses.h offers a field _flags.]) fi AC_MSG_CHECKING(for is_term_resized) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=is_term_resized]])], +AC_COMPILE_IFELSE([AC_LANG_CURSES_PROGRAM([[void *x=is_term_resized]])], [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.) AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)] ) AC_MSG_CHECKING(for resize_term) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=resize_term]])], +AC_COMPILE_IFELSE([AC_LANG_CURSES_PROGRAM([[void *x=resize_term]])], [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.) AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)] ) AC_MSG_CHECKING(for resizeterm) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=resizeterm]])], +AC_COMPILE_IFELSE([AC_LANG_CURSES_PROGRAM([[void *x=resizeterm]])], [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.) AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)] ) # last curses configure check -CPPFLAGS=$ac_save_cppflags AC_MSG_NOTICE([checking for device files]) dnl NOTE: Inform user how to proceed with files when cross compiling. if test "x$cross_compiling" = xyes; then if test "${ac_cv_file__dev_ptmx+set}" != set; then AC_MSG_CHECKING([for /dev/ptmx]) AC_MSG_RESULT([not set]) diff --git a/pyconfig.h.in b/pyconfig.h.in --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -626,19 +626,31 @@ #undef HAVE_MKTIME /* Define to 1 if you have the `mmap' function. */ #undef HAVE_MMAP /* Define to 1 if you have the `mremap' function. */ #undef HAVE_MREMAP +/* Define to 1 if you have the header file. */ +#undef HAVE_NCURSESW_NCURSES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NCURSESW_PANEL_H + /* Define to 1 if you have the header file. */ #undef HAVE_NCURSES_H +/* Define to 1 if you have the header file. */ +#undef HAVE_NCURSES_NCURSES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NCURSES_PANEL_H + /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_NETPACKET_PACKET_H /* Define to 1 if you have the header file. */ #undef HAVE_NET_IF_H @@ -647,16 +659,19 @@ #undef HAVE_NICE /* Define to 1 if you have the `openat' function. */ #undef HAVE_OPENAT /* Define to 1 if you have the `openpty' function. */ #undef HAVE_OPENPTY +/* Define to 1 if you have the header file. */ +#undef HAVE_PANEL_H + /* Define to 1 if you have the `pathconf' function. */ #undef HAVE_PATHCONF /* Define to 1 if you have the `pause' function. */ #undef HAVE_PAUSE /* Define to 1 if you have the `pipe2' function. */ #undef HAVE_PIPE2 diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -1344,17 +1344,16 @@ class PyBuildExt(build_ext): # Curses support, requiring the System V version of curses, often # provided by the ncurses library. curses_defines = [] curses_includes = [] panel_library = 'panel' if curses_library == 'ncursesw': curses_defines.append(('HAVE_NCURSESW', '1')) - curses_includes.append('/usr/include/ncursesw') # Bug 1464056: If _curses.so links with ncursesw, # _curses_panel.so must link with panelw. panel_library = 'panelw' if host_platform == 'darwin': # On OS X, there is no separate /usr/lib/libncursesw nor # libpanelw. If we are here, we found a locally-supplied # version of libncursesw. There should be also be a # libpanelw. _XOPEN_SOURCE defines are usually excluded