# ncurses 6.3 - patch 20211106 - Thomas E. Dickey
#
# ------------------------------------------------------------------------------
#
# Ncurses 6.3 is at
# 	ftp://ftp.invisible-island.net/ncurses/
#	https://invisible-mirror.net/archives/ncurses/
#
# Patches for ncurses 6.3 can be found at
# 	ftp://ftp.invisible-island.net/ncurses//6.3
#	https://invisible-mirror.net/archives/ncurses//6.3
#
# ------------------------------------------------------------------------------
# ftp://ftp.invisible-island.net/ncurses//6.3/ncurses-6.3-20211106.patch.gz
# patch by Thomas E. Dickey <dickey@invisible-island.net>
# created  Sun Nov  7 00:20:43 UTC 2021
# ------------------------------------------------------------------------------
# NEWS                             |   10 +++++++++-
# VERSION                          |    2 +-
# dist.mk                          |    4 ++--
# misc/Makefile.in                 |    4 ++--
# ncurses/base/lib_delwin.c        |   33 ++++++++++++++++++++-------------
# ncurses/base/lib_freeall.c       |    5 ++++-
# ncurses/base/lib_refresh.c       |   22 +++++++++++++++-------
# ncurses/tinfo/lib_cur_term.c     |    7 +++++--
# 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 +-
# panel/p_new.c                    |    4 ++--
# 16 files changed, 71 insertions(+), 42 deletions(-)
# ------------------------------------------------------------------------------
Index: NEWS
Prereq:  1.3738 
--- ncurses-6.3-20211030+/NEWS	2021-10-31 00:31:12.000000000 +0000
+++ ncurses-6.3-20211106/NEWS	2021-11-06 23:43:40.000000000 +0000
@@ -26,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: NEWS,v 1.3738 2021/10/31 00:31:12 tom Exp $
+-- $Id: NEWS,v 1.3741 2021/11/06 23:43:40 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
@@ -46,6 +46,14 @@
 Changes through 1.9.9e did not credit all contributions;
 it is not possible to add this information.
 
+20211106
+	+ improve check in misc/Makefile.in for empty $PKG_CONFIG_LIBDIR
+	+ modify wnoutrefresh to call pnoutrefresh if its parameter is a pad,
+	  rather than treating it as an error, and modify new_panel to permit
+	  its window-parameter to be a pad (report by Giorgos Xou).
+	+ fix a memory-leak in del_curterm (prompted by discussion with Bram
+	  Moolenaar, cf: 20210821).
+
 20211030
 	+ simplify some references to WINDOWS._flags using macros.
 	+ add a "check" rule in Ada95 makefile, to help with test-packages.
Index: VERSION
--- ncurses-6.3-20211030+/VERSION	2021-10-30 08:33:19.000000000 +0000
+++ ncurses-6.3-20211106/VERSION	2021-11-06 08:19:47.000000000 +0000
@@ -1 +1 @@
-5:0:10	6.3	20211030
+5:0:10	6.3	20211106
Index: dist.mk
Prereq:  1.1447 
--- ncurses-6.3-20211030+/dist.mk	2021-10-30 08:33:19.000000000 +0000
+++ ncurses-6.3-20211106/dist.mk	2021-11-06 08:19:47.000000000 +0000
@@ -26,7 +26,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: dist.mk,v 1.1447 2021/10/30 08:33:19 tom Exp $
+# $Id: dist.mk,v 1.1448 2021/11/06 08:19:47 tom Exp $
 # Makefile for creating ncurses distributions.
 #
 # This only needs to be used directly as a makefile by developers, but
@@ -38,7 +38,7 @@
 # These define the major/minor/patch versions of ncurses.
 NCURSES_MAJOR = 6
 NCURSES_MINOR = 3
