From: Thomas E. Dickey Date: Sun, 18 Aug 2019 00:33:55 +0000 (+0000) Subject: ncurses 6.1 - patch 20190817 X-Git-Tag: v6.2~24 X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=commitdiff_plain;h=9d37907c2305ee3dc7b829e98a465c3def2074f0 ncurses 6.1 - patch 20190817 + amend 20181208 changes for wbkgd() and wbkgrnd(), fixing a few details where it still differed from SVr4. + fix some cppcheck warnings, mostly style, in ncurses test-programs. --- diff --git a/NEWS b/NEWS index 1f356c4b..c7b0ac6c 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.3361 2019/08/10 19:05:52 tom Exp $ +-- $Id: NEWS,v 1.3364 2019/08/17 21:47:27 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,11 @@ 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. +20190817 + + amend 20181208 changes for wbkgd() and wbkgrnd(), fixing a few + details where it still differed from SVr4. + + fix some cppcheck warnings, mostly style, in ncurses test-programs. + 20190810 + fix a few more coverity warnings. diff --git a/VERSION b/VERSION index f1fe46df..8362207f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5:0:10 6.1 20190810 +5:0:10 6.1 20190817 diff --git a/dist.mk b/dist.mk index bc0ff985..6630c1be 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.1300 2019/08/10 12:52:53 tom Exp $ +# $Id: dist.mk,v 1.1301 2019/08/17 13:26:39 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 = 6 NCURSES_MINOR = 1 -NCURSES_PATCH = 20190810 +NCURSES_PATCH = 20190817 # 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_bkgd.c b/ncurses/base/lib_bkgd.c index d0d39d84..aa1db21e 100644 --- a/ncurses/base/lib_bkgd.c +++ b/ncurses/base/lib_bkgd.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2016,2018 Free Software Foundation, Inc. * + * Copyright (c) 1998-2018,2019 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -36,7 +36,7 @@ #include -MODULE_ID("$Id: lib_bkgd.c,v 1.52 2018/12/09 00:09:17 tom Exp $") +MODULE_ID("$Id: lib_bkgd.c,v 1.53 2019/08/17 20:59:41 tom Exp $") /* * Set the window's background information. @@ -145,6 +145,11 @@ wbkgrnd(WINDOW *win, const ARG_CH_T ch) memset(&old_bkgd, 0, sizeof(old_bkgd)); (void) wgetbkgrnd(win, &old_bkgd); + if (!memcmp(&old_bkgd, &new_bkgd, sizeof(new_bkgd))) { + T(("...unchanged")); + returnCode(OK); + } + old_char = old_bkgd; RemAttr(old_char, ~A_CHARTEXT); old_attr = AttrOf(old_bkgd); @@ -153,6 +158,8 @@ wbkgrnd(WINDOW *win, const ARG_CH_T ch) if (!(old_attr & A_COLOR)) { old_pair = 0; } + T(("... old background char %s, attr %s, pair %d", + _tracechar(CharOf(old_char)), _traceattr(old_attr), old_pair)); new_char = new_bkgd; RemAttr(new_char, ~A_CHARTEXT); @@ -163,15 +170,20 @@ wbkgrnd(WINDOW *win, const ARG_CH_T ch) if (!Charable(new_bkgd)) { new_char = old_char; } + if (!(new_attr & A_COLOR)) { + new_pair = 0; + } + T(("... new background char %s, attr %s, pair %d", + _tracechar(CharOf(new_char)), _traceattr(new_attr), new_pair)); (void) wbkgrndset(win, CHREF(new_bkgd)); /* SVr4 updates color pair if old/new match, otherwise just attrs */ if ((new_pair != 0) && (new_pair == old_pair)) { - SetAttr(win->_nc_bkgd, new_attr); - SetPair(win->_nc_bkgd, new_pair); + WINDOW_ATTRS(win) = new_attr; + SET_WINDOW_PAIR(win, new_pair); } else { - SetAttr(win->_nc_bkgd, new_attr); + WINDOW_ATTRS(win) = new_attr; } for (y = 0; y <= win->_maxy; y++) { @@ -195,7 +207,7 @@ wbkgrnd(WINDOW *win, const ARG_CH_T ch) | (new_attr & ALL_BUT_COLOR)); } } else { - SetAttr(*cp, new_attr); + SetAttr(*cp, (tmp_attr & ~old_attr) | new_attr); SetPair(*cp, new_pair); } } diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog index f035c112..82080e2d 100644 --- a/package/debian-mingw/changelog +++ b/package/debian-mingw/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.1+20190810) unstable; urgency=low +ncurses6 (6.1+20190817) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 10 Aug 2019 08:52:53 -0400 + -- Thomas E. Dickey Sat, 17 Aug 2019 09:26:39 -0400 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog index f035c112..82080e2d 100644 --- a/package/debian-mingw64/changelog +++ b/package/debian-mingw64/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.1+20190810) unstable; urgency=low +ncurses6 (6.1+20190817) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 10 Aug 2019 08:52:53 -0400 + -- Thomas E. Dickey Sat, 17 Aug 2019 09:26:39 -0400 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian/changelog b/package/debian/changelog index 3edff2eb..7f69ca23 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.1+20190810) unstable; urgency=low +ncurses6 (6.1+20190817) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 10 Aug 2019 08:52:53 -0400 + -- Thomas E. Dickey Sat, 17 Aug 2019 09:26:39 -0400 ncurses6 (5.9-20120608) unstable; urgency=low diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi index 41acfea1..ed12eeda 100644 --- a/package/mingw-ncurses.nsi +++ b/package/mingw-ncurses.nsi @@ -1,4 +1,4 @@ -; $Id: mingw-ncurses.nsi,v 1.346 2019/08/10 12:52:53 tom Exp $ +; $Id: mingw-ncurses.nsi,v 1.347 2019/08/17 13:26:39 tom Exp $ ; TODO add examples ; TODO bump ABI to 6 @@ -10,7 +10,7 @@ !define VERSION_MAJOR "6" !define VERSION_MINOR "1" !define VERSION_YYYY "2019" -!define VERSION_MMDD "0810" +!define VERSION_MMDD "0817" !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD} !define MY_ABI "5" diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec index 1181f382..369162c2 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.1 -Release: 20190810 +Release: 20190817 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/package/ncurses.spec b/package/ncurses.spec index 2fc4434e..c99e6a5a 100644 --- a/package/ncurses.spec +++ b/package/ncurses.spec @@ -1,7 +1,7 @@ Summary: shared libraries for terminal handling Name: ncurses6 Version: 6.1 -Release: 20190810 +Release: 20190817 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/package/ncursest.spec b/package/ncursest.spec index 51ad7103..9caf5836 100644 --- a/package/ncursest.spec +++ b/package/ncursest.spec @@ -1,7 +1,7 @@ Summary: Curses library with POSIX thread support. Name: ncursest6 Version: 6.1 -Release: 20190810 +Release: 20190817 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/test/blue.c b/test/blue.c index 9c4108a4..0889ff06 100644 --- a/test/blue.c +++ b/test/blue.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. * + * Copyright (c) 1998-2017,2019 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -36,7 +36,7 @@ *****************************************************************************/ /* - * $Id: blue.c,v 1.51 2017/09/30 17:43:18 tom Exp $ + * $Id: blue.c,v 1.52 2019/08/17 21:49:19 tom Exp $ */ #include @@ -153,14 +153,14 @@ init_vars(void) static void shuffle(int size) { - int i, j, numswaps, swapnum, temp; + int numswaps, swapnum; numswaps = size * 10; /* an arbitrary figure */ for (swapnum = 0; swapnum < numswaps; swapnum++) { - i = rand() % size; - j = rand() % size; - temp = deck[i]; + int i = rand() % size; + int j = rand() % size; + int temp = deck[i]; deck[i] = deck[j]; deck[j] = temp; } @@ -169,11 +169,11 @@ shuffle(int size) static void deal_cards(void) { - int ptr, card = 0, value, csuit, crank, suit, aces[4]; + int card = 0, value, csuit, crank, suit, aces[4]; memset(aces, 0, sizeof(aces)); for (suit = HEARTS; suit <= CLUBS; suit++) { - ptr = freeptr[suit]; + int ptr = freeptr[suit]; grid[ptr++] = NOCARD; /* 1st card space is blank */ while ((ptr % GRID_WIDTH) != 0) { value = deck[card++]; @@ -388,10 +388,10 @@ play_game(void) static int collect_discards(void) { - int row, col, cardno = 0, finish, gridno; + int row, col, cardno = 0, gridno; for (row = HEARTS; row <= CLUBS; row++) { - finish = 0; + int finish = 0; for (col = 1; col < GRID_WIDTH; col++) { gridno = row * GRID_WIDTH + col; diff --git a/test/bs.c b/test/bs.c index b8893e62..4de4dbc7 100644 --- a/test/bs.c +++ b/test/bs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2017,2018 Free Software Foundation, Inc. * + * Copyright (c) 1998-2018,2019 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 * @@ -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.73 2018/05/12 15:07:51 tom Exp $ + * $Id: bs.c,v 1.74 2019/08/17 21:49:19 tom Exp $ */ #include @@ -548,14 +548,15 @@ initgame(void) static int getcoord(int atcpu) { - int ny, nx, c; - if (atcpu) cgoto(cury, curx); else pgoto(cury, curx); (void) refresh(); + for (;;) { + int ny, nx, c; + if (atcpu) { MvPrintw(CYBASE + BDEPTH + 1, CXBASE + 11, "(%d, %c)", curx, 'A' + cury); @@ -731,10 +732,9 @@ static int awinna(void) { int i, j; - ship_t *ss; for (i = 0; i < 2; ++i) { - ss = (i) ? cpuship : plyship; + ship_t *ss = (i) ? cpuship : plyship; for (j = 0; j < SHIPTYPES; ++j, ++ss) if (ss->length > ss->hits) break; @@ -761,9 +761,11 @@ hitship(int x, int y) if (++ss->hits < ss->length) /* still afloat? */ return ((ship_t *) NULL); else { /* sunk! */ - int i, j; + int i; + + if (!closepack) { + int j; - if (!closepack) for (j = -1; j <= 1; j++) { int bx = ss->x + j * xincr[(ss->dir + 2) % dir_MAX]; int by = ss->y + j * yincr[(ss->dir + 2) % dir_MAX]; @@ -792,6 +794,7 @@ hitship(int x, int y) } } } + } for (i = 0; i < ss->length; ++i) { int x1 = ss->x + i * xincr[ss->dir]; @@ -884,12 +887,12 @@ plyturn(void) static int sgetc(const char *s) { - const char *s1; - int ch; - (void) refresh(); + for (;;) { - ch = getch(); + int ch = getch(); + const char *s1; + if (islower(ch)) ch = toupper(ch); if (is_QUIT(ch)) @@ -1161,9 +1164,9 @@ playagain(void) static void do_options(int c, char *op[]) { - register int i; - if (c > 1) { + int i; + for (i = 1; i < c; i++) { switch (op[i][0]) { default: diff --git a/test/cardfile.c b/test/cardfile.c index ba9e8de5..a782342e 100644 --- a/test/cardfile.c +++ b/test/cardfile.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1999-2016,2017 Free Software Foundation, Inc. * + * Copyright (c) 1999-2017,2019 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 * @@ -29,7 +29,7 @@ /* * Author: Thomas E. Dickey * - * $Id: cardfile.c,v 1.45 2017/10/19 21:14:25 tom Exp $ + * $Id: cardfile.c,v 1.46 2019/08/17 21:49:40 tom Exp $ * * File format: text beginning in column 1 is a title; other text is content. */ @@ -125,10 +125,12 @@ add_title(const char *title) static void add_content(CARD * card, const char *content) { - size_t total, offset; + size_t total; content = skip(content); if ((total = strlen(content)) != 0) { + size_t offset; + if (card->content != 0 && (offset = strlen(card->content)) != 0) { total += 1 + offset; card->content = typeRealloc(char, total + 1, card->content); @@ -173,10 +175,11 @@ static void read_data(char *fname) { FILE *fp; - CARD *card = 0; - char buffer[BUFSIZ]; if ((fp = fopen(fname, "r")) != 0) { + CARD *card = 0; + char buffer[BUFSIZ]; + while (fgets(buffer, sizeof(buffer), fp)) { trim(buffer); if (isspace(UChar(*buffer))) { @@ -197,15 +200,17 @@ static void write_data(const char *fname) { FILE *fp; - CARD *p = 0; - int n; if (!strcmp(fname, default_name)) fname = "cardfile.out"; if ((fp = fopen(fname, "w")) != 0) { + CARD *p = 0; + for (p = all_cards; p != 0; p = p->link) { FIELD **f = form_fields(p->form); + int n; + for (n = 0; f[n] != 0; n++) { char *s = field_buffer(f[n], 0); if (s != 0 @@ -365,7 +370,7 @@ show_legend(void) #if (defined(KEY_RESIZE) && HAVE_WRESIZE) || NO_LEAKS static void -free_form_fields(FIELD ** f) +free_form_fields(FIELD **f) { int n; @@ -391,7 +396,6 @@ cardfile(char *fname) int form_high; int y; int x; - int ch = ERR; int finished = FALSE; show_legend(); @@ -432,6 +436,8 @@ cardfile(char *fname) order_cards(top_card, visible_cards); while (!finished) { + int ch = ERR; + update_panels(); doupdate(); @@ -522,13 +528,11 @@ cardfile(char *fname) } #if NO_LEAKS while (all_cards != 0) { - FIELD **f; - p = all_cards; all_cards = all_cards->link; if (isVisible(p)) { - f = form_fields(p->form); + FIELD **f = form_fields(p->form); unpost_form(p->form); /* ...so we can free it */ free_form(p->form); /* this also disconnects the fields */ diff --git a/test/chgat.c b/test/chgat.c index 72dd48b6..5c82aee3 100644 --- a/test/chgat.c +++ b/test/chgat.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2006-2012,2017 Free Software Foundation, Inc. * + * Copyright (c) 2006-2017,2019 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: chgat.c,v 1.17 2017/09/28 23:04:14 tom Exp $ + * $Id: chgat.c,v 1.18 2019/08/17 21:49:19 tom Exp $ * * test-driver for chgat/wchgat/mvchgat/mvwchgat */ @@ -75,10 +75,11 @@ color_params(size_t state, short *pair) }; /* *INDENT-ON* */ - static bool first = TRUE; const char *result = 0; if (has_colors()) { + static bool first = TRUE; + if (first) { size_t n; diff --git a/test/clip_printw.c b/test/clip_printw.c index a1ee516b..f7689e6f 100644 --- a/test/clip_printw.c +++ b/test/clip_printw.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2008-2016,2017 Free Software Foundation, Inc. * + * Copyright (c) 2008-2017,2019 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: clip_printw.c,v 1.15 2017/09/28 23:07:23 tom Exp $ + * $Id: clip_printw.c,v 1.16 2019/08/17 21:49:40 tom Exp $ * * demonstrate how to use printw without wrapping. */ @@ -56,7 +56,7 @@ typedef struct { } STATUS; static int -clip_wprintw(WINDOW *win, NCURSES_CONST char *fmt,...) +clip_wprintw(WINDOW *win, NCURSES_CONST char *fmt, ...) { int y0, x0, y1, x1, width; WINDOW *sub; @@ -103,10 +103,11 @@ color_params(unsigned state, int *pair) }; /* *INDENT-ON* */ - static bool first = TRUE; const char *result = 0; if (has_colors()) { + static bool first = TRUE; + if (first) { unsigned n; diff --git a/test/color_content.c b/test/color_content.c index bb1f076a..8b11982a 100644 --- a/test/color_content.c +++ b/test/color_content.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: color_content.c,v 1.10 2019/01/21 01:05:44 tom Exp $ + * $Id: color_content.c,v 1.11 2019/08/17 21:29:13 tom Exp $ */ #define NEED_TIME_H @@ -251,7 +251,6 @@ int main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) { int i; - int repeat; while ((i = getopt(argc, argv, "f:il:npr:sx")) != -1) { switch (i) { @@ -305,6 +304,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) } } } else { + int repeat; for (repeat = 0; repeat < r_opt; ++repeat) { run_test(); diff --git a/test/color_set.c b/test/color_set.c index 477d049c..cfe3755b 100644 --- a/test/color_set.c +++ b/test/color_set.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2003-2012,2014 Free Software Foundation, Inc. * + * Copyright (c) 2003-2014,2019 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.8 2014/02/01 22:10:42 tom Exp $ + * $Id: color_set.c,v 1.9 2019/08/17 21:49:19 tom Exp $ */ #include @@ -39,13 +39,14 @@ int main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) { NCURSES_COLOR_T f, b; - int i; initscr(); cbreak(); noecho(); if (has_colors()) { + int i; + start_color(); (void) pair_content(0, &f, &b); diff --git a/test/demo_altkeys.c b/test/demo_altkeys.c index 0f4e898a..d85bac48 100644 --- a/test/demo_altkeys.c +++ b/test/demo_altkeys.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2005-2017,2018 Free Software Foundation, Inc. * + * Copyright (c) 2005-2018,2019 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: demo_altkeys.c,v 1.12 2018/12/29 17:52:53 tom Exp $ + * $Id: demo_altkeys.c,v 1.13 2019/08/17 21:49:40 tom Exp $ * * Demonstrate the define_key() function. * Thomas Dickey - 2005/10/22 @@ -47,11 +47,12 @@ static void log_last_line(WINDOW *win) { FILE *fp; - int y, x, n; - char temp[256]; if ((fp = fopen(MY_LOGFILE, "a")) != 0) { + char temp[256]; + int y, x, n; int need = sizeof(temp) - 1; + if (need > COLS) need = COLS; getyx(win, y, x); @@ -75,8 +76,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) int n; int ch; #if HAVE_GETTIMEOFDAY - int secs, msecs; - struct timeval current, previous; + struct timeval previous; #endif unlink(MY_LOGFILE); @@ -119,8 +119,10 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) while ((ch = getch()) != ERR) { bool escaped = (ch >= MY_KEYS); const char *name = keyname(escaped ? (ch - MY_KEYS) : ch); - #if HAVE_GETTIMEOFDAY + int secs, msecs; + struct timeval current; + gettimeofday(¤t, 0); secs = (int) (current.tv_sec - previous.tv_sec); msecs = (int) ((current.tv_usec - previous.tv_usec) / 1000); diff --git a/test/demo_defkey.c b/test/demo_defkey.c index 616a8557..e5bb9c26 100644 --- a/test/demo_defkey.c +++ b/test/demo_defkey.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2002-2017,2018 Free Software Foundation, Inc. * + * Copyright (c) 2002-2018,2019 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: demo_defkey.c,v 1.28 2018/02/12 09:57:31 tom Exp $ + * $Id: demo_defkey.c,v 1.29 2019/08/17 21:49:19 tom Exp $ * * Demonstrate the define_key() function. * Thomas Dickey - 2002/11/23 @@ -45,10 +45,10 @@ static void log_last_line(WINDOW *win) { FILE *fp; - int y, x, n; - char temp[256]; if ((fp = fopen(MY_LOGFILE, "a")) != 0) { + char temp[256]; + int y, x, n; int need = sizeof(temp) - 1; if (need > COLS) need = COLS; @@ -98,11 +98,12 @@ static char * visible(const char *string) { char *result = 0; - size_t need = 1; - int pass; - int n; if (string != 0 && *string != '\0') { + int pass; + int n; + size_t need = 1; + for (pass = 0; pass < 2; ++pass) { for (n = 0; string[n] != '\0'; ++n) { char temp[80]; @@ -185,7 +186,6 @@ duplicate(WINDOW *win, NCURSES_CONST char *name, int code) if (value != 0) { const char *prefix = 0; - char temp[BUFSIZ]; if (!(strncmp) (value, "\033[", (size_t) 2)) { prefix = "\033O"; @@ -193,6 +193,7 @@ duplicate(WINDOW *win, NCURSES_CONST char *name, int code) prefix = "\033["; } if (prefix != 0) { + char temp[BUFSIZ]; _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "%s%s", prefix, value + 2); really_define_key(win, temp, code); diff --git a/test/demo_forms.c b/test/demo_forms.c index b0a388e4..ccfb86e3 100644 --- a/test/demo_forms.c +++ b/test/demo_forms.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2003-2017,2018 Free Software Foundation, Inc. * + * Copyright (c) 2003-2018,2019 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: demo_forms.c,v 1.55 2018/07/14 23:26:02 tom Exp $ + * $Id: demo_forms.c,v 1.56 2019/08/17 21:49:19 tom Exp $ * * Demonstrate a variety of functions from the form library. * Thomas Dickey - 2003/4/26 @@ -338,9 +338,6 @@ static void show_current_field(WINDOW *win, FORM *form) { FIELD *field; - FIELDTYPE *type; - char *buffer; - int nbuf; int field_rows, field_cols, field_max; int currow, curcol; @@ -355,7 +352,11 @@ show_current_field(WINDOW *win, FORM *form) if (data_behind(form)) waddstr(win, " behind"); waddch(win, '\n'); + if ((field = current_field(form)) != 0) { + FIELDTYPE *type; + int nbuf; + wprintw(win, "Page %d%s, Field %d/%d%s:", form_page(form), new_page(field) ? "*" : "", @@ -411,6 +412,7 @@ show_current_field(WINDOW *win, FORM *form) waddstr(win, "\n"); for (nbuf = 0; nbuf <= 2; ++nbuf) { + char *buffer; if ((buffer = field_buffer(field, nbuf)) != 0) { wprintw(win, "buffer %d:", nbuf); (void) wattrset(win, A_REVERSE); @@ -430,13 +432,11 @@ show_current_field(WINDOW *win, FORM *form) static void demo_forms(void) { - WINDOW *w; FORM *form; FIELD *f[100]; /* will memset to zero */ - int finished = 0, c; + int c; unsigned n = 0; int pg; - WINDOW *also; const char *fname; static const char *my_enum[] = {"first", "second", "third", 0}; @@ -544,6 +544,9 @@ demo_forms(void) f[n] = (FIELD *) 0; if ((form = new_form(f)) != 0) { + WINDOW *w; + WINDOW *also; + int finished = 0; display_form(form); diff --git a/test/demo_menus.c b/test/demo_menus.c index 844afa7e..6e94b44b 100644 --- a/test/demo_menus.c +++ b/test/demo_menus.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: demo_menus.c,v 1.67 2019/08/10 19:25:27 tom Exp $ + * $Id: demo_menus.c,v 1.68 2019/08/17 21:45:32 tom Exp $ * * Demonstrate a variety of functions from the menu library. * Thomas Dickey - 2005/4/9 @@ -309,12 +309,11 @@ menu_create(ITEM ** items, int count, int ncols, MenuNo number) static void menu_destroy(MENU * m) { - int count; - Trace(("menu_destroy %p", (void *) m)); if (m != 0) { ITEM **items = menu_items(m); const char *blob = 0; + int count; count = item_count(m); Trace(("menu_destroy %p count %d", (void *) m, count)); @@ -429,7 +428,6 @@ build_select_menu(MenuNo number, char *filename) && (sb.st_mode & S_IFMT) == S_IFREG && sb.st_size != 0) { size_t size = (size_t) sb.st_size; - unsigned j, k; char *blob = typeMalloc(char, size + 1); MENU_DATA *list = typeCalloc(MENU_DATA, size + 1); @@ -442,6 +440,7 @@ build_select_menu(MenuNo number, char *filename) if (fp != 0) { if (fread(blob, sizeof(char), size, fp) == size) { bool mark = TRUE; + unsigned j, k; for (j = k = 0; j < size; ++j) { if (mark) { list[k++].name = blob + j; @@ -609,7 +608,6 @@ perform_trace_menu(int cmd) /* interactively set the trace level */ { ITEM **ip; - unsigned newtrace; int result; for (ip = menu_items(mpTrace); *ip; ip++) { @@ -625,7 +623,7 @@ perform_trace_menu(int cmd) if (result == E_OK) { if (update_trace_menu(mpTrace) || cmd == REQ_TOGGLE_ITEM) { - newtrace = 0; + unsigned newtrace = 0; for (ip = menu_items(mpTrace); *ip; ip++) { if (item_value(*ip)) { MENU_DATA *td = (MENU_DATA *) item_userptr(*ip); diff --git a/test/test_sgr.c b/test/test_sgr.c index 4ed59543..71811140 100644 --- a/test/test_sgr.c +++ b/test/test_sgr.c @@ -29,7 +29,7 @@ /* * Author: Thomas E. Dickey * - * $Id: test_sgr.c,v 1.13 2019/07/28 18:13:39 tom Exp $ + * $Id: test_sgr.c,v 1.14 2019/08/17 21:36:44 tom Exp $ * * A simple demo of the sgr/sgr0 terminal capabilities. */ @@ -147,7 +147,7 @@ dumpit(unsigned bits, unsigned ignore, const char *sgr, const char *sgr0) static char params[] = "SURBDBIPA"; unsigned n; - printf("%4d ", bits); + printf("%4u ", bits); bits &= ~ignore; for (n = 0; n < MAXPAR; ++n) { putchar((int) ((bits & (unsigned) (1 << n)) ? params[n] : '-'));