diff -r 8ea51c7d985f Include/py_curses.h --- a/Include/py_curses.h Sun Oct 09 14:54:12 2016 +0900 +++ b/Include/py_curses.h Sun Oct 09 22:11:26 2016 +0900 @@ -7,7 +7,7 @@ ** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards ** against multiple definition of wchar_t. */ -#ifdef _BSD_WCHAR_T_DEFINED_ +#ifdef _BSD_WCHAR_T_DEFINED_ #define _WCHAR_T #endif @@ -22,7 +22,7 @@ ** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards ** against multiple definition of wchar_t and wint_t. */ -#ifdef _XOPEN_SOURCE_EXTENDED +#ifdef _XOPEN_SOURCE_EXTENDED #ifndef __FreeBSD_version #include #endif @@ -44,7 +44,11 @@ #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 @@ -54,15 +58,8 @@ #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 @@ -74,12 +71,12 @@ /* Type declarations */ typedef struct { - PyObject_HEAD - WINDOW *win; - char *encoding; + PyObject_HEAD + WINDOW *win; + char *encoding; } PyCursesWindowObject; -#define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type) +#define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type) #define PyCurses_CAPSULE_NAME "_curses._C_API" diff -r 8ea51c7d985f Modules/_curses_panel.c --- a/Modules/_curses_panel.c Sun Oct 09 14:54:12 2016 +0900 +++ b/Modules/_curses_panel.c Sun Oct 09 22:11:26 2016 +0900 @@ -14,7 +14,13 @@ #include "py_curses.h" +#ifdef HAVE_NCURSESW_PANEL_H +#include +#elif defined(HAVE_NCURSES_PANEL_H) +#include +#else #include +#endif typedef struct { PyObject *PyCursesError; diff -r 8ea51c7d985f Modules/_cursesmodule.c --- a/Modules/_cursesmodule.c Sun Oct 09 14:54:12 2016 +0900 +++ b/Modules/_cursesmodule.c Sun Oct 09 22:11:26 2016 +0900 @@ -125,7 +125,7 @@ #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 @@ -918,7 +918,7 @@ 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) @@ -930,6 +930,16 @@ } #endif +#ifdef HAVE_CURSES_IS_PAD +#define py_is_pad(win) is_pad(win) +#else +#ifdef WINDOW_HAS_FLAGS +#define py_is_pad(win) ((win) ? ((win)->_flags & _ISPAD) != 0 : FALSE) +#else +#define py_is_pad(win) FALSE +#endif +#endif + /* chgat, added by Fabian Kreutz */ static PyObject * @@ -1069,12 +1079,10 @@ if (!PyCurses_ConvertToChtype(self, temp, &ch)) return NULL; -#ifdef WINDOW_HAS_FLAGS - if (self->win->_flags & _ISPAD) + if (py_is_pad(self->win)) return PyCursesCheckERR(pechochar(self->win, ch | attr), "echochar"); else -#endif return PyCursesCheckERR(wechochar(self->win, ch | attr), "echochar"); } @@ -1606,11 +1614,7 @@ int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol; int rtn; -#ifndef WINDOW_HAS_FLAGS - if (0) -#else - if (self->win->_flags & _ISPAD) -#endif + if (py_is_pad(self->win)) { switch(PyTuple_Size(args)) { case 6: @@ -1781,11 +1785,7 @@ int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol; int rtn; -#ifndef WINDOW_HAS_FLAGS - if (0) -#else - if (self->win->_flags & _ISPAD) -#endif + if (py_is_pad(self->win)) { switch(PyTuple_Size(args)) { case 6: @@ -1850,11 +1850,9 @@ } /* printf("Subwin: %i %i %i %i \n", nlines, ncols, begin_y, begin_x); */ -#ifdef WINDOW_HAS_FLAGS - if (self->win->_flags & _ISPAD) + if (py_is_pad(self->win)) win = subpad(self->win, nlines, ncols, begin_y, begin_x); else -#endif win = subwin(self->win, nlines, ncols, begin_y, begin_x); if (win == NULL) { @@ -2454,7 +2452,7 @@ 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 diff -r 8ea51c7d985f configure --- a/configure Sun Oct 09 14:54:12 2016 +0900 +++ b/configure Sun Oct 09 22:11:26 2016 +0900 @@ -15740,10 +15740,7 @@ 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" @@ -15776,6 +15773,8 @@ 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; } @@ -15784,7 +15783,15 @@ 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 () { @@ -15814,6 +15821,44 @@ fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for is_pad" >&5 +$as_echo_n "checking for is_pad... " >&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 () +{ + + bool b; + WINDOW *w; + b = is_pad(w); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +$as_echo "#define HAVE_CURSES_IS_PAD 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$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 + { $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 : @@ -15821,7 +15866,15 @@ 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 () { @@ -15856,7 +15909,15 @@ $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 () { @@ -15882,7 +15943,15 @@ $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 () { @@ -15908,7 +15977,15 @@ $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 () { @@ -15930,7 +16007,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;} diff -r 8ea51c7d985f configure.ac --- a/configure.ac Sun Oct 09 14:54:12 2016 +0900 +++ b/configure.ac Sun Oct 09 22:11:26 2016 +0900 @@ -4910,10 +4910,7 @@ 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,,,[ @@ -4922,10 +4919,20 @@ #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); ]])], @@ -4939,9 +4946,21 @@ [Define if mvwdelch in curses.h is an expression.]) fi +AC_MSG_CHECKING(for is_pad) +AC_COMPILE_IFELSE([AC_LANG_CURSES_PROGRAM([[ + bool b; + WINDOW *w; + b = is_pad(w); + ]])], + [AC_DEFINE(HAVE_CURSES_IS_PAD, 1, + [Define if you have the 'is_pad' function or macro.]) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)] +) + 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; ]])], @@ -4957,27 +4976,26 @@ 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]) diff -r 8ea51c7d985f pyconfig.h.in --- a/pyconfig.h.in Sun Oct 09 14:54:12 2016 +0900 +++ b/pyconfig.h.in Sun Oct 09 22:11:26 2016 +0900 @@ -149,6 +149,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_CURSES_H +/* Define if you have the 'is_pad' function or macro. */ +#undef HAVE_CURSES_IS_PAD + /* Define if you have the 'is_term_resized' function. */ #undef HAVE_CURSES_IS_TERM_RESIZED @@ -631,9 +634,21 @@ /* 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 @@ -652,6 +667,9 @@ /* 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 diff -r 8ea51c7d985f setup.py --- a/setup.py Sun Oct 09 14:54:12 2016 +0900 +++ b/setup.py Sun Oct 09 22:11:26 2016 +0900 @@ -1351,7 +1351,6 @@ 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'