From: Thomas E. Dickey Date: Sun, 15 Oct 2017 01:25:24 +0000 (+0000) Subject: ncurses 6.0 - patch 20171014 X-Git-Tag: v6.1~15 X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=commitdiff_plain;h=7fa7badf32c514211478cf9f79c70f20d435c2f2;ds=sidebyside ncurses 6.0 - patch 20171014 + minor cleanup to test/view.c: + eliminate "-n" option by simply reading the whole file. + implement page up/down commands. + add check in tput for init/reset operands to ensure those use a terminal. + improve manual pages which discuss chtype, cchar_t types and the attribute values which can be stored in those types. + correct array-index when parsing "-T" command-line option in tabs program. + modify demo_new_pair.c to pass extended pairs to setcchar(). + add test/dots_xcurses.c to illustrate a different approach used for extended colors which can be contrasted with dots_curses.c. + add a check in tic to note when a description uses non-mandatory delays without xon_xoff. This is not an error, but some descriptions for a terminal emulator may use the combination incorrectly. --- diff --git a/MANIFEST b/MANIFEST index 801598ec..eb0593ca 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1110,6 +1110,7 @@ ./test/dots_curses.c ./test/dots_mvcur.c ./test/dots_termcap.c +./test/dots_xcurses.c ./test/echochar.c ./test/edit_field.c ./test/edit_field.h diff --git a/NEWS b/NEWS index 9892f2e3..64be9a91 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.2966 2017/10/07 23:37:31 tom Exp $ +-- $Id: NEWS,v 1.2975 2017/10/14 23:49:52 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,23 @@ 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. +20171014 + + minor cleanup to test/view.c: + + eliminate "-n" option by simply reading the whole file. + + implement page up/down commands. + + add check in tput for init/reset operands to ensure those use a + terminal. + + improve manual pages which discuss chtype, cchar_t types and the + attribute values which can be stored in those types. + + correct array-index when parsing "-T" command-line option in tabs + program. + + modify demo_new_pair.c to pass extended pairs to setcchar(). + + add test/dots_xcurses.c to illustrate a different approach used for + extended colors which can be contrasted with dots_curses.c. + + add a check in tic to note when a description uses non-mandatory + delays without xon_xoff. This is not an error, but some descriptions + for a terminal emulator may use the combination incorrectly. + 20171007 + modify "-T" option of clear and tput to call use_tioctl() to obtain the operating system's notion of the screensize if possible. diff --git a/VERSION b/VERSION index 7264566f..a09a8abc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5:0:9 6.0 20171007 +5:0:9 6.0 20171014 diff --git a/dist.mk b/dist.mk index 83cbf583..04f266b3 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.1186 2017/10/02 01:01:40 tom Exp $ +# $Id: dist.mk,v 1.1187 2017/10/08 23:38:02 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 = 0 -NCURSES_PATCH = 20171007 +NCURSES_PATCH = 20171014 # 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 7468ce62..caa27fd0 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.0 (patch 20171007).
+       This describes ncurses version 6.0 (patch 20171014).
 
 
 
diff --git a/doc/html/man/captoinfo.1m.html b/doc/html/man/captoinfo.1m.html
index be498ab5..968588ec 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.0 (patch 20171007).
+       This describes ncurses version 6.0 (patch 20171014).
 
 
 

AUTHOR

diff --git a/doc/html/man/clear.1.html b/doc/html/man/clear.1.html
index 85a83053..bbefd61c 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.0 (patch 20171007).
+       This describes ncurses version 6.0 (patch 20171014).
 
 
 
diff --git a/doc/html/man/curs_attr.3x.html b/doc/html/man/curs_attr.3x.html
index f359177e..56844fd7 100644
--- a/doc/html/man/curs_attr.3x.html
+++ b/doc/html/man/curs_attr.3x.html
@@ -27,7 +27,8 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_attr.3x,v 1.53 2017/03/28 23:31:39 tom Exp @
+  * @Id: curs_attr.3x,v 1.60 2017/10/14 20:01:13 tom Exp @
+  * ---------------------------------------------------------------------------
   * attr_get
   * .br
   * .br
@@ -40,6 +41,14 @@
   * ---------------------------------------------------------------------------
   * ---------------------------------------------------------------------------
   * ---------------------------------------------------------------------------
+  * ---------------------------------------------------------------------------
+  * ---------------------------------------------------------------------------
+  * ---------------------------------------------------------------------------
+  * ---------------------------------------------------------------------------
+  * ---------------------------------------------------------------------------
+  * ---------------------------------------------------------------------------
+  * ---------------------------------------------------------------------------
+  * ---------------------------------------------------------------------------
 -->
 
 
@@ -240,6 +249,126 @@
        support more than 256 color pairs.
 
 
+

HISTORY

+       X/Open Curses is largely based  on  SVr4  curses,  adding  support  for
+       "wide-characters"  (not  specific to Unicode).  Some of the X/Open dif-
+       ferences from SVr4 curses address the way video attributes can  be  ap-
+       plied  to  wide-characters.   But aside from that, attrset and attr_set
+       are similar.  SVr4 curses provided the basic features for  manipulating
+       video  attributes.  However, earlier versions of curses provided a part
+       of these features.
+
+       As seen in 2.8BSD, curses assumed 7-bit characters,  using  the  eighth
+       bit  of  a byte to represent the standout feature (often implemented as
+       bold and/or reverse video).  The BSD curses library provided  functions
+       standout  and  standend which were carried along into X/Open Curses due
+       to their pervasive use in legacy applications.
+
+       Some terminals in the 1980s  could  support  a  variety  of  video  at-
+       tributes,  although the BSD curses library could do nothing with those.
+       System V (1983) provided an improved curses library.  It defined the A_
+       symbols  for  use  by  applications to manipulate the other attributes.
+       There are few useful references for the chronology.
+
+       Goodheart's book UNIX Curses Explained (1991)  describes  SVr3  (1987),
+       commenting on several functions:
+
+       o   the  attron,  attroff, attrset functions (and most of the functions
+           found in SVr4 but not in BSD curses) were introduced by System V,
+
+       o   the alternate character set feature with A_ALTCHARSET was added  in
+           SVr2 and improved in SVr3 (by adding acs_map[]),
+
+       o   start_color  and  related color-functions were introduced by System
+           V.3.2,
+
+       o   pads, soft-keys were added in SVr3, and
+
+       Goodheart did not mention the background character or the cchar_t type.
+       Those are respectively SVr4 and X/Open features.  He did mention the A_
+       constants, but did not indicate their values.  Those were not the  same
+       in different systems, even for those marked as System V.
+
+       Different  Unix  systems  used  different  sizes  for the bit-fields in
+       chtype for characters and colors, and took into account  the  different
+       integer sizes (32-bit versus 64-bit).
+
+       This  table  showing  the number of bits for A_COLOR and A_CHARTEXT was
+       gleaned from the curses header files for various operating systems  and
+       architectures.   The inferred architecture and notes reflect the format
+       and size of the defined constants as well as clues such as  the  alter-
+       nate  character  set implementation.  A 32-bit library can be used on a
+       64-bit system, but not necessarily the reverse.
+
+              Year   System        Arch    Color   Char   Notes
+              ----------------------------------------------------------------
+              1992   Solaris 5.2   32      6       17     SVr4 curses
+              1992   HPUX 9        32      no      8      SVr2 curses
+              1992   AIX 3.2       32      no      23     SVr2 curses
+              1994   OSF/1 r3      32      no      23     SVr2 curses
+              1995   HP-UX 10.00   32      6       16     SVr3 "curses_colr"
+              1995   HP-UX 10.00   32      6       8      SVr4, X/Open curses
+              1995   Solaris 5.4   32/64   7       16     X/Open curses
+              1996   AIX 4.2       32      7       16     X/Open curses
+              1996   OSF/1 r4      32      6       16     X/Open curses
+              1997   HP-UX 11.00   32      6       8      X/Open curses
+              2000   U/Win         32/64   7/31    16     uses chtype
+
+       Notes:
+
+          Regarding HP-UX,
+
+          o   HP-UX 10.20 (1996) added support for 64-bit  PA-RISC  processors
+              in 1996.
+
+          o   HP-UX  10.30 (1997) marked "curses_colr" obsolete.  That version
+              of curses was dropped with HP-UX 11.30 in 2006.
+
+          Regarding OSF/1 (and Tru64),
+
+          o   These used 64-bit hardware.  Like ncurses, the OSF/1 curses  in-
+              terface is not customized for 32-bit and 64-bit versions.
+
+          o   Unlike other systems which evolved from AT&T code, OSF/1 provid-
+              ed a new implementation for X/Open curses.
+
+          Regarding Solaris,
+
+          o   The initial release of Solaris was in 1992.
+
+          o   The xpg4 (X/Open) curses was developed by MKS from 1990 to 1995.
+              Sun's copyright began in 1996.
+
+          o   Sun updated the X/Open curses interface after 64-bit support was
+              introduced in 1997, but did not modify the  SVr4  curses  inter-
+              face.
+
+          Regarding U/Win,
+
+          o   Development  of  the  curses  library  began in 1991, stopped in
+              2000.
+
+          o   Color support was added in 1998.
+
+          o   The library uses only chtype (no cchar_t).
+
+       Once X/Open curses was adopted in the mid-1990s, the  constraint  of  a
+       32-bit interface with many colors and wide-characters for chtype became
+       a moot point.  The cchar_t structure (whose size and  members  are  not
+       specified in X/Open Curses) could be extended as needed.
+
+       Other interfaces are rarely used now:
+
+       o   BSD  curses was improved slightly in 1993/1994 using Keith Bostic's
+           modification to make the library 8-bit clean  for  nvi.   He  moved
+           standout attribute to a structure member.
+
+           The  resulting  4.4BSD curses was replaced by ncurses over the next
+           ten years.
+
+       o   U/Win is rarely used now.
+
+
 

EXTENSIONS

        This implementation provides the A_ITALIC attribute for terminals which
        have  the  enter_italics_mode (sitm) and exit_italics_mode (ritm) capa-
@@ -305,9 +434,25 @@
               WA_BOLD         Extra bright or bold
               WA_ALTCHARSET   Alternate character set
 
