-- 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
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
// * 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 *
#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(),
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);
// * 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 *
#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
constructing();
w = static_cast<WINDOW *>(0);
- set_keyboard();
}
NCursesWindow::NCursesWindow(int nlines, int ncols, int begin_y, int begin_x)
# 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
# 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)
#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.
cchar_t wch;
int tmp;
+ memset(&wch, 0, sizeof(wch));
(void) wgetbkgrnd(win, &wch);
tmp = _nc_to_char((wint_t) CharOf(wch));
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));
/****************************************************************************
- * 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 *
#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
{
int result;
#ifdef USE_TERM_DRIVER
- TERMINAL *new_term;
+ TERMINAL *new_term = 0;
#endif
T((T_CALLED("restartterm(%p,%s,%d,%p)"),
#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
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
/****************************************************************************
- * 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;
returnCode(ERR);
switch (format) {
- default:
case 0: /* left-justified */
offset = 0;
break;
****************************************************************************/
/*
- * $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
*
#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; \
}\
#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.
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;
#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 $")
/****************************************************************************
*
* 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)) {
&& _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);
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);
#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 */
* 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));
}
}
}
-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
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
#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>"
static void
cleanup(void)
{
+ int rc;
+
#if NO_LEAKS
free_namelist(namelst);
#endif
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);
}
}
_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)
* 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>
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++)
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);
}
error((char *) NULL);
} else if (strchr("hjkl8462", c)) {
- assert(ss != 0);
ss->x = curx;
ss->y = cury;
*
* 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
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);
int
main(int argc, char **argv)
{
- int NTiles, FromCol, ToCol;
+ int FromCol, ToCol;
setlocale(LC_ALL, "");
Usage();
ExitProgram(EXIT_FAILURE);
}
-#ifdef TRACE
- trace(TRACE_MAXIMUM);
-#endif
initscr();
if (has_colors()) {
int i;
curs_set(0);
leaveok(stdscr, TRUE); /* Attempt to remove cursor */
}
- InitTiles(NTiles);
+ InitTiles();
DisplayTiles();
if (AutoFlag) {
do {
}
static void
-InitTiles(int NTiles)
+InitTiles(void)
{
int Size, SlotNo;
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,
" ");
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
* 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
}
}
if (level > 0) {
- delwin(show);
delwin(work);
delwin(look);
}
+ delwin(show);
}
static void
* 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
}
}
if (level > 0) {
- delwin(show);
delwin(work);
delwin(look);
}
+ delwin(show);
}
static void
* 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>
}
}
-static void
+static bool
find_next_move(int *y, int *x)
{
unsigned j, k;
int next = 0;
int oldy, oldx;
int newy, newx;
+ bool result = FALSE;
if (movecount > 1) {
oldy = history[movecount - 1].y;
*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
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':
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 $
***************************************************************************/
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)
outerbox(ul, lr, TRUE);
refresh();
- wrefresh(rwindow);
+ if (rwindow != 0)
+ wrefresh(rwindow);
move(0, 0);
clrtoeol();
#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;
/****************************************************************************
- * 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 *
* 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
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) {
* 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
}
}
if (level > 0) {
- delwin(show);
delwin(work);
delwin(look);
}
+ delwin(show);
}
static void