From f9994a48d2f74b613a0adb19d3917f724d4d1312 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sun, 3 Oct 2021 00:30:14 +0000 Subject: [PATCH] ncurses 6.2 - patch 20211002 + use return-value from vsnprintf to reallocate as needed to allow for buffers larger than the screen size (report by "_RuRo_"). + modify tset "-q" option to refrain from modifying terminal modes, to match the documentation. + add section on margins to terminfo.5, adapted from X/Open Curses. + make tput/tset warning messages consistently using alias names when those are used, rather than the underlying program's name. + improve tput usage message for aliases such as clear, by eliminating tput-specific portions. + add a check in toe to ensure that a "termcap file" is text rather than binary. + further build-fixes for OpenBSD 6.9, whose header files differ from the other BSDs. --- NEWS | 17 +++- 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/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 | 109 ++++++++++++++++++++++- doc/html/man/tic.1m.html | 2 +- doc/html/man/toe.1m.html | 2 +- doc/html/man/tput.1.html | 65 +++++++------- doc/html/man/tset.1.html | 2 +- man/terminfo.tail | 119 +++++++++++++++++++++++++- man/tput.1 | 7 +- ncurses/base/MKlib_gen.sh | 8 +- ncurses/base/lib_color.c | 5 +- ncurses/base/safe_sprintf.c | 29 ++++--- ncurses/term.priv.h | 8 +- package/debian-mingw/changelog | 4 +- package/debian-mingw64/changelog | 4 +- package/debian/changelog | 4 +- package/mingw-ncurses.nsi | 4 +- package/mingw-ncurses.spec | 2 +- package/ncurses.spec | 2 +- package/ncursest.spec | 2 +- progs/reset_cmd.c | 8 +- progs/reset_cmd.h | 6 +- progs/tic.c | 15 ++-- progs/toe.c | 32 ++++++- progs/tput.c | 38 +++++--- progs/tset.c | 6 +- 38 files changed, 410 insertions(+), 118 deletions(-) diff --git a/NEWS b/NEWS index 989bf236..fdb530d8 100644 --- a/NEWS +++ b/NEWS @@ -26,7 +26,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.3712 2021/09/24 19:45:04 tom Exp $ +-- $Id: NEWS,v 1.3717 2021/10/02 22:25:41 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -46,6 +46,21 @@ 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. +20211002 + + use return-value from vsnprintf to reallocate as needed to allow for + buffers larger than the screen size (report by "_RuRo_"). + + modify tset "-q" option to refrain from modifying terminal modes, to + match the documentation. + + add section on margins to terminfo.5, adapted from X/Open Curses. + + make tput/tset warning messages consistently using alias names when + those are used, rather than the underlying program's name. + + improve tput usage message for aliases such as clear, by eliminating + tput-specific portions. + + add a check in toe to ensure that a "termcap file" is text rather + than binary. + + further build-fixes for OpenBSD 6.9, whose header files differ from + the other BSDs. + 20210925 + add kbeg to xterm+keypad to accommodate termcap applications -TD + add smglp and smgrp to vt420+lrmm, to provide useful data for the diff --git a/VERSION b/VERSION index 5280c093..b146b8e0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5:0:10 6.2 20210925 +5:0:10 6.2 20211002 diff --git a/dist.mk b/dist.mk index 951cf83e..e2fa72be 100644 --- a/dist.mk +++ b/dist.mk @@ -26,7 +26,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.1437 2021/09/25 10:32:30 tom Exp $ +# $Id: dist.mk,v 1.1438 2021/10/02 08:31:49 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -38,7 +38,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 6 NCURSES_MINOR = 2 -NCURSES_PATCH = 20210925 +NCURSES_PATCH = 20211002 # 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 896a37dc..6285fb23 100644 --- a/doc/html/man/adacurses6-config.1.html +++ b/doc/html/man/adacurses6-config.1.html @@ -126,7 +126,7 @@

SEE ALSO

        curses(3x)
 
-       This describes ncurses version 6.2 (patch 20210925).
+       This describes ncurses version 6.2 (patch 20211002).
 
 
 
diff --git a/doc/html/man/captoinfo.1m.html b/doc/html/man/captoinfo.1m.html
index 6c62295d..aefa17ab 100644
--- a/doc/html/man/captoinfo.1m.html
+++ b/doc/html/man/captoinfo.1m.html
@@ -199,7 +199,7 @@
 

SEE ALSO

        infocmp(1m), curses(3x), terminfo(5)
 
-       This describes ncurses version 6.2 (patch 20210925).
+       This describes ncurses version 6.2 (patch 20211002).
 
 
 

AUTHOR

diff --git a/doc/html/man/clear.1.html b/doc/html/man/clear.1.html
index bb222f91..537916a8 100644
--- a/doc/html/man/clear.1.html
+++ b/doc/html/man/clear.1.html
@@ -150,7 +150,7 @@
 

SEE ALSO

        tput(1), terminfo(5)
 
-       This describes ncurses version 6.2 (patch 20210925).
+       This describes ncurses version 6.2 (patch 20211002).
 
 
 
diff --git a/doc/html/man/form.3x.html b/doc/html/man/form.3x.html
index 907b12a5..6304e60f 100644
--- a/doc/html/man/form.3x.html
+++ b/doc/html/man/form.3x.html
@@ -248,7 +248,7 @@
        curses(3x) and related pages whose names  begin  "form_"  for  detailed
        descriptions of the entry points.
 
-       This describes ncurses version 6.2 (patch 20210925).
+       This describes ncurses version 6.2 (patch 20211002).
 
 
 
diff --git a/doc/html/man/infocmp.1m.html b/doc/html/man/infocmp.1m.html
index 18573a0d..3454a76e 100644
--- a/doc/html/man/infocmp.1m.html
+++ b/doc/html/man/infocmp.1m.html
@@ -514,7 +514,7 @@
 
        https://invisible-island.net/ncurses/tctest.html
 
-       This describes ncurses version 6.2 (patch 20210925).
+       This describes ncurses version 6.2 (patch 20211002).
 
 
 

AUTHOR

diff --git a/doc/html/man/infotocap.1m.html b/doc/html/man/infotocap.1m.html
index 66c53844..3980b99a 100644
--- a/doc/html/man/infotocap.1m.html
+++ b/doc/html/man/infotocap.1m.html
@@ -91,7 +91,7 @@
 

SEE ALSO

        infocmp(1m), tic(1m), curses(3x), terminfo(5)
 
-       This describes ncurses version 6.2 (patch 20210925).
+       This describes ncurses version 6.2 (patch 20211002).
 
 
 

AUTHOR

diff --git a/doc/html/man/menu.3x.html b/doc/html/man/menu.3x.html
index 590b0cea..64c40f50 100644
--- a/doc/html/man/menu.3x.html
+++ b/doc/html/man/menu.3x.html
@@ -223,7 +223,7 @@
        curses(3x) and related pages whose names  begin  "menu_"  for  detailed
        descriptions of the entry points.
 
