From: Thomas E. Dickey Date: Sun, 14 Aug 2022 00:26:10 +0000 (+0000) Subject: ncurses 6.3 - patch 20220813 X-Git-Tag: v6.4~21 X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=commitdiff_plain;h=1c305869cc1b9454efa9325fb5a44b18c79ce91b ncurses 6.3 - patch 20220813 + modify delscreen to more effectively delete all windows on the given screen. + amend portability note for delwin in manual page. + adapt test/test_delwin.c from example by Bill Gray. + account for prescreen data if freeing leaks in pthread-configuration + split-out _nc_set_read_thread(), to reduce compiler warnings about pthread_self(), which may/may not be a weak symbol. + improve pthread-configuration for test/worm.c --- diff --git a/MANIFEST b/MANIFEST index 8c3a1dc1..ce65f85d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1216,6 +1216,7 @@ ./test/test_addstr.c ./test/test_addwstr.c ./test/test_arrays.c +./test/test_delwin.c ./test/test_get_wstr.c ./test/test_getstr.c ./test/test_instr.c diff --git a/NEWS b/NEWS index 9b1a9040..8dca9518 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.3841 2022/08/06 19:13:14 tom Exp $ +-- $Id: NEWS,v 1.3846 2022/08/13 23:42:30 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -46,6 +46,16 @@ 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. +20220813 + + modify delscreen to more effectively delete all windows on the given + screen. + + amend portability note for delwin in manual page. + + adapt test/test_delwin.c from example by Bill Gray. + + account for prescreen data if freeing leaks in pthread-configuration + + split-out _nc_set_read_thread(), to reduce compiler warnings about + pthread_self(), which may/may not be a weak symbol. + + improve pthread-configuration for test/worm.c + 20220806 + amend end_of_stream() to allow for input files without a final newline. diff --git a/VERSION b/VERSION index f473b9bf..978194d7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5:0:10 6.3 20220806 +5:0:10 6.3 20220813 diff --git a/dist.mk b/dist.mk index f3390b9a..531ead2e 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.1496 2022/08/06 10:14:36 tom Exp $ +# $Id: dist.mk,v 1.1497 2022/08/13 09:43:55 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 = 20220806 +NCURSES_PATCH = 20220813 # 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 e1e4b8e3..28a543dc 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 20220724).
+       This describes ncurses version 6.3 (patch 20220813).
 
 
 
diff --git a/doc/html/man/captoinfo.1m.html b/doc/html/man/captoinfo.1m.html
index 522f97be..8f78a276 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 20220724).
+       This describes ncurses version 6.3 (patch 20220813).
 
 
 

AUTHOR

diff --git a/doc/html/man/clear.1.html b/doc/html/man/clear.1.html
index 94ba5d55..8e13a37c 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 20220724).
+       This describes ncurses version 6.3 (patch 20220813).
 
 
 
diff --git a/doc/html/man/curs_window.3x.html b/doc/html/man/curs_window.3x.html
index 1bd25353..660ed566 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.27 2022/07/24 15:35:15 tom Exp @
+  * @Id: curs_window.3x,v 1.28 2022/08/13 23:24:22 tom Exp @
 -->
 
 
@@ -241,8 +241,8 @@
            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.
+           each  screen,  to ensure that a window has no subwindows before al-
+           lowing deletion.
 
        o   NetBSD copied this feature of ncurses in 2003.
            PDCurses follows the scheme used in Solaris X/Open curses.
diff --git a/doc/html/man/form.3x.html b/doc/html/man/form.3x.html
index ad408f0d..c0eadee0 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 20220724).
+       This describes ncurses version 6.3 (patch 20220813).
 
 
 
diff --git a/doc/html/man/infocmp.1m.html b/doc/html/man/infocmp.1m.html
index 79dff9ee..e528651b 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 20220724).
+       This describes ncurses version 6.3 (patch 20220813).
 
 
 

AUTHOR

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

AUTHOR

diff --git a/doc/html/man/menu.3x.html b/doc/html/man/menu.3x.html
index 75529858..ed9a098c 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 20220724).
+       This describes ncurses version 6.3 (patch 20220813).
 
 
 
diff --git a/doc/html/man/ncurses.3x.html b/doc/html/man/ncurses.3x.html
index 93ff3ca2..1fdc512a 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 20220724).
+       This describes ncurses version 6.3 (patch 20220813).
 
        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 fc8193ec..452c48db 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 20220724).
+       This describes ncurses version 6.3 (patch 20220813).
 
 
 
diff --git a/doc/html/man/panel.3x.html b/doc/html/man/panel.3x.html
index 26dc1b18..a3922fba 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 20220724).
+       This describes ncurses version 6.3 (patch 20220813).
 
 
 

AUTHOR

diff --git a/doc/html/man/tabs.1.html b/doc/html/man/tabs.1.html
index 84cb384b..89a3fad4 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 20220724).
+       This describes ncurses version 6.3 (patch 20220813).
 
 
 
diff --git a/doc/html/man/terminfo.5.html b/doc/html/man/terminfo.5.html
index a3ea785b..bc30bf97 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 20220724).
+       This manual describes ncurses version 6.3 (patch 20220813).
 
 
 

Terminfo Entry Syntax

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

AUTHOR

diff --git a/doc/html/man/toe.1m.html b/doc/html/man/toe.1m.html
index d097fc10..2cbd734b 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 20220724).
+       This describes ncurses version 6.3 (patch 20220813).
 
 
 
diff --git a/doc/html/man/tput.1.html b/doc/html/man/tput.1.html
index 8d68b72b..9e93cd3d 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 20220724).
+       This describes ncurses version 6.3 (patch 20220813).
 
 
 
diff --git a/doc/html/man/tset.1.html b/doc/html/man/tset.1.html
index 6359953e..243433b0 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 20220724).
+       This describes ncurses version 6.3 (patch 20220813).
 
 
 
