From bfe3845eb1a2ff02a740e917b537e939ec4e44cb Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sun, 30 Dec 2018 01:55:38 +0000 Subject: [PATCH] ncurses 6.1 - patch 20181229 + improve man/curs_mouse.3x with regard to xterm + modify tracemunch to accept filename parameters in addition to use as a pipe/filter. + minor optimization to reduce calls to _nc_reserve_pairs (prompted by discussion with Bryan Christ). + add test/pair_content.c and test/color_content.c + modify infocmp to omit filtering of "OTxx" names which are used for obsolete capabilities, when the output is sorted by long-names. Doing this helps when making a table of the short/long capability names. --- MANIFEST | 2 + NEWS | 14 +- VERSION | 2 +- dist.mk | 4 +- doc/html/man/adacurses6-config.1.html | 2 +- doc/html/man/captoinfo.1m.html | 2 +- doc/html/man/clear.1.html | 2 +- doc/html/man/curs_mouse.3x.html | 9 +- doc/html/man/form.3x.html | 2 +- doc/html/man/infocmp.1m.html | 2 +- doc/html/man/infotocap.1m.html | 2 +- doc/html/man/menu.3x.html | 2 +- doc/html/man/ncurses.3x.html | 2 +- doc/html/man/ncurses6-config.1.html | 2 +- doc/html/man/panel.3x.html | 2 +- doc/html/man/tabs.1.html | 2 +- doc/html/man/terminfo.5.html | 2 +- doc/html/man/tic.1m.html | 2 +- doc/html/man/toe.1m.html | 2 +- doc/html/man/tput.1.html | 2 +- doc/html/man/tset.1.html | 2 +- man/curs_mouse.3x | 12 +- ncurses/base/lib_color.c | 68 ++++--- ncurses/base/new_pair.c | 8 +- ncurses/curses.priv.h | 21 ++- 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 | 4 +- test/color_content.c | 248 ++++++++++++++++++++++++++ test/color_name.h | 6 +- test/demo_altkeys.c | 16 +- test/extended_color.c | 64 ++++--- test/foldkeys.c | 16 +- test/modules | 4 +- test/pair_content.c | 236 ++++++++++++++++++++++++ test/programs | 8 +- test/savescreen.c | 14 +- test/tclock.c | 14 +- test/test.priv.h | 21 ++- test/tracemunch | 230 +++++++++++++----------- 45 files changed, 793 insertions(+), 282 deletions(-) create mode 100644 test/color_content.c create mode 100644 test/pair_content.c diff --git a/MANIFEST b/MANIFEST index 3551d6d2..27a22f63 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1095,6 +1095,7 @@ ./test/cardfile.dat ./test/chgat.c ./test/clip_printw.c +./test/color_content.c ./test/color_name.h ./test/color_set.c ./test/configure @@ -1177,6 +1178,7 @@ ./test/package/mingw-ncurses-examples.spec ./test/package/ncurses-examples.spec ./test/padview.c +./test/pair_content.c ./test/parse_rgb.h ./test/picsmap.c ./test/picsmap.h diff --git a/NEWS b/NEWS index 39121c15..f672d6b6 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.3231 2018/12/16 00:18:46 tom Exp $ +-- $Id: NEWS,v 1.3236 2018/12/29 23:45:51 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,18 @@ 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. +20181229 + + improve man/curs_mouse.3x with regard to xterm + + modify tracemunch to accept filename parameters in addition to use + as a pipe/filter. + + minor optimization to reduce calls to _nc_reserve_pairs (prompted by + discussion with Bryan Christ). + + add test/pair_content.c and test/color_content.c + + modify infocmp to omit filtering of "OTxx" names which are used for + obsolete capabilities, when the output is sorted by long-names. + Doing this helps when making a table of the short/long capability + names. + 20181215 + several fixes for gcc8 strict compiler warnings. + fix a typo in comments (Aaron Gyes). diff --git a/VERSION b/VERSION index 0bab1fe9..c99e42ef 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5:0:10 6.1 20181215 +5:0:10 6.1 20181229 diff --git a/dist.mk b/dist.mk index 692aec26..3de52035 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.1256 2018/12/15 19:14:57 tom Exp $ +# $Id: dist.mk,v 1.1258 2018/12/29 15:15:21 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 = 20181215 +NCURSES_PATCH = 20181229 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/doc/html/man/adacurses6-config.1.html b/doc/html/man/adacurses6-config.1.html index 235e07f3..ff1a86ca 100644 --- a/doc/html/man/adacurses6-config.1.html +++ b/doc/html/man/adacurses6-config.1.html @@ -125,7 +125,7 @@

SEE ALSO

        curses(3x)
 
-       This describes ncurses version 6.1 (patch 20181208).
+       This describes ncurses version 6.1 (patch 20181229).
 
 
 
diff --git a/doc/html/man/captoinfo.1m.html b/doc/html/man/captoinfo.1m.html
index 59a0bb00..1ff472ec 100644
--- a/doc/html/man/captoinfo.1m.html
+++ b/doc/html/man/captoinfo.1m.html
@@ -190,7 +190,7 @@
 

SEE ALSO

        infocmp(1m), curses(3x), terminfo(5)
 
-       This describes ncurses version 6.1 (patch 20181208).
+       This describes ncurses version 6.1 (patch 20181229).
 
 
 

AUTHOR

diff --git a/doc/html/man/clear.1.html b/doc/html/man/clear.1.html
index 54b8157d..a1a22a3e 100644
--- a/doc/html/man/clear.1.html
+++ b/doc/html/man/clear.1.html
@@ -148,7 +148,7 @@
 

SEE ALSO

        tput(1), terminfo(5)
 
-       This describes ncurses version 6.1 (patch 20181208).
+       This describes ncurses version 6.1 (patch 20181229).
 
 
 
diff --git a/doc/html/man/curs_mouse.3x.html b/doc/html/man/curs_mouse.3x.html
index 97859667..baafe628 100644
--- a/doc/html/man/curs_mouse.3x.html
+++ b/doc/html/man/curs_mouse.3x.html
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_mouse.3x,v 1.49 2018/07/28 22:19:56 tom Exp @
+  * @Id: curs_mouse.3x,v 1.50 2018/12/29 23:40:47 tom Exp @
 -->
 
 