-       This describes ncurses version 6.2 (patch 20210925).
+       This describes ncurses version 6.2 (patch 20211002).
 
 
 
diff --git a/doc/html/man/ncurses.3x.html b/doc/html/man/ncurses.3x.html
index 6bfb8675..03b8e47c 100644
--- a/doc/html/man/ncurses.3x.html
+++ b/doc/html/man/ncurses.3x.html
@@ -60,7 +60,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.2 (patch 20210925).
+       This describes ncurses version 6.2 (patch 20211002).
 
        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 12273291..0fa8141b 100644
--- a/doc/html/man/ncurses6-config.1.html
+++ b/doc/html/man/ncurses6-config.1.html
@@ -113,7 +113,7 @@
 

SEE ALSO

        curses(3x)
 
-       This describes ncurses version 6.2 (patch 20210925).
+       This describes ncurses version 6.2 (patch 20211002).
 
 
 
diff --git a/doc/html/man/panel.3x.html b/doc/html/man/panel.3x.html
index 0f61e014..22cf71ec 100644
--- a/doc/html/man/panel.3x.html
+++ b/doc/html/man/panel.3x.html
@@ -281,7 +281,7 @@
 

SEE ALSO

        curses(3x), curs_variables(3x),
 
-       This describes ncurses version 6.2 (patch 20210925).
+       This describes ncurses version 6.2 (patch 20211002).
 
 
 

AUTHOR

diff --git a/doc/html/man/tabs.1.html b/doc/html/man/tabs.1.html
index dc5cf413..6bb29cd8 100644
--- a/doc/html/man/tabs.1.html
+++ b/doc/html/man/tabs.1.html
@@ -207,7 +207,7 @@
 

SEE ALSO

        infocmp(1m), tset(1), curses(3x), terminfo(5).
 
-       This describes ncurses version 6.2 (patch 20210925).
+       This describes ncurses version 6.2 (patch 20211002).
 
 
 
diff --git a/doc/html/man/terminfo.5.html b/doc/html/man/terminfo.5.html
index 540e7060..f4020d03 100644
--- a/doc/html/man/terminfo.5.html
+++ b/doc/html/man/terminfo.5.html
@@ -62,7 +62,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: terminfo.tail,v 1.106 2021/08/28 19:00:29 tom Exp @
+  * @Id: terminfo.tail,v 1.107 2021/10/02 20:54:06 tom Exp @
   *.in -2
   *.in +2
   *.in -2
@@ -106,7 +106,7 @@
        have, by specifying how to perform screen operations, and by specifying
        padding requirements and initialization sequences.
 
-       This manual describes ncurses version 6.2 (patch 20210925).
+       This manual describes ncurses version 6.2 (patch 20211002).
 
 
 

Terminfo Entry Syntax

@@ -1605,6 +1605,107 @@
        outputting rmcup), specify nrrmc.
 
 
+

Margins

+       SVr4  (and  X/Open Curses) list several string capabilities for setting
+       margins.  Two were intended for use with  terminals,  and  another  six
+       were intended for use with printers.
+
+       o   The two terminal capabilities assume that the terminal may have the
+           capability of setting the left and/or right margin at  the  current
+           cursor column position.
+
+       o   The printer capabilities assume that the printer may have two types
+           of capability:
+
+           o   the ability to set a top and/or bottom margin using the current
+               line position, and
+
+           o   parameterized  capabilities  for setting the top, bottom, left,
+               right margins given the number of rows or columns.
+
+       In practice, the categorization into "terminal" and  "printer"  is  not
+       suitable:
+
+       o   The  AT&T  SVr4  terminal  database  uses smgl four times, for AT&T
+           hardware.
+
+           Three of the four are printers.   They  lack  the  ability  to  set
+           left/right margins by specifying the column.
+
+       o   Other  (non-AT&T) terminals may support margins but using different
+           assumptions from AT&T.
+
+           For instance, the DEC VT420 supports left/right margins,  but  only
+           using a column parameter.  As an added complication, the VT420 uses
+           two settings to fully enable left/right margins (left/right  margin
+           mode,  and  origin  mode).   The  former enables the margins, which
+           causes printed text to wrap  within  margins,  but  the  latter  is
+           needed to prevent cursor-addressing outside those margins.
+
+       o   Both  DEC  VT420  left/right  margins are set with a single control
+           sequence.  If either is omitted, the corresponding margin is set to
+           the  left  or  right  edge  of the display (rather than leaving the
+           margin unmodified).
+
+       These are the margin-related capabilities:
+
+                    Name       Description
+                    ----------------------------------------------
+                    smgl       Set left margin at current column
+                    smgr       Set right margin at current column
+                    smgb       Set bottom margin at current line
+                    smgt       Set top margin at current line
+                    smgbp      Set bottom margin at line N
+                    smglp      Set left margin at column N
+                    smgrp      Set right margin at column N
+                    smgtp      Set top margin at line N
+
+       When writing an application that uses these  string  capabilities,  the
+       pairs  should be first checked to see if each capability in the pair is
+       set or only one is set:
+
+       o   If both smglp and smgrp  are  set,  each  is  used  with  a  single
+           argument,  N,  that  gives  the column number of the left and right
+           margin, respectively.
+
+       o   If both smgtp and smgbp are set, each is used to set  the  top  and
+           bottom margin, respectively:
+
+           o   smgtp is used with a single argument, N, the line number of the
+               top margin.
+
+           o   smgbp is used with two arguments, N and M, that give  the  line
+               number of the bottom margin, the first counting from the top of
+               the page  and  the  second  counting  from  the  bottom.   This
+               accommodates  the two styles of specifying the bottom margin in
+               different manufacturers' printers.
+
+           When designing a terminfo entry for a printer that has  a  settable
+           bottom  margin,  only  the first or second argument should be used,
+           depending on the printer.  When developing an application that uses
+           smgbp to set the bottom margin, both arguments must be given.
+
+       Conversely, when only one capability in the pair is set:
+
+       o   If  only  one  of  smglp and smgrp is set, then it is used with two
+           arguments, the column number of the left and right margins, in that
+           order.
+
+       o   Likewise,  if  only  one of smgtp and smgbp is set, then it is used
+           with two arguments that give the top and bottom  margins,  in  that
+           order, counting from the top of the page.
+
+           When designing a terminfo entry for a printer that requires setting
+           both left and right or top and bottom margins simultaneously,  only
+           one  capability  in  the  pairs  smglp and smgrp or smgtp and smgbp
+           should be defined, leaving the other unset.
+
+       When setting margins, the line- and column-values are zero-based.
+
+       The mgc string capability should  be  defined.   Applications  such  as
+       tabs(1) rely upon this to reset all margins.
+
+
 

Area Clears

        If  the  terminal can clear from the current position to the end of the
        line, leaving the cursor where it is, this should be given as  el.   If