diff --git a/man/curs_window.3x b/man/curs_window.3x
index c786650e..f37eb5f6 100644
--- a/man/curs_window.3x
+++ b/man/curs_window.3x
@@ -27,7 +27,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_window.3x,v 1.27 2022/07/24 15:35:15 tom Exp $
+.\" $Id: curs_window.3x,v 1.28 2022/08/13 23:24:22 tom Exp $
 .TH curs_window 3X ""
 .de bP
 .ie n  .IP \(bu 4
@@ -269,7 +269,7 @@ 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.
+to ensure that a window has no subwindows before allowing deletion.
 .bP
 NetBSD copied this feature of ncurses in 2003.
 .br
diff --git a/ncurses/base/lib_getch.c b/ncurses/base/lib_getch.c
index 0d719cfc..43460394 100644
--- a/ncurses/base/lib_getch.c
+++ b/ncurses/base/lib_getch.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2018-2021,2022 Thomas E. Dickey                                *
  * Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -44,7 +44,7 @@
 #define NEED_KEY_EVENT
 #include 
 
-MODULE_ID("$Id: lib_getch.c,v 1.143 2021/10/23 17:06:20 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.144 2022/08/13 14:36:43 tom Exp $")
 
 #include 
 
@@ -309,16 +309,11 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
 	int buf;
 # if defined(EXP_WIN32_DRIVER)
 	if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && sp->_cbreak) {
-#  if USE_PTHREADS_EINTR
-	    if ((pthread_self) && (pthread_kill) && (pthread_equal))
-		_nc_globals.read_thread = pthread_self();
-#  endif
+	    _nc_set_read_thread(TRUE);
 	    n = _nc_console_read(sp,
 				 _nc_console_handle(sp->_ifd),
 				 &buf);
-#  if USE_PTHREADS_EINTR
-	    _nc_globals.read_thread = 0;
-#  endif
+	    _nc_set_read_thread(FALSE);
 	} else
 # elif defined(_NC_WINDOWS)
 	if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && sp->_cbreak)
@@ -334,12 +329,8 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
 	int buf;
 #endif
 	unsigned char c2 = 0;
-#if USE_PTHREADS_EINTR
-#if USE_WEAK_SYMBOLS
-	if ((pthread_self) && (pthread_kill) && (pthread_equal))
-#endif
-	    _nc_globals.read_thread = pthread_self();
-#endif
+
+	_nc_set_read_thread(TRUE);
 #if defined(EXP_WIN32_DRIVER)
 	n = _nc_console_read(sp,
 			     _nc_console_handle(sp->_ifd),
@@ -348,9 +339,7 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
 #else
 	n = (int) read(sp->_ifd, &c2, (size_t) 1);
 #endif
-#if USE_PTHREADS_EINTR
-	_nc_globals.read_thread = 0;
-#endif
+	_nc_set_read_thread(FALSE);
 	ch = c2;
 #endif /* USE_TERM_DRIVER */
     }
diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c
index c70cb5a3..f4151b81 100644
--- a/ncurses/base/lib_mouse.c
+++ b/ncurses/base/lib_mouse.c
@@ -85,7 +85,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_mouse.c,v 1.196 2022/04/30 23:21:34 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.197 2022/08/13 14:13:12 tom Exp $")
 
 #include 
 
@@ -1085,12 +1085,7 @@ decode_xterm_X10(SCREEN *sp, MEVENT * eventp)
     int res;
     bool result;
 
-# if USE_PTHREADS_EINTR
-#  if USE_WEAK_SYMBOLS
-    if ((pthread_self) && (pthread_kill) && (pthread_equal))
-#  endif
-	_nc_globals.read_thread = pthread_self();
-# endif
+    _nc_set_read_thread(TRUE);
     for (grabbed = 0; grabbed < MAX_KBUF; grabbed += (size_t) res) {
 
 	/* For VIO mouse we add extra bit 64 to disambiguate button-up. */
@@ -1104,9 +1099,7 @@ decode_xterm_X10(SCREEN *sp, MEVENT * eventp)
 	if (res == -1)
 	    break;
     }
-#if USE_PTHREADS_EINTR
-    _nc_globals.read_thread = 0;
-#endif
+    _nc_set_read_thread(FALSE);
     kbuf[MAX_KBUF] = '\0';
 
     TR(TRACE_IEVENT,
@@ -1140,12 +1133,7 @@ decode_xterm_1005(SCREEN *sp, MEVENT * eventp)
     coords[0] = 0;
     coords[1] = 0;
 
-# if USE_PTHREADS_EINTR
-#  if USE_WEAK_SYMBOLS
-    if ((pthread_self) && (pthread_kill) && (pthread_equal))
-#  endif
-	_nc_globals.read_thread = pthread_self();
-# endif
+    _nc_set_read_thread(TRUE);
     for (grabbed = 0; grabbed < limit;) {
 	int res;
 
@@ -1178,9 +1166,7 @@ decode_xterm_1005(SCREEN *sp, MEVENT * eventp)
 		break;
 	}
     }
-#if USE_PTHREADS_EINTR
-    _nc_globals.read_thread = 0;
-#endif
+    _nc_set_read_thread(FALSE);
 
     TR(TRACE_IEVENT,
        ("_nc_mouse_inline sees the following xterm data: %s",
@@ -1224,12 +1210,7 @@ read_SGR(SCREEN *sp, SGR_DATA * result)
     int marker = 1;
 
     memset(result, 0, sizeof(*result));
-# if USE_PTHREADS_EINTR
-#  if USE_WEAK_SYMBOLS
-    if ((pthread_self) && (pthread_kill) && (pthread_equal))
-#  endif
-	_nc_globals.read_thread = pthread_self();
-# endif
+    _nc_set_read_thread(TRUE);
 
     do {
 	int res;
@@ -1294,9 +1275,7 @@ read_SGR(SCREEN *sp, SGR_DATA * result)
 	}
 	++grabbed;
     } while (!isFinal(ch));
-#if USE_PTHREADS_EINTR
-    _nc_globals.read_thread = 0;
-#endif
+    _nc_set_read_thread(FALSE);
 
     kbuf[++grabbed] = 0;
     TR(TRACE_IEVENT,
diff --git a/ncurses/base/lib_set_term.c b/ncurses/base/lib_set_term.c
index 9d61f5ae..3b41d784 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.181 2022/07/21 23:35:21 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.182 2022/08/13 23:14:26 tom Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define MaxColors      InfoOf(sp).maxcolors
@@ -146,6 +146,7 @@ delscreen(SCREEN *sp)
 
     _nc_lock_global(curses);
     if (delink_screen(sp)) {
+	WINDOWLIST *wl;
 	bool is_current = (sp == CURRENT_SCREEN);
 
 #ifdef USE_SP_RIPOFF
@@ -162,9 +163,13 @@ delscreen(SCREEN *sp)
 	}
 #endif
 
-	(void) _nc_freewin(CurScreen(sp));
-	(void) _nc_freewin(NewScreen(sp));
-	(void) _nc_freewin(StdScreen(sp));
+	/* delete all of the windows in this screen */
+      rescan:
+	for (each_window(sp, wl)) {
+	    if (_nc_freewin(&(wl->win)) == OK) {
+		goto rescan;
+	    }
+	}
 
 	if (sp->_slk != 0) {
 
diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h
index 60199f90..1e8ec70b 100644
--- a/ncurses/curses.priv.h
+++ b/ncurses/curses.priv.h
@@ -35,7 +35,7 @@
  ****************************************************************************/
 
 /*
- * $Id: curses.priv.h,v 1.650 2022/05/01 14:41:33 tom Exp $
+ * $Id: curses.priv.h,v 1.651 2022/08/13 14:35:01 tom Exp $
  *
  *	curses.priv.h
  *
@@ -672,9 +672,14 @@ extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *);
 #define _nc_lock_global(name)	/* nothing */
 #define _nc_try_global(name)    0
 #define _nc_unlock_global(name)	/* nothing */
-
 #endif /* USE_PTHREADS */
 
+#if USE_PTHREADS_EINTR || defined(EXP_WIN32_DRIVER)
+extern NCURSES_EXPORT(void) _nc_set_read_thread(bool);
+#else
+#define _nc_set_read_thread(enable)	/* nothing */
+#endif
+
 /*
  * When using sp-funcs, locks are targeted to SCREEN-level granularity.
  * So the locking is done in the non-sp-func (which calls the sp-func) rather
diff --git a/ncurses/tinfo/entries.c b/ncurses/tinfo/entries.c
index 5f49ece9..8c5e10c0 100644
--- a/ncurses/tinfo/entries.c
+++ b/ncurses/tinfo/entries.c
@@ -38,7 +38,7 @@
 
 #include 
 
-MODULE_ID("$Id: entries.c,v 1.33 2022/05/07 17:08:11 tom Exp $")
+MODULE_ID("$Id: entries.c,v 1.34 2022/08/13 16:57:35 tom Exp $")
 
 /****************************************************************************
  *
@@ -125,6 +125,22 @@ _nc_leaks_tinfo(void)
     _nc_free_tparm(cur_term);
     _nc_tgetent_leaks();
 
+#ifdef USE_PTHREADS
+    /*
+     * Discard any prescreen data which is not used for the current screen.
+     */
+    _nc_lock_global(screen);
+    {
+	PRESCREEN_LIST *p;
+	pthread_t id = GetThreadID();
+	for (p = _nc_prescreen.allocated; p != 0; p = p->next) {
+	    if (p->id == id && p->sp != CURRENT_SCREEN) {
+		FreeAndNull(p->sp);
+	    }
+	}
+    }
+    _nc_unlock_global(screen);
+#endif
     if (TerminalOf(CURRENT_SCREEN) != 0) {
 	del_curterm(TerminalOf(CURRENT_SCREEN));
     }
diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c
index 89c40f96..db93a368 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.217 2022/07/21 08:24:50 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.218 2022/08/13 18:12:22 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);
-	    NCURSES_SP_NAME(baudrate)(NCURSES_SP_ARG);
+	    NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG);
 	}
 	code = OK;
 #endif
