From: Thomas E. Dickey Date: Sun, 9 Dec 2012 01:53:49 +0000 (+0000) Subject: ncurses 5.9 - patch 20121208 X-Git-Tag: v6.0~125 X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=commitdiff_plain;h=64f44b13d30e0a7bc2921a9d43755423f81564fd ncurses 5.9 - patch 20121208 + modify test/knight.c to show the number of choices possible for each position in automove option, e.g., to allow user to follow Warnsdorff's rule to solve the puzzle. + modify test/hanoi.c to show the minimum number of moves possible for the given number of tiles (prompted by patch by Lucas Gioia). > fixes based on Coverity report: + remove a few redundant checks. + correct logic in test/bs.c, when randomly placing a specific type of ship. + check return value from remove/unlink in tic. + check return value from sscanf in test/ncurses.c + fix a null dereference in c++/cursesw.cc + fix two instances of uninitialized variables when configuring for the terminal driver. + correct scope of variable used in SetSafeOutcWrapper macro. + set umask when calling mkstemp in tic. + initialize wbkgrndset() temporary variable when extended-colors are used. --- diff --git a/NEWS b/NEWS index 442fe3fc..0d840d40 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.1979 2012/12/02 01:51:32 tom Exp $ +-- $Id: NEWS,v 1.1992 2012/12/09 00:24:36 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,26 @@ 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. +20121208 + + modify test/knight.c to show the number of choices possible for + each position in automove option, e.g., to allow user to follow + Warnsdorff's rule to solve the puzzle. + + modify test/hanoi.c to show the minimum number of moves possible for + the given number of tiles (prompted by patch by Lucas Gioia). + > fixes based on Coverity report: + + remove a few redundant checks. + + correct logic in test/bs.c, when randomly placing a specific type of + ship. + + check return value from remove/unlink in tic. + + check return value from sscanf in test/ncurses.c + + fix a null dereference in c++/cursesw.cc + + fix two instances of uninitialized variables when configuring for the + terminal driver. + + correct scope of variable used in SetSafeOutcWrapper macro. + + set umask when calling mkstemp in tic. + + initialize wbkgrndset() temporary variable when extended-colors are + used. + 20121201 + also replace MinGW's wctomb(), fixing a problem with setcchar(). + modify test/view.c to load UTF-8 when built with MinGW by using diff --git a/c++/cursespad.cc b/c++/cursespad.cc index b5690a3e..11b42515 100644 --- a/c++/cursespad.cc +++ b/c++/cursespad.cc @@ -1,6 +1,6 @@ // * this is for making emacs happy: -*-Mode: C++;-*- /**************************************************************************** - * Copyright (c) 1998-2008,2011 Free Software Foundation, Inc. * + * Copyright (c) 1998-2011,2012 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 * @@ -36,7 +36,7 @@ #include #include -MODULE_ID("$Id: cursespad.cc,v 1.14 2011/09/17 22:12:10 tom Exp $") +MODULE_ID("$Id: cursespad.cc,v 1.16 2012/12/09 00:58:06 tom Exp $") NCursesPad::NCursesPad(int nlines, int ncols) : NCursesWindow(), @@ -229,25 +229,45 @@ void NCursesFramedPad::OnOperation(int pad_req) int Height = W->height(); int i, row, col, h_len, v_len; - h_len = (Width*Width + width() - 1)/width(); - if (h_len==0) + int my_width = width(); + + if (my_width != 0) { + h_len = (Width*Width + my_width - 1) / my_width; + if (h_len==0) + h_len = 1; + if (h_len > Width) + h_len = Width; + } else { h_len = 1; - if (h_len > Width) - h_len = Width; + } + + int my_height = height(); - v_len = (Height*Height + height() - 1)/height(); - if (v_len==0) + if (my_height != 0) { + v_len = (Height*Height + my_height - 1) / my_height; + if (v_len==0) + v_len = 1; + if (v_len > Height) + v_len = Height; + } else { v_len = 1; - if (v_len > Height) - v_len = Height; + } - col = (min_col * Width + width() - 1) / width(); - if (col + h_len > Width) - col = Width - h_len; + if (my_width != 0) { + col = (min_col * Width + my_width - 1) / my_width; + if (col + h_len > Width) + col = Width - h_len; + } else { + col = 0; + } - row = (min_row * Height + height() - 1) / height(); - if (row + v_len > Height) - row = Height - v_len; + if (my_height != 0) { + row = (min_row * Height + my_height - 1) / my_height; + if (row + v_len > Height) + row = Height - v_len; + } else { + row = 0; + } W2->vline(1,Width+1,Height); W2->attron(A_REVERSE); diff --git a/c++/cursesw.cc b/c++/cursesw.cc index f2e7e948..adbcf6e7 100644 --- a/c++/cursesw.cc +++ b/c++/cursesw.cc @@ -1,6 +1,6 @@ // * this is for making emacs happy: -*-Mode: C++;-*- /**************************************************************************** - * Copyright (c) 2007-2009,2011 Free Software Foundation, Inc. * + * Copyright (c) 2007-2011,2012 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 * @@ -42,7 +42,7 @@ #include "internal.h" #include "cursesw.h" -MODULE_ID("$Id: cursesw.cc,v 1.52 2011/09/17 22:12:10 tom Exp $") +MODULE_ID("$Id: cursesw.cc,v 1.53 2012/12/08 22:06:41 tom Exp $") #define COLORS_NEED_INITIALIZATION -1 #define COLORS_NOT_INITIALIZED 0 @@ -192,7 +192,6 @@ NCursesWindow::NCursesWindow() constructing(); w = static_cast(0); - set_keyboard(); } NCursesWindow::NCursesWindow(int nlines, int ncols, int begin_y, int begin_x) diff --git a/dist.mk b/dist.mk index c7160572..24e594b1 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.903 2012/12/01 18:22:40 tom Exp $ +# $Id: dist.mk,v 1.904 2012/12/08 15:04:46 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 = 5 NCURSES_MINOR = 9 -NCURSES_PATCH = 20121201 +NCURSES_PATCH = 20121208 # 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_bkgd.c b/ncurses/base/lib_bkgd.c index 2150279f..7bcd3ffb 100644 --- a/ncurses/base/lib_bkgd.c +++ b/ncurses/base/lib_bkgd.c @@ -36,7 +36,7 @@ #include -MODULE_ID("$Id: lib_bkgd.c,v 1.45 2012/03/10 21:20:18 tom Exp $") +MODULE_ID("$Id: lib_bkgd.c,v 1.48 2012/12/09 01:01:19 tom Exp $") /* * Set the window's background information. @@ -85,6 +85,7 @@ wbkgrndset(WINDOW *win, const ARG_CH_T ch) cchar_t wch; int tmp; + memset(&wch, 0, sizeof(wch)); (void) wgetbkgrnd(win, &wch); tmp = _nc_to_char((wint_t) CharOf(wch)); @@ -124,6 +125,8 @@ wbkgrnd(WINDOW *win, const ARG_CH_T ch) if (win) { NCURSES_CH_T new_bkgd = CHDEREF(ch); NCURSES_CH_T old_bkgrnd; + + memset(&old_bkgrnd, 0, sizeof(old_bkgrnd)); wgetbkgrnd(win, &old_bkgrnd); (void) wbkgrndset(win, CHREF(new_bkgd)); diff --git a/ncurses/base/lib_restart.c b/ncurses/base/lib_restart.c index c45023d3..3a3756e3 100644 --- a/ncurses/base/lib_restart.c +++ b/ncurses/base/lib_restart.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2009,2011 Free Software Foundation, Inc. * + * Copyright (c) 1998-2011,2012 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 * @@ -41,7 +41,7 @@ #include -MODULE_ID("$Id: lib_restart.c,v 1.14 2011/04/16 16:42:10 tom Exp $") +MODULE_ID("$Id: lib_restart.c,v 1.15 2012/12/08 20:40:06 tom Exp $") NCURSES_EXPORT(int) NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx @@ -51,7 +51,7 @@ NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx { int result; #ifdef USE_TERM_DRIVER - TERMINAL *new_term; + TERMINAL *new_term = 0; #endif T((T_CALLED("restartterm(%p,%s,%d,%p)"), diff --git a/ncurses/base/lib_slkrefr.c b/ncurses/base/lib_slkrefr.c index 1635c7f4..2cdc89cc 100644 --- a/ncurses/base/lib_slkrefr.c +++ b/ncurses/base/lib_slkrefr.c @@ -43,7 +43,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_slkrefr.c,v 1.27 2012/06/09 20:29:33 tom Exp $") +MODULE_ID("$Id: lib_slkrefr.c,v 1.28 2012/12/08 22:31:14 tom Exp $") #ifdef USE_TERM_DRIVER #define NumLabels InfoOf(SP_PARM).numlabels @@ -108,9 +108,7 @@ slk_intern_refresh(SCREEN *sp) if (fmt == 4) slk_paint_info(slk->win); wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x); - if (sp->_slk) { - (void) wattrset(slk->win, (int) AttrOf(sp->_slk->attr)); - } + (void) wattrset(slk->win, (int) AttrOf(slk->attr)); waddstr(slk->win, slk->ent[i].form_text); /* if we simulate SLK's, it's looking much more natural to use the current ATTRIBUTE also diff --git a/ncurses/base/lib_slkset.c b/ncurses/base/lib_slkset.c index ca662668..9091e001 100644 --- a/ncurses/base/lib_slkset.c +++ b/ncurses/base/lib_slkset.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. * + * Copyright (c) 1998-2011,2012 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 * @@ -44,13 +44,13 @@ #endif #endif -MODULE_ID("$Id: lib_slkset.c,v 1.22 2011/10/22 16:58:26 tom Exp $") +MODULE_ID("$Id: lib_slkset.c,v 1.24 2012/12/08 23:09:25 tom Exp $") NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_set) (NCURSES_SP_DCLx int i, const char *astr, int format) { SLK *slk; - int offset; + int offset = 0; int numchrs; int numcols; int limit; @@ -117,7 +117,6 @@ NCURSES_SP_NAME(slk_set) (NCURSES_SP_DCLx int i, const char *astr, int format) returnCode(ERR); switch (format) { - default: case 0: /* left-justified */ offset = 0; break; diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index 3165d83c..940dddf4 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -34,7 +34,7 @@ ****************************************************************************/ /* - * $Id: curses.priv.h,v 1.511 2012/12/02 01:41:23 tom Exp $ + * $Id: curses.priv.h,v 1.512 2012/12/08 20:19:40 tom Exp $ * * curses.priv.h * @@ -2159,9 +2159,9 @@ extern NCURSES_EXPORT(int) _nc_get_tty_mode(TTY *); #define SetSafeOutcWrapper(outc) \ SCREEN* sp = CURRENT_SCREEN; \ + struct screen outc_wrapper; \ if (sp==0) { \ - struct screen dummy; \ - sp = &dummy; \ + sp = &outc_wrapper; \ memset(sp,0,sizeof(struct screen)); \ sp->_outch = _nc_outc_wrapper; \ }\ diff --git a/ncurses/tinfo/comp_scan.c b/ncurses/tinfo/comp_scan.c index 058cf9ab..2a9aa563 100644 --- a/ncurses/tinfo/comp_scan.c +++ b/ncurses/tinfo/comp_scan.c @@ -50,7 +50,7 @@ #include #include -MODULE_ID("$Id: comp_scan.c,v 1.100 2012/04/29 00:20:51 tom Exp $") +MODULE_ID("$Id: comp_scan.c,v 1.101 2012/12/08 22:19:25 tom Exp $") /* * Maximum length of string capability we'll accept before raising an error. @@ -380,7 +380,7 @@ _nc_get_token(bool silent) if (end_of_stream()) { yyin = 0; - next_char(); /* frees its allocated memory */ + (void) next_char(); /* frees its allocated memory */ if (tok_buf != 0) { if (_nc_curr_token.tk_name == tok_buf) _nc_curr_token.tk_name = 0; diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c index 83742d5b..9467b7df 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.151 2012/11/18 00:24:56 tom Exp $") +MODULE_ID("$Id: lib_setup.c,v 1.154 2012/12/08 22:01:26 tom Exp $") /**************************************************************************** * @@ -438,8 +438,7 @@ _nc_update_screensize(SCREEN *sp) * We're doing it this way because those functions belong to the upper * ncurses library, while this resides in the lower terminfo library. */ - if (sp != 0 - && sp->_resize != 0) { + if (sp->_resize != 0) { if ((new_lines != old_lines) || (new_cols != old_cols)) { sp->_resize(NCURSES_SP_ARGx new_lines, new_cols); } else if (sp->_sig_winch && (sp->_ungetch != 0)) { @@ -683,6 +682,9 @@ TINFO_SETUP_TERM(TERMINAL ** tp, && _nc_name_match(termp->type.term_names, tname, "|")) { T(("reusing existing terminal information and mode-settings")); code = OK; +#ifdef USE_TERM_DRIVER + TCB = (TERMINAL_CONTROL_BLOCK *) termp; +#endif } else { #ifdef USE_TERM_DRIVER termp = (TERMINAL *) typeCalloc(TERMINAL_CONTROL_BLOCK, 1); @@ -845,7 +847,7 @@ _nc_setupterm(NCURSES_CONST char *tname, int reuse) { int res; - TERMINAL *termp; + TERMINAL *termp = 0; res = TINFO_SETUP_TERM(&termp, tname, Filedes, errret, reuse); if (ERR != res) NCURSES_SP_NAME(set_curterm) (CURRENT_SCREEN_PRE, termp); diff --git a/ncurses/tinfo/lib_tputs.c b/ncurses/tinfo/lib_tputs.c index 5c50500b..586f2cd0 100644 --- a/ncurses/tinfo/lib_tputs.c +++ b/ncurses/tinfo/lib_tputs.c @@ -51,7 +51,7 @@ #include /* ospeed */ #include -MODULE_ID("$Id: lib_tputs.c,v 1.87 2012/09/01 23:34:17 tom Exp $") +MODULE_ID("$Id: lib_tputs.c,v 1.88 2012/12/08 20:01:20 tom Exp $") NCURSES_EXPORT_VAR(char) PC = 0; /* used by termcap library */ NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0; /* used by termcap library */ @@ -127,7 +127,7 @@ NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_DCL0) * our amount. */ SP->out_inuse = 0; - (void) write(SP_PARM->_ofd, SP_PARM->out_buffer, amount); + IGNORE_RC(write(SP_PARM->_ofd, SP_PARM->out_buffer, amount)); } } } diff --git a/package/debian/changelog b/package/debian/changelog index d3ec2d69..1a041ffa 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,8 +1,8 @@ -ncurses6 (5.9-20121201) unstable; urgency=low +ncurses6 (5.9-20121208) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 01 Dec 2012 13:28:31 -0500 + -- Thomas E. Dickey Sat, 08 Dec 2012 10:12:21 -0500 ncurses6 (5.9-20120608) unstable; urgency=low diff --git a/package/ncurses.spec b/package/ncurses.spec index bcb3cba9..50f411bd 100644 --- a/package/ncurses.spec +++ b/package/ncurses.spec @@ -1,7 +1,7 @@ Summary: shared libraries for terminal handling Name: ncurses6 Release: 5.9 -Version: 20121201 +Version: 20121208 License: X11 Group: Development/Libraries Source: ncurses-%{release}-%{version}.tgz diff --git a/progs/tic.c b/progs/tic.c index 6128e330..717a1fb3 100644 --- a/progs/tic.c +++ b/progs/tic.c @@ -46,7 +46,7 @@ #include #include -MODULE_ID("$Id: tic.c,v 1.178 2012/10/27 19:57:21 tom Exp $") +MODULE_ID("$Id: tic.c,v 1.180 2012/12/08 22:17:22 tom Exp $") #define STDIN_NAME "" @@ -108,6 +108,8 @@ free_namelist(char **src) static void cleanup(void) { + int rc; + #if NO_LEAKS free_namelist(namelst); #endif @@ -115,10 +117,12 @@ cleanup(void) fclose(tmp_fp); if (to_remove != 0) { #if HAVE_REMOVE - remove(to_remove); + rc = remove(to_remove); #else - unlink(to_remove); + rc = unlink(to_remove); #endif + if (rc != 0) + perror(to_remove); } } @@ -376,9 +380,11 @@ open_tempfile(char *filename) _nc_STRCPY(filename, "/tmp/XXXXXX", PATH_MAX); #if HAVE_MKSTEMP { + int oldmask = umask(077); int fd = mkstemp(filename); if (fd >= 0) result = fdopen(fd, "w"); + umask(oldmask); } #else if (tmpnam(filename) != 0) diff --git a/test/bs.c b/test/bs.c index 53a4df76..f8784853 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.54 2012/11/18 00:57:48 tom Exp $ + * $Id: bs.c,v 1.56 2012/12/08 23:35:58 tom Exp $ */ #include @@ -426,10 +426,11 @@ initgame(void) placeship(COMPUTER, ss, FALSE); } - ss = (ship_t *) NULL; do { char c, docked[SHIPTYPES + 2], *cp = docked; + ss = (ship_t *) NULL; + /* figure which ships still wait to be placed */ *cp++ = 'R'; for (i = 0; i < SHIPTYPES; i++) @@ -459,13 +460,14 @@ initgame(void) do { c = (char) getch(); } while - (!(strchr("hjklrR", c) || c == FF)); + (!(strchr("hjkl8462rR", c) || c == FF)); if (c == FF) { (void) clearok(stdscr, TRUE); (void) refresh(); + } else if (ss == 0) { + beep(); /* simple to verify, unlikely to happen */ } else if (c == 'r') { - assert(ss != 0); prompt(1, "Random-placing your %s", ss->name); randomplace(PLAYER, ss); placeship(PLAYER, ss, TRUE); @@ -481,7 +483,6 @@ initgame(void) } error((char *) NULL); } else if (strchr("hjkl8462", c)) { - assert(ss != 0); ss->x = curx; ss->y = cury; diff --git a/test/hanoi.c b/test/hanoi.c index 02eade7c..4e4e7051 100644 --- a/test/hanoi.c +++ b/test/hanoi.c @@ -41,10 +41,11 @@ * * Date: 05.Nov.90 * - * $Id: hanoi.c,v 1.32 2012/06/09 20:30:32 tom Exp $ + * $Id: hanoi.c,v 1.34 2012/12/08 16:41:56 tom Exp $ */ #include +#include #define NPEGS 3 /* This is not configurable !! */ #define MINTILES 3 @@ -84,10 +85,11 @@ static short TileColour[] = COLOR_MAGENTA, /* Length 17 */ COLOR_RED, /* Length 19 */ }; +static int NTiles = 0; static int NMoves = 0; static bool AutoFlag = FALSE; -static void InitTiles(int NTiles); +static void InitTiles(void); static void DisplayTiles(void); static void MakeMove(int From, int To); static void AutoMove(int From, int To, int Num); @@ -99,7 +101,7 @@ static int InvalidMove(int From, int To); int main(int argc, char **argv) { - int NTiles, FromCol, ToCol; + int FromCol, ToCol; setlocale(LC_ALL, ""); @@ -130,9 +132,6 @@ main(int argc, char **argv) Usage(); ExitProgram(EXIT_FAILURE); } -#ifdef TRACE - trace(TRACE_MAXIMUM); -#endif initscr(); if (has_colors()) { int i; @@ -155,7 +154,7 @@ main(int argc, char **argv) curs_set(0); leaveok(stdscr, TRUE); /* Attempt to remove cursor */ } - InitTiles(NTiles); + InitTiles(); DisplayTiles(); if (AutoFlag) { do { @@ -211,7 +210,7 @@ InvalidMove(int From, int To) } static void -InitTiles(int NTiles) +InitTiles(void) { int Size, SlotNo; @@ -232,7 +231,7 @@ DisplayTiles(void) erase(); MvAddStr(1, 24, "T O W E R S O F H A N O I"); MvAddStr(3, 34, "SJR 1990"); - MvPrintw(19, 5, "Moves : %d", NMoves); + MvPrintw(19, 5, "Moves : %d of %.0f", NMoves, pow(2.0, NTiles) - 1); (void) attrset(A_REVERSE); MvAddStr(BASELINE, 8, " "); @@ -310,12 +309,12 @@ AutoMove(int From, int To, int Num) if (Num == 1) { MakeMove(From, To); napms(500); - return; + } else { + AutoMove(From, OTHER(From, To), Num - 1); + MakeMove(From, To); + napms(500); + AutoMove(OTHER(From, To), To, Num - 1); } - AutoMove(From, OTHER(From, To), Num - 1); - MakeMove(From, To); - napms(500); - AutoMove(OTHER(From, To), To, Num - 1); } static int diff --git a/test/ins_wide.c b/test/ins_wide.c index 07af7eda..6e4e7275 100644 --- a/test/ins_wide.c +++ b/test/ins_wide.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: ins_wide.c,v 1.18 2012/11/24 19:57:17 tom Exp $ + * $Id: ins_wide.c,v 1.19 2012/12/09 01:13:56 tom Exp $ * * Demonstrate the wins_wstr() and wins_wch functions. * Thomas Dickey - 2002/11/23 @@ -442,10 +442,10 @@ test_inserts(int level) } } if (level > 0) { - delwin(show); delwin(work); delwin(look); } + delwin(show); } static void diff --git a/test/inserts.c b/test/inserts.c index b858668a..ffac3336 100644 --- a/test/inserts.c +++ b/test/inserts.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: inserts.c,v 1.25 2012/11/24 19:57:17 tom Exp $ + * $Id: inserts.c,v 1.26 2012/12/09 00:51:51 tom Exp $ * * Demonstrate the winsstr() and winsch functions. * Thomas Dickey - 2002/10/19 @@ -371,10 +371,10 @@ test_inserts(int level) } } if (level > 0) { - delwin(show); delwin(work); delwin(look); } + delwin(show); } static void diff --git a/test/knight.c b/test/knight.c index 2835cd8b..604be1ec 100644 --- a/test/knight.c +++ b/test/knight.c @@ -33,7 +33,7 @@ * Eric S. Raymond July 22 1995. Mouse support * added September 20th 1995. * - * $Id: knight.c,v 1.32 2012/11/17 23:46:31 tom Exp $ + * $Id: knight.c,v 1.33 2012/12/09 00:14:28 tom Exp $ */ #include @@ -300,7 +300,7 @@ mark_possibles(int prow, int pcol, chtype mark) } } -static void +static bool find_next_move(int *y, int *x) { unsigned j, k; @@ -309,6 +309,7 @@ find_next_move(int *y, int *x) int next = 0; int oldy, oldx; int newy, newx; + bool result = FALSE; if (movecount > 1) { oldy = history[movecount - 1].y; @@ -335,9 +336,27 @@ find_next_move(int *y, int *x) *y = oldy + offsets[next].y; *x = oldx + offsets[next].x; } - } else { - beep(); + result = TRUE; } + return result; +} + +static void +count_next_moves(int y, int x) +{ + int count = 0; + unsigned j; + + wprintw(msgwin, "\nMove %d", movecount); + for (j = 0; j < SIZEOF(offsets); j++) { + int newy = y + offsets[j].y; + int newx = x + offsets[j].x; + if (chksqr(newy, newx)) { + ++count; + } + } + wprintw(msgwin, ", gives %d choices", count); + wclrtoeol(msgwin); } static void @@ -652,7 +671,10 @@ play(void) case 'a': nx = col; ny = rw; - find_next_move(&ny, &nx); + if (find_next_move(&ny, &nx)) + count_next_moves(ny, nx); + else + beep(); break; case 'F': diff --git a/test/ncurses.c b/test/ncurses.c index 326c747c..9810bce3 100644 --- a/test/ncurses.c +++ b/test/ncurses.c @@ -40,7 +40,7 @@ AUTHOR Author: Eric S. Raymond 1993 Thomas E. Dickey (beginning revision 1.27 in 1996). -$Id: ncurses.c,v 1.379 2012/11/18 00:56:44 tom Exp $ +$Id: ncurses.c,v 1.382 2012/12/09 00:56:24 tom Exp $ ***************************************************************************/ @@ -2244,7 +2244,7 @@ wide_color_test(void) if (row >= 0 && move(row, col) != ERR) { init_pair(pair, InxToFG(i), InxToBG(i)); - color_set(pair, NULL); + (void) color_set(pair, NULL); if (opt_acsc) attr_on((attr_t) A_ALTCHARSET, NULL); if (opt_bold) @@ -4244,7 +4244,8 @@ getwindow(void) outerbox(ul, lr, TRUE); refresh(); - wrefresh(rwindow); + if (rwindow != 0) + wrefresh(rwindow); move(0, 0); clrtoeol(); @@ -6826,7 +6827,14 @@ main(int argc, char *argv[]) #ifdef NCURSES_VERSION case 'a': assumed_colors = TRUE; - sscanf(optarg, "%d,%d", &default_fg, &default_bg); + switch (sscanf(optarg, "%d,%d", &default_fg, &default_bg)) { + case 0: + default_fg = COLOR_WHITE; + /* FALLTHRU */ + case 1: + default_bg = COLOR_BLACK; + break; + } break; case 'd': default_colors = TRUE; diff --git a/test/redraw.c b/test/redraw.c index 96c6b0f3..9cb0de95 100644 --- a/test/redraw.c +++ b/test/redraw.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2006-2010,2011 Free Software Foundation, Inc. * + * Copyright (c) 2006-2011,2012 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: redraw.c,v 1.7 2011/05/21 18:38:35 tom Exp $ + * $Id: redraw.c,v 1.8 2012/12/08 20:46:02 tom Exp $ * * Demonstrate the redrawwin() and wredrawln() functions. * Thomas Dickey - 2006/11/4 @@ -71,7 +71,7 @@ test_redraw(WINDOW *win) keypad(win, TRUE); getmaxyx(win, max_y, max_x); getbegyx(win, beg_y, beg_x); - while (!done && win != 0) { + while (!done) { ch = wgetch(win); getyx(win, y, x); switch (ch) { diff --git a/test/test_addchstr.c b/test/test_addchstr.c index cc3dc497..abb4380a 100644 --- a/test/test_addchstr.c +++ b/test/test_addchstr.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: test_addchstr.c,v 1.16 2012/11/24 19:51:05 tom Exp $ + * $Id: test_addchstr.c,v 1.17 2012/12/09 00:50:39 tom Exp $ * * Demonstrate the waddchstr() and waddch functions. * Thomas Dickey - 2009/9/12 @@ -450,10 +450,10 @@ test_adds(int level) } } if (level > 0) { - delwin(show); delwin(work); delwin(look); } + delwin(show); } static void