-       The  XSI  curses  standard specifies that each pair of corresponding A_
-       and WA_-using functions operates on the same current-highlight informa-
-       tion.
+       XSI  curses  does not assign values to these symbols, nor does it state
+       whether or not they are related to the similarly-named A_NORMAL, etc.:
+
+       o   The XSI curses standard specifies that each pair  of  corresponding
+           A_  and  WA_-using functions operates on the same current-highlight
+           information.
+
+       o   However, in some implementations, those symbols have unrelated val-
+           ues.
+
+           For example, the Solaris xpg4 (X/Open) curses declares attr_t to be
+           an unsigned short integer (16-bits), while chtype is a unsigned in-
+           teger  (32-bits).   The WA_ symbols in this case are different from
+           the A_ symbols because they are used for a smaller  datatype  which
+           does not represent A_CHARTEXT or A_COLOR.
+
+           In this implementation (as in many others), the values happen to be
+           the same because it simplifies copying information  between  chtype
+           and cchar_t variables.
 
        The XSI standard extended conformance level adds new highlights A_HORI-
        ZONTAL, A_LEFT, A_LOW, A_RIGHT, A_TOP,  A_VERTICAL  (and  corresponding
@@ -358,6 +503,7 @@
 
 
  • VIDEO ATTRIBUTES
  • NOTES
  • +
  • HISTORY
  • EXTENSIONS
  • PORTABILITY
  • RETURN VALUE
  • diff --git a/doc/html/man/curs_inch.3x.html b/doc/html/man/curs_inch.3x.html index e360994a..6d376744 100644 --- a/doc/html/man/curs_inch.3x.html +++ b/doc/html/man/curs_inch.3x.html @@ -1,7 +1,7 @@ @@ -82,6 +82,10 @@ wmove, and return an error if the position is outside the window, or if the window pointer is null. + The winch function does not return an error if the window contains + characters larger than 8-bits (255). Only the low-order 8 bits of the + character are used by winch. +

    NOTES

            Note that all of these routines may be macros.
    @@ -90,12 +94,40 @@
     

    PORTABILITY

            These functions are described in the XSI Curses standard, Issue 4.
     
    +       Very  old systems (before standardization) provide a different function
    +       with the same name:
    +
    +       o   The winch function was part of the  original  BSD  curses  library,
    +           which   stored   a  7-bit  character  combined  with  the  standout
    +           attribute.
    +
    +           In BSD curses, winch returned only the character  (as  an  integer)
    +           with the standout attribute removed.
    +
    +       o   System  V  curses  added support for several video attributes which
    +           could be combined with characters in the window.
    +
    +           Reflecting this improvment, the function was altered to return  the
    +           character combined with all video attributes in a chtype value.
    +
    +       X/Open Curses does not specify the size and layout of attributes, color
    +       and character values in chtype; it is  implementation-dependent.   This
    +       implementation  uses 8 bits for character values.  An application using
    +       more bits, e.g., a Unicode value, should use the wide-character equiva-
    +       lents to these functions.
    +
     
     

    SEE ALSO

    -       curses(3x).
    +       curses(3x)
    +            gives an overview of the WINDOW and chtype data types.
    +
    +       curs_attr(3x)
    +            goes  into more detail, pointing out portability problems and con-
    +            straints on the use of chtype for returning window information.
     
    -       Comparable  functions  in  the  wide-character  (ncursesw)  library are
    -       described in curs_in_wch(3x).
    +       curs_in_wch(3x)
    +            describes comparable functions for the  wide-character  (ncursesw)
    +            library.
     
     
     
    diff --git a/doc/html/man/form.3x.html b/doc/html/man/form.3x.html
    index da0733f8..8a6a1fcd 100644
    --- a/doc/html/man/form.3x.html
    +++ b/doc/html/man/form.3x.html
    @@ -234,7 +234,7 @@
            curses(3x)  and  related  pages  whose names begin "form_" for detailed
            descriptions of the entry points.
     
    -       This describes ncurses version 6.0 (patch 20171007).
    +       This describes ncurses version 6.0 (patch 20171014).
     
     
     
    diff --git a/doc/html/man/infocmp.1m.html b/doc/html/man/infocmp.1m.html
    index 210097bd..8658f777 100644
    --- a/doc/html/man/infocmp.1m.html
    +++ b/doc/html/man/infocmp.1m.html
    @@ -476,7 +476,7 @@
     
            http://invisible-island.net/ncurses/tctest.html
     
    -       This describes ncurses version 6.0 (patch 20171007).
    +       This describes ncurses version 6.0 (patch 20171014).
     
     
     

    AUTHOR

    diff --git a/doc/html/man/infotocap.1m.html b/doc/html/man/infotocap.1m.html
    index f3c7db53..3006556b 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.0 (patch 20171007).
    +       This describes ncurses version 6.0 (patch 20171014).
     
     
     

    AUTHOR

    diff --git a/doc/html/man/menu.3x.html b/doc/html/man/menu.3x.html
    index 7843459d..9d1f818b 100644
    --- a/doc/html/man/menu.3x.html
    +++ b/doc/html/man/menu.3x.html
    @@ -210,7 +210,7 @@
            curses(3x) and related pages whose names  begin  "menu_"  for  detailed
            descriptions of the entry points.
     
    -       This describes ncurses version 6.0 (patch 20171007).
    +       This describes ncurses version 6.0 (patch 20171014).
     
     
     
    diff --git a/doc/html/man/ncurses.3x.html b/doc/html/man/ncurses.3x.html
    index 69069d51..17a0fead 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.0 (patch 20171007).
    +       This describes ncurses version 6.0 (patch 20171014).
     
            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 fc93f936..19ce50e1 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.0 (patch 20171007).
    +       This describes ncurses version 6.0 (patch 20171014).
     
     
     
    diff --git a/doc/html/man/panel.3x.html b/doc/html/man/panel.3x.html
    index 216698b6..ab84cd47 100644
    --- a/doc/html/man/panel.3x.html
    +++ b/doc/html/man/panel.3x.html
    @@ -194,7 +194,7 @@
     

    SEE ALSO

            curses(3x), curs_variables(3x),
     
    -       This describes ncurses version 6.0 (patch 20171007).
    +       This describes ncurses version 6.0 (patch 20171014).
     
     
     

    AUTHOR

    diff --git a/doc/html/man/tabs.1.html b/doc/html/man/tabs.1.html
    index 073235ed..86255f61 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.0 (patch 20171007).
    +       This describes ncurses version 6.0 (patch 20171014).
     
     
     
    diff --git a/doc/html/man/terminfo.5.html b/doc/html/man/terminfo.5.html
    index d0b50f37..7e52bd52 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.0 (patch 20171007).
    +       ncurses version 6.0 (patch 20171014).
     
     
     

    Terminfo Entry Syntax

    diff --git a/doc/html/man/tic.1m.html b/doc/html/man/tic.1m.html
    index cd87c084..27e64e35 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.0 (patch 20171007).
    +       This describes ncurses version 6.0 (patch 20171014).
     
     
     

    AUTHOR

    diff --git a/doc/html/man/toe.1m.html b/doc/html/man/toe.1m.html
    index 7c807035..718f40aa 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.0 (patch 20171007).
    +       This describes ncurses version 6.0 (patch 20171014).
     
     
     
    diff --git a/doc/html/man/tput.1.html b/doc/html/man/tput.1.html
    index eafd4ba3..a855831c 100644
    --- a/doc/html/man/tput.1.html
    +++ b/doc/html/man/tput.1.html
    @@ -482,7 +482,7 @@
     

    SEE ALSO

            clear(1), stty(1), tabs(1), tset(1), terminfo(5), curs_termcap(3x).
     
    -       This describes ncurses version 6.0 (patch 20171007).
    +       This describes ncurses version 6.0 (patch 20171014).
     
     
     
    diff --git a/doc/html/man/tset.1.html b/doc/html/man/tset.1.html
    index d49ef9e5..40b12eb3 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.0 (patch 20171007).
    +       This describes ncurses version 6.0 (patch 20171014).
     
     
     
    diff --git a/man/curs_attr.3x b/man/curs_attr.3x
    index 4d336083..c3113e15 100644
    --- a/man/curs_attr.3x
    +++ b/man/curs_attr.3x
    @@ -27,13 +27,18 @@
     .\" authorization.                                                           *
     .\"***************************************************************************
     .\"
    -.\" $Id: curs_attr.3x,v 1.53 2017/03/28 23:31:39 tom Exp $
    +.\" $Id: curs_attr.3x,v 1.60 2017/10/14 20:01:13 tom Exp $
     .TH curs_attr 3X ""
    +.ie \n(.g .ds `` \(lq
    +.el       .ds `` ``
    +.ie \n(.g .ds '' \(rq
    +.el       .ds '' ''
     .de bP
     .IP \(bu 4
     ..
     .na
     .hy 0
    +.\" ---------------------------------------------------------------------------
     .SH NAME
     .\" attr_get
     \fBattr_get\fR,
    @@ -67,6 +72,7 @@
     \fBwstandout\fR \- \fBcurses\fR character and window attribute control routines
     .ad
     .hy
    +.\" ---------------------------------------------------------------------------
     .SH SYNOPSIS
     \fB#include \fR
     .sp
    @@ -120,6 +126,7 @@
     \fBint standout(void);\fR
     .br
     \fBint wstandout(WINDOW *\fP\fIwin\fP\fB);\fR
    +.\" ---------------------------------------------------------------------------
     .SH DESCRIPTION
     .PP
     These routines manipulate the current attributes of the named window,
    @@ -260,6 +267,7 @@ l l .
     The return values of many of these routines are not meaningful (they are
     implemented as macro-expanded assignments and simply return their argument).
     The SVr4 manual page claims (falsely) that these routines always return \fB1\fR.
    +.\" ---------------------------------------------------------------------------
     .SH NOTES
     These functions may be macros:
     .sp
    @@ -274,6 +282,137 @@ The alternate functions such as \fBcolor_set\fP can pass a color pair
     value directly.
     However, ncurses ABI 4 and 5 simply OR this value within the alternate functions.
     You must use ncurses ABI 6 to support more than 256 color pairs.
    +.\" ---------------------------------------------------------------------------
    +.SH HISTORY
    +X/Open Curses is largely based on SVr4 curses,
    +adding support for \*(``wide-characters\*('' (not specific to Unicode).
    +Some of the X/Open differences from SVr4 curses address the way
    +video attributes can be applied to wide-characters.
    +But aside from that, \fBattrset\fP and \fBattr_set\fP are similar.
    +SVr4 curses provided the basic features for manipulating video attributes.
    +However, earlier versions of curses provided a part of these features.
    +.PP
    +As seen in 2.8BSD, curses assumed 7-bit characters,
    +using the eighth bit of a byte to represent the \fIstandout\fP
    +feature (often implemented as bold and/or reverse video).
    +The BSD curses library provided functions \fBstandout\fP and \fBstandend\fP
    +which were carried along into X/Open Curses due to their pervasive use
    +in legacy applications.
    +.PP
    +Some terminals in the 1980s could support a variety of video attributes,
    +although the BSD curses library could do nothing with those.
    +System V (1983) provided an improved curses library.
    +It defined the \fBA_\fP symbols for use by applications to manipulate the
    +other attributes.
    +There are few useful references for the chronology.
    +.PP
    +Goodheart's book
    +\fIUNIX Curses Explained\fP (1991) describes SVr3 (1987),
    +commenting on several functions:
    +.bP
    +the \fBattron\fP, \fBattroff\fP, \fBattrset\fP functions
    +(and most of the functions found in SVr4 but not in BSD curses) were
    +introduced by System V,
    +.bP
    +the alternate character set feature with \fBA_ALTCHARSET\fP was
    +added in SVr2 and improved in SVr3 (by adding \fBacs_map[]\fP),
    +.bP
    +\fBstart_color\fP and related color-functions were introduced by System V.3.2,
    +.bP
    +pads, soft-keys were added in SVr3, and
    +.PP
    +Goodheart did not mention the background character or the \fBcchar_t\fP type.
    +Those are respectively SVr4 and X/Open features.
    +He did mention the \fBA_\fP constants, but did not indicate their values.
    +Those were not the same in different systems,
    +even for those marked as System V.
    +.PP
    +Different Unix systems used different sizes for the bit-fields in \fBchtype\fP
    +for \fIcharacters\fP and \fIcolors\fP, and took into account the different
    +integer sizes (32-bit versus 64-bit).
    +.PP
    +This table showing the number of bits for \fBA_COLOR\fP
    +and \fBA_CHARTEXT\fP
    +was gleaned from the curses header files for
    +various operating systems and architectures.
    +The inferred architecture and notes reflect
    +the format and size of the defined constants
    +as well as clues such as the alternate character set implementation.
    +A 32-bit library can be used on a 64-bit system,
    +but not necessarily the reverse.
    +.RS
    +.TS
    +l l l l l l
    +_ _ _ _ _ _
    +l l l l l l .
    +\fIYear\fR	\fISystem\fR	\fIArch\fP	\fIColor\fR	\fIChar\fR	\fINotes\fR
    +1992	Solaris 5.2	32	6	17	SVr4 curses
    +1992	HPUX 9	32	no	8	SVr2 curses
    +1992	AIX 3.2	32	no	23	SVr2 curses
    +1994	OSF/1 r3	32	no	23	SVr2 curses
    +1995	HP-UX 10.00	32	6	16	SVr3 \*(``curses_colr\*('' 
    +1995	HP-UX 10.00	32	6	8	SVr4, X/Open curses
    +1995	Solaris 5.4	32/64	7	16	X/Open curses
    +1996	AIX 4.2	32	7	16	X/Open curses
    +1996	OSF/1 r4	32	6	16	X/Open curses
    +1997	HP-UX 11.00	32	6	8	X/Open curses
    +2000	U/Win	32/64	7/31	16	uses \fBchtype\fP
    +.TE
    +.RE
    +.PP
    +Notes:
    +.RS 3
    +.PP
    +Regarding HP-UX,
    +.bP
    +HP-UX 10.20 (1996) added support for 64-bit PA-RISC processors in 1996.
    +.bP
    +HP-UX 10.30 (1997) marked \*(``curses_colr\*('' obsolete.
    +That version of curses was dropped with HP-UX 11.30 in 2006.
    +.PP
    +Regarding OSF/1 (and Tru64),
    +.bP
    +These used 64-bit hardware.
    +Like ncurses, the OSF/1 curses interface is not customized for 32-bit
    +and 64-bit versions.
    +.bP
    +Unlike other systems which evolved from AT&T code,
    +OSF/1 provided a new implementation for X/Open curses.
    +.PP
    +Regarding Solaris,
    +.bP
    +The initial release of Solaris was in 1992.
    +.bP
    +The \fIxpg4\fP (X/Open) curses was developed by MKS from 1990 to 1995.
    +Sun's copyright began in 1996.
    +.bP
    +Sun updated the X/Open curses interface after 64-bit support was introduced in 1997,
    +but did not modify the SVr4 curses interface.
    +.PP
    +Regarding U/Win,
    +.bP
    +Development of the curses library began in 1991, stopped in 2000. 
    +.bP
    +Color support was added in 1998.
    +.bP
    +The library uses only \fBchtype\fP (no \fBcchar_t\fP).
    +.RE
    +.PP
    +Once X/Open curses was adopted in the mid-1990s, the constraint of
    +a 32-bit interface with many colors and wide-characters for \fBchtype\fP
    +became a moot point.  The \fBcchar_t\fP structure (whose size and
    +members are not specified in X/Open Curses) could be extended as needed.
    +.PP
    +Other interfaces are rarely used now:
    +.bP
    +BSD curses was improved slightly in 1993/1994 using Keith Bostic's
    +modification to make the library 8-bit clean for \fBnvi\fP.
    +He moved \fIstandout\fP attribute to a structure member.
    +.IP
    +The resulting 4.4BSD curses was replaced by ncurses over the next ten years.
    +.bP
    +U/Win is rarely used now.
    +.\" ---------------------------------------------------------------------------
     .SH EXTENSIONS
     .PP
     This implementation provides the \fBA_ITALIC\fP attribute for terminals
    @@ -307,6 +446,7 @@ The remaining functions which have \fIopts\fP,
     but do not manipulate color,
     e.g., \fBwattr_on\fP and \fBwattr_off\fP
     are not used by this implementation except to check that they are \fBNULL\fP.
    +.\" ---------------------------------------------------------------------------
     .SH PORTABILITY
     These functions are supported in the XSI Curses standard, Issue 4.
     The standard defined the dedicated type for highlights,
    @@ -355,9 +495,26 @@ l l .
     .TE
     .RE
     .PP
    +XSI curses does not assign values to these symbols,
    +nor does it state whether or not they are related to the
    +similarly-named A_NORMAL, etc.:
    +.bP
     The XSI curses standard specifies that each pair of corresponding \fBA_\fR
     and \fBWA_\fR-using functions operates on the same current-highlight
     information.
    +.bP
    +However, in some implementations, those symbols have unrelated values.
    +.IP
    +For example, the Solaris \fIxpg4\fP (X/Open) curses declares
    +\fBattr_t\fP to be an unsigned short integer (16-bits),
    +while \fBchtype\fP is a unsigned integer (32-bits).
    +The \fBWA_\fP symbols in this case are different from the \fBA_\fP symbols
    +because they are used for a smaller datatype which does not
    +represent \fBA_CHARTEXT\fP or \fBA_COLOR\fP.
    +.IP
    +In this implementation (as in many others), the values happen to be
    +the same because it simplifies copying information between
    +\fBchtype\fP and \fBcchar_t\fP variables.
     .PP
     The XSI standard extended conformance level adds new highlights
     \fBA_HORIZONTAL\fR, \fBA_LEFT\fR, \fBA_LOW\fR, \fBA_RIGHT\fR, \fBA_TOP\fR,
    @@ -365,6 +522,7 @@ The XSI standard extended conformance level adds new highlights
     As of August 2013,
     no known terminal provides these highlights
     (i.e., via the \fBsgr1\fP capability).
    +.\" ---------------------------------------------------------------------------
     .SH RETURN VALUE
     All routines return the integer \fBOK\fR on success, or \fBERR\fP on failure.
     .PP
    @@ -383,6 +541,7 @@ used for retrieving attribute or color-pair values is \fBNULL\fP.
     Functions with a "mv" prefix first perform a cursor movement using
     \fBwmove\fP, and return an error if the position is outside the window,
     or if the window pointer is null.
    +.\" ---------------------------------------------------------------------------
     .SH SEE ALSO
     .na
     \fBcurses\fR(3X),
    diff --git a/man/curs_inch.3x b/man/curs_inch.3x
    index 7e1e3b43..4fe29e43 100644
    --- a/man/curs_inch.3x
    +++ b/man/curs_inch.3x
    @@ -1,6 +1,6 @@
     '\" t
     .\"***************************************************************************
    -.\" Copyright (c) 1998-2006,2010 Free Software Foundation, Inc.              *
    +.\" Copyright (c) 1998-2010,2017 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            *
    @@ -27,8 +27,11 @@
     .\" authorization.                                                           *
     .\"***************************************************************************
     .\"
    -.\" $Id: curs_inch.3x,v 1.17 2010/12/04 18:36:44 tom Exp $
    +.\" $Id: curs_inch.3x,v 1.18 2017/10/14 19:14:47 tom Exp $
     .TH curs_inch 3X ""
    +.de bP
    +.IP \(bu 4
    +..
     .SH NAME
     \fBinch\fR,
     \fBwinch\fR,
    @@ -65,13 +68,44 @@ l l .
     Functions with a "mv" prefix first perform a cursor movement using
     \fBwmove\fP, and return an error if the position is outside the window,
     or if the window pointer is null.
    +.PP
    +The \fBwinch\fP function does not return an error if the window contains
    +characters larger than 8-bits (255).
    +Only the low-order 8 bits of the character are used by \fBwinch\fP.
     .SH NOTES
     Note that all of these routines may be macros.
     .SH PORTABILITY
     These functions are described in the XSI Curses standard, Issue 4.
    -.SH SEE ALSO
    -\fBcurses\fR(3X).
     .PP
    -Comparable functions in the wide-character (ncursesw) library are
    -described in
    -\fBcurs_in_wch\fR(3X).
    +Very old systems (before standardization) provide a different function
    +with the same name:
    +.bP
    +The \fBwinch\fP function was part of the original BSD curses library,
    +which stored a 7-bit character combined with the \fIstandout\fP attribute.
    +.IP
    +In BSD curses, \fBwinch\fP returned only the character (as an integer)
    +with the \fIstandout\fP attribute removed.
    +.bP
    +System V curses added support for several video attributes which
    +could be combined with characters in the window.
    +.IP
    +Reflecting this improvment, the function was altered to return the
    +character combined with all video attributes in a \fBchtype\fP value.
    +.PP
    +X/Open Curses does not specify 
    +the size and layout of attributes, color and character values in
    +\fBchtype\fP; it is implementation-dependent.
    +This implementation uses 8 bits for character values.
    +An application using more bits, e.g., a Unicode value,
    +should use the wide-character equivalents to these functions.
    +.SH SEE ALSO
    +.TP 5
    +\fBcurses\fR(3X)
    +gives an overview of the WINDOW and \fBchtype\fP data types.
    +.TP 5
    +\fBcurs_attr\fR(3X)
    +goes into more detail, pointing out portability problems and
    +constraints on the use of \fBchtype\fP for returning window information.
    +.TP 5
    +\fBcurs_in_wch\fR(3X)
    +describes comparable functions for the wide-character (ncursesw) library.
    diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog
    index cf73ff7e..65545df2 100644
    --- a/package/debian-mingw/changelog
    +++ b/package/debian-mingw/changelog
    @@ -1,8 +1,8 @@
    -ncurses6 (6.0+20171007) unstable; urgency=low
    +ncurses6 (6.0+20171014) unstable; urgency=low
     
       * latest weekly patch
     
    - -- Thomas E. Dickey   Sun, 01 Oct 2017 21:01:40 -0400
    + -- Thomas E. Dickey   Sun, 08 Oct 2017 19:38:02 -0400
     
     ncurses6 (5.9-20131005) unstable; urgency=low
     
    diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog
    index cf73ff7e..65545df2 100644
    --- a/package/debian-mingw64/changelog
    +++ b/package/debian-mingw64/changelog
    @@ -1,8 +1,8 @@
    -ncurses6 (6.0+20171007) unstable; urgency=low
    +ncurses6 (6.0+20171014) unstable; urgency=low
     
       * latest weekly patch
     
    - -- Thomas E. Dickey   Sun, 01 Oct 2017 21:01:40 -0400
    + -- Thomas E. Dickey   Sun, 08 Oct 2017 19:38:02 -0400
     
     ncurses6 (5.9-20131005) unstable; urgency=low
     
    diff --git a/package/debian/changelog b/package/debian/changelog
    index 086ea2b2..ceaef328 100644
    --- a/package/debian/changelog
    +++ b/package/debian/changelog
    @@ -1,8 +1,8 @@
    -ncurses6 (6.0+20171007) unstable; urgency=low
    +ncurses6 (6.0+20171014) unstable; urgency=low
     
       * latest weekly patch
     
    - -- Thomas E. Dickey   Sun, 01 Oct 2017 21:01:40 -0400
    + -- Thomas E. Dickey   Sun, 08 Oct 2017 19:38:02 -0400
     
     ncurses6 (5.9-20120608) unstable; urgency=low
     
    diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi
    index 7992e15d..f300c595 100644
    --- a/package/mingw-ncurses.nsi
    +++ b/package/mingw-ncurses.nsi
    @@ -1,4 +1,4 @@
    -; $Id: mingw-ncurses.nsi,v 1.234 2017/10/02 01:01:40 tom Exp $
    +; $Id: mingw-ncurses.nsi,v 1.235 2017/10/08 23:38:02 tom Exp $
     
     ; TODO add examples
     ; TODO bump ABI to 6
    @@ -10,7 +10,7 @@
     !define VERSION_MAJOR "6"
     !define VERSION_MINOR "0"
     !define VERSION_YYYY  "2017"
    -!define VERSION_MMDD  "1007"
    +!define VERSION_MMDD  "1014"
     !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD}
     
     !define MY_ABI   "5"
    diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec
    index d86b3153..3ed34375 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.0
    -Release: 20171007
    +Release: 20171014
     License: X11
     Group: Development/Libraries
     Source: ncurses-%{version}-%{release}.tgz
    diff --git a/package/ncurses.spec b/package/ncurses.spec
    index 9ec39c8e..4c1cd095 100644
    --- a/package/ncurses.spec
    +++ b/package/ncurses.spec
    @@ -1,7 +1,7 @@
     Summary: shared libraries for terminal handling
     Name: ncurses6
     Version: 6.0
    -Release: 20171007
    +Release: 20171014
     License: X11
     Group: Development/Libraries
     Source: ncurses-%{version}-%{release}.tgz
    diff --git a/progs/progs.priv.h b/progs/progs.priv.h
    index 4b1b5381..54e6215d 100644
    --- a/progs/progs.priv.h
    +++ b/progs/progs.priv.h
    @@ -30,7 +30,7 @@
      *  Author: Thomas E. Dickey                    1997-on                     *
      ****************************************************************************/
     /*
    - * $Id: progs.priv.h,v 1.45 2017/10/07 20:42:10 tom Exp $
    + * $Id: progs.priv.h,v 1.46 2017/10/09 00:30:38 tom Exp $
      *
      *	progs.priv.h
      *
    @@ -138,6 +138,8 @@ extern int optind;
     #endif
     #endif
     
    +#define VtoTrace(opt) (unsigned) ((opt > 0) ? opt : (opt == 0))
    +
     /* error-returns for tput */
     #define ErrUsage	2
     #define ErrTermType	3
    diff --git a/progs/tabs.c b/progs/tabs.c
    index 7e2d12df..01325c32 100644
    --- a/progs/tabs.c
    +++ b/progs/tabs.c
    @@ -38,7 +38,7 @@
     #include 
     #include 
     
    -MODULE_ID("$Id: tabs.c,v 1.40 2017/10/07 19:34:58 tom Exp $")
    +MODULE_ID("$Id: tabs.c,v 1.41 2017/10/12 22:42:08 tom Exp $")
     
     static void usage(void) GCC_NORETURN;
     
    @@ -458,7 +458,7 @@ main(int argc, char *argv[])
     		    if (*++option != '\0') {
     			term_name = option;
     		    } else {
    -			term_name = argv[n++];
    +			term_name = argv[n];
     			option--;
     		    }
     		    option += ((int) strlen(option)) - 1;
    diff --git a/progs/tic.c b/progs/tic.c
    index 3545c3c9..e89c477b 100644
    --- a/progs/tic.c
    +++ b/progs/tic.c
    @@ -48,7 +48,7 @@
     #include 
     #include 
     
    -MODULE_ID("$Id: tic.c,v 1.244 2017/09/20 00:39:37 tom Exp $")
    +MODULE_ID("$Id: tic.c,v 1.247 2017/10/09 15:16:15 tom Exp $")
     
     #define STDIN_NAME ""
     
    @@ -674,8 +674,6 @@ add_digit(int *target, int source)
         *target = (*target * 10) + (source - '0');
     }
     
    -#define VtoTrace(opt) (unsigned) ((opt > 0) ? opt : (opt == 0))
    -
     int
     main(int argc, char *argv[])
     {
    @@ -1925,7 +1923,7 @@ skip_DECSCNM(const char *value, int *flag)
     }
     
     static void
    -check_delays(const char *name, const char *value)
    +check_delays(TERMTYPE2 *tp, const char *name, const char *value)
     {
         const char *p, *q;
         const char *first = 0;
    @@ -1975,6 +1973,14 @@ check_delays(const char *name, const char *value)
     		    _nc_warning("function-key %s has delay", name);
     		} else if (proportional && !line_capability(name)) {
     		    _nc_warning("non-line capability using proportional delay: %s", name);
    +		} else if (!xon_xoff &&
    +			   !mandatory &&
    +			   strchr(_nc_first_name(tp->term_names), '+') == 0) {
    +		    _nc_warning("%s in %s is used since no xon/xoff",
    +				(proportional
    +				 ? "proportional delay"
    +				 : "delay"),
    +				name);
     		}
     	    } else {
     		p = q - 1;	/* restart scan */
    @@ -2703,7 +2709,7 @@ check_termtype(TERMTYPE2 *tp, bool literal)
     		parametrized[j] > 0) {
     		check_params(tp, name, a, (j >= STRCOUNT));
     	    }
    -	    check_delays(ExtStrname(tp, (int) j, strnames), a);
    +	    check_delays(tp, ExtStrname(tp, (int) j, strnames), a);
     	    if (capdump) {
     		check_infotocap(tp, (int) j, a);
     	    }
    diff --git a/progs/tput.c b/progs/tput.c
    index 76370cbc..fd051eb4 100644
    --- a/progs/tput.c
    +++ b/progs/tput.c
    @@ -50,7 +50,7 @@
     #include 
     #include 
     
    -MODULE_ID("$Id: tput.c,v 1.77 2017/10/07 23:51:01 tom Exp $")
    +MODULE_ID("$Id: tput.c,v 1.78 2017/10/14 20:46:43 tom Exp $")
     
     #define PUTS(s)		fputs(s, stdout)
     
    @@ -316,7 +316,10 @@ main(int argc, char **argv)
         }
     
         is_alias = (is_clear || is_reset || is_init);
    -    need_tty = (is_reset || is_init);
    +    need_tty = ((is_reset || is_init) ||
    +		(optind < argc &&
    +		 (!strcmp(argv[optind], "reset") ||
    +		  !strcmp(argv[optind], "init"))));
     
         /*
          * Modify the argument list to omit the options we processed.
    diff --git a/test/demo_new_pair.c b/test/demo_new_pair.c
    index a0beb85c..4067c881 100644
    --- a/test/demo_new_pair.c
    +++ b/test/demo_new_pair.c
    @@ -26,7 +26,7 @@
      * authorization.                                                           *
      ****************************************************************************/
     /*
    - * $Id: demo_new_pair.c,v 1.17 2017/09/28 23:17:56 tom Exp $
    + * $Id: demo_new_pair.c,v 1.18 2017/10/11 22:16:14 tom Exp $
      *
      * Demonstrate the alloc_pair() function.
      */
    @@ -323,7 +323,9 @@ main(int argc, char *argv[])
     	    break;
     	wch[0] = use_wide ? 0xff03 : '#';
     	wch[1] = 0;
    -	setcchar(&temp, wch, my_attrs, (short) my_pair, NULL);
    +	setcchar(&temp, wch, my_attrs,
    +		 (short) my_pair,
    +		 (use_init ? NULL : (void *) &my_pair));
     	/*
     	 * At the end of a page, move the cursor to the home position.
     	 */
    diff --git a/test/dots.c b/test/dots.c
    index f9d2ef69..a03148bd 100644
    --- a/test/dots.c
    +++ b/test/dots.c
    @@ -29,7 +29,7 @@
     /*
      * Author: Thomas E. Dickey  1999
      *
    - * $Id: dots.c,v 1.26 2017/09/30 17:55:22 tom Exp $
    + * $Id: dots.c,v 1.28 2017/10/11 08:15:27 tom Exp $
      *
      * A simple demo of the terminfo interface.
      */
    @@ -40,8 +40,6 @@
     
     #include 
     
    -#define valid(s) ((s != 0) && s != (char *)-1)
    -
     static bool interrupted = FALSE;
     static long total_chars = 0;
     static time_t started;
    @@ -64,7 +62,7 @@ TPUTS_PROTO(outc, c)
     static bool
     outs(const char *s)
     {
    -    if (valid(s)) {
    +    if (VALID_STRING(s)) {
     	tputs(s, 1, outc);
     	return TRUE;
         }
    @@ -80,7 +78,7 @@ cleanup(void)
         outs(clear_screen);
         outs(cursor_normal);
     
    -    printf("\n\n%ld total chars, rate %.2f/sec\n",
    +    printf("\n\n%ld total cells, rate %.2f/sec\n",
     	   total_chars,
     	   ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
     }
    @@ -113,9 +111,9 @@ main(int argc GCC_UNUSED,
         outs(cursor_invisible);
         my_colors = max_colors;
         if (my_colors > 1) {
    -	if (!valid(set_a_foreground)
    -	    || !valid(set_a_background)
    -	    || (!valid(orig_colors) && !valid(orig_pair)))
    +	if (!VALID_STRING(set_a_foreground)
    +	    || !VALID_STRING(set_a_background)
    +	    || (!VALID_STRING(orig_colors) && !VALID_STRING(orig_pair)))
     	    my_colors = -1;
         }
     
    @@ -137,8 +135,8 @@ main(int argc GCC_UNUSED,
     		tputs(tparm2(set_a_background, z), 1, outc);
     		napms(1);
     	    }
    -	} else if (valid(exit_attribute_mode)
    -		   && valid(enter_reverse_mode)) {
    +	} else if (VALID_STRING(exit_attribute_mode)
    +		   && VALID_STRING(enter_reverse_mode)) {
     	    if (ranf() <= 0.01) {
     		outs((ranf() > 0.6)
     		     ? enter_reverse_mode
    diff --git a/test/dots_curses.c b/test/dots_curses.c
    index d27f2e23..477c4a14 100644
    --- a/test/dots_curses.c
    +++ b/test/dots_curses.c
    @@ -29,7 +29,7 @@
     /*
      * Author: Thomas E. Dickey
      *
    - * $Id: dots_curses.c,v 1.5 2017/09/30 15:41:17 tom Exp $
    + * $Id: dots_curses.c,v 1.7 2017/10/11 08:16:33 tom Exp $
      *
      * A simple demo of the curses interface used for comparison with termcap.
      */
    @@ -41,8 +41,6 @@
     
     #include 
     
    -#define valid(s) ((s != 0) && s != (char *)-1)
    -
     static bool interrupted = FALSE;
     static long total_chars = 0;
     static time_t started;
    @@ -52,7 +50,7 @@ cleanup(void)
     {
         endwin();
     
    -    printf("\n\n%ld total chars, rate %.2f/sec\n",
    +    printf("\n\n%ld total cells, rate %.2f/sec\n",
     	   total_chars,
     	   ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
     }
    diff --git a/test/dots_mvcur.c b/test/dots_mvcur.c
    index ed9de8c2..d6ce9329 100644
    --- a/test/dots_mvcur.c
    +++ b/test/dots_mvcur.c
    @@ -29,7 +29,7 @@
     /*
      * Author: Thomas E. Dickey - 2007
      *
    - * $Id: dots_mvcur.c,v 1.13 2017/09/30 21:34:15 tom Exp $
    + * $Id: dots_mvcur.c,v 1.15 2017/10/11 08:15:46 tom Exp $
      *
      * A simple demo of the terminfo interface, and mvcur.
      */
    @@ -40,8 +40,6 @@
     
     #include 
     
    -#define valid(s) ((s != 0) && s != (char *)-1)
    -
     static bool interrupted = FALSE;
     static long total_chars = 0;
     static time_t started;
    @@ -65,7 +63,7 @@ TPUTS_PROTO(outc, c)
     static bool
     outs(const char *s)
     {
    -    if (valid(s)) {
    +    if (VALID_STRING(s)) {
     	tputs(s, 1, outc);
     	return TRUE;
         }
    @@ -81,7 +79,7 @@ cleanup(void)
         outs(clear_screen);
         outs(cursor_normal);
     
    -    printf("\n\n%ld total chars, rate %.2f/sec\n",
    +    printf("\n\n%ld total cells, rate %.2f/sec\n",
     	   total_chars,
     	   ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
     }
    @@ -125,9 +123,9 @@ main(int argc GCC_UNUSED,
         outs(cursor_invisible);
         my_colors = max_colors;
         if (my_colors > 1) {
    -	if (!valid(set_a_foreground)
    -	    || !valid(set_a_background)
    -	    || (!valid(orig_colors) && !valid(orig_pair)))
    +	if (!VALID_STRING(set_a_foreground)
    +	    || !VALID_STRING(set_a_background)
    +	    || (!VALID_STRING(orig_colors) && !VALID_STRING(orig_pair)))
     	    my_colors = -1;
         }
     
    @@ -153,8 +151,8 @@ main(int argc GCC_UNUSED,
     		tputs(tparm2(set_a_background, z), 1, outc);
     		napms(1);
     	    }
    -	} else if (valid(exit_attribute_mode)
    -		   && valid(enter_reverse_mode)) {
    +	} else if (VALID_STRING(exit_attribute_mode)
    +		   && VALID_STRING(enter_reverse_mode)) {
     	    if (ranf() <= 0.01) {
     		outs((ranf() > 0.6)
     		     ? enter_reverse_mode
    diff --git a/test/dots_termcap.c b/test/dots_termcap.c
    index cd88b3eb..c3eef5cf 100644
    --- a/test/dots_termcap.c
    +++ b/test/dots_termcap.c
    @@ -29,7 +29,7 @@
     /*
      * Author: Thomas E. Dickey
      *
    - * $Id: dots_termcap.c,v 1.10 2017/09/30 17:55:22 tom Exp $
    + * $Id: dots_termcap.c,v 1.12 2017/10/11 08:15:07 tom Exp $
      *
      * A simple demo of the termcap interface.
      */
    @@ -44,8 +44,6 @@
     
     #include 
     
    -#define valid(s) ((s != 0) && s != (char *)-1)
    -
     static bool interrupted = FALSE;
     static long total_chars = 0;
     static time_t started;
    @@ -116,7 +114,7 @@ TPUTS_PROTO(outc, c)
     static bool
     outs(char *s)
     {
    -    if (valid(s)) {
    +    if (VALID_STRING(s)) {
     	tputs(s, 1, outc);
     	return TRUE;
         }
    @@ -132,7 +130,7 @@ cleanup(void)
         outs(t_cl);
         outs(t_ve);
     
    -    printf("\n\n%ld total chars, rate %.2f/sec\n",
    +    printf("\n\n%ld total cells, rate %.2f/sec\n",
     	   total_chars,
     	   ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
     }
    @@ -203,9 +201,9 @@ main(int argc GCC_UNUSED,
         outs(t_cl);
         outs(t_vi);
         if (num_colors > 1) {
    -	if (!valid(t_AF)
    -	    || !valid(t_AB)
    -	    || (!valid(t_oc) && !valid(t_op)))
    +	if (!VALID_STRING(t_AF)
    +	    || !VALID_STRING(t_AB)
    +	    || (!VALID_STRING(t_oc) && !VALID_STRING(t_op)))
     	    num_colors = -1;
         }
     
    @@ -227,8 +225,8 @@ main(int argc GCC_UNUSED,
     		tputs(tgoto(t_AB, 0, z), 1, outc);
     		my_napms(1);
     	    }
    -	} else if (valid(t_me)
    -		   && valid(t_mr)) {
    +	} else if (VALID_STRING(t_me)
    +		   && VALID_STRING(t_mr)) {
     	    if (ranf() <= 0.01) {
     		outs((ranf() > 0.6)
     		     ? t_mr
    diff --git a/test/dots_xcurses.c b/test/dots_xcurses.c
    new file mode 100644
    index 00000000..abf0a00a
    --- /dev/null
    +++ b/test/dots_xcurses.c
    @@ -0,0 +1,237 @@
    +/****************************************************************************
    + * Copyright (c) 2017 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.                                                           *
    + ****************************************************************************/
    +
    +/*
    + * Author: Thomas E. Dickey
    + *
    + * $Id: dots_xcurses.c,v 1.8 2017/10/12 00:20:41 tom Exp $
    + *
    + * A simple demo of the wide-curses interface used for comparison with termcap.
    + */
    +#include 
    +
    +#if !defined(__MINGW32__)
    +#include 
    +#endif
    +
    +#include 
    +
    +#if USE_WIDEC_SUPPORT
    +
    +#if HAVE_ALLOC_PAIR
    +#define NewPair(n) x_option ? ((void *)&(n)) : NULL
    +#else
    +#define NewPair(n) NULL
    +#endif
    +
    +#define InitPair(p,fg,bg) init_pair((short) (p), (short) (fg), (short) (bg))
    +
    +static bool interrupted = FALSE;
    +static long total_chars = 0;
    +static time_t started;
    +
    +#ifdef NCURSES_VERSION
    +static bool d_option = FALSE;
    +static bool x_option = FALSE;
    +#endif
    +
    +static void
    +cleanup(void)
    +{
    +    endwin();
    +
    +    printf("\n\n%ld total cells, rate %.2f/sec\n",
    +	   total_chars,
    +	   ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
    +}
    +
    +static void
    +onsig(int n GCC_UNUSED)
    +{
    +    interrupted = TRUE;
    +}
    +
    +static double
    +ranf(void)
    +{
    +    long r = (rand() & 077777);
    +    return ((double) r / 32768.);
    +}
    +
    +static int
    +mypair(int fg, int bg)
    +{
    +    int result;
    +#if HAVE_ALLOC_PAIR
    +    if (x_option) {
    +	result = alloc_pair(fg, bg);
    +    } else
    +#endif
    +    {
    +	int pair = (fg * COLORS) + bg;
    +	result = (pair >= COLOR_PAIRS) ? -1 : pair;
    +    }
    +    return result;
    +}
    +
    +static void
    +set_colors(int fg, int bg)
    +{
    +    int pair = mypair(fg, bg);
    +    if (pair > 0) {
    +	color_set((short) pair, NewPair(pair));
    +    }
    +}
    +
    +#if defined(NCURSES_VERSION)
    +static void
    +usage(void)
    +{
    +    static const char *msg[] =
    +    {
    +	"Usage: firework [options]"
    +	,""
    +	,"Options:"
    +#if HAVE_USE_DEFAULT_COLORS
    +	," -d       invoke use_default_colors()"
    +#endif
    +#if HAVE_ALLOC_PAIR
    +	," -x       use alloc_pair() rather than init_pair()"
    +#endif
    +    };
    +    size_t n;
    +
    +    for (n = 0; n < SIZEOF(msg); n++)
    +	fprintf(stderr, "%s\n", msg[n]);
    +
    +    ExitProgram(EXIT_FAILURE);
    +}
    +#endif
    +
    +int
    +main(int argc GCC_UNUSED,
    +     char *argv[]GCC_UNUSED)
    +{
    +    int margin = 2;
    +    int x, y, z, p;
    +    int fg, bg, ch;
    +    wchar_t wch[2];
    +    int pair;
    +    double r;
    +    double c;
    +
    +#if defined(NCURSES_VERSION)
    +    while ((ch = getopt(argc, argv, "dx")) != -1) {
    +	switch (ch) {
    +	case 'd':
    +	    d_option = TRUE;
    +	    break;
    +#if HAVE_ALLOC_PAIR
    +	case 'x':
    +	    x_option = TRUE;
    +	    break;
    +#endif
    +	default:
    +	    usage();
    +	    break;
    +	}
    +    }
    +#endif
    +
    +    srand((unsigned) time(0));
    +
    +    InitAndCatch(initscr(), onsig);
    +    if (has_colors()) {
    +	start_color();
    +#if HAVE_USE_DEFAULT_COLORS
    +	if (d_option)
    +	    use_default_colors();
    +#endif
    +	if (x_option) {
    +	    ;			/* nothing */
    +	} else {
    +	    for (fg = 0; fg < COLORS; fg++) {
    +		for (bg = 0; bg < COLORS; bg++) {
    +		    pair = mypair(fg, bg);
    +		    if (pair > 0) {
    +			InitPair(pair, fg, bg);
    +		    }
    +		}
    +	    }
    +	}
    +    }
    +
    +    r = (double) (LINES - (2 * margin));
    +    c = (double) (COLS - (2 * margin));
    +    started = time((time_t *) 0);
    +
    +    fg = COLOR_WHITE;
    +    bg = COLOR_BLACK;
    +    pair = 0;
    +    wch[1] = 0;
    +    while (!interrupted) {
    +	x = (int) (c * ranf()) + margin;
    +	y = (int) (r * ranf()) + margin;
    +	p = (ranf() > 0.9) ? '*' : ' ';
    +
    +	move(y, x);
    +	if (has_colors()) {
    +	    z = (int) (ranf() * COLORS);
    +	    if (ranf() > 0.01) {
    +		set_colors(fg = z, bg);
    +	    } else {
    +		set_colors(fg, bg = z);
    +		napms(1);
    +	    }
    +	} else {
    +	    if (ranf() <= 0.01) {
    +		if (ranf() > 0.6) {
    +		    attr_on(WA_REVERSE, NULL);
    +		} else {
    +		    attr_off(WA_REVERSE, NULL);
    +		}
    +		napms(1);
    +	    }
    +	}
    +	wch[0] = p;
    +	addnwstr(wch, 1);
    +	refresh();
    +	++total_chars;
    +    }
    +    cleanup();
    +    ExitProgram(EXIT_SUCCESS);
    +}
    +
    +#else
    +int
    +main(void)
    +{
    +    printf("This program requires the wide-ncurses library\n");
    +    ExitProgram(EXIT_FAILURE);
    +}
    +#endif
    diff --git a/test/echochar.c b/test/echochar.c
    index 1a3fd7d3..be8e68fc 100644
    --- a/test/echochar.c
    +++ b/test/echochar.c
    @@ -26,7 +26,7 @@
      * authorization.                                                           *
      ****************************************************************************/
     /*
    - * $Id: echochar.c,v 1.15 2017/09/30 15:42:10 tom Exp $
    + * $Id: echochar.c,v 1.17 2017/10/11 08:16:12 tom Exp $
      *
      * Demonstrate the echochar function (compare to dots.c).
      * Thomas Dickey - 2006/11/4
    @@ -36,8 +36,6 @@
     
     #include 
     
    -#define valid(s) ((s != 0) && s != (char *)-1)
    -
     static bool interrupted = FALSE;
     static long total_chars = 0;
     static time_t started;
    @@ -47,7 +45,7 @@ cleanup(void)
     {
         exit_curses();
     
    -    printf("\n\n%ld total chars, rate %.2f/sec\n",
    +    printf("\n\n%ld total cells, rate %.2f/sec\n",
     	   total_chars,
     	   ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
     }
    diff --git a/test/modules b/test/modules
    index ec490cec..938acf06 100644
    --- a/test/modules
    +++ b/test/modules
    @@ -1,4 +1,4 @@
    -# $Id: modules,v 1.64 2017/06/24 18:26:44 tom Exp $
    +# $Id: modules,v 1.65 2017/10/11 08:08:41 tom Exp $
     ##############################################################################
     # Copyright (c) 1998-2016,2017 Free Software Foundation, Inc.                #
     #                                                                            #
    @@ -53,6 +53,7 @@ dots		progs		$(srcdir)	$(HEADER_DEPS)
     dots_curses	progs		$(srcdir)	$(HEADER_DEPS)
     dots_mvcur	progs		$(srcdir)	$(HEADER_DEPS)
     dots_termcap	progs		$(srcdir)	$(HEADER_DEPS)
    +dots_xcurses	progs		$(srcdir)	$(HEADER_DEPS)
     echochar	progs		$(srcdir)	$(HEADER_DEPS)
     edit_field	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/edit_field.h	$(srcdir)/popup_msg.h
     extended_color	progs		$(srcdir)	$(HEADER_DEPS)
    diff --git a/test/programs b/test/programs
    index 6a3a710f..76b7c3b3 100644
    --- a/test/programs
    +++ b/test/programs
    @@ -1,4 +1,4 @@
    -# $Id: programs,v 1.39 2017/07/01 20:14:35 tom Exp $
    +# $Id: programs,v 1.40 2017/10/11 08:08:41 tom Exp $
     ##############################################################################
     # Copyright (c) 2006-2016,2017 Free Software Foundation, Inc.                #
     #                                                                            #
    @@ -51,6 +51,7 @@ dots		$(LDFLAGS_TINFO)	$(LOCAL_LIBS)	dots
     dots_curses	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	dots_curses
     dots_mvcur	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	dots_mvcur
     dots_termcap	$(LDFLAGS_TINFO)	$(LOCAL_LIBS)	dots_termcap
    +dots_xcurses	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	dots_xcurses
     echochar	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	echochar
     extended_color	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	extended_color
     filter		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	filter
    diff --git a/test/test.priv.h b/test/test.priv.h
    index a7cc109c..c2b4bd46 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.158 2017/09/30 17:58:37 tom Exp $ */
    +/* $Id: test.priv.h,v 1.160 2017/10/12 01:00:59 tom Exp $ */
     
     #ifndef __TEST_PRIV_H
     #define __TEST_PRIV_H 1
    @@ -571,38 +571,46 @@ extern int optind;
     #undef	WACS_NEQUAL
     #undef	WACS_STERLING
     
    -#define	WACS_RARROW     &(CURSES_WACS_ARRAY['+'])
    -#define	WACS_LARROW     &(CURSES_WACS_ARRAY[','])
    -#define	WACS_UARROW     &(CURSES_WACS_ARRAY['-'])
    -#define	WACS_DARROW     &(CURSES_WACS_ARRAY['.'])
    -#define	WACS_BLOCK      &(CURSES_WACS_ARRAY['0'])
    -#define	WACS_DIAMOND    &(CURSES_WACS_ARRAY['`'])
    -#define	WACS_CKBOARD    &(CURSES_WACS_ARRAY['a'])
    -#define	WACS_DEGREE     &(CURSES_WACS_ARRAY['f'])
    -#define	WACS_PLMINUS    &(CURSES_WACS_ARRAY['g'])
    -#define	WACS_BOARD      &(CURSES_WACS_ARRAY['h'])
    -#define	WACS_LANTERN    &(CURSES_WACS_ARRAY['i'])
    -#define	WACS_LRCORNER   &(CURSES_WACS_ARRAY['j'])
    -#define	WACS_URCORNER   &(CURSES_WACS_ARRAY['k'])
    -#define	WACS_ULCORNER   &(CURSES_WACS_ARRAY['l'])
    -#define	WACS_LLCORNER   &(CURSES_WACS_ARRAY['m'])
    -#define	WACS_PLUS       &(CURSES_WACS_ARRAY['n'])
    -#define	WACS_HLINE      &(CURSES_WACS_ARRAY['q'])
    -#define	WACS_S1         &(CURSES_WACS_ARRAY['o'])
    -#define	WACS_S9         &(CURSES_WACS_ARRAY['s'])
    -#define	WACS_LTEE       &(CURSES_WACS_ARRAY['t'])
    -#define	WACS_RTEE       &(CURSES_WACS_ARRAY['u'])
    -#define	WACS_BTEE       &(CURSES_WACS_ARRAY['v'])
    -#define	WACS_TTEE       &(CURSES_WACS_ARRAY['w'])
    -#define	WACS_VLINE      &(CURSES_WACS_ARRAY['x'])
    -#define	WACS_BULLET     &(CURSES_WACS_ARRAY['~'])
    -#define	WACS_S3		&(CURSES_WACS_ARRAY['p'])
    -#define	WACS_S7		&(CURSES_WACS_ARRAY['r'])
    -#define	WACS_LEQUAL	&(CURSES_WACS_ARRAY['y'])
    -#define	WACS_GEQUAL	&(CURSES_WACS_ARRAY['z'])
    -#define	WACS_PI		&(CURSES_WACS_ARRAY['{'])
    -#define	WACS_NEQUAL	&(CURSES_WACS_ARRAY['|'])
    -#define	WACS_STERLING	&(CURSES_WACS_ARRAY['}'])
    +#define WACS_RARROW     &(CURSES_WACS_ARRAY['+'])
    +#define WACS_LARROW     &(CURSES_WACS_ARRAY[','])
    +#define WACS_UARROW     &(CURSES_WACS_ARRAY['-'])
    +#define WACS_DARROW     &(CURSES_WACS_ARRAY['.'])
    +#define WACS_BLOCK      &(CURSES_WACS_ARRAY['0'])
    +#define WACS_DIAMOND    &(CURSES_WACS_ARRAY['`'])
    +#define WACS_CKBOARD    &(CURSES_WACS_ARRAY['a'])
    +#define WACS_DEGREE     &(CURSES_WACS_ARRAY['f'])
    +#define WACS_PLMINUS    &(CURSES_WACS_ARRAY['g'])
    +#define WACS_BOARD      &(CURSES_WACS_ARRAY['h'])
    +#define WACS_LANTERN    &(CURSES_WACS_ARRAY['i'])
    +#define WACS_LRCORNER   &(CURSES_WACS_ARRAY['j'])
    +#define WACS_URCORNER   &(CURSES_WACS_ARRAY['k'])
    +#define WACS_ULCORNER   &(CURSES_WACS_ARRAY['l'])
    +#define WACS_LLCORNER   &(CURSES_WACS_ARRAY['m'])
    +#define WACS_PLUS       &(CURSES_WACS_ARRAY['n'])
    +#define WACS_HLINE      &(CURSES_WACS_ARRAY['q'])
    +#define WACS_S1         &(CURSES_WACS_ARRAY['o'])
    +#define WACS_S9         &(CURSES_WACS_ARRAY['s'])
    +#define WACS_LTEE       &(CURSES_WACS_ARRAY['t'])
    +#define WACS_RTEE       &(CURSES_WACS_ARRAY['u'])
    +#define WACS_BTEE       &(CURSES_WACS_ARRAY['v'])
    +#define WACS_TTEE       &(CURSES_WACS_ARRAY['w'])
    +#define WACS_VLINE      &(CURSES_WACS_ARRAY['x'])
    +#define WACS_BULLET     &(CURSES_WACS_ARRAY['~'])
    +#define WACS_S3         &(CURSES_WACS_ARRAY['p'])
    +#define WACS_S7         &(CURSES_WACS_ARRAY['r'])
    +#define WACS_LEQUAL     &(CURSES_WACS_ARRAY['y'])
    +#define WACS_GEQUAL     &(CURSES_WACS_ARRAY['z'])
    +#define WACS_PI         &(CURSES_WACS_ARRAY['{'])
    +#define WACS_NEQUAL     &(CURSES_WACS_ARRAY['|'])
    +#define WACS_STERLING   &(CURSES_WACS_ARRAY['}'])
    +#endif
    +
    +#ifndef WA_NORMAL
    +#define WA_NORMAL       A_NORMAL
    +#define WA_BOLD         A_BOLD
    +#define WA_REVERSE      A_REVERSE
    +#define WA_UNDERLINE    A_UNDERLINE
    +#define WA_BLINK        A_BLINK
     #endif
     
     #ifndef OK
    @@ -691,7 +699,7 @@ extern char *strnames[], *strcodes[], *strfnames[];
     #define DECL_CURSES_DATA_TTYTYPE 0
     #endif
     
    -#if !HAVE_CURSES_DATA_TTYTYPE || DECL_CURSES_DATA_TTYTYPE
    +#if !defined(ttytype) && (!HAVE_CURSES_DATA_TTYTYPE || DECL_CURSES_DATA_TTYTYPE)
     #define ttytype termname()
     #endif
     
    diff --git a/test/test_termattrs.c b/test/test_termattrs.c
    index 5831f987..398bbcd8 100644
    --- a/test/test_termattrs.c
    +++ b/test/test_termattrs.c
    @@ -26,7 +26,7 @@
      * authorization.                                                           *
      ****************************************************************************/
     /*
    - * $Id: test_termattrs.c,v 1.1 2017/06/24 18:26:15 tom Exp $
    + * $Id: test_termattrs.c,v 1.2 2017/10/11 08:16:02 tom Exp $
      *
      * Demonstrate the termattrs and term_attrs functions.
      */
    @@ -36,8 +36,6 @@
     
     #if HAVE_SETUPTERM
     
    -#define valid(s) ((s != 0) && s != (char *)-1)
    -
     static FILE *my_fp;
     
     static void
    diff --git a/test/test_vid_puts.c b/test/test_vid_puts.c
    index 81812322..463e5957 100644
    --- a/test/test_vid_puts.c
    +++ b/test/test_vid_puts.c
    @@ -26,7 +26,7 @@
      * authorization.                                                           *
      ****************************************************************************/
     /*
    - * $Id: test_vid_puts.c,v 1.9 2017/06/24 17:48:04 tom Exp $
    + * $Id: test_vid_puts.c,v 1.10 2017/10/11 08:16:24 tom Exp $
      *
      * Demonstrate the vid_puts and vid_attr functions.
      * Thomas Dickey - 2013/01/12
    @@ -37,8 +37,6 @@
     
     #if USE_WIDEC_SUPPORT && HAVE_SETUPTERM && HAVE_VID_PUTS
     
    -#define valid(s) ((s != 0) && s != (char *)-1)
    -
     static FILE *my_fp;
     static bool p_opt = FALSE;
     
    @@ -54,7 +52,7 @@ TPUTS_PROTO(outc, c)
     static bool
     outs(const char *s)
     {
    -    if (valid(s)) {
    +    if (VALID_STRING(s)) {
     	tputs(s, 1, outc);
     	return TRUE;
         }
    diff --git a/test/test_vidputs.c b/test/test_vidputs.c
    index 0b16f2cd..3cf00476 100644
    --- a/test/test_vidputs.c
    +++ b/test/test_vidputs.c
    @@ -26,7 +26,7 @@
      * authorization.                                                           *
      ****************************************************************************/
     /*
    - * $Id: test_vidputs.c,v 1.8 2017/06/24 17:48:17 tom Exp $
    + * $Id: test_vidputs.c,v 1.9 2017/10/11 08:17:07 tom Exp $
      *
      * Demonstrate the vidputs and vidattr functions.
      * Thomas Dickey - 2013/01/12
    @@ -37,8 +37,6 @@
     
     #if HAVE_SETUPTERM && HAVE_VIDPUTS
     
    -#define valid(s) ((s != 0) && s != (char *)-1)
    -
     static FILE *my_fp;
     static bool p_opt = FALSE;
     
    @@ -54,7 +52,7 @@ TPUTS_PROTO(outc, c)
     static bool
     outs(const char *s)
     {
    -    if (valid(s)) {
    +    if (VALID_STRING(s)) {
     	tputs(s, 1, outc);
     	return TRUE;
         }
    diff --git a/test/view.c b/test/view.c
    index e24628e2..00062e8e 100644
    --- a/test/view.c
    +++ b/test/view.c
    @@ -50,17 +50,20 @@
      * scroll operation worked, and the refresh() code only had to do a
      * partial repaint.
      *
    - * $Id: view.c,v 1.104 2017/09/30 17:50:38 tom Exp $
    + * $Id: view.c,v 1.111 2017/10/15 00:56:58 tom Exp $
      */
     
     #include 
     #include 
     #include 
     
    +#include 
     #include 
     
     #undef CTRL			/* conflict on AIX 5.2 with  */
     
    +static void finish(int sig) GCC_NORETURN;
    +
     #if HAVE_TERMIOS_H
     # include 
     #else
    @@ -86,9 +89,6 @@
     #undef CTRL
     #define CTRL(x)	((x) & 0x1f)
     
    -static void finish(int sig) GCC_NORETURN;
    -static void show_all(const char *tag);
    -
     #if defined(SIGWINCH) && defined(TIOCGWINSZ) && HAVE_RESIZE_TERM
     #define CAN_RESIZE 1
     #else
    @@ -96,7 +96,6 @@ static void show_all(const char *tag);
     #endif
     
     #if CAN_RESIZE
    -static void adjust(int sig);
     static int interrupted;
     static bool waiting = FALSE;
     #endif
    @@ -111,6 +110,13 @@ static int num_lines;
     
     static void usage(void) GCC_NORETURN;
     
    +static void
    +failed(const char *msg)
    +{
    +    fprintf(stderr, "%s\n", msg);
    +    ExitProgram(EXIT_FAILURE);
    +}
    +
     static void
     usage(void)
     {
    @@ -121,7 +127,6 @@ usage(void)
     	,"Options:"
     	," -c       use color if terminal supports it"
     	," -i       ignore INT, QUIT, TERM signals"
    -	," -n NUM   specify maximum number of lines (default 1000)"
     #if defined(KEY_RESIZE)
     	," -r       use old-style sigwinch handler rather than KEY_RESIZE"
     #endif
    @@ -225,6 +230,233 @@ ch_dup(char *src)
         return dst;
     }
     
    +static void
    +finish(int sig)
    +{
    +    endwin();
    +#if NO_LEAKS
    +    if (vec_lines != 0) {
    +	int n;
    +	for (n = 0; n < num_lines; ++n) {
    +	    free(vec_lines[n]);
    +	}
    +	free(vec_lines);
    +    }
    +#endif
    +    ExitProgram(sig != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
    +}
    +
    +static void
    +show_all(const char *tag)
    +{
    +    int i;
    +    char temp[BUFSIZ];
    +    NCURSES_CH_T *s;
    +    time_t this_time;
    +
    +#if CAN_RESIZE
    +    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
    +		"%.20s (%3dx%3d) col %d ", tag, LINES, COLS, shift);
    +    i = (int) strlen(temp);
    +    if ((i + 7) < (int) sizeof(temp)) {
    +	_nc_SPRINTF(temp + i, _nc_SLIMIT(sizeof(temp) - (size_t) i)
    +		    "view %.*s",
    +		    (int) (sizeof(temp) - 7 - (size_t) i),
    +		    fname);
    +    }
    +#else
    +    (void) tag;
    +    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
    +		"view %.*s", (int) sizeof(temp) - 7, fname);
    +#endif
    +    move(0, 0);
    +    printw("%.*s", COLS, temp);
    +    clrtoeol();
    +    this_time = time((time_t *) 0);
    +    _nc_STRNCPY(temp, ctime(&this_time), (size_t) 30);
    +    if ((i = (int) strlen(temp)) != 0) {
    +	temp[--i] = 0;
    +	if (move(0, COLS - i - 2) != ERR)
    +	    printw("  %s", temp);
    +    }
    +
    +    scrollok(stdscr, FALSE);	/* prevent screen from moving */
    +    for (i = 1; i < LINES; i++) {
    +	int len;
    +	int actual = (int) (lptr + i - vec_lines);
    +	if (actual >= num_lines) {
    +	    clrtobot();
    +	    break;
    +	}
    +	move(i, 0);
    +	printw("%3d:", actual);
    +	clrtoeol();
    +	if ((s = lptr[i - 1]) == 0) {
    +	    continue;
    +	}
    +	len = ch_len(s);
    +	if (len > shift) {
    +#if USE_WIDEC_SUPPORT
    +	    add_wchstr(s + shift);
    +#else
    +	    addchstr(s + shift);
    +#endif
    +	}
    +#if defined(NCURSES_VERSION) || defined(HAVE_WCHGAT)
    +	if (try_color)
    +	    wchgat(stdscr, -1, WA_NORMAL, my_pair, NULL);
    +#endif
    +    }
    +    setscrreg(1, LINES - 1);
    +    scrollok(stdscr, TRUE);
    +    refresh();
    +}
    +
    +#if CAN_RESIZE
    +/*
    + * This uses functions that are "unsafe", but it seems to work on SunOS. 
    + * Usually: the "unsafe" refers to the functions that POSIX lists which may be
    + * called from a signal handler.  Those do not include buffered I/O, which is
    + * used for instance in wrefresh().  To be really portable, you should use the
    + * KEY_RESIZE return (which relies on ncurses' sigwinch handler).
    + *
    + * The 'wrefresh(curscr)' is needed to force the refresh to start from the top
    + * of the screen -- some xterms mangle the bitmap while resizing.
    + */
    +static void
    +adjust(int sig)
    +{
    +    if (waiting || sig == 0) {
    +	struct winsize size;
    +
    +	if (ioctl(fileno(stdout), TIOCGWINSZ, &size) == 0) {
    +	    resize_term(size.ws_row, size.ws_col);
    +	    wrefresh(curscr);
    +	    show_all(sig ? "SIGWINCH" : "interrupt");
    +	}
    +	interrupted = FALSE;
    +    } else {
    +	interrupted = TRUE;
    +    }
    +    (void) signal(SIGWINCH, adjust);	/* some systems need this */
    +}
    +#endif /* CAN_RESIZE */
    +
    +static void
    +read_file(const char *filename)
    +{
    +    FILE *fp;
    +    int pass;
    +    int k;
    +    size_t j;
    +    size_t len;
    +    struct stat sb;
    +    char *my_blob;
    +    char **my_vec = 0;
    +
    +    if (stat(filename, &sb) != 0
    +	|| (sb.st_mode & S_IFMT) != S_IFREG) {
    +	failed("input is not a file");
    +    }
    +
    +    if (sb.st_size == 0) {
    +	failed("input is empty");
    +    }
    +
    +    if ((fp = fopen(filename, "r")) == 0) {
    +	failed("cannot open input-file");
    +    }
    +
    +    if ((my_blob = malloc((size_t) sb.st_size + 1)) == 0) {
    +	failed("cannot allocate memory for input-file");
    +    }
    +
    +    len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp);
    +    my_blob[sb.st_size] = '\0';
    +    fclose(fp);
    +
    +    for (pass = 0; pass < 2; ++pass) {
    +	char *base = my_blob;
    +	k = 0;
    +	for (j = 0; j < len; ++j) {
    +	    if (my_blob[j] == '\n') {
    +		if (pass) {
    +		    my_vec[k] = base;
    +		    my_blob[j] = '\0';
    +		}
    +		base = my_blob + j + 1;
    +		++k;
    +	    }
    +	}
    +	num_lines = k;
    +	if (base != (my_blob + j))
    +	    ++num_lines;
    +	if (!pass &&
    +	    ((my_vec = typeCalloc(char *, (size_t) k + 2)) == 0)) {
    +	    failed("cannot allocate line-vector #1");
    +	}
    +    }
    +    if ((vec_lines = typeCalloc(NCURSES_CH_T *, (size_t) num_lines + 2)) == 0)
    +	failed("cannot allocate line-vector #2");
    +
    +    Trace(("slurp the file"));
    +    for (k = 0; k < num_lines; ++k) {
    +	char *buf = my_vec[k];
    +	char temp[BUFSIZ], *s, *d;
    +	int col;
    +
    +	lptr = &vec_lines[k];
    +
    +#if USE_WIDEC_SUPPORT
    +	if (lptr == vec_lines) {
    +	    if (!memcmp("", buf, 3)) {
    +		Trace(("trim BOM"));
    +		s = buf + 3;
    +		d = buf;
    +		do {
    +		} while ((*d++ = *s++) != '\0');
    +	    }
    +	}
    +#endif
    +
    +	/* convert tabs and nonprinting chars so that shift will work properly */
    +	for (s = buf, d = temp, col = 0; (*d = *s) != '\0'; s++) {
    +	    if (*d == '\r') {
    +		if (s[1] == '\n') {
    +		    continue;
    +		} else {
    +		    break;
    +		}
    +	    }
    +	    if (*d == '\n') {
    +		*d = '\0';
    +		break;
    +	    } else if (*d == '\t') {
    +		col = (col | 7) + 1;
    +		while ((d - temp) != col)
    +		    *d++ = ' ';
    +	    } else
    +#if USE_WIDEC_SUPPORT
    +		col++, d++;
    +#else
    +	    if (isprint(UChar(*d))) {
    +		col++;
    +		d++;
    +	    } else {
    +		_nc_SPRINTF(d, _nc_SLIMIT(sizeof(temp) - (d - buf))
    +			    "\\%03o", UChar(*s));
    +		d += strlen(d);
    +		col = (int) (d - temp);
    +	    }
    +#endif
    +	}
    +	*lptr = ch_dup(temp);
    +    }
    +
    +    free(my_vec);
    +    free(my_blob);
    +}
    +
     int
     main(int argc, char *argv[])
     {
    @@ -239,6 +471,8 @@ main(int argc, char *argv[])
     	"  r,      - scroll the viewport right by one column",
     	"",
     	"  h,       - scroll the viewport to top of file",
    +	"  ^F,    - scroll to the next page",
    +	"  ^B,    - scroll to the previous page",
     	"  e,        - scroll the viewport to end of file",
     	"",
     	"  ^L             - repaint using redrawwin()",
    @@ -250,9 +484,6 @@ main(int argc, char *argv[])
     	0
         };
     
    -    int MAXLINES = 1000;
    -    FILE *fp;
    -    char buf[BUFSIZ];
         int i;
         int my_delay = 0;
         NCURSES_CH_T **olptr;
    @@ -268,15 +499,7 @@ main(int argc, char *argv[])
     
         setlocale(LC_ALL, "");
     
    -#ifndef NCURSES_VERSION
    -    /*
    -     * We know ncurses will catch SIGINT if we don't establish our own handler.
    -     * Other versions of curses may/may not catch it.
    -     */
    -    (void) signal(SIGINT, finish);	/* arrange interrupts to terminate */
    -#endif
    -
    -    while ((i = getopt(argc, argv, "cin:rstT:")) != -1) {
    +    while ((i = getopt(argc, argv, "cirstT:")) != -1) {
     	switch (i) {
     	case 'c':
     	    try_color = TRUE;
    @@ -284,11 +507,6 @@ main(int argc, char *argv[])
     	case 'i':
     	    ignore_sigs = TRUE;
     	    break;
    -	case 'n':
    -	    if ((MAXLINES = atoi(optarg)) < 1 ||
    -		(MAXLINES + 2) <= 1)
    -		usage();
    -	    break;
     #if CAN_RESIZE
     	case 'r':
     	    nonposix_resize = TRUE;
    @@ -318,82 +536,14 @@ main(int argc, char *argv[])
         if (optind + 1 != argc)
     	usage();
     
    -    if ((vec_lines = typeCalloc(NCURSES_CH_T *, (size_t) MAXLINES + 2)) == 0)
    -	usage();
    -
    -    assert(vec_lines != 0);
    +    read_file(fname = argv[optind]);
     
    -    fname = argv[optind];
    -    if ((fp = fopen(fname, "r")) == 0) {
    -	perror(fname);
    -	ExitProgram(EXIT_FAILURE);
    -    }
     #if CAN_RESIZE
         if (nonposix_resize)
     	(void) signal(SIGWINCH, adjust);	/* arrange interrupts to resize */
     #endif
     
    -    Trace(("slurp the file"));
    -    for (lptr = &vec_lines[0]; (lptr - vec_lines) < MAXLINES; lptr++) {
    -	char temp[BUFSIZ], *s, *d;
    -	int col;
    -
    -	if (fgets(buf, sizeof(buf), fp) == 0)
    -	    break;
    -
    -#if USE_WIDEC_SUPPORT
    -	if (lptr == vec_lines) {
    -	    if (!memcmp("", buf, 3)) {
    -		Trace(("trim BOM"));
    -		s = buf + 3;
    -		d = buf;
    -		do {
    -		} while ((*d++ = *s++) != '\0');
    -	    }
    -	}
    -#endif
    -
    -	/* convert tabs and nonprinting chars so that shift will work properly */
    -	for (s = buf, d = temp, col = 0; (*d = *s) != '\0'; s++) {
    -	    if (*d == '\r') {
    -		if (s[1] == '\n') {
    -		    continue;
    -		} else {
    -		    break;
    -		}
    -	    }
    -	    if (*d == '\n') {
    -		*d = '\0';
    -		break;
    -	    } else if (*d == '\t') {
    -		col = (col | 7) + 1;
    -		while ((d - temp) != col)
    -		    *d++ = ' ';
    -	    } else
    -#if USE_WIDEC_SUPPORT
    -		col++, d++;
    -#else
    -	    if (isprint(UChar(*d))) {
    -		col++;
    -		d++;
    -	    } else {
    -		_nc_SPRINTF(d, _nc_SLIMIT(sizeof(temp) - (d - buf))
    -			    "\\%03o", UChar(*s));
    -		d += strlen(d);
    -		col = (int) (d - temp);
    -	    }
    -#endif
    -	}
    -	*lptr = ch_dup(temp);
    -    }
    -    (void) fclose(fp);
    -    num_lines = (int) (lptr - vec_lines);
    -
    -    if (ignore_sigs) {
    -	InitAndCatch(initscr(), SIG_IGN);
    -    } else {
    -	initscr();
    -    }
    +    InitAndCatch(initscr(), ignore_sigs ? SIG_IGN : finish);
         keypad(stdscr, TRUE);	/* enable keyboard mapping */
         (void) nonl();		/* tell curses not to do NL->CR/NL on output */
         (void) cbreak();		/* take input chars one at a time, no wait for \n */
    @@ -473,15 +623,41 @@ main(int argc, char *argv[])
     	    scrl((int) (lptr - olptr));
     	    break;
     
    +	case '<':
    +	    shift = 0;
    +	    /* FALLTHRU */
     	case 'h':
    +	    /* FALLTHRU */
     	case KEY_HOME:
     	    lptr = vec_lines;
     	    break;
     
    +	case '>':
    +	    shift = 0;
    +	    /* FALLTHRU */
     	case 'e':
    +	    /* FALLTHRU */
     	case KEY_END:
     	    if (num_lines > LINES)
    -		lptr = vec_lines + num_lines - LINES + 1;
    +		lptr = (vec_lines + num_lines - LINES + 1);
    +	    else
    +		lptr = (vec_lines + (num_lines - 2));
    +	    break;
    +
    +	case CTRL('F'):
    +	    /* FALLTHRU */
    +	case KEY_NPAGE:
    +	    if ((lptr - vec_lines) < (num_lines - 5))
    +		lptr += (LINES - 1);
    +	    else
    +		lptr = (vec_lines + num_lines - 2);
    +	    break;
    +
    +	case CTRL('B'):
    +	    /* FALLTHRU */
    +	case KEY_PPAGE:
    +	    if ((lptr - vec_lines) >= LINES)
    +		lptr -= (LINES - 1);
     	    else
     		lptr = vec_lines;
     	    break;
    @@ -549,108 +725,3 @@ main(int argc, char *argv[])
     
         finish(0);			/* we're done */
     }
    -
    -static void
    -finish(int sig)
    -{
    -    endwin();
    -#if NO_LEAKS
    -    if (vec_lines != 0) {
    -	int n;
    -	for (n = 0; n < num_lines; ++n) {
    -	    free(vec_lines[n]);
    -	}
    -	free(vec_lines);
    -    }
    -#endif
    -    ExitProgram(sig != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
    -}
    -
    -#if CAN_RESIZE
    -/*
    - * This uses functions that are "unsafe", but it seems to work on SunOS. 
    - * Usually: the "unsafe" refers to the functions that POSIX lists which may be
    - * called from a signal handler.  Those do not include buffered I/O, which is
    - * used for instance in wrefresh().  To be really portable, you should use the
    - * KEY_RESIZE return (which relies on ncurses' sigwinch handler).
    - *
    - * The 'wrefresh(curscr)' is needed to force the refresh to start from the top
    - * of the screen -- some xterms mangle the bitmap while resizing.
    - */
    -static void
    -adjust(int sig)
    -{
    -    if (waiting || sig == 0) {
    -	struct winsize size;
    -
    -	if (ioctl(fileno(stdout), TIOCGWINSZ, &size) == 0) {
    -	    resize_term(size.ws_row, size.ws_col);
    -	    wrefresh(curscr);
    -	    show_all(sig ? "SIGWINCH" : "interrupt");
    -	}
    -	interrupted = FALSE;
    -    } else {
    -	interrupted = TRUE;
    -    }
    -    (void) signal(SIGWINCH, adjust);	/* some systems need this */
    -}
    -#endif /* CAN_RESIZE */
    -
    -static void
    -show_all(const char *tag)
    -{
    -    int i;
    -    char temp[BUFSIZ];
    -    NCURSES_CH_T *s;
    -    time_t this_time;
    -
    -#if CAN_RESIZE
    -    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
    -		"%.20s (%3dx%3d) col %d ", tag, LINES, COLS, shift);
    -    i = (int) strlen(temp);
    -    if ((i + 7) < (int) sizeof(temp)) {
    -	_nc_SPRINTF(temp + i, _nc_SLIMIT(sizeof(temp) - (size_t) i)
    -		    "view %.*s",
    -		    (int) (sizeof(temp) - 7 - (size_t) i),
    -		    fname);
    -    }
    -#else
    -    (void) tag;
    -    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
    -		"view %.*s", (int) sizeof(temp) - 7, fname);
    -#endif
    -    move(0, 0);
    -    printw("%.*s", COLS, temp);
    -    clrtoeol();
    -    this_time = time((time_t *) 0);
    -    _nc_STRNCPY(temp, ctime(&this_time), (size_t) 30);
    -    if ((i = (int) strlen(temp)) != 0) {
    -	temp[--i] = 0;
    -	if (move(0, COLS - i - 2) != ERR)
    -	    printw("  %s", temp);
    -    }
    -
    -    scrollok(stdscr, FALSE);	/* prevent screen from moving */
    -    for (i = 1; i < LINES; i++) {
    -	move(i, 0);
    -	printw("%3ld:", (long) (lptr + i - vec_lines));
    -	clrtoeol();
    -	if ((s = lptr[i - 1]) != 0) {
    -	    int len = ch_len(s);
    -	    if (len > shift) {
    -#if USE_WIDEC_SUPPORT
    -		add_wchstr(s + shift);
    -#else
    -		addchstr(s + shift);
    -#endif
    -	    }
    -#if defined(NCURSES_VERSION) || defined(HAVE_WCHGAT)
    -	    if (try_color)
    -		wchgat(stdscr, -1, WA_NORMAL, my_pair, NULL);
    -#endif
    -	}
    -    }
    -    setscrreg(1, LINES - 1);
    -    scrollok(stdscr, TRUE);
    -    refresh();
    -}