From 6662c1ccb49cb09d0f2cec2ec6150410a0fd0f7f Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sun, 24 Jul 2022 22:50:11 +0000 Subject: [PATCH] ncurses 6.3 - patch 20220724 + add portability notes for delscreen and delwin in manual. + improve pthread-configuration for test/worm.c, test/rain.c + improve pointer/limit checks associated with deleting a screen (Debian #1015756). --- NEWS | 8 ++++++- VERSION | 2 +- dist.mk | 4 ++-- doc/html/man/adacurses6-config.1.html | 2 +- doc/html/man/captoinfo.1m.html | 2 +- doc/html/man/clear.1.html | 2 +- doc/html/man/curs_initscr.3x.html | 30 +++++++++++++++++++---- doc/html/man/curs_window.3x.html | 23 ++++++++++++++++-- doc/html/man/form.3x.html | 2 +- doc/html/man/infocmp.1m.html | 2 +- doc/html/man/infotocap.1m.html | 2 +- doc/html/man/menu.3x.html | 2 +- doc/html/man/ncurses.3x.html | 2 +- doc/html/man/ncurses6-config.1.html | 2 +- doc/html/man/panel.3x.html | 2 +- doc/html/man/tabs.1.html | 2 +- doc/html/man/terminfo.5.html | 2 +- doc/html/man/tic.1m.html | 2 +- doc/html/man/toe.1m.html | 2 +- doc/html/man/tput.1.html | 2 +- doc/html/man/tset.1.html | 2 +- doc/html/man/user_caps.5.html | 4 ++-- man/curs_initscr.3x | 29 +++++++++++++++++++++-- man/curs_window.3x | 21 ++++++++++++++++- ncurses/base/lib_set_term.c | 8 +++++-- ncurses/tinfo/lib_setup.c | 4 ++-- ncurses/tinfo/lib_tputs.c | 9 +++---- ncurses/trace/lib_trace.c | 22 ++++++++++++----- ncurses/tty/tty_update.c | 16 +++++++++---- 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 +- test/rain.c | 23 ++++++++++++++---- test/test_mouse.c | 14 +++++------ test/worm.c | 34 +++++++++++++++++++++++---- 39 files changed, 227 insertions(+), 78 deletions(-) diff --git a/NEWS b/NEWS index 08fdee8d..cc91b40d 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.3831 2022/07/16 18:43:58 tom Exp $ +-- $Id: NEWS,v 1.3836 2022/07/24 10:06:18 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -46,6 +46,12 @@ 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. +20220724 + + add portability notes for delscreen and delwin in manual. + + improve pthread-configuration for test/worm.c, test/rain.c + + improve pointer/limit checks associated with deleting a screen + (Debian #1015756). + 20220716 + build-fix for test_mouse.c, for non-standard cfmakeraw. + improve shell-scripts with shellcheck diff --git a/VERSION b/VERSION index 4f88e782..ec9534b9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5:0:10 6.3 20220716 +5:0:10 6.3 20220724 diff --git a/dist.mk b/dist.mk index 0f350b28..928c6d6b 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.1492 2022/07/16 10:45:29 tom Exp $ +# $Id: dist.mk,v 1.1494 2022/07/24 09:45:40 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 = 3 -NCURSES_PATCH = 20220716 +NCURSES_PATCH = 20220724 # 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 257b5234..e1e4b8e3 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.3 (patch 20220703).
+       This describes ncurses version 6.3 (patch 20220724).
 
 
 
diff --git a/doc/html/man/captoinfo.1m.html b/doc/html/man/captoinfo.1m.html
index 8671ed66..522f97be 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.3 (patch 20220703).
+       This describes ncurses version 6.3 (patch 20220724).
 
 
 

AUTHOR

diff --git a/doc/html/man/clear.1.html b/doc/html/man/clear.1.html
index db2a0edf..94ba5d55 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), xterm(1).
 
-       This describes ncurses version 6.3 (patch 20220703).
+       This describes ncurses version 6.3 (patch 20220724).
 
 
 
diff --git a/doc/html/man/curs_initscr.3x.html b/doc/html/man/curs_initscr.3x.html
index f7600061..08d21a61 100644
--- a/doc/html/man/curs_initscr.3x.html
+++ b/doc/html/man/curs_initscr.3x.html
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_initscr.3x,v 1.37 2022/02/12 20:07:29 tom Exp @
+  * @Id: curs_initscr.3x,v 1.39 2022/07/24 15:46:49 tom Exp @
 -->
 
 