@@ -319,6 +319,10 @@
 
           \E[?1000%?%p1%{1}%=%th%el%;
 
+       The mouse driver also recognizes a newer xterm private mode 1006, e.g.,
+
+          \E[?1006;1000%?%p1%{1}%=%th%el%;
+
        The  z  member in the event structure is not presently used.  It is in-
        tended for use with touch screens (which may be pressure-sensitive)  or
        with 3D-mice/trackballs/power gloves.
@@ -345,7 +349,8 @@
        identify terminals which support the xterm mouse protocol, ncurses  as-
        sumes  that  if  your  $TERM  environment variable contains "xterm", or
        kmous is defined in the terminal description,  then  the  terminal  may
-       send mouse events.
+       send mouse events.  The kmous capability is checked first, allowing the
+       use of newer xterm mouse protocols.
 
 
 

SEE ALSO

diff --git a/doc/html/man/form.3x.html b/doc/html/man/form.3x.html
index 2fba6951..b296ec6d 100644
--- a/doc/html/man/form.3x.html
+++ b/doc/html/man/form.3x.html
@@ -246,7 +246,7 @@
        curses(3x)  and  related  pages  whose names begin "form_" for detailed
        descriptions of the entry points.
 
-       This describes ncurses version 6.1 (patch 20181208).
+       This describes ncurses version 6.1 (patch 20181229).
 
 
 
diff --git a/doc/html/man/infocmp.1m.html b/doc/html/man/infocmp.1m.html
index f93f94d4..c87696ee 100644
--- a/doc/html/man/infocmp.1m.html
+++ b/doc/html/man/infocmp.1m.html
@@ -481,7 +481,7 @@
 
        https://invisible-island.net/ncurses/tctest.html
 
-       This describes ncurses version 6.1 (patch 20181208).
+       This describes ncurses version 6.1 (patch 20181229).
 
 
 

AUTHOR

diff --git a/doc/html/man/infotocap.1m.html b/doc/html/man/infotocap.1m.html
index 971ab4f2..b70b1a92 100644
--- a/doc/html/man/infotocap.1m.html
+++ b/doc/html/man/infotocap.1m.html
@@ -85,7 +85,7 @@
 

SEE ALSO

        curses(3x), tic(1m), infocmp(1m), terminfo(5)
 
-       This describes ncurses version 6.1 (patch 20181208).
+       This describes ncurses version 6.1 (patch 20181229).
 
 
 

AUTHOR

diff --git a/doc/html/man/menu.3x.html b/doc/html/man/menu.3x.html
index 7a54da3c..c9ddc850 100644
--- a/doc/html/man/menu.3x.html
+++ b/doc/html/man/menu.3x.html
@@ -221,7 +221,7 @@
        curses(3x)  and  related  pages  whose names begin "menu_" for detailed
        descriptions of the entry points.
 
-       This describes ncurses version 6.1 (patch 20181208).
+       This describes ncurses version 6.1 (patch 20181229).
 
 
 
diff --git a/doc/html/man/ncurses.3x.html b/doc/html/man/ncurses.3x.html
index 092c974c..64590f9d 100644
--- a/doc/html/man/ncurses.3x.html
+++ b/doc/html/man/ncurses.3x.html
@@ -59,7 +59,7 @@
        method of updating  character  screens  with  reasonable  optimization.
        This  implementation  is  "new  curses"  (ncurses)  and is the approved
        replacement for 4.4BSD classic curses,  which  has  been  discontinued.
-       This describes ncurses version 6.1 (patch 20181208).
+       This describes ncurses version 6.1 (patch 20181229).
 
        The  ncurses  library emulates the curses library of System V Release 4
        UNIX, and XPG4 (X/Open Portability Guide) curses  (also  known  as  XSI
diff --git a/doc/html/man/ncurses6-config.1.html b/doc/html/man/ncurses6-config.1.html
index 2b0cd4e1..cee51992 100644
--- a/doc/html/man/ncurses6-config.1.html
+++ b/doc/html/man/ncurses6-config.1.html
@@ -112,7 +112,7 @@
 

SEE ALSO

        curses(3x)
 
-       This describes ncurses version 6.1 (patch 20181208).
+       This describes ncurses version 6.1 (patch 20181229).
 
 
 
diff --git a/doc/html/man/panel.3x.html b/doc/html/man/panel.3x.html
index 57118c05..5c0b19b7 100644
--- a/doc/html/man/panel.3x.html
+++ b/doc/html/man/panel.3x.html
@@ -204,7 +204,7 @@
 

SEE ALSO

        curses(3x), curs_variables(3x),
 
-       This describes ncurses version 6.1 (patch 20181208).
+       This describes ncurses version 6.1 (patch 20181229).
 
 
 

AUTHOR

diff --git a/doc/html/man/tabs.1.html b/doc/html/man/tabs.1.html
index 7be465a9..4b55a387 100644
--- a/doc/html/man/tabs.1.html
+++ b/doc/html/man/tabs.1.html
@@ -164,7 +164,7 @@
 

SEE ALSO

        tset(1), infocmp(1m), curses(3x), terminfo(5).
 
-       This describes ncurses version 6.1 (patch 20181208).
+       This describes ncurses version 6.1 (patch 20181229).
 
 
 
diff --git a/doc/html/man/terminfo.5.html b/doc/html/man/terminfo.5.html
index ea4a93d7..958ad4fc 100644
--- a/doc/html/man/terminfo.5.html
+++ b/doc/html/man/terminfo.5.html
@@ -74,7 +74,7 @@
        Terminfo describes terminals by giving a set of capabilities which they
        have, by specifying how to perform screen operations, and by specifying
        padding  requirements  and  initialization  sequences.   This describes
-       ncurses version 6.1 (patch 20181208).
+       ncurses version 6.1 (patch 20181229).
 
 
 

Terminfo Entry Syntax

diff --git a/doc/html/man/tic.1m.html b/doc/html/man/tic.1m.html
index 38270188..d7a03f7f 100644
--- a/doc/html/man/tic.1m.html
+++ b/doc/html/man/tic.1m.html
@@ -364,7 +364,7 @@
        infocmp(1m),   captoinfo(1m),   infotocap(1m),   toe(1m),   curses(3x),
        term(5).  terminfo(5).
 
-       This describes ncurses version 6.1 (patch 20181208).
+       This describes ncurses version 6.1 (patch 20181229).
 
 
 

AUTHOR

diff --git a/doc/html/man/toe.1m.html b/doc/html/man/toe.1m.html
index f0705592..fe0a6883 100644
--- a/doc/html/man/toe.1m.html
+++ b/doc/html/man/toe.1m.html
@@ -113,7 +113,7 @@
        tic(1m), infocmp(1m), captoinfo(1m),  infotocap(1m),  curses(3x),  ter-
        minfo(5).
 
-       This describes ncurses version 6.1 (patch 20181208).
+       This describes ncurses version 6.1 (patch 20181229).
 
 
 
diff --git a/doc/html/man/tput.1.html b/doc/html/man/tput.1.html
index afa3be2a..32ddfb38 100644
--- a/doc/html/man/tput.1.html
+++ b/doc/html/man/tput.1.html
@@ -522,7 +522,7 @@
 

SEE ALSO

        clear(1), stty(1), tabs(1), tset(1), terminfo(5), curs_termcap(3x).
 
-       This describes ncurses version 6.1 (patch 20181208).
+       This describes ncurses version 6.1 (patch 20181229).
 
 
 
diff --git a/doc/html/man/tset.1.html b/doc/html/man/tset.1.html
index 43ab7e46..88d8f5d5 100644
--- a/doc/html/man/tset.1.html
+++ b/doc/html/man/tset.1.html
@@ -389,7 +389,7 @@
        csh(1),  sh(1),  stty(1),   curs_terminfo(3x),   tty(4),   terminfo(5),
        ttys(5), environ(7)
 
-       This describes ncurses version 6.1 (patch 20181208).
+       This describes ncurses version 6.1 (patch 20181229).
 
 
 
diff --git a/man/curs_mouse.3x b/man/curs_mouse.3x
index f5d1cbab..f48cb1e8 100644
--- a/man/curs_mouse.3x
+++ b/man/curs_mouse.3x
@@ -27,7 +27,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_mouse.3x,v 1.49 2018/07/28 22:19:56 tom Exp $
+.\" $Id: curs_mouse.3x,v 1.50 2018/12/29 23:40:47 tom Exp $
 .ie \n(.g .ds `` \(lq
 .el       .ds `` ``
 .ie \n(.g .ds '' \(rq
@@ -370,6 +370,12 @@ corresponds to private mode 1000 of xterm:
 \\E[?1000%?%p1%{1}%=%th%el%;
 .RE
 .PP
+The mouse driver also recognizes a newer xterm private mode 1006, e.g.,
+.PP
+.RS 3
+\\E[?1006;1000%?%p1%{1}%=%th%el%;
+.RE
+.PP
 The \fIz\fP member in the event structure is not presently used.
 It is intended
 for use with touch screens (which may be pressure-sensitive) or with
@@ -396,9 +402,11 @@ i.e., it is the beginning of the response.
 .PP
 Because there are no standard terminal responses that would serve to identify
 terminals which support the xterm mouse protocol, \fBncurses\fR assumes that
-if your $TERM environment variable contains "xterm",
+if your $TERM environment variable contains \*(``xterm\*('',
 or \fBkmous\fR is defined in
 the terminal description, then the terminal may send mouse events.
+The \fBkmous\fP capability is checked first, allowing the
+use of newer xterm mouse protocols.
 .SH SEE ALSO
 \fBcurses\fR(3X),
 \fBcurs_kernel\fR(3X),
diff --git a/ncurses/base/lib_color.c b/ncurses/base/lib_color.c
index 409b66ca..df8424b4 100644
--- a/ncurses/base/lib_color.c
+++ b/ncurses/base/lib_color.c
@@ -48,7 +48,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_color.c,v 1.138 2018/05/16 08:24:08 tom Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.139 2018/12/29 20:10:07 tom Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define CanChange      InfoOf(SP_PARM).canchange
@@ -405,7 +405,7 @@ NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0)
 	    COLORS = maxcolors;
 #endif
 
-	    _nc_reserve_pairs(SP_PARM, 16);
+	    ReservePairs(SP_PARM, 16);
 	    if (SP_PARM->_color_pairs != 0) {
 		if (init_direct_colors(NCURSES_SP_ARG)) {
 		    result = OK;
@@ -514,49 +514,41 @@ _nc_change_pair(SCREEN *sp, int pair)
     }
 }
 
-NCURSES_EXPORT(colorpair_t *)
+NCURSES_EXPORT(void)
 _nc_reserve_pairs(SCREEN *sp, int want)
 {
-    colorpair_t *result = 0;
     int have = sp->_pair_alloc;
 
-    if ((sp->_color_pairs != 0) && (want < sp->_pair_alloc)) {
-	result = &(sp->_color_pairs[want]);
-    } else {
-
-	if (have == 0)
-	    have = 1;
-	while (have <= want)
-	    have *= 2;
-	if (have > sp->_pair_limit)
-	    have = sp->_pair_limit;
+    if (have == 0)
+	have = 1;
+    while (have <= want)
+	have *= 2;
+    if (have > sp->_pair_limit)
+	have = sp->_pair_limit;
 
-	if (sp->_color_pairs == 0) {
-	    sp->_color_pairs = TYPE_CALLOC(colorpair_t, have);
-	} else if (have > sp->_pair_alloc) {
+    if (sp->_color_pairs == 0) {
+	sp->_color_pairs = TYPE_CALLOC(colorpair_t, have);
+    } else if (have > sp->_pair_alloc) {
 #if NCURSES_EXT_COLORS
-	    colorpair_t *next;
-
-	    if ((next = typeCalloc(colorpair_t, have)) == 0)
-		_nc_err_abort(MSG_NO_MEMORY);
-	    memcpy(next, sp->_color_pairs, (size_t) sp->_pair_alloc * sizeof(*next));
-	    _nc_copy_pairs(sp, next, sp->_color_pairs, sp->_pair_alloc);
-	    free(sp->_color_pairs);
-	    sp->_color_pairs = next;
+	colorpair_t *next;
+
+	if ((next = typeCalloc(colorpair_t, have)) == 0)
+	    _nc_err_abort(MSG_NO_MEMORY);
+	memcpy(next, sp->_color_pairs, (size_t) sp->_pair_alloc * sizeof(*next));
+	_nc_copy_pairs(sp, next, sp->_color_pairs, sp->_pair_alloc);
+	free(sp->_color_pairs);
+	sp->_color_pairs = next;
 #else
-	    TYPE_REALLOC(colorpair_t, have, sp->_color_pairs);
-	    if (sp->_color_pairs != 0) {
-		memset(sp->_color_pairs + sp->_pair_alloc, 0,
-		       sizeof(colorpair_t) * (size_t) (have - sp->_pair_alloc));
-	    }
-#endif
-	}
+	TYPE_REALLOC(colorpair_t, have, sp->_color_pairs);
 	if (sp->_color_pairs != 0) {
-	    sp->_pair_alloc = have;
-	    result = &(sp->_color_pairs[want]);
+	    memset(sp->_color_pairs + sp->_pair_alloc, 0,
+		   sizeof(colorpair_t) * (size_t) (have - sp->_pair_alloc));
 	}
+#endif
+    }
+    if (sp->_color_pairs != 0) {
+	sp->_pair_alloc = have;
     }
-    return result;
 }
 
 /*
@@ -578,7 +570,7 @@ _nc_init_pair(SCREEN *sp, int pair, int f, int b)
 
     maxcolors = MaxColors;
 
-    _nc_reserve_pairs(sp, pair);
+    ReservePairs(sp, pair);
     previous = sp->_color_pairs[pair];
 #if NCURSES_EXT_FUNCS
     if (sp->_default_color || sp->_assumed_color) {
@@ -941,7 +933,7 @@ _nc_pair_content(SCREEN *sp, int pair, int *f, int *b)
 	int fg;
 	int bg;
 
-	_nc_reserve_pairs(sp, pair);
+	ReservePairs(sp, pair);
 	fg = FORE_OF(sp->_color_pairs[pair]);
 	bg = BACK_OF(sp->_color_pairs[pair]);
 #if NCURSES_EXT_FUNCS
@@ -1125,7 +1117,7 @@ NCURSES_SP_NAME(reset_color_pairs) (NCURSES_SP_DCL0)
 	    free(SP_PARM->_color_pairs);
 	    SP_PARM->_color_pairs = 0;
 	    SP_PARM->_pair_alloc = 0;
-	    _nc_reserve_pairs(SP_PARM, 16);
+	    ReservePairs(SP_PARM, 16);
 	    clearok(CurScreen(SP_PARM), TRUE);
 	    touchwin(StdScreen(SP_PARM));
 	}
diff --git a/ncurses/base/new_pair.c b/ncurses/base/new_pair.c
index bbccc19e..c47e61e7 100644
--- a/ncurses/base/new_pair.c
+++ b/ncurses/base/new_pair.c
@@ -60,7 +60,7 @@
 
 #endif
 
-MODULE_ID("$Id: new_pair.c,v 1.15 2018/03/01 15:02:12 tom Exp $")
+MODULE_ID("$Id: new_pair.c,v 1.17 2018/12/29 21:27:21 tom Exp $")
 
 #if NCURSES_EXT_COLORS
 
@@ -193,7 +193,8 @@ _nc_reset_color_pair(SCREEN *sp, int pair, colorpair_t * next)
 {
     colorpair_t *last;
     if (ValidPair(sp, pair)) {
-	last = _nc_reserve_pairs(sp, pair);
+	ReservePairs(sp, pair);
+	last = &(sp->_color_pairs[pair]);
 	delink_color_pair(sp, pair);
 	if (last->mode > cpFREE &&
 	    (last->fg != next->fg || last->bg != next->bg)) {
@@ -277,7 +278,8 @@ NCURSES_SP_NAME(alloc_pair) (NCURSES_SP_DCLx int fg, int bg)
 	    }
 	    if (!found && (SP_PARM->_pair_alloc < SP_PARM->_pair_limit)) {
 		pair = SP_PARM->_pair_alloc;
-		if (_nc_reserve_pairs(sp, pair) == 0) {
+		ReservePairs(SP_PARM, pair);
+		if (SP_PARM->_color_pairs == 0) {
 		    pair = -1;
 		} else {
 		    found = TRUE;
diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h
index b5be745d..4519ce95 100644
--- a/ncurses/curses.priv.h
+++ b/ncurses/curses.priv.h
@@ -34,7 +34,7 @@
  ****************************************************************************/
 
 /*
- * $Id: curses.priv.h,v 1.612 2018/12/16 01:16:58 tom Exp $
+ * $Id: curses.priv.h,v 1.613 2018/12/29 20:07:04 tom Exp $
  *
  *	curses.priv.h
  *
@@ -1544,26 +1544,27 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 #define PUTC_INIT	init_mb (PUT_st)
 #define PUTC(ch)	do { if(!isWidecExt(ch)) {				    \
 			if (Charable(ch)) {					    \
-			    TR_PUTC(CharOf(ch)); \
-			    NCURSES_OUTC_FUNC (NCURSES_SP_ARGx CharOf(ch)); \
+			    TR_PUTC(CharOf(ch));				    \
+			    NCURSES_OUTC_FUNC (NCURSES_SP_ARGx CharOf(ch));	    \
 			    COUNT_OUTCHARS(1);					    \
 			} else {						    \
 			    for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {	    \
 				PUTC_ch = (ch).chars[PUTC_i];			    \
 				if (PUTC_ch == L'\0')				    \
 				    break;					    \
-				PUTC_INIT;						    \
+				PUTC_INIT;					    \
 				PUTC_n = (int) wcrtomb(PUTC_buf,		    \
 						       (ch).chars[PUTC_i], &PUT_st); \
 				if (PUTC_n <= 0) {				    \
-				    if (PUTC_ch && is8bits(PUTC_ch) && PUTC_i == 0) \
-					TR_PUTC(CharOf(ch)); \
+				    if (PUTC_ch && is8bits(PUTC_ch) && PUTC_i == 0) { \
+					TR_PUTC(CharOf(ch));			    \
 					NCURSES_OUTC_FUNC (NCURSES_SP_ARGx CharOf(ch)); \
+				    }						    \
 				    break;					    \
 				} else {					    \
 				    int PUTC_j;					    \
 				    for (PUTC_j = 0; PUTC_j < PUTC_n; ++PUTC_j) {   \
-					TR_PUTC(PUTC_buf[PUTC_j]); \
+					TR_PUTC(PUTC_buf[PUTC_j]);		    \
 					NCURSES_OUTC_FUNC (NCURSES_SP_ARGx PUTC_buf[PUTC_j]); \
 				    }						    \
 				}						    \
@@ -2065,9 +2066,13 @@ extern NCURSES_EXPORT(int) _nc_init_color(SCREEN *, int, int, int, int);
 extern NCURSES_EXPORT(int) _nc_init_pair(SCREEN *, int, int, int);
 extern NCURSES_EXPORT(int) _nc_pair_content(SCREEN *, int, int *, int *);
 extern NCURSES_EXPORT(bool) _nc_reset_colors(void);
-extern NCURSES_EXPORT(colorpair_t *) _nc_reserve_pairs(SCREEN *, int);
+extern NCURSES_EXPORT(void) _nc_reserve_pairs(SCREEN *, int);
 extern NCURSES_EXPORT(void) _nc_change_pair(SCREEN *, int);
 
+#define ReservePairs(sp,want) \
+	    if ((sp->_color_pairs == 0) || (want >= sp->_pair_alloc)) \
+		_nc_reserve_pairs(sp, want)
+
 /* lib_getch.c */
 extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, int *, int EVENTLIST_2nd(_nc_eventlist *));
 
diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog
index 6c6adfbd..9f260cb6 100644
--- a/package/debian-mingw/changelog
+++ b/package/debian-mingw/changelog
@@ -1,8 +1,8 @@
-ncurses6 (6.1+20181215) unstable; urgency=low
+ncurses6 (6.1+20181229) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey   Sat, 15 Dec 2018 14:14:57 -0500
+ -- Thomas E. Dickey   Sat, 29 Dec 2018 10:15:21 -0500
 
 ncurses6 (5.9-20131005) unstable; urgency=low
 
diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog
index 6c6adfbd..9f260cb6 100644
--- a/package/debian-mingw64/changelog
+++ b/package/debian-mingw64/changelog
@@ -1,8 +1,8 @@
-ncurses6 (6.1+20181215) unstable; urgency=low
+ncurses6 (6.1+20181229) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey   Sat, 15 Dec 2018 14:14:57 -0500
+ -- Thomas E. Dickey   Sat, 29 Dec 2018 10:15:21 -0500
 
 ncurses6 (5.9-20131005) unstable; urgency=low
 
diff --git a/package/debian/changelog b/package/debian/changelog
index ce35b2ba..b268fd0b 100644
--- a/package/debian/changelog
+++ b/package/debian/changelog
@@ -1,8 +1,8 @@
-ncurses6 (6.1+20181215) unstable; urgency=low
+ncurses6 (6.1+20181229) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey   Sat, 15 Dec 2018 14:14:57 -0500
+ -- Thomas E. Dickey   Sat, 29 Dec 2018 10:15:21 -0500
 
 ncurses6 (5.9-20120608) unstable; urgency=low
 
diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi
index 5c0b5f64..2b9f4d52 100644
--- a/package/mingw-ncurses.nsi
+++ b/package/mingw-ncurses.nsi
@@ -1,4 +1,4 @@
-; $Id: mingw-ncurses.nsi,v 1.303 2018/12/15 19:14:57 tom Exp $
+; $Id: mingw-ncurses.nsi,v 1.305 2018/12/29 15:15:21 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  "2018"
-!define VERSION_MMDD  "1215"
+!define VERSION_MMDD  "1229"
 !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD}
 
 !define MY_ABI   "5"
diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec
index 2abd05cd..519da61e 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: 20181215
+Release: 20181229
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
diff --git a/package/ncurses.spec b/package/ncurses.spec
index e141cd1f..89ad313a 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: 20181215
+Release: 20181229
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
diff --git a/package/ncursest.spec b/package/ncursest.spec
index 4d625730..cffae6fa 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: 20181215
+Release: 20181229
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
diff --git a/progs/dump_entry.c b/progs/dump_entry.c
index 3b1fcb1e..e9e8d604 100644
--- a/progs/dump_entry.c
+++ b/progs/dump_entry.c
@@ -39,7 +39,7 @@
 #include "termsort.c"		/* this C file is generated */
 #include 	/* so is this */
 
-MODULE_ID("$Id: dump_entry.c,v 1.168 2017/09/02 21:01:54 tom Exp $")
+MODULE_ID("$Id: dump_entry.c,v 1.169 2018/12/23 00:37:35 tom Exp $")
 
 #define DISCARD(string) string = ABSENT_STRING
 #define PRINTF (void) printf
@@ -94,7 +94,7 @@ static int indent = 8;
 #define OBSOLETE(n) (n[0] == 'O' && n[1] == 'T')
 #endif
 
-#define isObsolete(f,n) ((f == F_TERMINFO || f == F_VARIABLE) && OBSOLETE(n))
+#define isObsolete(f,n) ((f == F_TERMINFO || f == F_VARIABLE) && (sortmode != S_VARIABLE) && OBSOLETE(n))
 
 #if NCURSES_XNAMES
 #define BoolIndirect(j) ((j >= BOOLCOUNT) ? (j) : ((sortmode == S_NOSORT) ? j : bool_indirect[j]))
diff --git a/test/color_content.c b/test/color_content.c
new file mode 100644
index 00000000..77b04f17
--- /dev/null
+++ b/test/color_content.c
@@ -0,0 +1,248 @@
+/****************************************************************************
+ * Copyright (c) 2018 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            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+/*
+ * $Id: color_content.c,v 1.2 2018/12/30 00:52:58 tom Exp $
+ */
+
+#define NEED_TIME_H
+#include 
+
+typedef struct {
+    NCURSES_COLOR_T r;
+    NCURSES_COLOR_T g;
+    NCURSES_COLOR_T b;
+} MYCOLOR;
+
+static int i_opt;
+static int l_opt;
+static int n_opt;
+static int r_opt;
+static int s_opt;
+
+static MYCOLOR *expected;
+
+#if HAVE_GETTIMEOFDAY
+static struct timeval initial_time;
+static struct timeval finish_time;
+#endif
+
+static void
+failed(const char *msg)
+{
+    printw("%s", msg);
+    getch();
+    endwin();
+    ExitProgram(EXIT_FAILURE);
+}
+
+static NCURSES_COLOR_T
+random_color(void)
+{
+    return (NCURSES_COLOR_T) (rand() % 1000);
+}
+
+static void
+setup_test(void)
+{
+    initscr();
+    cbreak();
+    noecho();
+    scrollok(stdscr, TRUE);
+    if (has_colors()) {
+	start_color();
+	if (!can_change_color())
+	    failed("this terminal cannot initialize colors");
+
+	if (!l_opt)
+	    l_opt = COLORS;
+	if (l_opt <= 0)
+	    failed("color limit must be greater than zero");
+
+	if (!n_opt) {
+	    NCURSES_PAIRS_T color;
+
+	    expected = typeCalloc(MYCOLOR, l_opt);
+	    if (s_opt) {
+		NCURSES_COLOR_T r;
+		NCURSES_COLOR_T g;
+		NCURSES_COLOR_T b;
+		color = 0;
+		for (r = 0; r < 1000; ++r) {
+		    for (g = 0; g < 1000; ++g) {
+			for (b = 0; b < 1000; ++b) {
+			    if (color < l_opt) {
+				init_color(color, r, g, b);
+				expected[color].r = r;
+				expected[color].g = g;
+				expected[color].b = b;
+				++color;
+			    } else {
+				break;
+			    }
+			}
+		    }
+		}
+	    } else {
+		for (color = 1; color < l_opt; ++color) {
+		    expected[color].r = random_color();
+		    expected[color].g = random_color();
+		    expected[color].b = random_color();
+		    init_color(color, expected[color].r, expected[color].g,
+			       expected[color].b);
+		}
+	    }
+	}
+    } else {
+	failed("This demo requires a color terminal");
+    }
+#if HAVE_GETTIMEOFDAY
+    gettimeofday(&initial_time, 0);
+#endif
+}
+
+static void
+run_test(void)
+{
+    NCURSES_PAIRS_T color;
+    bool success = TRUE;
+    for (color = 0; color < l_opt; ++color) {
+	NCURSES_COLOR_T r;
+	NCURSES_COLOR_T g;
+	NCURSES_COLOR_T b;
+	if (color_content(color, &r, &g, &b) == OK) {
+	    if (expected != 0) {
+		if (r != expected[color].r)
+		    success = FALSE;
+		if (g != expected[color].g)
+		    success = FALSE;
+		if (b != expected[color].b)
+		    success = FALSE;
+	    }
+	}
+    }
+    if (i_opt) {
+	addch(success ? '.' : '?');
+	refresh();
+    }
+}
+
+static void
+finish_test(void)
+{
+    getch();
+    endwin();
+}
+
+#if HAVE_GETTIMEOFDAY
+static double
+seconds(struct timeval *mark)
+{
+    double result = (double) mark->tv_sec;
+    result += ((double) mark->tv_usec / 1e6);
+    return result;
+}
+#endif
+
+static void
+usage(void)
+{
+    static const char *msg[] =
+    {
+	"Usage: pair_content [options]"
+	,""
+	,"Options:"
+	," -i       interactive, showing test-progress"
+	," -l NUM   test NUM color pairs, rather than terminal description"
+	," -n       do not initialize color pairs"
+	," -r COUNT repeat for given count"
+	," -s       initialize pairs sequentially rather than random"
+    };
+    size_t n;
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+    ExitProgram(EXIT_FAILURE);
+}
+
+int
+main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+{
+    int i;
+    int repeat;
+
+    while ((i = getopt(argc, argv, "il:nr:s")) != -1) {
+	switch (i) {
+	case 'i':
+	    i_opt = 1;
+	    break;
+	case 'l':
+	    if ((l_opt = atoi(optarg)) <= 0)
+		usage();
+	    break;
+	case 'n':
+	    n_opt = 1;
+	    break;
+	case 'r':
+	    if ((r_opt = atoi(optarg)) <= 0)
+		usage();
+	    break;
+	case 's':
+	    s_opt = 1;
+	    break;
+	default:
+	    usage();
+	}
+    }
+    if (optind < argc)
+	usage();
+    if (r_opt <= 0)
+	r_opt = 1;
+
+    setup_test();
+
+    for (repeat = 0; repeat < r_opt; ++repeat) {
+	run_test();
+	if (i_opt) {
+	    addch('.');
+	    refresh();
+	}
+    }
+
+    if (i_opt) {
+	addch('\n');
+    }
+    printw("DONE: ");
+#if HAVE_GETTIMEOFDAY
+    gettimeofday(&finish_time, 0);
+    printw("%.03f seconds",
+	   seconds(&finish_time)
+	   - seconds(&initial_time));
+#endif
+    finish_test();
+
+    ExitProgram(EXIT_SUCCESS);
+}
diff --git a/test/color_name.h b/test/color_name.h
index a9ea6a3e..5ec4dcbf 100644
--- a/test/color_name.h
+++ b/test/color_name.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2011-2012,2016 Free Software Foundation, Inc.              *
+ * Copyright (c) 2011-2016,2018 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_name.h,v 1.5 2016/09/04 20:11:36 tom Exp $
+ * $Id: color_name.h,v 1.6 2018/12/29 15:19:30 tom Exp $
  */
 
 #ifndef __COLORNAME_H
@@ -79,7 +79,7 @@ color_code(const char *color)
     }
     return result;
 }
-#endif /* NEED_COLOR_NAME */
+#endif /* NEED_COLOR_CODE */
 
 #ifdef NEED_COLOR_NAME
 static const char *
diff --git a/test/demo_altkeys.c b/test/demo_altkeys.c
index a83a549d..0f4e898a 100644
--- a/test/demo_altkeys.c
+++ b/test/demo_altkeys.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2005-2016,2017 Free Software Foundation, Inc.              *
+ * Copyright (c) 2005-2017,2018 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,27 +26,17 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_altkeys.c,v 1.11 2017/06/17 18:33:03 tom Exp $
+ * $Id: demo_altkeys.c,v 1.12 2018/12/29 17:52:53 tom Exp $
  *
  * Demonstrate the define_key() function.
  * Thomas Dickey - 2005/10/22
  */
 
+#define NEED_TIME_H
 #include 
 
 #if defined(NCURSES_VERSION) && NCURSES_EXT_FUNCS
 
-#if TIME_WITH_SYS_TIME
-# include 
-# include 
-#else
-# if HAVE_SYS_TIME_H
-#  include 
-# else
-#  include 
-# endif
-#endif
-
 #define MY_LOGFILE "demo_altkeys.log"
 #define MY_KEYS (KEY_MAX + 1)
 
diff --git a/test/extended_color.c b/test/extended_color.c
index 437ed568..63426e81 100644
--- a/test/extended_color.c
+++ b/test/extended_color.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2017 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2017,2018 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: extended_color.c,v 1.10 2017/04/15 21:40:50 tom Exp $
+ * $Id: extended_color.c,v 1.11 2018/12/29 21:50:33 tom Exp $
  */
 
 #include 
@@ -35,7 +35,12 @@
 
 #define SHOW(n) ((n) == ERR ? "ERR" : "OK")
 
+#if USE_SP_FUNCS
 static bool opt_s = FALSE;
+#define if_opt_s(a,b) (opt_s ? (a) : (b))
+#else
+#define if_opt_s(a,b) (b)
+#endif
 
 static void
 failed(const char *name)
@@ -51,11 +56,9 @@ do_pair_content(SCREEN *sp, int pair)
 {
     int i, f, b;
 
-    if (opt_s) {
-	i = extended_pair_content_sp(sp, pair, &f, &b);
-    } else {
-	i = extended_pair_content(0, &f, &b);
-    }
+    (void) sp;
+    i = if_opt_s(extended_pair_content_sp(sp, pair, &f, &b),
+		 extended_pair_content(0, &f, &b));
     if (i != OK)
 	failed("pair_content");
     printw("pair %d contains (%d,%d)\n", pair, f, b);
@@ -66,11 +69,10 @@ static void
 do_init_pair(SCREEN *sp, int pair, int fg, int bg)
 {
     int i;
-    if (opt_s) {
-	i = init_extended_pair_sp(sp, pair, fg, bg);
-    } else {
-	i = init_extended_pair(pair, fg, bg);
-    }
+
+    (void) sp;
+    i = if_opt_s(init_extended_pair_sp(sp, pair, fg, bg),
+		 init_extended_pair(pair, fg, bg));
     if (i != OK)
 	failed("init_pair");
 }
@@ -80,11 +82,10 @@ do_init_color(SCREEN *sp, int color, int adjust)
 {
     int r, g, b;
     int i;
-    if (opt_s) {
-	i = extended_color_content_sp(sp, color, &r, &g, &b);
-    } else {
-	i = extended_color_content(color, &r, &g, &b);
-    }
+
+    (void) sp;
+    i = if_opt_s(extended_color_content_sp(sp, color, &r, &g, &b),
+		 extended_color_content(color, &r, &g, &b));
     if (i != OK)
 	failed("color_content");
 
@@ -92,11 +93,8 @@ do_init_color(SCREEN *sp, int color, int adjust)
     g = (adjust + 1000 + g) % 1000;
     b = (adjust + 1000 + b) % 1000;
 
-    if (opt_s) {
-	i = init_extended_color_sp(sp, color, r, g, b);
-    } else {
-	i = init_extended_color(color, r, g, b);
-    }
+    i = if_opt_s(init_extended_color_sp(sp, color, r, g, b),
+		 init_extended_color(color, r, g, b));
     if (i != OK)
 	failed("init_color");
 }
@@ -116,11 +114,10 @@ show_1_rgb(SCREEN *sp, const char *name, int color, int y, int x)
 {
     int r, g, b;
     int i;
-    if (opt_s) {
-	i = extended_color_content_sp(sp, color, &r, &g, &b);
-    } else {
-	i = extended_color_content(color, &r, &g, &b);
-    }
+
+    (void) sp;
+    i = if_opt_s(extended_color_content_sp(sp, color, &r, &g, &b),
+		 extended_color_content(color, &r, &g, &b));
     wmove(stdscr, y, x);
     if (i == OK) {
 	printw("%-8s %3d/%3d/%3d", name, r, g, b);
@@ -166,9 +163,11 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
 
     while ((i = getopt(argc, argv, "s")) != -1) {
 	switch (i) {
+#if USE_SP_FUNCS
 	case 's':
 	    opt_s = TRUE;
 	    break;
+#endif
 	default:
 	    usage();
 	    /* NOTREACHED */
@@ -210,11 +209,8 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
 
     printw("Drawing soft-key tabs with pair 2\n");
     slk_attrset(A_BOLD);	/* reverse-video is hard to see */
-    if (opt_s) {
-	extended_slk_color_sp(sp, 2);
-    } else {
-	extended_slk_color(2);
-    }
+    i = if_opt_s(extended_slk_color_sp(sp, 2),
+		 extended_slk_color(2));
     for (i = 1; i <= 8; ++i) {
 	char temp[80];
 	sprintf(temp, "(SLK-%d)", i);
@@ -223,7 +219,9 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
     slk_touch();
     slk_noutrefresh();
 
-    if (opt_s ? can_change_color_sp(sp) : can_change_color()) {
+    i = if_opt_s(can_change_color_sp(sp),
+		 can_change_color());
+    if (i) {
 	do_color_set("Default Colors", 0);
 	printw("Press any key to stop...\n");
 	nodelay(stdscr, TRUE);
diff --git a/test/foldkeys.c b/test/foldkeys.c
index f7ecfd97..bcda90c2 100644
--- a/test/foldkeys.c
+++ b/test/foldkeys.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2006-2016,2017 Free Software Foundation, Inc.              *
+ * Copyright (c) 2006-2017,2018 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, 2006
  *
- * $Id: foldkeys.c,v 1.6 2017/06/17 19:36:33 tom Exp $
+ * $Id: foldkeys.c,v 1.7 2018/12/29 17:53:03 tom Exp $
  *
  * Demonstrate a method for altering key definitions at runtime.
  *
@@ -38,21 +38,11 @@
  * merging only for the keys which are defined in the terminal description.
  */
 
+#define NEED_TIME_H
 #include 
 
 #if defined(NCURSES_VERSION) && NCURSES_EXT_FUNCS
 
-#if TIME_WITH_SYS_TIME
-# include 
-# include 
-#else
-# if HAVE_SYS_TIME_H
-#  include 
-# else
-#  include 
-# endif
-#endif
-
 #define MY_LOGFILE "demo_foldkeys.log"
 #define MY_KEYS (KEY_MAX + 1)
 
diff --git a/test/modules b/test/modules
index dcdd29f5..4862b100 100644
--- a/test/modules
+++ b/test/modules
@@ -1,4 +1,4 @@
-# $Id: modules,v 1.68 2018/11/24 17:59:04 tom Exp $
+# $Id: modules,v 1.69 2018/12/29 15:32:12 tom Exp $
 ##############################################################################
 # Copyright (c) 1998-2017,2018 Free Software Foundation, Inc.                #
 #                                                                            #
@@ -38,6 +38,7 @@ bs		progs		$(srcdir)	$(HEADER_DEPS)
 cardfile	progs		$(srcdir)	$(HEADER_DEPS)	../include/panel.h ../include/form.h
 chgat		progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
 clip_printw	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
+color_content	progs		$(srcdir)	$(HEADER_DEPS)
 color_set	progs		$(srcdir)	$(HEADER_DEPS)
 demo_altkeys	progs		$(srcdir)	$(HEADER_DEPS)
 demo_defkey	progs		$(srcdir)	$(HEADER_DEPS)
@@ -80,6 +81,7 @@ movewindow	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
 ncurses		progs		$(srcdir)	$(HEADER_DEPS)	../include/panel.h ../include/menu.h ../include/form.h
 newdemo		progs		$(srcdir)	$(HEADER_DEPS)
 padview		progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/widechars.h	$(srcdir)/popup_msg.h
+pair_content	progs		$(srcdir)	$(HEADER_DEPS)
 picsmap		progs		$(srcdir)	$(HEADER_DEPS)
 popup_msg	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
 railroad	progs		$(srcdir)	$(HEADER_DEPS)
diff --git a/test/pair_content.c b/test/pair_content.c
new file mode 100644
index 00000000..4e1d0b88
--- /dev/null
+++ b/test/pair_content.c
@@ -0,0 +1,236 @@
+/****************************************************************************
+ * Copyright (c) 2018 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            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+/*
+ * $Id: pair_content.c,v 1.2 2018/12/30 00:54:48 tom Exp $
+ */
+
+#define NEED_TIME_H
+#include 
+
+typedef struct {
+    NCURSES_COLOR_T fg;
+    NCURSES_COLOR_T bg;
+} MYPAIR;
+
+static int i_opt;
+static int l_opt;
+static int n_opt;
+static int r_opt;
+static int s_opt;
+
+static MYPAIR *expected;
+
+#if HAVE_GETTIMEOFDAY
+static struct timeval initial_time;
+static struct timeval finish_time;
+#endif
+
+static void
+failed(const char *msg)
+{
+    printw("%s", msg);
+    getch();
+    endwin();
+    ExitProgram(EXIT_FAILURE);
+}
+
+static NCURSES_COLOR_T
+random_color(void)
+{
+    return (NCURSES_COLOR_T) (rand() % COLORS);
+}
+
+static void
+setup_test(void)
+{
+    initscr();
+    cbreak();
+    noecho();
+    scrollok(stdscr, TRUE);
+    if (has_colors()) {
+	start_color();
+
+	if (!l_opt)
+	    l_opt = COLOR_PAIRS;
+	if (l_opt <= 1)
+	    failed("color-pair limit must be greater than one");
+
+	if (!n_opt) {
+	    NCURSES_PAIRS_T pair;
+
+	    expected = typeCalloc(MYPAIR, l_opt);
+	    if (s_opt) {
+		NCURSES_COLOR_T fg;
+		NCURSES_COLOR_T bg;
+		pair = 1;
+		for (fg = 0; fg < COLORS; ++fg) {
+		    for (bg = 0; bg < COLORS; ++bg) {
+			if (pair < l_opt) {
+			    init_pair(pair, fg, bg);
+			    expected[pair].fg = fg;
+			    expected[pair].bg = bg;
+			    ++pair;
+			} else {
+			    break;
+			}
+		    }
+		}
+	    } else {
+		for (pair = 1; (int) pair < l_opt; ++pair) {
+		    expected[pair].fg = random_color();
+		    expected[pair].bg = random_color();
+		    init_pair(pair, expected[pair].fg, expected[pair].bg);
+		}
+	    }
+	}
+    } else {
+	failed("This demo requires a color terminal");
+    }
+#if HAVE_GETTIMEOFDAY
+    gettimeofday(&initial_time, 0);
+#endif
+}
+
+static void
+run_test(void)
+{
+    NCURSES_PAIRS_T pair;
+    bool success = TRUE;
+    for (pair = 1; (int) pair < l_opt; ++pair) {
+	NCURSES_COLOR_T fg;
+	NCURSES_COLOR_T bg;
+	if (pair_content(pair, &fg, &bg) == OK) {
+	    if (expected != 0) {
+		if (fg != expected[pair].fg)
+		    success = FALSE;
+		if (bg != expected[pair].bg)
+		    success = FALSE;
+	    }
+	}
+    }
+    if (i_opt) {
+	addch(success ? '.' : '?');
+	refresh();
+    }
+}
+
+static void
+finish_test(void)
+{
+    getch();
+    endwin();
+}
+
+#if HAVE_GETTIMEOFDAY
+static double
+seconds(struct timeval *mark)
+{
+    double result = (double) mark->tv_sec;
+    result += ((double) mark->tv_usec / 1e6);
+    return result;
+}
+#endif
+
+static void
+usage(void)
+{
+    static const char *msg[] =
+    {
+	"Usage: pair_content [options]"
+	,""
+	,"Options:"
+	," -i       interactive, showing test-progress"
+	," -l NUM   test NUM color pairs, rather than terminal description"
+	," -n       do not initialize color pairs"
+	," -r COUNT repeat for given count"
+	," -s       initialize pairs sequentially rather than random"
+    };
+    size_t n;
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+    ExitProgram(EXIT_FAILURE);
+}
+
+int
+main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+{
+    int i;
+    int repeat;
+
+    while ((i = getopt(argc, argv, "il:nr:s")) != -1) {
+	switch (i) {
+	case 'i':
+	    i_opt = 1;
+	    break;
+	case 'l':
+	    if ((l_opt = atoi(optarg)) <= 0)
+		usage();
+	    break;
+	case 'n':
+	    n_opt = 1;
+	    break;
+	case 'r':
+	    if ((r_opt = atoi(optarg)) <= 0)
+		usage();
+	    break;
+	case 's':
+	    s_opt = 1;
+	    break;
+	default:
+	    usage();
+	}
+    }
+    if (optind < argc)
+	usage();
+    if (r_opt <= 0)
+	r_opt = 1;
+
+    setup_test();
+
+    for (repeat = 0; repeat < r_opt; ++repeat) {
+	run_test();
+	if (i_opt) {
+	    addch('.');
+	    refresh();
+	}
+    }
+
+    if (i_opt) {
+	addch('\n');
+    }
+    printw("DONE: ");
+#if HAVE_GETTIMEOFDAY
+    gettimeofday(&finish_time, 0);
+    printw("%.03f seconds",
+	   seconds(&finish_time)
+	   - seconds(&initial_time));
+#endif
+    finish_test();
+
+    ExitProgram(EXIT_SUCCESS);
+}
diff --git a/test/programs b/test/programs
index dfa4cb43..e9e5144c 100644
--- a/test/programs
+++ b/test/programs
@@ -1,6 +1,6 @@
-# $Id: programs,v 1.42 2018/11/24 17:56:32 tom Exp $
+# $Id: programs,v 1.43 2018/12/29 15:32:00 tom Exp $
 ##############################################################################
-# Copyright (c) 2006-2016,2017 Free Software Foundation, Inc.                #
+# Copyright (c) 2006-2017,2018 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 "Software"), #
@@ -36,6 +36,7 @@ bs		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	bs
 cardfile	$(LDFLAGS_DEFAULT)	$(LOCAL_LIBS)	cardfile
 chgat		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	chgat popup_msg
 clip_printw	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	clip_printw popup_msg
+color_content	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	color_content
 color_set	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	color_set
 demo_altkeys	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	demo_altkeys
 demo_defkey	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	demo_defkey
@@ -74,9 +75,10 @@ list_keys	$(LDFLAGS_TINFO)	$(LOCAL_LIBS)	list_keys
 lrtest		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	lrtest
 movewindow	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	movewindow popup_msg
 ncurses		$(LDFLAGS_DEFAULT)	$(LOCAL_LIBS)	ncurses
+newdemo		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	newdemo
 padview		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	padview popup_msg
+pair_content	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	pair_content
 picsmap		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	picsmap
-newdemo		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	newdemo
 railroad	$(LDFLAGS_TINFO)	$(LOCAL_LIBS)	railroad
 rain		$(LDFLAGS_THREADS)	$(LOCAL_LIBS)	rain popup_msg
 redraw		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	redraw popup_msg
diff --git a/test/savescreen.c b/test/savescreen.c
index 9d88079f..d96089da 100644
--- a/test/savescreen.c
+++ b/test/savescreen.c
@@ -26,12 +26,13 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: savescreen.c,v 1.53 2018/05/12 15:11:16 tom Exp $
+ * $Id: savescreen.c,v 1.54 2018/12/29 17:25:56 tom Exp $
  *
  * Demonstrate save/restore functions from the curses library.
  * Thomas Dickey - 2007/7/14
  */
 
+#define NEED_TIME_H
 #include 
 #include 
 #include 
@@ -41,17 +42,6 @@
 #include 
 #include 
 
-#if TIME_WITH_SYS_TIME
-# include 
-# include 
-#else
-# if HAVE_SYS_TIME_H
-#  include 
-# else
-#  include 
-# endif
-#endif
-
 #if defined(__hpux)
 #define MyMarker 'X'
 #else
diff --git a/test/tclock.c b/test/tclock.c
index 42cb8cf7..23456a43 100644
--- a/test/tclock.c
+++ b/test/tclock.c
@@ -1,22 +1,12 @@
-/* $Id: tclock.c,v 1.38 2017/09/09 00:37:06 tom Exp $ */
+/* $Id: tclock.c,v 1.39 2018/12/29 17:23:42 tom Exp $ */
 
+#define NEED_TIME_H
 #include 
 
 #if HAVE_MATH_H
 
 #include 
 
-#if TIME_WITH_SYS_TIME
-# include 
-# include 
-#else
-# if HAVE_SYS_TIME_H
-#  include 
-# else
-#  include 
-# endif
-#endif
-
 /*
   tclock - analog/digital clock for curses.
   If it gives you joy, then
diff --git a/test/test.priv.h b/test/test.priv.h
index f4c11aa5..f1ac8774 100644
--- a/test/test.priv.h
+++ b/test/test.priv.h
@@ -29,7 +29,7 @@
 /****************************************************************************
  *  Author: Thomas E. Dickey                    1996-on                     *
  ****************************************************************************/
-/* $Id: test.priv.h,v 1.169 2018/08/19 00:28:27 tom Exp $ */
+/* $Id: test.priv.h,v 1.171 2018/12/29 21:44:07 tom Exp $ */
 
 #ifndef __TEST_PRIV_H
 #define __TEST_PRIV_H 1
@@ -467,6 +467,12 @@ extern int optind;
 #define slk_clear()		/* nothing */
 #endif
 
+#if HAVE_TPUTS_SP
+#define USE_SP_FUNCS 1
+#else
+#define USE_SP_FUNCS 0
+#endif
+
 #ifndef HAVE_WSYNCDOWN
 #define wsyncdown(win)		/* nothing */
 #endif
@@ -897,6 +903,19 @@ extern char *strnames[], *strcodes[], *strfnames[];
 
 #endif
 
+#ifdef NEED_TIME_H
+#if TIME_WITH_SYS_TIME
+# include 
+# include 
+#else
+# if HAVE_SYS_TIME_H
+#  include 
+# else
+#  include 
+# endif
+#endif
+#endif
+
 /* Use this to quiet gcc's -Wwrite-strings warnings, but accommodate SVr4
  * curses which doesn't have const parameters declared (so far) in the places
  * that XSI shows.
diff --git a/test/tracemunch b/test/tracemunch
index 0e05aaee..c23607e9 100755
--- a/test/tracemunch
+++ b/test/tracemunch
@@ -1,5 +1,5 @@
 #!/usr/bin/env perl
-# $Id: tracemunch,v 1.20 2018/05/02 00:14:29 tom Exp $
+# $Id: tracemunch,v 1.24 2018/12/29 22:20:06 tom Exp $
 ##############################################################################
 # Copyright (c) 1998-2017,2018 Free Software Foundation, Inc.                #
 #                                                                            #
@@ -90,129 +90,149 @@ sub transaddr {
     return $arg;
 }
 
-while () {
-    my $addr;
-    my $n;
-    my $awaiting = "";
-
-  CLASSIFY: {
-
-        my $thread = "";
-        if ( $_ =~ /^(0x[[:xdigit:]]+):/ ) {
-            $thr_addr{$1} = ++$thr_nums unless defined $thr_addr{$1};
-            $thread = "thread" . $thr_addr{$1} . ":";
-            $_ =~ s/^[^:]*://;
-        }
-
-        # Transform window pointer addresses so it's easier to compare logs
-        $awaiting = "curscr" if ( $_ =~ /creating curscr/ );
-        $awaiting = "newscr" if ( $_ =~ /creating newscr/ );
-        $awaiting = "stdscr" if ( $_ =~ /creating stdscr/ );
-        $awaiting = "screen" if ( $_ =~ /^(\+ )*called \{new_prescr\(\)/ );
-        if ( $_ =~ /^create :window 0x([[:xdigit:]]+)/ ) {
-            $addr = "0x$1";
-            if ( $awaiting eq "curscr" ) {
-                $curscr = $addr;
-            }
-            elsif ( $awaiting eq "newscr" ) {
-                $newscr = $addr;
+sub muncher($) {
+    my $STDIN = shift;
+
+    while (<$STDIN>) {
+        my $addr;
+        my $n;
+        my $awaiting = "";
+
+      CLASSIFY: {
+
+            # just in case someone tries a file with cr/lf line-endings:
+            $_ =~ s/\r\n/\n/g;
+            $_ =~ s/\r/\n/g;
+
+            my $thread = "";
+            if ( $_ =~ /^(0x[[:xdigit:]]+):/ ) {
+                $thr_addr{$1} = ++$thr_nums unless defined $thr_addr{$1};
+                $thread = "thread" . $thr_addr{$1} . ":";
+                $_ =~ s/^[^:]*://;
             }
-            elsif ( $awaiting eq "stdscr" ) {
-                $stdscr = $addr;
+
+            # Transform window pointer addresses so it's easier to compare logs
+            $awaiting = "curscr" if ( $_ =~ /creating curscr/ );
+            $awaiting = "newscr" if ( $_ =~ /creating newscr/ );
+            $awaiting = "stdscr" if ( $_ =~ /creating stdscr/ );
+            $awaiting = "screen" if ( $_ =~ /^(\+ )*called \{new_prescr\(\)/ );
+            if ( $_ =~ /^create :window 0x([[:xdigit:]]+)/ ) {
+                $addr = "0x$1";
+                if ( $awaiting eq "curscr" ) {
+                    $curscr = $addr;
+                }
+                elsif ( $awaiting eq "newscr" ) {
+                    $newscr = $addr;
+                }
+                elsif ( $awaiting eq "stdscr" ) {
+                    $stdscr = $addr;
+                }
+                else {
+                    $win_addr{$addr} = $win_nums++;
+                }
+                $awaiting = "";
             }
-            else {
-                $win_addr{$addr} = $win_nums++;
+            elsif ( $_ =~ /^(\+ )*called \{_nc_add_to_try\((0x[[:xdigit:]]+),/ )
+            {
+                $try_addr{$2} = ++$try_nums unless defined $try_addr{$2};
             }
-            $awaiting = "";
-        }
-        elsif ( $_ =~ /^(\+ )*called \{_nc_add_to_try\((0x[[:xdigit:]]+),/ ) {
-            $try_addr{$2} = ++$try_nums unless defined $try_addr{$2};
-        }
-        elsif ( $_ =~ /^(\+ )*_nc_alloc_screen_sp 0x([[:xdigit:]]+)/ ) {
-            $addr = "0x$2";
-            $scr_addr{$addr} = ++$scr_nums unless ( $scr_addr{$addr} );
-            $awaiting = "";
-        }
-        elsif ( $_ =~ /^(\+ )*return }0x([[:xdigit:]]+)/ ) {
-            $addr = "0x$2";
-            if ( $awaiting eq "screen" ) {
+            elsif ( $_ =~ /^(\+ )*_nc_alloc_screen_sp 0x([[:xdigit:]]+)/ ) {
+                $addr = "0x$2";
                 $scr_addr{$addr} = ++$scr_nums unless ( $scr_addr{$addr} );
+                $awaiting = "";
             }
-        }
-        elsif ( $_ =~ /^\.\.\.deleted win=0x([[:xdigit:]]+)/ ) {
-            $addr = "0x$1";
-            $_    = &transaddr($_);
-            if ( $addr eq $curscr ) {
-                $curscr = "";
-            }
-            elsif ( $addr eq $newscr ) {
-                $newscr = "";
-            }
-            elsif ( $addr eq $stdscr ) {
-                $stdscr = "";
-            }
-            else {
-                undef $win_addr{$addr};
+            elsif ( $_ =~ /^(\+ )*return }0x([[:xdigit:]]+)/ ) {
+                $addr = "0x$2";
+                if ( $awaiting eq "screen" ) {
+                    $scr_addr{$addr} = ++$scr_nums unless ( $scr_addr{$addr} );
+                }
             }
-        }
-
-        # Compactify runs of PutAttrChar calls (TR_CHARPUT)
-        if ( $_ =~ /$putattr/ ) {
-            my $putattr_chars = $1;
-            my $starty        = $2;
-            my $startx        = $3;
-            while () {
-                if ( $_ =~ /$putattr/ ) {
-                    $putattr_chars .= $1;
+            elsif ( $_ =~ /^\.\.\.deleted win=0x([[:xdigit:]]+)/ ) {
+                $addr = "0x$1";
+                $_    = &transaddr($_);
+                if ( $addr eq $curscr ) {
+                    $curscr = "";
+                }
+                elsif ( $addr eq $newscr ) {
+                    $newscr = "";
+                }
+                elsif ( $addr eq $stdscr ) {
+                    $stdscr = "";
                 }
                 else {
-                    last;
+                    undef $win_addr{$addr};
                 }
             }
-            print
+
+            # Compactify runs of PutAttrChar calls (TR_CHARPUT)
+            if ( $_ =~ /$putattr/ ) {
+                my $putattr_chars = $1;
+                my $starty        = $2;
+                my $startx        = $3;
+                while (<$STDIN>) {
+                    if ( $_ =~ /$putattr/ ) {
+                        $putattr_chars .= $1;
+                    }
+                    else {
+                        last;
+                    }
+                }
+                print
 "RUN of PutAttrChar()s: \"$putattr_chars\" from ${starty}, ${startx}\n";
-            redo CLASSIFY;
-        }
-
-        # Compactify runs of waddnstr calls (TR_CALLS)
-        if ( $_ =~ /$waddnstr/ ) {
-            my $waddnstr_chars = $2;
-            my $winaddr        = $1;
-            while () {
-                if ( $_ =~ /$waddnstr/ && $1 eq $winaddr ) {
-                    $waddnstr_chars .= $2;
+                redo CLASSIFY;
+            }
+
+            # Compactify runs of waddnstr calls (TR_CALLS)
+            if ( $_ =~ /$waddnstr/ ) {
+                my $waddnstr_chars = $2;
+                my $winaddr        = $1;
+                while (<$STDIN>) {
+                    if ( $_ =~ /$waddnstr/ && $1 eq $winaddr ) {
+                        $waddnstr_chars .= $2;
+                    }
+                    else {
+                        last;
+                    }
+                }
+                my $winaddstr = &transaddr($winaddr);
+                print "RUN of waddnstr()s: $winaddr, \"$waddnstr_chars\"\n";
+                redo CLASSIFY;
+            }
+
+            # More transformations can go here
+
+            # Repeated runs of anything
+            my $anyline     = &transaddr($_);
+            my $repeatcount = 1;
+            while (<$STDIN>) {
+                if ( &transaddr($_) eq $anyline ) {
+                    $repeatcount++;
                 }
                 else {
                     last;
                 }
             }
-            my $winaddstr = &transaddr($winaddr);
-            print "RUN of waddnstr()s: $winaddr, \"$waddnstr_chars\"\n";
-            redo CLASSIFY;
-        }
-
-        # More transformations can go here
-
-        # Repeated runs of anything
-        my $anyline     = &transaddr($_);
-        my $repeatcount = 1;
-        while () {
-            if ( &transaddr($_) eq $anyline ) {
-                $repeatcount++;
+            if ( $repeatcount > 1 ) {
+                print "${repeatcount} REPEATS OF $anyline";
             }
             else {
-                last;
+                print $thread . $anyline;
             }
-        }
-        if ( $repeatcount > 1 ) {
-            print "${repeatcount} REPEATS OF $anyline";
-        }
-        else {
-            print $thread . $anyline;
-        }
-        redo CLASSIFY if $_;
-
-    }    # :CLASSIFY
+            redo CLASSIFY if $_;
+
+        }    # :CLASSIFY
+    }
+}
+
+if ( $#ARGV >= 0 ) {
+    while ( $#ARGV >= 0 ) {
+        my $file = shift @ARGV;
+        open my $ifh, "<", $file or die $!;
+        &muncher($ifh);
+    }
+}
+else {
+    &muncher( \*STDIN );
 }
 
 # tracemunch ends here
-- 
2.44.0