@@ -1786,6 +1887,7 @@
                tparm parameter      attribute        escape sequence
 
                none                 none             \E[0m
+
                p1                   standout         \E[0;1;7m
                p2                   underline        \E[0;4m
                p3                   reverse          \E[0;7m
@@ -2114,7 +2216,6 @@
          solid square block          ACS_BLOCK      #         0        0x30
          diamond                     ACS_DIAMOND    +         `        0x60
          checker board (stipple)     ACS_CKBOARD    :         a        0x61
-
          degree symbol               ACS_DEGREE     \         f        0x66
          plus/minus                  ACS_PLMINUS    #         g        0x67
          board of squares            ACS_BOARD      #         h        0x68
@@ -2132,6 +2233,7 @@
          tee pointing right          ACS_LTEE       +         t        0x74
          tee pointing left           ACS_RTEE       +         u        0x75
          tee pointing up             ACS_BTEE       +         v        0x76
+
          tee pointing down           ACS_TTEE       +         w        0x77
          vertical line               ACS_VLINE      |         x        0x78
          less-than-or-equal-to       ACS_LEQUAL     <         y        0x79
@@ -2565,6 +2667,7 @@
 
  • Basic Capabilities
  • Parameterized Strings
  • Cursor Motions
  • +
  • Margins
  • Area Clears
  • Insert/delete line and vertical motions
  • Insert/Delete Character
  • diff --git a/doc/html/man/tic.1m.html b/doc/html/man/tic.1m.html index 39f1e664..4127b6d0 100644 --- a/doc/html/man/tic.1m.html +++ b/doc/html/man/tic.1m.html @@ -461,7 +461,7 @@ captoinfo(1m), infocmp(1m), infotocap(1m), toe(1m), curses(3x), term(5). terminfo(5). user_caps(5). - This describes ncurses version 6.2 (patch 20210925). + This describes ncurses version 6.2 (patch 20211002).

    AUTHOR

    diff --git a/doc/html/man/toe.1m.html b/doc/html/man/toe.1m.html
    index 70f0340b..a55bf168 100644
    --- a/doc/html/man/toe.1m.html
    +++ b/doc/html/man/toe.1m.html
    @@ -171,7 +171,7 @@
            captoinfo(1m),   infocmp(1m),   infotocap(1m),   tic(1m),   curses(3x),
            terminfo(5).
     
    -       This describes ncurses version 6.2 (patch 20210925).
    +       This describes ncurses version 6.2 (patch 20211002).
     
     
     
    diff --git a/doc/html/man/tput.1.html b/doc/html/man/tput.1.html
    index 00b0e006..4376be45 100644
    --- a/doc/html/man/tput.1.html
    +++ b/doc/html/man/tput.1.html
    @@ -28,7 +28,7 @@
       * sale, use or other dealings in this Software without prior written       *
       * authorization.                                                           *
       ****************************************************************************
    -  * @Id: tput.1,v 1.71 2021/09/19 00:34:23 tom Exp @
    +  * @Id: tput.1,v 1.72 2021/10/02 21:41:00 tom Exp @
     -->
     
     
    @@ -459,82 +459,83 @@
                to analyze nonstandard capname operands.
     
                Besides  providing  more  reliable operation than AT&T's utility, a
    -           portability problem is introduced by  this  analysis.   An  OpenBSD
    +           portability problem is introduced  by  this  analysis:  An  OpenBSD
                developer  adapted  the  internal  library function from ncurses to
    -           allow tput to interpret multiple  commands  on  a  line.   Portable
    +           port NetBSD's  termcap-based  tput  to  terminfo.   That  had  been
    +           modified  to  interpret  multiple  commands  on  a  line.  Portable
                applications should not rely upon this feature; ncurses provides it
                to support applications written specifically for OpenBSD.
     
            This  implementation  (unlike  others)  can  accept  both  termcap  and
    -       terminfo  names for the capname feature, if termcap support is compiled
    -       in.  However, the  predefined  termcap  and  terminfo  names  have  two
    +       terminfo names for the capname feature, if termcap support is  compiled
    +       in.   However,  the  predefined  termcap  and  terminfo  names have two
            ambiguities in this case (and the terminfo name is assumed):
     
    -       o   The  termcap  name  dl corresponds to the terminfo name dl1 (delete
    +       o   The termcap name dl corresponds to the terminfo  name  dl1  (delete
                one line).
    -           The terminfo name dl corresponds to the termcap name DL  (delete  a
    +           The  terminfo  name dl corresponds to the termcap name DL (delete a
                given number of lines).
     
    -       o   The  termcap  name  ed  corresponds  to the terminfo name rmdc (end
    +       o   The termcap name ed corresponds to  the  terminfo  name  rmdc  (end
                delete mode).
    -           The terminfo name ed corresponds to the termcap name cd  (clear  to
    +           The  terminfo  name ed corresponds to the termcap name cd (clear to
                end of screen).
     
    -       The  longname  and  -S options, and the parameter-substitution features
    -       used in the cup example,  were  not  supported  in  BSD  curses  before
    +       The longname and -S options, and  the  parameter-substitution  features
    +       used  in  the  cup  example,  were  not  supported in BSD curses before
            4.3reno (1989) or in AT&T/USL curses before SVr4 (1988).
     
    -       IEEE   Std   1003.1/The   Open   Group   Base  Specifications  Issue  7
    -       (POSIX.1-2008) documents only the operands for clear, init  and  reset.
    +       IEEE  Std  1003.1/The  Open  Group    Base   Specifications   Issue   7
    +       (POSIX.1-2008)  documents  only the operands for clear, init and reset.
            There are a few interesting observations to make regarding that:
     
    -       o   In  this implementation, clear is part of the capname support.  The
    -           others  (init  and  longname)  do  not   correspond   to   terminal
    +       o   In this implementation, clear is part of the capname support.   The
    +           others   (init   and   longname)  do  not  correspond  to  terminal
                capabilities.
     
            o   Other  implementations  of  tput  on  SVr4-based  systems  such  as
    -           Solaris, IRIX64 and HPUX as well as others such as  AIX  and  Tru64
    +           Solaris,  IRIX64  and  HPUX as well as others such as AIX and Tru64
                provide support for capname operands.
     
            o   A few platforms such as FreeBSD recognize termcap names rather than
                terminfo capability names in their respective tput commands.  Since
    -           2010,  NetBSD's  tput  uses  terminfo names.  Before that, it (like
    +           2010, NetBSD's tput uses terminfo names.   Before  that,  it  (like
                FreeBSD) recognized termcap names.
     
    -           Beginning in 2021, FreeBSD uses the ncurses  tput,  configured  for
    +           Beginning  in  2021,  FreeBSD uses the ncurses tput, configured for
                both terminfo (tested first) and termcap (as a fallback).
     
            Because (apparently) all of the certified Unix systems support the full
    -       set of capability names, the reasoning for documenting only a  few  may
    +       set  of  capability names, the reasoning for documenting only a few may
            not be apparent.
     
    -       o   X/Open  Curses Issue 7 documents tput differently, with capname and
    +       o   X/Open Curses Issue 7 documents tput differently, with capname  and
                the other features used in this implementation.
     
    -       o   That is, there are two standards for tput:  POSIX  (a  subset)  and
    -           X/Open  Curses (the full implementation).  POSIX documents a subset
    -           to avoid the  complication  of  including  X/Open  Curses  and  the
    +       o   That  is,  there  are  two standards for tput: POSIX (a subset) and
    +           X/Open Curses (the full implementation).  POSIX documents a  subset
    +           to  avoid  the  complication  of  including  X/Open  Curses and the
                terminal capabilities database.
     
    -       o   While  it  is  certainly  possible  to write a tput program without
    -           using  curses,  none  of  the   systems   which   have   a   curses
    -           implementation  provide  a  tput utility which does not provide the
    +       o   While it is certainly possible to  write  a  tput  program  without
    +           using   curses,   none   of   the   systems  which  have  a  curses
    +           implementation provide a tput utility which does  not  provide  the
                capname feature.
     
            X/Open  Curses  Issue  7  (2009)  is  the  first  version  to  document
            utilities.  However that part of X/Open Curses does not follow existing
            practice (i.e., Unix features documented in SVID 3):
     
    -       o   It assigns exit code 4 to "invalid operand", which may be the  same
    -           as  unknown capability.  For instance, the source code for Solaris'
    +       o   It  assigns exit code 4 to "invalid operand", which may be the same
    +           as unknown capability.  For instance, the source code for  Solaris'
                xcurses uses the term "invalid" in this case.
     
    -       o   It assigns exit  code  255  to  a  numeric  variable  that  is  not
    +       o   It  assigns  exit  code  255  to  a  numeric  variable  that is not
                specified in the terminfo database.  That likely is a documentation
    -           error, confusing the -1 written  to  the  standard  output  for  an
    +           error,  confusing  the  -1  written  to  the standard output for an
                absent or cancelled numeric value versus an (unsigned) exit code.
     
    -       The  various  Unix systems (AIX, HPUX, Solaris) use the same exit-codes
    +       The various Unix systems (AIX, HPUX, Solaris) use the  same  exit-codes
            as ncurses.
     
            NetBSD curses documents different exit codes which do not correspond to
    @@ -544,7 +545,7 @@
     

    SEE ALSO

            clear(1), stty(1), tabs(1), tset(1), curs_termcap(3x), terminfo(5).
     
    -       This describes ncurses version 6.2 (patch 20210925).
    +       This describes ncurses version 6.2 (patch 20211002).
     
     
     
    diff --git a/doc/html/man/tset.1.html b/doc/html/man/tset.1.html
    index ed9dc11c..92f13e13 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.2 (patch 20210925).
    +       This describes ncurses version 6.2 (patch 20211002).
     
     
     
    diff --git a/man/terminfo.tail b/man/terminfo.tail
    index 5c3abd1b..07217112 100644
    --- a/man/terminfo.tail
    +++ b/man/terminfo.tail
    @@ -27,7 +27,7 @@
     .\" authorization.                                                           *
     .\"***************************************************************************
     .\"
    -.\" $Id: terminfo.tail,v 1.106 2021/08/28 19:00:29 tom Exp $
    +.\" $Id: terminfo.tail,v 1.107 2021/10/02 20:54:06 tom Exp $
     .ps +1
     .SS User-Defined Capabilities
     .
    @@ -647,6 +647,122 @@ If the \fBsmcup\fP sequence will not restore the screen after an
     \fBrmcup\fP sequence is output (to the state prior to outputting
     \fBrmcup\fP), specify \fBnrrmc\fP.
     .PP
    +.SS Margins
    +SVr4 (and X/Open Curses)
    +list several string capabilities for setting margins.
    +Two were intended for use with terminals,
    +and another six were intended for use with printers.
    +.bP
    +The two terminal capabilities assume that the terminal may have
    +the capability of setting the left and/or right margin at the current
    +cursor column position.
    +.bP
    +The printer capabilities assume that the printer may have
    +two types of capability:
    +.RS
    +.bP
    +the ability to set a top and/or bottom margin using the current
    +line position, and
    +.bP
    +parameterized capabilities for setting the top, bottom, left, right margins
    +given the number of rows or columns.
    +.RE
    +.RE
    +.PP
    +In practice, the categorization into \*(``terminal\*('' and \*(``printer\*(''
    +is not suitable:
    +.bP
    +The AT&T SVr4 terminal database uses \fBsmgl\fP four times,
    +for AT&T hardware.
    +.IP
    +Three of the four are printers.
    +They lack the ability to set left/right margins by specifying the column.
    +.bP
    +Other (non-AT&T) terminals may support margins
    +but using different assumptions from AT&T.
    +.IP
    +For instance, the DEC VT420 supports left/right margins,
    +but only using a column parameter.
    +As an added complication, the VT420 uses two settings to fully enable
    +left/right margins (left/right margin mode, and origin mode).
    +The former enables the margins, which causes printed text
    +to wrap within margins, but the latter is needed to prevent
    +cursor-addressing outside those margins.
    +.bP
    +Both DEC VT420 left/right margins are set with a single control sequence.
    +If either is omitted, the corresponding margin is set to the left or
    +right edge of the display (rather than leaving the margin unmodified).
    +.PP
    +These are the margin-related capabilities:
    +.TS
    +center;
    +l l
    +_ _
    +lw8 lw18.
    +\fBName	Description\fP
    +smgl	Set left margin at current column
    +smgr	Set right margin at current column
    +smgb	Set bottom margin at current line
    +smgt	Set top margin at current line
    +smgbp	Set bottom margin at line \fIN\fP
    +smglp	Set left margin at column \fIN\fP
    +smgrp	Set right margin at column \fIN\fP
    +smgtp	Set top margin at line \fIN\fP
    +.TE
    +.PP
    +When writing an application that
    +uses these string capabilities,
    +the pairs should be first checked to see
    +if each capability in the pair is set or only one is set:
    +.bP
    +If both \fBsmglp\fP and \fBsmgrp\fP are set,
    +each is used with a single argument, \fIN\fP,
    +that gives the column number of the left and right margin, respectively.
    +.bP
    +If both \fBsmgtp\fP and \fBsmgbp\fP are set,
    +each is used to set the top and bottom margin,
    +respectively:
    +.RS 4
    +.bP
    +\fBsmgtp\fP is used with a single argument, \fIN\fP,
    +the line number of the top margin.
    +.bP
    +\fBsmgbp\fP is used with two arguments, \fIN\fP and \fIM\fP,
    +that give the line number of the bottom margin,
    +the first counting from the top of the
    +page and the second counting from the bottom.
    +This accommodates the two styles of specifying
    +the bottom margin in different manufacturers' printers.
    +.RE
    +.IP
    +When designing a terminfo entry for a
    +printer that has a settable bottom margin,
    +only the first or second argument should be used, depending on the printer.
    +When developing an application that uses \fBsmgbp\fP to set the bottom margin,
    +both arguments must be given.
    +.PP
    +Conversely, when only one capability in the pair is set:
    +.bP 
    +If only one of \fBsmglp\fP and \fBsmgrp\fP is set,
    +then it is used with two arguments,
    +the column number of the left and right margins, in that order.
    +.bP
    +Likewise, if only one of \fBsmgtp\fP and \fBsmgbp\fP is set, then it
    +is used with two arguments that give the top and bottom margins,
    +in that order, counting from the top of the page.
    +.IP
    +When designing a terminfo entry for a printer that requires setting both
    +left and right or top and bottom margins simultaneously,
    +only one capability in the pairs
    +\fBsmglp\fP and \fBsmgrp\fP or
    +\fBsmgtp\fP and \fBsmgbp\fP should be defined,
    +leaving the other unset.
    +.PP
    +When setting margins, the line- and column-values are zero-based.
    +.PP
    +The \fBmgc\fP string capability should be defined.
    +Applications such as \fBtabs\fP(1) rely upon this to reset all margins.
    +.\"
     .SS Area Clears
     .PP
     If the terminal can clear from the current position to the end of the
    @@ -662,6 +778,7 @@ if a true
     .B ed
     is not available.)
     .PP
    +.\"
     .SS Insert/delete line and vertical motions
     .PP
     If the terminal can open a new blank line before the line where the cursor
    diff --git a/man/tput.1 b/man/tput.1
    index 50a7cd6c..0834e447 100644
    --- a/man/tput.1
    +++ b/man/tput.1
    @@ -28,7 +28,7 @@
     .\" authorization.                                                           *
     .\"***************************************************************************
     .\"
    -.\" $Id: tput.1,v 1.71 2021/09/19 00:34:23 tom Exp $
    +.\" $Id: tput.1,v 1.72 2021/10/02 21:41:00 tom Exp $
     .TH @TPUT@ 1 ""
     .ds d @TERMINFO@
     .ds n 1
    @@ -518,9 +518,10 @@ the standard \fIcapname\fR operands, and an internal library
     function to analyze nonstandard \fIcapname\fR operands.
     .IP
     Besides providing more reliable operation than AT&T's utility,
    -a portability problem is introduced by this analysis.
    +a portability problem is introduced by this analysis:
     An OpenBSD developer adapted the internal library function from ncurses
    -to allow \fBtput\fP to interpret multiple commands on a line.
    +to port NetBSD's termcap-based \fBtput\fP to terminfo.
    +That had been modified to interpret multiple commands on a line.
     Portable applications should not rely upon this feature;
     ncurses provides it to support applications written
     specifically for OpenBSD.
    diff --git a/ncurses/base/MKlib_gen.sh b/ncurses/base/MKlib_gen.sh
    index 26e473b4..9dc08557 100755
    --- a/ncurses/base/MKlib_gen.sh
    +++ b/ncurses/base/MKlib_gen.sh
    @@ -2,7 +2,7 @@
     #
     # MKlib_gen.sh -- generate sources from curses.h macro definitions
     #
    -# ($Id: MKlib_gen.sh,v 1.70 2021/09/24 19:23:20 tom Exp $)
    +# ($Id: MKlib_gen.sh,v 1.71 2021/09/26 22:08:53 tom Exp $)
     #
     ##############################################################################
     # Copyright 2018-2020,2021 Thomas E. Dickey                                  #
    @@ -470,9 +470,9 @@ END		{
     				if ( value !~ /P_POUNDC/ ) {
     					gsub(/[ \t]+/," ",value);
     					sub(/^[0-9a-zA-Z_]+ /,"",value);
    -					sub(/^\* /,"",value);
    -					gsub("struct [0-9a-zA-Z_]+ \*","",value);
    -					gsub(/[0-9a-zA-Z_]+ \* /,"",value);
    +					sub(/^[*][ \t]*/,"",value);
    +					gsub("struct[ \t]*[0-9a-zA-Z_]+[ \t]*[*]","",value);
    +					gsub(/[0-9a-zA-Z_]+[ \t]*[*][ \t]*/,"",value);
     					gsub(/ (const) /," ",value);
     					gsub(/ (int|short|attr_t|chtype|wchar_t|NCURSES_BOOL|NCURSES_OUTC|NCURSES_OUTC_sp|va_list) /," ",value);
     					gsub(/ void /,"",value);
    diff --git a/ncurses/base/lib_color.c b/ncurses/base/lib_color.c
    index e4276784..e4dc79b5 100644
    --- a/ncurses/base/lib_color.c
    +++ b/ncurses/base/lib_color.c
    @@ -49,7 +49,7 @@
     #define CUR SP_TERMTYPE
     #endif
     
    -MODULE_ID("$Id: lib_color.c,v 1.147 2021/05/08 15:11:48 tom Exp $")
    +MODULE_ID("$Id: lib_color.c,v 1.148 2021/10/02 22:55:48 tom Exp $")
     
     #ifdef USE_TERM_DRIVER
     #define CanChange      InfoOf(SP_PARM).canchange
    @@ -831,7 +831,6 @@ static int
     _nc_color_content(SCREEN *sp, int color, int *r, int *g, int *b)
     {
         int result = ERR;
    -    int maxcolors;
     
         T((T_CALLED("color_content(%p,%d,%p,%p,%p)"),
            (void *) sp,
    @@ -841,7 +840,7 @@ _nc_color_content(SCREEN *sp, int color, int *r, int *g, int *b)
            (void *) b));
     
         if (sp != 0) {
    -	maxcolors = MaxColors;
    +	int maxcolors = MaxColors;
     
     	if (color >= 0 && OkColorHi(color) && sp->_coloron) {
     	    int c_r, c_g, c_b;
    diff --git a/ncurses/base/safe_sprintf.c b/ncurses/base/safe_sprintf.c
    index 1868c009..3fff2e83 100644
    --- a/ncurses/base/safe_sprintf.c
    +++ b/ncurses/base/safe_sprintf.c
    @@ -1,5 +1,5 @@
     /****************************************************************************
    - * Copyright 2018,2020 Thomas E. Dickey                                     *
    + * Copyright 2018-2020,2021 Thomas E. Dickey                                *
      * Copyright 1998-2012,2013 Free Software Foundation, Inc.                  *
      *                                                                          *
      * Permission is hereby granted, free of charge, to any person obtaining a  *
    @@ -34,7 +34,7 @@
     #include 
     #include 
     
    -MODULE_ID("$Id: safe_sprintf.c,v 1.33 2020/02/02 23:34:34 tom Exp $")
    +MODULE_ID("$Id: safe_sprintf.c,v 1.35 2021/10/03 00:25:09 tom Exp $")
     
     #if USE_SAFE_SPRINTF
     
    @@ -223,9 +223,9 @@ NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_DCLx
     				    const char *fmt,
     				    va_list ap)
     {
    -    char *result = 0;
    +    char *result = NULL;
     
    -    if (SP_PARM != 0 && fmt != 0) {
    +    if (SP_PARM != NULL && fmt != NULL) {
     #if USE_SAFE_SPRINTF
     	va_list ap2;
     	int len;
    @@ -238,7 +238,7 @@ NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_DCLx
     	    my_length = (size_t) (2 * (len + 1));
     	    my_buffer = typeRealloc(char, my_length, my_buffer);
     	}
    -	if (my_buffer != 0) {
    +	if (my_buffer != NULL) {
     	    *my_buffer = '\0';
     	    if (len >= 0) {
     		vsprintf(my_buffer, fmt, ap);
    @@ -255,21 +255,30 @@ NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_DCLx
     	    if (screen_columns(SP_PARM) > MyCols)
     		MyCols = screen_columns(SP_PARM);
     	    my_length = (size_t) (MyRows * (MyCols + 1)) + 1;
    +	    if (my_length < 80)
    +		my_length = 80;
     	    my_buffer = typeRealloc(char, my_length, my_buffer);
     	}
     
    -	if (my_buffer != 0) {
    +	if (my_buffer != NULL) {
     # if HAVE_VSNPRINTF
    -	    vsnprintf(my_buffer, my_length, fmt, ap);	/* SUSv2, 1997 */
    +	    /* SUSv2, 1997 */
    +	    int used;
    +	    while ((used = vsnprintf(my_buffer, my_length, fmt, ap))
    +		   >= (int) my_length) {
    +		my_length = (size_t) ((3 * used) / 2);
    +		my_buffer = typeRealloc(char, my_length, my_buffer);
    +	    }
     # else
    -	    vsprintf(my_buffer, fmt, ap);	/* ISO/ANSI C, 1989 */
    +	    /* ISO/ANSI C, 1989 */
    +	    vsprintf(my_buffer, fmt, ap);
     # endif
     	    result = my_buffer;
     	}
     #endif
    -    } else if (my_buffer != 0) {	/* see _nc_freeall() */
    +    } else if (my_buffer != NULL) {	/* see _nc_freeall() */
     	free(my_buffer);
    -	my_buffer = 0;
    +	my_buffer = NULL;
     	my_length = 0;
         }
         return result;
    diff --git a/ncurses/term.priv.h b/ncurses/term.priv.h
    index 85380ac3..ce7a986b 100644
    --- a/ncurses/term.priv.h
    +++ b/ncurses/term.priv.h
    @@ -27,7 +27,7 @@
      ****************************************************************************/
     
     /*
    - * $Id: term.priv.h,v 1.5 2021/09/24 16:42:04 tom Exp $
    + * $Id: term.priv.h,v 1.6 2021/09/26 20:43:08 tom Exp $
      *
      *	term.priv.h
      *
    @@ -55,6 +55,12 @@ extern "C" {
     #include 		/* time_t */
     #include 		/* time_t */
     
    +#ifdef USE_PTHREADS
    +#if USE_REENTRANT
    +#include 
    +#endif
    +#endif
    +
     /*
      * State of tparm().
      */
    diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog
    index 42f5224a..d8bc3611 100644
    --- a/package/debian-mingw/changelog
    +++ b/package/debian-mingw/changelog
    @@ -1,8 +1,8 @@
    -ncurses6 (6.2+20210925) unstable; urgency=low
    +ncurses6 (6.2+20211002) unstable; urgency=low
     
       * latest weekly patch
     
    - -- Thomas E. Dickey   Fri, 24 Sep 2021 15:17:49 -0400
    + -- Thomas E. Dickey   Sun, 26 Sep 2021 16:21:29 -0400
     
     ncurses6 (5.9-20131005) unstable; urgency=low
     
    diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog
    index 42f5224a..d8bc3611 100644
    --- a/package/debian-mingw64/changelog
    +++ b/package/debian-mingw64/changelog
    @@ -1,8 +1,8 @@
    -ncurses6 (6.2+20210925) unstable; urgency=low
    +ncurses6 (6.2+20211002) unstable; urgency=low
     
       * latest weekly patch
     
    - -- Thomas E. Dickey   Fri, 24 Sep 2021 15:17:49 -0400
    + -- Thomas E. Dickey   Sun, 26 Sep 2021 16:21:29 -0400
     
     ncurses6 (5.9-20131005) unstable; urgency=low
     
    diff --git a/package/debian/changelog b/package/debian/changelog
    index b6df649b..ebfe4387 100644
    --- a/package/debian/changelog
    +++ b/package/debian/changelog
    @@ -1,8 +1,8 @@
    -ncurses6 (6.2+20210925) unstable; urgency=low
    +ncurses6 (6.2+20211002) unstable; urgency=low
     
       * latest weekly patch
     
    - -- Thomas E. Dickey   Fri, 24 Sep 2021 15:17:49 -0400
    + -- Thomas E. Dickey   Sun, 26 Sep 2021 16:21:29 -0400
     
     ncurses6 (5.9-20120608) unstable; urgency=low
     
    diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi
    index 043cd554..e4c2fb7e 100644
    --- a/package/mingw-ncurses.nsi
    +++ b/package/mingw-ncurses.nsi
    @@ -1,4 +1,4 @@
    -; $Id: mingw-ncurses.nsi,v 1.479 2021/09/25 10:32:30 tom Exp $
    +; $Id: mingw-ncurses.nsi,v 1.480 2021/10/02 08:31:49 tom Exp $
     
     ; TODO add examples
     ; TODO bump ABI to 6
    @@ -10,7 +10,7 @@
     !define VERSION_MAJOR "6"
     !define VERSION_MINOR "2"
     !define VERSION_YYYY  "2021"
    -!define VERSION_MMDD  "0925"
    +!define VERSION_MMDD  "1002"
     !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD}
     
     !define MY_ABI   "5"
    diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec
    index d771d4b3..be32da31 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.2
    -Release: 20210925
    +Release: 20211002
     License: X11
     Group: Development/Libraries
     Source: ncurses-%{version}-%{release}.tgz
    diff --git a/package/ncurses.spec b/package/ncurses.spec
    index b6755bfd..3d8ec810 100644
    --- a/package/ncurses.spec
    +++ b/package/ncurses.spec
    @@ -1,7 +1,7 @@
     Summary: shared libraries for terminal handling
     Name: ncurses6
     Version: 6.2
    -Release: 20210925
    +Release: 20211002
     License: X11
     Group: Development/Libraries
     Source: ncurses-%{version}-%{release}.tgz
    diff --git a/package/ncursest.spec b/package/ncursest.spec
    index dd527d26..6157e3cb 100644
    --- a/package/ncursest.spec
    +++ b/package/ncursest.spec
    @@ -1,7 +1,7 @@
     Summary: Curses library with POSIX thread support.
     Name: ncursest6
     Version: 6.2
    -Release: 20210925
    +Release: 20211002
     License: X11
     Group: Development/Libraries
     Source: ncurses-%{version}-%{release}.tgz
    diff --git a/progs/reset_cmd.c b/progs/reset_cmd.c
    index e740fa66..eff3af72 100644
    --- a/progs/reset_cmd.c
    +++ b/progs/reset_cmd.c
    @@ -53,7 +53,7 @@
     #include 
     #endif
     
    -MODULE_ID("$Id: reset_cmd.c,v 1.27 2021/09/04 10:29:59 tom Exp $")
    +MODULE_ID("$Id: reset_cmd.c,v 1.28 2021/10/02 18:08:44 tom Exp $")
     
     /*
      * SCO defines TIOCGSIZE and the corresponding struct.  Other systems (SunOS,
    @@ -193,7 +193,7 @@ out_char(int c)
      * a child program dies in raw mode.
      */
     void
    -reset_tty_settings(int fd, TTY * tty_settings)
    +reset_tty_settings(int fd, TTY * tty_settings, int noset)
     {
         GET_TTY(fd, tty_settings);
     
    @@ -329,7 +329,9 @@ reset_tty_settings(int fd, TTY * tty_settings)
     	);
     #endif
     
    -    SET_TTY(fd, tty_settings);
    +    if (!noset) {
    +	SET_TTY(fd, tty_settings);
    +    }
     }
     
     /*
    diff --git a/progs/reset_cmd.h b/progs/reset_cmd.h
    index 7d457154..91a637c7 100644
    --- a/progs/reset_cmd.h
    +++ b/progs/reset_cmd.h
    @@ -1,5 +1,5 @@
     /****************************************************************************
    - * Copyright 2020 Thomas E. Dickey                                          *
    + * Copyright 2020,2021 Thomas E. Dickey                                     *
      * Copyright 2016 Free Software Foundation, Inc.                            *
      *                                                                          *
      * Permission is hereby granted, free of charge, to any person obtaining a  *
    @@ -32,7 +32,7 @@
      ****************************************************************************/
     
     /*
    - * $Id: reset_cmd.h,v 1.8 2020/02/02 23:34:34 tom Exp $
    + * $Id: reset_cmd.h,v 1.9 2021/10/02 20:58:58 tom Exp $
      *
      * Utility functions for resetting terminal.
      */
    @@ -51,7 +51,7 @@ extern bool send_init_strings(int /* fd */, TTY * /* old_settings */);
     extern void print_tty_chars(TTY * /* old_settings */, TTY * /* new_settings */);
     extern void reset_flush(void);
     extern void reset_start(FILE * /* fp */, bool /* is_reset */, bool /* is_init */ );
    -extern void reset_tty_settings(int /* fd */, TTY * /* tty_settings */);
    +extern void reset_tty_settings(int /* fd */, TTY * /* tty_settings */, int /* noset */);
     extern void set_control_chars(TTY * /* tty_settings */, int /* erase */, int /* intr */, int /* kill */);
     extern void set_conversions(TTY * /* tty_settings */);
     
    diff --git a/progs/tic.c b/progs/tic.c
    index a6281b32..672e51ed 100644
    --- a/progs/tic.c
    +++ b/progs/tic.c
    @@ -49,7 +49,7 @@
     #include 
     #include 
     
    -MODULE_ID("$Id: tic.c,v 1.302 2021/09/04 10:29:59 tom Exp $")
    +MODULE_ID("$Id: tic.c,v 1.305 2021/10/02 11:13:50 tom Exp $")
     
     #define STDIN_NAME ""
     
    @@ -1338,7 +1338,7 @@ check_ansi_cursor(char *list[4])
     	    if (j != k
     		&& !strcmp(list[j], list[k])) {
     		char *value = _nc_tic_expand(list[k], TRUE, 0);
    -		_nc_warning("repeated cursor control %s\n", value);
    +		_nc_warning("repeated cursor control %s", value);
     		repeated = TRUE;
     	    }
     	}
    @@ -1367,19 +1367,19 @@ check_ansi_cursor(char *list[4])
     		    continue;
     		if (memcmp(list[j], up, prefix)) {
     		    char *value = _nc_tic_expand(list[j], TRUE, 0);
    -		    _nc_warning("inconsistent prefix for %s\n", value);
    +		    _nc_warning("inconsistent prefix for %s", value);
     		    continue;
     		}
     		if (strlen(list[j]) < suffix) {
     		    char *value = _nc_tic_expand(list[j], TRUE, 0);
    -		    _nc_warning("inconsistent length for %s, expected %d\n",
    +		    _nc_warning("inconsistent length for %s, expected %d",
     				value, (int) suffix + 1);
     		    continue;
     		}
     		want = "BADC"[j];
     		if (list[j][suffix] != want) {
     		    char *value = _nc_tic_expand(list[j], TRUE, 0);
    -		    _nc_warning("inconsistent suffix for %s, expected %c, have %c\n",
    +		    _nc_warning("inconsistent suffix for %s, expected %c, have %c",
     				value, want, list[j][suffix]);
     		}
     	    }
    @@ -2085,10 +2085,13 @@ check_params(TERMTYPE2 *tp, const char *name, const char *value, int extended)
     	    for (n = 0; n < limit; ++n) {
     		_nc_reset_tparm(NULL);
     		(void) TPARM_9(value, n, n, n, n, n, n, n, n, n);
    -		if (_nc_tparm_err)
    +		if (_nc_tparm_err) {
     		    _nc_warning("problem%s in tparm(%s, %d, ...)",
     				(_nc_tparm_err == 1) ? "" : "s",
     				name, n);
    +		    if (debug_level < 2)
    +			break;
    +		}
     	    }
     	}
         }
    diff --git a/progs/toe.c b/progs/toe.c
    index 60a76a22..32f2ae4c 100644
    --- a/progs/toe.c
    +++ b/progs/toe.c
    @@ -45,7 +45,7 @@
     #include 
     #endif
     
    -MODULE_ID("$Id: toe.c,v 1.83 2021/09/21 20:07:51 tom Exp $")
    +MODULE_ID("$Id: toe.c,v 1.84 2021/09/28 08:27:29 tom Exp $")
     
     #define isDotname(name) (!strcmp(name, ".") || !strcmp(name, ".."))
     
    @@ -330,6 +330,26 @@ sorthook(int db_index, int db_limit, const char *term_name, TERMTYPE2 *tp)
     }
     
     #if NCURSES_USE_TERMCAP
    +/*
    + * Check if the buffer contents are printable ASCII, ensuring that we do not
    + * accidentally pick up incompatible binary content from a hashed database.
    + */
    +static bool
    +is_termcap(char *buffer)
    +{
    +    bool result = TRUE;
    +    while (*buffer != '\0') {
    +	int ch = UChar(*buffer++);
    +	if (ch == '\t')
    +	    continue;
    +	if (ch < ' ' || ch > '~') {
    +	    result = FALSE;
    +	    break;
    +	}
    +    }
    +    return result;
    +}
    +
     static void
     show_termcap(int db_index, int db_limit, char *buffer, DescHook hook)
     {
    @@ -518,11 +538,13 @@ typelist(int eargc, char *eargv[],
     	    db_array[1] = 0;
     
     	    if (cgetfirst(&buffer, db_array) > 0) {
    -		show_termcap(i, eargc, buffer, hook);
    -		free(buffer);
    -		while (cgetnext(&buffer, db_array) > 0) {
    +		if (is_termcap(buffer)) {
     		    show_termcap(i, eargc, buffer, hook);
     		    free(buffer);
    +		    while (cgetnext(&buffer, db_array) > 0) {
    +			show_termcap(i, eargc, buffer, hook);
    +			free(buffer);
    +		    }
     		}
     		cgetclose();
     		continue;
    @@ -539,6 +561,8 @@ typelist(int eargc, char *eargv[],
     
     	    if ((fp = safe_fopen(eargv[i], "r")) != 0) {
     		while (fgets(buffer, sizeof(buffer), fp) != 0) {
    +		    if (!is_termcap(buffer))
    +			break;
     		    if (*buffer == '#')
     			continue;
     		    if (isspace(*buffer))
    diff --git a/progs/tput.c b/progs/tput.c
    index ccc2f56d..8ac478e6 100644
    --- a/progs/tput.c
    +++ b/progs/tput.c
    @@ -47,13 +47,12 @@
     #include 
     #include 
     
    -MODULE_ID("$Id: tput.c,v 1.94 2021/09/19 00:06:44 tom Exp $")
    +MODULE_ID("$Id: tput.c,v 1.97 2021/10/02 18:09:23 tom Exp $")
     
     #define PUTS(s)		fputs(s, stdout)
     
     const char *_nc_progname = "tput";
     
    -static char *prg_name;
     static bool is_init = FALSE;
     static bool is_reset = FALSE;
     static bool is_clear = FALSE;
    @@ -64,7 +63,7 @@ quit(int status, const char *fmt, ...)
         va_list argp;
     
         va_start(argp, fmt);
    -    fprintf(stderr, "%s: ", prg_name);
    +    fprintf(stderr, "%s: ", _nc_progname);
         vfprintf(stderr, fmt, argp);
         fprintf(stderr, "\n");
         va_end(argp);
    @@ -72,7 +71,7 @@ quit(int status, const char *fmt, ...)
     }
     
     static GCC_NORETURN void
    -usage(void)
    +usage(const char *optstring)
     {
     #define KEEP(s) s "\n"
         static const char msg[] =
    @@ -91,8 +90,21 @@ usage(void)
     	KEEP("  capname     unlike clear/init/reset, print value for capability \"capname\"")
         };
     #undef KEEP
    -    (void) fprintf(stderr, "Usage: %s [options] [command]\n", prg_name);
    -    fputs(msg, stderr);
    +    (void) fprintf(stderr, "Usage: %s [options] [command]\n", _nc_progname);
    +    if (optstring != NULL) {
    +	const char *s = msg;
    +	while (*s != '\0') {
    +	    fputc(UChar(*s), stderr);
    +	    if (!strncmp(s, "  -", 3)) {
    +		if (strchr(optstring, s[3]) == NULL)
    +		    s = strchr(s, '\n') + 1;
    +	    } else if (!strncmp(s, "\n\nC", 3))
    +		break;
    +	    ++s;
    +	}
    +    } else {
    +	fputs(msg, stderr);
    +    }
         ExitProgram(ErrUsage);
     }
     
    @@ -156,7 +168,7 @@ tput_cmd(int fd, TTY * settings, bool opt_x, int argc, char **argv, int *used)
     
     	if (is_reset) {
     	    reset_start(stdout, TRUE, FALSE);
    -	    reset_tty_settings(fd, settings);
    +	    reset_tty_settings(fd, settings, FALSE);
     	} else {
     	    reset_start(stdout, FALSE, TRUE);
     	}
    @@ -329,11 +341,12 @@ main(int argc, char **argv)
         bool is_alias;
         bool need_tty;
     
    -    prg_name = check_aliases(_nc_rootname(argv[0]), TRUE);
    +    _nc_progname = check_aliases(_nc_rootname(argv[0]), TRUE);
    +    is_alias = (is_clear || is_reset || is_init);
     
         term = getenv("TERM");
     
    -    while ((c = getopt(argc, argv, "ST:Vx")) != -1) {
    +    while ((c = getopt(argc, argv, is_alias ? "T:Vx" : "ST:Vx")) != -1) {
     	switch (c) {
     	case 'S':
     	    cmdline = FALSE;
    @@ -350,12 +363,11 @@ main(int argc, char **argv)
     	    opt_x = TRUE;
     	    break;
     	default:
    -	    usage();
    +	    usage(is_alias ? "TVx" : NULL);
     	    /* NOTREACHED */
     	}
         }
     
    -    is_alias = (is_clear || is_reset || is_init);
         need_tty = ((is_reset || is_init) ||
     		(optind < argc &&
     		 (!strcmp(argv[optind], "reset") ||
    @@ -369,7 +381,7 @@ main(int argc, char **argv)
     	    argc -= optind;
     	    argv += optind;
     	}
    -	argv[0] = prg_name;
    +	argv[0] = strdup(_nc_progname);
         } else {
     	argc -= optind;
     	argv += optind;
    @@ -386,7 +398,7 @@ main(int argc, char **argv)
         if (cmdline) {
     	int code = 0;
     	if ((argc <= 0) && !is_alias)
    -	    usage();
    +	    usage(NULL);
     	while (argc > 0) {
     	    code = tput_cmd(fd, &tty_settings, opt_x, argc, argv, &used);
     	    if (code != 0)
    diff --git a/progs/tset.c b/progs/tset.c
    index 7fd91634..62611b3d 100644
    --- a/progs/tset.c
    +++ b/progs/tset.c
    @@ -98,7 +98,7 @@
     char *ttyname(int fd);
     #endif
     
    -MODULE_ID("$Id: tset.c,v 1.128 2021/04/03 23:03:48 tom Exp $")
    +MODULE_ID("$Id: tset.c,v 1.130 2021/10/02 18:08:09 tom Exp $")
     
     #ifndef environ
     extern char **environ;
    @@ -775,6 +775,7 @@ main(int argc, char **argv)
         bool opt_w = FALSE;		/* set window-size */
         TTY mode, oldmode;
     
    +    _nc_progname = _nc_rootname(*argv);
         obsolete(argv);
         noinit = noset = quiet = Sflag = sflag = showterm = 0;
         while ((ch = getopt(argc, argv, "a:cd:e:Ii:k:m:p:qQrSsVw")) != -1) {
    @@ -833,7 +834,6 @@ main(int argc, char **argv)
     	}
         }
     
    -    _nc_progname = _nc_rootname(*argv);
         argc -= optind;
         argv += optind;
     
    @@ -855,7 +855,7 @@ main(int argc, char **argv)
     
         if (same_program(_nc_progname, PROG_RESET)) {
     	reset_start(stderr, TRUE, FALSE);
    -	reset_tty_settings(my_fd, &mode);
    +	reset_tty_settings(my_fd, &mode, noset);
         } else {
     	reset_start(stderr, FALSE, TRUE);
         }
    -- 
    2.45.0