# ncurses 6.3 - patch 20211211 - Thomas E. Dickey
#
# ------------------------------------------------------------------------------
#
# Ncurses 6.3 is at
# 	ftp://ftp.invisible-island.net/ncurses/
#	https://invisible-mirror.net/archives/ncurses/
#	https://ftp.gnu.org/gnu/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-20211211.patch.gz
# patch by Thomas E. Dickey <dickey@invisible-island.net>
# created  Sun Dec 12 01:11:22 UTC 2021
# ------------------------------------------------------------------------------
# Ada95/gen/gen.c                     |    7 -
# MANIFEST                            |    1 
# NEWS                                |    5 
# VERSION                             |    2 
# dist.mk                             |    4 
# ncurses-6.3-20211211/test/combine.c |  204 ++++++++++++++++++++++++++++++++++
# ncurses/base/lib_delwin.c           |    5 
# package/debian-mingw/changelog      |    4 
# package/debian-mingw64/changelog    |    4 
# package/debian/changelog            |    4 
# package/mingw-ncurses.nsi           |    4 
# package/mingw-ncurses.spec          |    2 
# package/ncurses.spec                |    2 
# package/ncursest.spec               |    2 
# progs/tic.c                         |    7 -
# test/modules                        |    3 
# test/programs                       |    3 
# 17 files changed, 237 insertions(+), 26 deletions(-)
# ------------------------------------------------------------------------------
Index: Ada95/gen/gen.c
Prereq:  1.77 
--- ncurses-6.3-20211204+/Ada95/gen/gen.c	2020-08-16 18:05:05.000000000 +0000
+++ ncurses-6.3-20211211/Ada95/gen/gen.c	2021-12-11 21:03:21.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2014,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -35,7 +35,7 @@
 
 /*
     Version Control
-    $Id: gen.c,v 1.77 2020/08/16 18:05:05 tom Exp $
+    $Id: gen.c,v 1.78 2021/12/11 21:03:21 tom Exp $
   --------------------------------------------------------------------------*/
 /*
   This program prints on its standard output the source for the
@@ -95,7 +95,7 @@
 	      const char *name,
 	      size_t value)
 {
-  fprintf(fp, "   %-28s : constant := %lu;\n", name, value);
+  fprintf(fp, "   %-28s : constant := %lu;\n", name, (unsigned long)value);
 }
 
 #define PRINT_NAMED_CONSTANT(name) \
@@ -490,6 +490,7 @@
   print_comment(fp, "Field_Options from opts(3FORM)");
   PRINT_NAMED_BITMASK(Field_Options, O_NL_OVERLOAD);
   PRINT_NAMED_BITMASK(Field_Options, O_BS_OVERLOAD);
+
   /*  Field_Options_Size is defined below */
 
   print_comment(fp, "MEVENT structure from mouse(3NCURSES)");
Index: MANIFEST
--- ncurses-6.3-20211204+/MANIFEST	2021-10-20 22:50:11.000000000 +0000
+++ ncurses-6.3-20211211/MANIFEST	2021-12-11 21:06:27.000000000 +0000
@@ -1111,6 +1111,7 @@
 ./test/color_content.c
 ./test/color_name.h
 ./test/color_set.c
+./test/combine.c
 ./test/configure
 ./test/configure.in
 ./test/demo_altkeys.c
Index: NEWS
Prereq:  1.3753 
--- ncurses-6.3-20211204+/NEWS	2021-12-04 23:03:57.000000000 +0000
+++ ncurses-6.3-20211211/NEWS	2021-12-11 21:46:44.000000000 +0000
@@ -26,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: NEWS,v 1.3753 2021/12/04 23:03:57 tom Exp $
+-- $Id: NEWS,v 1.3755 2021/12/11 21:46:44 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
@@ -46,6 +46,9 @@
 Changes through 1.9.9e did not credit all contributions;
 it is not possible to add this information.
 
+20211211
+	+ add test/combine.c, to demo/test combining characters.
+
 20211204
 	+ improve configure check for getttynam (report by Werner Fink).
 