@@ -174,9 +174,31 @@
 
        o   This implementation allows using initscr after endwin.
 
-       Old versions of curses, e.g., BSD 4.4, may have returned a null pointer
-       from initscr when an error is detected, rather  than  exiting.   It  is
-       safe but redundant to check the return value of initscr in XSI Curses.
+       Old versions of curses, e.g., BSD 4.4, would return a null pointer from
+       initscr when an error is detected, rather than exiting.  It is safe but
+       redundant to check the return value of initscr in XSI Curses.
+
+       Calling  endwin  does not dispose of the memory allocated in initscr or
+       newterm.  Deleting a SCREEN provides a way to do this:
+
+       o   X/Open Curses does not say what happens to WINDOWs  when  delscreen
+           "frees  storage associated with the SCREEN" nor does the SVr4 docu-
+           mentation help, adding that it should be called after endwin  if  a
+           SCREEN is no longer needed.
+
+       o   However,  WINDOWs are implicitly associated with a SCREEN.  so that
+           it is reasonable to expect delscreen to deal with these.
+
+       o   SVr4 curses deletes  the  standard  WINDOW  structures  stdscr  and
+           curscr  as  well  as a work area newscr.  SVr4 curses ignores other
+           windows.
+
+       o   Since version 4.0 (1996), ncurses has maintained a list of all win-
+           dows  for  each screen, using that information to delete those win-
+           dows when delscreen is called.
+
+       o   NetBSD copied this feature of ncurses in  2001.   PDCurses  follows
+           the SVr4 model, deleting only the standard WINDOW structures.
 
 
 

Unset TERM Variable

diff --git a/doc/html/man/curs_window.3x.html b/doc/html/man/curs_window.3x.html
index 9583670b..1bd25353 100644
--- a/doc/html/man/curs_window.3x.html
+++ b/doc/html/man/curs_window.3x.html
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_window.3x,v 1.25 2022/02/12 20:06:41 tom Exp @
+  * @Id: curs_window.3x,v 1.27 2022/07/24 15:35:15 tom Exp @
 -->
 
 
@@ -229,9 +229,28 @@
 

PORTABILITY

        The XSI Curses standard, Issue 4 describes these functions.
 
+       X/Open Curses states regarding delwin:
+
+       o   It must delete subwindows before deleting their parent.
+
+       o   If  delwin  is asked to delete a parent window, it can only succeed
+           if the curses library keeps a list of the subwindows.  SVr4  curses
+           kept  a  count  of the number of subwindows rather than a list.  It
+           simply returned ERR when asked  to  delete  a  subwindow.   Solaris
+           X/Open curses does not even make that check, and will delete a par-
+           ent window which still has subwindows.
+
+       o   Since release 4.0 (1996), ncurses maintains a list of  windows  for
+           each  screen,  and  is  able  to recursively delete subwindows when
+           asked to delete their parent.
+
+       o   NetBSD copied this feature of ncurses in 2003.
+           PDCurses follows the scheme used in Solaris X/Open curses.
+
 
 

SEE ALSO

-       curses(3x), curs_refresh(3x), curs_touch(3x), curs_variables(3x)
+       curses(3x),   curs_initscr(3x),    curs_refresh(3x),    curs_touch(3x),
+       curs_variables(3x)
 
 
 
diff --git a/doc/html/man/form.3x.html b/doc/html/man/form.3x.html
index 5381b50b..ad408f0d 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.3 (patch 20220703).
+       This describes ncurses version 6.3 (patch 20220724).
 
 
 
diff --git a/doc/html/man/infocmp.1m.html b/doc/html/man/infocmp.1m.html
index bda0a7b5..79dff9ee 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.3 (patch 20220703).
+       This describes ncurses version 6.3 (patch 20220724).
 
 
 

AUTHOR

diff --git a/doc/html/man/infotocap.1m.html b/doc/html/man/infotocap.1m.html
index 29055404..c6c32f20 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.3 (patch 20220703).
+       This describes ncurses version 6.3 (patch 20220724).
 
 
 

AUTHOR

diff --git a/doc/html/man/menu.3x.html b/doc/html/man/menu.3x.html
index b1a45155..75529858 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.3 (patch 20220703).
+       This describes ncurses version 6.3 (patch 20220724).
 
 
 