-NCURSES_PATCH = 20211030
+NCURSES_PATCH = 20211106
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
Index: misc/Makefile.in
Prereq:  1.78 
--- ncurses-6.3-20211030+/misc/Makefile.in	2021-07-03 19:07:50.000000000 +0000
+++ ncurses-6.3-20211106/misc/Makefile.in	2021-11-06 23:36:12.000000000 +0000
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.78 2021/07/03 19:07:50 tom Exp $
+# $Id: Makefile.in,v 1.79 2021/11/06 23:36:12 tom Exp $
 ##############################################################################
 # Copyright 2018-2020,2021 Thomas E. Dickey                                  #
 # Copyright 1998-2016,2017 Free Software Foundation, Inc.                    #
@@ -147,7 +147,7 @@
 # directory during this rule:
 @MAKE_PC_FILES@install \
 @MAKE_PC_FILES@install.libs :: pc-files
-@MAKE_PC_FILES@	@$(SHELL) -c 'case "x$(DESTDIR)$(PKG_CONFIG_LIBDIR)" in \
+@MAKE_PC_FILES@	@$(SHELL) -c 'case "x$(PKG_CONFIG_LIBDIR)" in \
 @MAKE_PC_FILES@		x/*) \
 @MAKE_PC_FILES@			mkdir -p $(DESTDIR)$(PKG_CONFIG_LIBDIR); \
 @MAKE_PC_FILES@			for name in $(PC_FILES); do \
Index: ncurses/base/lib_delwin.c
Prereq:  1.21 
--- ncurses-6.3-20211030+/ncurses/base/lib_delwin.c	2020-02-02 23:34:34.000000000 +0000
+++ ncurses-6.3-20211106/ncurses/base/lib_delwin.c	2021-11-06 21:54:14.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2008,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,24 +43,28 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_delwin.c,v 1.21 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_delwin.c,v 1.22 2021/11/06 21:54:14 tom Exp $")
 
 static bool
 cannot_delete(WINDOW *win)
 {
     WINDOWLIST *p;
     bool result = TRUE;
+    if (IS_PAD(win)) {
+	result = FALSE;
+    } else {
 #ifdef USE_SP_WINDOWLIST
-    SCREEN *sp = _nc_screen_of(win);
+	SCREEN *sp = _nc_screen_of(win);
 #endif
 
-    for (each_window(SP_PARM, p)) {
-	if (&(p->win) == win) {
-	    result = FALSE;
-	} else if ((p->win._flags & _SUBWIN) != 0
-		   && p->win._parent == win) {
-	    result = TRUE;
-	    break;
+	for (each_window(SP_PARM, p)) {
+	    if (&(p->win) == win) {
+		result = FALSE;
+	    } else if (IS_SUBWIN(&(p->win))
+		       && p->win._parent == win) {
+		result = TRUE;
+		break;
+	    }
 	}
     }
     return result;
@@ -77,15 +81,18 @@
 	if (win == 0
 	    || cannot_delete(win)) {
 	    result = ERR;
+	} else if (IS_PAD(win)) {
+	    win->_parent = NULL;
+	    result = OK;
 	} else {
 #if NCURSES_SP_FUNCS
 	    SCREEN *sp = _nc_screen_of(win);
 #endif
-	    if (win->_flags & _SUBWIN)
+	    if (IS_SUBWIN(win)) {
 		touchwin(win->_parent);
-	    else if (CurScreen(SP_PARM) != 0)
+	    } else if (CurScreen(SP_PARM) != 0) {
 		touchwin(CurScreen(SP_PARM));
-
+	    }
 	    result = _nc_freewin(win);
 	}
 	_nc_unlock_global(curses);
Index: ncurses/base/lib_freeall.c
Prereq:  1.75 
--- ncurses-6.3-20211030+/ncurses/base/lib_freeall.c	2021-10-23 18:53:46.000000000 +0000
+++ ncurses-6.3-20211106/ncurses/base/lib_freeall.c	2021-11-06 21:52:49.000000000 +0000
@@ -40,7 +40,7 @@
 extern int malloc_errfd;	/* FIXME */
 #endif
 
