Commit baac01e6 authored by Serhiy Storchaka's avatar Serhiy Storchaka Committed by GitHub

bpo-31891: Fix building the curses module on NetBSD. (#4165)

parent 19f68301
...@@ -48,10 +48,6 @@ ...@@ -48,10 +48,6 @@
#include <ncurses.h> #include <ncurses.h>
#else #else
#include <curses.h> #include <curses.h>
#ifdef HAVE_TERM_H
/* for tigetstr, which is not declared in SysV curses */
#include <term.h>
#endif
#endif #endif
#ifdef HAVE_NCURSES_H #ifdef HAVE_NCURSES_H
......
...@@ -25,9 +25,12 @@ requires('curses') ...@@ -25,9 +25,12 @@ requires('curses')
# If either of these don't exist, skip the tests. # If either of these don't exist, skip the tests.
curses = import_module('curses') curses = import_module('curses')
import_module('curses.panel')
import_module('curses.ascii') import_module('curses.ascii')
import_module('curses.textpad') import_module('curses.textpad')
try:
import curses.panel
except ImportError:
pass
def requires_curses_func(name): def requires_curses_func(name):
return unittest.skipUnless(hasattr(curses, name), return unittest.skipUnless(hasattr(curses, name),
...@@ -138,6 +141,7 @@ class TestCurses(unittest.TestCase): ...@@ -138,6 +141,7 @@ class TestCurses(unittest.TestCase):
stdscr.idcok(1) stdscr.idcok(1)
stdscr.idlok(1) stdscr.idlok(1)
if hasattr(stdscr, 'immedok'):
stdscr.immedok(1) stdscr.immedok(1)
stdscr.insch('c') stdscr.insch('c')
stdscr.insdelln(1) stdscr.insdelln(1)
...@@ -172,6 +176,7 @@ class TestCurses(unittest.TestCase): ...@@ -172,6 +176,7 @@ class TestCurses(unittest.TestCase):
stdscr.setscrreg(10,15) stdscr.setscrreg(10,15)
win3 = stdscr.subwin(10,10) win3 = stdscr.subwin(10,10)
win3 = stdscr.subwin(10,10, 5,5) win3 = stdscr.subwin(10,10, 5,5)
if hasattr(stdscr, 'syncok'):
stdscr.syncok(1) stdscr.syncok(1)
stdscr.timeout(5) stdscr.timeout(5)
stdscr.touchline(5,5) stdscr.touchline(5,5)
...@@ -211,15 +216,19 @@ class TestCurses(unittest.TestCase): ...@@ -211,15 +216,19 @@ class TestCurses(unittest.TestCase):
"Test module-level functions" "Test module-level functions"
for func in [curses.baudrate, curses.beep, curses.can_change_color, for func in [curses.baudrate, curses.beep, curses.can_change_color,
curses.cbreak, curses.def_prog_mode, curses.doupdate, curses.cbreak, curses.def_prog_mode, curses.doupdate,
curses.filter, curses.flash, curses.flushinp, curses.flash, curses.flushinp,
curses.has_colors, curses.has_ic, curses.has_il, curses.has_colors, curses.has_ic, curses.has_il,
curses.isendwin, curses.killchar, curses.longname, curses.isendwin, curses.killchar, curses.longname,
curses.nocbreak, curses.noecho, curses.nonl, curses.nocbreak, curses.noecho, curses.nonl,
curses.noqiflush, curses.noraw, curses.noqiflush, curses.noraw,
curses.reset_prog_mode, curses.termattrs, curses.reset_prog_mode, curses.termattrs,
curses.termname, curses.erasechar, curses.getsyx]: curses.termname, curses.erasechar]:
with self.subTest(func=func.__qualname__): with self.subTest(func=func.__qualname__):
func() func()
if hasattr(curses, 'filter'):
curses.filter()
if hasattr(curses, 'getsyx'):
curses.getsyx()
# Functions that actually need arguments # Functions that actually need arguments
if curses.tigetstr("cnorm"): if curses.tigetstr("cnorm"):
...@@ -243,14 +252,17 @@ class TestCurses(unittest.TestCase): ...@@ -243,14 +252,17 @@ class TestCurses(unittest.TestCase):
curses.putp(b'abc') curses.putp(b'abc')
curses.qiflush() curses.qiflush()
curses.raw() ; curses.raw(1) curses.raw() ; curses.raw(1)
if hasattr(curses, 'setsyx'):
curses.setsyx(5,5) curses.setsyx(5,5)
curses.tigetflag('hc') curses.tigetflag('hc')
curses.tigetnum('co') curses.tigetnum('co')
curses.tigetstr('cr') curses.tigetstr('cr')
curses.tparm(b'cr') curses.tparm(b'cr')
if hasattr(curses, 'typeahead'):
curses.typeahead(sys.__stdin__.fileno()) curses.typeahead(sys.__stdin__.fileno())
curses.unctrl('a') curses.unctrl('a')
curses.ungetch('a') curses.ungetch('a')
if hasattr(curses, 'use_env'):
curses.use_env(1) curses.use_env(1)
# Functions only available on a few platforms # Functions only available on a few platforms
...@@ -285,6 +297,7 @@ class TestCurses(unittest.TestCase): ...@@ -285,6 +297,7 @@ class TestCurses(unittest.TestCase):
curses.ungetmouse(0, 0, 0, 0, curses.BUTTON1_PRESSED) curses.ungetmouse(0, 0, 0, 0, curses.BUTTON1_PRESSED)
m = curses.getmouse() m = curses.getmouse()
@requires_curses_func('panel')
def test_userptr_without_set(self): def test_userptr_without_set(self):
w = curses.newwin(10, 10) w = curses.newwin(10, 10)
p = curses.panel.new_panel(w) p = curses.panel.new_panel(w)
...@@ -293,6 +306,7 @@ class TestCurses(unittest.TestCase): ...@@ -293,6 +306,7 @@ class TestCurses(unittest.TestCase):
msg='userptr should fail since not set'): msg='userptr should fail since not set'):
p.userptr() p.userptr()
@requires_curses_func('panel')
def test_userptr_memory_leak(self): def test_userptr_memory_leak(self):
w = curses.newwin(10, 10) w = curses.newwin(10, 10)
p = curses.panel.new_panel(w) p = curses.panel.new_panel(w)
...@@ -305,6 +319,7 @@ class TestCurses(unittest.TestCase): ...@@ -305,6 +319,7 @@ class TestCurses(unittest.TestCase):
self.assertEqual(sys.getrefcount(obj), nrefs, self.assertEqual(sys.getrefcount(obj), nrefs,
"set_userptr leaked references") "set_userptr leaked references")
@requires_curses_func('panel')
def test_userptr_segfault(self): def test_userptr_segfault(self):
panel = curses.panel.new_panel(self.stdscr) panel = curses.panel.new_panel(self.stdscr)
class A: class A:
...@@ -313,6 +328,7 @@ class TestCurses(unittest.TestCase): ...@@ -313,6 +328,7 @@ class TestCurses(unittest.TestCase):
panel.set_userptr(A()) panel.set_userptr(A())
panel.set_userptr(None) panel.set_userptr(None)
@requires_curses_func('panel')
def test_new_curses_panel(self): def test_new_curses_panel(self):
panel = curses.panel.new_panel(self.stdscr) panel = curses.panel.new_panel(self.stdscr)
self.assertRaises(TypeError, type(panel)) self.assertRaises(TypeError, type(panel))
......
This diff is collapsed.
...@@ -15812,6 +15812,186 @@ else ...@@ -15812,6 +15812,186 @@ else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; } $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for immedok" >&5
$as_echo_n "checking for immedok... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <curses.h>
int
main ()
{
#ifndef immedok
void *x=immedok
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
$as_echo "#define HAVE_CURSES_IMMEDOK 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 for syncok" >&5
$as_echo_n "checking for syncok... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <curses.h>
int
main ()
{
#ifndef syncok
void *x=syncok
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
$as_echo "#define HAVE_CURSES_SYNCOK 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 for filter" >&5
$as_echo_n "checking for filter... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <curses.h>
int
main ()
{
#ifndef filter
void *x=filter
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
$as_echo "#define HAVE_CURSES_FILTER 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 for has_key" >&5
$as_echo_n "checking for has_key... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <curses.h>
int
main ()
{
#ifndef has_key
void *x=has_key
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
$as_echo "#define HAVE_CURSES_HAS_KEY 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 for typeahead" >&5
$as_echo_n "checking for typeahead... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <curses.h>
int
main ()
{
#ifndef typeahead
void *x=typeahead
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
$as_echo "#define HAVE_CURSES_TYPEAHEAD 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 for use_env" >&5
$as_echo_n "checking for use_env... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <curses.h>
int
main ()
{
#ifndef use_env
void *x=use_env
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
$as_echo "#define HAVE_CURSES_USE_ENV 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 fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
# last curses configure check # last curses configure check
......
...@@ -4992,6 +4992,72 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm ...@@ -4992,6 +4992,72 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm
AC_MSG_RESULT(yes)], AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)] [AC_MSG_RESULT(no)]
) )
AC_MSG_CHECKING(for immedok)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
#ifndef immedok
void *x=immedok
#endif
]])],
[AC_DEFINE(HAVE_CURSES_IMMEDOK, 1, Define if you have the 'immedok' function.)
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)]
)
AC_MSG_CHECKING(for syncok)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
#ifndef syncok
void *x=syncok
#endif
]])],
[AC_DEFINE(HAVE_CURSES_SYNCOK, 1, Define if you have the 'syncok' function.)
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)]
)
AC_MSG_CHECKING(for filter)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
#ifndef filter
void *x=filter
#endif
]])],
[AC_DEFINE(HAVE_CURSES_FILTER, 1, Define if you have the 'filter' function.)
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)]
)
AC_MSG_CHECKING(for has_key)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
#ifndef has_key
void *x=has_key
#endif
]])],
[AC_DEFINE(HAVE_CURSES_HAS_KEY, 1, Define if you have the 'has_key' function.)
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)]
)
AC_MSG_CHECKING(for typeahead)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
#ifndef typeahead
void *x=typeahead
#endif
]])],
[AC_DEFINE(HAVE_CURSES_TYPEAHEAD, 1, Define if you have the 'typeahead' function.)
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)]
)
AC_MSG_CHECKING(for use_env)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
#ifndef use_env
void *x=use_env
#endif
]])],
[AC_DEFINE(HAVE_CURSES_USE_ENV, 1, Define if you have the 'use_env' function.)
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)]
)
# last curses configure check # last curses configure check
CPPFLAGS=$ac_save_cppflags CPPFLAGS=$ac_save_cppflags
......
...@@ -146,9 +146,18 @@ ...@@ -146,9 +146,18 @@
/* Define if you have the 'ctermid_r' function. */ /* Define if you have the 'ctermid_r' function. */
#undef HAVE_CTERMID_R #undef HAVE_CTERMID_R
/* Define if you have the 'filter' function. */
#undef HAVE_CURSES_FILTER
/* Define to 1 if you have the <curses.h> header file. */ /* Define to 1 if you have the <curses.h> header file. */
#undef HAVE_CURSES_H #undef HAVE_CURSES_H
/* Define if you have the 'has_key' function. */
#undef HAVE_CURSES_HAS_KEY
/* Define if you have the 'immedok' function. */
#undef HAVE_CURSES_IMMEDOK
/* Define if you have the 'is_term_resized' function. */ /* Define if you have the 'is_term_resized' function. */
#undef HAVE_CURSES_IS_TERM_RESIZED #undef HAVE_CURSES_IS_TERM_RESIZED
...@@ -158,6 +167,15 @@ ...@@ -158,6 +167,15 @@
/* Define if you have the 'resize_term' function. */ /* Define if you have the 'resize_term' function. */
#undef HAVE_CURSES_RESIZE_TERM #undef HAVE_CURSES_RESIZE_TERM
/* Define if you have the 'syncok' function. */
#undef HAVE_CURSES_SYNCOK
/* Define if you have the 'typeahead' function. */
#undef HAVE_CURSES_TYPEAHEAD
/* Define if you have the 'use_env' function. */
#undef HAVE_CURSES_USE_ENV
/* Define to 1 if you have the declaration of `isfinite', and to 0 if you /* Define to 1 if you have the declaration of `isfinite', and to 0 if you
don't. */ don't. */
#undef HAVE_DECL_ISFINITE #undef HAVE_DECL_ISFINITE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment