From 56a81c7e79f73d397cc8074401d039f59c34cad5 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sun, 9 May 2021 00:34:51 +0000 Subject: [PATCH] ncurses 6.2 - patch 20210508 + modify tputs' error check to allow it to be used without first calling tgetent or setupterm, noting that terminfo initialization is requires for supporting the terminfo delay feature (report by Sebastiano Vigna). + fix several warnings from clang --analyze + add null-pointer check in comp_parse.c, when a "use=" clause refers to a nonexisting terminal description (report/patch by Miroslav Lichvar, cf: 20210227). --- NEWS | 12 +++++- VERSION | 2 +- dist.mk | 4 +- menu/m_post.c | 55 +++++++++++++------------ ncurses/base/lib_bkgd.c | 4 +- ncurses/base/lib_color.c | 71 +++++++++++++++++--------------- ncurses/base/lib_set_term.c | 8 ++-- ncurses/base/new_pair.c | 4 +- ncurses/tinfo/alloc_entry.c | 6 +-- ncurses/tinfo/comp_parse.c | 12 +++--- ncurses/tinfo/lib_tputs.c | 38 ++++++++--------- package/debian-mingw/changelog | 4 +- package/debian-mingw64/changelog | 4 +- package/debian/changelog | 4 +- package/mingw-ncurses.nsi | 4 +- package/mingw-ncurses.spec | 2 +- package/ncurses.spec | 2 +- package/ncursest.spec | 2 +- test/demo_menus.c | 4 +- test/hanoi.c | 6 +-- test/knight.c | 4 +- test/ncurses.c | 6 +-- test/picsmap.c | 3 +- test/test_add_wchstr.c | 6 +-- test/view.c | 8 ++-- 25 files changed, 146 insertions(+), 129 deletions(-) diff --git a/NEWS b/NEWS index 4948668c..16c3eabc 100644 --- a/NEWS +++ b/NEWS @@ -26,7 +26,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.3660 2021/05/01 21:55:29 tom Exp $ +-- $Id: NEWS,v 1.3662 2021/05/08 23:37:13 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -46,6 +46,16 @@ See the AUTHORS file for the corresponding full names. Changes through 1.9.9e did not credit all contributions; it is not possible to add this information. +20210508 + + modify tputs' error check to allow it to be used without first + calling tgetent or setupterm, noting that terminfo initialization + is requires for supporting the terminfo delay feature (report by + Sebastiano Vigna). + + fix several warnings from clang --analyze + + add null-pointer check in comp_parse.c, when a "use=" clause refers + to a nonexisting terminal description (report/patch by Miroslav + Lichvar, cf: 20210227). + 20210501 + add a special case in the configure script to work around one of the build-time breakages reported for OpenBSD 6 here: diff --git a/VERSION b/VERSION index 68ca8693..168b7e9d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5:0:10 6.2 20210501 +5:0:10 6.2 20210508 diff --git a/dist.mk b/dist.mk index a70125d4..372897a3 100644 --- a/dist.mk +++ b/dist.mk @@ -26,7 +26,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.1413 2021/05/01 09:40:30 tom Exp $ +# $Id: dist.mk,v 1.1414 2021/05/08 13:20:24 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -38,7 +38,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 6 NCURSES_MINOR = 2 -NCURSES_PATCH = 20210501 +NCURSES_PATCH = 20210508 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/menu/m_post.c b/menu/m_post.c index b4b1bc14..1dbd6b80 100644 --- a/menu/m_post.c +++ b/menu/m_post.c @@ -38,7 +38,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_post.c,v 1.35 2021/03/27 23:46:29 tom Exp $") +MODULE_ID("$Id: m_post.c,v 1.36 2021/05/08 20:20:01 tom Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu @@ -215,45 +215,48 @@ _nc_Draw_Menu(const MENU *menu) lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : item; - do + if (item != NULL) { - ITEM *lasthor; - - wmove(menu->win, y, 0); - - hitem = item; - lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : hitem; - do { - _nc_Post_Item(menu, hitem); + ITEM *lasthor; - wattron(menu->win, (int)menu->back); - if (((hitem = hitem->right) != lasthor) && hitem) + wmove(menu->win, y, 0); + + hitem = item; + lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : hitem; + + do { - int i, j, cy, cx; - chtype ch = ' '; + _nc_Post_Item(menu, hitem); - getyx(menu->win, cy, cx); - for (j = 0; j < menu->spc_rows; j++) + wattron(menu->win, (int)menu->back); + if (((hitem = hitem->right) != lasthor) && hitem) { - wmove(menu->win, cy + j, cx); - for (i = 0; i < menu->spc_cols; i++) + int i, j, cy, cx; + chtype ch = ' '; + + getyx(menu->win, cy, cx); + for (j = 0; j < menu->spc_rows; j++) { - waddch(menu->win, ch); + wmove(menu->win, cy + j, cx); + for (i = 0; i < menu->spc_cols; i++) + { + waddch(menu->win, ch); + } } + wmove(menu->win, cy, cx + menu->spc_cols); } - wmove(menu->win, cy, cx + menu->spc_cols); } - } - while (hitem && (hitem != lasthor)); - wattroff(menu->win, (int)menu->back); + while (hitem && (hitem != lasthor)); + wattroff(menu->win, (int)menu->back); - item = item->down; - y += menu->spc_rows; + item = item->down; + y += menu->spc_rows; + } + while (item && (item != lastvert)); } - while (item && (item != lastvert)); } /*--------------------------------------------------------------------------- diff --git a/ncurses/base/lib_bkgd.c b/ncurses/base/lib_bkgd.c index 23effc7c..4f990808 100644 --- a/ncurses/base/lib_bkgd.c +++ b/ncurses/base/lib_bkgd.c @@ -37,7 +37,7 @@ #include -MODULE_ID("$Id: lib_bkgd.c,v 1.62 2021/02/13 20:06:54 tom Exp $") +MODULE_ID("$Id: lib_bkgd.c,v 1.63 2021/05/08 14:58:12 tom Exp $") static const NCURSES_CH_T blank = NewChar(BLANK_TEXT); @@ -64,7 +64,7 @@ wbkgrndset(WINDOW *win, const ARG_CH_T ch) { int pair; - if ((pair = GetPair(win->_nc_bkgd)) != 0) + if (GetPair(win->_nc_bkgd) != 0) SET_WINDOW_PAIR(win, 0); if ((pair = GetPair(CHDEREF(ch))) != 0) SET_WINDOW_PAIR(win, pair); diff --git a/ncurses/base/lib_color.c b/ncurses/base/lib_color.c index 907e9743..e4276784 100644 --- a/ncurses/base/lib_color.c +++ b/ncurses/base/lib_color.c @@ -49,7 +49,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_color.c,v 1.146 2021/02/14 00:17:09 tom Exp $") +MODULE_ID("$Id: lib_color.c,v 1.147 2021/05/08 15:11:48 tom Exp $") #ifdef USE_TERM_DRIVER #define CanChange InfoOf(SP_PARM).canchange @@ -266,7 +266,7 @@ init_direct_colors(NCURSES_SP_DCL0) ; } - if ((n = tigetflag(name)) > 0) { + if (tigetflag(name) > 0) { n = (width + 2) / 3; result->bits.red = UChar(n); result->bits.green = UChar(n); @@ -840,52 +840,57 @@ _nc_color_content(SCREEN *sp, int color, int *r, int *g, int *b) (void *) g, (void *) b)); - if (sp == 0) - returnCode(result); - - maxcolors = MaxColors; + if (sp != 0) { + maxcolors = MaxColors; - if (color < 0 || !OkColorHi(color) || !sp->_coloron) { - result = ERR; - } else { - int c_r, c_g, c_b; + if (color >= 0 && OkColorHi(color) && sp->_coloron) { + int c_r, c_g, c_b; - if (sp->_direct_color.value) { - rgb_bits_t *work = &(sp->_direct_color); + if (sp->_direct_color.value) { + rgb_bits_t *work = &(sp->_direct_color); #define max_direct_color(name) ((1 << work->bits.name) - 1) #define value_direct_color(max) (1000 * ((color >> bitoff) & max)) / max - int max_r = max_direct_color(red); - int max_g = max_direct_color(green); - int max_b = max_direct_color(blue); + int max_r = max_direct_color(red); + int max_g = max_direct_color(green); + int max_b = max_direct_color(blue); - int bitoff = 0; + int bitoff = 0; - c_b = value_direct_color(max_b); - bitoff += work->bits.blue; + c_b = value_direct_color(max_b); + bitoff += work->bits.blue; - c_g = value_direct_color(max_g); - bitoff += work->bits.green; + c_g = value_direct_color(max_g); + bitoff += work->bits.green; - c_r = value_direct_color(max_r); + c_r = value_direct_color(max_r); - } else { - c_r = sp->_color_table[color].red; - c_g = sp->_color_table[color].green; - c_b = sp->_color_table[color].blue; - } + } else { + c_r = sp->_color_table[color].red; + c_g = sp->_color_table[color].green; + c_b = sp->_color_table[color].blue; + } + + if (r) + *r = c_r; + if (g) + *g = c_g; + if (b) + *b = c_b; + TR(TRACE_ATTRS, ("...color_content(%d,%d,%d,%d)", + color, c_r, c_g, c_b)); + result = OK; + } + } + if (result != OK) { if (r) - *r = c_r; + *r = 0; if (g) - *g = c_g; + *g = 0; if (b) - *b = c_b; - - TR(TRACE_ATTRS, ("...color_content(%d,%d,%d,%d)", - color, c_r, c_g, c_b)); - result = OK; + *b = 0; } returnCode(result); } diff --git a/ncurses/base/lib_set_term.c b/ncurses/base/lib_set_term.c index c2751ec4..264fb98e 100644 --- a/ncurses/base/lib_set_term.c +++ b/ncurses/base/lib_set_term.c @@ -54,7 +54,7 @@ #undef CUR #define CUR SP_TERMTYPE -MODULE_ID("$Id: lib_set_term.c,v 1.177 2021/04/17 15:04:41 tom Exp $") +MODULE_ID("$Id: lib_set_term.c,v 1.179 2021/05/08 21:48:34 tom Exp $") #ifdef USE_TERM_DRIVER #define MaxColors InfoOf(sp).maxcolors @@ -417,7 +417,6 @@ NCURSES_SP_NAME(_nc_setupscreen) ( fflush(output); _setmode(fileno(output), _O_BINARY); #endif - NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_ARGx output, TRUE); sp->_lines = (NCURSES_SIZE_T) slines; sp->_lines_avail = (NCURSES_SIZE_T) slines; sp->_columns = (NCURSES_SIZE_T) scolumns; @@ -500,7 +499,7 @@ NCURSES_SP_NAME(_nc_setupscreen) ( p = extract_fgbg(p, &(sp->_default_fg)); p = extract_fgbg(p, &(sp->_default_bg)); if (*p) /* assume rxvt was compiled with xpm support */ - p = extract_fgbg(p, &(sp->_default_bg)); + extract_fgbg(p, &(sp->_default_bg)); TR(TRACE_CHARPUT | TRACE_MOVE, ("decoded fg=%d, bg=%d", sp->_default_fg, sp->_default_bg)); if (sp->_default_fg >= MaxColors) { @@ -697,6 +696,9 @@ NCURSES_SP_NAME(_nc_setupscreen) ( formats (4-4 or 3-2-3) for which there may be some hardware support. */ if (rop->hook == _nc_slk_initialize) { + if (!TerminalOf(sp)) { + continue; + } if (!(NumLabels <= 0 || !SLK_STDFMT(slk_format))) { continue; } diff --git a/ncurses/base/new_pair.c b/ncurses/base/new_pair.c index c04f4acb..33369da4 100644 --- a/ncurses/base/new_pair.c +++ b/ncurses/base/new_pair.c @@ -61,7 +61,7 @@ #endif -MODULE_ID("$Id: new_pair.c,v 1.21 2021/02/14 00:17:09 tom Exp $") +MODULE_ID("$Id: new_pair.c,v 1.22 2021/05/08 15:26:34 tom Exp $") #if NCURSES_EXT_COLORS @@ -297,7 +297,7 @@ NCURSES_SP_NAME(alloc_pair) (NCURSES_SP_DCLx int fg, int bg) found = TRUE; } } - if (!found) { + if (!found && SP_PARM->_color_pairs != NULL) { for (pair = 1; pair <= hint; pair++) { if (SP_PARM->_color_pairs[pair].mode == cpFREE) { T(("found gap %d", pair)); diff --git a/ncurses/tinfo/alloc_entry.c b/ncurses/tinfo/alloc_entry.c index 4bf7d6c8..de280124 100644 --- a/ncurses/tinfo/alloc_entry.c +++ b/ncurses/tinfo/alloc_entry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2013,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -48,7 +48,7 @@ #include -MODULE_ID("$Id: alloc_entry.c,v 1.64 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: alloc_entry.c,v 1.65 2021/05/04 23:15:34 tom Exp $") #define ABSENT_OFFSET -1 #define CANCELLED_OFFSET -2 @@ -242,7 +242,7 @@ _nc_merge_entry(ENTRY * const target, ENTRY * const source) _nc_align_termtype(to, from); #endif for_each_boolean(i, from) { - if (to->Booleans[i] != (char) CANCELLED_BOOLEAN) { + if (to->Booleans[i] != (NCURSES_SBOOL) CANCELLED_BOOLEAN) { int mergebool = from->Booleans[i]; if (mergebool == CANCELLED_BOOLEAN) diff --git a/ncurses/tinfo/comp_parse.c b/ncurses/tinfo/comp_parse.c index e47625b3..2bc94853 100644 --- a/ncurses/tinfo/comp_parse.c +++ b/ncurses/tinfo/comp_parse.c @@ -48,7 +48,7 @@ #include -MODULE_ID("$Id: comp_parse.c,v 1.112 2021/02/27 21:01:21 tom Exp $") +MODULE_ID("$Id: comp_parse.c,v 1.113 2021/05/08 15:03:42 tom Exp $") static void sanity_check2(TERMTYPE2 *, bool); NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2) (TERMTYPE2 *, bool) = sanity_check2; @@ -457,8 +457,9 @@ _nc_resolve_uses2(bool fullresolve, bool literal) /* verify that there are no earlier uses */ for (j = 0; j < i; ++j) { - if (!strcmp(qp->uses[j].link->tterm.term_names, - rp->tterm.term_names)) { + if (qp->uses[j].link != NULL + && !strcmp(qp->uses[j].link->tterm.term_names, + rp->tterm.term_names)) { _nc_warning("duplicate use=%s", lookfor); break; } @@ -487,8 +488,9 @@ _nc_resolve_uses2(bool fullresolve, bool literal) /* verify that there are no earlier uses */ for (j = 0; j < i; ++j) { - if (!strcmp(qp->uses[j].link->tterm.term_names, - rp->tterm.term_names)) { + if (qp->uses[j].link != NULL + && !strcmp(qp->uses[j].link->tterm.term_names, + rp->tterm.term_names)) { _nc_warning("duplicate use=%s", lookfor); break; } diff --git a/ncurses/tinfo/lib_tputs.c b/ncurses/tinfo/lib_tputs.c index 4b89a19e..b9ca41cc 100644 --- a/ncurses/tinfo/lib_tputs.c +++ b/ncurses/tinfo/lib_tputs.c @@ -52,7 +52,7 @@ #include /* ospeed */ #include -MODULE_ID("$Id: lib_tputs.c,v 1.107 2021/04/03 18:45:53 tom Exp $") +MODULE_ID("$Id: lib_tputs.c,v 1.108 2021/05/08 23:27:40 tom Exp $") NCURSES_EXPORT_VAR(char) PC = 0; /* used by termcap library */ NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0; /* used by termcap library */ @@ -276,8 +276,8 @@ NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx NCURSES_SP_OUTC outc) { NCURSES_SP_OUTC my_outch = GetOutCh(); - bool always_delay; - bool normal_delay; + bool always_delay = FALSE; + bool normal_delay = FALSE; int number; #if BSD_TPUTS int trailpad; @@ -305,32 +305,30 @@ NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx } #endif /* TRACE */ - if (SP_PARM != 0 && !HasTInfoTerminal(SP_PARM)) - return ERR; - if (!VALID_STRING(string)) return ERR; - if ( + if (SP_PARM != 0 && HasTInfoTerminal(SP_PARM)) { + if ( #if NCURSES_SP_FUNCS - (SP_PARM != 0 && SP_PARM->_term == 0) + (SP_PARM != 0 && SP_PARM->_term == 0) #else - cur_term == 0 + cur_term == 0 #endif - ) { - always_delay = FALSE; - normal_delay = TRUE; - } else { - always_delay = (string == bell) || (string == flash_screen); - normal_delay = - !xon_xoff - && padding_baud_rate + ) { + always_delay = FALSE; + normal_delay = TRUE; + } else { + always_delay = (string == bell) || (string == flash_screen); + normal_delay = + !xon_xoff + && padding_baud_rate #if NCURSES_NO_PADDING - && !GetNoPadding(SP_PARM) + && !GetNoPadding(SP_PARM) #endif - && (_nc_baudrate(ospeed) >= padding_baud_rate); + && (_nc_baudrate(ospeed) >= padding_baud_rate); + } } - #if BSD_TPUTS /* * This ugly kluge deals with the fact that some ancient BSD programs diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog index 9fb13212..91c778f8 100644 --- a/package/debian-mingw/changelog +++ b/package/debian-mingw/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.2+20210501) unstable; urgency=low +ncurses6 (6.2+20210508) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 01 May 2021 05:40:30 -0400 + -- Thomas E. Dickey Sat, 08 May 2021 09:20:24 -0400 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog index 9fb13212..91c778f8 100644 --- a/package/debian-mingw64/changelog +++ b/package/debian-mingw64/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.2+20210501) unstable; urgency=low +ncurses6 (6.2+20210508) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 01 May 2021 05:40:30 -0400 + -- Thomas E. Dickey Sat, 08 May 2021 09:20:24 -0400 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian/changelog b/package/debian/changelog index 54e72bc2..c78ce2e7 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.2+20210501) unstable; urgency=low +ncurses6 (6.2+20210508) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 01 May 2021 05:40:30 -0400 + -- Thomas E. Dickey Sat, 08 May 2021 09:20:24 -0400 ncurses6 (5.9-20120608) unstable; urgency=low diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi index 37f63ae8..90a791dc 100644 --- a/package/mingw-ncurses.nsi +++ b/package/mingw-ncurses.nsi @@ -1,4 +1,4 @@ -; $Id: mingw-ncurses.nsi,v 1.456 2021/05/01 09:40:30 tom Exp $ +; $Id: mingw-ncurses.nsi,v 1.457 2021/05/08 13:20:24 tom Exp $ ; TODO add examples ; TODO bump ABI to 6 @@ -10,7 +10,7 @@ !define VERSION_MAJOR "6" !define VERSION_MINOR "2" !define VERSION_YYYY "2021" -!define VERSION_MMDD "0501" +!define VERSION_MMDD "0508" !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD} !define MY_ABI "5" diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec index 7b95fb23..4bd7e182 100644 --- a/package/mingw-ncurses.spec +++ b/package/mingw-ncurses.spec @@ -3,7 +3,7 @@ Summary: shared libraries for terminal handling Name: mingw32-ncurses6 Version: 6.2 -Release: 20210501 +Release: 20210508 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/package/ncurses.spec b/package/ncurses.spec index d2b20853..a8753c49 100644 --- a/package/ncurses.spec +++ b/package/ncurses.spec @@ -1,7 +1,7 @@ Summary: shared libraries for terminal handling Name: ncurses6 Version: 6.2 -Release: 20210501 +Release: 20210508 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/package/ncursest.spec b/package/ncursest.spec index deca9d84..1bc1937d 100644 --- a/package/ncursest.spec +++ b/package/ncursest.spec @@ -1,7 +1,7 @@ Summary: Curses library with POSIX thread support. Name: ncursest6 Version: 6.2 -Release: 20210501 +Release: 20210508 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/test/demo_menus.c b/test/demo_menus.c index adaa5949..9f3b4d22 100644 --- a/test/demo_menus.c +++ b/test/demo_menus.c @@ -27,7 +27,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: demo_menus.c,v 1.72 2021/03/20 16:05:49 tom Exp $ + * $Id: demo_menus.c,v 1.73 2021/05/08 19:41:08 tom Exp $ * * Demonstrate a variety of functions from the menu library. * Thomas Dickey - 2005/4/9 @@ -565,7 +565,7 @@ tracetrace(unsigned tlevel) } _nc_SPRINTF(buf, _nc_SLIMIT(need) "0x%02x = {", tlevel); if (tlevel == 0) { - _nc_STRCAT(buf, t_tbl[0].name, need); + _nc_STRCAT(buf, t_tbl[0].name ? t_tbl[0].name : "", need); _nc_STRCAT(buf, ", ", need); } else { for (n = 1; t_tbl[n].name != 0; n++) diff --git a/test/hanoi.c b/test/hanoi.c index 8f1792d9..610b2d8a 100644 --- a/test/hanoi.c +++ b/test/hanoi.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019,2020 Thomas E. Dickey * + * Copyright 2019-2020,2021 Thomas E. Dickey * * Copyright 1998-2014,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -42,7 +42,7 @@ * * Date: 05.Nov.90 * - * $Id: hanoi.c,v 1.41 2020/02/02 23:34:34 tom Exp $ + * $Id: hanoi.c,v 1.42 2021/05/08 20:44:44 tom Exp $ */ #include @@ -283,7 +283,7 @@ main(int argc, char **argv) } setlocale(LC_ALL, ""); - switch (ch = (argc - optind)) { + switch (argc - optind) { case 2: if (strcmp(argv[optind + 1], "a")) { usage(); diff --git a/test/knight.c b/test/knight.c index f9f725b0..08ccf225 100644 --- a/test/knight.c +++ b/test/knight.c @@ -34,7 +34,7 @@ * Eric S. Raymond July 22 1995. Mouse support * added September 20th 1995. * - * $Id: knight.c,v 1.48 2021/04/25 00:10:43 tom Exp $ + * $Id: knight.c,v 1.49 2021/05/08 19:32:15 tom Exp $ */ #include @@ -621,10 +621,10 @@ play(void) for (i = 0; i < ylimit; i++) { for (j = 0; j < xlimit; j++) { - squares[i][j] = FALSE; unmarkcell(i, j); } } + memset(squares, 0, sizeof(squares)); memset(history, 0, sizeof(history)); history[0].y = history[0].x = -1; history[1].y = history[1].x = -1; diff --git a/test/ncurses.c b/test/ncurses.c index 37693ac4..966c76af 100644 --- a/test/ncurses.c +++ b/test/ncurses.c @@ -41,7 +41,7 @@ AUTHOR Author: Eric S. Raymond 1993 Thomas E. Dickey (beginning revision 1.27 in 1996). -$Id: ncurses.c,v 1.524 2021/03/20 16:11:50 tom Exp $ +$Id: ncurses.c,v 1.525 2021/05/08 19:44:31 tom Exp $ ***************************************************************************/ @@ -5531,7 +5531,7 @@ panner_legend(int line) "Number repeats. Toggle legend:? filler:a timer:t scrollmark:s." }; int n = ((int) SIZEOF(legend) - (LINES - line)); - if (n >= 0) { + if (n >= 0 && n < (int) SIZEOF(legend)) { if (move(line, 0) != ERR) { if (show_panner_legend) printw("%s", legend[n]); @@ -6232,7 +6232,7 @@ tracetrace(unsigned tlevel) } _nc_SPRINTF(buf, _nc_SLIMIT(need) "0x%02x = {", tlevel); if (tlevel == 0) { - _nc_STRCAT(buf, t_tbl[0].name, need); + _nc_STRCAT(buf, t_tbl[0].name ? t_tbl[0].name : "", need); _nc_STRCAT(buf, ", ", need); } else { for (n = 1; t_tbl[n].name != 0; n++) diff --git a/test/picsmap.c b/test/picsmap.c index 1b4758d4..f95747f4 100644 --- a/test/picsmap.c +++ b/test/picsmap.c @@ -27,7 +27,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: picsmap.c,v 1.138 2021/05/01 20:38:40 tom Exp $ + * $Id: picsmap.c,v 1.139 2021/05/08 15:56:05 tom Exp $ * * Author: Thomas E. Dickey * @@ -604,7 +604,6 @@ read_palette(const char *filename) continue; } } - s += strlen(s); if (tries & 2) { int len = (int) strlen(filename); diff --git a/test/test_add_wchstr.c b/test/test_add_wchstr.c index a7ada59e..b1d320bb 100644 --- a/test/test_add_wchstr.c +++ b/test/test_add_wchstr.c @@ -27,7 +27,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: test_add_wchstr.c,v 1.28 2021/03/27 23:41:34 tom Exp $ + * $Id: test_add_wchstr.c,v 1.29 2021/05/08 20:04:10 tom Exp $ * * Demonstrate the waddwchstr() and wadd_wch functions. * Thomas Dickey - 2009/9/12 @@ -133,10 +133,10 @@ ChWLen(const wchar_t *source) size_t adjust = 0; size_t n; - for (n = 0; n < result; ++n) { + for (n = 0; source[n] != 0; ++n) { const char *s; - if (source[n] < 256 && (s = unctrl((chtype) source[n])) != 0) { + if ((source[n] < 256) && (s = unctrl((chtype) source[n])) != 0) { adjust += (strlen(s) - 1); } } diff --git a/test/view.c b/test/view.c index 30a9c7ff..c4c53c79 100644 --- a/test/view.c +++ b/test/view.c @@ -52,7 +52,7 @@ * scroll operation worked, and the refresh() code only had to do a * partial repaint. * - * $Id: view.c,v 1.140 2021/03/27 22:42:22 tom Exp $ + * $Id: view.c,v 1.141 2021/05/08 15:57:04 tom Exp $ */ #include @@ -78,9 +78,7 @@ static int num_lines; static bool n_option = FALSE; #endif -static GCC_NORETURN void usage(void); - -static void +static GCC_NORETURN void failed(const char *msg) { endwin(); @@ -368,7 +366,7 @@ read_file(const char *filename) free(my_blob); } -static void +static GCC_NORETURN void usage(void) { static const char *msg[] = -- 2.44.0