-MODULE_ID("$Id: lib_freeall.c,v 1.75 2021/10/23 18:53:46 tom Exp $")
+MODULE_ID("$Id: lib_freeall.c,v 1.76 2021/11/06 21:52:49 tom Exp $")
 
 /*
  * Free all ncurses data.  This is used for testing only (there's no practical
@@ -78,6 +78,9 @@
 		WINDOW *p_win = &(p->win);
 		bool found = FALSE;
 
+		if (IS_PAD(p_win))
+		    continue;
+
 #ifndef USE_SP_WINDOWLIST
 		if (p->screen != SP_PARM)
 		    continue;
Index: ncurses/base/lib_refresh.c
Prereq:  1.46 
--- ncurses-6.3-20211030+/ncurses/base/lib_refresh.c	2020-02-02 23:34:34.000000000 +0000
+++ ncurses-6.3-20211106/ncurses/base/lib_refresh.c	2021-11-06 22:22:03.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2011 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_refresh.c,v 1.46 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_refresh.c,v 1.47 2021/11/06 22:22:03 tom Exp $")
 
 NCURSES_EXPORT(int)
 wrefresh(WINDOW *win)
@@ -92,13 +92,21 @@
 
     T((T_CALLED("wnoutrefresh(%p)"), (void *) win));
 
-    /*
-     * This function will break badly if we try to refresh a pad.
-     */
-    if ((win == 0)
-	|| (win->_flags & _ISPAD))
+    if (win == NULL)
 	returnCode(ERR);
 
+    /*
+     * Handle pads as a special case.
+     */
+    if (IS_PAD(win)) {
+	returnCode(pnoutrefresh(win,
+				win->_pad._pad_y,
+				win->_pad._pad_x,
+				win->_pad._pad_top,
+				win->_pad._pad_left,
+				win->_pad._pad_bottom,
+				win->_pad._pad_right));
+    }
 #ifdef TRACE
     if (USE_TRACEF(TRACE_UPDATE)) {
 	_tracedump("...win", win);
Index: ncurses/tinfo/lib_cur_term.c
Prereq:  1.43 
--- ncurses-6.3-20211030+/ncurses/tinfo/lib_cur_term.c	2020-10-24 18:54:32.000000000 +0000
+++ ncurses-6.3-20211106/ncurses/tinfo/lib_cur_term.c	2021-11-06 19:04:21.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -41,7 +41,7 @@
 #include <termcap.h>		/* ospeed */
 #include <tic.h>		/* VALID_STRING */
 
-MODULE_ID("$Id: lib_cur_term.c,v 1.43 2020/10/24 18:54:32 tom Exp $")
+MODULE_ID("$Id: lib_cur_term.c,v 1.44 2021/11/06 19:04:21 tom Exp $")
 
 #undef CUR
 #define CUR TerminalType(termp).
@@ -167,10 +167,13 @@
 	/* discard memory used in tgetent's cache for this terminal */
 	_nc_tgetent_leak(termp);
 #endif
+	free(termp->tparm_state.fmt_buff);
+	free(termp->tparm_state.out_buff);
 	free(termp);
 
 	rc = OK;
     }
+
     returnCode(rc);
 }
 
Index: package/debian-mingw/changelog
--- ncurses-6.3-20211030+/package/debian-mingw/changelog	2021-10-30 08:33:19.000000000 +0000
+++ ncurses-6.3-20211106/package/debian-mingw/changelog	2021-11-06 08:19:47.000000000 +0000
@@ -1,8 +1,8 @@
-ncurses6 (6.3+20211030) unstable; urgency=low
+ncurses6 (6.3+20211106) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 30 Oct 2021 04:33:19 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 06 Nov 2021 04:19:47 -0400
 
 ncurses6 (5.9-20131005) unstable; urgency=low
 
Index: package/debian-mingw64/changelog
--- ncurses-6.3-20211030+/package/debian-mingw64/changelog	2021-10-30 08:33:19.000000000 +0000
+++ ncurses-6.3-20211106/package/debian-mingw64/changelog	2021-11-06 08:19:47.000000000 +0000
@@ -1,8 +1,8 @@
-ncurses6 (6.3+20211030) unstable; urgency=low
+ncurses6 (6.3+20211106) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 30 Oct 2021 04:33:19 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 06 Nov 2021 04:19:47 -0400
 
 ncurses6 (5.9-20131005) unstable; urgency=low
 
