From 410952f85a313e9ddb6a1d5939dec1b89c8a40f9 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sat, 27 May 2023 22:35:09 +0000 Subject: [PATCH] ncurses 6.4 - patch 20230527 + fixes for compiler warnings/cppcheck. --- NEWS | 5 +- VERSION | 2 +- dist.mk | 4 +- ncurses/base/lib_mouse.c | 4 +- ncurses/base/lib_refresh.c | 6 +- ncurses/curses.priv.h | 8 +-- ncurses/tinfo/alloc_ttype.c | 6 +- ncurses/tinfo/comp_parse.c | 7 ++- ncurses/tinfo/comp_scan.c | 23 ++++---- ncurses/tinfo/entries.c | 6 +- ncurses/tinfo/lib_termcap.c | 6 +- ncurses/tinfo/strings.c | 6 +- ncurses/tinfo/write_entry.c | 25 ++++---- ncurses/trace/visbuf.c | 8 ++- 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 +- progs/dump_entry.c | 6 +- progs/infocmp.c | 6 +- progs/tabs.c | 8 +-- progs/tic.c | 99 ++++++++++++++++---------------- test/bs.c | 14 +++-- test/demo_forms.c | 6 +- test/demo_menus.c | 5 +- test/demo_termcap.c | 19 +++--- test/demo_terminfo.c | 19 +++--- test/echochar.c | 6 +- test/movewindow.c | 9 +-- test/ncurses.c | 12 ++-- test/test_addwstr.c | 6 +- test/test_delwin.c | 6 +- test/test_sgr.c | 6 +- 36 files changed, 192 insertions(+), 173 deletions(-) diff --git a/NEWS b/NEWS index 9eeeb572..81a433ad 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.3955 2023/05/20 18:39:29 tom Exp $ +-- $Id: NEWS,v 1.3957 2023/05/27 20:09:50 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -46,6 +46,9 @@ 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. +20230527 + + fixes for compiler warnings/cppcheck. + 20230520 + fixes for compiler warnings in MinGW environments. diff --git a/VERSION b/VERSION index 8a66af02..122a064f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5:0:10 6.4 20230520 +5:0:10 6.4 20230527 diff --git a/dist.mk b/dist.mk index 6bfa61d4..82a2f1c5 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.1545 2023/05/20 14:39:41 tom Exp $ +# $Id: dist.mk,v 1.1546 2023/05/27 09:18:04 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 = 4 -NCURSES_PATCH = 20230520 +NCURSES_PATCH = 20230527 # 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_mouse.c b/ncurses/base/lib_mouse.c index 319a276a..b35ac750 100644 --- a/ncurses/base/lib_mouse.c +++ b/ncurses/base/lib_mouse.c @@ -85,7 +85,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_mouse.c,v 1.198 2023/03/25 23:27:28 tom Exp $") +MODULE_ID("$Id: lib_mouse.c,v 1.199 2023/05/27 20:13:10 tom Exp $") #include @@ -776,7 +776,7 @@ _nc_mouse_init(SCREEN *sp) { bool result = FALSE; - T((T_CALLED("_nc_mouse_init(%p)"), sp)); + T((T_CALLED("_nc_mouse_init(%p)"), (void *)sp)); if (sp != 0) { if (!sp->_mouse_initialized) { diff --git a/ncurses/base/lib_refresh.c b/ncurses/base/lib_refresh.c index 4579cbf8..bcaa4624 100644 --- a/ncurses/base/lib_refresh.c +++ b/ncurses/base/lib_refresh.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020,2021 Thomas E. Dickey * + * Copyright 2020-2021,2023 Thomas E. Dickey * * Copyright 1998-2010,2011 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -43,7 +43,7 @@ #include -MODULE_ID("$Id: lib_refresh.c,v 1.47 2021/11/06 22:22:03 tom Exp $") +MODULE_ID("$Id: lib_refresh.c,v 1.48 2023/05/27 20:13:10 tom Exp $") NCURSES_EXPORT(int) wrefresh(WINDOW *win) @@ -208,7 +208,6 @@ wnoutrefresh(WINDOW *win) }); if_WIDEC({ - static cchar_t blank = BLANK; int last_dst = begx + ((last_src < win->_maxx) ? last_src : win->_maxx); @@ -254,6 +253,7 @@ wnoutrefresh(WINDOW *win) */ if (fix_left < dst_col || fix_right > last_dst) { for (j = fix_left; j <= fix_right; ++j) { + static cchar_t blank = BLANK; nline->text[j] = blank; CHANGED_CELL(nline, j); } diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index 5531c064..2c872994 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -35,7 +35,7 @@ ****************************************************************************/ /* - * $Id: curses.priv.h,v 1.666 2023/05/20 18:20:39 tom Exp $ + * $Id: curses.priv.h,v 1.667 2023/05/27 20:13:10 tom Exp $ * * curses.priv.h * @@ -2080,7 +2080,7 @@ typedef struct { /* strings.c */ extern NCURSES_EXPORT(string_desc *) _nc_str_init (string_desc *, char *, size_t); extern NCURSES_EXPORT(string_desc *) _nc_str_null (string_desc *, size_t); -extern NCURSES_EXPORT(string_desc *) _nc_str_copy (string_desc *, string_desc *); +extern NCURSES_EXPORT(string_desc *) _nc_str_copy (string_desc *, const string_desc *); extern NCURSES_EXPORT(bool) _nc_safe_strcat (string_desc *, const char *); extern NCURSES_EXPORT(bool) _nc_safe_strcpy (string_desc *, const char *); @@ -2121,7 +2121,7 @@ extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE2 extern NCURSES_EXPORT(int) _nc_setup_tinfo(const char *, TERMTYPE2 *); extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, int, int); extern NCURSES_EXPORT(int) _nc_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *)); -extern NCURSES_EXPORT(int) _nc_trans_string (char *, char *); +extern NCURSES_EXPORT(int) _nc_trans_string (char *, const char *); extern NCURSES_EXPORT(void) _nc_init_termtype (TERMTYPE2 *const); extern NCURSES_EXPORT(void) _nc_do_color (int, int, int, NCURSES_OUTC); extern NCURSES_EXPORT(void) _nc_flush (void); @@ -2170,7 +2170,7 @@ extern NCURSES_EXPORT(void) _nc_comp_userdefs_leaks(void); extern NCURSES_EXPORT(void) _nc_db_iterator_leaks(void); extern NCURSES_EXPORT(void) _nc_keyname_leaks(void); extern NCURSES_EXPORT(void) _nc_names_leaks(void); -extern NCURSES_EXPORT(void) _nc_tgetent_leak(TERMINAL *); +extern NCURSES_EXPORT(void) _nc_tgetent_leak(const TERMINAL *); extern NCURSES_EXPORT(void) _nc_tgetent_leaks(void); #endif diff --git a/ncurses/tinfo/alloc_ttype.c b/ncurses/tinfo/alloc_ttype.c index 36085e47..ff32770d 100644 --- a/ncurses/tinfo/alloc_ttype.c +++ b/ncurses/tinfo/alloc_ttype.c @@ -43,7 +43,7 @@ #include -MODULE_ID("$Id: alloc_ttype.c,v 1.48 2023/04/22 15:50:28 tom Exp $") +MODULE_ID("$Id: alloc_ttype.c,v 1.49 2023/05/27 20:13:10 tom Exp $") #if NCURSES_XNAMES /* @@ -378,8 +378,8 @@ adjust_cancels(TERMTYPE2 *to, TERMTYPE2 *from) int j, k; DEBUG(3, (T_CALLED("adjust_cancels(%s), from(%s)"), - to ? NonNull(to->term_names) : "?", - from ? NonNull(from->term_names) : "?")); + NonNull(to->term_names), + NonNull(from->term_names))); for (j = first; j < last;) { char *name = to->ext_Names[j]; int j_str = to->num_Strings - first - to->ext_Strings; diff --git a/ncurses/tinfo/comp_parse.c b/ncurses/tinfo/comp_parse.c index 74fba109..4244df4e 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.132 2023/05/20 18:08:48 tom Exp $") +MODULE_ID("$Id: comp_parse.c,v 1.133 2023/05/27 20:13:10 tom Exp $") static void sanity_check2(TERMTYPE2 *, bool); NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2) (TERMTYPE2 *, bool) = sanity_check2; @@ -264,8 +264,9 @@ _nc_read_entry_source(FILE *fp, char *buf, if (_nc_tail) { /* set up the head pointer */ - for (_nc_head = _nc_tail; _nc_head->last; _nc_head = _nc_head->last) - continue; + for (_nc_head = _nc_tail; _nc_head->last; _nc_head = _nc_head->last) { + /* EMPTY */ ; + } DEBUG(2, ("head = %s", _nc_head->tterm.term_names)); DEBUG(2, ("tail = %s", _nc_tail->tterm.term_names)); diff --git a/ncurses/tinfo/comp_scan.c b/ncurses/tinfo/comp_scan.c index c4b077de..3ba0835e 100644 --- a/ncurses/tinfo/comp_scan.c +++ b/ncurses/tinfo/comp_scan.c @@ -51,7 +51,7 @@ #include #include -MODULE_ID("$Id: comp_scan.c,v 1.121 2023/05/20 18:33:33 tom Exp $") +MODULE_ID("$Id: comp_scan.c,v 1.122 2023/05/27 20:13:10 tom Exp $") /* * Maximum length of string capability we'll accept before raising an error. @@ -328,9 +328,11 @@ end_of_stream(void) static NCURSES_INLINE int eat_escaped_newline(int ch) { - if (ch == '\\') - while ((ch = next_char()) == '\n' || iswhite(ch)) - continue; + if (ch == '\\') { + while ((ch = next_char()) == '\n' || iswhite(ch)) { + /* EMPTY */ ; + } + } return ch; } @@ -434,7 +436,6 @@ _nc_get_token(bool silent) while ((ch = next_char()) == '\n' || iswhite(ch)) { if (ch == '\n') had_newline = TRUE; - continue; } ch = eat_escaped_newline(ch); @@ -459,8 +460,9 @@ _nc_get_token(bool silent) dot_flag = TRUE; DEBUG(8, ("dot-flag set")); - while ((ch = next_char()) == '.' || iswhite(ch)) - continue; + while ((ch = next_char()) == '.' || iswhite(ch)) { + /* EMPTY */ ; + } } if (ch == EOF) { @@ -601,8 +603,9 @@ _nc_get_token(bool silent) /* throw away trailing /, *$/ */ for (--tok_ptr; iswhite(*tok_ptr) || *tok_ptr == ','; - tok_ptr--) - continue; + tok_ptr--) { + /* EMPTY */ ; + } tok_ptr[1] = '\0'; } @@ -831,7 +834,7 @@ _nc_get_token(bool silent) */ NCURSES_EXPORT(int) -_nc_trans_string(char *ptr, char *last) +_nc_trans_string(char *ptr, const char *const last) { int count = 0; int number = 0; diff --git a/ncurses/tinfo/entries.c b/ncurses/tinfo/entries.c index 8c5e10c0..f47fd3fe 100644 --- a/ncurses/tinfo/entries.c +++ b/ncurses/tinfo/entries.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019-2021,2022 Thomas E. Dickey * + * Copyright 2019-2022,2023 Thomas E. Dickey * * Copyright 2006-2012,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,7 +38,7 @@ #include -MODULE_ID("$Id: entries.c,v 1.34 2022/08/13 16:57:35 tom Exp $") +MODULE_ID("$Id: entries.c,v 1.35 2023/05/27 20:13:10 tom Exp $") /**************************************************************************** * @@ -65,7 +65,7 @@ NCURSES_EXPORT_VAR(ENTRY *) _nc_head = 0; NCURSES_EXPORT_VAR(ENTRY *) _nc_tail = 0; static ENTRY * -_nc_delink_entry(ENTRY * headp, TERMTYPE2 *tterm) +_nc_delink_entry(ENTRY * headp, const TERMTYPE2 *const tterm) /* delink the allocated storage for the given list entry */ { ENTRY *ep, *last; diff --git a/ncurses/tinfo/lib_termcap.c b/ncurses/tinfo/lib_termcap.c index 5ce43a3c..2ece9859 100644 --- a/ncurses/tinfo/lib_termcap.c +++ b/ncurses/tinfo/lib_termcap.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018,2020 Thomas E. Dickey * + * Copyright 2018-2020,2023 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -49,7 +49,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_termcap.c,v 1.88 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: lib_termcap.c,v 1.89 2023/05/27 20:13:10 tom Exp $") NCURSES_EXPORT_VAR(char *) UP = 0; NCURSES_EXPORT_VAR(char *) BC = 0; @@ -399,7 +399,7 @@ tgetstr(const char *id, char **area) #undef CacheInx #define CacheInx num NCURSES_EXPORT(void) -_nc_tgetent_leak(TERMINAL *termp) +_nc_tgetent_leak(const TERMINAL *const termp) { if (termp != 0) { int num; diff --git a/ncurses/tinfo/strings.c b/ncurses/tinfo/strings.c index a1d8beb6..03f59c24 100644 --- a/ncurses/tinfo/strings.c +++ b/ncurses/tinfo/strings.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2023 Thomas E. Dickey * * Copyright 2000-2012,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,7 +38,7 @@ #include #include -MODULE_ID("$Id: strings.c,v 1.10 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: strings.c,v 1.11 2023/05/27 20:13:10 tom Exp $") /**************************************************************************** * Useful string functions (especially for mvcur) @@ -95,7 +95,7 @@ _nc_str_null(string_desc * dst, size_t len) * Copy a descriptor */ NCURSES_EXPORT(string_desc *) -_nc_str_copy(string_desc * dst, string_desc * src) +_nc_str_copy(string_desc * dst, const string_desc * const src) { *dst = *src; return dst; diff --git a/ncurses/tinfo/write_entry.c b/ncurses/tinfo/write_entry.c index 156ce744..9de73364 100644 --- a/ncurses/tinfo/write_entry.c +++ b/ncurses/tinfo/write_entry.c @@ -42,7 +42,7 @@ #include -MODULE_ID("$Id: write_entry.c,v 1.126 2023/04/29 20:30:57 tom Exp $") +MODULE_ID("$Id: write_entry.c,v 1.127 2023/05/27 20:13:10 tom Exp $") #if 1 #define TRACE_OUT(p) DEBUG(2, p) @@ -128,18 +128,16 @@ check_writeable(int code) char dir[sizeof(LEAF_FMT)]; char *s = 0; - if (code == 0 || (s = (strchr) (dirnames, code)) == 0) + if (code == 0 || (s = (strchr) (dirnames, code)) == 0) { _nc_err_abort("Illegal terminfo subdirectory \"" LEAF_FMT "\"", code); - - if (verified[s - dirnames]) - return; - - _nc_SPRINTF(dir, _nc_SLIMIT(sizeof(dir)) LEAF_FMT, code); - if (make_db_root(dir) < 0) { - _nc_err_abort("%s/%s: permission denied", _nc_tic_dir(0), dir); + } else if (!verified[s - dirnames]) { + _nc_SPRINTF(dir, _nc_SLIMIT(sizeof(dir)) LEAF_FMT, code); + if (make_db_root(dir) < 0) { + _nc_err_abort("%s/%s: permission denied", _nc_tic_dir(0), dir); + } else { + verified[s - dirnames] = TRUE; + } } - - verified[s - dirnames] = TRUE; } #endif /* !USE_HASHED_DB */ @@ -333,8 +331,9 @@ _nc_write_entry(TERMTYPE2 *const tp) if (ptr != name_list) { *ptr = '\0'; - for (ptr = name_list; *ptr != '\0' && *ptr != '|'; ptr++) - continue; + for (ptr = name_list; *ptr != '\0' && *ptr != '|'; ptr++) { + /* EMPTY */ ; + } if (*ptr == '\0') other_names = ptr; diff --git a/ncurses/trace/visbuf.c b/ncurses/trace/visbuf.c index aca8affc..590e4230 100644 --- a/ncurses/trace/visbuf.c +++ b/ncurses/trace/visbuf.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019-2020,2021 Thomas E. Dickey * + * Copyright 2019-2021,2023 Thomas E. Dickey * * Copyright 2001-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -43,7 +43,7 @@ #include #include -MODULE_ID("$Id: visbuf.c,v 1.53 2021/02/27 20:07:57 tom Exp $") +MODULE_ID("$Id: visbuf.c,v 1.54 2023/05/27 20:13:10 tom Exp $") #define NUM_VISBUFS 4 @@ -67,7 +67,9 @@ static const char r_brace[] = StringOf(R_BRACE); static char * _nc_vischar(char *tp, unsigned c LIMIT_ARG) { - if (c == '"' || c == '\\') { + if (tp == NULL) { + return NULL; + } else if (c == '"' || c == '\\') { *tp++ = '\\'; *tp++ = (char) c; } else if (is7bits((int) c) && (isgraph((int) c) || c == ' ')) { diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog index 8714f554..6c037cd7 100644 --- a/package/debian-mingw/changelog +++ b/package/debian-mingw/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.4+20230520) unstable; urgency=low +ncurses6 (6.4+20230527) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 20 May 2023 10:39:41 -0400 + -- Thomas E. Dickey Sat, 27 May 2023 05:18:04 -0400 ncurses6 (5.9+20131005) unstable; urgency=low diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog index 8714f554..6c037cd7 100644 --- a/package/debian-mingw64/changelog +++ b/package/debian-mingw64/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.4+20230520) unstable; urgency=low +ncurses6 (6.4+20230527) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 20 May 2023 10:39:41 -0400 + -- Thomas E. Dickey Sat, 27 May 2023 05:18:04 -0400 ncurses6 (5.9+20131005) unstable; urgency=low diff --git a/package/debian/changelog b/package/debian/changelog index 6ac66463..cbf3ddf7 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.4+20230520) unstable; urgency=low +ncurses6 (6.4+20230527) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 20 May 2023 10:39:41 -0400 + -- Thomas E. Dickey Sat, 27 May 2023 05:18:04 -0400 ncurses6 (5.9+20120608) unstable; urgency=low diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi index 1ecb27bf..75cc1d87 100644 --- a/package/mingw-ncurses.nsi +++ b/package/mingw-ncurses.nsi @@ -1,4 +1,4 @@ -; $Id: mingw-ncurses.nsi,v 1.585 2023/05/20 14:39:41 tom Exp $ +; $Id: mingw-ncurses.nsi,v 1.586 2023/05/27 09:18:04 tom Exp $ ; TODO add examples ; TODO bump ABI to 6 @@ -10,7 +10,7 @@ !define VERSION_MAJOR "6" !define VERSION_MINOR "4" !define VERSION_YYYY "2023" -!define VERSION_MMDD "0520" +!define VERSION_MMDD "0527" !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD} !define MY_ABI "5" diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec index ae1fe318..edf59183 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.4 -Release: 20230520 +Release: 20230527 License: X11 Group: Development/Libraries URL: https://invisible-island.net/ncurses/ diff --git a/package/ncurses.spec b/package/ncurses.spec index 7ad1c6ba..f4b2e559 100644 --- a/package/ncurses.spec +++ b/package/ncurses.spec @@ -1,7 +1,7 @@ Summary: shared libraries for terminal handling Name: ncurses6 Version: 6.4 -Release: 20230520 +Release: 20230527 License: X11 Group: Development/Libraries URL: https://invisible-island.net/ncurses/ diff --git a/package/ncursest.spec b/package/ncursest.spec index 13baeff8..b218ea6b 100644 --- a/package/ncursest.spec +++ b/package/ncursest.spec @@ -1,7 +1,7 @@ Summary: Curses library with POSIX thread support. Name: ncursest6 Version: 6.4 -Release: 20230520 +Release: 20230527 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/progs/dump_entry.c b/progs/dump_entry.c index aad715b9..be332d2e 100644 --- a/progs/dump_entry.c +++ b/progs/dump_entry.c @@ -40,7 +40,7 @@ #include /* this C file is generated */ #include /* so is this */ -MODULE_ID("$Id: dump_entry.c,v 1.195 2023/01/21 21:25:21 tom Exp $") +MODULE_ID("$Id: dump_entry.c,v 1.196 2023/05/27 20:13:10 tom Exp $") #define DISCARD(string) string = ABSENT_STRING #define PRINTF (void) printf @@ -1311,7 +1311,7 @@ fmt_entry(TERMTYPE2 *tterm, } static bool -kill_string(TERMTYPE2 *tterm, char *cap) +kill_string(TERMTYPE2 *tterm, const char *const cap) { unsigned n; for (n = 0; n < NUM_STRINGS(tterm); ++n) { @@ -1693,7 +1693,7 @@ show_entry(void) outbuf.used = (size_t) j; } else if (!infodump && ch == '\\') { outbuf.used = (size_t) j; - } else if (ch == delim && (j == 0 || outbuf.text[j - 1] != '\\')) { + } else if (ch == delim && (outbuf.text[j - 1] != '\\')) { outbuf.used = (size_t) (j + 1); } else { break; diff --git a/progs/infocmp.c b/progs/infocmp.c index 171d794d..ec5e0765 100644 --- a/progs/infocmp.c +++ b/progs/infocmp.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020-2021,2022 Thomas E. Dickey * + * Copyright 2020-2022,2023 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -43,7 +43,7 @@ #include -MODULE_ID("$Id: infocmp.c,v 1.156 2022/09/24 10:13:06 tom Exp $") +MODULE_ID("$Id: infocmp.c,v 1.157 2023/05/27 20:13:10 tom Exp $") #define MAX_STRING 1024 /* maximum formatted string */ @@ -158,7 +158,7 @@ no_numeric(int value) } static bool -no_string(char *value) +no_string(const char *const value) { bool result = (value == ABSENT_STRING); if (!strcmp(s_absent, s_cancel)) diff --git a/progs/tabs.c b/progs/tabs.c index 7378d116..c852eb85 100644 --- a/progs/tabs.c +++ b/progs/tabs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020-2021,2022 Thomas E. Dickey * + * Copyright 2020-2022,2023 Thomas E. Dickey * * Copyright 2008-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -39,7 +39,7 @@ #include #include -MODULE_ID("$Id: tabs.c,v 1.51 2022/02/26 22:44:44 tom Exp $") +MODULE_ID("$Id: tabs.c,v 1.52 2023/05/27 20:13:10 tom Exp $") static GCC_NORETURN void usage(void); @@ -183,7 +183,7 @@ decode_tabs(const char *tab_list, int margin) } static void -print_ruler(int *tab_list, const char *new_line) +print_ruler(const int *const tab_list, const char *new_line) { int last = 0; int n; @@ -649,7 +649,7 @@ main(int argc, char *argv[]) /* set tty modes to -ocrnl to allow \r */ if (isatty(STDOUT_FILENO)) { TTY new_settings = tty_settings; - new_settings.c_oflag &= (unsigned)~OCRNL; + new_settings.c_oflag &= (unsigned) ~OCRNL; update_tty_settings(&tty_settings, &new_settings); change_tty = TRUE; new_line = "\r\n"; diff --git a/progs/tic.c b/progs/tic.c index 7ae61677..d8052648 100644 --- a/progs/tic.c +++ b/progs/tic.c @@ -49,7 +49,7 @@ #include #include -MODULE_ID("$Id: tic.c,v 1.321 2023/04/08 15:51:57 tom Exp $") +MODULE_ID("$Id: tic.c,v 1.322 2023/05/27 20:13:10 tom Exp $") #define STDIN_NAME "" @@ -1169,6 +1169,7 @@ check_acs(TERMTYPE2 *tp) char *q; memset(mapped, 0, sizeof(mapped)); + memset(missing, 0, sizeof(missing)); for (p = acs_chars; *p != '\0'; p += 2) { if (p[1] == '\0') { _nc_warning("acsc has odd number of characters"); @@ -1350,8 +1351,7 @@ check_ansi_cursor(char *list[4]) for (j = 0; j < 4; ++j) { skip[j] = FALSE; for (k = 0; k < j; ++k) { - if (j != k - && !strcmp(list[j], list[k])) { + if (!strcmp(list[j], list[k])) { char *value = _nc_tic_expand(list[k], TRUE, 0); _nc_warning("repeated cursor control %s", value); repeated = TRUE; @@ -2440,60 +2440,63 @@ static void check_infotocap(TERMTYPE2 *tp, int i, const char *value) { const char *name = ExtStrname(tp, i, strnames); - int params = ((i < (int) SIZEOF(parametrized)) - ? parametrized[i] - : ((*value == 'k') - ? 0 - : has_params(value, FALSE))); char *ti_value = NULL; - char *tc_value; - bool embedded; assert(SIZEOF(parametrized) == STRCOUNT); if (!VALID_STRING(value) || (ti_value = strdup(value)) == NULL) { _nc_warning("tic-expansion of %s failed", name); - } else if ((tc_value = _nc_infotocap(name, ti_value, params)) == ABSENT_STRING) { - _nc_warning("tic-conversion of %s failed", name); - } else if (params > 0) { - int limit = 5; - int count; - bool first = TRUE; - - if (!strcmp(name, "setf") - || !strcmp(name, "setb") - || !strcmp(name, "setaf") - || !strcmp(name, "setab")) { - if ((limit = max_colors) > 256) - limit = 256; - } - for (count = 0; count < limit; ++count) { - char *ti_check = check_1_infotocap(name, ti_value, count); - char *tc_check = check_1_infotocap(name, tc_value, count); - - if (strcmp(ti_check, tc_check)) { - if (first) { - fprintf(stderr, "check_infotocap(%s)\n", name); - fprintf(stderr, "...ti '%s'\n", _nc_visbuf2(0, ti_value)); - fprintf(stderr, "...tc '%s'\n", _nc_visbuf2(0, tc_value)); - first = FALSE; + } else { + char *tc_value; + bool embedded; + int params = ((i < (int) SIZEOF(parametrized)) + ? parametrized[i] + : ((*value == 'k') + ? 0 + : has_params(value, FALSE))); + + if ((tc_value = _nc_infotocap(name, ti_value, params)) == ABSENT_STRING) { + _nc_warning("tic-conversion of %s failed", name); + } else if (params > 0) { + int limit = 5; + int count; + bool first = TRUE; + + if (!strcmp(name, "setf") + || !strcmp(name, "setb") + || !strcmp(name, "setaf") + || !strcmp(name, "setab")) { + if ((limit = max_colors) > 256) + limit = 256; + } + for (count = 0; count < limit; ++count) { + char *ti_check = check_1_infotocap(name, ti_value, count); + char *tc_check = check_1_infotocap(name, tc_value, count); + + if (strcmp(ti_check, tc_check)) { + if (first) { + fprintf(stderr, "check_infotocap(%s)\n", name); + fprintf(stderr, "...ti '%s'\n", _nc_visbuf2(0, ti_value)); + fprintf(stderr, "...tc '%s'\n", _nc_visbuf2(0, tc_value)); + first = FALSE; + } + _nc_warning("tparm-conversion of %s(%d) differs between\n\tterminfo %s\n\ttermcap %s", + name, count, + _nc_visbuf2(0, ti_check), + _nc_visbuf2(1, tc_check)); } - _nc_warning("tparm-conversion of %s(%d) differs between\n\tterminfo %s\n\ttermcap %s", - name, count, - _nc_visbuf2(0, ti_check), - _nc_visbuf2(1, tc_check)); + free(ti_check); + free(tc_check); + } + } else if (params == 0 && !same_ti_tc(ti_value, tc_value, &embedded)) { + if (embedded) { + _nc_warning("termcap equivalent of %s cannot use embedded delay", name); + } else { + _nc_warning("tic-conversion of %s changed value\n\tfrom %s\n\tto %s", + name, ti_value, tc_value); } - free(ti_check); - free(tc_check); - } - } else if (params == 0 && !same_ti_tc(ti_value, tc_value, &embedded)) { - if (embedded) { - _nc_warning("termcap equivalent of %s cannot use embedded delay", name); - } else { - _nc_warning("tic-conversion of %s changed value\n\tfrom %s\n\tto %s", - name, ti_value, tc_value); } + free(ti_value); } - free(ti_value); } static char * diff --git a/test/bs.c b/test/bs.c index 3e773317..c7569cf2 100644 --- a/test/bs.c +++ b/test/bs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2021,2022 Thomas E. Dickey * + * Copyright 2018-2022,2023 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -35,7 +35,7 @@ * v2.0 featuring strict ANSI/POSIX conformance, November 1993. * v2.1 with ncurses mouse support, September 1995 * - * $Id: bs.c,v 1.78 2022/12/11 00:18:37 tom Exp $ + * $Id: bs.c,v 1.79 2023/05/27 20:13:10 tom Exp $ */ #include @@ -898,8 +898,9 @@ sgetc(const char *s) ch = toupper(ch); if (is_QUIT(ch)) uninitgame(0); - for (s1 = s; *s1 && ch != *s1; ++s1) - continue; + for (s1 = s; *s1 && ch != *s1; ++s1) { + /* EMPTY */ ; + } if (*s1) { AddCh(ch); (void) refresh(); @@ -1270,8 +1271,9 @@ main(int argc, char *argv[]) } } } else - while ((turn ? cputurn() : plyturn()) && awinna() == -1) - continue; + while ((turn ? cputurn() : plyturn()) && awinna() == -1) { + /* EMPTY */ ; + } turn = OTHER; } } while diff --git a/test/demo_forms.c b/test/demo_forms.c index 8e831255..61c4cc72 100644 --- a/test/demo_forms.c +++ b/test/demo_forms.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2020,2022 Thomas E. Dickey * + * Copyright 2018-2022,2023 Thomas E. Dickey * * Copyright 2003-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -27,7 +27,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: demo_forms.c,v 1.61 2022/12/04 00:40:11 tom Exp $ + * $Id: demo_forms.c,v 1.62 2023/05/27 20:13:10 tom Exp $ * * Demonstrate a variety of functions from the form library. * Thomas Dickey - 2003/4/26 @@ -242,7 +242,7 @@ show_insert_mode(bool insert_mode) #define O_SELECTABLE (O_ACTIVE | O_VISIBLE) static FIELD * -another_field(FORM *form, FIELD *field) +another_field(FORM *form, const FIELD *const field) { FIELD **f = form_fields(form); FIELD *result = 0; diff --git a/test/demo_menus.c b/test/demo_menus.c index ab3880cb..7b0bf303 100644 --- a/test/demo_menus.c +++ b/test/demo_menus.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019-2021,2022 Thomas E. Dickey * + * Copyright 2019-2022,2023 Thomas E. Dickey * * Copyright 2003-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -27,7 +27,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: demo_menus.c,v 1.79 2022/12/04 00:40:11 tom Exp $ + * $Id: demo_menus.c,v 1.80 2023/05/27 20:13:10 tom Exp $ * * Demonstrate a variety of functions from the menu library. * Thomas Dickey - 2005/4/9 @@ -925,7 +925,6 @@ perform_menus(void) } if (code == E_REQUEST_DENIED) beep(); - continue; } } diff --git a/test/demo_termcap.c b/test/demo_termcap.c index 468bd976..6e2aba70 100644 --- a/test/demo_termcap.c +++ b/test/demo_termcap.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019-2021,2022 Thomas E. Dickey * + * Copyright 2019-2022,2023 Thomas E. Dickey * * Copyright 2005-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -30,7 +30,7 @@ /* * Author: Thomas E. Dickey * - * $Id: demo_termcap.c,v 1.64 2022/12/10 23:22:09 tom Exp $ + * $Id: demo_termcap.c,v 1.65 2023/05/27 20:13:10 tom Exp $ * * A simple demo of the termcap interface. */ @@ -105,7 +105,7 @@ static long total_s_values; #define EachCapName(n) n = 33; n < 127; ++n static char * -make_dbitem(char *p, char *q) +make_dbitem(const char *const p, const char *const q) { size_t need = strlen(e_opt) + 2 + (size_t) (p - q); char *result = malloc(need); @@ -404,7 +404,8 @@ typedef enum { static void parse_description(const char *input_name) { - static char empty[1]; + static char empty[1] = + {0}; FILE *fp; struct stat sb; @@ -437,11 +438,13 @@ parse_description(const char *input_name) failed("cannot allocate memory for input-file"); } - if ((fp = fopen(input_name, "r")) == 0) + if ((fp = fopen(input_name, "r")) == 0) { failed("cannot open input-file"); - len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp); - my_blob[sb.st_size] = '\0'; - fclose(fp); + } else { + len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp); + my_blob[sb.st_size] = '\0'; + fclose(fp); + } /* * First, get rid of comments and escaped newlines, as well as repeated diff --git a/test/demo_terminfo.c b/test/demo_terminfo.c index 1b2d426c..5e78015c 100644 --- a/test/demo_terminfo.c +++ b/test/demo_terminfo.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019-2021,2022 Thomas E. Dickey * + * Copyright 2019-2022,2023 Thomas E. Dickey * * Copyright 2009-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -30,7 +30,7 @@ /* * Author: Thomas E. Dickey * - * $Id: demo_terminfo.c,v 1.56 2022/12/10 23:22:09 tom Exp $ + * $Id: demo_terminfo.c,v 1.57 2023/05/27 20:13:10 tom Exp $ * * A simple demo of the terminfo interface. */ @@ -96,7 +96,7 @@ static long total_s_values; #define FNAME(type) "%s %-*s = ", #type, f_opt ? 24 : FCOLS static char * -make_dbitem(char *p, char *q) +make_dbitem(const char *const p, const char *const q) { size_t need = strlen(e_opt) + 2 + (size_t) (p - q); char *result = malloc(need); @@ -430,7 +430,8 @@ typedef enum { static void parse_description(const char *input_name) { - static char empty[1]; + static char empty[1] = + {0}; FILE *fp; struct stat sb; @@ -463,11 +464,13 @@ parse_description(const char *input_name) failed("cannot allocate memory for input-file"); } - if ((fp = fopen(input_name, "r")) == 0) + if ((fp = fopen(input_name, "r")) == 0) { failed("cannot open input-file"); - len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp); - my_blob[sb.st_size] = '\0'; - fclose(fp); + } else { + len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp); + my_blob[sb.st_size] = '\0'; + fclose(fp); + } /* * First, get rid of comments and escaped newlines, as well as repeated diff --git a/test/echochar.c b/test/echochar.c index 1d981574..08497069 100644 --- a/test/echochar.c +++ b/test/echochar.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019-2020,2022 Thomas E. Dickey * + * Copyright 2019-2022,2023 Thomas E. Dickey * * Copyright 2006-2014,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -27,7 +27,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: echochar.c,v 1.25 2022/12/10 22:28:50 tom Exp $ + * $Id: echochar.c,v 1.26 2023/05/27 20:13:10 tom Exp $ * * Demonstrate the echochar function (compare to dots.c). * Thomas Dickey - 2006/11/4 @@ -65,7 +65,7 @@ ranf(void) } static void -set_color(char *my_pairs, int fg, int bg) +set_color(const char *const my_pairs, int fg, int bg) { int pair = (fg * COLORS) + bg; if (pair < COLOR_PAIRS) { diff --git a/test/movewindow.c b/test/movewindow.c index 7fe7329f..07797ca6 100644 --- a/test/movewindow.c +++ b/test/movewindow.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2021,2022 Thomas E. Dickey * + * Copyright 2018-2022,2023 Thomas E. Dickey * * Copyright 2006-2013,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -27,7 +27,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: movewindow.c,v 1.53 2022/12/10 23:31:31 tom Exp $ + * $Id: movewindow.c,v 1.54 2023/05/27 20:13:10 tom Exp $ * * Demonstrate move functions for windows and derived windows from the curses * library. @@ -324,6 +324,7 @@ add_window(WINDOW *parent, WINDOW *child) all_windows = typeRealloc(FRAME, need, all_windows); if (!all_windows) failed("add_window"); + have = need; } all_windows[num_windows].parent = parent; all_windows[num_windows].child = child; @@ -331,7 +332,7 @@ add_window(WINDOW *parent, WINDOW *child) } static int -window2num(WINDOW *win) +window2num(const WINDOW *const win) { int n; int result = -1; @@ -407,7 +408,7 @@ prev_window(WINDOW *win) } static void -recur_move_window(WINDOW *parent, int dy, int dx) +recur_move_window(const WINDOW *const parent, int dy, int dx) { unsigned n; diff --git a/test/ncurses.c b/test/ncurses.c index fed8b9be..a402c4c5 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.534 2023/02/25 19:30:27 tom Exp $ +$Id: ncurses.c,v 1.535 2023/05/27 20:13:10 tom Exp $ ***************************************************************************/ @@ -770,7 +770,7 @@ slk_repaint(void) * Resize both and paint the box in the parent. */ static void -resize_boxes(unsigned level, WINDOW *win) +resize_boxes(unsigned level, const WINDOW *const win) { unsigned n; int base = 5; @@ -1012,7 +1012,7 @@ getch_test(bool recur GCC_UNUSED) */ #if defined(KEY_RESIZE) && HAVE_WRESIZE static void -resize_wide_boxes(unsigned level, WINDOW *win) +resize_wide_boxes(unsigned level, const WINDOW *const win) { unsigned n; int base = 5; @@ -6161,7 +6161,6 @@ menu_test(bool recur GCC_UNUSED) break; if (c == E_REQUEST_DENIED) beep(); - continue; } MvPrintw(LINES - 2, 0, @@ -6329,8 +6328,9 @@ trace_set(bool recur GCC_UNUSED) set_item_value(*ip, TRUE); } - while (run_trace_menu(m)) - continue; + while (run_trace_menu(m)) { + /* EMPTY */ ; + } newtrace = 0; for (ip = menu_items(m); *ip; ip++) diff --git a/test/test_addwstr.c b/test/test_addwstr.c index aa7bf857..9e51f49d 100644 --- a/test/test_addwstr.c +++ b/test/test_addwstr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020,2022 Thomas E. Dickey * + * Copyright 2020-2022,2023 Thomas E. Dickey * * Copyright 2009-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -27,7 +27,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: test_addwstr.c,v 1.21 2022/12/10 22:28:50 tom Exp $ + * $Id: test_addwstr.c,v 1.22 2023/05/27 20:13:10 tom Exp $ * * Demonstrate the waddwstr() and wadd_wch functions. * Thomas Dickey - 2009/9/12 @@ -114,7 +114,7 @@ legend(WINDOW *win, int level, Options state, wchar_t *buffer, int length) } static int -ColOf(wchar_t *buffer, int length, int margin) +ColOf(const wchar_t *const buffer, int length, int margin) { int n; int result; diff --git a/test/test_delwin.c b/test/test_delwin.c index 7a874251..09ef5c53 100644 --- a/test/test_delwin.c +++ b/test/test_delwin.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2022 Thomas E. Dickey * + * Copyright 2022,2023 Thomas E. Dickey * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -27,7 +27,7 @@ ****************************************************************************/ /* - * $Id: test_delwin.c,v 1.4 2022/12/10 22:14:07 tom Exp $ + * $Id: test_delwin.c,v 1.5 2023/05/27 20:34:51 tom Exp $ */ #include @@ -123,7 +123,7 @@ main(int argc, char **argv) show_rc("Deleted parent", "should fail, it still has a subwindow", - rc = delwin(parent)); + delwin(parent)); next_step(stdscr); show_rc("Deleted child1", "should succeed", diff --git a/test/test_sgr.c b/test/test_sgr.c index dbd1caf1..8763dca3 100644 --- a/test/test_sgr.c +++ b/test/test_sgr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019-2021,2022 Thomas E. Dickey * + * Copyright 2019-2022,2023 Thomas E. Dickey * * Copyright 2015-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -30,7 +30,7 @@ /* * Author: Thomas E. Dickey * - * $Id: test_sgr.c,v 1.21 2022/12/10 23:23:27 tom Exp $ + * $Id: test_sgr.c,v 1.22 2023/05/27 20:13:10 tom Exp $ * * A simple demo of the sgr/sgr0 terminal capabilities. */ @@ -61,7 +61,7 @@ static int db_item; static long total_values; static char * -make_dbitem(char *p, char *q) +make_dbitem(const char *const p, const char *const q) { size_t need = strlen(e_opt) + 2 + (size_t) (p - q); char *result = malloc(need); -- 2.45.0