From af3d0ee323cbb22d2a7596d564bf68f7307f5076 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sun, 18 Jun 2017 00:37:29 +0000 Subject: [PATCH 1/1] ncurses 6.0 - patch 20170617 + fill in some places where TERMTYPE2 vs TERMTYPE was not used (report by Allen Hewes). + use ExitTerminfo() internally in error-exits for ncurses' setupterm to help with leak checking. + use ExitProgram() in error-exit from initscr() to help with leak checking. + review test-programs, adding checks for cases where the terminal cannot be initialized. --- NEWS | 12 +++++++++++- VERSION | 2 +- dist.mk | 4 ++-- ncurses/base/lib_initscr.c | 4 ++-- ncurses/base/lib_mouse.c | 8 ++++---- ncurses/base/new_pair.c | 4 ++-- ncurses/curses.priv.h | 28 ++++++++++++++++++++++++---- ncurses/tinfo/lib_cur_term.c | 6 ++---- ncurses/tinfo/lib_setup.c | 16 +++++++++------- ncurses/tinfo/tinfo_driver.c | 15 +++++++++------ package/debian-mingw/changelog | 4 ++-- package/debian-mingw64/changelog | 4 ++-- package/debian/changelog | 4 ++-- package/mingw-ncurses.nsi | 4 ++-- package/mingw-ncurses.spec | 2 +- package/ncurses.spec | 2 +- test/bs.c | 4 ++-- test/demo_altkeys.c | 9 ++++++--- test/demo_new_pair.c | 8 +++++--- test/dots_mvcur.c | 9 ++++++--- test/filter.c | 9 ++++++--- test/foldkeys.c | 10 +++++++--- test/list_keys.c | 4 ++-- test/sp_tinfo.c | 19 +++++++++++-------- 24 files changed, 121 insertions(+), 70 deletions(-) diff --git a/NEWS b/NEWS index e158c539..0c0c33e7 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.2855 2017/06/10 22:10:46 tom Exp $ +-- $Id: NEWS,v 1.2859 2017/06/17 21:53:35 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,16 @@ See the AUTHORS file for the corresponding full names. Changes through 1.9.9e did not credit all contributions; it is not possible to add this information. +20170617 + + fill in some places where TERMTYPE2 vs TERMTYPE was not used + (report by Allen Hewes). + + use ExitTerminfo() internally in error-exits for ncurses' setupterm + to help with leak checking. + + use ExitProgram() in error-exit from initscr() to help with leak + checking. + + review test-programs, adding checks for cases where the terminal + cannot be initialized. + 20170610 + add option "-xp" to picsmap.c, to use init_extended_pair(). + make simple performance fixes for picsmap.c diff --git a/VERSION b/VERSION index 5b6dd1ba..df0fdb87 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5:0:9 6.0 20170610 +5:0:9 6.0 20170617 diff --git a/dist.mk b/dist.mk index afbaf93e..7d448017 100644 --- a/dist.mk +++ b/dist.mk @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.1167 2017/06/10 10:38:18 tom Exp $ +# $Id: dist.mk,v 1.1168 2017/06/17 18:17:23 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -37,7 +37,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 6 NCURSES_MINOR = 0 -NCURSES_PATCH = 20170610 +NCURSES_PATCH = 20170617 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/ncurses/base/lib_initscr.c b/ncurses/base/lib_initscr.c index c1851b04..e0a5c717 100644 --- a/ncurses/base/lib_initscr.c +++ b/ncurses/base/lib_initscr.c @@ -45,7 +45,7 @@ #include /* needed for ISC */ #endif -MODULE_ID("$Id: lib_initscr.c,v 1.42 2017/03/28 21:14:01 tom Exp $") +MODULE_ID("$Id: lib_initscr.c,v 1.43 2017/06/17 18:42:45 tom Exp $") NCURSES_EXPORT(WINDOW *) initscr(void) @@ -88,7 +88,7 @@ initscr(void) #endif if (newterm(name, stdout, stdin) == 0) { fprintf(stderr, "Error opening terminal: %s.\n", name); - exit(EXIT_FAILURE); + ExitProgram(EXIT_FAILURE); } /* def_shell_mode - done in newterm/_nc_setupscreen */ diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c index 01c7195b..61ec3c8b 100644 --- a/ncurses/base/lib_mouse.c +++ b/ncurses/base/lib_mouse.c @@ -84,7 +84,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_mouse.c,v 1.174 2017/06/10 23:27:20 tom Exp $") +MODULE_ID("$Id: lib_mouse.c,v 1.175 2017/06/17 22:05:15 tom Exp $") #include @@ -602,7 +602,7 @@ initialize_mousetype(SCREEN *sp) /* OS/2 VIO */ #if USE_EMX_MOUSE if (!sp->_emxmouse_thread - && strstr(TerminalOf(sp)->type.term_names, "xterm") == 0 + && strstr(SP_TERMTYPE term_names, "xterm") == 0 && key_mouse) { int handles[2]; @@ -716,10 +716,10 @@ initialize_mousetype(SCREEN *sp) /* we know how to recognize mouse events under "xterm" */ if (key_mouse != 0) { if (!strcmp(key_mouse, xterm_kmous) - || strstr(TerminalOf(sp)->type.term_names, "xterm") != 0) { + || strstr(SP_TERMTYPE term_names, "xterm") != 0) { init_xterm_mouse(sp); } - } else if (strstr(TerminalOf(sp)->type.term_names, "xterm") != 0) { + } else if (strstr(SP_TERMTYPE term_names, "xterm") != 0) { if (_nc_add_to_try(&(sp->_keytry), xterm_kmous, KEY_MOUSE) == OK) init_xterm_mouse(sp); } diff --git a/ncurses/base/new_pair.c b/ncurses/base/new_pair.c index 851e8f0a..8597fc4d 100644 --- a/ncurses/base/new_pair.c +++ b/ncurses/base/new_pair.c @@ -60,7 +60,7 @@ #endif -MODULE_ID("$Id: new_pair.c,v 1.10 2017/03/28 09:14:15 tom Exp $") +MODULE_ID("$Id: new_pair.c,v 1.11 2017/06/17 18:43:16 tom Exp $") #if USE_NEW_PAIR @@ -118,7 +118,7 @@ dumpit(SCREEN *sp, int pair, const char *tag) if (next_len(sp, 0) != prev_len(sp, 0)) { endwin(); - exit(1); + ExitProgram(EXIT_FAILURE); } } #else diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index f6c4879f..e4f62f69 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -34,7 +34,7 @@ ****************************************************************************/ /* - * $Id: curses.priv.h,v 1.573 2017/06/02 23:19:52 tom Exp $ + * $Id: curses.priv.h,v 1.575 2017/06/17 22:21:08 tom Exp $ * * curses.priv.h * @@ -394,6 +394,11 @@ color_t; #define TerminalType(tp) (tp)->type #endif +#ifdef CUR +#undef CUR +#define CUR TerminalType(cur_term). +#endif + /* * Reduce dependency on cur_term global by using terminfo data from SCREEN's * pointer to this data. @@ -402,7 +407,7 @@ color_t; #undef CUR #endif -#define SP_TERMTYPE TerminalOf(sp)->type. +#define SP_TERMTYPE TerminalType(TerminalOf(sp)). #include @@ -1918,6 +1923,14 @@ extern NCURSES_EXPORT(void) _nc_expanded (void); #define getcwd(buf,len) getwd(buf) #endif +#define save_ttytype(termp) \ + if (TerminalType(termp).term_names != 0) { \ + _nc_STRNCPY(ttytype, \ + TerminalType(termp).term_names, \ + NAMESIZE - 1); \ + ttytype[NAMESIZE - 1] = '\0'; \ + } + /* charable.c */ #if USE_WIDEC_SUPPORT extern NCURSES_EXPORT(bool) _nc_is_charable(wchar_t); @@ -2010,13 +2023,20 @@ extern NCURSES_EXPORT(void) _nc_tinfo_cmdch(TERMINAL *, int); extern NCURSES_EXPORT(int) _nc_ripoffline(int, int(*)(WINDOW*, int)); /* lib_setup.c */ +#if NO_LEAKS +#define ExitTerminfo(code) _nc_free_tinfo(code) +#else +#define ExitTerminfo(code) exit(code) +#endif + #define SETUP_FAIL ERR + #define ret_error(code, fmt, arg) if (errret) {\ *errret = code;\ returnCode(SETUP_FAIL);\ } else {\ fprintf(stderr, fmt, arg);\ - exit(EXIT_FAILURE);\ + ExitTerminfo(EXIT_FAILURE);\ } #define ret_error1(code, fmt, arg) ret_error(code, "'%s': " fmt, arg) @@ -2026,7 +2046,7 @@ extern NCURSES_EXPORT(int) _nc_ripoffline(int, int(*)(WINDOW*, int)); returnCode(SETUP_FAIL);\ } else {\ fprintf(stderr, msg);\ - exit(EXIT_FAILURE);\ + ExitTerminfo(EXIT_FAILURE);\ } /* lib_tstp.c */ diff --git a/ncurses/tinfo/lib_cur_term.c b/ncurses/tinfo/lib_cur_term.c index a61a6556..e5cd76bf 100644 --- a/ncurses/tinfo/lib_cur_term.c +++ b/ncurses/tinfo/lib_cur_term.c @@ -39,7 +39,7 @@ #include #include /* ospeed */ -MODULE_ID("$Id: lib_cur_term.c,v 1.40 2017/04/15 21:35:08 tom Exp $") +MODULE_ID("$Id: lib_cur_term.c,v 1.41 2017/06/17 22:21:35 tom Exp $") #undef CUR #define CUR TerminalType(termp). @@ -108,9 +108,7 @@ NCURSES_SP_NAME(set_curterm) (NCURSES_SP_DCLx TERMINAL *termp) } #endif #if !USE_REENTRANT -#define MY_SIZE (size_t) (NAMESIZE - 1) - _nc_STRNCPY(ttytype, TerminalType(termp).term_names, MY_SIZE); - ttytype[MY_SIZE] = '\0'; + save_ttytype(termp); #endif } _nc_unlock_global(curses); diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c index 67a2a0aa..93a42a04 100644 --- a/ncurses/tinfo/lib_setup.c +++ b/ncurses/tinfo/lib_setup.c @@ -48,7 +48,7 @@ #include #endif -MODULE_ID("$Id: lib_setup.c,v 1.178 2017/04/11 23:51:32 tom Exp $") +MODULE_ID("$Id: lib_setup.c,v 1.182 2017/06/17 22:21:50 tom Exp $") /**************************************************************************** * @@ -115,12 +115,12 @@ NCURSES_PUBLIC_VAR(ttytype) (void) if (CURRENT_SCREEN) { TERMINAL *termp = TerminalOf(CURRENT_SCREEN); if (termp != 0) { - result = termp->type.term_names; + result = TerminalType(termp).term_names; } } #else if (cur_term != 0) { - result = cur_term->type.term_names; + result = TerminalType(cur_term).term_names; } #endif return result; @@ -693,7 +693,7 @@ TINFO_SETUP_TERM(TERMINAL **tp, && termp->Filedes == Filedes && termp->_termname != 0 && !strcmp(termp->_termname, tname) - && _nc_name_match(termp->type.term_names, tname, "|")) { + && _nc_name_match(TerminalType(termp).term_names, tname, "|")) { T(("reusing existing terminal information and mode-settings")); code = OK; #ifdef USE_TERM_DRIVER @@ -721,6 +721,8 @@ TINFO_SETUP_TERM(TERMINAL **tp, termp->Filedes = (short) Filedes; termp->_termname = strdup(tname); } else { + _nc_free_termtype2(&TerminalType(termp)); + free(my_tcb); ret_error0(errret ? *errret : TGETENT_ERR, "Could not find any driver to handle this terminal.\n"); } @@ -744,8 +746,10 @@ TINFO_SETUP_TERM(TERMINAL **tp, if (status != TGETENT_YES) { del_curterm(termp); if (status == TGETENT_ERR) { + _nc_free_termtype2(&TerminalType(termp)); ret_error0(status, "terminals database is inaccessible\n"); } else if (status == TGETENT_NO) { + _nc_free_termtype2(&TerminalType(termp)); ret_error1(status, "unknown terminal type.\n", tname); } } @@ -753,9 +757,7 @@ TINFO_SETUP_TERM(TERMINAL **tp, _nc_export_termtype2(&termp->type, &TerminalType(termp)); #endif #if !USE_REENTRANT -#define MY_SIZE (size_t) (NAMESIZE - 1) - _nc_STRNCPY(ttytype, termp->type.term_names, MY_SIZE); - ttytype[MY_SIZE] = '\0'; + save_ttytype(termp); #endif termp->Filedes = (short) Filedes; diff --git a/ncurses/tinfo/tinfo_driver.c b/ncurses/tinfo/tinfo_driver.c index 21004732..8d471d18 100644 --- a/ncurses/tinfo/tinfo_driver.c +++ b/ncurses/tinfo/tinfo_driver.c @@ -51,7 +51,7 @@ # endif #endif -MODULE_ID("$Id: tinfo_driver.c,v 1.51 2017/04/14 08:19:49 tom Exp $") +MODULE_ID("$Id: tinfo_driver.c,v 1.54 2017/06/17 22:22:03 tom Exp $") /* * SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS, @@ -179,8 +179,10 @@ drv_CanHandle(TERMINAL_CONTROL_BLOCK * TCB, const char *tname, int *errret) if (status != TGETENT_YES) { NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx termp); if (status == TGETENT_ERR) { + _nc_free_termtype2(&TerminalType(termp)); ret_error0(status, "terminals database is inaccessible\n"); } else if (status == TGETENT_NO) { + _nc_free_termtype2(&TerminalType(termp)); ret_error1(status, "unknown terminal type.\n", tname); } } @@ -189,9 +191,7 @@ drv_CanHandle(TERMINAL_CONTROL_BLOCK * TCB, const char *tname, int *errret) _nc_export_termtype2(&termp->type, &TerminalType(termp)); #endif #if !USE_REENTRANT -#define MY_SIZE (size_t) NAMESIZE - 1 - _nc_STRNCPY(ttytype, termp->type.term_names, MY_SIZE); - ttytype[MY_SIZE] = '\0'; + save_ttytype(termp); #endif if (command_character) @@ -215,12 +215,15 @@ drv_CanHandle(TERMINAL_CONTROL_BLOCK * TCB, const char *tname, int *errret) if ((VALID_STRING(cursor_address) || (VALID_STRING(cursor_down) && VALID_STRING(cursor_home))) && VALID_STRING(clear_screen)) { + _nc_free_termtype2(&TerminalType(termp)); ret_error1(TGETENT_YES, "terminal is not really generic.\n", tname); } else { + _nc_free_termtype2(&TerminalType(termp)); ret_error1(TGETENT_NO, "I need something more specific.\n", tname); } } if (hard_copy) { + _nc_free_termtype2(&TerminalType(termp)); ret_error1(TGETENT_YES, "I can't handle hardcopy terminals.\n", tname); } @@ -887,10 +890,10 @@ drv_initmouse(TERMINAL_CONTROL_BLOCK * TCB) if (sp != 0) { if (key_mouse != 0) { if (!strcmp(key_mouse, xterm_kmous) - || strstr(TerminalOf(sp)->type.term_names, "xterm") != 0) { + || strstr(SP_TERMTYPE term_names, "xterm") != 0) { init_xterm_mouse(sp); } - } else if (strstr(TerminalOf(sp)->type.term_names, "xterm") != 0) { + } else if (strstr(SP_TERMTYPE term_names, "xterm") != 0) { if (_nc_add_to_try(&(sp->_keytry), xterm_kmous, KEY_MOUSE) == OK) init_xterm_mouse(sp); } diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog index edceaed7..1f234fac 100644 --- a/package/debian-mingw/changelog +++ b/package/debian-mingw/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.0+20170610) unstable; urgency=low +ncurses6 (6.0+20170617) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 10 Jun 2017 06:38:19 -0400 + -- Thomas E. Dickey Sat, 17 Jun 2017 14:17:23 -0400 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog index edceaed7..1f234fac 100644 --- a/package/debian-mingw64/changelog +++ b/package/debian-mingw64/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.0+20170610) unstable; urgency=low +ncurses6 (6.0+20170617) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 10 Jun 2017 06:38:19 -0400 + -- Thomas E. Dickey Sat, 17 Jun 2017 14:17:23 -0400 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian/changelog b/package/debian/changelog index e62bc966..aa223f1b 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.0+20170610) unstable; urgency=low +ncurses6 (6.0+20170617) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 10 Jun 2017 06:38:19 -0400 + -- Thomas E. Dickey Sat, 17 Jun 2017 14:17:23 -0400 ncurses6 (5.9-20120608) unstable; urgency=low diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi index 151e1898..b637b8e4 100644 --- a/package/mingw-ncurses.nsi +++ b/package/mingw-ncurses.nsi @@ -1,4 +1,4 @@ -; $Id: mingw-ncurses.nsi,v 1.215 2017/06/10 10:38:18 tom Exp $ +; $Id: mingw-ncurses.nsi,v 1.216 2017/06/17 18:17:23 tom Exp $ ; TODO add examples ; TODO bump ABI to 6 @@ -10,7 +10,7 @@ !define VERSION_MAJOR "6" !define VERSION_MINOR "0" !define VERSION_YYYY "2017" -!define VERSION_MMDD "0610" +!define VERSION_MMDD "0617" !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD} !define MY_ABI "5" diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec index 08db8d9c..be2a22d0 100644 --- a/package/mingw-ncurses.spec +++ b/package/mingw-ncurses.spec @@ -3,7 +3,7 @@ Summary: shared libraries for terminal handling Name: mingw32-ncurses6 Version: 6.0 -Release: 20170610 +Release: 20170617 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/package/ncurses.spec b/package/ncurses.spec index 8a704789..741ff1f2 100644 --- a/package/ncurses.spec +++ b/package/ncurses.spec @@ -1,7 +1,7 @@ Summary: shared libraries for terminal handling Name: ncurses6 Version: 6.0 -Release: 20170610 +Release: 20170617 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/test/bs.c b/test/bs.c index 7f298474..59597588 100644 --- a/test/bs.c +++ b/test/bs.c @@ -34,7 +34,7 @@ * v2.0 featuring strict ANSI/POSIX conformance, November 1993. * v2.1 with ncurses mouse support, September 1995 * - * $Id: bs.c,v 1.67 2017/05/14 00:27:05 tom Exp $ + * $Id: bs.c,v 1.68 2017/06/17 18:45:40 tom Exp $ */ #include @@ -220,6 +220,7 @@ intro(void) srand((unsigned) (time(0L) + getpid())); /* Kick the random number generator */ CATCHALL(uninitgame); + (void) initscr(); if ((tmpname = getlogin()) != 0 && (your_name = strdup(tmpname)) != 0) { @@ -228,7 +229,6 @@ intro(void) your_name = strdup(dftname); } - (void) initscr(); keypad(stdscr, TRUE); (void) def_prog_mode(); (void) nonl(); diff --git a/test/demo_altkeys.c b/test/demo_altkeys.c index 3dcb780b..a83a549d 100644 --- a/test/demo_altkeys.c +++ b/test/demo_altkeys.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2005-2010,2016 Free Software Foundation, Inc. * + * Copyright (c) 2005-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: demo_altkeys.c,v 1.10 2016/09/04 20:17:42 tom Exp $ + * $Id: demo_altkeys.c,v 1.11 2017/06/17 18:33:03 tom Exp $ * * Demonstrate the define_key() function. * Thomas Dickey - 2005/10/22 @@ -91,7 +91,10 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) unlink(MY_LOGFILE); - newterm(0, stdout, stdin); + if (newterm(0, stdout, stdin) == 0) { + fprintf(stderr, "Cannot initialize terminal\n"); + ExitProgram(EXIT_FAILURE); + } (void) cbreak(); /* take input chars one at a time, no wait for \n */ (void) noecho(); /* don't echo input */ diff --git a/test/demo_new_pair.c b/test/demo_new_pair.c index 1070c06a..8c29870b 100644 --- a/test/demo_new_pair.c +++ b/test/demo_new_pair.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: demo_new_pair.c,v 1.13 2017/04/15 17:36:00 tom Exp $ + * $Id: demo_new_pair.c,v 1.14 2017/06/17 19:48:45 tom Exp $ * * Demonstrate the alloc_pair() function. */ @@ -229,8 +229,10 @@ main(int argc, char *argv[]) fprintf(stderr, "cannot open terminal for output\n"); ExitProgram(EXIT_FAILURE); } - if (newterm(NULL, output, stdin) == 0) - usage(); + if (newterm(NULL, output, stdin) == 0) { + fprintf(stderr, "Cannot initialize terminal\n"); + ExitProgram(EXIT_FAILURE); + } (void) cbreak(); /* read chars without wait for \n */ (void) noecho(); /* don't echo input */ update_modes(); diff --git a/test/dots_mvcur.c b/test/dots_mvcur.c index 90b9c4e5..4812282e 100644 --- a/test/dots_mvcur.c +++ b/test/dots_mvcur.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2007-2009,2013 Free Software Foundation, Inc. * + * Copyright (c) 2007-2013,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,7 +29,7 @@ /* * Author: Thomas E. Dickey - 2007 * - * $Id: dots_mvcur.c,v 1.10 2013/09/28 22:44:18 tom Exp $ + * $Id: dots_mvcur.c,v 1.11 2017/06/17 18:25:30 tom Exp $ * * A simple demo of the terminfo interface, and mvcur. */ @@ -113,7 +113,10 @@ main(int argc GCC_UNUSED, CATCHALL(onsig); srand((unsigned) time(0)); - sp = newterm((char *) 0, stdout, stdin); + if ((sp = newterm((char *) 0, stdout, stdin)) == 0) { + fprintf(stderr, "Cannot initialize terminal\n"); + ExitProgram(EXIT_FAILURE); + } outs(clear_screen); outs(cursor_home); outs(cursor_invisible); diff --git a/test/filter.c b/test/filter.c index 90a74a6c..926ec6b8 100644 --- a/test/filter.c +++ b/test/filter.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2014,2016 Free Software Foundation, Inc. * + * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,7 +29,7 @@ /* * Author: Thomas E. Dickey 1998 * - * $Id: filter.c,v 1.28 2016/09/10 21:23:23 tom Exp $ + * $Id: filter.c,v 1.29 2017/06/17 18:16:39 tom Exp $ * * An example of the 'filter()' function in ncurses, this program prompts * for commands and executes them (like a command shell). It illustrates @@ -359,7 +359,10 @@ main(int argc, char *argv[]) if (i_option) { initscr(); } else { - (void) newterm((char *) 0, stdout, stdin); + if (newterm((char *) 0, stdout, stdin) == 0) { + fprintf(stderr, "cannot initialize terminal\n"); + ExitProgram(EXIT_FAILURE); + } } #ifdef NCURSES_VERSION if (a_option) { diff --git a/test/foldkeys.c b/test/foldkeys.c index 30d4b7df..f7ecfd97 100644 --- a/test/foldkeys.c +++ b/test/foldkeys.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2006,2016 Free Software Foundation, Inc. * + * Copyright (c) 2006-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,7 +29,7 @@ /* * Author: Thomas E. Dickey, 2006 * - * $Id: foldkeys.c,v 1.5 2016/09/04 20:49:06 tom Exp $ + * $Id: foldkeys.c,v 1.6 2017/06/17 19:36:33 tom Exp $ * * Demonstrate a method for altering key definitions at runtime. * @@ -209,9 +209,13 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) struct timeval current, previous; #endif + if (newterm(0, stdout, stdin) == 0) { + fprintf(stderr, "Cannot initialize terminal\n"); + ExitProgram(EXIT_FAILURE); + } + unlink(MY_LOGFILE); - newterm(0, stdout, stdin); (void) cbreak(); /* take input chars one at a time, no wait for \n */ (void) noecho(); /* don't echo input */ diff --git a/test/list_keys.c b/test/list_keys.c index 31c057a0..00460c2d 100644 --- a/test/list_keys.c +++ b/test/list_keys.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: list_keys.c,v 1.19 2017/04/08 22:57:26 tom Exp $ + * $Id: list_keys.c,v 1.20 2017/06/17 21:11:25 tom Exp $ * * Author: Thomas E Dickey * @@ -89,7 +89,7 @@ show_key(const char *name, bool show) { int width = 0; char buffer[10]; - NCURSES_CONST char *value = tigetstr(name); + NCURSES_CONST char *value = tigetstr((NCURSES_CONST char *) name); if (show && t_opt) fputc('"', stdout); diff --git a/test/sp_tinfo.c b/test/sp_tinfo.c index 1c20588a..a3e5c553 100644 --- a/test/sp_tinfo.c +++ b/test/sp_tinfo.c @@ -27,7 +27,7 @@ ****************************************************************************/ /* - * $Id: sp_tinfo.c,v 1.19 2017/05/13 23:19:04 tom Exp $ + * $Id: sp_tinfo.c,v 1.21 2017/06/17 21:19:25 tom Exp $ * * TOTO: add option for non-sp-funcs interface */ @@ -81,7 +81,7 @@ initialize(const char *name, FILE *output) tgetent_sp(result->sp, temp, name); free(temp); } else { - setupterm(name, fileno(output), &error); + setupterm((NCURSES_CONST char *) name, fileno(output), &error); } result->term = cur_term; @@ -100,13 +100,16 @@ show_flag(MYDATA * data, const char *name, int value) } } +#define TC_PARMS data->sp, (NCURSES_CONST char *)tc +#define TI_PARMS data->sp, (NCURSES_CONST char *)ti + static void show_cap_flag(MYDATA * data, const char *ti, const char *tc) { const char *name = (opt_t ? tc : ti); show_flag(data, name, (opt_t - ? tgetflag_sp(data->sp, tc) - : tigetflag_sp(data->sp, ti))); + ? tgetflag_sp(TC_PARMS) + : tigetflag_sp(TI_PARMS))); } static void @@ -126,8 +129,8 @@ show_cap_number(MYDATA * data, const char *ti, const char *tc) { const char *name = (opt_t ? tc : ti); show_number(data, name, (opt_t - ? tgetnum_sp(data->sp, tc) - : tigetnum_sp(data->sp, ti))); + ? tgetnum_sp(TC_PARMS) + : tigetnum_sp(TI_PARMS))); } static void @@ -162,8 +165,8 @@ show_cap_string(MYDATA * data, const char *ti, const char *tc) char tcapjunk[1024]; char *tcap_ptr = tcapjunk; show_string(data, name, (opt_t - ? tgetstr_sp(data->sp, tc, &tcap_ptr) - : tigetstr_sp(data->sp, ti))); + ? tgetstr_sp(TC_PARMS, &tcap_ptr) + : tigetstr_sp(TI_PARMS))); } static void -- 2.44.0