@@ -908,6 +908,7 @@ _nc_forget_prescr(void)
 {
     PRESCREEN_LIST *p, *q;
     pthread_t id = GetThreadID();
+    _nc_lock_global(screen);
     for (p = _nc_prescreen.allocated, q = 0; p != 0; q = p, p = p->next) {
 	if (p->id == id) {
 	    if (q) {
@@ -919,6 +920,7 @@ _nc_forget_prescr(void)
 	    break;
 	}
     }
+    _nc_unlock_global(screen);
 }
 #endif /* USE_PTHREADS */
 
diff --git a/ncurses/tinfo/tinfo_driver.c b/ncurses/tinfo/tinfo_driver.c
index fb6496f0..eb4ecb3d 100644
--- a/ncurses/tinfo/tinfo_driver.c
+++ b/ncurses/tinfo/tinfo_driver.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2018-2021,2022 Thomas E. Dickey                                *
  * Copyright 2008-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -52,7 +52,7 @@
 # endif
 #endif
 
-MODULE_ID("$Id: tinfo_driver.c,v 1.72 2021/06/17 21:30:22 tom Exp $")
+MODULE_ID("$Id: tinfo_driver.c,v 1.73 2022/08/13 14:36:43 tom Exp $")
 
 /*
  * SCO defines TIOCGSIZE and the corresponding struct.  Other systems (SunOS,
@@ -1282,10 +1282,7 @@ drv_read(TERMINAL_CONTROL_BLOCK * TCB, int *buf)
     assert(buf);
     SetSP();
 
-# if USE_PTHREADS_EINTR
-    if ((pthread_self) && (pthread_kill) && (pthread_equal))
-	_nc_globals.read_thread = pthread_self();
-# endif
+    _nc_set_read_thread(TRUE);
 #ifdef EXP_WIN32_DRIVER
     n = _nc_console_read(sp,
 			 _nc_console_handle(sp->_ifd),
@@ -1293,9 +1290,7 @@ drv_read(TERMINAL_CONTROL_BLOCK * TCB, int *buf)
 #else
     n = (int) read(sp->_ifd, &c2, (size_t) 1);
 #endif
-#if USE_PTHREADS_EINTR
-    _nc_globals.read_thread = 0;
-#endif
+    _nc_set_read_thread(FALSE);
 #ifndef EXP_WIN32_DRIVER
     *buf = (int) c2;
 #endif
diff --git a/ncurses/tty/lib_tstp.c b/ncurses/tty/lib_tstp.c
index a20e72a9..ec086ca7 100644
--- a/ncurses/tty/lib_tstp.c
+++ b/ncurses/tty/lib_tstp.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 2020-2021,2022 Thomas E. Dickey                                *
  * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,7 +43,7 @@
 
 #include 
 
-MODULE_ID("$Id: lib_tstp.c,v 1.51 2021/09/04 10:54:35 tom Exp $")
+MODULE_ID("$Id: lib_tstp.c,v 1.52 2022/08/13 14:36:43 tom Exp $")
 
 #if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC)
 #define USE_SIGTSTP 1
@@ -284,6 +284,22 @@ handle_SIGINT(int sig)
 }
 
 #if USE_SIGWINCH
+
+# ifndef _nc_set_read_thread
+NCURSES_EXPORT(void)
+_nc_set_read_thread(bool enable)
+{
+    if (enable) {
+#  if USE_WEAK_SYMBOLS
+	if ((pthread_self) && (pthread_kill) && (pthread_equal))
+#  endif
+	    _nc_globals.read_thread = pthread_self();
+    } else {
+	_nc_globals.read_thread = 0;
+    }
+}
+# endif
+
 static void
 handle_SIGWINCH(int sig GCC_UNUSED)
 {
diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog
index 1e32b6ca..aabe8417 100644
--- a/package/debian-mingw/changelog
+++ b/package/debian-mingw/changelog
@@ -1,8 +1,8 @@
-ncurses6 (6.3+20220806) unstable; urgency=low
+ncurses6 (6.3+20220813) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey   Sat, 06 Aug 2022 06:14:36 -0400
+ -- Thomas E. Dickey   Sat, 13 Aug 2022 05:43:55 -0400
 
 ncurses6 (5.9-20131005) unstable; urgency=low
 
diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog
index 1e32b6ca..aabe8417 100644
--- a/package/debian-mingw64/changelog
+++ b/package/debian-mingw64/changelog
@@ -1,8 +1,8 @@
-ncurses6 (6.3+20220806) unstable; urgency=low
+ncurses6 (6.3+20220813) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey   Sat, 06 Aug 2022 06:14:36 -0400
+ -- Thomas E. Dickey   Sat, 13 Aug 2022 05:43:55 -0400
 
 ncurses6 (5.9-20131005) unstable; urgency=low
 
diff --git a/package/debian/changelog b/package/debian/changelog
index c0d2c646..870eea54 100644
--- a/package/debian/changelog
+++ b/package/debian/changelog
@@ -1,8 +1,8 @@
-ncurses6 (6.3+20220806) unstable; urgency=low
+ncurses6 (6.3+20220813) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey   Sat, 06 Aug 2022 06:14:36 -0400
+ -- Thomas E. Dickey   Sat, 13 Aug 2022 05:43:55 -0400
 
 ncurses6 (5.9-20120608) unstable; urgency=low
 
diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi
index f3bfa139..f8883001 100644
--- a/package/mingw-ncurses.nsi
+++ b/package/mingw-ncurses.nsi
@@ -1,4 +1,4 @@
-; $Id: mingw-ncurses.nsi,v 1.536 2022/08/06 10:14:36 tom Exp $
+; $Id: mingw-ncurses.nsi,v 1.537 2022/08/13 09:43:55 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  "0806"
+!define VERSION_MMDD  "0813"
 !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD}
 
 !define MY_ABI   "5"
diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec
index ae2e3ca9..36d9dc56 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: 20220806
+Release: 20220813
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
diff --git a/package/ncurses.spec b/package/ncurses.spec
index 812e7abe..3f0bb4b1 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: 20220806
+Release: 20220813
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
diff --git a/package/ncursest.spec b/package/ncursest.spec
index c2f80db5..efc0c72e 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: 20220806
+Release: 20220813
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
diff --git a/test/README b/test/README
index 4eb8f2d8..7844aa7e 100644
--- a/test/README
+++ b/test/README
@@ -26,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: README,v 1.76 2022/06/04 23:25:37 tom Exp $
+-- $Id: README,v 1.77 2022/08/13 23:34:33 tom Exp $
 -------------------------------------------------------------------------------
 
 The programs in this directory are used to test and demonstrate ncurses.
@@ -234,9 +234,9 @@ BC				test: demo_termcap
 COLORS				test: color_content demo_new_pair dots_curses dots_xcurses echochar ncurses pair_content picsmap savescreen xmas
 COLOR_PAIR			test: background blue bs cardfile clip_printw demo_forms demo_menus demo_panels dots_curses dup_field echochar filter firework gdc hanoi ins_wide insdelln inserts knight move_field ncurses newdemo padview picsmap rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr testaddch testcurs view worm xmas
 COLOR_PAIRS			test: demo_new_pair dots_curses dots_xcurses echochar ncurses newdemo pair_content
-COLS				test: cardfile combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_panels demo_tabs ditto dots_curses dots_xcurses echochar filter firework foldkeys hashtest inch_wide inchs ins_wide inserts lrtest movewindow ncurses newdemo padview picsmap rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view worm
+COLS				test: cardfile combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_panels demo_tabs ditto dots_curses dots_xcurses echochar filter firework foldkeys hashtest inch_wide inchs ins_wide inserts lrtest movewindow ncurses newdemo padview picsmap rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view worm
 ESCDELAY			test: test_opaque
-LINES				test: cardfile combine demo_defkey demo_keyok demo_menus demo_panels demo_tabs ditto dots_curses dots_xcurses echochar firework hanoi hashtest inch_wide inchs ins_wide inserts lrtest move_field movewindow ncurses newdemo padview picsmap rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view worm xmas
+LINES				test: cardfile combine demo_defkey demo_keyok demo_menus demo_panels demo_tabs ditto dots_curses dots_xcurses echochar firework hanoi hashtest inch_wide inchs ins_wide inserts lrtest move_field movewindow ncurses newdemo padview picsmap rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view worm xmas
 PAIR_NUMBER			test: dump_window ncurses
 PC				test: demo_termcap
 SP				lib: form
@@ -277,11 +277,11 @@ boolfnames			test: demo_terminfo test_arrays progs: dump_entry
 boolnames			test: demo_terminfo test_arrays progs: dump_entry infocmp
 border				-
 border_set			-
-box				test: cardfile chgat clip_printw demo_forms demo_menus demo_panels ditto inch_wide inchs ins_wide insdelln inserts lrtest ncurses newdemo popup_msg redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs
+box				test: cardfile chgat clip_printw demo_forms demo_menus demo_panels ditto inch_wide inchs ins_wide insdelln inserts lrtest ncurses newdemo popup_msg redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs
 box_set				test: ncurses
 can_change_color		test: color_content extended_color ncurses
 can_change_color_sp		test: extended_color
-cbreak				test: back_ground background blue bs cardfile chgat clip_printw color_content color_set combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_new_pair demo_panels demo_tabs ditto dup_field extended_color filter firework foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts knight lrtest move_field movewindow ncurses newdemo padview pair_content picsmap savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_unget_wch testcurs view worm xmas
+cbreak				test: back_ground background blue bs cardfile chgat clip_printw color_content color_set combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_new_pair demo_panels demo_tabs ditto dup_field extended_color filter firework foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts knight lrtest move_field movewindow ncurses newdemo padview pair_content picsmap savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_unget_wch testcurs view worm xmas
 cbreak_sp			test: sp_tinfo
 chgat				test: chgat
 clear				test: blue bs filter gdc ncurses padview testcurs xmas
@@ -310,9 +310,9 @@ delay_output			test: newdemo
 delay_output_sp			test: sp_tinfo
 delch				-
 deleteln			test: insdelln
-delscreen			test: ditto dots_mvcur
-delwin				test: cardfile chgat clip_printw demo_forms demo_panels dup_field inch_wide inchs ins_wide insdelln inserts move_field ncurses newdemo padview popup_msg redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view
-derwin				test: cardfile chgat clip_printw demo_forms demo_menus ditto inch_wide inchs ins_wide insdelln inserts movewindow ncurses test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque
+delscreen			test: ditto dots_mvcur test_delwin
+delwin				test: cardfile chgat clip_printw demo_forms demo_panels dup_field inch_wide inchs ins_wide insdelln inserts move_field ncurses newdemo padview popup_msg redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view
+derwin				test: cardfile chgat clip_printw demo_forms demo_menus ditto inch_wide inchs ins_wide insdelln inserts movewindow ncurses test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_opaque
 doupdate			test: cardfile demo_menus demo_panels ditto ins_wide inserts knight movewindow ncurses padview popup_msg redraw savescreen test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr
 doupdate_sp			lib: ncurses
 dupwin				test: popup_msg
@@ -320,14 +320,14 @@ echo				test: bs hanoi ncurses test_get_wstr test_getstr testcurs testscanw
 echo_sp				lib: ncurses
 echo_wchar			test: ncurses
 echochar			test: echochar ncurses
-endwin				test: back_ground background blue bs cardfile chgat clip_printw color_content color_set combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_new_pair demo_panels demo_tabs ditto dots_curses dots_mvcur dots_xcurses dup_field echochar extended_color filter firework firstlast foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts key_names keynames knight lrtest move_field movewindow ncurses newdemo padview pair_content picsmap rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_unget_wch testaddch testcurs testscanw view worm xmas
+endwin				test: back_ground background blue bs cardfile chgat clip_printw color_content color_set combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_new_pair demo_panels demo_tabs ditto dots_curses dots_mvcur dots_xcurses dup_field echochar extended_color filter firework firstlast foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts key_names keynames knight lrtest move_field movewindow ncurses newdemo padview pair_content picsmap rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_unget_wch testaddch testcurs testscanw view worm xmas
 endwin_sp			lib: ncurses
 erase				test: cardfile demo_menus filter firework firstlast hanoi lrtest ncurses picsmap tclock test_opaque testcurs
 erasechar			test: ncurses
 erasechar_sp			test: sp_tinfo
 erasewchar			test: ncurses
 erasewchar_sp			lib: ncurses
-exit_curses			test: back_ground background blue bs cardfile chgat clip_printw color_content color_set combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_new_pair demo_panels demo_tabs ditto dots_curses dots_xcurses dup_field echochar extended_color filter firework firstlast foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts key_names keynames knight lrtest move_field movewindow ncurses newdemo padview pair_content picsmap rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_setupterm test_termattrs test_unget_wch testaddch testcurs testscanw view worm xmas
+exit_curses			test: back_ground background blue bs cardfile chgat clip_printw color_content color_set combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_new_pair demo_panels demo_tabs ditto dots_curses dots_xcurses dup_field echochar extended_color filter firework firstlast foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts key_names keynames knight lrtest move_field movewindow ncurses newdemo padview pair_content picsmap rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_setupterm test_termattrs test_unget_wch testaddch testcurs testscanw view worm xmas
 exit_terminfo			test: demo_termcap demo_terminfo dots dots_mvcur dots_termcap list_keys railroad sp_tinfo test_arrays test_sgr test_tparm test_vid_puts test_vidputs
 extended_color_content		test: color_content extended_color
 extended_color_content_sp	test: extended_color
@@ -539,7 +539,7 @@ mvwinsnstr			test: inserts
 mvwinsstr			test: inserts testcurs
 mvwinstr			test: test_instr
 mvwinwstr			test: test_inwstr
-mvwprintw			test: demo_menus demo_panels inch_wide inchs ncurses test_instr test_inwstr testcurs
+mvwprintw			test: demo_menus demo_panels inch_wide inchs ncurses test_delwin test_instr test_inwstr testcurs
 mvwscanw			test: testcurs
 mvwvline			test: ins_wide inserts movewindow ncurses test_add_wchstr test_addchstr test_addstr test_addwstr
 mvwvline_set			-
@@ -549,16 +549,16 @@ new_prescr			test: sp_tinfo
 newpad				test: ncurses padview popup_msg testcurs
 newpad_sp			lib: ncurses
 newscr				lib: ncurses
-newterm				test: demo_altkeys demo_new_pair ditto dots_mvcur extended_color filter foldkeys gdc key_names keynames redraw test_setupterm test_termattrs
+newterm				test: demo_altkeys demo_new_pair ditto dots_mvcur extended_color filter foldkeys gdc key_names keynames redraw test_delwin test_setupterm test_termattrs
 newterm_sp			-
-newwin				test: cardfile chgat clip_printw demo_defkey demo_forms demo_keyok demo_menus demo_panels ditto firstlast inch_wide inchs ins_wide insdelln inserts knight movewindow ncurses newdemo popup_msg redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view xmas
+newwin				test: cardfile chgat clip_printw demo_defkey demo_forms demo_keyok demo_menus demo_panels ditto firstlast inch_wide inchs ins_wide insdelln inserts knight movewindow ncurses newdemo popup_msg redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view xmas
 newwin_sp			lib: ncurses
 nl				test: demo_forms dup_field move_field ncurses rain testcurs
 nl_sp				lib: ncurses
 nocbreak			test: testcurs
 nocbreak_sp			test: sp_tinfo
 nodelay				test: demo_new_pair ditto extended_color firework gdc lrtest ncurses newdemo padview rain tclock test_opaque view worm xmas
-noecho				test: back_ground background bs cardfile chgat clip_printw color_content color_set combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_new_pair demo_panels demo_tabs ditto dup_field extended_color firework firstlast foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts knight lrtest move_field movewindow ncurses padview pair_content picsmap rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_unget_wch testcurs view worm xmas
+noecho				test: back_ground background bs cardfile chgat clip_printw color_content color_set combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_new_pair demo_panels demo_tabs ditto dup_field extended_color firework firstlast foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts knight lrtest move_field movewindow ncurses padview pair_content picsmap rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_unget_wch testcurs view worm xmas
 noecho_sp			lib: ncurses
 nofilter			-
 nofilter_sp			-
@@ -581,7 +581,7 @@ pecho_wchar			-
 pechochar			-
 pnoutrefresh			test: ncurses padview popup_msg
 prefresh			test: testcurs
-printw				test: back_ground background blue bs color_content color_set combine demo_altkeys demo_defkey demo_keyok demo_tabs extended_color filter foldkeys ncurses pair_content savescreen test_unget_wch testcurs testscanw view
+printw				test: back_ground background blue bs color_content color_set combine demo_altkeys demo_defkey demo_keyok demo_tabs extended_color filter foldkeys ncurses pair_content savescreen test_delwin test_unget_wch testcurs testscanw view
 putp				test: filter test_mouse test_sgr progs: tput
 putp_sp				test: sp_tinfo
 putwin				test: ncurses
@@ -590,7 +590,7 @@ qiflush_sp			test: sp_tinfo
 raw				test: demo_forms dup_field move_field ncurses redraw testcurs
 raw_sp				test: sp_tinfo
 redrawwin			test: combine padview redraw view
-refresh				test: blue bs color_content demo_defkey demo_forms demo_keyok demo_menus demo_panels demo_tabs dots_curses dots_mvcur dots_xcurses dup_field echochar filter firstlast form_driver_w gdc hanoi hashtest lrtest move_field movewindow ncurses pair_content picsmap savescreen tclock test_mouse testcurs view xmas
+refresh				test: blue bs color_content demo_defkey demo_forms demo_keyok demo_menus demo_panels demo_tabs dots_curses dots_mvcur dots_xcurses dup_field echochar filter firstlast form_driver_w gdc hanoi hashtest lrtest move_field movewindow ncurses pair_content picsmap savescreen tclock test_delwin test_mouse testcurs view xmas
 reset_color_pairs		test: picsmap
 reset_color_pairs_sp		-
 reset_prog_mode			test: filter ncurses
@@ -619,7 +619,7 @@ scr_set				test: savescreen
 scr_set_sp			-
 scrl				test: view
 scroll				test: testcurs
-scrollok			test: clip_printw color_content demo_altkeys demo_defkey demo_keyok demo_new_pair demo_panels ditto foldkeys hashtest knight ncurses pair_content picsmap redraw test_opaque test_unget_wch testcurs testscanw view
+scrollok			test: clip_printw color_content demo_altkeys demo_defkey demo_keyok demo_new_pair demo_panels ditto foldkeys hashtest knight ncurses pair_content picsmap redraw test_delwin test_opaque test_unget_wch testcurs testscanw view
 set_curterm			test: list_keys sp_tinfo
 set_curterm_sp			test: sp_tinfo
 set_escdelay			test: test_opaque
@@ -665,7 +665,7 @@ standend			test: blue gdc ncurses
 standout			test: blue ncurses
 start_color			test: back_ground background blue bs cardfile chgat clip_printw color_content color_set demo_forms demo_menus demo_new_pair demo_panels dots_curses dots_xcurses dup_field echochar extended_color filter firework gdc hanoi ins_wide insdelln inserts knight move_field ncurses newdemo padview pair_content picsmap rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr testaddch testcurs view worm xmas
 start_color_sp			-
-stdscr				test: back_ground background bs chgat clip_printw color_content combine demo_altkeys demo_forms demo_menus demo_new_pair demo_panels ditto dup_field edit_field extended_color filter firework foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts key_names keynames knight lrtest move_field movewindow ncurses padview pair_content picsmap rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_unget_wch testcurs testscanw view worm xmas
+stdscr				test: back_ground background bs chgat clip_printw color_content combine demo_altkeys demo_forms demo_menus demo_new_pair demo_panels ditto dup_field edit_field extended_color filter firework foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts key_names keynames knight lrtest move_field movewindow ncurses padview pair_content picsmap rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_unget_wch testcurs testscanw view worm xmas
 strcodes			test: demo_termcap test_arrays progs: dump_entry
 strfnames			test: demo_terminfo list_keys test_arrays progs: dump_entry
 strnames			test: demo_terminfo foldkeys list_keys test_arrays test_tparm progs: dump_entry infocmp tic
@@ -696,7 +696,7 @@ tigetstr_sp			test: sp_tinfo
 timeout				test: filter rain savescreen
 tiparm				-
 touchline			test: chgat clip_printw insdelln
-touchwin			test: chgat clip_printw demo_menus filter firstlast inch_wide inchs ins_wide insdelln inserts movewindow ncurses popup_msg redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque xmas
+touchwin			test: chgat clip_printw demo_menus filter firstlast inch_wide inchs ins_wide insdelln inserts movewindow ncurses popup_msg redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_opaque xmas
 tparm				test: dots dots_mvcur test_mouse test_sgr test_tparm progs: tic tput
 tputs				test: dots dots_mvcur dots_termcap railroad test_tparm test_vid_puts test_vidputs progs: clear_cmd reset_cmd tabs
 tputs_sp			test: sp_tinfo
@@ -763,7 +763,7 @@ wborder				test: ncurses
 wborder_set			test: ncurses
 wchgat				test: chgat test_get_wstr test_getstr view
 wclear				test: ncurses test_opaque testcurs
-wclrtobot			test: firstlast inch_wide inchs ncurses test_instr test_inwstr testcurs
+wclrtobot			test: firstlast inch_wide inchs ncurses test_delwin test_instr test_inwstr testcurs
 wclrtoeol			test: chgat clip_printw demo_defkey demo_keyok demo_menus demo_panels firstlast inch_wide inchs ins_wide insdelln inserts knight ncurses test_add_wchstr test_addchstr test_addstr test_addwstr test_instr test_inwstr testcurs
 wcolor_set			lib: ncurses
 wcursyncup			lib: form
@@ -776,7 +776,7 @@ werase				test: cardfile demo_forms demo_menus demo_panels dup_field firstlast k
 wget_wch			test: ins_wide ncurses test_add_wchstr test_addwstr
 wget_wstr			test: test_get_wstr
 wgetbkgrnd			lib: ncurses
-wgetch				test: cardfile chgat clip_printw demo_defkey demo_keyok demo_menus demo_panels ditto dump_window dup_field edit_field gdc insdelln inserts knight move_field movewindow ncurses newdemo popup_msg rain redraw test_addchstr test_addstr test_opaque testcurs worm
+wgetch				test: cardfile chgat clip_printw demo_defkey demo_keyok demo_menus demo_panels ditto dump_window dup_field edit_field gdc insdelln inserts knight move_field movewindow ncurses newdemo popup_msg rain redraw test_addchstr test_addstr test_delwin test_opaque testcurs worm
 wgetdelay			test: test_opaque
 wgetn_wstr			test: ncurses test_get_wstr
 wgetnstr			test: ncurses test_getstr
@@ -808,11 +808,11 @@ wmove				test: chgat clip_printw demo_altkeys demo_defkey demo_keyok demo_menus
 wnoutrefresh			test: demo_menus ditto inch_wide inchs ins_wide inserts knight movewindow ncurses padview popup_msg redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque
 wprintw				test: chgat clip_printw demo_defkey demo_forms demo_keyok demo_menus demo_panels inch_wide inchs ins_wide insdelln inserts knight ncurses test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque testcurs
 wredrawln			test: redraw
-wrefresh			test: chgat clip_printw demo_forms demo_keyok demo_menus demo_panels dup_field firstlast ins_wide insdelln inserts knight lrtest move_field movewindow ncurses newdemo popup_msg redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr testcurs worm xmas
+wrefresh			test: chgat clip_printw demo_forms demo_keyok demo_menus demo_panels dup_field firstlast ins_wide insdelln inserts knight lrtest move_field movewindow ncurses newdemo popup_msg redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin testcurs worm xmas
 wresize				test: cardfile demo_menus ncurses
 wscanw				test: testcurs
 wscrl				test: ncurses testcurs
-wsetscrreg			test: ncurses testcurs
+wsetscrreg			test: ncurses test_delwin testcurs
 wstandend			test: ncurses test_opaque xmas
 wstandout			test: ncurses test_opaque xmas
 wsyncdown			test: movewindow
diff --git a/test/demo_tabs.c b/test/demo_tabs.c
index 6bd067ea..2fa79287 100644
--- a/test/demo_tabs.c
+++ b/test/demo_tabs.c
@@ -29,13 +29,13 @@
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: demo_tabs.c,v 1.6 2022/05/15 13:04:57 tom Exp $
+ * $Id: demo_tabs.c,v 1.7 2022/08/13 21:02:25 tom Exp $
  *
  * A simple demo of tabs in curses.
  */
 #define USE_CURSES
 #define USE_TINFO
-#include "test.priv.h"
+#include 
 
 static void
 usage(void)
diff --git a/test/modules b/test/modules
index 6c5125f7..7e3fcc22 100644
--- a/test/modules
+++ b/test/modules
@@ -1,4 +1,4 @@
-# $Id: modules,v 1.77 2022/05/07 22:39:21 tom Exp $
+# $Id: modules,v 1.78 2022/08/13 20:53:43 tom Exp $
 ##############################################################################
 # Copyright 2018-2021,2022 Thomas E. Dickey                                  #
 # Copyright 1998-2016,2017 Free Software Foundation, Inc.                    #
@@ -101,6 +101,7 @@ test_addchstr	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/linedata.h
 test_addstr	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/linedata.h
 test_addwstr	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/linedata.h
 test_arrays	progs		$(srcdir)	$(HEADER_DEPS)
+test_delwin	progs		$(srcdir)	$(HEADER_DEPS)
 test_get_wstr	progs		$(srcdir)	$(HEADER_DEPS)
 test_getstr	progs		$(srcdir)	$(HEADER_DEPS)
 test_instr	progs		$(srcdir)	$(HEADER_DEPS)
diff --git a/test/programs b/test/programs
index 306a1b07..191a16dc 100644
--- a/test/programs
+++ b/test/programs
@@ -1,4 +1,4 @@
-# $Id: programs,v 1.53 2022/05/07 22:39:49 tom Exp $
+# $Id: programs,v 1.55 2022/08/13 23:37:10 tom Exp $
 ##############################################################################
 # Copyright 2018-2021,2022 Thomas E. Dickey                                  #
 # Copyright 2006-2016,2017 Free Software Foundation, Inc.                    #
@@ -96,6 +96,7 @@ test_addchstr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_addchstr
 test_addstr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_addstr
 test_addwstr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_addwstr
 test_arrays	$(LDFLAGS_TINFO)	$(LOCAL_LIBS)	test_arrays
+test_delwin	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_delwin
 test_get_wstr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_get_wstr popup_msg
 test_getstr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_getstr popup_msg
 test_instr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_instr
diff --git a/test/test_delwin.c b/test/test_delwin.c
new file mode 100644
index 00000000..450dad1e
--- /dev/null
+++ b/test/test_delwin.c
@@ -0,0 +1,117 @@
+/****************************************************************************
+ * Copyright 2022 Thomas E. Dickey                                          *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/*
+ * $Id: test_delwin.c,v 1.3 2022/08/14 00:12:52 tom Exp $
+ */
+#include 
+
+#define STATUS 10
+
+static SCREEN *my_screen;
+
+static void
+show_rc(const char *what, const char *explain, int rc)
+{
+    printw("%s : %d (%s)\n", what, rc, explain);
+}
+
+static void
+next_step(WINDOW *win)
+{
+    int ch = wgetch(win);
+    if (ch == QUIT || ch == ESCAPE) {
+	endwin();
+	/* use this to verify if delscreen frees all memory */
+	delscreen(my_screen);
+	exit(EXIT_FAILURE);
+    }
+}
+
+int
+main(void)
+{
+    WINDOW *parent, *child1;
+    int rc;
+
+    if ((my_screen = newterm(NULL, stdout, stdin)) == NULL)
+	ExitProgram(EXIT_FAILURE);
+
+    noecho();
+    cbreak();
+
+    refresh();
+    wsetscrreg(stdscr, 0, STATUS - 1);
+    scrollok(stdscr, TRUE);
+
+    parent = newwin(0, 0, STATUS, 0);
+    box(parent, 0, 0);
+    wrefresh(parent);
+    next_step(parent);
+
+    printw("New window %p    %s\n", (void *) parent, "Top window");
+    mvwprintw(parent, 1, 1, "Top window");
+    wrefresh(parent);
+    next_step(stdscr);
+
+    child1 = derwin(parent, LINES - STATUS - 4, COLS - 4, 2, 2);
+    box(child1, 0, 0);
+    mvwprintw(child1, 1, 1, "Sub window");
+    wrefresh(child1);
+
+    printw("Sub window %p    %s\n", (void *) child1, "Hello world!");
+    next_step(stdscr);
+
+    show_rc("Deleted parent",
+	    "should fail, it still has a subwindow",
+	    rc = delwin(parent));
+    next_step(stdscr);
+    show_rc("Deleted child1",
+	    "should succeed",
+	    rc = delwin(child1));
+    next_step(stdscr);
+    if (rc == OK) {
+	wclrtobot(parent);
+	box(parent, 0, 0);
+	next_step(parent);
+    }
+    show_rc("Deleted parent",
+	    "should succeed, it has no subwindow now",
+	    rc = delwin(parent));
+    next_step(stdscr);
+    if (rc == OK) {
+	touchwin(stdscr);
+	next_step(stdscr);
+    }
+    show_rc("Deleted parent",
+	    "should fail, may dump core",
+	    delwin(parent));
+    next_step(stdscr);
+    endwin();
+    ExitProgram(EXIT_SUCCESS);
+}
diff --git a/test/worm.c b/test/worm.c
index 4888a519..2ce1c5ee 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.84 2022/07/23 17:06:16 tom Exp $
+  $Id: worm.c,v 1.85 2022/08/13 13:28:01 tom Exp $
 */
 
 #include 
@@ -663,6 +663,15 @@ main(int argc, char *argv[])
 
     Trace(("Cleanup"));
     cleanup();
+#ifdef USE_PTHREADS
+    /*
+     * Do this just in case one of the threads did not really exit.
+     */
+    Trace(("join all threads"));
+    for (n = 0; n < number; n++) {
+	pthread_join(worm[n].thread, NULL);
+    }
+#endif
 #if NO_LEAKS
     for (y = 0; y < max_refs; y++) {
 	free(refs[y]);
@@ -672,15 +681,6 @@ main(int argc, char *argv[])
 	free(w->xpos);
 	free(w->ypos);
     }
-#endif
-#ifdef USE_PTHREADS
-    /*
-     * Do this just in case one of the threads did not really exit.
-     */
-    Trace(("join all threads"));
-    for (n = 0; n < number; n++) {
-	pthread_join(worm[n].thread, NULL);
-    }
 #endif
     ExitProgram(EXIT_SUCCESS);
 }