Index: package/debian/changelog
--- ncurses-6.3-20211030+/package/debian/changelog	2021-10-30 08:33:19.000000000 +0000
+++ ncurses-6.3-20211106/package/debian/changelog	2021-11-06 08:19:47.000000000 +0000
@@ -1,8 +1,8 @@
-ncurses6 (6.3+20211030) unstable; urgency=low
+ncurses6 (6.3+20211106) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 30 Oct 2021 04:33:19 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 06 Nov 2021 04:19:47 -0400
 
 ncurses6 (5.9-20120608) unstable; urgency=low
 
Index: package/mingw-ncurses.nsi
Prereq:  1.489 
--- ncurses-6.3-20211030+/package/mingw-ncurses.nsi	2021-10-30 08:33:19.000000000 +0000
+++ ncurses-6.3-20211106/package/mingw-ncurses.nsi	2021-11-06 08:19:47.000000000 +0000
@@ -1,4 +1,4 @@
-; $Id: mingw-ncurses.nsi,v 1.489 2021/10/30 08:33:19 tom Exp $
+; $Id: mingw-ncurses.nsi,v 1.490 2021/11/06 08:19:47 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  "2021"
-!define VERSION_MMDD  "1030"
+!define VERSION_MMDD  "1106"
 !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD}
 
 !define MY_ABI   "5"
Index: package/mingw-ncurses.spec
--- ncurses-6.3-20211030+/package/mingw-ncurses.spec	2021-10-30 08:33:19.000000000 +0000
+++ ncurses-6.3-20211106/package/mingw-ncurses.spec	2021-11-06 08:19:47.000000000 +0000
@@ -3,7 +3,7 @@
 Summary: shared libraries for terminal handling
 Name: mingw32-ncurses6
 Version: 6.3
-Release: 20211030
+Release: 20211106
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
Index: package/ncurses.spec
--- ncurses-6.3-20211030+/package/ncurses.spec	2021-10-30 08:33:19.000000000 +0000
+++ ncurses-6.3-20211106/package/ncurses.spec	2021-11-06 08:19:47.000000000 +0000
@@ -1,7 +1,7 @@
 Summary: shared libraries for terminal handling
 Name: ncurses6
 Version: 6.3
-Release: 20211030
+Release: 20211106
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
Index: package/ncursest.spec
--- ncurses-6.3-20211030+/package/ncursest.spec	2021-10-30 08:33:19.000000000 +0000
+++ ncurses-6.3-20211106/package/ncursest.spec	2021-11-06 08:19:47.000000000 +0000
@@ -1,7 +1,7 @@
 Summary: Curses library with POSIX thread support.
 Name: ncursest6
 Version: 6.3
-Release: 20211030
+Release: 20211106
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
Index: panel/p_new.c
Prereq:  1.23 
--- ncurses-6.3-20211030+/panel/p_new.c	2021-06-17 21:20:30.000000000 +0000
+++ ncurses-6.3-20211106/panel/p_new.c	2021-10-23 15:12:06.000000000 +0000
@@ -39,7 +39,7 @@
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_new.c,v 1.23 2021/06/17 21:20:30 tom Exp $")
+MODULE_ID("$Id: p_new.c,v 1.24 2021/10/23 15:12:06 tom Exp $")
 
 #ifdef TRACE
 static char *stdscr_id;
@@ -117,7 +117,7 @@
     (void)root_panel(NCURSES_SP_ARG);
   assert(_nc_stdscr_pseudo_panel);
 
-  if (!(win->_flags & _ISPAD) && (pan = AllocPanel("new_panel")))
+  if ((pan = AllocPanel("new_panel")) != NULL)
     {
       pan->win = win;
       pan->above = (PANEL *)0;