Index: VERSION
--- ncurses-6.3-20211204+/VERSION	2021-12-04 12:21:05.000000000 +0000
+++ ncurses-6.3-20211211/VERSION	2021-12-11 13:00:34.000000000 +0000
@@ -1 +1 @@
-5:0:10	6.3	20211204
+5:0:10	6.3	20211211
Index: dist.mk
Prereq:  1.1453 
--- ncurses-6.3-20211204+/dist.mk	2021-12-04 12:21:05.000000000 +0000
+++ ncurses-6.3-20211211/dist.mk	2021-12-11 13:00:34.000000000 +0000
@@ -26,7 +26,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: dist.mk,v 1.1453 2021/12/04 12:21:05 tom Exp $
+# $Id: dist.mk,v 1.1454 2021/12/11 13:00:34 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 = 20211204
+NCURSES_PATCH = 20211211
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
Index: ncurses/base/lib_delwin.c
Prereq:  1.23 
--- ncurses-6.3-20211204+/ncurses/base/lib_delwin.c	2021-11-15 23:05:32.000000000 +0000
+++ ncurses-6.3-20211211/ncurses/base/lib_delwin.c	2021-12-11 23:56:25.000000000 +0000
@@ -43,16 +43,17 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_delwin.c,v 1.23 2021/11/15 23:05:32 tom Exp $")
+MODULE_ID("$Id: lib_delwin.c,v 1.24 2021/12/11 23:56:25 tom Exp $")
 
 static bool
 cannot_delete(WINDOW *win)
 {
-    WINDOWLIST *p;
     bool result = TRUE;
+
     if (IS_PAD(win)) {
 	result = FALSE;
     } else {
+	WINDOWLIST *p;
 #ifdef USE_SP_WINDOWLIST
 	SCREEN *sp = _nc_screen_of(win);
 #endif
Index: package/debian-mingw/changelog
--- ncurses-6.3-20211204+/package/debian-mingw/changelog	2021-12-04 12:21:05.000000000 +0000
+++ ncurses-6.3-20211211/package/debian-mingw/changelog	2021-12-11 13:00:34.000000000 +0000
@@ -1,8 +1,8 @@
-ncurses6 (6.3+20211204) unstable; urgency=low
+ncurses6 (6.3+20211211) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 04 Dec 2021 07:21:05 -0500
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 11 Dec 2021 08:00:34 -0500
 
 ncurses6 (5.9-20131005) unstable; urgency=low
 
Index: package/debian-mingw64/changelog
--- ncurses-6.3-20211204+/package/debian-mingw64/changelog	2021-12-04 12:21:05.000000000 +0000
+++ ncurses-6.3-20211211/package/debian-mingw64/changelog	2021-12-11 13:00:34.000000000 +0000
@@ -1,8 +1,8 @@
-ncurses6 (6.3+20211204) unstable; urgency=low
+ncurses6 (6.3+20211211) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 04 Dec 2021 07:21:05 -0500
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 11 Dec 2021 08:00:34 -0500
 
 ncurses6 (5.9-20131005) unstable; urgency=low
 
Index: package/debian/changelog
--- ncurses-6.3-20211204+/package/debian/changelog	2021-12-04 12:21:05.000000000 +0000
+++ ncurses-6.3-20211211/package/debian/changelog	2021-12-11 13:00:34.000000000 +0000
@@ -1,8 +1,8 @@
-ncurses6 (6.3+20211204) unstable; urgency=low
+ncurses6 (6.3+20211211) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 04 Dec 2021 07:21:05 -0500
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 11 Dec 2021 08:00:34 -0500
 
 ncurses6 (5.9-20120608) unstable; urgency=low
 
Index: package/mingw-ncurses.nsi
Prereq:  1.495 
--- ncurses-6.3-20211204+/package/mingw-ncurses.nsi	2021-12-04 12:21:05.000000000 +0000
+++ ncurses-6.3-20211211/package/mingw-ncurses.nsi	2021-12-11 13:00:34.000000000 +0000
@@ -1,4 +1,4 @@
-; $Id: mingw-ncurses.nsi,v 1.495 2021/12/04 12:21:05 tom Exp $
+; $Id: mingw-ncurses.nsi,v 1.496 2021/12/11 13:00:34 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  "1204"
+!define VERSION_MMDD  "1211"
 !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD}
 
 !define MY_ABI   "5"
Index: package/mingw-ncurses.spec
--- ncurses-6.3-20211204+/package/mingw-ncurses.spec	2021-12-04 12:21:05.000000000 +0000
+++ ncurses-6.3-20211211/package/mingw-ncurses.spec	2021-12-11 13:00:34.000000000 +0000
@@ -3,7 +3,7 @@
 Summary: shared libraries for terminal handling
 Name: mingw32-ncurses6
 Version: 6.3
-Release: 20211204
+Release: 20211211
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
Index: package/ncurses.spec
--- ncurses-6.3-20211204+/package/ncurses.spec	2021-12-04 12:21:05.000000000 +0000
+++ ncurses-6.3-20211211/package/ncurses.spec	2021-12-11 13:00:34.000000000 +0000
@@ -1,7 +1,7 @@
 Summary: shared libraries for terminal handling
 Name: ncurses6
 Version: 6.3
-Release: 20211204
+Release: 20211211
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
Index: package/ncursest.spec
--- ncurses-6.3-20211204+/package/ncursest.spec	2021-12-04 12:21:05.000000000 +0000
+++ ncurses-6.3-20211211/package/ncursest.spec	2021-12-11 13:00:34.000000000 +0000
@@ -1,7 +1,7 @@
 Summary: Curses library with POSIX thread support.
 Name: ncursest6
 Version: 6.3
-Release: 20211204
+Release: 20211211
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
Index: progs/tic.c
Prereq:  1.307 
--- ncurses-6.3-20211204+/progs/tic.c	2021-10-05 08:07:05.000000000 +0000
+++ ncurses-6.3-20211211/progs/tic.c	2021-12-12 00:00:33.000000000 +0000
@@ -49,7 +49,7 @@
 #include <parametrized.h>
 #include <transform.h>
 
-MODULE_ID("$Id: tic.c,v 1.307 2021/10/05 08:07:05 tom Exp $")
+MODULE_ID("$Id: tic.c,v 1.308 2021/12/12 00:00:33 tom Exp $")
 
 #define STDIN_NAME "<stdin>"
 
@@ -682,7 +682,6 @@
 main(int argc, char *argv[])
 {
     char my_tmpname[PATH_MAX];
-    char my_altfile[PATH_MAX];
     int v_opt = -1;
     int smart_defaults = TRUE;
     char *termcap;
@@ -933,6 +932,7 @@
     }
 
     if (tmp_fp == NULL) {
+	char my_altfile[PATH_MAX];
 	tmp_fp = open_input(source_file, my_altfile);
 	if (!strcmp(source_file, "-")) {
 	    source_file = STDIN_NAME;
@@ -2717,12 +2717,11 @@
 static void
 check_conflict(TERMTYPE2 *tp)
 {
-    bool conflict = FALSE;
-
     if (!(_nc_syntax == SYN_TERMCAP && capdump)) {
 	char *check = calloc((size_t) (NUM_STRINGS(tp) + 1), sizeof(char));
 	NAME_VALUE *given = get_fkey_list(tp);
 	unsigned j, k;
+	bool conflict = FALSE;
 
 	if (check == NULL)
 	    failed("check_conflict");
Index: test/combine.c
--- /dev/null	2021-12-11 17:04:04.096000000 +0000
+++ ncurses-6.3-20211211/test/combine.c	2021-12-12 01:10:28.000000000 +0000
@@ -0,0 +1,204 @@
+/****************************************************************************
+ * Copyright 2021 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: combine.c,v 1.7 2021/12/12 01:10:28 tom Exp $
+ */
+
+#include <test.priv.h>
+
+#if USE_WIDEC_SUPPORT
+
+static int c_opt;
+static int r_opt;
+
+static int
+next_char(int value)
+{
+    do {
+	++value;
+    } while (!iswprint((wint_t) value));
+    return value;
+}
+
+static void
+do_row(int row, int base_ch, int over_ch)
+{
+    int col = 0;
+    bool done = FALSE;
+    bool reverse = (r_opt && !(row % 2));
+
+    move(row, col);
+    printw("[U+%04X]", over_ch);
+    do {
+	if (c_opt) {
+	    wchar_t source[2];
+	    cchar_t target;
+	    attr_t attr = reverse ? A_REVERSE : A_NORMAL;
+
+	    source[1] = 0;
+
+	    source[0] = base_ch;
+	    setcchar(&target, source, attr, 0, NULL);
+	    add_wch(&target);
+
+	    source[0] = over_ch;
+	    setcchar(&target, source, attr, 0, NULL);
+	    add_wch(&target);
+	} else {
+	    wchar_t data[3];
+
+	    data[0] = base_ch;
+	    data[1] = over_ch;
+	    data[2] = 0;
+	    if (reverse)
+		attr_on(A_REVERSE, NULL);
+	    addwstr(data);
+	    if (reverse)
+		attr_off(A_REVERSE, NULL);
+	}
+	col = getcurx(stdscr);
+	base_ch = next_char(base_ch);
+	done = (col + 1 >= COLS);
+    } while (!done);
+}
+
+#define LAST_OVER 0x6f
+
+static int
+next_over(int value)
+{
+    if (++value > LAST_OVER)
+	value = 0;
+    return value;
+}
+
+static int
+prev_over(int value)
+{
+    if (--value < 0)
+	value = LAST_OVER;
+    return value;
+}
+
+static void
+do_all(int over_it)
+{
+    int row;
+
+    for (row = 0; row < LINES; ++row) {
+	do_row(row, ' ', 0x300 + over_it);
+	over_it = next_over(over_it);
+    }
+}
+
+static void
+usage(void)
+{
+    static const char *msg[] =
+    {
+	"Usage: combine [options]",
+	"",
+	"Demonstrate combining-characters.",
+	"",
+	"Options:",
+	" -c       use cchar_t data rather than wchar_t string",
+	" -r       draw even-numbered rows in reverse-video",
+    };
+    unsigned n;
+    for (n = 0; n < SIZEOF(msg); ++n) {
+	fprintf(stderr, "%s\n", msg[n]);
+    }
+    ExitProgram(EXIT_FAILURE);
+}
+
+int
+main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+{
+    int n;
+    int over_it = 0;
+    bool done = FALSE;
+
+    while ((n = getopt(argc, argv, "cr")) != -1) {
+	switch (n) {
+	case 'c':
+	    c_opt = TRUE;
+	    break;
+	case 'r':
+	    r_opt = TRUE;
+	    break;
+	default:
+	    usage();
+	    break;
+	}
+    }
+
+    setlocale(LC_ALL, "");
+    initscr();
+    cbreak();
+    noecho();
+    keypad(stdscr, TRUE);
+
+    do {
+	do_all(over_it);
+	switch (getch()) {
+	case 'q':
+	case QUIT:
+	case ESCAPE:
+	    done = TRUE;
+	    break;
+	case KEY_HOME:
+	case '0':
+	    over_it = 0;
+	    break;
+	case KEY_END:
+	case '$':
+	    over_it = LAST_OVER;
+	    break;
+	case KEY_UP:
+	case '-':
+	    over_it = prev_over(over_it);
+	    break;
+	case KEY_DOWN:
+	case '+':
+	    over_it = next_over(over_it);
+	    break;
+	}
+    } while (!done);
+
+    endwin();
+
+    ExitProgram(EXIT_SUCCESS);
+}
+#else
+int
+main(void)
+{
+    printf("This program requires wide-curses functions\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
Index: test/modules
Prereq:  1.74 
--- ncurses-6.3-20211204+/test/modules	2021-02-13 16:33:43.000000000 +0000
+++ ncurses-6.3-20211211/test/modules	2021-12-11 17:41:34.000000000 +0000
@@ -1,4 +1,4 @@
-# $Id: modules,v 1.74 2021/02/13 16:33:43 tom Exp $
+# $Id: modules,v 1.75 2021/12/11 17:41:34 tom Exp $
 ##############################################################################
 # Copyright 2018-2020,2021 Thomas E. Dickey                                  #
 # Copyright 1998-2016,2017 Free Software Foundation, Inc.                    #
@@ -42,6 +42,7 @@
 clip_printw	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
 color_content	progs		$(srcdir)	$(HEADER_DEPS)
 color_set	progs		$(srcdir)	$(HEADER_DEPS)
+combine		progs		$(srcdir)	$(HEADER_DEPS)
 demo_altkeys	progs		$(srcdir)	$(HEADER_DEPS)
 demo_defkey	progs		$(srcdir)	$(HEADER_DEPS)
 demo_forms	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/edit_field.h
Index: test/programs
Prereq:  1.49 
--- ncurses-6.3-20211204+/test/programs	2021-03-13 20:37:44.000000000 +0000
+++ ncurses-6.3-20211211/test/programs	2021-12-11 17:46:18.000000000 +0000
@@ -1,4 +1,4 @@
-# $Id: programs,v 1.49 2021/03/13 20:37:44 tom Exp $
+# $Id: programs,v 1.50 2021/12/11 17:46:18 tom Exp $
 ##############################################################################
 # Copyright 2018-2020,2021 Thomas E. Dickey                                  #
 # Copyright 2006-2016,2017 Free Software Foundation, Inc.                    #
@@ -40,6 +40,7 @@
 clip_printw	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	clip_printw popup_msg
 color_content	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	color_content
 color_set	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	color_set
+combine		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	combine popup_msg
 demo_altkeys	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	demo_altkeys
 demo_defkey	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	demo_defkey
 demo_forms	$(LDFLAGS_DEFAULT)	$(LOCAL_LIBS)	demo_forms edit_field popup_msg