From: Thomas E. Dickey Date: Sun, 9 Dec 2018 02:29:47 +0000 (+0000) Subject: ncurses 6.1 - patch 20181208 X-Git-Tag: v6.2~60 X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=commitdiff_plain;h=321b81e6b3fa425daddac02420d862100dc3aac8;hp=31418a0e4a6f75ceffc9fee20ddbe390209a4ef4 ncurses 6.1 - patch 20181208 + modify wbkgd() and wbkgrnd() to improve compatibility with SVr4 curses, changing the way the window rendition is updated when the background character is modified (report by Valery Ushakov). --- diff --git a/NEWS b/NEWS index 27e2f56a..06392ce0 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.3225 2018/12/01 20:59:08 tom Exp $ +-- $Id: NEWS,v 1.3227 2018/12/08 23:02:39 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,11 @@ See the AUTHORS file for the corresponding full names. Changes through 1.9.9e did not credit all contributions; it is not possible to add this information. +20181208 + + modify wbkgd() and wbkgrnd() to improve compatibility with SVr4 + curses, changing the way the window rendition is updated when the + background character is modified (report by Valery Ushakov). + 20181201 + add midnightbsd to CF_XOPEN_SOURCE macro (patch by Urs Jansen). + add "@" command to test/ncurses F-test, to allow rapid jump to diff --git a/VERSION b/VERSION index 1cdeb474..ef14eb02 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5:0:10 6.1 20181201 +5:0:10 6.1 20181208 diff --git a/dist.mk b/dist.mk index fba98a8b..cf868bef 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.1254 2018/11/30 23:49:03 tom Exp $ +# $Id: dist.mk,v 1.1255 2018/12/08 16:21:26 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -37,7 +37,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 6 NCURSES_MINOR = 1 -NCURSES_PATCH = 20181201 +NCURSES_PATCH = 20181208 # 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 2e1cde2b..235e07f3 100644 --- a/doc/html/man/adacurses6-config.1.html +++ b/doc/html/man/adacurses6-config.1.html @@ -125,7 +125,7 @@

SEE ALSO

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

SEE ALSO

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

AUTHOR

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

SEE ALSO

        tput(1), terminfo(5)
 
-       This describes ncurses version 6.1 (patch 20180901).
+       This describes ncurses version 6.1 (patch 20181208).
 
 
 
diff --git a/doc/html/man/curs_bkgd.3x.html b/doc/html/man/curs_bkgd.3x.html
index b5637820..a96929f4 100644
--- a/doc/html/man/curs_bkgd.3x.html
+++ b/doc/html/man/curs_bkgd.3x.html
@@ -26,7 +26,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_bkgd.3x,v 1.26 2018/07/28 21:34:06 tom Exp @
+  * @Id: curs_bkgd.3x,v 1.28 2018/12/09 00:45:05 tom Exp @
 -->
 
 
@@ -81,14 +81,46 @@
 

bkgd

        The bkgd and wbkgd functions set the background property of the current
        or  specified  window  and  then  apply this setting to every character
-       position in that window:
+       position in that window.  According to  X/Open  Curses,  it  should  do
+       this:
 
-       o   The rendition of every character on the screen is  changed  to  the
+       o   The  rendition  of  every character on the screen is changed to the
            new background rendition.
 
-       o   Wherever  the former background character appears, it is changed to
+       o   Wherever the former background character appears, it is changed  to
            the new background character.
 
+       Neither  X/Open Curses nor the SVr4 manual pages give details about the
+       way the rendition of characters on the screen is updated when  bkgd  or
+       wbkgd is used to change the background character.
+
+       This  implementation,  like  SVr4 curses, does not store the background
+       and window attribute contributions to each cell separately.  It updates
+       the rendition by comparing the character, non-color attributes and col-
+       ors contained in the background.  For each cell in the window,  whether
+       or not it is blank:
+
+       o   The  library  first  compares  the character, and if it matches the
+           current character part of the background, it replaces that with the
+           new background character.
+
+       o   The  library  then  checks  if the cell uses color, i.e., its color
+           pair value is nonzero.  If not, it simply replaces  the  attributes
+           and color pair in the cell with those from the new background char-
+           acter.
+
+       o   If the cell uses color, and that matches the color in  the  current
+           background, the library removes attributes which may have come from
+           the current background and adds attributes from the new background.
+           It finishes by setting the cell to use the color from the new back-
+           ground.
+
+       o   If the cell uses color, and that does not match the  color  in  the
+           current   background,   the  library  updates  only  the  non-color
+           attributes, first removing those which may have come from the  cur-
+           rent  background,  and  then  adding  attributes from the new back-
+           ground.
+
 
 

