From 1c551ea75ea57f9186fbe8d79674ac85baa4d358 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sun, 16 Dec 2012 01:26:24 +0000 Subject: [PATCH] ncurses 5.9 - patch 20121215 + fix several warnings from clang 3.1 --analyze, includes correcting a null-pointer check in _nc_mvcur_resume. + correct display of double-width characters with MinGW port (report by Erwin Waterlander). + replace MinGW's wcrtomb(), fixing a problem with _nc_viscbuf > fixes based on Coverity report: + correct coloring in test/bs.c + correct check for 8-bit value in _nc_insert_ch(). + remove dead code in progs/tset.c, test/linedata.h + add null-pointer checks in lib_tracemse.c, panel.priv.h, and some test-programs. --- NEWS | 15 ++++++- dist.mk | 4 +- ncurses/base/lib_color.c | 5 ++- ncurses/base/lib_insch.c | 8 ++-- ncurses/curses.priv.h | 5 ++- ncurses/tinfo/lib_setup.c | 4 +- ncurses/tinfo/make_hash.c | 5 +-- ncurses/tinfo/trim_sgr0.c | 79 +++++++++++++++++++--------------- ncurses/trace/lib_tracemse.c | 37 ++++++++++------ ncurses/tty/lib_mvcur.c | 11 ++--- ncurses/tty/tty_update.c | 77 ++++++++++++++++----------------- ncurses/widechar/lib_wunctrl.c | 6 +-- ncurses/win32con/win_driver.c | 28 ++++++------ package/debian/changelog | 4 +- package/ncurses.spec | 2 +- panel/panel.priv.h | 6 +-- progs/dump_entry.c | 8 +++- progs/tic.c | 8 ++-- progs/tset.c | 5 +-- test/bs.c | 25 +++++------ test/color_set.c | 6 +-- test/ins_wide.c | 8 ++-- test/inserts.c | 8 ++-- test/linedata.h | 6 +-- test/movewindow.c | 14 ++++-- test/test_add_wchstr.c | 8 ++-- test/test_addchstr.c | 8 ++-- test/test_addstr.c | 8 ++-- test/test_addwstr.c | 8 ++-- test/worm.c | 10 +++-- 30 files changed, 241 insertions(+), 185 deletions(-) diff --git a/NEWS b/NEWS index 0d840d40..cfe9286e 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.1992 2012/12/09 00:24:36 tom Exp $ +-- $Id: NEWS,v 1.1998 2012/12/16 00:13:07 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,19 @@ 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. +20121215 + + fix several warnings from clang 3.1 --analyze, includes correcting + a null-pointer check in _nc_mvcur_resume. + + correct display of double-width characters with MinGW port (report + by Erwin Waterlander). + + replace MinGW's wcrtomb(), fixing a problem with _nc_viscbuf + > fixes based on Coverity report: + + correct coloring in test/bs.c + + correct check for 8-bit value in _nc_insert_ch(). + + remove dead code in progs/tset.c, test/linedata.h + + add null-pointer checks in lib_tracemse.c, panel.priv.h, and some + test-programs. + 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 diff --git a/dist.mk b/dist.mk index 24e594b1..776b2c16 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.904 2012/12/08 15:04:46 tom Exp $ +# $Id: dist.mk,v 1.905 2012/12/15 16:32:44 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 = 20121208 +NCURSES_PATCH = 20121215 # 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_color.c b/ncurses/base/lib_color.c index 0a68e309..00392987 100644 --- a/ncurses/base/lib_color.c +++ b/ncurses/base/lib_color.c @@ -45,7 +45,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_color.c,v 1.105 2012/06/09 20:34:11 tom Exp $") +MODULE_ID("$Id: lib_color.c,v 1.106 2012/12/15 19:14:34 tom Exp $") #ifdef USE_TERM_DRIVER #define CanChange InfoOf(SP_PARM).canchange @@ -804,7 +804,8 @@ NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx 1, outc); return; } else if (SP_PARM != 0) { - pair_content((short) pair, &fg, &bg); + if (pair_content((short) pair, &fg, &bg) == ERR) + return; } } diff --git a/ncurses/base/lib_insch.c b/ncurses/base/lib_insch.c index e21ec02b..7a9ab082 100644 --- a/ncurses/base/lib_insch.c +++ b/ncurses/base/lib_insch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. * + * Copyright (c) 1998-2009,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 * @@ -43,7 +43,7 @@ #include #include -MODULE_ID("$Id: lib_insch.c,v 1.32 2009/10/24 22:04:35 tom Exp $") +MODULE_ID("$Id: lib_insch.c,v 1.33 2012/12/15 22:51:12 tom Exp $") /* * Insert the given character, updating the current location to simplify @@ -82,7 +82,7 @@ _nc_insert_ch(SCREEN *sp, WINDOW *win, chtype ch) #if USE_WIDEC_SUPPORT WINDOW_EXT(win, addch_used) == 0 && #endif - is8bits(ChCharOf(ch)) && + is8bits(ch) && (isprint(ChCharOf(ch)) || (ChAttrOf(ch) & A_ALTCHARSET) || (sp != 0 && sp->_legacy_coding && !iscntrl(ChCharOf(ch))))) { @@ -101,7 +101,7 @@ _nc_insert_ch(SCREEN *sp, WINDOW *win, chtype ch) *temp1 = _nc_render(win, wch); win->_curx++; } - } else if (is8bits(ChCharOf(ch)) && iscntrl(ChCharOf(ch))) { + } else if (is8bits(ch) && iscntrl(ChCharOf(ch))) { s = NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx ChCharOf(ch)); while (*s != '\0') { code = _nc_insert_ch(sp, win, ChAttrOf(ch) | UChar(*s)); diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index 940dddf4..46445329 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -34,7 +34,7 @@ ****************************************************************************/ /* - * $Id: curses.priv.h,v 1.512 2012/12/08 20:19:40 tom Exp $ + * $Id: curses.priv.h,v 1.514 2012/12/15 20:03:45 tom Exp $ * * curses.priv.h * @@ -1418,7 +1418,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; AttrOf(dst) |= (attr_t) (ext + 1) #define if_WIDEC(code) code -#define Charable(ch) ((SP_PARM != 0 && SP_PARM->_legacy_coding) \ +#define Charable(ch) ((SP_PARM->_legacy_coding) \ || (AttrOf(ch) & A_ALTCHARSET) \ || (!isWidecExt(ch) && \ (ch).chars[1] == L'\0' && \ @@ -2046,6 +2046,7 @@ extern NCURSES_EXPORT(int) _nc_eventlist_timeout(_nc_eventlist *); extern int __MINGW_NOTHROW _nc_wctomb(char *, wchar_t); #define wctomb(s,wc) _nc_wctomb(s,wc) +#define wcrtomb(s,wc,n) _nc_wctomb(s,wc) extern int __MINGW_NOTHROW _nc_mbtowc(wchar_t *, const char *, size_t); #define mbtowc(pwc,s,n) _nc_mbtowc(pwc,s,n) diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c index 9467b7df..6e738e0f 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.154 2012/12/08 22:01:26 tom Exp $") +MODULE_ID("$Id: lib_setup.c,v 1.155 2012/12/15 19:04:54 tom Exp $") /**************************************************************************** * @@ -438,7 +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->_resize != 0) { + if (sp != 0 && 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)) { diff --git a/ncurses/tinfo/make_hash.c b/ncurses/tinfo/make_hash.c index 99e4bd4f..38980d24 100644 --- a/ncurses/tinfo/make_hash.c +++ b/ncurses/tinfo/make_hash.c @@ -44,7 +44,7 @@ #include -MODULE_ID("$Id: make_hash.c,v 1.9 2012/11/18 01:30:03 tom Exp $") +MODULE_ID("$Id: make_hash.c,v 1.10 2012/12/16 00:40:14 tom Exp $") /* * _nc_make_hash_table() @@ -275,8 +275,7 @@ main(int argc, char **argv) printf("static struct name_table_entry *_nc_%s_table = 0;\n\n", root_name); } else { - printf("static struct name_table_entry %s _nc_%s_table[] =\n", - bigstring ? "" : "const", + printf("static struct name_table_entry const _nc_%s_table[] =\n", root_name); printf("{\n"); for (n = 0; n < CAPTABSIZE; n++) { diff --git a/ncurses/tinfo/trim_sgr0.c b/ncurses/tinfo/trim_sgr0.c index ee18c731..ec5e2b78 100644 --- a/ncurses/tinfo/trim_sgr0.c +++ b/ncurses/tinfo/trim_sgr0.c @@ -36,7 +36,7 @@ #include -MODULE_ID("$Id: trim_sgr0.c,v 1.14 2012/02/22 22:34:31 tom Exp $") +MODULE_ID("$Id: trim_sgr0.c,v 1.15 2012/12/15 20:57:17 tom Exp $") #undef CUR #define CUR tp-> @@ -48,21 +48,28 @@ MODULE_ID("$Id: trim_sgr0.c,v 1.14 2012/02/22 22:34:31 tom Exp $") static char * set_attribute_9(TERMTYPE *tp, int flag) { - const char *result; + const char *value; + char *result; - if ((result = tparm(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, flag)) == 0) - result = ""; - return strdup(result); + value = tparm(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, flag); + if (PRESENT(value)) + result = strdup(value); + else + result = 0; + return result; } static int is_csi(const char *s) { - if (UChar(s[0]) == CSI) - return 1; - else if (s[0] == ESC && s[1] == L_BRACK) - return 2; - return 0; + int result = 0; + if (s != 0) { + if (UChar(s[0]) == CSI) + result = 1; + else if (s[0] == ESC && s[1] == L_BRACK) + result = 2; + } + return result; } static char * @@ -97,7 +104,7 @@ skip_delay(const char *s) static bool rewrite_sgr(char *s, char *attr) { - if (PRESENT(s)) { + if (s != 0) { if (PRESENT(attr)) { size_t len_s = strlen(s); size_t len_a = strlen(attr); @@ -121,33 +128,35 @@ static bool similar_sgr(char *a, char *b) { bool result = FALSE; - int csi_a = is_csi(a); - int csi_b = is_csi(b); - size_t len_a; - size_t len_b; + if (a != 0 && b != 0) { + int csi_a = is_csi(a); + int csi_b = is_csi(b); + size_t len_a; + size_t len_b; - TR(TRACE_DATABASE, ("similar_sgr:\n\t%s\n\t%s", - _nc_visbuf2(1, a), - _nc_visbuf2(2, b))); - if (csi_a != 0 && csi_b != 0 && csi_a == csi_b) { - a += csi_a; - b += csi_b; - if (*a != *b) { - a = skip_zero(a); - b = skip_zero(b); + TR(TRACE_DATABASE, ("similar_sgr:\n\t%s\n\t%s", + _nc_visbuf2(1, a), + _nc_visbuf2(2, b))); + if (csi_a != 0 && csi_b != 0 && csi_a == csi_b) { + a += csi_a; + b += csi_b; + if (*a != *b) { + a = skip_zero(a); + b = skip_zero(b); + } } + len_a = strlen(a); + len_b = strlen(b); + if (len_a && len_b) { + if (len_a > len_b) + result = (strncmp(a, b, len_b) == 0); + else + result = (strncmp(a, b, len_a) == 0); + } + TR(TRACE_DATABASE, ("...similar_sgr: %d\n\t%s\n\t%s", result, + _nc_visbuf2(1, a), + _nc_visbuf2(2, b))); } - len_a = strlen(a); - len_b = strlen(b); - if (len_a && len_b) { - if (len_a > len_b) - result = (strncmp(a, b, len_b) == 0); - else - result = (strncmp(a, b, len_a) == 0); - } - TR(TRACE_DATABASE, ("...similar_sgr: %d\n\t%s\n\t%s", result, - _nc_visbuf2(1, a), - _nc_visbuf2(2, b))); return result; } diff --git a/ncurses/trace/lib_tracemse.c b/ncurses/trace/lib_tracemse.c index e062a26a..51ffa2ef 100644 --- a/ncurses/trace/lib_tracemse.c +++ b/ncurses/trace/lib_tracemse.c @@ -38,7 +38,7 @@ #include -MODULE_ID("$Id: lib_tracemse.c,v 1.20 2012/02/22 22:40:24 tom Exp $") +MODULE_ID("$Id: lib_tracemse.c,v 1.21 2012/12/15 23:51:19 tom Exp $") #ifdef TRACE @@ -114,24 +114,33 @@ _trace_mmask_t(SCREEN *sp, mmask_t code) NCURSES_EXPORT(char *) _nc_tracemouse(SCREEN *sp, MEVENT const *ep) { - _nc_SPRINTF(my_buffer, _nc_SLIMIT(sizeof(my_buffer)) - TRACEMSE_FMT, - ep->id, - ep->x, - ep->y, - ep->z, - (unsigned long) ep->bstate); - - (void) _trace_mmask_t(sp, ep->bstate); - _nc_STRCAT(my_buffer, "}", sizeof(my_buffer)); - return (my_buffer); + char *result = 0; + + if (sp != 0) { + _nc_SPRINTF(my_buffer, _nc_SLIMIT(sizeof(my_buffer)) + TRACEMSE_FMT, + ep->id, + ep->x, + ep->y, + ep->z, + (unsigned long) ep->bstate); + + (void) _trace_mmask_t(sp, ep->bstate); + _nc_STRCAT(my_buffer, "}", sizeof(my_buffer)); + result = (my_buffer); + } + return result; } NCURSES_EXPORT(mmask_t) _nc_retrace_mmask_t(SCREEN *sp, mmask_t code) { - *my_buffer = '\0'; - T((T_RETURN("{%s}"), _trace_mmask_t(sp, code))); + if (sp != 0) { + *my_buffer = '\0'; + T((T_RETURN("{%s}"), _trace_mmask_t(sp, code))); + } else { + T((T_RETURN("{?}"))); + } return code; } diff --git a/ncurses/tty/lib_mvcur.c b/ncurses/tty/lib_mvcur.c index 8de26c4f..78453e35 100644 --- a/ncurses/tty/lib_mvcur.c +++ b/ncurses/tty/lib_mvcur.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 * @@ -159,7 +159,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_mvcur.c,v 1.127 2011/10/22 16:09:52 tom Exp $") +MODULE_ID("$Id: lib_mvcur.c,v 1.128 2012/12/15 20:59:27 tom Exp $") #define WANT_CHAR(sp, y, x) NewScreen(sp)->_line[y].text[x] /* desired state */ @@ -285,7 +285,7 @@ NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_resume) (NCURSES_SP_DCL0) /* what to do at initialization time and after each shellout */ { - if (SP_PARM && !IsTermInfo(SP_PARM)) + if (!SP_PARM || !IsTermInfo(SP_PARM)) return; /* initialize screen for cursor access */ @@ -327,13 +327,14 @@ NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_init) (NCURSES_SP_DCL0) /* initialize the cost structure */ { - if (SP_PARM->_ofp && isatty(fileno(SP_PARM->_ofp))) + if (SP_PARM->_ofp && isatty(fileno(SP_PARM->_ofp))) { SP_PARM->_char_padding = ((BAUDBYTE * 1000 * 10) / (BAUDRATE(SP_PARM) > 0 ? BAUDRATE(SP_PARM) : 9600)); - else + } else { SP_PARM->_char_padding = 1; /* must be nonzero */ + } if (SP_PARM->_char_padding <= 0) SP_PARM->_char_padding = 1; /* must be nonzero */ TR(TRACE_CHARPUT | TRACE_MOVE, ("char_padding %d msecs", SP_PARM->_char_padding)); diff --git a/ncurses/tty/tty_update.c b/ncurses/tty/tty_update.c index 368beaf4..9be99738 100644 --- a/ncurses/tty/tty_update.c +++ b/ncurses/tty/tty_update.c @@ -82,7 +82,7 @@ #include -MODULE_ID("$Id: tty_update.c,v 1.271 2012/08/25 21:04:03 tom Exp $") +MODULE_ID("$Id: tty_update.c,v 1.272 2012/12/15 21:00:19 tom Exp $") /* * This define controls the line-breakout optimization. Every once in a @@ -1076,24 +1076,22 @@ ClrToEOL(NCURSES_SP_DCLx NCURSES_CH_T blank, int needclear) { int j; - if (SP_PARM != 0) { - if (CurScreen(SP_PARM) != 0 - && SP_PARM->_cursrow >= 0) { - for (j = SP_PARM->_curscol; j < screen_columns(SP_PARM); j++) { - if (j >= 0) { - NCURSES_CH_T *cp = - &(CurScreen(SP_PARM)->_line[SP_PARM->_cursrow].text[j]); - - if (!CharEq(*cp, blank)) { - *cp = blank; - needclear = TRUE; - } + if (CurScreen(SP_PARM) != 0 + && SP_PARM->_cursrow >= 0) { + for (j = SP_PARM->_curscol; j < screen_columns(SP_PARM); j++) { + if (j >= 0) { + NCURSES_CH_T *cp = + &(CurScreen(SP_PARM)->_line[SP_PARM->_cursrow].text[j]); + + if (!CharEq(*cp, blank)) { + *cp = blank; + needclear = TRUE; } } } } - if (needclear && (SP_PARM != 0)) { + if (needclear) { UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("clr_eol"); if (clr_eol && SP_PARM->_el_cost <= (screen_columns(SP_PARM) - SP_PARM->_curscol)) { @@ -1117,9 +1115,6 @@ ClrToEOS(NCURSES_SP_DCLx NCURSES_CH_T blank) { int row, col; - if (0 == SP_PARM) - return; - row = SP_PARM->_cursrow; col = SP_PARM->_curscol; @@ -2155,33 +2150,33 @@ _nc_screen_init(void) NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_wrap) (NCURSES_SP_DCL0) { - if (SP_PARM == 0) - return; + if (SP_PARM != 0) { - UpdateAttrs(SP_PARM, normal); + UpdateAttrs(SP_PARM, normal); #if NCURSES_EXT_FUNCS - if (SP_PARM->_coloron - && !SP_PARM->_default_color) { - static const NCURSES_CH_T blank = NewChar(BLANK_TEXT); - SP_PARM->_default_color = TRUE; - NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx - -1, - 0, - FALSE, - NCURSES_SP_NAME(_nc_outch)); - SP_PARM->_default_color = FALSE; - - TINFO_MVCUR(NCURSES_SP_ARGx - SP_PARM->_cursrow, - SP_PARM->_curscol, - screen_lines(SP_PARM) - 1, - 0); - - ClrToEOL(NCURSES_SP_ARGx blank, TRUE); - } + if (SP_PARM->_coloron + && !SP_PARM->_default_color) { + static const NCURSES_CH_T blank = NewChar(BLANK_TEXT); + SP_PARM->_default_color = TRUE; + NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx + -1, + 0, + FALSE, + NCURSES_SP_NAME(_nc_outch)); + SP_PARM->_default_color = FALSE; + + TINFO_MVCUR(NCURSES_SP_ARGx + SP_PARM->_cursrow, + SP_PARM->_curscol, + screen_lines(SP_PARM) - 1, + 0); + + ClrToEOL(NCURSES_SP_ARGx blank, TRUE); + } #endif - if (SP_PARM->_color_defs) { - NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_ARG); + if (SP_PARM->_color_defs) { + NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_ARG); + } } } diff --git a/ncurses/widechar/lib_wunctrl.c b/ncurses/widechar/lib_wunctrl.c index c2328a43..45d49520 100644 --- a/ncurses/widechar/lib_wunctrl.c +++ b/ncurses/widechar/lib_wunctrl.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2001-2010,2011 Free Software Foundation, Inc. * + * Copyright (c) 2001-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 * @@ -35,7 +35,7 @@ #include -MODULE_ID("$Id: lib_wunctrl.c,v 1.15 2011/05/28 22:06:26 tom Exp $") +MODULE_ID("$Id: lib_wunctrl.c,v 1.16 2012/12/15 20:53:42 tom Exp $") NCURSES_EXPORT(wchar_t *) NCURSES_SP_NAME(wunctrl) (NCURSES_SP_DCLx cchar_t *wc) @@ -45,7 +45,7 @@ NCURSES_SP_NAME(wunctrl) (NCURSES_SP_DCLx cchar_t *wc) if (wc == 0) { result = 0; - } else if (Charable(*wc)) { + } else if (SP_PARM != 0 && Charable(*wc)) { const char *p = NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx (unsigned) _nc_to_char((wint_t)CharOf(*wc))); diff --git a/ncurses/win32con/win_driver.c b/ncurses/win32con/win_driver.c index 02cd378c..03313270 100644 --- a/ncurses/win32con/win_driver.c +++ b/ncurses/win32con/win_driver.c @@ -38,7 +38,7 @@ #include #define CUR my_term.type. -MODULE_ID("$Id: win_driver.c,v 1.14 2012/09/22 19:15:14 tom Exp $") +MODULE_ID("$Id: win_driver.c,v 1.15 2012/12/15 19:39:49 tom Exp $") #define WINMAGIC NCDRV_MAGIC(NCDRV_WINCONSOLE) @@ -143,9 +143,10 @@ MapAttr(TERMINAL_CONTROL_BLOCK * TCB, WORD res, attr_t ch) * TODO: _nc_wacs should be part of sp. */ static BOOL -con_write16(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, cchar_t *str, int n) +con_write16(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, cchar_t *str, int limit) { - CHAR_INFO ci[n]; + int actual = 0; + CHAR_INFO ci[limit]; COORD loc, siz; SMALL_RECT rec; int i; @@ -159,34 +160,37 @@ con_write16(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, cchar_t *str, int n) SetSP(); - for (i = 0; i < n; i++) { + for (i = actual = 0; i < limit; i++) { ch = str[i]; - ci[i].Char.UnicodeChar = CharOf(ch); - ci[i].Attributes = MapAttr(TCB, - PropOf(TCB)->SBI.wAttributes, - AttrOf(ch)); + if (isWidecExt(ch)) + continue; + ci[actual].Char.UnicodeChar = CharOf(ch); + ci[actual].Attributes = MapAttr(TCB, + PropOf(TCB)->SBI.wAttributes, + AttrOf(ch)); if (AttrOf(ch) & A_ALTCHARSET) { if (_nc_wacs) { int which = CharOf(ch); if (which > 0 && which < ACS_LEN && CharOf(_nc_wacs[which]) != 0) { - ci[i].Char.UnicodeChar = CharOf(_nc_wacs[which]); + ci[actual].Char.UnicodeChar = CharOf(_nc_wacs[which]); } else { - ci[i].Char.UnicodeChar = ' '; + ci[actual].Char.UnicodeChar = ' '; } } } + ++actual; } loc.X = (short) 0; loc.Y = (short) 0; - siz.X = (short) n; + siz.X = (short) actual; siz.Y = 1; rec.Left = (short) x; rec.Top = (short) y; - rec.Right = (short) (x + n - 1); + rec.Right = (short) (x + limit - 1); rec.Bottom = rec.Top; return WriteConsoleOutputW(TCB->hdl, ci, siz, loc, &rec); diff --git a/package/debian/changelog b/package/debian/changelog index 1a041ffa..ffadf002 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,8 +1,8 @@ -ncurses6 (5.9-20121208) unstable; urgency=low +ncurses6 (5.9-20121215) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 08 Dec 2012 10:12:21 -0500 + -- Thomas E. Dickey Sat, 15 Dec 2012 11:32:40 -0500 ncurses6 (5.9-20120608) unstable; urgency=low diff --git a/package/ncurses.spec b/package/ncurses.spec index 50f411bd..538bf1a5 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: 20121208 +Version: 20121215 License: X11 Group: Development/Libraries Source: ncurses-%{release}-%{version}.tgz diff --git a/panel/panel.priv.h b/panel/panel.priv.h index 016a84c1..76607fb2 100644 --- a/panel/panel.priv.h +++ b/panel/panel.priv.h @@ -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 * @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ -/* $Id: panel.priv.h,v 1.24 2011/05/21 18:55:07 tom Exp $ */ +/* $Id: panel.priv.h,v 1.25 2012/12/15 23:57:43 tom Exp $ */ #ifndef NCURSES_PANEL_PRIV_H #define NCURSES_PANEL_PRIV_H 1 @@ -89,7 +89,7 @@ struct screen; /* forward declaration */ #define GetScreenHook(sp) \ struct panelhook* ph = NCURSES_SP_NAME(_nc_panelhook)(sp) #define GetPanelHook(pan) \ - GetScreenHook(_nc_screen_of((pan)->win)) + GetScreenHook(pan ? _nc_screen_of((pan)->win) : 0) #define GetWindowHook(win) \ SCREEN* sp = _nc_screen_of(win); \ GetScreenHook(sp) diff --git a/progs/dump_entry.c b/progs/dump_entry.c index 31deedb2..56610e9d 100644 --- a/progs/dump_entry.c +++ b/progs/dump_entry.c @@ -39,7 +39,7 @@ #include "termsort.c" /* this C file is generated */ #include /* so is this */ -MODULE_ID("$Id: dump_entry.c,v 1.101 2012/10/27 19:45:17 tom Exp $") +MODULE_ID("$Id: dump_entry.c,v 1.102 2012/12/15 18:25:56 tom Exp $") #define INDENT 8 #define DISCARD(string) string = ABSENT_STRING @@ -100,6 +100,8 @@ static const char *separator, *trailer; #define StrIndirect(j) ((sortmode == S_NOSORT) ? (j) : str_indirect[j]) #endif +static void failed(const char *) GCC_NORETURN; + static void failed(const char *s) { @@ -828,7 +830,9 @@ fmt_entry(TERMTYPE *tterm, } } /* e.g., trimmed_sgr0 */ - if (capability != tterm->Strings[i]) + if (capability != ABSENT_STRING && + capability != CANCELLED_STRING && + capability != tterm->Strings[i]) free(capability); } len += (int) (num_strings * 2); diff --git a/progs/tic.c b/progs/tic.c index 717a1fb3..9ad79d47 100644 --- a/progs/tic.c +++ b/progs/tic.c @@ -46,7 +46,7 @@ #include #include -MODULE_ID("$Id: tic.c,v 1.180 2012/12/08 22:17:22 tom Exp $") +MODULE_ID("$Id: tic.c,v 1.182 2012/12/16 00:03:12 tom Exp $") #define STDIN_NAME "" @@ -552,7 +552,7 @@ matches(char **needle, const char *haystack) return (code); } -static const char * +static char * valid_db_path(const char *nominal) { struct stat sb; @@ -623,7 +623,7 @@ static void show_databases(const char *outdir) { bool specific = (outdir != 0) || getenv("TERMINFO") != 0; - const char *result; + char *result; const char *tried = 0; if (outdir == 0) { @@ -631,6 +631,7 @@ show_databases(const char *outdir) } if ((result = valid_db_path(outdir)) != 0) { printf("%s\n", result); + free(result); } else { tried = outdir; } @@ -638,6 +639,7 @@ show_databases(const char *outdir) if ((outdir = _nc_home_terminfo())) { if ((result = valid_db_path(outdir)) != 0) { printf("%s\n", result); + free(result); } else if (!specific) { tried = outdir; } diff --git a/progs/tset.c b/progs/tset.c index bf3bf192..f7f00c5e 100644 --- a/progs/tset.c +++ b/progs/tset.c @@ -119,7 +119,7 @@ char *ttyname(int fd); #include #include -MODULE_ID("$Id: tset.c,v 1.89 2012/02/22 22:50:47 tom Exp $") +MODULE_ID("$Id: tset.c,v 1.90 2012/12/15 23:01:17 tom Exp $") /* * SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS, @@ -474,9 +474,6 @@ add_mapping(const char *port, char *arg) mapp->speed = tbaudrate(p); } - if (arg == (char *) 0) /* Non-optional type. */ - goto badmopt; - mapp->type = arg; /* Terminate porttype, if specified. */ diff --git a/test/bs.c b/test/bs.c index f8784853..ebcabc42 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.56 2012/12/08 23:35:58 tom Exp $ + * $Id: bs.c,v 1.59 2012/12/16 00:20:49 tom Exp $ */ #include @@ -110,7 +110,7 @@ static char sub[] = "Submarine"; static char destroy[] = "Destroyer"; static char ptboat[] = "PT Boat"; -static char name[40]; +static char *your_name; static char dftname[] = "stranger"; /* direction constants */ @@ -220,11 +220,12 @@ intro(void) CATCHALL(uninitgame); - if ((tmpname = getlogin()) != 0) { - (void) strcpy(name, tmpname); - name[0] = (char) toupper(UChar(name[0])); - } else - (void) strcpy(name, dftname); + if ((tmpname = getlogin()) != 0 && + (your_name = strdup(tmpname)) != 0) { + your_name[0] = (char) toupper(UChar(your_name[0])); + } else { + your_name = dftname; + } (void) initscr(); keypad(stdscr, TRUE); @@ -955,8 +956,8 @@ cpufire(int x, int y) bool hit, sunk; ship_t *ss = NULL; - hit = board[PLAYER][x][y] ? MARK_HIT : MARK_MISS; - hits[COMPUTER][x][y] = (char) hit; + hit = board[PLAYER][x][y]; + hits[COMPUTER][x][y] = (hit ? MARK_HIT : MARK_MISS); MvPrintw(PROMPTLINE, 0, "I shoot at %c%d. I %s!", y + 'A', x, hit ? "hit" : "miss"); @@ -1133,16 +1134,16 @@ playagain(void) ++cpuwon; else ++plywon; - j = 18 + (int) strlen(name); + j = 18 + (int) strlen(your_name); if (plywon >= 10) ++j; if (cpuwon >= 10) ++j; MvPrintw(1, (COLWIDTH - j) / 2, - "%s: %d Computer: %d", name, plywon, cpuwon); + "%s: %d Computer: %d", your_name, plywon, cpuwon); prompt(2, (awinna())? "Want to be humiliated again, %s [yn]? " - : "Going to give me a chance for revenge, %s [yn]? ", name); + : "Going to give me a chance for revenge, %s [yn]? ", your_name); return (sgetc("YN") == 'Y'); } diff --git a/test/color_set.c b/test/color_set.c index 2e981cba..041e6fd7 100644 --- a/test/color_set.c +++ b/test/color_set.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2003-2006,2008 Free Software Foundation, Inc. * + * Copyright (c) 2003-2008,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: color_set.c,v 1.6 2008/02/10 00:18:01 tom Exp $ + * $Id: color_set.c,v 1.7 2012/12/15 22:04:14 tom Exp $ */ #include @@ -48,7 +48,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) if (has_colors()) { start_color(); - pair_content(0, &f, &b); + (void) pair_content(0, &f, &b); printw("pair 0 contains (%d,%d)\n", f, b); getch(); diff --git a/test/ins_wide.c b/test/ins_wide.c index 6e4e7275..a168dc11 100644 --- a/test/ins_wide.c +++ b/test/ins_wide.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: ins_wide.c,v 1.19 2012/12/09 01:13:56 tom Exp $ + * $Id: ins_wide.c,v 1.20 2012/12/16 00:51:02 tom Exp $ * * Demonstrate the wins_wstr() and wins_wch functions. * Thomas Dickey - 2002/11/23 @@ -294,11 +294,13 @@ test_inserts(int level) case key_RECUR: test_inserts(level + 1); - touchwin(look); + if (look) + touchwin(look); touchwin(work); touchwin(show); - wnoutrefresh(look); + if (look) + wnoutrefresh(look); wnoutrefresh(work); wnoutrefresh(show); diff --git a/test/inserts.c b/test/inserts.c index ffac3336..ae38fa21 100644 --- a/test/inserts.c +++ b/test/inserts.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: inserts.c,v 1.26 2012/12/09 00:51:51 tom Exp $ + * $Id: inserts.c,v 1.27 2012/12/16 00:35:27 tom Exp $ * * Demonstrate the winsstr() and winsch functions. * Thomas Dickey - 2002/10/19 @@ -219,11 +219,13 @@ test_inserts(int level) case key_RECUR: test_inserts(level + 1); - touchwin(look); + if (look) + touchwin(look); touchwin(work); touchwin(show); - wnoutrefresh(look); + if (look) + wnoutrefresh(look); wnoutrefresh(work); wnoutrefresh(show); diff --git a/test/linedata.h b/test/linedata.h index 2510ee72..751bc6b5 100644 --- a/test/linedata.h +++ b/test/linedata.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2009,2010 Free Software Foundation, Inc. * + * Copyright (c) 2009-2010,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 * @@ -85,10 +85,8 @@ read_linedata(WINDOW *work) beep(); continue; } - } else if (code != ERR) { - result = (int) ch; - break; } else { + result = (int) ch; break; } } diff --git a/test/movewindow.c b/test/movewindow.c index 11521a07..612cb882 100644 --- a/test/movewindow.c +++ b/test/movewindow.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: movewindow.c,v 1.37 2012/10/27 19:37:56 tom Exp $ + * $Id: movewindow.c,v 1.38 2012/12/15 18:36:40 tom Exp $ * * Demonstrate move functions for windows and derived windows from the curses * library. @@ -218,8 +218,16 @@ selectcell(WINDOW *parent, res.x = ulj + j; return (&res); } - i %= si; - j %= sj; + + if (si <= 0) + i = 0; + else + i %= si; + + if (sj <= 0) + j = 0; + else + j %= sj; /* * If the caller can handle continuous movement, return the result. diff --git a/test/test_add_wchstr.c b/test/test_add_wchstr.c index 6b1b2d7a..c509f003 100644 --- a/test/test_add_wchstr.c +++ b/test/test_add_wchstr.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: test_add_wchstr.c,v 1.19 2012/11/24 20:04:13 tom Exp $ + * $Id: test_add_wchstr.c,v 1.20 2012/12/16 00:12:04 tom Exp $ * * Demonstrate the waddwchstr() and wadd_wch functions. * Thomas Dickey - 2009/9/12 @@ -371,11 +371,13 @@ test_add_wchstr(int level) case key_RECUR: test_add_wchstr(level + 1); - touchwin(look); + if (look) + touchwin(look); touchwin(work); touchwin(show); - wnoutrefresh(look); + if (look) + wnoutrefresh(look); wnoutrefresh(work); wnoutrefresh(show); diff --git a/test/test_addchstr.c b/test/test_addchstr.c index abb4380a..2aae844e 100644 --- a/test/test_addchstr.c +++ b/test/test_addchstr.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: test_addchstr.c,v 1.17 2012/12/09 00:50:39 tom Exp $ + * $Id: test_addchstr.c,v 1.18 2012/12/16 00:36:27 tom Exp $ * * Demonstrate the waddchstr() and waddch functions. * Thomas Dickey - 2009/9/12 @@ -294,11 +294,13 @@ test_adds(int level) case key_RECUR: test_adds(level + 1); - touchwin(look); + if (look) + touchwin(look); touchwin(work); touchwin(show); - wnoutrefresh(look); + if (look) + wnoutrefresh(look); wnoutrefresh(work); wnoutrefresh(show); diff --git a/test/test_addstr.c b/test/test_addstr.c index a6876a89..a14cdedc 100644 --- a/test/test_addstr.c +++ b/test/test_addstr.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: test_addstr.c,v 1.9 2012/11/24 19:49:02 tom Exp $ + * $Id: test_addstr.c,v 1.10 2012/12/16 00:14:10 tom Exp $ * * Demonstrate the waddstr() and waddch functions. * Thomas Dickey - 2009/9/12 @@ -213,11 +213,13 @@ test_adds(int level) case key_RECUR: test_adds(level + 1); - touchwin(look); + if (look) + touchwin(look); touchwin(work); touchwin(show); - wnoutrefresh(look); + if (look) + wnoutrefresh(look); wnoutrefresh(work); wnoutrefresh(show); diff --git a/test/test_addwstr.c b/test/test_addwstr.c index e369b667..cb057faf 100644 --- a/test/test_addwstr.c +++ b/test/test_addwstr.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: test_addwstr.c,v 1.10 2012/11/24 20:04:54 tom Exp $ + * $Id: test_addwstr.c,v 1.11 2012/12/16 00:11:18 tom Exp $ * * Demonstrate the waddwstr() and wadd_wch functions. * Thomas Dickey - 2009/9/12 @@ -299,11 +299,13 @@ test_inserts(int level) case key_RECUR: test_inserts(level + 1); - touchwin(look); + if (look) + touchwin(look); touchwin(work); touchwin(show); - wnoutrefresh(look); + if (look) + wnoutrefresh(look); wnoutrefresh(work); wnoutrefresh(show); diff --git a/test/worm.c b/test/worm.c index 1f0a6fcb..f64911c6 100644 --- a/test/worm.c +++ b/test/worm.c @@ -61,7 +61,7 @@ Options: traces will be dumped. The program stops and waits for one character of input at the beginning and end of the interval. - $Id: worm.c,v 1.61 2012/10/27 19:37:17 tom Exp $ + $Id: worm.c,v 1.62 2012/12/15 18:32:40 tom Exp $ */ #include @@ -431,6 +431,7 @@ main(int argc, char *argv[]) struct worm *w; int *ip; bool done = FALSE; + int max_refs; setlocale(LC_ALL, ""); @@ -513,8 +514,9 @@ main(int argc, char *argv[]) } #endif /* A_COLOR */ - refs = typeMalloc(int *, (size_t) LINES); - for (y = 0; y < LINES; y++) { + max_refs = LINES; + refs = typeMalloc(int *, (size_t) max_refs); + for (y = 0; y < max_refs; y++) { refs[y] = typeMalloc(int, (size_t) COLS); for (x = 0; x < COLS; x++) { refs[y][x] = 0; @@ -608,7 +610,7 @@ main(int argc, char *argv[]) Trace(("Cleanup")); cleanup(); #ifdef NO_LEAKS - for (y = 0; y < LINES; y++) { + for (y = 0; y < max_refs; y++) { free(refs[y]); } free(refs); -- 2.44.0