diff --git a/doc/html/man/ncurses.3x.html b/doc/html/man/ncurses.3x.html
index 7cb2044d..93ff3ca2 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.3 (patch 20220703).
+       This describes ncurses version 6.3 (patch 20220724).
 
        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 d0860f9e..fc8193ec 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.3 (patch 20220703).
+       This describes ncurses version 6.3 (patch 20220724).
 
 
 
diff --git a/doc/html/man/panel.3x.html b/doc/html/man/panel.3x.html
index 0176a494..26dc1b18 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.3 (patch 20220703).
+       This describes ncurses version 6.3 (patch 20220724).
 
 
 

AUTHOR

diff --git a/doc/html/man/tabs.1.html b/doc/html/man/tabs.1.html
index 4d29b6c0..84cb384b 100644
--- a/doc/html/man/tabs.1.html
+++ b/doc/html/man/tabs.1.html
@@ -252,7 +252,7 @@
 

SEE ALSO

        infocmp(1m), tset(1), curses(3x), terminfo(5).
 
-       This describes ncurses version 6.3 (patch 20220703).
+       This describes ncurses version 6.3 (patch 20220724).
 
 
 
diff --git a/doc/html/man/terminfo.5.html b/doc/html/man/terminfo.5.html
index afafa7ae..a3ea785b 100644
--- a/doc/html/man/terminfo.5.html
+++ b/doc/html/man/terminfo.5.html
@@ -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.3 (patch 20220703).
+       This manual describes ncurses version 6.3 (patch 20220724).
 
 
 

Terminfo Entry Syntax

diff --git a/doc/html/man/tic.1m.html b/doc/html/man/tic.1m.html
index 2009919f..e4c99e14 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.3 (patch 20220703).
+       This describes ncurses version 6.3 (patch 20220724).
 
 
 

AUTHOR

diff --git a/doc/html/man/toe.1m.html b/doc/html/man/toe.1m.html
index 1963869f..d097fc10 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.3 (patch 20220703).
+       This describes ncurses version 6.3 (patch 20220724).
 
 
 
diff --git a/doc/html/man/tput.1.html b/doc/html/man/tput.1.html
index 46610227..8d68b72b 100644
--- a/doc/html/man/tput.1.html
+++ b/doc/html/man/tput.1.html
@@ -545,7 +545,7 @@
 

SEE ALSO

        clear(1), stty(1), tabs(1), tset(1), curs_termcap(3x), terminfo(5).
 
-       This describes ncurses version 6.3 (patch 20220703).
+       This describes ncurses version 6.3 (patch 20220724).
 
 
 
diff --git a/doc/html/man/tset.1.html b/doc/html/man/tset.1.html
index 796770b3..6359953e 100644
--- a/doc/html/man/tset.1.html
+++ b/doc/html/man/tset.1.html
@@ -391,7 +391,7 @@
        csh(1),   sh(1),   stty(1),   curs_terminfo(3x),  tty(4),  terminfo(5),
        ttys(5), environ(7)
 
-       This describes ncurses version 6.3 (patch 20220703).
+       This describes ncurses version 6.3 (patch 20220724).
 
 
 
diff --git a/doc/html/man/user_caps.5.html b/doc/html/man/user_caps.5.html
index 52d69b72..d99c5397 100644
--- a/doc/html/man/user_caps.5.html
+++ b/doc/html/man/user_caps.5.html
@@ -1,6 +1,6 @@
 
 
 
