]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 5.9 - patch 20121208
authorThomas E. Dickey <dickey@invisible-island.net>
Sun, 9 Dec 2012 01:53:49 +0000 (01:53 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sun, 9 Dec 2012 01:53:49 +0000 (01:53 +0000)
+ 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.

23 files changed:
NEWS
c++/cursespad.cc
c++/cursesw.cc
dist.mk
ncurses/base/lib_bkgd.c
ncurses/base/lib_restart.c
ncurses/base/lib_slkrefr.c
ncurses/base/lib_slkset.c
ncurses/curses.priv.h
ncurses/tinfo/comp_scan.c
ncurses/tinfo/lib_setup.c
ncurses/tinfo/lib_tputs.c
package/debian/changelog
package/ncurses.spec
progs/tic.c
test/bs.c
test/hanoi.c
test/ins_wide.c
test/inserts.c
test/knight.c
test/ncurses.c
test/redraw.c
test/test_addchstr.c

diff --git a/NEWS b/NEWS
index 442fe3fc71e8bab0f311d1d60aac172d238797ea..0d840d404be1dbe0e50ed771081bec62df5c7edd 100644 (file)
--- 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
index b5690a3e303a2dadba12ef8ce8874cc751cba816..11b42515a4674ffba0f15f5d491de17741bb4ed4 100644 (file)
@@ -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 <etip.h>
 #include <cursesw.h>
 
-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);
index f2e7e94858aa4b16077a10412ae699ebe390cb90..adbcf6e71ef053f350051a68c54aa8ccbffc867a 100644 (file)
@@ -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<WINDOW *>(0);
-    set_keyboard();
 }
 
 NCursesWindow::NCursesWindow(int nlines, int ncols, int begin_y, int begin_x)
diff --git a/dist.mk b/dist.mk
index c7160572bcae95ff883769d9189fc55c3770e5ad..24e594b1b1b8822029eb05fa40cb07e2c24595a3 100644 (file)
--- 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)
index 2150279f060b76b5cb8ebc533bc24256811809c1..7bcd3ffb5a3fe1c0f532bb5f307a430e63be48d9 100644 (file)
@@ -36,7 +36,7 @@
 
 #include <curses.priv.h>
 
-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));
index c45023d3d24f54812165cbabdf9d396d78b53190..3a3756e385e83dba0b9efdd5eff79dcdc64e50d6 100644 (file)
@@ -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 <curses.priv.h>
 
-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)"),
index 1635c7f474fcd939ebd796b1ebb1c68d11b7a7e7..2cdc89cc31feb9f72ea0b8f86f7b577f9c8d59f0 100644 (file)
@@ -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
index ca66266855eaec884ecb1e094750405a81a53626..9091e001a91d63d9ea7a622cc493bda6b29967fc 100644 (file)
@@ -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            *
 #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;
index 3165d83c76f4f6adc6942a29c977b3d746e6bc3a..940dddf4b74bbc594bdf38f5a0bc8091b62ce4de 100644 (file)
@@ -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;      \
     }\
index 058cf9ab21b5c74794619ebbbe0dd71983756d32..2a9aa56371c8b3a1fca9de394a8d7b96aaa418a5 100644 (file)
@@ -50,7 +50,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-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;
index 83742d5b78baf38c3ea3e58b01e71bc45150df4f..9467b7df6b3097a68003bb8a00214d7647de7536 100644 (file)
@@ -48,7 +48,7 @@
 #include <locale.h>
 #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);
index 5c50500b0a046e88bf5aa29da409843cb00b1d56..586f2cd0ca5a2d8990bf40d2fcf0feadd7ccd2df 100644 (file)
@@ -51,7 +51,7 @@
 #include <termcap.h>           /* ospeed */
 #include <tic.h>
 
-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));
        }
     }
 }
index d3ec2d69a713c1f46657f070315a4dda3bfe0a4f..1a041ffa49740a045774fa5d303eace2c7f27bca 100644 (file)
@@ -1,8 +1,8 @@
-ncurses6 (5.9-20121201) unstable; urgency=low
+ncurses6 (5.9-20121208) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 01 Dec 2012 13:28:31 -0500
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 08 Dec 2012 10:12:21 -0500
 
 ncurses6 (5.9-20120608) unstable; urgency=low
 
index bcb3cba903b18880d9eca3beb7be0ff1228b7506..50f411bd1f9388c9b78c0821fb6ad7fcdab42855 100644 (file)
@@ -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
index 6128e3301dd0e25786049451a01e655ca888a06f..717a1fb35126bbb79b2544b03907c2c810d0d933 100644 (file)
@@ -46,7 +46,7 @@
 #include <hashed_db.h>
 #include <transform.h>
 
-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 "<stdin>"
 
@@ -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)
index 53a4df7637c9d6f247c99e7a501a904eddd87881..f8784853c7620cf233452089adf655d779685b30 100644 (file)
--- 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 <test.priv.h>
@@ -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;
 
index 02eade7c330649aa119195ca05b07bc67b9e649e..4e4e7051148a1947390c7e3413af080d71a6caff 100644 (file)
  *
  *     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 <test.priv.h>
+#include <math.h>
 
 #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
index 07af7eda0ad360a84c88e5dd32b9b90812203081..6e4e7275cdf6723f75db63e865f32a86640c19a8 100644 (file)
@@ -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
index b858668af2a028043e90f55429d2805952ecb73f..ffac333691864dcc242838760fb19676ab0183ed 100644 (file)
@@ -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
index 2835cd8b8d4689707dc07de372b6ef1c38b304ba..604be1ec984fa81ab97d0ee5ad9c83e2ecdaa184 100644 (file)
@@ -33,7 +33,7 @@
  * Eric S. Raymond <esr@snark.thyrsus.com> 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 <test.priv.h>
@@ -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':
index 326c747cad027cb542b0d50ae06e8ce1e3ad0cc1..9810bce3858fb4cd77a56d072e988f7d4c2754b7 100644 (file)
@@ -40,7 +40,7 @@ AUTHOR
    Author: Eric S. Raymond <esr@snark.thyrsus.com> 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;
index 96c6b0f308b67a78d0438085fee300e92f0c2e32..9cb0de95a809a3e66845e559648668dacf8f51f7 100644 (file)
@@ -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) {
index cc3dc4978cc172efb6ac22ac5a69bc866954a270..abb4380a31c83207ff54211d35bc44dadcec5dc7 100644 (file)
@@ -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