getbkgd

        The getbkgd function returns  the  given  window's  current  background
@@ -96,19 +128,32 @@
 
 
 

RETURN VALUE

-       The  routines  bkgd and wbkgd return the integer OK.  The SVr4.0 manual
-       says "or a non-negative integer if immedok is set", but this appears to
-       be an error.
+       These  functions are described in the XSI Curses standard, Issue 4.  It
+       specifies that bkgd and wbkgd return ERR on failure, but gives no fail-
+       ure conditions.
+
+       The  routines  bkgd and wbkgd return the integer OK, unless the library
+       has not been initialized.
+
+       In contrast, the SVr4.0 manual says bkgd and wbkgd may return OK "or  a
+       non-negative  integer  if  immedok  is set", which refers to the return
+       value from wrefresh (used to implement the immediate repainting).   The
+       SVr4  curses  wrefresh  returns the number of characters written to the
+       screen during the refresh.  This implementation does not do that.
 
 
 

NOTES

        Note that bkgdset and bkgd may be macros.
 
+       X/Open Curses mentions that the character part of the  background  must
+       be  a  single-byte  value.   This  implementation, like SVr4, checks to
+       ensure that, and will reuse the old background character if  the  check
+       fails.
+
 
 

PORTABILITY

-       These  functions are described in the XSI Curses standard, Issue 4.  It
-       specifies that bkgd and wbkgd return ERR on failure, but gives no fail-
-       ure conditions.
+       These  functions  are  described  in  the  XSI Curses standard, Issue 4
+       (X/Open Curses).
 
 
 

SEE ALSO

diff --git a/doc/html/man/curs_bkgrnd.3x.html b/doc/html/man/curs_bkgrnd.3x.html
index 4d03fd1b..7d952f0c 100644
--- a/doc/html/man/curs_bkgrnd.3x.html
+++ b/doc/html/man/curs_bkgrnd.3x.html
@@ -26,7 +26,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_bkgrnd.3x,v 1.9 2018/07/28 21:34:06 tom Exp @
+  * @Id: curs_bkgrnd.3x,v 1.10 2018/12/09 00:50:50 tom Exp @
 -->
 
 
@@ -100,6 +100,10 @@
 

NOTES

        Note that bkgrnd, bkgrndset, and getbkgrnd may be macros.
 
+       X/Open Curses does not provide details on how the rendition is changed.
+       This  implementation follows the approach used in SVr4 curses, which is
+       explained in the manual page for wbkgd.
+
 
 

RETURN VALUE

        The bkgrndset and wbkgrndset routines do not return a value.
@@ -112,6 +116,11 @@
        o   A null character pointer is treated as an error.
 
 
+

PORTABILITY

+       These  functions  are  described  in  the  XSI Curses standard, Issue 4
+       (X/Open Curses).
+
+
 

SEE ALSO

        curses(3x), curs_bkgd(3x)
 
