diff -r fca5c4a63251 Include/py_curses.h --- a/Include/py_curses.h Thu Oct 06 14:32:10 2016 -0700 +++ b/Include/py_curses.h Fri Oct 07 22:19:10 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 @@ -57,9 +57,6 @@ #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 @@ -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 fca5c4a63251 Modules/_cursesmodule.c --- a/Modules/_cursesmodule.c Thu Oct 06 14:32:10 2016 -0700 +++ b/Modules/_cursesmodule.c Fri Oct 07 22:19:10 2016 +0900 @@ -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) { diff -r fca5c4a63251 configure --- a/configure Thu Oct 06 14:32:10 2016 -0700 +++ b/configure Fri Oct 07 22:19:10 2016 +0900 @@ -15814,6 +15814,37 @@ 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. */ +#include +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 : diff -r fca5c4a63251 configure.ac --- a/configure.ac Thu Oct 06 14:32:10 2016 -0700 +++ b/configure.ac Fri Oct 07 22:19:10 2016 +0900 @@ -4939,6 +4939,18 @@ [Define if mvwdelch in curses.h is an expression.]) fi +AC_MSG_CHECKING(for is_pad) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ + 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 ]], [[ diff -r fca5c4a63251 pyconfig.h.in --- a/pyconfig.h.in Thu Oct 06 14:32:10 2016 -0700 +++ b/pyconfig.h.in Fri Oct 07 22:19:10 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