diff --git a/man/curs_initscr.3x b/man/curs_initscr.3x
index 17e5fb9c..5e17ead0 100644
--- a/man/curs_initscr.3x
+++ b/man/curs_initscr.3x
@@ -27,7 +27,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_initscr.3x,v 1.37 2022/02/12 20:07:29 tom Exp $
+.\" $Id: curs_initscr.3x,v 1.39 2022/07/24 15:46:49 tom Exp $
 .TH curs_initscr 3X ""
 .de bP
 .ie n  .IP \(bu 4
@@ -176,10 +176,35 @@ to restore the screen after \fBendwin\fP.
 .bP
 This implementation allows using \fBinitscr\fP after \fBendwin\fP.
 .PP
-Old versions of curses, e.g., BSD 4.4, may have returned a null pointer
+Old versions of curses, e.g., BSD 4.4, would return a null pointer
 from \fBinitscr\fP when an error is detected, rather than exiting.
 It is safe but redundant to check the return value of \fBinitscr\fP
 in XSI Curses.
+.PP
+Calling \fBendwin\fP does not dispose of the memory allocated in \fBinitscr\fP
+or \fBnewterm\fP.
+Deleting a \fBSCREEN\fP provides a way to do this:
+.bP
+X/Open Curses does not say what happens to \fBWINDOW\fPs when \fBdelscreen\fP
+\*(``frees storage associated with the \fBSCREEN\fP\*(''
+nor does the SVr4 documentation help,
+adding that it should be called after \fBendwin\fP if a \fBSCREEN\fP
+is no longer needed.
+.bP
+However, \fBWINDOW\fPs are implicitly associated with a \fBSCREEN\fP.
+so that it is reasonable to expect \fBdelscreen\fP to deal with these.
+.bP
+SVr4 curses deletes the standard \fBWINDOW\fP structures
+\fBstdscr\fP and \fBcurscr\fP as well as a work area \fBnewscr\fP.
+SVr4 curses ignores other windows.
+.bP
+Since version 4.0 (1996), ncurses has maintained a list of all windows
+for each screen,
+using that information to delete those windows when \fBdelscreen\fP is called.
+.bP
+NetBSD copied this feature of ncurses in 2001.
+PDCurses follows the SVr4 model,
+deleting only the standard \fBWINDOW\fP structures.
 .SS Unset TERM Variable
 .PP
 If the TERM variable is missing or empty, \fBinitscr\fP uses the
diff --git a/man/curs_window.3x b/man/curs_window.3x
index 5a671c70..c786650e 100644
--- a/man/curs_window.3x
+++ b/man/curs_window.3x
@@ -27,7 +27,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_window.3x,v 1.25 2022/02/12 20:06:41 tom Exp $
+.\" $Id: curs_window.3x,v 1.27 2022/07/24 15:35:15 tom Exp $
 .TH curs_window 3X ""
 .de bP
 .ie n  .IP \(bu 4
@@ -256,8 +256,27 @@ is patterned on the XPG4 curses standard.
 The weaker XPG4 spec may result in slower updates.
 .SH PORTABILITY
 The XSI Curses standard, Issue 4 describes these functions.
+.PP
+X/Open Curses states regarding \fBdelwin\fP:
+.bP
+It must delete subwindows before deleting their parent.
+.bP
+If \fBdelwin\fP is asked to delete a parent window,
+it can only succeed if the curses library keeps a list of the subwindows.
+SVr4 curses kept a count of the number of subwindows rather than a list.
+It simply returned \fBERR\fP when asked to delete a subwindow.
+Solaris X/Open curses does not even make that check,
+and will delete a parent window which still has subwindows.
+.bP
+Since release 4.0 (1996), ncurses maintains a list of windows for each screen,
+and is able to recursively delete subwindows when asked to delete their parent.
+.bP
+NetBSD copied this feature of ncurses in 2003.
+.br
+PDCurses follows the scheme used in Solaris X/Open curses.
 .SH SEE ALSO
 \fBcurses\fP(3X),
+\fBcurs_initscr\fP(3X),
 \fBcurs_refresh\fP(3X),
 \fBcurs_touch\fP(3X),
 \fBcurs_variables\fP(3X)
diff --git a/ncurses/base/lib_set_term.c b/ncurses/base/lib_set_term.c
index 2d28b751..9d61f5ae 100644
--- a/ncurses/base/lib_set_term.c
+++ b/ncurses/base/lib_set_term.c
@@ -54,7 +54,7 @@
 #undef CUR
 #define CUR SP_TERMTYPE
 
-MODULE_ID("$Id: lib_set_term.c,v 1.180 2022/07/09 18:58:58 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.181 2022/07/21 23:35:21 tom Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define MaxColors      InfoOf(sp).maxcolors
@@ -146,6 +146,8 @@ delscreen(SCREEN *sp)
 
     _nc_lock_global(curses);
     if (delink_screen(sp)) {
+	bool is_current = (sp == CURRENT_SCREEN);
+
 #ifdef USE_SP_RIPOFF
 	if (safe_ripoff_sp && safe_ripoff_sp != safe_ripoff_stack) {
 	    ripoff_t *rop;
@@ -219,7 +221,7 @@ delscreen(SCREEN *sp)
 	 * application might try to use (except cur_term, which may have
 	 * multiple references in different screens).
 	 */
-	if (sp == CURRENT_SCREEN) {
+	if (is_current) {
 #if !USE_REENTRANT
 	    curscr = 0;
 	    newscr = 0;
@@ -234,6 +236,8 @@ delscreen(SCREEN *sp)
 		_nc_wacs = 0;
 	    }
 #endif
+	} else {
+	    set_term(CURRENT_SCREEN);
 	}
     }
     _nc_unlock_global(curses);
diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c
index 5ed47409..89c40f96 100644
--- a/ncurses/tinfo/lib_setup.c
+++ b/ncurses/tinfo/lib_setup.c
@@ -49,7 +49,7 @@
 #include 
 #endif
 
-MODULE_ID("$Id: lib_setup.c,v 1.216 2022/07/09 18:58:58 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.217 2022/07/21 08:24:50 tom Exp $")
 
 /****************************************************************************
  *
@@ -831,7 +831,7 @@ TINFO_SETUP_TERM(TERMINAL **tp,
 	if (NC_ISATTY(Filedes)) {
 	    NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_ARG);
 	    NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_ARG);
-	    baudrate();
+	    NCURSES_SP_NAME(baudrate)(NCURSES_SP_ARG);
 	}
 	code = OK;
 #endif
diff --git a/ncurses/tinfo/lib_tputs.c b/ncurses/tinfo/lib_tputs.c
index b9ca41cc..0e52a401 100644
--- a/ncurses/tinfo/lib_tputs.c
+++ b/ncurses/tinfo/lib_tputs.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2018-2021,2022 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -52,7 +52,7 @@
 #include 		/* ospeed */
 #include 
 
-MODULE_ID("$Id: lib_tputs.c,v 1.108 2021/05/08 23:27:40 tom Exp $")
+MODULE_ID("$Id: lib_tputs.c,v 1.109 2022/07/21 23:26:34 tom Exp $")
 
 NCURSES_EXPORT_VAR(char) PC = 0;              /* used by termcap library */
 NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0;        /* used by termcap library */
@@ -128,9 +128,8 @@ NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_DCL0)
 			   SP_PARM->out_buffer));
 	if (SP_PARM->out_inuse) {
 	    char *buf = SP_PARM->out_buffer;
-	    size_t amount = SP->out_inuse;
+	    size_t amount = SP_PARM->out_inuse;
 
-	    SP->out_inuse = 0;
 	    TR(TRACE_CHARPUT, ("flushing %ld/%ld bytes",
 			       (unsigned long) amount, _nc_outchars));
 	    while (amount) {
@@ -155,6 +154,8 @@ NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_DCL0)
 	TR(TRACE_CHARPUT, ("flushing stdout"));
 	fflush(stdout);
     }
+    if (SP_PARM != 0)
+	SP_PARM->out_inuse = 0;
     returnVoid;
 }
 
diff --git a/ncurses/trace/lib_trace.c b/ncurses/trace/lib_trace.c
index 9acbd471..b6f2a75e 100644
--- a/ncurses/trace/lib_trace.c
+++ b/ncurses/trace/lib_trace.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2018-2021,2022 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -48,7 +48,7 @@
 
 #include 
 
-MODULE_ID("$Id: lib_trace.c,v 1.99 2021/06/26 20:44:59 tom Exp $")
+MODULE_ID("$Id: lib_trace.c,v 1.100 2022/07/23 20:08:45 tom Exp $")
 
 NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */
 
@@ -94,12 +94,22 @@ NCURSES_EXPORT_VAR(long) _nc_outchars = 0;
 #define MyNested	_nc_globals.nested_tracef
 #endif /* TRACE */
 
+#if USE_REENTRANT
+#define Locked(statement) { \
+	_nc_lock_global(tst_tracef); \
+	statement; \
+	_nc_unlock_global(tst_tracef); \
+    }
+#else
+#define Locked(statement) statement
+#endif
+
 NCURSES_EXPORT(unsigned)
 curses_trace(unsigned tracelevel)
 {
     unsigned result;
 #if defined(TRACE)
-    result = _nc_tracing;
+    Locked(result = _nc_tracing);
     if ((MyFP == 0) && tracelevel) {
 	MyInit = TRUE;
 	if (MyFD >= 0) {
@@ -125,7 +135,7 @@ curses_trace(unsigned tracelevel)
 		;		/* EMPTY */
 	    }
 	}
-	_nc_tracing = tracelevel;
+	Locked(_nc_tracing = tracelevel);
 	/* Try to set line-buffered mode, or (failing that) unbuffered,
 	 * so that the trace-output gets flushed automatically at the
 	 * end of each line.  This is useful in case the program dies.
@@ -147,9 +157,9 @@ curses_trace(unsigned tracelevel)
 	    fclose(MyFP);
 	    MyFP = 0;
 	}
-	_nc_tracing = tracelevel;
+	Locked(_nc_tracing = tracelevel);
     } else if (_nc_tracing != tracelevel) {
-	_nc_tracing = tracelevel;
+	Locked(_nc_tracing = tracelevel);
 	_tracef("tracelevel=%#x", tracelevel);
     }
 #else
diff --git a/ncurses/tty/tty_update.c b/ncurses/tty/tty_update.c
index bdd673be..80815244 100644
--- a/ncurses/tty/tty_update.c
+++ b/ncurses/tty/tty_update.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2018-2021,2022 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -85,7 +85,7 @@
 
 #include 
 
-MODULE_ID("$Id: tty_update.c,v 1.312 2021/09/04 10:29:59 tom Exp $")
+MODULE_ID("$Id: tty_update.c,v 1.314 2022/07/23 22:12:59 tom Exp $")
 
 /*
  * This define controls the line-breakout optimization.  Every once in a
@@ -757,14 +757,20 @@ TINFO_DOUPDATE(NCURSES_SP_DCL0)
      * We do not allow applications to assign new values in the reentrant
      * model.
      */
+#if NCURSES_SP_FUNCS
+    if (SP_PARM == CURRENT_SCREEN) {
+#endif
 #define SyncScreens(internal,exported) \
 	if (internal == 0) internal = exported; \
 	if (internal != exported) exported = internal
 
-    SyncScreens(CurScreen(SP_PARM), curscr);
-    SyncScreens(NewScreen(SP_PARM), newscr);
-    SyncScreens(StdScreen(SP_PARM), stdscr);
+	SyncScreens(CurScreen(SP_PARM), curscr);
+	SyncScreens(NewScreen(SP_PARM), newscr);
+	SyncScreens(StdScreen(SP_PARM), stdscr);
+#if NCURSES_SP_FUNCS
+    }
 #endif
+#endif /* !USE_REENTRANT */
 
     if (CurScreen(SP_PARM) == 0
 	|| NewScreen(SP_PARM) == 0
diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog
index 49a5357f..dbde558c 100644
--- a/package/debian-mingw/changelog
+++ b/package/debian-mingw/changelog
@@ -1,8 +1,8 @@
-ncurses6 (6.3+20220716) unstable; urgency=low
+ncurses6 (6.3+20220724) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey   Sat, 16 Jul 2022 06:45:29 -0400
+ -- Thomas E. Dickey   Sun, 24 Jul 2022 05:45:41 -0400
 
 ncurses6 (5.9-20131005) unstable; urgency=low
 
diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog
index 49a5357f..dbde558c 100644
--- a/package/debian-mingw64/changelog
+++ b/package/debian-mingw64/changelog
@@ -1,8 +1,8 @@
-ncurses6 (6.3+20220716) unstable; urgency=low
+ncurses6 (6.3+20220724) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey   Sat, 16 Jul 2022 06:45:29 -0400
+ -- Thomas E. Dickey   Sun, 24 Jul 2022 05:45:41 -0400
 
 ncurses6 (5.9-20131005) unstable; urgency=low
 
diff --git a/package/debian/changelog b/package/debian/changelog
index 6d2c769e..1c0a2bc6 100644
--- a/package/debian/changelog
+++ b/package/debian/changelog
@@ -1,8 +1,8 @@
-ncurses6 (6.3+20220716) unstable; urgency=low
+ncurses6 (6.3+20220724) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey   Sat, 16 Jul 2022 06:45:29 -0400
+ -- Thomas E. Dickey   Sun, 24 Jul 2022 05:45:41 -0400
 
 ncurses6 (5.9-20120608) unstable; urgency=low
 
diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi
index 3bab9bae..026fc01f 100644
--- a/package/mingw-ncurses.nsi
+++ b/package/mingw-ncurses.nsi
@@ -1,4 +1,4 @@
-; $Id: mingw-ncurses.nsi,v 1.532 2022/07/16 10:45:29 tom Exp $
+; $Id: mingw-ncurses.nsi,v 1.534 2022/07/24 09:45:40 tom Exp $
 
 ; TODO add examples
 ; TODO bump ABI to 6
@@ -10,7 +10,7 @@
 !define VERSION_MAJOR "6"
 !define VERSION_MINOR "3"
 !define VERSION_YYYY  "2022"
-!define VERSION_MMDD  "0716"
+!define VERSION_MMDD  "0724"
 !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD}
 
 !define MY_ABI   "5"
diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec
index a1e162f4..c2ced9eb 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.3
-Release: 20220716
+Release: 20220724
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
diff --git a/package/ncurses.spec b/package/ncurses.spec
index dac8d9ff..4067ae97 100644
--- a/package/ncurses.spec
+++ b/package/ncurses.spec
@@ -1,7 +1,7 @@
 Summary: shared libraries for terminal handling
 Name: ncurses6
 Version: 6.3
-Release: 20220716
+Release: 20220724
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
diff --git a/package/ncursest.spec b/package/ncursest.spec
index e83ae9d6..07e361bb 100644
--- a/package/ncursest.spec
+++ b/package/ncursest.spec
@@ -1,7 +1,7 @@
 Summary: Curses library with POSIX thread support.
 Name: ncursest6
 Version: 6.3
-Release: 20220716
+Release: 20220724
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
diff --git a/test/rain.c b/test/rain.c
index 4c3568cf..dde411b2 100644
--- a/test/rain.c
+++ b/test/rain.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2020,2022 Thomas E. Dickey                                *
  * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: rain.c,v 1.52 2020/08/29 16:22:03 juergen Exp $
+ * $Id: rain.c,v 1.54 2022/07/23 22:47:38 tom Exp $
  */
 #include 
 #include 
@@ -57,6 +57,7 @@ typedef struct DATA {
 
 #ifdef USE_PTHREADS
 pthread_cond_t cond_next_drop;
+pthread_mutex_t mutex_drop_data;
 pthread_mutex_t mutex_next_drop;
 static int used_threads;
 
@@ -200,7 +201,7 @@ draw_part(void (*func) (DATA *), int state, DATA * data)
 static int
 put_next_drop(void)
 {
-    pthread_cond_signal(&cond_next_drop);
+    pthread_cond_broadcast(&cond_next_drop);
     pthread_mutex_unlock(&mutex_next_drop);
 
     return 0;
@@ -246,7 +247,9 @@ draw_drop(void *arg)
 	 * to the data which it uses for setting up this thread (but it has
 	 * been modified to use different coordinates).
 	 */
+	pthread_mutex_lock(&mutex_drop_data);
 	mydata = *(DATA *) arg;
+	pthread_mutex_unlock(&mutex_drop_data);
 
 	draw_part(part1, 0, &mydata);
 	draw_part(part2, 1, &mydata);
@@ -254,6 +257,7 @@ draw_drop(void *arg)
 	draw_part(part4, 3, &mydata);
 	draw_part(part5, 4, &mydata);
 	draw_part(part6, 0, &mydata);
+
     } while (get_next_drop());
 
     return NULL;
@@ -374,7 +378,9 @@ main(int argc, char *argv[])
     curs_set(0);
     timeout(0);
 
-#ifndef USE_PTHREADS
+#ifdef USE_PTHREADS
+    pthread_mutex_init(&mutex_drop_data, NULL);
+#else /* !USE_PTHREADS */
     for (j = MAX_DROP; --j >= 0;) {
 	last[j].x = random_x();
 	last[j].y = random_y();
@@ -383,14 +389,21 @@ main(int argc, char *argv[])
 #endif
 
     while (!done) {
+#ifdef USE_PTHREADS
+	pthread_mutex_lock(&mutex_drop_data);
+
 	drop.x = random_x();
 	drop.y = random_y();
 
-#ifdef USE_PTHREADS
 	if (start_drop(&drop) != 0) {
 	    beep();
 	}
+
+	pthread_mutex_unlock(&mutex_drop_data);
 #else
+	drop.x = random_x();
+	drop.y = random_y();
+
 	/*
 	 * The non-threaded code draws parts of each drop on each loop.
 	 */
diff --git a/test/test_mouse.c b/test/test_mouse.c
index c898080a..602df4cf 100644
--- a/test/test_mouse.c
+++ b/test/test_mouse.c
@@ -22,7 +22,7 @@
  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
  ****************************************************************************/
 /*
- * $Id: test_mouse.c,v 1.20 2022/07/16 18:52:09 tom Exp $
+ * $Id: test_mouse.c,v 1.22 2022/07/24 15:18:53 tom Exp $
  *
  * Author: Leonid S Usov
  *
@@ -47,11 +47,11 @@ raw_loop(void)
     cfmakeraw(&tty);
 #else
     tty = old;
-    tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
-		     | INLCR | IGNCR | ICRNL | IXON);
-    tty.c_oflag &= ~OPOST;
-    tty.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
-    tty.c_cflag &= ~(CSIZE | PARENB);
+    tty.c_iflag &= (unsigned) (~(IGNBRK | BRKINT | PARMRK | ISTRIP
+				 | INLCR | IGNCR | ICRNL | IXON));
+    tty.c_oflag &= (unsigned) (~OPOST);
+    tty.c_lflag &= (unsigned) (~(ECHO | ECHONL | ICANON | ISIG | IEXTEN));
+    tty.c_cflag &= (unsigned) (~(CSIZE | PARENB));
     tty.c_cflag |= CS8;
     tcsetattr(0, TCSANOW, &tty);
 #endif
@@ -121,7 +121,7 @@ usage(void)
     {
 	"Usage: test_mouse [options]",
 	"",
-	"Test mouse events.  These examples for $TERM demonstrate xterm"
+	"Test mouse events.  These examples for $TERM demonstrate xterm",
 	"features:",
 	"    xterm",
 	"    xterm-1002",
diff --git a/test/worm.c b/test/worm.c
index ab1eb9fa..4888a519 100644
--- a/test/worm.c
+++ b/test/worm.c
@@ -53,7 +53,7 @@
   traces will be dumped.  The program stops and waits for one character of
   input at the beginning and end of the interval.
 
-  $Id: worm.c,v 1.83 2022/07/09 20:51:25 tom Exp $
+  $Id: worm.c,v 1.84 2022/07/23 17:06:16 tom Exp $
 */
 
 #include 
@@ -107,6 +107,18 @@ static int length = 16, number = 3;
 static chtype trail = ' ';
 
 static unsigned pending;
+
+#ifdef USE_PTHREADS
+#define Locked(statement) { \
+	pthread_mutex_lock(&pending_mutex); \
+	statement; \
+	pthread_mutex_unlock(&pending_mutex); \
+    }
+pthread_mutex_t pending_mutex;
+#else
+#define Locked(statement) statement
+#endif
+
 #ifdef TRACE
 static int generation, trace_start, trace_end;
 #endif /* TRACE */
@@ -248,13 +260,18 @@ draw_worm(WINDOW *win, void *data)
     WORM *w = (WORM *) data;
     const struct options *op;
     unsigned mask = (unsigned) (~(1 << (w - worm)));
-    chtype attrs = w->attrs | ((mask & pending) ? A_REVERSE : 0);
+    chtype attrs;
 
     int x;
     int y;
     int h;
 
     bool done = FALSE;
+    bool is_pending;
+
+    Locked(is_pending = ((mask & pending) != 0));
+
+    attrs = w->attrs | (is_pending ? A_REVERSE : 0);
 
     if ((x = w->xpos[h = w->head]) < 0) {
 	wmove(win, y = w->ypos[h] = last_y, x = w->xpos[h] = 0);
@@ -336,9 +353,12 @@ draw_worm(WINDOW *win, void *data)
 static bool
 quit_worm(int bitnum)
 {
-    pending = (pending | (unsigned) (1 << bitnum));
+    Locked(pending = (pending | (unsigned) (1 << bitnum)));
+
     napms(10);			/* let the other thread(s) have a chance */
-    pending = (pending & (unsigned) ~(1 << bitnum));
+
+    Locked(pending = (pending & (unsigned) ~(1 << bitnum)));
+
     return quitting;
 }
 
@@ -593,8 +613,12 @@ main(int argc, char *argv[])
     USING_WINDOW1(stdscr, wrefresh, safe_wrefresh);
     nodelay(stdscr, TRUE);
 
+#ifdef USE_PTHREADS
+    pthread_mutex_init(&pending_mutex, NULL);
+#endif
+
     while (!done) {
-	++sequence;
+	Locked(++sequence);
 	if ((ch = get_input()) > 0) {
 #ifdef TRACE
 	    if (trace_start || trace_end) {
-- 
2.44.0