@@ -132,6 +141,7 @@
 
 
  • NOTES
  • RETURN VALUE
  • +
  • PORTABILITY
  • SEE ALSO
  • diff --git a/doc/html/man/form.3x.html b/doc/html/man/form.3x.html index 11c5bff9..2fba6951 100644 --- a/doc/html/man/form.3x.html +++ b/doc/html/man/form.3x.html @@ -246,7 +246,7 @@ curses(3x) and related pages whose names begin "form_" for detailed descriptions of the entry points. - This describes ncurses version 6.1 (patch 20180901). + This describes ncurses version 6.1 (patch 20181208). diff --git a/doc/html/man/infocmp.1m.html b/doc/html/man/infocmp.1m.html index ae6e07b9..f93f94d4 100644 --- a/doc/html/man/infocmp.1m.html +++ b/doc/html/man/infocmp.1m.html @@ -481,7 +481,7 @@ https://invisible-island.net/ncurses/tctest.html - This describes ncurses version 6.1 (patch 20180901). + This describes ncurses version 6.1 (patch 20181208).

    AUTHOR

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

    SEE ALSO

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

    AUTHOR

    diff --git a/doc/html/man/menu.3x.html b/doc/html/man/menu.3x.html
    index cc374e1f..7a54da3c 100644
    --- a/doc/html/man/menu.3x.html
    +++ b/doc/html/man/menu.3x.html
    @@ -221,7 +221,7 @@
            curses(3x)  and  related  pages  whose names begin "menu_" for detailed
            descriptions of the entry points.
     
    -       This describes ncurses version 6.1 (patch 20180901).
    +       This describes ncurses version 6.1 (patch 20181208).
     
     
     
    diff --git a/doc/html/man/ncurses.3x.html b/doc/html/man/ncurses.3x.html
    index ae4f63c7..092c974c 100644
    --- a/doc/html/man/ncurses.3x.html
    +++ b/doc/html/man/ncurses.3x.html
    @@ -59,7 +59,7 @@
            method of updating  character  screens  with  reasonable  optimization.
            This  implementation  is  "new  curses"  (ncurses)  and is the approved
            replacement for 4.4BSD classic curses,  which  has  been  discontinued.
    -       This describes ncurses version 6.1 (patch 20180901).
    +       This describes ncurses version 6.1 (patch 20181208).
     
            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 f19bcf16..2b0cd4e1 100644
    --- a/doc/html/man/ncurses6-config.1.html
    +++ b/doc/html/man/ncurses6-config.1.html
    @@ -112,7 +112,7 @@
     

    SEE ALSO

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

    SEE ALSO

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

    AUTHOR

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

    SEE ALSO

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

    Terminfo Entry Syntax

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

    AUTHOR

    diff --git a/doc/html/man/toe.1m.html b/doc/html/man/toe.1m.html
    index 13872498..f0705592 100644
    --- a/doc/html/man/toe.1m.html
    +++ b/doc/html/man/toe.1m.html
    @@ -113,7 +113,7 @@
            tic(1m), infocmp(1m), captoinfo(1m),  infotocap(1m),  curses(3x),  ter-
            minfo(5).
     
    -       This describes ncurses version 6.1 (patch 20180901).
    +       This describes ncurses version 6.1 (patch 20181208).
     
     
     
    diff --git a/doc/html/man/tput.1.html b/doc/html/man/tput.1.html
    index 65c76c9d..afa3be2a 100644
    --- a/doc/html/man/tput.1.html
    +++ b/doc/html/man/tput.1.html
    @@ -27,7 +27,7 @@
       * sale, use or other dealings in this Software without prior written       *
       * authorization.                                                           *
       ****************************************************************************
    -  * @Id: tput.1,v 1.61 2018/08/25 23:28:12 tom Exp @
    +  * @Id: tput.1,v 1.62 2018/09/30 20:31:59 Sven.Joachim Exp @
     -->
     
     
    @@ -505,7 +505,7 @@
     
            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.
    +           xcurses uses the term "invalid" in this case.
     
            o   It  assigns  exit code 255 to a numeric variable that is not speci-
                fied in the terminfo database.   That  likely  is  a  documentation
    @@ -522,7 +522,7 @@
     

    SEE ALSO

            clear(1), stty(1), tabs(1), tset(1), terminfo(5), curs_termcap(3x).
     
    -       This describes ncurses version 6.1 (patch 20180901).
    +       This describes ncurses version 6.1 (patch 20181208).
     
     
     
    diff --git a/doc/html/man/tset.1.html b/doc/html/man/tset.1.html
    index 57f34822..43ab7e46 100644
    --- a/doc/html/man/tset.1.html
    +++ b/doc/html/man/tset.1.html
    @@ -389,7 +389,7 @@
            csh(1),  sh(1),  stty(1),   curs_terminfo(3x),   tty(4),   terminfo(5),
            ttys(5), environ(7)
     
    -       This describes ncurses version 6.1 (patch 20180901).
    +       This describes ncurses version 6.1 (patch 20181208).
     
     
     
    diff --git a/man/curs_bkgd.3x b/man/curs_bkgd.3x
    index 2dc21e6a..d93bbd4a 100644
    --- a/man/curs_bkgd.3x
    +++ b/man/curs_bkgd.3x
    @@ -26,7 +26,7 @@
     .\" authorization.                                                           *
     .\"***************************************************************************
     .\"
    -.\" $Id: curs_bkgd.3x,v 1.26 2018/07/28 21:34:06 tom Exp $
    +.\" $Id: curs_bkgd.3x,v 1.28 2018/12/09 00:45:05 tom Exp $
     .de bP
     .ie n  .IP \(bu 4
     .el    .IP \(bu 2
    @@ -57,8 +57,7 @@ The window background is a \fBchtype\fR consisting of
     any combination of attributes (i.e., rendition) and a character.
     The attribute part of the background is combined (OR'ed) with all non-blank
     characters that are written into the window with \fBwaddch\fR.
    -Both
    -the character and attribute parts of the background are combined with
    +Both the character and attribute parts of the background are combined with
     the blank characters.
     The background becomes a property of the
     character and moves with the character through any scrolling and
    @@ -71,7 +70,8 @@ as the graphic rendition of the character put on the screen.
     .PP
     The \fBbkgd\fR and \fBwbkgd\fR functions
     set the background property of the current or specified window
    -and then apply this setting to every character position in that window:
    +and then apply this setting to every character position in that window.
    +According to X/Open Curses, it should do this:
     .PP
     .bP
     The rendition of every character on the screen is changed to
    @@ -79,23 +79,72 @@ the new background rendition.
     .bP
     Wherever the former background character
     appears, it is changed to the new background character.
    +.PP
    +Neither X/Open Curses nor the SVr4 manual pages give details about
    +the way the rendition of characters on the screen is updated when
    +\fBbkgd\fP or \fBwbkgd\fP is used to change the background character.
    +.PP
    +This implementation, like SVr4 curses, does not store the background
    +and window attribute contributions to each cell separately.
    +It updates the rendition by comparing the character, non-color attributes and
    +colors contained in the background.
    +For each cell in the window, whether or not it is blank:
    +.bP
    +The library first compares the \fIcharacter\fP,
    +and if it matches the current character part of the background,
    +it replaces that with the new background character.
    +.bP
    +The library then checks if the cell uses color,
    +i.e., its color pair value is nonzero.
    +If not, it simply replaces the attributes and color pair in the
    +cell with those from the new background character.
    +.bP
    +If the cell uses color,
    +and that matches the color in the current background,
    +the library removes attributes
    +which may have come from the current background 
    +and adds attributes from the new background.
    +It finishes by setting the cell
    +to use the color from the new background.
    +.bP
    +If the cell uses color,
    +and that does not match the color in the current background,
    +the library updates only the non-color attributes,
    +first removing those which may have come from the current background,
    +and then adding attributes from the new background.
     .SS getbkgd
     .PP
     The \fBgetbkgd\fR function returns the given window's current background
     character/attribute pair.
     .SH RETURN VALUE
     .PP
    -The routines \fBbkgd\fR and \fBwbkgd\fR return the integer \fBOK\fR.
    -The SVr4.0 manual says "or a non-negative integer if \fBimmedok\fR is set",
    -but this appears to be an error.
    +These functions are described in the XSI Curses standard, Issue 4.
    +It specifies that \fBbkgd\fR and \fBwbkgd\fR return \fBERR\fR on failure,
    +but gives no failure conditions.
    +.PP
    +The routines \fBbkgd\fR and \fBwbkgd\fR return the integer \fBOK\fR,
    +unless the library has not been initialized.
    +.PP
    +In contrast,
    +the SVr4.0 manual says \fBbkgd\fR and \fBwbkgd\fR may return \fBOK\fP
    +"or a non-negative integer if \fBimmedok\fR is set",
    +which refers to the return value from \fBwrefresh\fP
    +(used to implement the immediate repainting).
    +The SVr4 curses \fBwrefresh\fP returns the number of characters
    +written to the screen during the refresh.
    +This implementation does not do that.
     .SH NOTES
     .PP
     Note that \fBbkgdset\fR and \fBbkgd\fR may be macros.
    +.PP
    +X/Open Curses mentions that the character part of the background must
    +be a single-byte value.
    +This implementation, like SVr4, checks to ensure that,
    +and will reuse the old background character if the check fails.
     .SH PORTABILITY
     .PP
    -These functions are described in the XSI Curses standard, Issue 4.
    -It specifies that \fBbkgd\fR and \fBwbkgd\fR return \fBERR\fR on failure,
    -but gives no failure conditions.
    +These functions are described in the XSI Curses standard, Issue 4
    +(X/Open Curses).
     .SH SEE ALSO
     .na
     .PP
    diff --git a/man/curs_bkgrnd.3x b/man/curs_bkgrnd.3x
    index 8a092022..78ee92e1 100644
    --- a/man/curs_bkgrnd.3x
    +++ b/man/curs_bkgrnd.3x
    @@ -26,7 +26,7 @@
     .\" authorization.                                                           *
     .\"***************************************************************************
     .\"
    -.\" $Id: curs_bkgrnd.3x,v 1.9 2018/07/28 21:34:06 tom Exp $
    +.\" $Id: curs_bkgrnd.3x,v 1.10 2018/12/09 00:50:50 tom Exp $
     .de bP
     .ie n  .IP \(bu 4
     .el    .IP \(bu 2
    @@ -97,6 +97,10 @@ Note that
     \fBbkgrndset\fR, and
     \fBgetbkgrnd\fR
     may be macros.
    +.PP
    +X/Open Curses does not provide details on how the rendition is changed.
    +This implementation follows the approach used in SVr4 curses,
    +which is explained in the manual page for \fBwbkgd\fP.
     .SH RETURN VALUE
     .PP
     The \fBbkgrndset\fR and \fBwbkgrndset\fR routines do not return a value.
    @@ -107,6 +111,10 @@ Otherwise, they return \fBERR\fR:
     A null window pointer is treated as an error.
     .bP
     A null character pointer is treated as an error.
    +.SH PORTABILITY
    +.PP
    +These functions are described in the XSI Curses standard, Issue 4
    +(X/Open Curses).
     .SH SEE ALSO
     \fBcurses\fR(3X),
     \fBcurs_bkgd\fR(3X)
    diff --git a/ncurses/base/lib_bkgd.c b/ncurses/base/lib_bkgd.c
    index 5dfe5c6d..d0d39d84 100644
    --- a/ncurses/base/lib_bkgd.c
    +++ b/ncurses/base/lib_bkgd.c
    @@ -1,5 +1,5 @@
     /****************************************************************************
    - * Copyright (c) 1998-2014,2016 Free Software Foundation, Inc.              *
    + * Copyright (c) 1998-2016,2018 Free Software Foundation, Inc.              *
      *                                                                          *
      * Permission is hereby granted, free of charge, to any person obtaining a  *
      * copy of this software and associated documentation files (the            *
    @@ -36,7 +36,7 @@
     
     #include 
     
    -MODULE_ID("$Id: lib_bkgd.c,v 1.50 2016/05/28 23:11:26 tom Exp $")
    +MODULE_ID("$Id: lib_bkgd.c,v 1.52 2018/12/09 00:09:17 tom Exp $")
     
     /*
      * Set the window's background information.
    @@ -117,31 +117,86 @@ static NCURSES_INLINE int
     #endif
     wbkgrnd(WINDOW *win, const ARG_CH_T ch)
     {
    +#undef  SP_PARM
    +#define SP_PARM SP		/* to use Charable() */
         int code = ERR;
     
         T((T_CALLED("wbkgd(%p,%s)"), (void *) win, _tracech_t(ch)));
     
    -    if (win) {
    +    if (SP == 0) {
    +	;
    +    } else if (win) {
     	NCURSES_CH_T new_bkgd = CHDEREF(ch);
    -	NCURSES_CH_T old_bkgrnd;
    +	NCURSES_CH_T old_bkgd;
     	int y;
    +	NCURSES_CH_T old_char;
    +	attr_t old_attr;
    +	int old_pair;
    +	NCURSES_CH_T new_char;
    +	attr_t new_attr;
    +	int new_pair;
    +
    +	/* SVr4 trims color info if non-color terminal */
    +	if (!SP->_pair_limit) {
    +	    RemAttr(new_bkgd, A_COLOR);
    +	    SetPair(new_bkgd, 0);
    +	}
     
    -	memset(&old_bkgrnd, 0, sizeof(old_bkgrnd));
    -	(void) wgetbkgrnd(win, &old_bkgrnd);
    +	memset(&old_bkgd, 0, sizeof(old_bkgd));
    +	(void) wgetbkgrnd(win, &old_bkgd);
    +
    +	old_char = old_bkgd;
    +	RemAttr(old_char, ~A_CHARTEXT);
    +	old_attr = AttrOf(old_bkgd);
    +	old_pair = GetPair(old_bkgd);
    +
    +	if (!(old_attr & A_COLOR)) {
    +	    old_pair = 0;
    +	}
    +
    +	new_char = new_bkgd;
    +	RemAttr(new_char, ~A_CHARTEXT);
    +	new_attr = AttrOf(new_bkgd);
    +	new_pair = GetPair(new_bkgd);
    +
    +	/* SVr4 limits background character to printable 7-bits */
    +	if (!Charable(new_bkgd)) {
    +	    new_char = old_char;
    +	}
     
     	(void) wbkgrndset(win, CHREF(new_bkgd));
    -	(void) wattrset(win, (int) AttrOf(win->_nc_bkgd));
    +
    +	/* SVr4 updates color pair if old/new match, otherwise just attrs */
    +	if ((new_pair != 0) && (new_pair == old_pair)) {
    +	    SetAttr(win->_nc_bkgd, new_attr);
    +	    SetPair(win->_nc_bkgd, new_pair);
    +	} else {
    +	    SetAttr(win->_nc_bkgd, new_attr);
    +	}
     
     	for (y = 0; y <= win->_maxy; y++) {
     	    int x;
     
     	    for (x = 0; x <= win->_maxx; x++) {
    -		if (CharEq(win->_line[y].text[x], old_bkgrnd)) {
    -		    win->_line[y].text[x] = win->_nc_bkgd;
    +		NCURSES_CH_T *cp = &(win->_line[y].text[x]);
    +		int tmp_pair = GetPair(*cp);
    +		attr_t tmp_attr = AttrOf(*cp);
    +
    +		if (CharEq(*cp, old_bkgd)) {
    +		    SetChar2(*cp, CharOf(new_char));
    +		}
    +		if (tmp_pair != 0) {
    +		    if (tmp_pair == old_pair) {
    +			SetAttr(*cp, (tmp_attr & ~old_attr) | new_attr);
    +			SetPair(*cp, new_pair);
    +		    } else {
    +			SetAttr(*cp,
    +				(tmp_attr & (~old_attr | A_COLOR))
    +				| (new_attr & ALL_BUT_COLOR));
    +		    }
     		} else {
    -		    NCURSES_CH_T wch = win->_line[y].text[x];
    -		    RemAttr(wch, (~(A_ALTCHARSET | A_CHARTEXT)));
    -		    win->_line[y].text[x] = _nc_render(win, wch);
    +		    SetAttr(*cp, new_attr);
    +		    SetPair(*cp, new_pair);
     		}
     	    }
     	}
    diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog
    index 3ca5cb2c..d1ac9873 100644
    --- a/package/debian-mingw/changelog
    +++ b/package/debian-mingw/changelog
    @@ -1,8 +1,8 @@
    -ncurses6 (6.1+20181201) unstable; urgency=low
    +ncurses6 (6.1+20181208) unstable; urgency=low
     
       * latest weekly patch
     
    - -- Thomas E. Dickey   Fri, 30 Nov 2018 18:49:03 -0500
    + -- Thomas E. Dickey   Sat, 08 Dec 2018 11:21:26 -0500
     
     ncurses6 (5.9-20131005) unstable; urgency=low
     
    diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog
    index 3ca5cb2c..d1ac9873 100644
    --- a/package/debian-mingw64/changelog
    +++ b/package/debian-mingw64/changelog
    @@ -1,8 +1,8 @@
    -ncurses6 (6.1+20181201) unstable; urgency=low
    +ncurses6 (6.1+20181208) unstable; urgency=low
     
       * latest weekly patch
     
    - -- Thomas E. Dickey   Fri, 30 Nov 2018 18:49:03 -0500
    + -- Thomas E. Dickey   Sat, 08 Dec 2018 11:21:26 -0500
     
     ncurses6 (5.9-20131005) unstable; urgency=low
     
    diff --git a/package/debian/changelog b/package/debian/changelog
    index 6c78595b..02851aec 100644
    --- a/package/debian/changelog
    +++ b/package/debian/changelog
    @@ -1,8 +1,8 @@
    -ncurses6 (6.1+20181201) unstable; urgency=low
    +ncurses6 (6.1+20181208) unstable; urgency=low
     
       * latest weekly patch
     
    - -- Thomas E. Dickey   Fri, 30 Nov 2018 18:49:03 -0500
    + -- Thomas E. Dickey   Sat, 08 Dec 2018 11:21:26 -0500
     
     ncurses6 (5.9-20120608) unstable; urgency=low
     
    diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi
    index fa6af386..0974dd66 100644
    --- a/package/mingw-ncurses.nsi
    +++ b/package/mingw-ncurses.nsi
    @@ -1,4 +1,4 @@
    -; $Id: mingw-ncurses.nsi,v 1.301 2018/11/30 23:49:03 tom Exp $
    +; $Id: mingw-ncurses.nsi,v 1.302 2018/12/08 16:21:26 tom Exp $
     
     ; TODO add examples
     ; TODO bump ABI to 6
    @@ -10,7 +10,7 @@
     !define VERSION_MAJOR "6"
     !define VERSION_MINOR "1"
     !define VERSION_YYYY  "2018"
    -!define VERSION_MMDD  "1201"
    +!define VERSION_MMDD  "1208"
     !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD}
     
     !define MY_ABI   "5"
    diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec
    index 5d1a5b68..b247b2b4 100644
    --- a/package/mingw-ncurses.spec
    +++ b/package/mingw-ncurses.spec
    @@ -3,7 +3,7 @@
     Summary: shared libraries for terminal handling
     Name: mingw32-ncurses6
     Version: 6.1
    -Release: 20181201
    +Release: 20181208
     License: X11
     Group: Development/Libraries
     Source: ncurses-%{version}-%{release}.tgz
    diff --git a/package/ncurses.spec b/package/ncurses.spec
    index f8c4fbed..7c438cc4 100644
    --- a/package/ncurses.spec
    +++ b/package/ncurses.spec
    @@ -1,7 +1,7 @@
     Summary: shared libraries for terminal handling
     Name: ncurses6
     Version: 6.1
    -Release: 20181201
    +Release: 20181208
     License: X11
     Group: Development/Libraries
     Source: ncurses-%{version}-%{release}.tgz
    diff --git a/package/ncursest.spec b/package/ncursest.spec
    index 6188b702..505974c2 100644
    --- a/package/ncursest.spec
    +++ b/package/ncursest.spec
    @@ -1,7 +1,7 @@
     Summary: Curses library with POSIX thread support.
     Name: ncursest6
     Version: 6.1
    -Release: 20181201
    +Release: 20181208
     License: X11
     Group: Development/Libraries
     Source: ncurses-%{version}-%{release}.tgz