1# ncurses 6.1 - patch 20190817 - Thomas E. Dickey
2#
3# ------------------------------------------------------------------------------
4#
5# Ncurses 6.1 is at
6# 	ftp.gnu.org:/pub/gnu
7#
8# Patches for ncurses 6.1 can be found at
9# 	ftp://ftp.invisible-island.net/ncurses/6.1
10#	http://invisible-mirror.net/archives/ncurses/6.1
11#
12# ------------------------------------------------------------------------------
13# ftp://ftp.invisible-island.net/ncurses/6.1/ncurses-6.1-20190817.patch.gz
14# patch by Thomas E. Dickey <dickey@invisible-island.net>
15# created  Sun Aug 18 00:33:55 UTC 2019
16# ------------------------------------------------------------------------------
17# NEWS                             |    7 ++++++-
18# VERSION                          |    2 +-
19# dist.mk                          |    4 ++--
20# ncurses/base/lib_bkgd.c          |   24 ++++++++++++++++++------
21# package/debian-mingw/changelog   |    4 ++--
22# package/debian-mingw64/changelog |    4 ++--
23# package/debian/changelog         |    4 ++--
24# package/mingw-ncurses.nsi        |    4 ++--
25# package/mingw-ncurses.spec       |    2 +-
26# package/ncurses.spec             |    2 +-
27# package/ncursest.spec            |    2 +-
28# test/blue.c                      |   20 ++++++++++----------
29# test/bs.c                        |   31 +++++++++++++++++--------------
30# test/cardfile.c                  |   28 ++++++++++++++++------------
31# test/chgat.c                     |    7 ++++---
32# test/clip_printw.c               |    9 +++++----
33# test/color_content.c             |    4 ++--
34# test/color_set.c                 |    7 ++++---
35# test/demo_altkeys.c              |   16 +++++++++-------
36# test/demo_defkey.c               |   17 +++++++++--------
37# test/demo_forms.c                |   19 +++++++++++--------
38# test/demo_menus.c                |   10 ++++------
39# test/test_sgr.c                  |    4 ++--
40# 23 files changed, 131 insertions(+), 100 deletions(-)
41# ------------------------------------------------------------------------------
42Index: NEWS
43Prereq:  1.3361
44--- ncurses-6.1-20190810+/NEWS	2019-08-10 19:05:52.000000000 +0000
45+++ ncurses-6.1-20190817/NEWS	2019-08-17 21:47:27.000000000 +0000
46@@ -25,7 +25,7 @@
47 -- sale, use or other dealings in this Software without prior written        --
48 -- authorization.                                                            --
49 -------------------------------------------------------------------------------
50--- $Id: NEWS,v 1.3361 2019/08/10 19:05:52 tom Exp $
51+-- $Id: NEWS,v 1.3364 2019/08/17 21:47:27 tom Exp $
52 -------------------------------------------------------------------------------
53
54 This is a log of changes that ncurses has gone through since Zeyd started
55@@ -45,6 +45,11 @@
56 Changes through 1.9.9e did not credit all contributions;
57 it is not possible to add this information.
58
59+20190817
60+	+ amend 20181208 changes for wbkgd() and wbkgrnd(), fixing a few
61+	  details where it still differed from SVr4.
62+	+ fix some cppcheck warnings, mostly style, in ncurses test-programs.
63+
64 20190810
65 	+ fix a few more coverity warnings.
66
67Index: VERSION
68--- ncurses-6.1-20190810+/VERSION	2019-08-10 12:52:53.000000000 +0000
69+++ ncurses-6.1-20190817/VERSION	2019-08-17 13:26:39.000000000 +0000
70@@ -1 +1 @@
71-5:0:10	6.1	20190810
72+5:0:10	6.1	20190817
73Index: dist.mk
74Prereq:  1.1300
75--- ncurses-6.1-20190810+/dist.mk	2019-08-10 12:52:53.000000000 +0000
76+++ ncurses-6.1-20190817/dist.mk	2019-08-17 13:26:39.000000000 +0000
77@@ -25,7 +25,7 @@
78 # use or other dealings in this Software without prior written               #
79 # authorization.                                                             #
80 ##############################################################################
81-# $Id: dist.mk,v 1.1300 2019/08/10 12:52:53 tom Exp $
82+# $Id: dist.mk,v 1.1301 2019/08/17 13:26:39 tom Exp $
83 # Makefile for creating ncurses distributions.
84 #
85 # This only needs to be used directly as a makefile by developers, but
86@@ -37,7 +37,7 @@
87 # These define the major/minor/patch versions of ncurses.
88 NCURSES_MAJOR = 6
89 NCURSES_MINOR = 1
90-NCURSES_PATCH = 20190810
91+NCURSES_PATCH = 20190817
92
93 # We don't append the patch to the version, since this only applies to releases
94 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
95Index: ncurses/base/lib_bkgd.c
96Prereq:  1.52
97--- ncurses-6.1-20190810+/ncurses/base/lib_bkgd.c	2018-12-09 00:09:17.000000000 +0000
98+++ ncurses-6.1-20190817/ncurses/base/lib_bkgd.c	2019-08-17 20:59:41.000000000 +0000
99@@ -1,5 +1,5 @@
100 /****************************************************************************
101- * Copyright (c) 1998-2016,2018 Free Software Foundation, Inc.              *
102+ * Copyright (c) 1998-2018,2019 Free Software Foundation, Inc.              *
103  *                                                                          *
104  * Permission is hereby granted, free of charge, to any person obtaining a  *
105  * copy of this software and associated documentation files (the            *
106@@ -36,7 +36,7 @@
107
108 #include <curses.priv.h>
109
110-MODULE_ID("$Id: lib_bkgd.c,v 1.52 2018/12/09 00:09:17 tom Exp $")
111+MODULE_ID("$Id: lib_bkgd.c,v 1.53 2019/08/17 20:59:41 tom Exp $")
112
113 /*
114  * Set the window's background information.
115@@ -145,6 +145,11 @@
116 	memset(&old_bkgd, 0, sizeof(old_bkgd));
117 	(void) wgetbkgrnd(win, &old_bkgd);
118
119+	if (!memcmp(&old_bkgd, &new_bkgd, sizeof(new_bkgd))) {
120+	    T(("...unchanged"));
121+	    returnCode(OK);
122+	}
123+
124 	old_char = old_bkgd;
125 	RemAttr(old_char, ~A_CHARTEXT);
126 	old_attr = AttrOf(old_bkgd);
127@@ -153,6 +158,8 @@
128 	if (!(old_attr & A_COLOR)) {
129 	    old_pair = 0;
130 	}
131+	T(("... old background char %s, attr %s, pair %d",
132+	   _tracechar(CharOf(old_char)), _traceattr(old_attr), old_pair));
133
134 	new_char = new_bkgd;
135 	RemAttr(new_char, ~A_CHARTEXT);
136@@ -163,15 +170,20 @@
137 	if (!Charable(new_bkgd)) {
138 	    new_char = old_char;
139 	}
140+	if (!(new_attr & A_COLOR)) {
141+	    new_pair = 0;
142+	}
143+	T(("... new background char %s, attr %s, pair %d",
144+	   _tracechar(CharOf(new_char)), _traceattr(new_attr), new_pair));
145
146 	(void) wbkgrndset(win, CHREF(new_bkgd));
147
148 	/* SVr4 updates color pair if old/new match, otherwise just attrs */
149 	if ((new_pair != 0) && (new_pair == old_pair)) {
150-	    SetAttr(win->_nc_bkgd, new_attr);
151-	    SetPair(win->_nc_bkgd, new_pair);
152+	    WINDOW_ATTRS(win) = new_attr;
153+	    SET_WINDOW_PAIR(win, new_pair);
154 	} else {
155-	    SetAttr(win->_nc_bkgd, new_attr);
156+	    WINDOW_ATTRS(win) = new_attr;
157 	}
158
159 	for (y = 0; y <= win->_maxy; y++) {
160@@ -195,7 +207,7 @@
161 				| (new_attr & ALL_BUT_COLOR));
162 		    }
163 		} else {
164-		    SetAttr(*cp, new_attr);
165+		    SetAttr(*cp, (tmp_attr & ~old_attr) | new_attr);
166 		    SetPair(*cp, new_pair);
167 		}
168 	    }
169Index: package/debian-mingw/changelog
170--- ncurses-6.1-20190810+/package/debian-mingw/changelog	2019-08-10 12:52:53.000000000 +0000
171+++ ncurses-6.1-20190817/package/debian-mingw/changelog	2019-08-17 13:26:39.000000000 +0000
172@@ -1,8 +1,8 @@
173-ncurses6 (6.1+20190810) unstable; urgency=low
174+ncurses6 (6.1+20190817) unstable; urgency=low
175
176   * latest weekly patch
177
178- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 10 Aug 2019 08:52:53 -0400
179+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 17 Aug 2019 09:26:39 -0400
180
181 ncurses6 (5.9-20131005) unstable; urgency=low
182
183Index: package/debian-mingw64/changelog
184--- ncurses-6.1-20190810+/package/debian-mingw64/changelog	2019-08-10 12:52:53.000000000 +0000
185+++ ncurses-6.1-20190817/package/debian-mingw64/changelog	2019-08-17 13:26:39.000000000 +0000
186@@ -1,8 +1,8 @@
187-ncurses6 (6.1+20190810) unstable; urgency=low
188+ncurses6 (6.1+20190817) unstable; urgency=low
189
190   * latest weekly patch
191
192- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 10 Aug 2019 08:52:53 -0400
193+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 17 Aug 2019 09:26:39 -0400
194
195 ncurses6 (5.9-20131005) unstable; urgency=low
196
197Index: package/debian/changelog
198--- ncurses-6.1-20190810+/package/debian/changelog	2019-08-10 12:52:53.000000000 +0000
199+++ ncurses-6.1-20190817/package/debian/changelog	2019-08-17 13:26:39.000000000 +0000
200@@ -1,8 +1,8 @@
201-ncurses6 (6.1+20190810) unstable; urgency=low
202+ncurses6 (6.1+20190817) unstable; urgency=low
203
204   * latest weekly patch
205
206- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 10 Aug 2019 08:52:53 -0400
207+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 17 Aug 2019 09:26:39 -0400
208
209 ncurses6 (5.9-20120608) unstable; urgency=low
210
211Index: package/mingw-ncurses.nsi
212Prereq:  1.346
213--- ncurses-6.1-20190810+/package/mingw-ncurses.nsi	2019-08-10 12:52:53.000000000 +0000
214+++ ncurses-6.1-20190817/package/mingw-ncurses.nsi	2019-08-17 13:26:39.000000000 +0000
215@@ -1,4 +1,4 @@
216-; $Id: mingw-ncurses.nsi,v 1.346 2019/08/10 12:52:53 tom Exp $
217+; $Id: mingw-ncurses.nsi,v 1.347 2019/08/17 13:26:39 tom Exp $
218
219 ; TODO add examples
220 ; TODO bump ABI to 6
221@@ -10,7 +10,7 @@
222 !define VERSION_MAJOR "6"
223 !define VERSION_MINOR "1"
224 !define VERSION_YYYY  "2019"
225-!define VERSION_MMDD  "0810"
226+!define VERSION_MMDD  "0817"
227 !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD}
228
229 !define MY_ABI   "5"
230Index: package/mingw-ncurses.spec
231--- ncurses-6.1-20190810+/package/mingw-ncurses.spec	2019-08-10 12:52:53.000000000 +0000
232+++ ncurses-6.1-20190817/package/mingw-ncurses.spec	2019-08-17 13:26:39.000000000 +0000
233@@ -3,7 +3,7 @@
234 Summary: shared libraries for terminal handling
235 Name: mingw32-ncurses6
236 Version: 6.1
237-Release: 20190810
238+Release: 20190817
239 License: X11
240 Group: Development/Libraries
241 Source: ncurses-%{version}-%{release}.tgz
242Index: package/ncurses.spec
243--- ncurses-6.1-20190810+/package/ncurses.spec	2019-08-10 12:52:53.000000000 +0000
244+++ ncurses-6.1-20190817/package/ncurses.spec	2019-08-17 13:26:39.000000000 +0000
245@@ -1,7 +1,7 @@
246 Summary: shared libraries for terminal handling
247 Name: ncurses6
248 Version: 6.1
249-Release: 20190810
250+Release: 20190817
251 License: X11
252 Group: Development/Libraries
253 Source: ncurses-%{version}-%{release}.tgz
254Index: package/ncursest.spec
255--- ncurses-6.1-20190810+/package/ncursest.spec	2019-08-10 12:52:53.000000000 +0000
256+++ ncurses-6.1-20190817/package/ncursest.spec	2019-08-17 13:26:39.000000000 +0000
257@@ -1,7 +1,7 @@
258 Summary: Curses library with POSIX thread support.
259 Name: ncursest6
260 Version: 6.1
261-Release: 20190810
262+Release: 20190817
263 License: X11
264 Group: Development/Libraries
265 Source: ncurses-%{version}-%{release}.tgz
266Index: test/blue.c
267Prereq:  1.51
268--- ncurses-6.1-20190810+/test/blue.c	2017-09-30 17:43:18.000000000 +0000
269+++ ncurses-6.1-20190817/test/blue.c	2019-08-17 21:49:19.000000000 +0000
270@@ -1,5 +1,5 @@
271 /****************************************************************************
272- * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc.              *
273+ * Copyright (c) 1998-2017,2019 Free Software Foundation, Inc.              *
274  *                                                                          *
275  * Permission is hereby granted, free of charge, to any person obtaining a  *
276  * copy of this software and associated documentation files (the            *
277@@ -36,7 +36,7 @@
278  *****************************************************************************/
279
280 /*
281- * $Id: blue.c,v 1.51 2017/09/30 17:43:18 tom Exp $
282+ * $Id: blue.c,v 1.52 2019/08/17 21:49:19 tom Exp $
283  */
284
285 #include <test.priv.h>
286@@ -153,14 +153,14 @@
287 static void
288 shuffle(int size)
289 {
290-    int i, j, numswaps, swapnum, temp;
291+    int numswaps, swapnum;
292
293     numswaps = size * 10;	/* an arbitrary figure */
294
295     for (swapnum = 0; swapnum < numswaps; swapnum++) {
296-	i = rand() % size;
297-	j = rand() % size;
298-	temp = deck[i];
299+	int i = rand() % size;
300+	int j = rand() % size;
301+	int temp = deck[i];
302 	deck[i] = deck[j];
303 	deck[j] = temp;
304     }
305@@ -169,11 +169,11 @@
306 static void
307 deal_cards(void)
308 {
309-    int ptr, card = 0, value, csuit, crank, suit, aces[4];
310+    int card = 0, value, csuit, crank, suit, aces[4];
311
312     memset(aces, 0, sizeof(aces));
313     for (suit = HEARTS; suit <= CLUBS; suit++) {
314-	ptr = freeptr[suit];
315+	int ptr = freeptr[suit];
316 	grid[ptr++] = NOCARD;	/* 1st card space is blank */
317 	while ((ptr % GRID_WIDTH) != 0) {
318 	    value = deck[card++];
319@@ -388,10 +388,10 @@
320 static int
321 collect_discards(void)
322 {
323-    int row, col, cardno = 0, finish, gridno;
324+    int row, col, cardno = 0, gridno;
325
326     for (row = HEARTS; row <= CLUBS; row++) {
327-	finish = 0;
328+	int finish = 0;
329 	for (col = 1; col < GRID_WIDTH; col++) {
330 	    gridno = row * GRID_WIDTH + col;
331
332Index: test/bs.c
333Prereq:  1.73
334--- ncurses-6.1-20190810+/test/bs.c	2018-05-12 15:07:51.000000000 +0000
335+++ ncurses-6.1-20190817/test/bs.c	2019-08-17 21:49:19.000000000 +0000
336@@ -1,5 +1,5 @@
337 /****************************************************************************
338- * Copyright (c) 1998-2017,2018 Free Software Foundation, Inc.              *
339+ * Copyright (c) 1998-2018,2019 Free Software Foundation, Inc.              *
340  *                                                                          *
341  * Permission is hereby granted, free of charge, to any person obtaining a  *
342  * copy of this software and associated documentation files (the            *
343@@ -34,7 +34,7 @@
344  * v2.0 featuring strict ANSI/POSIX conformance, November 1993.
345  * v2.1 with ncurses mouse support, September 1995
346  *
347- * $Id: bs.c,v 1.73 2018/05/12 15:07:51 tom Exp $
348+ * $Id: bs.c,v 1.74 2019/08/17 21:49:19 tom Exp $
349  */
350
351 #include <test.priv.h>
352@@ -548,14 +548,15 @@
353 static int
354 getcoord(int atcpu)
355 {
356-    int ny, nx, c;
357-
358     if (atcpu)
359 	cgoto(cury, curx);
360     else
361 	pgoto(cury, curx);
362     (void) refresh();
363+
364     for (;;) {
365+	int ny, nx, c;
366+
367 	if (atcpu) {
368 	    MvPrintw(CYBASE + BDEPTH + 1, CXBASE + 11, "(%d, %c)",
369 		     curx, 'A' + cury);
370@@ -731,10 +732,9 @@
371 awinna(void)
372 {
373     int i, j;
374-    ship_t *ss;
375
376     for (i = 0; i < 2; ++i) {
377-	ss = (i) ? cpuship : plyship;
378+	ship_t *ss = (i) ? cpuship : plyship;
379 	for (j = 0; j < SHIPTYPES; ++j, ++ss)
380 	    if (ss->length > ss->hits)
381 		break;
382@@ -761,9 +761,11 @@
383 	    if (++ss->hits < ss->length)	/* still afloat? */
384 		return ((ship_t *) NULL);
385 	    else {		/* sunk! */
386-		int i, j;
387+		int i;
388+
389+		if (!closepack) {
390+		    int j;
391
392-		if (!closepack)
393 		    for (j = -1; j <= 1; j++) {
394 			int bx = ss->x + j * xincr[(ss->dir + 2) % dir_MAX];
395 			int by = ss->y + j * yincr[(ss->dir + 2) % dir_MAX];
396@@ -792,6 +794,7 @@
397 			    }
398 			}
399 		    }
400+		}
401
402 		for (i = 0; i < ss->length; ++i) {
403 		    int x1 = ss->x + i * xincr[ss->dir];
404@@ -884,12 +887,12 @@
405 static int
406 sgetc(const char *s)
407 {
408-    const char *s1;
409-    int ch;
410-
411     (void) refresh();
412+
413     for (;;) {
414-	ch = getch();
415+	int ch = getch();
416+	const char *s1;
417+
418 	if (islower(ch))
419 	    ch = toupper(ch);
420 	if (is_QUIT(ch))
421@@ -1161,9 +1164,9 @@
422 static void
423 do_options(int c, char *op[])
424 {
425-    register int i;
426-
427     if (c > 1) {
428+	int i;
429+
430 	for (i = 1; i < c; i++) {
431 	    switch (op[i][0]) {
432 	    default:
433Index: test/cardfile.c
434Prereq:  1.45
435--- ncurses-6.1-20190810+/test/cardfile.c	2017-10-19 21:14:25.000000000 +0000
436+++ ncurses-6.1-20190817/test/cardfile.c	2019-08-17 21:49:40.000000000 +0000
437@@ -1,5 +1,5 @@
438 /****************************************************************************
439- * Copyright (c) 1999-2016,2017 Free Software Foundation, Inc.              *
440+ * Copyright (c) 1999-2017,2019 Free Software Foundation, Inc.              *
441  *                                                                          *
442  * Permission is hereby granted, free of charge, to any person obtaining a  *
443  * copy of this software and associated documentation files (the            *
444@@ -29,7 +29,7 @@
445 /*
446  * Author: Thomas E. Dickey
447  *
448- * $Id: cardfile.c,v 1.45 2017/10/19 21:14:25 tom Exp $
449+ * $Id: cardfile.c,v 1.46 2019/08/17 21:49:40 tom Exp $
450  *
451  * File format: text beginning in column 1 is a title; other text is content.
452  */
453@@ -125,10 +125,12 @@
454 static void
455 add_content(CARD * card, const char *content)
456 {
457-    size_t total, offset;
458+    size_t total;
459
460     content = skip(content);
461     if ((total = strlen(content)) != 0) {
462+	size_t offset;
463+
464 	if (card->content != 0 && (offset = strlen(card->content)) != 0) {
465 	    total += 1 + offset;
466 	    card->content = typeRealloc(char, total + 1, card->content);
467@@ -173,10 +175,11 @@
468 read_data(char *fname)
469 {
470     FILE *fp;
471-    CARD *card = 0;
472-    char buffer[BUFSIZ];
473
474     if ((fp = fopen(fname, "r")) != 0) {
475+	CARD *card = 0;
476+	char buffer[BUFSIZ];
477+
478 	while (fgets(buffer, sizeof(buffer), fp)) {
479 	    trim(buffer);
480 	    if (isspace(UChar(*buffer))) {
481@@ -197,15 +200,17 @@
482 write_data(const char *fname)
483 {
484     FILE *fp;
485-    CARD *p = 0;
486-    int n;
487
488     if (!strcmp(fname, default_name))
489 	fname = "cardfile.out";
490
491     if ((fp = fopen(fname, "w")) != 0) {
492+	CARD *p = 0;
493+
494 	for (p = all_cards; p != 0; p = p->link) {
495 	    FIELD **f = form_fields(p->form);
496+	    int n;
497+
498 	    for (n = 0; f[n] != 0; n++) {
499 		char *s = field_buffer(f[n], 0);
500 		if (s != 0
501@@ -365,7 +370,7 @@
502
503 #if (defined(KEY_RESIZE) && HAVE_WRESIZE) || NO_LEAKS
504 static void
505-free_form_fields(FIELD ** f)
506+free_form_fields(FIELD **f)
507 {
508     int n;
509
510@@ -391,7 +396,6 @@
511     int form_high;
512     int y;
513     int x;
514-    int ch = ERR;
515     int finished = FALSE;
516
517     show_legend();
518@@ -432,6 +436,8 @@
519     order_cards(top_card, visible_cards);
520
521     while (!finished) {
522+	int ch = ERR;
523+
524 	update_panels();
525 	doupdate();
526
527@@ -522,13 +528,11 @@
528     }
529 #if NO_LEAKS
530     while (all_cards != 0) {
531-	FIELD **f;
532-
533 	p = all_cards;
534 	all_cards = all_cards->link;
535
536 	if (isVisible(p)) {
537-	    f = form_fields(p->form);
538+	    FIELD **f = form_fields(p->form);
539
540 	    unpost_form(p->form);	/* ...so we can free it */
541 	    free_form(p->form);	/* this also disconnects the fields */
542Index: test/chgat.c
543Prereq:  1.17
544--- ncurses-6.1-20190810+/test/chgat.c	2017-09-28 23:04:14.000000000 +0000
545+++ ncurses-6.1-20190817/test/chgat.c	2019-08-17 21:49:19.000000000 +0000
546@@ -1,5 +1,5 @@
547 /****************************************************************************
548- * Copyright (c) 2006-2012,2017 Free Software Foundation, Inc.              *
549+ * Copyright (c) 2006-2017,2019 Free Software Foundation, Inc.              *
550  *                                                                          *
551  * Permission is hereby granted, free of charge, to any person obtaining a  *
552  * copy of this software and associated documentation files (the            *
553@@ -26,7 +26,7 @@
554  * authorization.                                                           *
555  ****************************************************************************/
556 /*
557- * $Id: chgat.c,v 1.17 2017/09/28 23:04:14 tom Exp $
558+ * $Id: chgat.c,v 1.18 2019/08/17 21:49:19 tom Exp $
559  *
560  * test-driver for chgat/wchgat/mvchgat/mvwchgat
561  */
562@@ -75,10 +75,11 @@
563     };
564     /* *INDENT-ON* */
565
566-    static bool first = TRUE;
567     const char *result = 0;
568
569     if (has_colors()) {
570+	static bool first = TRUE;
571+
572 	if (first) {
573 	    size_t n;
574
575Index: test/clip_printw.c
576Prereq:  1.15
577--- ncurses-6.1-20190810+/test/clip_printw.c	2017-09-28 23:07:23.000000000 +0000
578+++ ncurses-6.1-20190817/test/clip_printw.c	2019-08-17 21:49:40.000000000 +0000
579@@ -1,5 +1,5 @@
580 /****************************************************************************
581- * Copyright (c) 2008-2016,2017 Free Software Foundation, Inc.              *
582+ * Copyright (c) 2008-2017,2019 Free Software Foundation, Inc.              *
583  *                                                                          *
584  * Permission is hereby granted, free of charge, to any person obtaining a  *
585  * copy of this software and associated documentation files (the            *
586@@ -26,7 +26,7 @@
587  * authorization.                                                           *
588  ****************************************************************************/
589 /*
590- * $Id: clip_printw.c,v 1.15 2017/09/28 23:07:23 tom Exp $
591+ * $Id: clip_printw.c,v 1.16 2019/08/17 21:49:40 tom Exp $
592  *
593  * demonstrate how to use printw without wrapping.
594  */
595@@ -56,7 +56,7 @@
596 } STATUS;
597
598 static int
599-clip_wprintw(WINDOW *win, NCURSES_CONST char *fmt,...)
600+clip_wprintw(WINDOW *win, NCURSES_CONST char *fmt, ...)
601 {
602     int y0, x0, y1, x1, width;
603     WINDOW *sub;
604@@ -103,10 +103,11 @@
605     };
606     /* *INDENT-ON* */
607
608-    static bool first = TRUE;
609     const char *result = 0;
610
611     if (has_colors()) {
612+	static bool first = TRUE;
613+
614 	if (first) {
615 	    unsigned n;
616
617Index: test/color_content.c
618Prereq:  1.10
619--- ncurses-6.1-20190810+/test/color_content.c	2019-01-21 01:05:44.000000000 +0000
620+++ ncurses-6.1-20190817/test/color_content.c	2019-08-17 21:29:13.000000000 +0000
621@@ -26,7 +26,7 @@
622  * authorization.                                                           *
623  ****************************************************************************/
624 /*
625- * $Id: color_content.c,v 1.10 2019/01/21 01:05:44 tom Exp $
626+ * $Id: color_content.c,v 1.11 2019/08/17 21:29:13 tom Exp $
627  */
628
629 #define NEED_TIME_H
630@@ -251,7 +251,6 @@
631 main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
632 {
633     int i;
634-    int repeat;
635
636     while ((i = getopt(argc, argv, "f:il:npr:sx")) != -1) {
637 	switch (i) {
638@@ -305,6 +304,7 @@
639 	    }
640 	}
641     } else {
642+	int repeat;
643
644 	for (repeat = 0; repeat < r_opt; ++repeat) {
645 	    run_test();
646Index: test/color_set.c
647Prereq:  1.8
648--- ncurses-6.1-20190810+/test/color_set.c	2014-02-01 22:10:42.000000000 +0000
649+++ ncurses-6.1-20190817/test/color_set.c	2019-08-17 21:49:19.000000000 +0000
650@@ -1,5 +1,5 @@
651 /****************************************************************************
652- * Copyright (c) 2003-2012,2014 Free Software Foundation, Inc.              *
653+ * Copyright (c) 2003-2014,2019 Free Software Foundation, Inc.              *
654  *                                                                          *
655  * Permission is hereby granted, free of charge, to any person obtaining a  *
656  * copy of this software and associated documentation files (the            *
657@@ -26,7 +26,7 @@
658  * authorization.                                                           *
659  ****************************************************************************/
660 /*
661- * $Id: color_set.c,v 1.8 2014/02/01 22:10:42 tom Exp $
662+ * $Id: color_set.c,v 1.9 2019/08/17 21:49:19 tom Exp $
663  */
664
665 #include <test.priv.h>
666@@ -39,13 +39,14 @@
667 main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
668 {
669     NCURSES_COLOR_T f, b;
670-    int i;
671
672     initscr();
673     cbreak();
674     noecho();
675
676     if (has_colors()) {
677+	int i;
678+
679 	start_color();
680
681 	(void) pair_content(0, &f, &b);
682Index: test/demo_altkeys.c
683Prereq:  1.12
684--- ncurses-6.1-20190810+/test/demo_altkeys.c	2018-12-29 17:52:53.000000000 +0000
685+++ ncurses-6.1-20190817/test/demo_altkeys.c	2019-08-17 21:49:40.000000000 +0000
686@@ -1,5 +1,5 @@
687 /****************************************************************************
688- * Copyright (c) 2005-2017,2018 Free Software Foundation, Inc.              *
689+ * Copyright (c) 2005-2018,2019 Free Software Foundation, Inc.              *
690  *                                                                          *
691  * Permission is hereby granted, free of charge, to any person obtaining a  *
692  * copy of this software and associated documentation files (the            *
693@@ -26,7 +26,7 @@
694  * authorization.                                                           *
695  ****************************************************************************/
696 /*
697- * $Id: demo_altkeys.c,v 1.12 2018/12/29 17:52:53 tom Exp $
698+ * $Id: demo_altkeys.c,v 1.13 2019/08/17 21:49:40 tom Exp $
699  *
700  * Demonstrate the define_key() function.
701  * Thomas Dickey - 2005/10/22
702@@ -47,11 +47,12 @@
703 log_last_line(WINDOW *win)
704 {
705     FILE *fp;
706-    int y, x, n;
707-    char temp[256];
708
709     if ((fp = fopen(MY_LOGFILE, "a")) != 0) {
710+	char temp[256];
711+	int y, x, n;
712 	int need = sizeof(temp) - 1;
713+
714 	if (need > COLS)
715 	    need = COLS;
716 	getyx(win, y, x);
717@@ -75,8 +76,7 @@
718     int n;
719     int ch;
720 #if HAVE_GETTIMEOFDAY
721-    int secs, msecs;
722-    struct timeval current, previous;
723+    struct timeval previous;
724 #endif
725
726     unlink(MY_LOGFILE);
727@@ -119,8 +119,10 @@
728     while ((ch = getch()) != ERR) {
729 	bool escaped = (ch >= MY_KEYS);
730 	const char *name = keyname(escaped ? (ch - MY_KEYS) : ch);
731-
732 #if HAVE_GETTIMEOFDAY
733+	int secs, msecs;
734+	struct timeval current;
735+
736 	gettimeofday(&current, 0);
737 	secs = (int) (current.tv_sec - previous.tv_sec);
738 	msecs = (int) ((current.tv_usec - previous.tv_usec) / 1000);
739Index: test/demo_defkey.c
740Prereq:  1.28
741--- ncurses-6.1-20190810+/test/demo_defkey.c	2018-02-12 09:57:31.000000000 +0000
742+++ ncurses-6.1-20190817/test/demo_defkey.c	2019-08-17 21:49:19.000000000 +0000
743@@ -1,5 +1,5 @@
744 /****************************************************************************
745- * Copyright (c) 2002-2017,2018 Free Software Foundation, Inc.              *
746+ * Copyright (c) 2002-2018,2019 Free Software Foundation, Inc.              *
747  *                                                                          *
748  * Permission is hereby granted, free of charge, to any person obtaining a  *
749  * copy of this software and associated documentation files (the            *
750@@ -26,7 +26,7 @@
751  * authorization.                                                           *
752  ****************************************************************************/
753 /*
754- * $Id: demo_defkey.c,v 1.28 2018/02/12 09:57:31 tom Exp $
755+ * $Id: demo_defkey.c,v 1.29 2019/08/17 21:49:19 tom Exp $
756  *
757  * Demonstrate the define_key() function.
758  * Thomas Dickey - 2002/11/23
759@@ -45,10 +45,10 @@
760 log_last_line(WINDOW *win)
761 {
762     FILE *fp;
763-    int y, x, n;
764-    char temp[256];
765
766     if ((fp = fopen(MY_LOGFILE, "a")) != 0) {
767+	char temp[256];
768+	int y, x, n;
769 	int need = sizeof(temp) - 1;
770 	if (need > COLS)
771 	    need = COLS;
772@@ -98,11 +98,12 @@
773 visible(const char *string)
774 {
775     char *result = 0;
776-    size_t need = 1;
777-    int pass;
778-    int n;
779
780     if (string != 0 && *string != '\0') {
781+	int pass;
782+	int n;
783+	size_t need = 1;
784+
785 	for (pass = 0; pass < 2; ++pass) {
786 	    for (n = 0; string[n] != '\0'; ++n) {
787 		char temp[80];
788@@ -185,7 +186,6 @@
789
790     if (value != 0) {
791 	const char *prefix = 0;
792-	char temp[BUFSIZ];
793
794 	if (!(strncmp) (value, "\033[", (size_t) 2)) {
795 	    prefix = "\033O";
796@@ -193,6 +193,7 @@
797 	    prefix = "\033[";
798 	}
799 	if (prefix != 0) {
800+	    char temp[BUFSIZ];
801 	    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
802 			"%s%s", prefix, value + 2);
803 	    really_define_key(win, temp, code);
804Index: test/demo_forms.c
805Prereq:  1.55
806--- ncurses-6.1-20190810+/test/demo_forms.c	2018-07-14 23:26:02.000000000 +0000
807+++ ncurses-6.1-20190817/test/demo_forms.c	2019-08-17 21:49:19.000000000 +0000
808@@ -1,5 +1,5 @@
809 /****************************************************************************
810- * Copyright (c) 2003-2017,2018 Free Software Foundation, Inc.              *
811+ * Copyright (c) 2003-2018,2019 Free Software Foundation, Inc.              *
812  *                                                                          *
813  * Permission is hereby granted, free of charge, to any person obtaining a  *
814  * copy of this software and associated documentation files (the            *
815@@ -26,7 +26,7 @@
816  * authorization.                                                           *
817  ****************************************************************************/
818 /*
819- * $Id: demo_forms.c,v 1.55 2018/07/14 23:26:02 tom Exp $
820+ * $Id: demo_forms.c,v 1.56 2019/08/17 21:49:19 tom Exp $
821  *
822  * Demonstrate a variety of functions from the form library.
823  * Thomas Dickey - 2003/4/26
824@@ -338,9 +338,6 @@
825 show_current_field(WINDOW *win, FORM *form)
826 {
827     FIELD *field;
828-    FIELDTYPE *type;
829-    char *buffer;
830-    int nbuf;
831     int field_rows, field_cols, field_max;
832     int currow, curcol;
833
834@@ -355,7 +352,11 @@
835     if (data_behind(form))
836 	waddstr(win, " behind");
837     waddch(win, '\n');
838+
839     if ((field = current_field(form)) != 0) {
840+	FIELDTYPE *type;
841+	int nbuf;
842+
843 	wprintw(win, "Page %d%s, Field %d/%d%s:",
844 		form_page(form),
845 		new_page(field) ? "*" : "",
846@@ -411,6 +412,7 @@
847
848 	waddstr(win, "\n");
849 	for (nbuf = 0; nbuf <= 2; ++nbuf) {
850+	    char *buffer;
851 	    if ((buffer = field_buffer(field, nbuf)) != 0) {
852 		wprintw(win, "buffer %d:", nbuf);
853 		(void) wattrset(win, A_REVERSE);
854@@ -430,13 +432,11 @@
855 static void
856 demo_forms(void)
857 {
858-    WINDOW *w;
859     FORM *form;
860     FIELD *f[100];		/* will memset to zero */
861-    int finished = 0, c;
862+    int c;
863     unsigned n = 0;
864     int pg;
865-    WINDOW *also;
866     const char *fname;
867     static const char *my_enum[] =
868     {"first", "second", "third", 0};
869@@ -544,6 +544,9 @@
870     f[n] = (FIELD *) 0;
871
872     if ((form = new_form(f)) != 0) {
873+	WINDOW *w;
874+	WINDOW *also;
875+	int finished = 0;
876
877 	display_form(form);
878
879Index: test/demo_menus.c
880Prereq:  1.67
881--- ncurses-6.1-20190810+/test/demo_menus.c	2019-08-10 19:25:27.000000000 +0000
882+++ ncurses-6.1-20190817/test/demo_menus.c	2019-08-17 21:45:32.000000000 +0000
883@@ -26,7 +26,7 @@
884  * authorization.                                                           *
885  ****************************************************************************/
886 /*
887- * $Id: demo_menus.c,v 1.67 2019/08/10 19:25:27 tom Exp $
888+ * $Id: demo_menus.c,v 1.68 2019/08/17 21:45:32 tom Exp $
889  *
890  * Demonstrate a variety of functions from the menu library.
891  * Thomas Dickey - 2005/4/9
892@@ -309,12 +309,11 @@
893 static void
894 menu_destroy(MENU * m)
895 {
896-    int count;
897-
898     Trace(("menu_destroy %p", (void *) m));
899     if (m != 0) {
900 	ITEM **items = menu_items(m);
901 	const char *blob = 0;
902+	int count;
903
904 	count = item_count(m);
905 	Trace(("menu_destroy %p count %d", (void *) m, count));
906@@ -429,7 +428,6 @@
907 	    && (sb.st_mode & S_IFMT) == S_IFREG
908 	    && sb.st_size != 0) {
909 	    size_t size = (size_t) sb.st_size;
910-	    unsigned j, k;
911 	    char *blob = typeMalloc(char, size + 1);
912 	    MENU_DATA *list = typeCalloc(MENU_DATA, size + 1);
913
914@@ -442,6 +440,7 @@
915 		if (fp != 0) {
916 		    if (fread(blob, sizeof(char), size, fp) == size) {
917 			bool mark = TRUE;
918+			unsigned j, k;
919 			for (j = k = 0; j < size; ++j) {
920 			    if (mark) {
921 				list[k++].name = blob + j;
922@@ -609,7 +608,6 @@
923 /* interactively set the trace level */
924 {
925     ITEM **ip;
926-    unsigned newtrace;
927     int result;
928
929     for (ip = menu_items(mpTrace); *ip; ip++) {
930@@ -625,7 +623,7 @@
931
932     if (result == E_OK) {
933 	if (update_trace_menu(mpTrace) || cmd == REQ_TOGGLE_ITEM) {
934-	    newtrace = 0;
935+	    unsigned newtrace = 0;
936 	    for (ip = menu_items(mpTrace); *ip; ip++) {
937 		if (item_value(*ip)) {
938 		    MENU_DATA *td = (MENU_DATA *) item_userptr(*ip);
939Index: test/test_sgr.c
940Prereq:  1.13
941--- ncurses-6.1-20190810+/test/test_sgr.c	2019-07-28 18:13:39.000000000 +0000
942+++ ncurses-6.1-20190817/test/test_sgr.c	2019-08-17 21:36:44.000000000 +0000
943@@ -29,7 +29,7 @@
944 /*
945  * Author: Thomas E. Dickey
946  *
947- * $Id: test_sgr.c,v 1.13 2019/07/28 18:13:39 tom Exp $
948+ * $Id: test_sgr.c,v 1.14 2019/08/17 21:36:44 tom Exp $
949  *
950  * A simple demo of the sgr/sgr0 terminal capabilities.
951  */
952@@ -147,7 +147,7 @@
953     static char params[] = "SURBDBIPA";
954     unsigned n;
955
956-    printf("%4d ", bits);
957+    printf("%4u ", bits);
958     bits &= ~ignore;
959     for (n = 0; n < MAXPAR; ++n) {
960 	putchar((int) ((bits & (unsigned) (1 << n)) ? params[n] : '-'));
961