libncurses: Import https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.5.tar.gz changes

Change-Id: I3433d30ca01359fd2e3623ede96b531f0b39cbfa
Signed-off-by: micky387 <mickaelsaibi@free.fr>
diff --git a/ncurses/Makefile b/ncurses/Makefile
deleted file mode 100644
index 528f13f..0000000
--- a/ncurses/Makefile
+++ /dev/null
@@ -1,2420 +0,0 @@
-# $Id: Makefile.in,v 1.147 2015/08/05 23:15:41 tom Exp $
-##############################################################################
-# Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.                #
-#                                                                            #
-# Permission is hereby granted, free of charge, to any person obtaining a    #
-# copy of this software and associated documentation files (the "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.                                                             #
-##############################################################################
-#
-# Author: Thomas E. Dickey 1996-on
-#
-# Makefile for ncurses source code.
-#
-# This makes the following:
-#	programs
-#	includes
-#	libraries (normal/debug/profile/shared)
-#
-# The variable 'srcdir' refers to the source-distribution, and can be set with
-# the configure script by "--srcdir=DIR".
-#
-# The rules are organized to produce the libraries for the configured models,
-# and the programs with the configured default model.
-
-# turn off _all_ suffix rules; we'll generate our own
-.SUFFIXES:
-
-SHELL		= /bin/sh
-
-THIS		= Makefile
-
-CF_MFLAGS 	= 
-
-
-x		= 
-o		= .o
-
-MODEL		= normal
-DESTDIR		= 
-top_srcdir	= ..
-srcdir		= .
-prefix		= /system
-exec_prefix	= ${prefix}
-bindir		= ${exec_prefix}/bin
-libdir		= ${exec_prefix}/lib
-includedir	= ${prefix}/include
-datarootdir	= ${prefix}/share
-datadir		= ${datarootdir}
-includesubdir	= /ncurses
-
-INCLUDEDIR	= $(DESTDIR)$(includedir)$(includesubdir)
-
-PACKAGE		= ncurses
-
-LIBTOOL		= 
-LIBTOOL_OPTS	=  
-LIBTOOL_CLEAN	= 
-LIBTOOL_COMPILE	= 
-LIBTOOL_LINK	= ${CC}
-LIBTOOL_INSTALL	= 
-LIBTOOL_UNINSTALL = 
-LT_UNDEF	= 
-
-INSTALL		= /usr/bin/install -c
-INSTALL_LIB	= /usr/bin/install -c -m 644
-INSTALL_PROG	= ${INSTALL}
-INSTALL_DATA	= ${INSTALL} -m 644
-
-AR		= arm-linux-androideabi-ar
-ARFLAGS		= -curv
-AWK		= mawk
-LD		= arm-linux-androideabi-ld
-LN_S		= ln -s -f
-NM		= arm-linux-androideabi-nm
-
-CTAGS		= 
-ETAGS		= 
-
-CC		= /home/shade/dev/cm/13/prebuilts/clang/linux-x86/host/3.6/bin/clang
-CPP		= /home/shade/dev/cm/13/prebuilts/clang/linux-x86/host/3.6/bin/clang -E
-CFLAGS		= -target arm-linux-androideabi -I/home/shade/dev/cm/13/bionic/libc/include -I/home/shade/dev/cm/13/bionic/libc/kernel/uapi -I/home/shade/dev/cm/13/bionic/libc/arch-arm/include -I/home/shade/dev/cm/13/bionic/libc/kernel/uapi/asm-arm --sysroot=/home/shade/dev/cm/13/prebuilts/ndk/current/platforms/android-21/arch-arm -L/home/shade/dev/cm/13/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/lib/gcc/arm-linux-androideabi/4.9.x-google/armv7-a -I/home/shade/dev/cm/13/bionic/libm/include -I/home/shade/dev/cm/13/bionic/libm/include/arm -I/home/shade/dev/cm/13/external/libselinux/include -I/home/shade/dev/cm/13/system/core/include -I/home/shade/dev/cm/13/bionic/libc/dns/include -I.  --param max-inline-insns-single=1200
-
-INCDIR		= $(srcdir)/../include
-CPPFLAGS	= -DHAVE_CONFIG_H -I. -I../include   -D_XOPEN_SOURCE=500 -D_FILE_OFFSET_BITS=64  -DNDEBUG
-
-CCFLAGS		= $(CPPFLAGS) $(CFLAGS)
-
-BUILD_CPPFLAGS	= -DHAVE_CONFIG_H -DUSE_BUILD_CC -I../ncurses -I$(srcdir) -I../include -I$(INCDIR)  
-BUILD_CC	= gcc
-BUILD_CCFLAGS	= 
-BUILD_LDFLAGS	= 
-BUILD_LIBS	= 
-
-# The executables built in this directory are used for generating source that
-# is compiled into the build, or are test-programs that are not installed.
-
-BUILD_EXEEXT	= 
-x		= 
-
-CFLAGS_LIBTOOL	= $(CCFLAGS)
-CFLAGS_NORMAL	= $(CCFLAGS)
-CFLAGS_DEBUG	= $(CCFLAGS) -g -DTRACE
-CFLAGS_PROFILE	= $(CCFLAGS) -pg
-CFLAGS_SHARED	= $(CCFLAGS) -fPIC
-
-CFLAGS_DEFAULT	= $(CFLAGS_NORMAL)
-
-LINK		= $(LIBTOOL)
-LDFLAGS		= -L/home/shade/dev/cm/13/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/lib/gcc/arm-linux-androideabi/4.9.x-google/armv7-a -L/home/shade/dev/cm/13/out/target/product/bacon/system/lib -lc -lselinux -lcutils  
-
-SHLIB_DIRS	= -L../lib
-SHLIB_LIST	= $(SHLIB_DIRS) 
-TINFO_LIST	= $(SHLIB_DIRS) 
-TICS_LIST	= $(SHLIB_DIRS) 
-
-RPATH_LIST	= ${libdir}
-RESULTING_SYMS	= 
-VERSIONED_SYMS	= 
-MK_SHARED_LIB	= ${CC} ${CFLAGS} -shared -Wl,-soname,`basename $@ .${REL_VERSION}`.${ABI_VERSION},-stats,-lc -o $@
-
-NCURSES_MAJOR	= 6
-NCURSES_MINOR	= 0
-REL_VERSION	= 6.0
-ABI_VERSION	= 6
-
-RANLIB		= arm-linux-androideabi-ranlib
-
-LIBRARIES	=  ../lib/libncurses.a ../lib/libncurses_g.a
-
-LINT		= lint
-LINT_OPTS	= 
-LINT_LIBS	= -lncurses 
-
-FALLBACK_LIST	= 
-
-USE_BIG_STRINGS	= 1
-TERMINFO_CAPS	= $(top_srcdir)/include/Caps
-
-TERMINFO	= /system/etc/terminfo
-TERMINFO_SRC	= ${top_srcdir}/misc/terminfo.src
-TIC_PATH	= /usr/bin/tic
-
-AUTO_SRC = \
-	./codes.c \
-	./comp_captab.c \
-	./expanded.c \
-	./fallback.c \
-	./lib_gen.c \
-	./lib_keyname.c \
-	./link_test.c \
-	./names.c \
-	./unctrl.c \
-	init_keytry.h \
-	keys.list
-
-HEADER_DEPS	= \
-	$(srcdir)/curses.priv.h \
-	../include/ncurses_dll.h \
-	../include/ncurses_cfg.h \
-	../include/curses.h \
-	$(INCDIR)/nc_panel.h \
-	../include/term.h \
-	$(INCDIR)/term_entry.h \
-	$(INCDIR)/nc_tparm.h \
-	$(INCDIR)/nc_alloc.h \
-	$(INCDIR)/nc_mingw.h
-
-TEST_DEPS	= ../lib/libncurses.a
-TEST_ARGS	=  -L../lib -lform -lmenu -lpanel -lncurses   
-TEST_LDFLAGS	=  $(TEST_ARGS)   -L/home/shade/dev/cm/13/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/lib/gcc/arm-linux-androideabi/4.9.x-google/armv7-a -L/home/shade/dev/cm/13/out/target/product/bacon/system/lib -lc -lselinux -lcutils
-
-TEST_PROGS = \
-	captoinfo$x \
-	hardscroll$x \
-	link_test$x \
-	hashmap$x \
-	lib_mvcur$x
-
-base	 = $(srcdir)/base
-serial	 = $(srcdir)/tty
-tinfo	 = $(srcdir)/tinfo
-trace	 = $(srcdir)/trace
-wide	 = $(srcdir)/widechar
-win32con = $(srcdir)/win32con
-
-################################################################################
-all \
-libs ::		$(AUTO_SRC) ../lib $(LIBRARIES)
-
-sources:	$(AUTO_SRC)
-
-$(DESTDIR)$(bindir) \
-$(DESTDIR)$(libdir) :
-	mkdir -p $@
-
-../lib : ; mkdir $@
-
-./fallback.c : $(tinfo)/MKfallback.sh
-	$(SHELL) -e $(tinfo)/MKfallback.sh $(TERMINFO) $(TERMINFO_SRC) $(TIC_PATH) $(FALLBACK_LIST) >$@
-
-./lib_gen.c : $(base)/MKlib_gen.sh ../include/curses.h
-	$(SHELL) -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" generated <../include/curses.h >$@
-
-init_keytry.h: make_keys$(BUILD_EXEEXT) keys.list
-	./make_keys$(BUILD_EXEEXT) keys.list > $@
-
-keys.list :	$(tinfo)/MKkeys_list.sh
-	AWK=$(AWK) $(SHELL) $(tinfo)/MKkeys_list.sh $(TERMINFO_CAPS) | sort >$@
-
-make_keys$(BUILD_EXEEXT) : \
-		$(tinfo)/make_keys.c \
-		names.c
-	$(BUILD_CC) -o $@ $(BUILD_CPPFLAGS) $(BUILD_CCFLAGS) $(tinfo)/make_keys.c $(BUILD_LDFLAGS) $(BUILD_LIBS)
-
-make_hash$(BUILD_EXEEXT) : \
-		$(tinfo)/make_hash.c \
-		../include/hashsize.h
-	$(BUILD_CC) -o $@ $(BUILD_CPPFLAGS) $(BUILD_CCFLAGS) $(tinfo)/make_hash.c $(BUILD_LDFLAGS) $(BUILD_LIBS)
-
-./expanded.c : $(srcdir)/curses.priv.h $(serial)/MKexpanded.sh
-	$(SHELL) -e $(serial)/MKexpanded.sh "$(CPP)" $(CPPFLAGS) > $@
-
-./comp_captab.c: \
-		make_hash$(BUILD_EXEEXT) \
-		../include/hashsize.h \
-		$(tinfo)/MKcaptab.sh \
-		$(tinfo)/MKcaptab.awk
-	$(SHELL) -e $(tinfo)/MKcaptab.sh $(AWK) $(USE_BIG_STRINGS) $(tinfo)/MKcaptab.awk $(srcdir)/../include/Caps > $@
-
-./lib_keyname.c: keys.list $(base)/MKkeyname.awk
-	$(AWK) -f $(base)/MKkeyname.awk bigstrings=$(USE_BIG_STRINGS) keys.list > $@
-
-./codes.c: $(tinfo)/MKcodes.awk
-	$(AWK) -f $(tinfo)/MKcodes.awk bigstrings=$(USE_BIG_STRINGS) $(srcdir)/../include/Caps >$@
-
-./names.c: $(tinfo)/MKnames.awk
-	$(AWK) -f $(tinfo)/MKnames.awk bigstrings=$(USE_BIG_STRINGS) $(srcdir)/../include/Caps >$@
-
-./unctrl.c: $(base)/MKunctrl.awk
-	echo | $(AWK) -f $(base)/MKunctrl.awk bigstrings=$(USE_BIG_STRINGS) >$@
-
-tags:
-	$(CTAGS) *.[ch] */*.[ch]
-
-#TAGS:
-#	$(ETAGS) *.[ch] */*.[ch]
-
-mostlyclean ::
-	-rm -f core tags TAGS *~ *.bak *.i *.ln *.atac trace
-	-rm -f $(TEST_PROGS)
-
-clean :: mostlyclean
-	-rm -f $(AUTO_SRC)
-	-rm -f make_keys$(BUILD_EXEEXT)
-	-rm -f make_hash$(BUILD_EXEEXT)
-	-rm -rf .libs *.dSYM *.map
-
-distclean :: clean
-	-rm -f Makefile
-
-realclean :: distclean
-
-# These rules are used to allow "make -n" to work on a clean directory-tree
-../include/hashsize.h \
-../include/parametrized.h \
-../include/term.h :
-	cd ../include; $(MAKE) $(CF_MFLAGS)
-
-# These rules build test-programs for the modules that have test-drivers
-test_progs : $(TEST_PROGS)
-
-./link_test.c : $(base)/MKlib_gen.sh ../include/curses.h
-	$(SHELL) -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" implemented <../include/curses.h >$@
-
-captoinfo$x : $(tinfo)/captoinfo.c $(TEST_DEPS)
-	 $(LIBTOOL_LINK) -o $@ $(CFLAGS_DEFAULT) -DMAIN $(tinfo)/captoinfo.c $(TEST_LDFLAGS)
-
-hardscroll$x : $(serial)/hardscroll.c $(TEST_DEPS)
-	 $(LIBTOOL_LINK) -o $@ $(CFLAGS_DEFAULT) -DSCROLLDEBUG $(serial)/hardscroll.c $(TEST_LDFLAGS)
-
-hashmap$x : $(serial)/hashmap.c $(serial)/hardscroll.c $(TEST_DEPS)
-	 $(LIBTOOL_LINK) -o $@ $(CFLAGS_DEFAULT) -DHASHDEBUG $(serial)/hashmap.c $(serial)/hardscroll.c $(TEST_LDFLAGS)
-
-lib_mvcur$x : $(serial)/lib_mvcur.c $(TEST_DEPS) \
-		../objects/dump_entry$o
-	 $(LIBTOOL_LINK) -o $@ $(CFLAGS_DEFAULT) -DNCURSES_TEST -I$(serial)/../../progs $(serial)/lib_mvcur.c ../objects/dump_entry$o $(TEST_LDFLAGS)
-
-link_test$x : ./link_test.c $(TEST_DEPS) \
-		../objects/link_test$o
-	 $(CC) -o $@ $(CFLAGS_DEFAULT) ../objects/link_test$o $(TEST_LDFLAGS)
-
-../objects/dump_entry$o:
-	cd ../progs && $(MAKE) ../objects/dump_entry$o
-
-###############################################################################
-# The remainder of this file is automatically generated during configuration
-###############################################################################
-
-# Generated by CF_LIB_RULES
-resulting.map: 
-	sed  -e "s/NCURSES\([WT]\+\)\?_/NCURSES\16_/g" -e "/deprecated in ABI6/d" <  >$@
-
-clean::
-	rm -f resulting.map
-
-# generated by mk-0th.awk
-#   libname:    ncurses
-#   subsets:    ticlib+termlib+ext_tinfo+base+ext_funcs
-#   ticlib:     
-#   termlib:    
-
-.SUFFIXES: .c .cc .h .i .ii
-.c.i :
-	$(CPP) $(CPPFLAGS) $< >$@
-.cc.ii :
-	$(CPP) $(CPPFLAGS) $< >$@
-.h.i :
-	$(CPP) $(CPPFLAGS) $< >$@
-
-C_SRC = \
-	$(serial)/hardscroll.c \
-	$(serial)/hashmap.c \
-	$(base)/lib_addch.c \
-	$(base)/lib_addstr.c \
-	$(base)/lib_beep.c \
-	$(base)/lib_bkgd.c \
-	$(base)/lib_box.c \
-	$(base)/lib_chgat.c \
-	$(base)/lib_clear.c \
-	$(base)/lib_clearok.c \
-	$(base)/lib_clrbot.c \
-	$(base)/lib_clreol.c \
-	$(base)/lib_color.c \
-	$(base)/lib_colorset.c \
-	$(base)/lib_delch.c \
-	$(base)/lib_delwin.c \
-	$(base)/lib_echo.c \
-	$(base)/lib_endwin.c \
-	$(base)/lib_erase.c \
-	$(base)/lib_flash.c \
-	./lib_gen.c \
-	$(base)/lib_getch.c \
-	$(base)/lib_getstr.c \
-	$(base)/lib_hline.c \
-	$(base)/lib_immedok.c \
-	$(base)/lib_inchstr.c \
-	$(base)/lib_initscr.c \
-	$(base)/lib_insch.c \
-	$(base)/lib_insdel.c \
-	$(base)/lib_insnstr.c \
-	$(base)/lib_instr.c \
-	$(base)/lib_isendwin.c \
-	$(base)/lib_leaveok.c \
-	$(base)/lib_mouse.c \
-	$(base)/lib_move.c \
-	$(serial)/lib_mvcur.c \
-	$(base)/lib_mvwin.c \
-	$(base)/lib_newterm.c \
-	$(base)/lib_newwin.c \
-	$(base)/lib_nl.c \
-	$(base)/lib_overlay.c \
-	$(base)/lib_pad.c \
-	$(base)/lib_printw.c \
-	$(base)/lib_redrawln.c \
-	$(base)/lib_refresh.c \
-	$(base)/lib_restart.c \
-	$(base)/lib_scanw.c \
-	$(base)/lib_screen.c \
-	$(base)/lib_scroll.c \
-	$(base)/lib_scrollok.c \
-	$(base)/lib_scrreg.c \
-	$(base)/lib_set_term.c \
-	$(base)/lib_slk.c \
-	$(base)/lib_slkatr_set.c \
-	$(base)/lib_slkatrof.c \
-	$(base)/lib_slkatron.c \
-	$(base)/lib_slkatrset.c \
-	$(base)/lib_slkattr.c \
-	$(base)/lib_slkclear.c \
-	$(base)/lib_slkcolor.c \
-	$(base)/lib_slkinit.c \
-	$(base)/lib_slklab.c \
-	$(base)/lib_slkrefr.c \
-	$(base)/lib_slkset.c \
-	$(base)/lib_slktouch.c \
-	$(base)/lib_touch.c \
-	$(trace)/lib_tracedmp.c \
-	$(trace)/lib_tracemse.c \
-	$(serial)/lib_tstp.c \
-	$(base)/lib_ungetch.c \
-	$(serial)/lib_vidattr.c \
-	$(base)/lib_vline.c \
-	$(base)/lib_wattroff.c \
-	$(base)/lib_wattron.c \
-	$(base)/lib_winch.c \
-	$(base)/lib_window.c \
-	$(base)/nc_panel.c \
-	$(base)/safe_sprintf.c \
-	$(serial)/tty_update.c \
-	$(trace)/varargs.c \
-	$(base)/vsscanf.c \
-	$(base)/lib_freeall.c \
-	./expanded.c \
-	$(base)/legacy_coding.c \
-	$(base)/lib_dft_fgbg.c \
-	$(tinfo)/lib_print.c \
-	$(base)/resizeterm.c \
-	$(trace)/trace_xnames.c \
-	$(tinfo)/use_screen.c \
-	$(base)/use_window.c \
-	$(base)/wresize.c \
-	$(tinfo)/access.c \
-	$(tinfo)/add_tries.c \
-	$(tinfo)/alloc_ttype.c \
-	./codes.c \
-	./comp_captab.c \
-	$(tinfo)/comp_error.c \
-	$(tinfo)/comp_hash.c \
-	$(tinfo)/db_iterator.c \
-	$(tinfo)/doalloc.c \
-	$(tinfo)/entries.c \
-	./fallback.c \
-	$(tinfo)/free_ttype.c \
-	$(tinfo)/getenv_num.c \
-	$(tinfo)/home_terminfo.c \
-	$(tinfo)/init_keytry.c \
-	$(tinfo)/lib_acs.c \
-	$(tinfo)/lib_baudrate.c \
-	$(tinfo)/lib_cur_term.c \
-	$(tinfo)/lib_data.c \
-	$(tinfo)/lib_has_cap.c \
-	$(tinfo)/lib_kernel.c \
-	./lib_keyname.c \
-	$(tinfo)/lib_longname.c \
-	$(tinfo)/lib_napms.c \
-	$(tinfo)/lib_options.c \
-	$(tinfo)/lib_raw.c \
-	$(tinfo)/lib_setup.c \
-	$(tinfo)/lib_termcap.c \
-	$(tinfo)/lib_termname.c \
-	$(tinfo)/lib_tgoto.c \
-	$(tinfo)/lib_ti.c \
-	$(tinfo)/lib_tparm.c \
-	$(tinfo)/lib_tputs.c \
-	$(trace)/lib_trace.c \
-	$(trace)/lib_traceatr.c \
-	$(trace)/lib_tracebits.c \
-	$(trace)/lib_tracechr.c \
-	$(tinfo)/lib_ttyflags.c \
-	$(serial)/lib_twait.c \
-	$(tinfo)/name_match.c \
-	./names.c \
-	$(tinfo)/obsolete.c \
-	$(tinfo)/read_entry.c \
-	$(tinfo)/read_termcap.c \
-	$(tinfo)/strings.c \
-	$(trace)/trace_buf.c \
-	$(trace)/trace_tries.c \
-	$(base)/tries.c \
-	$(tinfo)/trim_sgr0.c \
-	./unctrl.c \
-	$(trace)/visbuf.c \
-	$(tinfo)/alloc_entry.c \
-	$(tinfo)/captoinfo.c \
-	$(tinfo)/comp_expand.c \
-	$(tinfo)/comp_parse.c \
-	$(tinfo)/comp_scan.c \
-	$(tinfo)/parse_entry.c \
-	$(tinfo)/write_entry.c \
-	$(base)/define_key.c \
-	$(tinfo)/hashed_db.c \
-	$(base)/key_defined.c \
-	$(base)/keybound.c \
-	$(base)/keyok.c \
-	$(base)/version.c
-
-# Producing llib-lncurses is time-consuming, so there's no direct-dependency for
-# it in the lintlib rule.  We'll only remove in the cleanest setup.
-
-NCURSES_SRC = \
-	$(serial)/hardscroll.c \
-	$(serial)/hashmap.c \
-	$(base)/lib_addch.c \
-	$(base)/lib_addstr.c \
-	$(base)/lib_beep.c \
-	$(base)/lib_bkgd.c \
-	$(base)/lib_box.c \
-	$(base)/lib_chgat.c \
-	$(base)/lib_clear.c \
-	$(base)/lib_clearok.c \
-	$(base)/lib_clrbot.c \
-	$(base)/lib_clreol.c \
-	$(base)/lib_color.c \
-	$(base)/lib_colorset.c \
-	$(base)/lib_delch.c \
-	$(base)/lib_delwin.c \
-	$(base)/lib_echo.c \
-	$(base)/lib_endwin.c \
-	$(base)/lib_erase.c \
-	$(base)/lib_flash.c \
-	./lib_gen.c \
-	$(base)/lib_getch.c \
-	$(base)/lib_getstr.c \
-	$(base)/lib_hline.c \
-	$(base)/lib_immedok.c \
-	$(base)/lib_inchstr.c \
-	$(base)/lib_initscr.c \
-	$(base)/lib_insch.c \
-	$(base)/lib_insdel.c \
-	$(base)/lib_insnstr.c \
-	$(base)/lib_instr.c \
-	$(base)/lib_isendwin.c \
-	$(base)/lib_leaveok.c \
-	$(base)/lib_mouse.c \
-	$(base)/lib_move.c \
-	$(serial)/lib_mvcur.c \
-	$(base)/lib_mvwin.c \
-	$(base)/lib_newterm.c \
-	$(base)/lib_newwin.c \
-	$(base)/lib_nl.c \
-	$(base)/lib_overlay.c \
-	$(base)/lib_pad.c \
-	$(base)/lib_printw.c \
-	$(base)/lib_redrawln.c \
-	$(base)/lib_refresh.c \
-	$(base)/lib_restart.c \
-	$(base)/lib_scanw.c \
-	$(base)/lib_screen.c \
-	$(base)/lib_scroll.c \
-	$(base)/lib_scrollok.c \
-	$(base)/lib_scrreg.c \
-	$(base)/lib_set_term.c \
-	$(base)/lib_slk.c \
-	$(base)/lib_slkatr_set.c \
-	$(base)/lib_slkatrof.c \
-	$(base)/lib_slkatron.c \
-	$(base)/lib_slkatrset.c \
-	$(base)/lib_slkattr.c \
-	$(base)/lib_slkclear.c \
-	$(base)/lib_slkcolor.c \
-	$(base)/lib_slkinit.c \
-	$(base)/lib_slklab.c \
-	$(base)/lib_slkrefr.c \
-	$(base)/lib_slkset.c \
-	$(base)/lib_slktouch.c \
-	$(base)/lib_touch.c \
-	$(trace)/lib_tracedmp.c \
-	$(trace)/lib_tracemse.c \
-	$(serial)/lib_tstp.c \
-	$(base)/lib_ungetch.c \
-	$(serial)/lib_vidattr.c \
-	$(base)/lib_vline.c \
-	$(base)/lib_wattroff.c \
-	$(base)/lib_wattron.c \
-	$(base)/lib_winch.c \
-	$(base)/lib_window.c \
-	$(base)/nc_panel.c \
-	$(base)/safe_sprintf.c \
-	$(serial)/tty_update.c \
-	$(trace)/varargs.c \
-	$(base)/vsscanf.c \
-	$(base)/lib_freeall.c \
-	./expanded.c \
-	$(base)/legacy_coding.c \
-	$(base)/lib_dft_fgbg.c \
-	$(tinfo)/lib_print.c \
-	$(base)/resizeterm.c \
-	$(trace)/trace_xnames.c \
-	$(tinfo)/use_screen.c \
-	$(base)/use_window.c \
-	$(base)/wresize.c \
-	$(tinfo)/access.c \
-	$(tinfo)/add_tries.c \
-	$(tinfo)/alloc_ttype.c \
-	./codes.c \
-	./comp_captab.c \
-	$(tinfo)/comp_error.c \
-	$(tinfo)/comp_hash.c \
-	$(tinfo)/db_iterator.c \
-	$(tinfo)/doalloc.c \
-	$(tinfo)/entries.c \
-	./fallback.c \
-	$(tinfo)/free_ttype.c \
-	$(tinfo)/getenv_num.c \
-	$(tinfo)/home_terminfo.c \
-	$(tinfo)/init_keytry.c \
-	$(tinfo)/lib_acs.c \
-	$(tinfo)/lib_baudrate.c \
-	$(tinfo)/lib_cur_term.c \
-	$(tinfo)/lib_data.c \
-	$(tinfo)/lib_has_cap.c \
-	$(tinfo)/lib_kernel.c \
-	./lib_keyname.c \
-	$(tinfo)/lib_longname.c \
-	$(tinfo)/lib_napms.c \
-	$(tinfo)/lib_options.c \
-	$(tinfo)/lib_raw.c \
-	$(tinfo)/lib_setup.c \
-	$(tinfo)/lib_termcap.c \
-	$(tinfo)/lib_termname.c \
-	$(tinfo)/lib_tgoto.c \
-	$(tinfo)/lib_ti.c \
-	$(tinfo)/lib_tparm.c \
-	$(tinfo)/lib_tputs.c \
-	$(trace)/lib_trace.c \
-	$(trace)/lib_traceatr.c \
-	$(trace)/lib_tracebits.c \
-	$(trace)/lib_tracechr.c \
-	$(tinfo)/lib_ttyflags.c \
-	$(serial)/lib_twait.c \
-	$(tinfo)/name_match.c \
-	./names.c \
-	$(tinfo)/obsolete.c \
-	$(tinfo)/read_entry.c \
-	$(tinfo)/read_termcap.c \
-	$(tinfo)/strings.c \
-	$(trace)/trace_buf.c \
-	$(trace)/trace_tries.c \
-	$(base)/tries.c \
-	$(tinfo)/trim_sgr0.c \
-	./unctrl.c \
-	$(trace)/visbuf.c \
-	$(tinfo)/alloc_entry.c \
-	$(tinfo)/captoinfo.c \
-	$(tinfo)/comp_expand.c \
-	$(tinfo)/comp_parse.c \
-	$(tinfo)/comp_scan.c \
-	$(tinfo)/parse_entry.c \
-	$(tinfo)/write_entry.c \
-	$(base)/define_key.c \
-	$(tinfo)/hashed_db.c \
-	$(base)/key_defined.c \
-	$(base)/keybound.c \
-	$(base)/keyok.c \
-	$(base)/version.c
-
-clean ::
-	rm -f llib-lncurses.*
-
-realclean ::
-	rm -f llib-lncurses
-
-llib-lncurses : $(NCURSES_SRC)
-	cproto -a -l -DNCURSES_ENABLE_STDBOOL_H=0 -DLINT $(CPPFLAGS) $(NCURSES_SRC) >$@
-
-lintlib ::
-	sh $(srcdir)/../misc/makellib ncurses $(CPPFLAGS)
-
-lint ::
-	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(NCURSES_SRC) $(LINT_LIBS)
-
-# generated by mk-1st.awk (subset=ticlib+termlib+ext_tinfo+base+ext_funcs)
-#  name:          ncurses
-#  traces:        DEBUG
-#  MODEL:         NORMAL
-#  CXX_MODEL:     NORMAL
-#  model:         objects
-#  prefix:        lib
-#  suffix:        .a
-#  subset:        ticlib+termlib+ext_tinfo+base+ext_funcs
-#  driver:        no
-#  ShlibVer:      rel
-#  ShlibVerInfix: no
-#  SymLink:       ln -s -f
-#  TermlibRoot:   ncurses
-#  TermlibSuffix: .a
-#  ReLink:        no
-#  DoLinks:       yes
-#  rmSoLocs:      no
-#  ldconfig:      :
-#  overwrite:     no
-#  depend:        ../include/ncurses_cfg.h ./curses.priv.h
-#  host:          arm-unknown-linux-androideabi
-
-NORMAL_OBJS = \
-	../objects/hardscroll$o \
-	../objects/hashmap$o \
-	../objects/lib_addch$o \
-	../objects/lib_addstr$o \
-	../objects/lib_beep$o \
-	../objects/lib_bkgd$o \
-	../objects/lib_box$o \
-	../objects/lib_chgat$o \
-	../objects/lib_clear$o \
-	../objects/lib_clearok$o \
-	../objects/lib_clrbot$o \
-	../objects/lib_clreol$o \
-	../objects/lib_color$o \
-	../objects/lib_colorset$o \
-	../objects/lib_delch$o \
-	../objects/lib_delwin$o \
-	../objects/lib_echo$o \
-	../objects/lib_endwin$o \
-	../objects/lib_erase$o \
-	../objects/lib_flash$o \
-	../objects/lib_gen$o \
-	../objects/lib_getch$o \
-	../objects/lib_getstr$o \
-	../objects/lib_hline$o \
-	../objects/lib_immedok$o \
-	../objects/lib_inchstr$o \
-	../objects/lib_initscr$o \
-	../objects/lib_insch$o \
-	../objects/lib_insdel$o \
-	../objects/lib_insnstr$o \
-	../objects/lib_instr$o \
-	../objects/lib_isendwin$o \
-	../objects/lib_leaveok$o \
-	../objects/lib_mouse$o \
-	../objects/lib_move$o \
-	../objects/lib_mvcur$o \
-	../objects/lib_mvwin$o \
-	../objects/lib_newterm$o \
-	../objects/lib_newwin$o \
-	../objects/lib_nl$o \
-	../objects/lib_overlay$o \
-	../objects/lib_pad$o \
-	../objects/lib_printw$o \
-	../objects/lib_redrawln$o \
-	../objects/lib_refresh$o \
-	../objects/lib_restart$o \
-	../objects/lib_scanw$o \
-	../objects/lib_screen$o \
-	../objects/lib_scroll$o \
-	../objects/lib_scrollok$o \
-	../objects/lib_scrreg$o \
-	../objects/lib_set_term$o \
-	../objects/lib_slk$o \
-	../objects/lib_slkatr_set$o \
-	../objects/lib_slkatrof$o \
-	../objects/lib_slkatron$o \
-	../objects/lib_slkatrset$o \
-	../objects/lib_slkattr$o \
-	../objects/lib_slkclear$o \
-	../objects/lib_slkcolor$o \
-	../objects/lib_slkinit$o \
-	../objects/lib_slklab$o \
-	../objects/lib_slkrefr$o \
-	../objects/lib_slkset$o \
-	../objects/lib_slktouch$o \
-	../objects/lib_touch$o \
-	../objects/lib_tstp$o \
-	../objects/lib_ungetch$o \
-	../objects/lib_vidattr$o \
-	../objects/lib_vline$o \
-	../objects/lib_wattroff$o \
-	../objects/lib_wattron$o \
-	../objects/lib_winch$o \
-	../objects/lib_window$o \
-	../objects/nc_panel$o \
-	../objects/safe_sprintf$o \
-	../objects/tty_update$o \
-	../objects/varargs$o \
-	../objects/vsscanf$o \
-	../objects/lib_freeall$o \
-	../objects/expanded$o \
-	../objects/legacy_coding$o \
-	../objects/lib_dft_fgbg$o \
-	../objects/lib_print$o \
-	../objects/resizeterm$o \
-	../objects/use_screen$o \
-	../objects/use_window$o \
-	../objects/wresize$o \
-	../objects/access$o \
-	../objects/add_tries$o \
-	../objects/alloc_ttype$o \
-	../objects/codes$o \
-	../objects/comp_captab$o \
-	../objects/comp_error$o \
-	../objects/comp_hash$o \
-	../objects/db_iterator$o \
-	../objects/doalloc$o \
-	../objects/entries$o \
-	../objects/fallback$o \
-	../objects/free_ttype$o \
-	../objects/getenv_num$o \
-	../objects/home_terminfo$o \
-	../objects/init_keytry$o \
-	../objects/lib_acs$o \
-	../objects/lib_baudrate$o \
-	../objects/lib_cur_term$o \
-	../objects/lib_data$o \
-	../objects/lib_has_cap$o \
-	../objects/lib_kernel$o \
-	../objects/lib_keyname$o \
-	../objects/lib_longname$o \
-	../objects/lib_napms$o \
-	../objects/lib_options$o \
-	../objects/lib_raw$o \
-	../objects/lib_setup$o \
-	../objects/lib_termcap$o \
-	../objects/lib_termname$o \
-	../objects/lib_tgoto$o \
-	../objects/lib_ti$o \
-	../objects/lib_tparm$o \
-	../objects/lib_tputs$o \
-	../objects/lib_trace$o \
-	../objects/lib_ttyflags$o \
-	../objects/lib_twait$o \
-	../objects/name_match$o \
-	../objects/names$o \
-	../objects/obsolete$o \
-	../objects/read_entry$o \
-	../objects/read_termcap$o \
-	../objects/strings$o \
-	../objects/tries$o \
-	../objects/trim_sgr0$o \
-	../objects/unctrl$o \
-	../objects/visbuf$o \
-	../objects/alloc_entry$o \
-	../objects/captoinfo$o \
-	../objects/comp_expand$o \
-	../objects/comp_parse$o \
-	../objects/comp_scan$o \
-	../objects/parse_entry$o \
-	../objects/write_entry$o \
-	../objects/define_key$o \
-	../objects/hashed_db$o \
-	../objects/key_defined$o \
-	../objects/keybound$o \
-	../objects/keyok$o \
-	../objects/version$o
-
-$(NORMAL_OBJS) : ../include/ncurses_cfg.h ./curses.priv.h
-
-../lib/libncurses.a : $(NORMAL_OBJS)
-	$(AR) $(ARFLAGS) $@ $?
-	$(RANLIB) $@
-
-install \
-install.libs \
-install.ncurses :: $(DESTDIR)$(libdir) ../lib/libncurses.a
-	@echo installing ../lib/libncurses.a as $(DESTDIR)$(libdir)/libncurses.a
-	$(INSTALL_DATA) ../lib/libncurses.a $(DESTDIR)$(libdir)/libncurses.a
-	$(RANLIB) $(DESTDIR)$(libdir)/libncurses.a
-
-uninstall \
-uninstall.libs \
-uninstall.ncurses ::
-	@echo uninstalling $(DESTDIR)$(libdir)/libncurses.a
-	-@rm -f $(DESTDIR)$(libdir)/libncurses.a
-
-clean ::
-	-rm -f ../lib/libncurses.a
-
-mostlyclean::
-	-rm -f $(NORMAL_OBJS)
-
-# generated by mk-2nd.awk
-#   model:      objects
-#   MODEL:      NORMAL
-#   echo:       yes
-#   subset:     ticlib+termlib+ext_tinfo+base+ext_funcs
-#   crenames:   yes
-#   cxxrenames: 
-#   traces:     DEBUG
-#   srcdir:     .
-
-../objects/hardscroll$o :	$(serial)/hardscroll.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(serial)/hardscroll.c -o ../objects/hardscroll$o
-
-../objects/hashmap$o :	$(serial)/hashmap.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(serial)/hashmap.c -o ../objects/hashmap$o
-
-../objects/lib_addch$o :	$(base)/lib_addch.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_addch.c -o ../objects/lib_addch$o
-
-../objects/lib_addstr$o :	$(base)/lib_addstr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_addstr.c -o ../objects/lib_addstr$o
-
-../objects/lib_beep$o :	$(base)/lib_beep.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_beep.c -o ../objects/lib_beep$o
-
-../objects/lib_bkgd$o :	$(base)/lib_bkgd.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_bkgd.c -o ../objects/lib_bkgd$o
-
-../objects/lib_box$o :	$(base)/lib_box.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_box.c -o ../objects/lib_box$o
-
-../objects/lib_chgat$o :	$(base)/lib_chgat.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_chgat.c -o ../objects/lib_chgat$o
-
-../objects/lib_clear$o :	$(base)/lib_clear.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_clear.c -o ../objects/lib_clear$o
-
-../objects/lib_clearok$o :	$(base)/lib_clearok.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_clearok.c -o ../objects/lib_clearok$o
-
-../objects/lib_clrbot$o :	$(base)/lib_clrbot.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_clrbot.c -o ../objects/lib_clrbot$o
-
-../objects/lib_clreol$o :	$(base)/lib_clreol.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_clreol.c -o ../objects/lib_clreol$o
-
-../objects/lib_color$o :	$(base)/lib_color.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_color.c -o ../objects/lib_color$o
-
-../objects/lib_colorset$o :	$(base)/lib_colorset.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_colorset.c -o ../objects/lib_colorset$o
-
-../objects/lib_delch$o :	$(base)/lib_delch.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_delch.c -o ../objects/lib_delch$o
-
-../objects/lib_delwin$o :	$(base)/lib_delwin.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_delwin.c -o ../objects/lib_delwin$o
-
-../objects/lib_echo$o :	$(base)/lib_echo.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_echo.c -o ../objects/lib_echo$o
-
-../objects/lib_endwin$o :	$(base)/lib_endwin.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_endwin.c -o ../objects/lib_endwin$o
-
-../objects/lib_erase$o :	$(base)/lib_erase.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_erase.c -o ../objects/lib_erase$o
-
-../objects/lib_flash$o :	$(base)/lib_flash.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_flash.c -o ../objects/lib_flash$o
-
-../objects/lib_gen$o :	./lib_gen.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/lib_gen.c -o ../objects/lib_gen$o
-
-../objects/lib_getch$o :	$(base)/lib_getch.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/fifo_defs.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_getch.c -o ../objects/lib_getch$o
-
-../objects/lib_getstr$o :	$(base)/lib_getstr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_getstr.c -o ../objects/lib_getstr$o
-
-../objects/lib_hline$o :	$(base)/lib_hline.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_hline.c -o ../objects/lib_hline$o
-
-../objects/lib_immedok$o :	$(base)/lib_immedok.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_immedok.c -o ../objects/lib_immedok$o
-
-../objects/lib_inchstr$o :	$(base)/lib_inchstr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_inchstr.c -o ../objects/lib_inchstr$o
-
-../objects/lib_initscr$o :	$(base)/lib_initscr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_initscr.c -o ../objects/lib_initscr$o
-
-../objects/lib_insch$o :	$(base)/lib_insch.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_insch.c -o ../objects/lib_insch$o
-
-../objects/lib_insdel$o :	$(base)/lib_insdel.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_insdel.c -o ../objects/lib_insdel$o
-
-../objects/lib_insnstr$o :	$(base)/lib_insnstr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_insnstr.c -o ../objects/lib_insnstr$o
-
-../objects/lib_instr$o :	$(base)/lib_instr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_instr.c -o ../objects/lib_instr$o
-
-../objects/lib_isendwin$o :	$(base)/lib_isendwin.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_isendwin.c -o ../objects/lib_isendwin$o
-
-../objects/lib_leaveok$o :	$(base)/lib_leaveok.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_leaveok.c -o ../objects/lib_leaveok$o
-
-../objects/lib_mouse$o :	$(base)/lib_mouse.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_mouse.c -o ../objects/lib_mouse$o
-
-../objects/lib_move$o :	$(base)/lib_move.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_move.c -o ../objects/lib_move$o
-
-../objects/lib_mvcur$o :	$(serial)/lib_mvcur.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			$(srcdir)/../progs/dump_entry.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(serial)/lib_mvcur.c -o ../objects/lib_mvcur$o
-
-../objects/lib_mvwin$o :	$(base)/lib_mvwin.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_mvwin.c -o ../objects/lib_mvwin$o
-
-../objects/lib_newterm$o :	$(base)/lib_newterm.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_newterm.c -o ../objects/lib_newterm$o
-
-../objects/lib_newwin$o :	$(base)/lib_newwin.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_newwin.c -o ../objects/lib_newwin$o
-
-../objects/lib_nl$o :	$(base)/lib_nl.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_nl.c -o ../objects/lib_nl$o
-
-../objects/lib_overlay$o :	$(base)/lib_overlay.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_overlay.c -o ../objects/lib_overlay$o
-
-../objects/lib_pad$o :	$(base)/lib_pad.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_pad.c -o ../objects/lib_pad$o
-
-../objects/lib_printw$o :	$(base)/lib_printw.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_printw.c -o ../objects/lib_printw$o
-
-../objects/lib_redrawln$o :	$(base)/lib_redrawln.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_redrawln.c -o ../objects/lib_redrawln$o
-
-../objects/lib_refresh$o :	$(base)/lib_refresh.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_refresh.c -o ../objects/lib_refresh$o
-
-../objects/lib_restart$o :	$(base)/lib_restart.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_restart.c -o ../objects/lib_restart$o
-
-../objects/lib_scanw$o :	$(base)/lib_scanw.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_scanw.c -o ../objects/lib_scanw$o
-
-../objects/lib_screen$o :	$(base)/lib_screen.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_screen.c -o ../objects/lib_screen$o
-
-../objects/lib_scroll$o :	$(base)/lib_scroll.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_scroll.c -o ../objects/lib_scroll$o
-
-../objects/lib_scrollok$o :	$(base)/lib_scrollok.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_scrollok.c -o ../objects/lib_scrollok$o
-
-../objects/lib_scrreg$o :	$(base)/lib_scrreg.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_scrreg.c -o ../objects/lib_scrreg$o
-
-../objects/lib_set_term$o :	$(base)/lib_set_term.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_set_term.c -o ../objects/lib_set_term$o
-
-../objects/lib_slk$o :	$(base)/lib_slk.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_slk.c -o ../objects/lib_slk$o
-
-../objects/lib_slkatr_set$o :	$(base)/lib_slkatr_set.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_slkatr_set.c -o ../objects/lib_slkatr_set$o
-
-../objects/lib_slkatrof$o :	$(base)/lib_slkatrof.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_slkatrof.c -o ../objects/lib_slkatrof$o
-
-../objects/lib_slkatron$o :	$(base)/lib_slkatron.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_slkatron.c -o ../objects/lib_slkatron$o
-
-../objects/lib_slkatrset$o :	$(base)/lib_slkatrset.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_slkatrset.c -o ../objects/lib_slkatrset$o
-
-../objects/lib_slkattr$o :	$(base)/lib_slkattr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_slkattr.c -o ../objects/lib_slkattr$o
-
-../objects/lib_slkclear$o :	$(base)/lib_slkclear.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_slkclear.c -o ../objects/lib_slkclear$o
-
-../objects/lib_slkcolor$o :	$(base)/lib_slkcolor.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_slkcolor.c -o ../objects/lib_slkcolor$o
-
-../objects/lib_slkinit$o :	$(base)/lib_slkinit.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_slkinit.c -o ../objects/lib_slkinit$o
-
-../objects/lib_slklab$o :	$(base)/lib_slklab.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_slklab.c -o ../objects/lib_slklab$o
-
-../objects/lib_slkrefr$o :	$(base)/lib_slkrefr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_slkrefr.c -o ../objects/lib_slkrefr$o
-
-../objects/lib_slkset$o :	$(base)/lib_slkset.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_slkset.c -o ../objects/lib_slkset$o
-
-../objects/lib_slktouch$o :	$(base)/lib_slktouch.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_slktouch.c -o ../objects/lib_slktouch$o
-
-../objects/lib_touch$o :	$(base)/lib_touch.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_touch.c -o ../objects/lib_touch$o
-
-../objects/lib_tstp$o :	$(serial)/lib_tstp.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/SigAction.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(serial)/lib_tstp.c -o ../objects/lib_tstp$o
-
-../objects/lib_ungetch$o :	$(base)/lib_ungetch.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/fifo_defs.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_ungetch.c -o ../objects/lib_ungetch$o
-
-../objects/lib_vidattr$o :	$(serial)/lib_vidattr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(serial)/lib_vidattr.c -o ../objects/lib_vidattr$o
-
-../objects/lib_vline$o :	$(base)/lib_vline.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_vline.c -o ../objects/lib_vline$o
-
-../objects/lib_wattroff$o :	$(base)/lib_wattroff.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_wattroff.c -o ../objects/lib_wattroff$o
-
-../objects/lib_wattron$o :	$(base)/lib_wattron.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_wattron.c -o ../objects/lib_wattron$o
-
-../objects/lib_winch$o :	$(base)/lib_winch.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_winch.c -o ../objects/lib_winch$o
-
-../objects/lib_window$o :	$(base)/lib_window.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_window.c -o ../objects/lib_window$o
-
-../objects/link_test$o :	./link_test.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/link_test.c -o ../objects/link_test$o
-
-../objects/nc_panel$o :	$(base)/nc_panel.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/nc_panel.c -o ../objects/nc_panel$o
-
-../objects/safe_sprintf$o :	$(base)/safe_sprintf.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/safe_sprintf.c -o ../objects/safe_sprintf$o
-
-../objects/tty_update$o :	$(serial)/tty_update.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(serial)/tty_update.c -o ../objects/tty_update$o
-
-../objects/varargs$o :	$(trace)/varargs.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(trace)/varargs.c -o ../objects/varargs$o
-
-../objects/vsscanf$o :	$(base)/vsscanf.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/vsscanf.c -o ../objects/vsscanf$o
-
-../objects/lib_freeall$o :	$(base)/lib_freeall.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_freeall.c -o ../objects/lib_freeall$o
-
-../objects/expanded$o :	./expanded.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/expanded.c -o ../objects/expanded$o
-
-../objects/legacy_coding$o :	$(base)/legacy_coding.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/legacy_coding.c -o ../objects/legacy_coding$o
-
-../objects/lib_dft_fgbg$o :	$(base)/lib_dft_fgbg.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/lib_dft_fgbg.c -o ../objects/lib_dft_fgbg$o
-
-../objects/lib_print$o :	$(tinfo)/lib_print.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_print.c -o ../objects/lib_print$o
-
-../objects/resizeterm$o :	$(base)/resizeterm.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/resizeterm.c -o ../objects/resizeterm$o
-
-../objects/use_screen$o :	$(tinfo)/use_screen.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/use_screen.c -o ../objects/use_screen$o
-
-../objects/use_window$o :	$(base)/use_window.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/use_window.c -o ../objects/use_window$o
-
-../objects/wresize$o :	$(base)/wresize.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/wresize.c -o ../objects/wresize$o
-
-../objects/access$o :	$(tinfo)/access.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/access.c -o ../objects/access$o
-
-../objects/add_tries$o :	$(tinfo)/add_tries.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/add_tries.c -o ../objects/add_tries$o
-
-../objects/alloc_ttype$o :	$(tinfo)/alloc_ttype.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/alloc_ttype.c -o ../objects/alloc_ttype$o
-
-../objects/codes$o :	./codes.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/codes.c -o ../objects/codes$o
-
-../objects/comp_captab$o :	./comp_captab.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			../include/hashsize.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/comp_captab.c -o ../objects/comp_captab$o
-
-../objects/comp_error$o :	$(tinfo)/comp_error.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/comp_error.c -o ../objects/comp_error$o
-
-../objects/comp_hash$o :	$(tinfo)/comp_hash.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			../include/hashsize.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/comp_hash.c -o ../objects/comp_hash$o
-
-../objects/db_iterator$o :	$(tinfo)/db_iterator.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/db_iterator.c -o ../objects/db_iterator$o
-
-../objects/doalloc$o :	$(tinfo)/doalloc.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/doalloc.c -o ../objects/doalloc$o
-
-../objects/entries$o :	$(tinfo)/entries.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/entries.c -o ../objects/entries$o
-
-../objects/fallback$o :	./fallback.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/fallback.c -o ../objects/fallback$o
-
-../objects/free_ttype$o :	$(tinfo)/free_ttype.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/free_ttype.c -o ../objects/free_ttype$o
-
-../objects/getenv_num$o :	$(tinfo)/getenv_num.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/getenv_num.c -o ../objects/getenv_num$o
-
-../objects/home_terminfo$o :	$(tinfo)/home_terminfo.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/home_terminfo.c -o ../objects/home_terminfo$o
-
-../objects/init_keytry$o :	$(tinfo)/init_keytry.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			init_keytry.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/init_keytry.c -o ../objects/init_keytry$o
-
-../objects/lib_acs$o :	$(tinfo)/lib_acs.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_acs.c -o ../objects/lib_acs$o
-
-../objects/lib_baudrate$o :	$(tinfo)/lib_baudrate.c \
-			$(HEADER_DEPS) \
-			../include/termcap.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_baudrate.c -o ../objects/lib_baudrate$o
-
-../objects/lib_cur_term$o :	$(tinfo)/lib_cur_term.c \
-			$(HEADER_DEPS) \
-			../include/termcap.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_cur_term.c -o ../objects/lib_cur_term$o
-
-../objects/lib_data$o :	$(tinfo)/lib_data.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_data.c -o ../objects/lib_data$o
-
-../objects/lib_has_cap$o :	$(tinfo)/lib_has_cap.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_has_cap.c -o ../objects/lib_has_cap$o
-
-../objects/lib_kernel$o :	$(tinfo)/lib_kernel.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_kernel.c -o ../objects/lib_kernel$o
-
-../objects/lib_keyname$o :	./lib_keyname.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/lib_keyname.c -o ../objects/lib_keyname$o
-
-../objects/lib_longname$o :	$(tinfo)/lib_longname.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_longname.c -o ../objects/lib_longname$o
-
-../objects/lib_napms$o :	$(tinfo)/lib_napms.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_napms.c -o ../objects/lib_napms$o
-
-../objects/lib_options$o :	$(tinfo)/lib_options.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_options.c -o ../objects/lib_options$o
-
-../objects/lib_raw$o :	$(tinfo)/lib_raw.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_raw.c -o ../objects/lib_raw$o
-
-../objects/lib_setup$o :	$(tinfo)/lib_setup.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_setup.c -o ../objects/lib_setup$o
-
-../objects/lib_termcap$o :	$(tinfo)/lib_termcap.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			../include/termcap.h \
-			$(INCDIR)/capdefaults.c
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_termcap.c -o ../objects/lib_termcap$o
-
-../objects/lib_termname$o :	$(tinfo)/lib_termname.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_termname.c -o ../objects/lib_termname$o
-
-../objects/lib_tgoto$o :	$(tinfo)/lib_tgoto.c \
-			$(HEADER_DEPS) \
-			../include/termcap.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_tgoto.c -o ../objects/lib_tgoto$o
-
-../objects/lib_ti$o :	$(tinfo)/lib_ti.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_ti.c -o ../objects/lib_ti$o
-
-../objects/lib_tparm$o :	$(tinfo)/lib_tparm.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_tparm.c -o ../objects/lib_tparm$o
-
-../objects/lib_tputs$o :	$(tinfo)/lib_tputs.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			../include/termcap.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_tputs.c -o ../objects/lib_tputs$o
-
-../objects/lib_trace$o :	$(trace)/lib_trace.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(trace)/lib_trace.c -o ../objects/lib_trace$o
-
-../objects/lib_ttyflags$o :	$(tinfo)/lib_ttyflags.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/lib_ttyflags.c -o ../objects/lib_ttyflags$o
-
-../objects/lib_twait$o :	$(serial)/lib_twait.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(serial)/lib_twait.c -o ../objects/lib_twait$o
-
-../objects/name_match$o :	$(tinfo)/name_match.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/name_match.c -o ../objects/name_match$o
-
-../objects/names$o :	./names.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/names.c -o ../objects/names$o
-
-../objects/obsolete$o :	$(tinfo)/obsolete.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/obsolete.c -o ../objects/obsolete$o
-
-../objects/read_entry$o :	$(tinfo)/read_entry.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			$(INCDIR)/hashed_db.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/read_entry.c -o ../objects/read_entry$o
-
-../objects/read_termcap$o :	$(tinfo)/read_termcap.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/read_termcap.c -o ../objects/read_termcap$o
-
-../objects/strings$o :	$(tinfo)/strings.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/strings.c -o ../objects/strings$o
-
-../objects/tries$o :	$(base)/tries.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/tries.c -o ../objects/tries$o
-
-../objects/trim_sgr0$o :	$(tinfo)/trim_sgr0.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/trim_sgr0.c -o ../objects/trim_sgr0$o
-
-../objects/unctrl$o :	./unctrl.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/unctrl.c -o ../objects/unctrl$o
-
-../objects/visbuf$o :	$(trace)/visbuf.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(trace)/visbuf.c -o ../objects/visbuf$o
-
-../objects/alloc_entry$o :	$(tinfo)/alloc_entry.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/alloc_entry.c -o ../objects/alloc_entry$o
-
-../objects/captoinfo$o :	$(tinfo)/captoinfo.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/captoinfo.c -o ../objects/captoinfo$o
-
-../objects/comp_expand$o :	$(tinfo)/comp_expand.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/comp_expand.c -o ../objects/comp_expand$o
-
-../objects/comp_parse$o :	$(tinfo)/comp_parse.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/comp_parse.c -o ../objects/comp_parse$o
-
-../objects/comp_scan$o :	$(tinfo)/comp_scan.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/comp_scan.c -o ../objects/comp_scan$o
-
-../objects/parse_entry$o :	$(tinfo)/parse_entry.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			../include/parametrized.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/parse_entry.c -o ../objects/parse_entry$o
-
-../objects/write_entry$o :	$(tinfo)/write_entry.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			$(INCDIR)/hashed_db.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/write_entry.c -o ../objects/write_entry$o
-
-../objects/define_key$o :	$(base)/define_key.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/define_key.c -o ../objects/define_key$o
-
-../objects/hashed_db$o :	$(tinfo)/hashed_db.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			$(INCDIR)/hashed_db.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(tinfo)/hashed_db.c -o ../objects/hashed_db$o
-
-../objects/key_defined$o :	$(base)/key_defined.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/key_defined.c -o ../objects/key_defined$o
-
-../objects/keybound$o :	$(base)/keybound.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/keybound.c -o ../objects/keybound$o
-
-../objects/keyok$o :	$(base)/keyok.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/keyok.c -o ../objects/keyok$o
-
-../objects/version$o :	$(base)/version.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../ncurses/$(base)/version.c -o ../objects/version$o
-
-
-# generated by mk-1st.awk (subset=ticlib+termlib+ext_tinfo+base+ext_funcs)
-#  name:          ncurses
-#  traces:        DEBUG
-#  MODEL:         DEBUG
-#  CXX_MODEL:     DEBUG
-#  model:         obj_g
-#  prefix:        lib
-#  suffix:        _g.a
-#  subset:        ticlib+termlib+ext_tinfo+base+ext_funcs
-#  driver:        no
-#  ShlibVer:      rel
-#  ShlibVerInfix: no
-#  SymLink:       ln -s -f
-#  TermlibRoot:   ncurses
-#  TermlibSuffix: .a
-#  ReLink:        no
-#  DoLinks:       yes
-#  rmSoLocs:      no
-#  ldconfig:      :
-#  overwrite:     no
-#  depend:        ../include/ncurses_cfg.h ./curses.priv.h
-#  host:          arm-unknown-linux-androideabi
-
-DEBUG_OBJS = \
-	../obj_g/hardscroll$o \
-	../obj_g/hashmap$o \
-	../obj_g/lib_addch$o \
-	../obj_g/lib_addstr$o \
-	../obj_g/lib_beep$o \
-	../obj_g/lib_bkgd$o \
-	../obj_g/lib_box$o \
-	../obj_g/lib_chgat$o \
-	../obj_g/lib_clear$o \
-	../obj_g/lib_clearok$o \
-	../obj_g/lib_clrbot$o \
-	../obj_g/lib_clreol$o \
-	../obj_g/lib_color$o \
-	../obj_g/lib_colorset$o \
-	../obj_g/lib_delch$o \
-	../obj_g/lib_delwin$o \
-	../obj_g/lib_echo$o \
-	../obj_g/lib_endwin$o \
-	../obj_g/lib_erase$o \
-	../obj_g/lib_flash$o \
-	../obj_g/lib_gen$o \
-	../obj_g/lib_getch$o \
-	../obj_g/lib_getstr$o \
-	../obj_g/lib_hline$o \
-	../obj_g/lib_immedok$o \
-	../obj_g/lib_inchstr$o \
-	../obj_g/lib_initscr$o \
-	../obj_g/lib_insch$o \
-	../obj_g/lib_insdel$o \
-	../obj_g/lib_insnstr$o \
-	../obj_g/lib_instr$o \
-	../obj_g/lib_isendwin$o \
-	../obj_g/lib_leaveok$o \
-	../obj_g/lib_mouse$o \
-	../obj_g/lib_move$o \
-	../obj_g/lib_mvcur$o \
-	../obj_g/lib_mvwin$o \
-	../obj_g/lib_newterm$o \
-	../obj_g/lib_newwin$o \
-	../obj_g/lib_nl$o \
-	../obj_g/lib_overlay$o \
-	../obj_g/lib_pad$o \
-	../obj_g/lib_printw$o \
-	../obj_g/lib_redrawln$o \
-	../obj_g/lib_refresh$o \
-	../obj_g/lib_restart$o \
-	../obj_g/lib_scanw$o \
-	../obj_g/lib_screen$o \
-	../obj_g/lib_scroll$o \
-	../obj_g/lib_scrollok$o \
-	../obj_g/lib_scrreg$o \
-	../obj_g/lib_set_term$o \
-	../obj_g/lib_slk$o \
-	../obj_g/lib_slkatr_set$o \
-	../obj_g/lib_slkatrof$o \
-	../obj_g/lib_slkatron$o \
-	../obj_g/lib_slkatrset$o \
-	../obj_g/lib_slkattr$o \
-	../obj_g/lib_slkclear$o \
-	../obj_g/lib_slkcolor$o \
-	../obj_g/lib_slkinit$o \
-	../obj_g/lib_slklab$o \
-	../obj_g/lib_slkrefr$o \
-	../obj_g/lib_slkset$o \
-	../obj_g/lib_slktouch$o \
-	../obj_g/lib_touch$o \
-	../obj_g/lib_tracedmp$o \
-	../obj_g/lib_tracemse$o \
-	../obj_g/lib_tstp$o \
-	../obj_g/lib_ungetch$o \
-	../obj_g/lib_vidattr$o \
-	../obj_g/lib_vline$o \
-	../obj_g/lib_wattroff$o \
-	../obj_g/lib_wattron$o \
-	../obj_g/lib_winch$o \
-	../obj_g/lib_window$o \
-	../obj_g/nc_panel$o \
-	../obj_g/safe_sprintf$o \
-	../obj_g/tty_update$o \
-	../obj_g/varargs$o \
-	../obj_g/vsscanf$o \
-	../obj_g/lib_freeall$o \
-	../obj_g/expanded$o \
-	../obj_g/legacy_coding$o \
-	../obj_g/lib_dft_fgbg$o \
-	../obj_g/lib_print$o \
-	../obj_g/resizeterm$o \
-	../obj_g/trace_xnames$o \
-	../obj_g/use_screen$o \
-	../obj_g/use_window$o \
-	../obj_g/wresize$o \
-	../obj_g/access$o \
-	../obj_g/add_tries$o \
-	../obj_g/alloc_ttype$o \
-	../obj_g/codes$o \
-	../obj_g/comp_captab$o \
-	../obj_g/comp_error$o \
-	../obj_g/comp_hash$o \
-	../obj_g/db_iterator$o \
-	../obj_g/doalloc$o \
-	../obj_g/entries$o \
-	../obj_g/fallback$o \
-	../obj_g/free_ttype$o \
-	../obj_g/getenv_num$o \
-	../obj_g/home_terminfo$o \
-	../obj_g/init_keytry$o \
-	../obj_g/lib_acs$o \
-	../obj_g/lib_baudrate$o \
-	../obj_g/lib_cur_term$o \
-	../obj_g/lib_data$o \
-	../obj_g/lib_has_cap$o \
-	../obj_g/lib_kernel$o \
-	../obj_g/lib_keyname$o \
-	../obj_g/lib_longname$o \
-	../obj_g/lib_napms$o \
-	../obj_g/lib_options$o \
-	../obj_g/lib_raw$o \
-	../obj_g/lib_setup$o \
-	../obj_g/lib_termcap$o \
-	../obj_g/lib_termname$o \
-	../obj_g/lib_tgoto$o \
-	../obj_g/lib_ti$o \
-	../obj_g/lib_tparm$o \
-	../obj_g/lib_tputs$o \
-	../obj_g/lib_trace$o \
-	../obj_g/lib_traceatr$o \
-	../obj_g/lib_tracebits$o \
-	../obj_g/lib_tracechr$o \
-	../obj_g/lib_ttyflags$o \
-	../obj_g/lib_twait$o \
-	../obj_g/name_match$o \
-	../obj_g/names$o \
-	../obj_g/obsolete$o \
-	../obj_g/read_entry$o \
-	../obj_g/read_termcap$o \
-	../obj_g/strings$o \
-	../obj_g/trace_buf$o \
-	../obj_g/trace_tries$o \
-	../obj_g/tries$o \
-	../obj_g/trim_sgr0$o \
-	../obj_g/unctrl$o \
-	../obj_g/visbuf$o \
-	../obj_g/alloc_entry$o \
-	../obj_g/captoinfo$o \
-	../obj_g/comp_expand$o \
-	../obj_g/comp_parse$o \
-	../obj_g/comp_scan$o \
-	../obj_g/parse_entry$o \
-	../obj_g/write_entry$o \
-	../obj_g/define_key$o \
-	../obj_g/hashed_db$o \
-	../obj_g/key_defined$o \
-	../obj_g/keybound$o \
-	../obj_g/keyok$o \
-	../obj_g/version$o
-
-$(DEBUG_OBJS) : ../include/ncurses_cfg.h ./curses.priv.h
-
-../lib/libncurses_g.a : $(DEBUG_OBJS)
-	$(AR) $(ARFLAGS) $@ $?
-	$(RANLIB) $@
-
-install \
-install.libs \
-install.ncurses :: $(DESTDIR)$(libdir) ../lib/libncurses_g.a
-	@echo installing ../lib/libncurses_g.a as $(DESTDIR)$(libdir)/libncurses_g.a
-	$(INSTALL_DATA) ../lib/libncurses_g.a $(DESTDIR)$(libdir)/libncurses_g.a
-	$(RANLIB) $(DESTDIR)$(libdir)/libncurses_g.a
-
-uninstall \
-uninstall.libs \
-uninstall.ncurses ::
-	@echo uninstalling $(DESTDIR)$(libdir)/libncurses_g.a
-	-@rm -f $(DESTDIR)$(libdir)/libncurses_g.a
-
-clean ::
-	-rm -f ../lib/libncurses_g.a
-
-mostlyclean::
-	-rm -f $(DEBUG_OBJS)
-
-# generated by mk-2nd.awk
-#   model:      obj_g
-#   MODEL:      DEBUG
-#   echo:       yes
-#   subset:     ticlib+termlib+ext_tinfo+base+ext_funcs
-#   crenames:   yes
-#   cxxrenames: 
-#   traces:     DEBUG
-#   srcdir:     .
-
-../obj_g/hardscroll$o :	$(serial)/hardscroll.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(serial)/hardscroll.c -o ../obj_g/hardscroll$o
-
-../obj_g/hashmap$o :	$(serial)/hashmap.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(serial)/hashmap.c -o ../obj_g/hashmap$o
-
-../obj_g/lib_addch$o :	$(base)/lib_addch.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_addch.c -o ../obj_g/lib_addch$o
-
-../obj_g/lib_addstr$o :	$(base)/lib_addstr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_addstr.c -o ../obj_g/lib_addstr$o
-
-../obj_g/lib_beep$o :	$(base)/lib_beep.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_beep.c -o ../obj_g/lib_beep$o
-
-../obj_g/lib_bkgd$o :	$(base)/lib_bkgd.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_bkgd.c -o ../obj_g/lib_bkgd$o
-
-../obj_g/lib_box$o :	$(base)/lib_box.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_box.c -o ../obj_g/lib_box$o
-
-../obj_g/lib_chgat$o :	$(base)/lib_chgat.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_chgat.c -o ../obj_g/lib_chgat$o
-
-../obj_g/lib_clear$o :	$(base)/lib_clear.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_clear.c -o ../obj_g/lib_clear$o
-
-../obj_g/lib_clearok$o :	$(base)/lib_clearok.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_clearok.c -o ../obj_g/lib_clearok$o
-
-../obj_g/lib_clrbot$o :	$(base)/lib_clrbot.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_clrbot.c -o ../obj_g/lib_clrbot$o
-
-../obj_g/lib_clreol$o :	$(base)/lib_clreol.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_clreol.c -o ../obj_g/lib_clreol$o
-
-../obj_g/lib_color$o :	$(base)/lib_color.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_color.c -o ../obj_g/lib_color$o
-
-../obj_g/lib_colorset$o :	$(base)/lib_colorset.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_colorset.c -o ../obj_g/lib_colorset$o
-
-../obj_g/lib_delch$o :	$(base)/lib_delch.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_delch.c -o ../obj_g/lib_delch$o
-
-../obj_g/lib_delwin$o :	$(base)/lib_delwin.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_delwin.c -o ../obj_g/lib_delwin$o
-
-../obj_g/lib_echo$o :	$(base)/lib_echo.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_echo.c -o ../obj_g/lib_echo$o
-
-../obj_g/lib_endwin$o :	$(base)/lib_endwin.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_endwin.c -o ../obj_g/lib_endwin$o
-
-../obj_g/lib_erase$o :	$(base)/lib_erase.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_erase.c -o ../obj_g/lib_erase$o
-
-../obj_g/lib_flash$o :	$(base)/lib_flash.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_flash.c -o ../obj_g/lib_flash$o
-
-../obj_g/lib_gen$o :	./lib_gen.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/lib_gen.c -o ../obj_g/lib_gen$o
-
-../obj_g/lib_getch$o :	$(base)/lib_getch.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/fifo_defs.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_getch.c -o ../obj_g/lib_getch$o
-
-../obj_g/lib_getstr$o :	$(base)/lib_getstr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_getstr.c -o ../obj_g/lib_getstr$o
-
-../obj_g/lib_hline$o :	$(base)/lib_hline.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_hline.c -o ../obj_g/lib_hline$o
-
-../obj_g/lib_immedok$o :	$(base)/lib_immedok.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_immedok.c -o ../obj_g/lib_immedok$o
-
-../obj_g/lib_inchstr$o :	$(base)/lib_inchstr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_inchstr.c -o ../obj_g/lib_inchstr$o
-
-../obj_g/lib_initscr$o :	$(base)/lib_initscr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_initscr.c -o ../obj_g/lib_initscr$o
-
-../obj_g/lib_insch$o :	$(base)/lib_insch.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_insch.c -o ../obj_g/lib_insch$o
-
-../obj_g/lib_insdel$o :	$(base)/lib_insdel.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_insdel.c -o ../obj_g/lib_insdel$o
-
-../obj_g/lib_insnstr$o :	$(base)/lib_insnstr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_insnstr.c -o ../obj_g/lib_insnstr$o
-
-../obj_g/lib_instr$o :	$(base)/lib_instr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_instr.c -o ../obj_g/lib_instr$o
-
-../obj_g/lib_isendwin$o :	$(base)/lib_isendwin.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_isendwin.c -o ../obj_g/lib_isendwin$o
-
-../obj_g/lib_leaveok$o :	$(base)/lib_leaveok.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_leaveok.c -o ../obj_g/lib_leaveok$o
-
-../obj_g/lib_mouse$o :	$(base)/lib_mouse.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_mouse.c -o ../obj_g/lib_mouse$o
-
-../obj_g/lib_move$o :	$(base)/lib_move.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_move.c -o ../obj_g/lib_move$o
-
-../obj_g/lib_mvcur$o :	$(serial)/lib_mvcur.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			$(srcdir)/../progs/dump_entry.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(serial)/lib_mvcur.c -o ../obj_g/lib_mvcur$o
-
-../obj_g/lib_mvwin$o :	$(base)/lib_mvwin.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_mvwin.c -o ../obj_g/lib_mvwin$o
-
-../obj_g/lib_newterm$o :	$(base)/lib_newterm.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_newterm.c -o ../obj_g/lib_newterm$o
-
-../obj_g/lib_newwin$o :	$(base)/lib_newwin.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_newwin.c -o ../obj_g/lib_newwin$o
-
-../obj_g/lib_nl$o :	$(base)/lib_nl.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_nl.c -o ../obj_g/lib_nl$o
-
-../obj_g/lib_overlay$o :	$(base)/lib_overlay.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_overlay.c -o ../obj_g/lib_overlay$o
-
-../obj_g/lib_pad$o :	$(base)/lib_pad.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_pad.c -o ../obj_g/lib_pad$o
-
-../obj_g/lib_printw$o :	$(base)/lib_printw.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_printw.c -o ../obj_g/lib_printw$o
-
-../obj_g/lib_redrawln$o :	$(base)/lib_redrawln.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_redrawln.c -o ../obj_g/lib_redrawln$o
-
-../obj_g/lib_refresh$o :	$(base)/lib_refresh.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_refresh.c -o ../obj_g/lib_refresh$o
-
-../obj_g/lib_restart$o :	$(base)/lib_restart.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_restart.c -o ../obj_g/lib_restart$o
-
-../obj_g/lib_scanw$o :	$(base)/lib_scanw.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_scanw.c -o ../obj_g/lib_scanw$o
-
-../obj_g/lib_screen$o :	$(base)/lib_screen.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_screen.c -o ../obj_g/lib_screen$o
-
-../obj_g/lib_scroll$o :	$(base)/lib_scroll.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_scroll.c -o ../obj_g/lib_scroll$o
-
-../obj_g/lib_scrollok$o :	$(base)/lib_scrollok.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_scrollok.c -o ../obj_g/lib_scrollok$o
-
-../obj_g/lib_scrreg$o :	$(base)/lib_scrreg.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_scrreg.c -o ../obj_g/lib_scrreg$o
-
-../obj_g/lib_set_term$o :	$(base)/lib_set_term.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_set_term.c -o ../obj_g/lib_set_term$o
-
-../obj_g/lib_slk$o :	$(base)/lib_slk.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_slk.c -o ../obj_g/lib_slk$o
-
-../obj_g/lib_slkatr_set$o :	$(base)/lib_slkatr_set.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_slkatr_set.c -o ../obj_g/lib_slkatr_set$o
-
-../obj_g/lib_slkatrof$o :	$(base)/lib_slkatrof.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_slkatrof.c -o ../obj_g/lib_slkatrof$o
-
-../obj_g/lib_slkatron$o :	$(base)/lib_slkatron.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_slkatron.c -o ../obj_g/lib_slkatron$o
-
-../obj_g/lib_slkatrset$o :	$(base)/lib_slkatrset.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_slkatrset.c -o ../obj_g/lib_slkatrset$o
-
-../obj_g/lib_slkattr$o :	$(base)/lib_slkattr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_slkattr.c -o ../obj_g/lib_slkattr$o
-
-../obj_g/lib_slkclear$o :	$(base)/lib_slkclear.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_slkclear.c -o ../obj_g/lib_slkclear$o
-
-../obj_g/lib_slkcolor$o :	$(base)/lib_slkcolor.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_slkcolor.c -o ../obj_g/lib_slkcolor$o
-
-../obj_g/lib_slkinit$o :	$(base)/lib_slkinit.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_slkinit.c -o ../obj_g/lib_slkinit$o
-
-../obj_g/lib_slklab$o :	$(base)/lib_slklab.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_slklab.c -o ../obj_g/lib_slklab$o
-
-../obj_g/lib_slkrefr$o :	$(base)/lib_slkrefr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_slkrefr.c -o ../obj_g/lib_slkrefr$o
-
-../obj_g/lib_slkset$o :	$(base)/lib_slkset.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_slkset.c -o ../obj_g/lib_slkset$o
-
-../obj_g/lib_slktouch$o :	$(base)/lib_slktouch.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_slktouch.c -o ../obj_g/lib_slktouch$o
-
-../obj_g/lib_touch$o :	$(base)/lib_touch.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_touch.c -o ../obj_g/lib_touch$o
-
-../obj_g/lib_tracedmp$o :	$(trace)/lib_tracedmp.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(trace)/lib_tracedmp.c -o ../obj_g/lib_tracedmp$o
-
-../obj_g/lib_tracemse$o :	$(trace)/lib_tracemse.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(trace)/lib_tracemse.c -o ../obj_g/lib_tracemse$o
-
-../obj_g/lib_tstp$o :	$(serial)/lib_tstp.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/SigAction.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(serial)/lib_tstp.c -o ../obj_g/lib_tstp$o
-
-../obj_g/lib_ungetch$o :	$(base)/lib_ungetch.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/fifo_defs.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_ungetch.c -o ../obj_g/lib_ungetch$o
-
-../obj_g/lib_vidattr$o :	$(serial)/lib_vidattr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(serial)/lib_vidattr.c -o ../obj_g/lib_vidattr$o
-
-../obj_g/lib_vline$o :	$(base)/lib_vline.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_vline.c -o ../obj_g/lib_vline$o
-
-../obj_g/lib_wattroff$o :	$(base)/lib_wattroff.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_wattroff.c -o ../obj_g/lib_wattroff$o
-
-../obj_g/lib_wattron$o :	$(base)/lib_wattron.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_wattron.c -o ../obj_g/lib_wattron$o
-
-../obj_g/lib_winch$o :	$(base)/lib_winch.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_winch.c -o ../obj_g/lib_winch$o
-
-../obj_g/lib_window$o :	$(base)/lib_window.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_window.c -o ../obj_g/lib_window$o
-
-../obj_g/link_test$o :	./link_test.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/link_test.c -o ../obj_g/link_test$o
-
-../obj_g/nc_panel$o :	$(base)/nc_panel.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/nc_panel.c -o ../obj_g/nc_panel$o
-
-../obj_g/safe_sprintf$o :	$(base)/safe_sprintf.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/safe_sprintf.c -o ../obj_g/safe_sprintf$o
-
-../obj_g/tty_update$o :	$(serial)/tty_update.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(serial)/tty_update.c -o ../obj_g/tty_update$o
-
-../obj_g/varargs$o :	$(trace)/varargs.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(trace)/varargs.c -o ../obj_g/varargs$o
-
-../obj_g/vsscanf$o :	$(base)/vsscanf.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/vsscanf.c -o ../obj_g/vsscanf$o
-
-../obj_g/lib_freeall$o :	$(base)/lib_freeall.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_freeall.c -o ../obj_g/lib_freeall$o
-
-../obj_g/expanded$o :	./expanded.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/expanded.c -o ../obj_g/expanded$o
-
-../obj_g/legacy_coding$o :	$(base)/legacy_coding.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/legacy_coding.c -o ../obj_g/legacy_coding$o
-
-../obj_g/lib_dft_fgbg$o :	$(base)/lib_dft_fgbg.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/lib_dft_fgbg.c -o ../obj_g/lib_dft_fgbg$o
-
-../obj_g/lib_print$o :	$(tinfo)/lib_print.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_print.c -o ../obj_g/lib_print$o
-
-../obj_g/resizeterm$o :	$(base)/resizeterm.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/resizeterm.c -o ../obj_g/resizeterm$o
-
-../obj_g/trace_xnames$o :	$(trace)/trace_xnames.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(trace)/trace_xnames.c -o ../obj_g/trace_xnames$o
-
-../obj_g/use_screen$o :	$(tinfo)/use_screen.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/use_screen.c -o ../obj_g/use_screen$o
-
-../obj_g/use_window$o :	$(base)/use_window.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/use_window.c -o ../obj_g/use_window$o
-
-../obj_g/wresize$o :	$(base)/wresize.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/wresize.c -o ../obj_g/wresize$o
-
-../obj_g/access$o :	$(tinfo)/access.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/access.c -o ../obj_g/access$o
-
-../obj_g/add_tries$o :	$(tinfo)/add_tries.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/add_tries.c -o ../obj_g/add_tries$o
-
-../obj_g/alloc_ttype$o :	$(tinfo)/alloc_ttype.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/alloc_ttype.c -o ../obj_g/alloc_ttype$o
-
-../obj_g/codes$o :	./codes.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/codes.c -o ../obj_g/codes$o
-
-../obj_g/comp_captab$o :	./comp_captab.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			../include/hashsize.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/comp_captab.c -o ../obj_g/comp_captab$o
-
-../obj_g/comp_error$o :	$(tinfo)/comp_error.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/comp_error.c -o ../obj_g/comp_error$o
-
-../obj_g/comp_hash$o :	$(tinfo)/comp_hash.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			../include/hashsize.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/comp_hash.c -o ../obj_g/comp_hash$o
-
-../obj_g/db_iterator$o :	$(tinfo)/db_iterator.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/db_iterator.c -o ../obj_g/db_iterator$o
-
-../obj_g/doalloc$o :	$(tinfo)/doalloc.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/doalloc.c -o ../obj_g/doalloc$o
-
-../obj_g/entries$o :	$(tinfo)/entries.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/entries.c -o ../obj_g/entries$o
-
-../obj_g/fallback$o :	./fallback.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/fallback.c -o ../obj_g/fallback$o
-
-../obj_g/free_ttype$o :	$(tinfo)/free_ttype.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/free_ttype.c -o ../obj_g/free_ttype$o
-
-../obj_g/getenv_num$o :	$(tinfo)/getenv_num.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/getenv_num.c -o ../obj_g/getenv_num$o
-
-../obj_g/home_terminfo$o :	$(tinfo)/home_terminfo.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/home_terminfo.c -o ../obj_g/home_terminfo$o
-
-../obj_g/init_keytry$o :	$(tinfo)/init_keytry.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			init_keytry.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/init_keytry.c -o ../obj_g/init_keytry$o
-
-../obj_g/lib_acs$o :	$(tinfo)/lib_acs.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_acs.c -o ../obj_g/lib_acs$o
-
-../obj_g/lib_baudrate$o :	$(tinfo)/lib_baudrate.c \
-			$(HEADER_DEPS) \
-			../include/termcap.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_baudrate.c -o ../obj_g/lib_baudrate$o
-
-../obj_g/lib_cur_term$o :	$(tinfo)/lib_cur_term.c \
-			$(HEADER_DEPS) \
-			../include/termcap.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_cur_term.c -o ../obj_g/lib_cur_term$o
-
-../obj_g/lib_data$o :	$(tinfo)/lib_data.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_data.c -o ../obj_g/lib_data$o
-
-../obj_g/lib_has_cap$o :	$(tinfo)/lib_has_cap.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_has_cap.c -o ../obj_g/lib_has_cap$o
-
-../obj_g/lib_kernel$o :	$(tinfo)/lib_kernel.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_kernel.c -o ../obj_g/lib_kernel$o
-
-../obj_g/lib_keyname$o :	./lib_keyname.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/lib_keyname.c -o ../obj_g/lib_keyname$o
-
-../obj_g/lib_longname$o :	$(tinfo)/lib_longname.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_longname.c -o ../obj_g/lib_longname$o
-
-../obj_g/lib_napms$o :	$(tinfo)/lib_napms.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_napms.c -o ../obj_g/lib_napms$o
-
-../obj_g/lib_options$o :	$(tinfo)/lib_options.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_options.c -o ../obj_g/lib_options$o
-
-../obj_g/lib_raw$o :	$(tinfo)/lib_raw.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_raw.c -o ../obj_g/lib_raw$o
-
-../obj_g/lib_setup$o :	$(tinfo)/lib_setup.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_setup.c -o ../obj_g/lib_setup$o
-
-../obj_g/lib_termcap$o :	$(tinfo)/lib_termcap.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			../include/termcap.h \
-			$(INCDIR)/capdefaults.c
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_termcap.c -o ../obj_g/lib_termcap$o
-
-../obj_g/lib_termname$o :	$(tinfo)/lib_termname.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_termname.c -o ../obj_g/lib_termname$o
-
-../obj_g/lib_tgoto$o :	$(tinfo)/lib_tgoto.c \
-			$(HEADER_DEPS) \
-			../include/termcap.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_tgoto.c -o ../obj_g/lib_tgoto$o
-
-../obj_g/lib_ti$o :	$(tinfo)/lib_ti.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_ti.c -o ../obj_g/lib_ti$o
-
-../obj_g/lib_tparm$o :	$(tinfo)/lib_tparm.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_tparm.c -o ../obj_g/lib_tparm$o
-
-../obj_g/lib_tputs$o :	$(tinfo)/lib_tputs.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			../include/termcap.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_tputs.c -o ../obj_g/lib_tputs$o
-
-../obj_g/lib_trace$o :	$(trace)/lib_trace.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(trace)/lib_trace.c -o ../obj_g/lib_trace$o
-
-../obj_g/lib_traceatr$o :	$(trace)/lib_traceatr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(trace)/lib_traceatr.c -o ../obj_g/lib_traceatr$o
-
-../obj_g/lib_tracebits$o :	$(trace)/lib_tracebits.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(trace)/lib_tracebits.c -o ../obj_g/lib_tracebits$o
-
-../obj_g/lib_tracechr$o :	$(trace)/lib_tracechr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(trace)/lib_tracechr.c -o ../obj_g/lib_tracechr$o
-
-../obj_g/lib_ttyflags$o :	$(tinfo)/lib_ttyflags.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/lib_ttyflags.c -o ../obj_g/lib_ttyflags$o
-
-../obj_g/lib_twait$o :	$(serial)/lib_twait.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(serial)/lib_twait.c -o ../obj_g/lib_twait$o
-
-../obj_g/name_match$o :	$(tinfo)/name_match.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/name_match.c -o ../obj_g/name_match$o
-
-../obj_g/names$o :	./names.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/names.c -o ../obj_g/names$o
-
-../obj_g/obsolete$o :	$(tinfo)/obsolete.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/obsolete.c -o ../obj_g/obsolete$o
-
-../obj_g/read_entry$o :	$(tinfo)/read_entry.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			$(INCDIR)/hashed_db.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/read_entry.c -o ../obj_g/read_entry$o
-
-../obj_g/read_termcap$o :	$(tinfo)/read_termcap.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/read_termcap.c -o ../obj_g/read_termcap$o
-
-../obj_g/strings$o :	$(tinfo)/strings.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/strings.c -o ../obj_g/strings$o
-
-../obj_g/trace_buf$o :	$(trace)/trace_buf.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(trace)/trace_buf.c -o ../obj_g/trace_buf$o
-
-../obj_g/trace_tries$o :	$(trace)/trace_tries.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(trace)/trace_tries.c -o ../obj_g/trace_tries$o
-
-../obj_g/tries$o :	$(base)/tries.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/tries.c -o ../obj_g/tries$o
-
-../obj_g/trim_sgr0$o :	$(tinfo)/trim_sgr0.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/trim_sgr0.c -o ../obj_g/trim_sgr0$o
-
-../obj_g/unctrl$o :	./unctrl.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/unctrl.c -o ../obj_g/unctrl$o
-
-../obj_g/visbuf$o :	$(trace)/visbuf.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(trace)/visbuf.c -o ../obj_g/visbuf$o
-
-../obj_g/alloc_entry$o :	$(tinfo)/alloc_entry.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/alloc_entry.c -o ../obj_g/alloc_entry$o
-
-../obj_g/captoinfo$o :	$(tinfo)/captoinfo.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/captoinfo.c -o ../obj_g/captoinfo$o
-
-../obj_g/comp_expand$o :	$(tinfo)/comp_expand.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/comp_expand.c -o ../obj_g/comp_expand$o
-
-../obj_g/comp_parse$o :	$(tinfo)/comp_parse.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/comp_parse.c -o ../obj_g/comp_parse$o
-
-../obj_g/comp_scan$o :	$(tinfo)/comp_scan.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/comp_scan.c -o ../obj_g/comp_scan$o
-
-../obj_g/parse_entry$o :	$(tinfo)/parse_entry.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			../include/parametrized.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/parse_entry.c -o ../obj_g/parse_entry$o
-
-../obj_g/write_entry$o :	$(tinfo)/write_entry.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			$(INCDIR)/hashed_db.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/write_entry.c -o ../obj_g/write_entry$o
-
-../obj_g/define_key$o :	$(base)/define_key.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/define_key.c -o ../obj_g/define_key$o
-
-../obj_g/hashed_db$o :	$(tinfo)/hashed_db.c \
-			$(HEADER_DEPS) \
-			$(INCDIR)/tic.h \
-			$(INCDIR)/hashed_db.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(tinfo)/hashed_db.c -o ../obj_g/hashed_db$o
-
-../obj_g/key_defined$o :	$(base)/key_defined.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/key_defined.c -o ../obj_g/key_defined$o
-
-../obj_g/keybound$o :	$(base)/keybound.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/keybound.c -o ../obj_g/keybound$o
-
-../obj_g/keyok$o :	$(base)/keyok.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/keyok.c -o ../obj_g/keyok$o
-
-../obj_g/version$o :	$(base)/version.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../ncurses/$(base)/version.c -o ../obj_g/version$o
-
-depend : ${AUTO_SRC}
-	makedepend -- ${CPPFLAGS} -- ${C_SRC}
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/ncurses/Makefile.in b/ncurses/Makefile.in
index e42c5e3..ae198df 100644
--- a/ncurses/Makefile.in
+++ b/ncurses/Makefile.in
@@ -1,6 +1,7 @@
-# $Id: Makefile.in,v 1.147 2015/08/05 23:15:41 tom Exp $
+# $Id: Makefile.in,v 1.184 2024/01/19 12:00:00 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.                #
+# Copyright 2018-2022,2024 Thomas E. Dickey                                  #
+# Copyright 1998-2017,2018 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -49,7 +50,7 @@
 VPATH		= @srcdir@
 THIS		= Makefile
 
-CF_MFLAGS 	= @cf_cv_makeflags@
+TOP_MFLAGS	= @cf_cv_makeflags@ DESTDIR="$(DESTDIR)" RPATH_LIST="$(RPATH_LIST)"
 @SET_MAKE@
 
 x		= @EXEEXT@
@@ -83,7 +84,7 @@
 
 INSTALL		= @INSTALL@
 INSTALL_LIB	= @INSTALL@ @INSTALL_LIB@
-INSTALL_PROG	= @INSTALL_PROGRAM@
+INSTALL_PROG	= @INSTALL_PROGRAM@ @INSTALL_OPT_S@
 INSTALL_DATA	= @INSTALL_DATA@
 
 AR		= @AR@
@@ -98,14 +99,15 @@
 
 CC		= @CC@
 CPP		= @CPP@
-CFLAGS		= @CFLAGS@
+CFLAGS		= @CFLAGS@ @EXTRA_CFLAGS@
+LIBS		= @LIBS@
 
 INCDIR		= $(srcdir)/../include
-CPPFLAGS	= -DHAVE_CONFIG_H @CPPFLAGS@
+CPPFLAGS	= -DHAVE_CONFIG_H -DBUILDING_NCURSES -I../ncurses @CPPFLAGS@
 
 CCFLAGS		= $(CPPFLAGS) $(CFLAGS)
 
-BUILD_CPPFLAGS	= -DHAVE_CONFIG_H -DUSE_BUILD_CC -I../ncurses -I$(srcdir) -I../include -I$(INCDIR) @BUILD_CPPFLAGS@ 
+BUILD_CPPFLAGS	= -DHAVE_CONFIG_H -DUSE_BUILD_CC -I../ncurses -I$(srcdir) -I../include -I$(INCDIR) @BUILD_CPPFLAGS@
 BUILD_CC	= @BUILD_CC@
 BUILD_CCFLAGS	= @BUILD_CFLAGS@
 BUILD_LDFLAGS	= @BUILD_LDFLAGS@
@@ -118,20 +120,20 @@
 x		= @EXEEXT@
 
 CFLAGS_LIBTOOL	= $(CCFLAGS)
-CFLAGS_NORMAL	= $(CCFLAGS)
-CFLAGS_DEBUG	= $(CCFLAGS) @CC_G_OPT@ -DTRACE
-CFLAGS_PROFILE	= $(CCFLAGS) -pg
+CFLAGS_NORMAL	= $(CCFLAGS) -DNCURSES_STATIC
+CFLAGS_DEBUG	= $(CCFLAGS) -DNCURSES_STATIC @CC_G_OPT@ -DTRACE
+CFLAGS_PROFILE	= $(CCFLAGS) -DNCURSES_STATIC -pg
 CFLAGS_SHARED	= $(CCFLAGS) @CC_SHARED_OPTS@
 
 CFLAGS_DEFAULT	= $(CFLAGS_@DFT_UPR_MODEL@)
 
 LINK		= $(LIBTOOL)
-LDFLAGS		= @LDFLAGS@ @LD_MODEL@ @LIBS@
+LDFLAGS		= @LDFLAGS@ @LD_MODEL@
 
 SHLIB_DIRS	= -L../lib
-SHLIB_LIST	= $(SHLIB_DIRS) @SHLIB_LIST@
-TINFO_LIST	= $(SHLIB_DIRS) @TINFO_LIST@
-TICS_LIST	= $(SHLIB_DIRS) @TICS_LIST@
+SHLIB_LIST	= $(SHLIB_DIRS) @SHLIB_LIST@ @LIBS@
+TINFO_LIST	= $(SHLIB_DIRS) @TINFO_LIST@ @LIBS@
+TICS_LIST	= $(SHLIB_DIRS) @TICS_LIST@ @LIBS@
 
 RPATH_LIST	= @RPATH_LIST@
 RESULTING_SYMS	= @RESULTING_SYMS@
@@ -155,14 +157,17 @@
 
 USE_BIG_STRINGS	= @USE_BIG_STRINGS@
 TERMINFO_CAPS	= $(top_srcdir)/include/@TERMINFO_CAPS@
+CAPLIST		= $(TERMINFO_CAPS) $(top_srcdir)/include/Caps-ncurses
 
 TERMINFO	= @TERMINFO@
 TERMINFO_SRC	= @TERMINFO_SRC@
-TIC_PATH	= @TIC_PATH@
+TIC_PATH	= @TIC@
+INFOCMP_PATH	= @INFOCMP@
 
 AUTO_SRC = \
 	./codes.c \
 	./comp_captab.c \
+	./comp_userdefs.c \
 	./expanded.c \
 	./fallback.c \
 	./lib_gen.c \
@@ -173,28 +178,37 @@
 	init_keytry.h \
 	keys.list
 
-HEADER_DEPS	= \
-	$(srcdir)/curses.priv.h \
-	../include/ncurses_dll.h \
+HEADER_DEPS	= @INTERNALS_HDR@ \
 	../include/ncurses_cfg.h \
+	../include/ncurses_def.h \
+	../include/ncurses_dll.h \
 	../include/curses.h \
-	$(INCDIR)/nc_panel.h \
 	../include/term.h \
-	$(INCDIR)/term_entry.h \
-	$(INCDIR)/nc_tparm.h \
+	../include/unctrl.h \
 	$(INCDIR)/nc_alloc.h \
-	$(INCDIR)/nc_mingw.h
+	$(INCDIR)/nc_panel.h \
+	$(INCDIR)/nc_string.h \
+	$(INCDIR)/nc_termios.h \
+	$(INCDIR)/nc_tparm.h \
+	$(INCDIR)/nc_win32.h \
+	$(INCDIR)/term_entry.h \
+	$(srcdir)/curses.priv.h \
+	$(srcdir)/new_pair.h \
+	$(srcdir)/term.priv.h
 
 TEST_DEPS	= ../lib/@LIB_PREFIX@ncurses@DFT_DEP_SUFFIX@
-TEST_ARGS	= @LDFLAGS_STATIC@ @TEST_ARGS@ @LDFLAGS_SHARED@ 
+TEST_ARGS	= @LDFLAGS_STATIC@ @TEST_ARGS@ @LDFLAGS_SHARED@
 TEST_LDFLAGS	= @LD_MODEL@ $(TEST_ARGS) @LIBS@ @LOCAL_LDFLAGS@ @LDFLAGS@
 
 TEST_PROGS = \
 	captoinfo$x \
 	hardscroll$x \
-	link_test$x \
 	hashmap$x \
-	lib_mvcur$x
+	lib_mvcur$x \
+	link_test$x \
+	report_hashing$x
+
+LOCAL_LIBDIR	= @top_builddir@/lib
 
 base	 = $(srcdir)/base
 serial	 = $(srcdir)/tty
@@ -204,8 +218,20 @@
 win32con = $(srcdir)/win32con
 
 ################################################################################
-all \
-libs ::		$(AUTO_SRC) ../lib $(LIBRARIES)
+
+@MAKE_PHONY@.PHONY :	all
+@MAKE_PHONY@.PHONY :	check
+@MAKE_PHONY@.PHONY :	clean
+@MAKE_PHONY@.PHONY :	distclean
+@MAKE_PHONY@.PHONY :	libs
+@MAKE_PHONY@.PHONY :	mostlyclean
+@MAKE_PHONY@.PHONY :	realclean
+@MAKE_PHONY@.PHONY :	sources
+@MAKE_PHONY@.PHONY :	test_progs
+
+all libs ::	$(AUTO_SRC) ../lib $(LIBRARIES)
+
+@CHECK_BUILD@all libs ::	report_offsets$(BUILD_EXEEXT)
 
 sources:	$(AUTO_SRC)
 
@@ -216,27 +242,35 @@
 ../lib : ; mkdir $@
 
 ./fallback.c : $(tinfo)/MKfallback.sh
-	$(SHELL) -e $(tinfo)/MKfallback.sh $(TERMINFO) $(TERMINFO_SRC) $(TIC_PATH) $(FALLBACK_LIST) >$@
+	$(SHELL) -e $(tinfo)/MKfallback.sh $(TERMINFO) $(TERMINFO_SRC) "$(TIC_PATH)" "$(INFOCMP_PATH)" $(FALLBACK_LIST) >$@
 
 ./lib_gen.c : $(base)/MKlib_gen.sh ../include/curses.h
-	$(SHELL) -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" generated <../include/curses.h >$@
+	FGREP="@FGREP@" $(SHELL) -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" generated <../include/curses.h >$@
 
-init_keytry.h: make_keys$(BUILD_EXEEXT) keys.list
+init_keytry.h : make_keys$(BUILD_EXEEXT) keys.list
 	./make_keys$(BUILD_EXEEXT) keys.list > $@
 
 keys.list :	$(tinfo)/MKkeys_list.sh
-	AWK=$(AWK) $(SHELL) $(tinfo)/MKkeys_list.sh $(TERMINFO_CAPS) | sort >$@
+	AWK=$(AWK) USE_SIGWINCH=@cf_cv_enable_sigwinch@ $(SHELL) $(tinfo)/MKkeys_list.sh $(CAPLIST) | LC_ALL=C sort >$@
 
 make_keys$(BUILD_EXEEXT) : \
+		build.priv.h \
 		$(tinfo)/make_keys.c \
-		names.c
+		./names.c
 	$(BUILD_CC) -o $@ $(BUILD_CPPFLAGS) $(BUILD_CCFLAGS) $(tinfo)/make_keys.c $(BUILD_LDFLAGS) $(BUILD_LIBS)
 
 make_hash$(BUILD_EXEEXT) : \
+		build.priv.h \
 		$(tinfo)/make_hash.c \
 		../include/hashsize.h
 	$(BUILD_CC) -o $@ $(BUILD_CPPFLAGS) $(BUILD_CCFLAGS) $(tinfo)/make_hash.c $(BUILD_LDFLAGS) $(BUILD_LIBS)
 
+report_offsets$(BUILD_EXEEXT) : \
+		$(srcdir)/curses.priv.h \
+		$(srcdir)/report_offsets.c
+	$(BUILD_CC) -o $@ $(BUILD_CPPFLAGS) $(BUILD_CCFLAGS) $(srcdir)/report_offsets.c $(BUILD_LDFLAGS) $(BUILD_LIBS)
+	./report_offsets$(BUILD_EXEEXT)
+
 ./expanded.c : $(srcdir)/curses.priv.h $(serial)/MKexpanded.sh
 	$(SHELL) -e $(serial)/MKexpanded.sh "$(CPP)" $(CPPFLAGS) > $@
 
@@ -245,16 +279,22 @@
 		../include/hashsize.h \
 		$(tinfo)/MKcaptab.sh \
 		$(tinfo)/MKcaptab.awk
-	$(SHELL) -e $(tinfo)/MKcaptab.sh $(AWK) $(USE_BIG_STRINGS) $(tinfo)/MKcaptab.awk $(srcdir)/../include/@TERMINFO_CAPS@ > $@
+	$(SHELL) -e $(tinfo)/MKcaptab.sh $(AWK) $(USE_BIG_STRINGS) $(tinfo)/MKcaptab.awk $(CAPLIST) > $@
+
+./comp_userdefs.c: \
+		make_hash$(BUILD_EXEEXT) \
+		../include/hashsize.h \
+		$(tinfo)/MKuserdefs.sh
+	$(SHELL) -e $(tinfo)/MKuserdefs.sh $(AWK) $(USE_BIG_STRINGS) $(CAPLIST) > $@
 
 ./lib_keyname.c: keys.list $(base)/MKkeyname.awk
-	$(AWK) -f $(base)/MKkeyname.awk bigstrings=$(USE_BIG_STRINGS) keys.list > $@
+	$(AWK) -f $(base)/MKkeyname.awk use_sigwinch=@cf_cv_enable_sigwinch@ bigstrings=$(USE_BIG_STRINGS) keys.list > $@
 
 ./codes.c: $(tinfo)/MKcodes.awk
-	$(AWK) -f $(tinfo)/MKcodes.awk bigstrings=$(USE_BIG_STRINGS) $(srcdir)/../include/@TERMINFO_CAPS@ >$@
+	$(AWK) -f $(tinfo)/MKcodes.awk bigstrings=$(USE_BIG_STRINGS) $(CAPLIST) >$@
 
 ./names.c: $(tinfo)/MKnames.awk
-	$(AWK) -f $(tinfo)/MKnames.awk bigstrings=$(USE_BIG_STRINGS) $(srcdir)/../include/@TERMINFO_CAPS@ >$@
+	$(AWK) -f $(tinfo)/MKnames.awk bigstrings=$(USE_BIG_STRINGS) $(CAPLIST) >$@
 
 ./unctrl.c: $(base)/MKunctrl.awk
 	echo | $(AWK) -f $(base)/MKunctrl.awk bigstrings=$(USE_BIG_STRINGS) >$@
@@ -266,13 +306,15 @@
 @MAKE_UPPER_TAGS@	$(ETAGS) *.[ch] */*.[ch]
 
 mostlyclean ::
-	-rm -f core tags TAGS *~ *.bak *.i *.ln *.atac trace
+	-rm -f core tags TAGS *~ *.bak *.i *.ln *.atac
+	-test -d trace || rm -f trace
 	-rm -f $(TEST_PROGS)
 
 clean :: mostlyclean
 	-rm -f $(AUTO_SRC)
 	-rm -f make_keys$(BUILD_EXEEXT)
 	-rm -f make_hash$(BUILD_EXEEXT)
+	-rm -f report_offsets$(BUILD_EXEEXT)
 	-rm -rf .libs *.dSYM *.map
 
 distclean :: clean
@@ -284,13 +326,14 @@
 ../include/hashsize.h \
 ../include/parametrized.h \
 ../include/term.h :
-	cd ../include; $(MAKE) $(CF_MFLAGS)
+	( cd ../include && $(MAKE) $(TOP_MFLAGS) )
 
 # These rules build test-programs for the modules that have test-drivers
+@MAKE_PHONY@.PHONY :	test_progs
 test_progs : $(TEST_PROGS)
 
 ./link_test.c : $(base)/MKlib_gen.sh ../include/curses.h
-	$(SHELL) -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" implemented <../include/curses.h >$@
+	FGREP="@FGREP@" $(SHELL) -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" implemented <../include/curses.h >$@
 
 captoinfo$x : $(tinfo)/captoinfo.c $(TEST_DEPS)
 	@ECHO_LD@ $(LIBTOOL_LINK) -o $@ $(CFLAGS_DEFAULT) -DMAIN $(tinfo)/captoinfo.c $(TEST_LDFLAGS)
@@ -310,7 +353,29 @@
 	@ECHO_LD@ $(CC) -o $@ $(CFLAGS_DEFAULT) ../@DFT_OBJ_SUBDIR@/link_test$o $(TEST_LDFLAGS)
 
 ../@DFT_OBJ_SUBDIR@/dump_entry$o:
-	cd ../progs && $(MAKE) ../@DFT_OBJ_SUBDIR@/dump_entry$o
+	( cd ../progs && $(MAKE) ../@DFT_OBJ_SUBDIR@/dump_entry$o )
+
+report_hashing$x : \
+		$(srcdir)/curses.priv.h \
+		$(srcdir)/report_hashing.c $(TEST_DEPS)
+	@ECHO_LD@ $(CC) -o $@ $(CFLAGS_DEFAULT) report_hashing.c $(TEST_LDFLAGS)
+
+# Verify that each header-file can be compiled without including another.
+@MAKE_PHONY@.PHONY :	check_headers
+check_headers:
+	@$(SHELL) -c "for header in *.h;\
+		do \
+			echo \"** testing \$${header}\" ; \
+			echo \"#include <\$${header}>\" >headers.c; \
+			echo \"int main(void) { return 0; }\" >>headers.c; \
+			$(CC) -c $(CFLAGS) $(CPPFLAGS) headers.c; \
+		done"
+	-@rm -f headers.*
+
+@MAKE_PHONY@.PHONY :	check_objects
+check_objects: test_progs
+
+check :: check_headers check_objects
 
 ###############################################################################
 # The remainder of this file is automatically generated during configuration
diff --git a/ncurses/README b/ncurses/README
index cbde335..f52a652 100644
--- a/ncurses/README
+++ b/ncurses/README
@@ -1,5 +1,6 @@
 -------------------------------------------------------------------------------
--- Copyright (c) 1998-2006,2009 Free Software Foundation, Inc.               --
+-- Copyright 2020 Thomas E. Dickey                                           --
+-- Copyright 1998-2006,2009 Free Software Foundation, Inc.                   --
 --                                                                           --
 -- Permission is hereby granted, free of charge, to any person obtaining a   --
 -- copy of this software and associated documentation files (the             --
@@ -25,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: README,v 1.10 2009/06/27 14:44:30 tom Exp $
+-- $Id: README,v 1.11 2020/02/02 23:34:34 tom Exp $
 -------------------------------------------------------------------------------
 For discussion of the package internals, see hackguide.html in the doc/html
 directory.
diff --git a/ncurses/README.IZ b/ncurses/README.IZ
index 78206cd..a9e52ea 100644
--- a/ncurses/README.IZ
+++ b/ncurses/README.IZ
@@ -1,5 +1,6 @@
 -------------------------------------------------------------------------------
--- Copyright (c) 2002,2006 Free Software Foundation, Inc.                    --
+-- Copyright 2020,2021 Thomas E. Dickey                                      --
+-- Copyright 2002,2006 Free Software Foundation, Inc.                        --
 --                                                                           --
 -- Permission is hereby granted, free of charge, to any person obtaining a   --
 -- copy of this software and associated documentation files (the             --
@@ -25,16 +26,16 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: README.IZ,v 1.2 2006/04/22 23:13:05 tom Exp $
+-- $Id: README.IZ,v 1.5 2021/06/17 21:20:30 tom Exp $
 ---------------------------------------------------------------------
 
 Here is the patch.  I did no testing whatsoever with event watching
-requests present (I need some applications which exersize this before
+requests present (I need some applications which exercise this before
 this, probably lynx ;-), but the code looks working "the normal way".
 
 I had no way to test that the poll() branch compiles/works...
 
-Here is the API: 
+Here is the API:
 
 *) two new functions wgetch_events() wgetstrn_event() are introduced,
    which allow an event-watch specification given as the last argument;
diff --git a/ncurses/SigAction.h b/ncurses/SigAction.h
index 5dfde64..30f2474 100644
--- a/ncurses/SigAction.h
+++ b/ncurses/SigAction.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2003,2005 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,7 +33,7 @@
  ****************************************************************************/
 
 /*
- * $Id: SigAction.h,v 1.8 2005/08/06 20:05:32 tom Exp $
+ * $Id: SigAction.h,v 1.10 2020/02/02 23:34:34 tom Exp $
  *
  * This file exists to handle non-POSIX systems which don't have <unistd.h>,
  * and usually no sigaction() nor <termios.h>
diff --git a/ncurses/base/MKkeyname.awk b/ncurses/base/MKkeyname.awk
index 7901611..b3d04ee 100644
--- a/ncurses/base/MKkeyname.awk
+++ b/ncurses/base/MKkeyname.awk
@@ -1,6 +1,7 @@
-# $Id: MKkeyname.awk,v 1.48 2013/08/24 17:37:22 tom Exp $
+# $Id: MKkeyname.awk,v 1.51 2020/02/02 23:34:34 tom Exp $
 ##############################################################################
-# Copyright (c) 1999-2012,2013 Free Software Foundation, Inc.                #
+# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 1998-2016,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -70,14 +71,13 @@
 	print "NCURSES_EXPORT(NCURSES_CONST char *)"
 	print "safe_keyname (SCREEN *sp, int c)"
 	print "{"
-	print "	int i;"
 	print "	char name[20];"
-	print "	char *p;"
 	print "	NCURSES_CONST char *result = 0;"
 	print ""
 	print "	if (c == -1) {"
 	print "		result = \"-1\";"
 	print "	} else {"
+	print "		int i;"
 	if (bigstrings) {
 		print "		for (i = 0; _nc_key_names[i].offset != -1; i++) {"
 		print "			if (_nc_key_names[i].code == c) {"
@@ -114,7 +114,7 @@
 	print "				/* create and cache result as needed */"
 	print "				if (MyTable[c] == 0) {"
 	print "					int cc = c;"
-	print "					p = name;"
+	print "					char *p = name;"
 	print "#define P_LIMIT (sizeof(name) - (size_t) (p - name))"
 	print "					if (cc >= 128 && m_prefix) {"
 	print "						_nc_STRCPY(p, \"M-\", P_LIMIT);"
@@ -135,7 +135,7 @@
 	print "		} else if (result == 0 && HasTerminal(sp)) {"
 	print "			int j, k;"
 	print "			char * bound;"
-	print "			TERMTYPE *tp = &(TerminalOf(sp)->type);"
+	print "			TERMTYPE2 *tp = &TerminalType(TerminalOf(sp));"
 	print "			unsigned save_trace = _nc_tracing;"
 	print ""
 	print "			_nc_tracing = 0;	/* prevent recursion via keybound() */"
@@ -166,8 +166,8 @@
 	print "#if NO_LEAKS"
 	print "void _nc_keyname_leaks(void)"
 	print "{"
-	print "	int j;"
 	print "	if (MyTable != 0) {"
+	print "		int j;"
 	print "		for (j = 0; j < SIZEOF_TABLE; ++j) {"
 	print "			FreeIfNeeded(MyTable[j]);"
 	print "		}"
diff --git a/ncurses/base/MKlib_gen.sh b/ncurses/base/MKlib_gen.sh
index 4f7f19d..f0ac045 100755
--- a/ncurses/base/MKlib_gen.sh
+++ b/ncurses/base/MKlib_gen.sh
@@ -2,10 +2,11 @@
 #
 # MKlib_gen.sh -- generate sources from curses.h macro definitions
 #
-# ($Id: MKlib_gen.sh,v 1.50 2015/08/07 00:48:24 tom Exp $)
+# ($Id: MKlib_gen.sh,v 1.73 2022/10/01 13:14:20 tom Exp $)
 #
 ##############################################################################
-# Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.                #
+# 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    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -62,22 +63,31 @@
 if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
 if test "${LC_COLLATE+set}"  = set; then LC_COLLATE=C;  export LC_COLLATE;  fi
 
-preprocessor="$1 -DNCURSES_INTERNALS -I../include"
+preprocessor="$1 -DNCURSES_WATTR_MACROS -DNCURSES_INTERNALS -I../include"
 AWK="$2"
 USE="$3"
 
 # A patch discussed here:
 #	https://gcc.gnu.org/ml/gcc-patches/2014-06/msg02185.html
+#
 # introduces spurious #line markers into the preprocessor output.  The result
 # appears in gcc 5.0 and (with modification) in 5.1, making it necessary to
 # determine if we are using gcc, and if so, what version because the proposed
 # solution uses a nonstandard option.
-PRG=`echo "$1" | $AWK '{ sub(/^[[:space:]]*/,""); sub(/[[:space:]].*$/, ""); print; }' || exit 0`
-FSF=`"$PRG" --version 2>/dev/null || exit 0 | fgrep "Free Software Foundation" | head -n 1`
+#
+# As illustrated in
+#	https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60723
+#
+# gcc developers chose to ignore the problems with this, and summarized those
+# as "intriguing problems" in
+#	https://gcc.gnu.org/gcc-5/porting_to.html
+
+PRG=`echo "$1" | "$AWK" '{ sub(/^[ 	]*/,""); sub(/[ 	].*$/, ""); print; }' || exit 0`
+FSF=`("$PRG" --version 2>/dev/null || exit 0) | ${FGREP-grep -F} "Free Software Foundation" | head -n 1`
 ALL=`"$PRG" -dumpversion 2>/dev/null || exit 0`
-ONE=`echo "$ALL" | sed -e 's/\..*$//'`
+ONE=`echo "$ALL" | sed -e 's/[^0-9].*$//'`
 if test -n "$FSF" && test -n "$ALL" && test -n "$ONE" ; then
-	if test $ONE -ge 5 ; then
+	if test "$ONE" -ge 5 ; then
 		echo ".. adding -P option to work around $PRG $ALL" >&2
 		preprocessor="$preprocessor -P"
 	fi
@@ -91,14 +101,15 @@
 AW1=awk1_${PID}.awk
 AW2=awk2_${PID}.awk
 TMP=gen__${PID}.c
-trap "rm -f $ED1 $ED2 $ED3 $ED4 $AW1 $AW2 $TMP" 0 1 2 5 15
+trap "rm -f $ED1 $ED2 $ED3 $ED4 $AW1 $AW2 $TMP; exit 1" 1 2 3 15
+trap "rm -f $ED1 $ED2 $ED3 $ED4 $AW1 $AW2 $TMP" 0
 
 ALL=$USE
 if test "$USE" = implemented ; then
-	CALL="call_"
 	cat >$ED1 <<EOF1
 /^extern.*implemented/{
 	h
+	s/GCC_DEPRECATED([^)]*)//
 	s/NCURSES_SP_NAME(\([^)]*\))/NCURSES_SP_NAME___\1/
 	h
 	s/^.*implemented:\([^ 	*]*\).*/P_POUNDCif_USE_\1_SUPPORT/p
@@ -117,7 +128,6 @@
 }
 EOF1
 else
-	CALL=""
 	cat >$ED1 <<EOF1
 /^extern.*${ALL}/{
 	h
@@ -176,7 +186,8 @@
 
 if test "$USE" = generated ; then
 cat >$ED4 <<EOF
-	s/^\(.*\) \(.*\) (\(.*\))\$/NCURSES_EXPORT(\1) (\2) (\3)/
+	s/^\(.*\) \(.*\) (\(.*\))\$/NCURSES_EXPORT(\1) \2 (\3)/
+	/attr_[sg]et.* z)/s,z),z GCC_UNUSED),
 EOF
 else
 cat >$ED4 <<EOF
@@ -230,7 +241,7 @@
 	} else if ( $first == "bool" || $first == "NCURSES_BOOL" ) {
 		returnType = "Bool";
 	} else if ( $second == "*" ) {
-		returnType = "Ptr";
+		returnType = ($1 == "NCURSES_CONST") ? "CPtr" : "Ptr";
 	} else {
 		returnType = "Code";
 	}
@@ -241,6 +252,9 @@
 			break;
 		}
 	}
+	if (using == "implemented") {
+		printf "#undef %s\n", $myfunc;
+	}
 	print $0;
 	print "{";
 	argcount = 1;
@@ -273,6 +287,11 @@
 		dotrace = 0;
 	}
 
+	do_getstr = 0;
+	if ($myfunc ~ /get[n]?str/) {
+		do_getstr = 1;
+	}
+
 	call = "@@T((T_CALLED(\""
 	args = ""
 	comma = ""
@@ -309,7 +328,11 @@
 				call = call "%s"
 			} else if (pointer) {
 				if ( argtype == "char" ) {
-					call = call "%s"
+					if (do_getstr) {
+						call = call "%p"
+					} else {
+						call = call "%s"
+					}
 					comma = comma "_nc_visbuf2(" num ","
 					pointer = 0;
 				} else {
@@ -359,7 +382,7 @@
 	call = call ")); "
 
 	if (dotrace)
-		printf "%s", call
+		printf "%s\n\t@@", call
 
 	if (match($0, "^void")) {
 		call = ""
@@ -398,9 +421,10 @@
 
 cat >$AW2 <<EOF1
 BEGIN		{
+		printf "/* This file was generated by $0 $USE */\n"
+		print ""
 		print "/*"
 		print " * DO NOT EDIT THIS FILE BY HAND!"
-		printf " * It is generated by $0 %s.\n", "$USE"
 		if ( "$USE" == "generated" ) {
 			print " *"
 			print " * This is a file of trivial functions generated from macro"
@@ -417,14 +441,10 @@
 		print "#include <ncurses_cfg.h>"
 		print ""
 		print "#undef NCURSES_NOMACROS	/* _this_ file uses macros */"
+		print "#define NCURSES_NOMACROS 1"
 		print ""
 		print "#include <curses.priv.h>"
 		print ""
-		print "#undef vw_scanw"
-		print "#undef vwscanw"
-		print ""
-		print "#undef vw_printw"
-		print "#undef vwprintw"
 		}
 /^DECLARATIONS/	{start = 1; next;}
 		{
@@ -449,16 +469,17 @@
 			for (n = 1; n < start; ++n) {
 				value = calls[n];
 				if ( value !~ /P_POUNDC/ ) {
-					gsub(/[[:blank:]]+/," ",value);
-					sub(/^[[:alnum:]_]+ /,"",value);
-					sub(/^\* /,"",value);
-					gsub(/[[:alnum:]_]+ \* /,"",value);
+					gsub(/[ \t]+/," ",value);
+					sub(/^[0-9a-zA-Z_]+ /,"",value);
+					sub(/^[*][ \t]*/,"",value);
+					gsub("struct[ \t]*[0-9a-zA-Z_]+[ \t]*[*]","",value);
+					gsub(/[0-9a-zA-Z_]+[ \t]*[*][ \t]*/,"",value);
 					gsub(/ (const) /," ",value);
 					gsub(/ (int|short|attr_t|chtype|wchar_t|NCURSES_BOOL|NCURSES_OUTC|NCURSES_OUTC_sp|va_list) /," ",value);
 					gsub(/ void /,"",value);
 					sub(/^/,"call_",value);
-					gsub(/ (a[[:digit:]]|z) /, " 0 ", value);
-					gsub(/ int[[:blank:]]*[(][^)]+[)][(][^)]+[)]/, "0", value);
+					gsub(/ (a[0-9]|z) /, " 0 ", value);
+					gsub(/ int[ \t]*[(][^)]+[)][(][^)]+[)]/, "0", value);
 					printf "\t%s;\n", value;
 				} else {
 					print value;
@@ -484,7 +505,7 @@
 sed -n -f $ED1 \
 | sed -e 's/NCURSES_EXPORT(\(.*\)) \(.*\) (\(.*\))/\1 \2(\3)/' \
 | sed -f $ED2 \
-| $AWK -f $AW1 using=$USE \
+| "$AWK" -f $AW1 using="$USE" \
 | sed \
 	-e 's/ [ ]*$//g' \
 	-e 's/^\([a-zA-Z_][a-zA-Z_]*[ *]*\)/\1 gen_/' \
@@ -496,7 +517,7 @@
 	-e 's/  / /g' \
 	-e 's/^ //' \
 	-e 's/_Bool/NCURSES_BOOL/g' \
-| $AWK -f $AW2 \
+| "$AWK" -f $AW2 \
 | sed -f $ED3 \
 | sed \
 	-e 's/^.*T_CALLED.*returnCode( \([a-z].*) \));/	return \1;/' \
diff --git a/ncurses/base/MKunctrl.awk b/ncurses/base/MKunctrl.awk
index 51ceb63..e5362bd 100644
--- a/ncurses/base/MKunctrl.awk
+++ b/ncurses/base/MKunctrl.awk
@@ -1,6 +1,7 @@
-# $Id: MKunctrl.awk,v 1.27 2012/06/09 20:29:33 tom Exp $
+# $Id: MKunctrl.awk,v 1.30 2024/02/03 21:09:14 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2009,2012 Free Software Foundation, Inc.                #
+# Copyright 2020,2024 Thomas E. Dickey                                       #
+# Copyright 1998-2012,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -143,6 +144,7 @@
 		print  "\tint check = (int) ChCharOf(ch);"
 		print  "\tconst char *result;"
 		print  ""
+		print  "\t(void) sp;"
 		print  "\tif (check >= 0 && check < (int)SIZEOF(unctrl_table)) {"
 		print  "#if NCURSES_EXT_FUNCS"
 		print  "\t\tif ((sp != 0)"
@@ -153,6 +155,7 @@
 		print  "\t\telse"
 		print  "\t\tif ((check >= 160)"
 		print  "\t\t && (check < 256)"
+		print  "\t\t && !_nc_unicode_locale()"
 		print  "\t\t && ((sp != 0)"
 		print  "\t\t  && ((sp->_legacy_coding > 0)"
 		print  "\t\t   || (sp->_legacy_coding == 0"
diff --git a/ncurses/base/README b/ncurses/base/README
index 4677e42..2710b36 100644
--- a/ncurses/base/README
+++ b/ncurses/base/README
@@ -1,5 +1,6 @@
 -------------------------------------------------------------------------------
--- Copyright (c) 1998,2006 Free Software Foundation, Inc.                    --
+-- Copyright 2020 Thomas E. Dickey                                           --
+-- Copyright 1998,2006 Free Software Foundation, Inc.                        --
 --                                                                           --
 -- Permission is hereby granted, free of charge, to any person obtaining a   --
 -- copy of this software and associated documentation files (the             --
@@ -25,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: README,v 1.2 2006/04/22 22:19:37 tom Exp $
+-- $Id: README,v 1.3 2020/02/02 23:34:34 tom Exp $
 -------------------------------------------------------------------------------
 
 The functions in this directory are the generic (not device-specific) modules
diff --git a/ncurses/base/define_key.c b/ncurses/base/define_key.c
index c78375a..fb9ae36 100644
--- a/ncurses/base/define_key.c
+++ b/ncurses/base/define_key.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2009,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -33,7 +34,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: define_key.c,v 1.21 2014/03/08 20:32:59 tom Exp $")
+MODULE_ID("$Id: define_key.c,v 1.22 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(define_key) (NCURSES_SP_DCLx const char *str, int keycode)
diff --git a/ncurses/base/key_defined.c b/ncurses/base/key_defined.c
index ef987a5..147e5fe 100644
--- a/ncurses/base/key_defined.c
+++ b/ncurses/base/key_defined.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2003-2006,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 2003-2006,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -31,8 +32,9 @@
  ****************************************************************************/
 
 #include <curses.priv.h>
+#include <tic.h>
 
-MODULE_ID("$Id: key_defined.c,v 1.9 2009/10/24 22:15:47 tom Exp $")
+MODULE_ID("$Id: key_defined.c,v 1.11 2023/06/24 15:36:32 tom Exp $")
 
 static int
 find_definition(TRIES * tree, const char *str)
@@ -40,7 +42,7 @@
     TRIES *ptr;
     int result = OK;
 
-    if (str != 0 && *str != '\0') {
+    if (VALID_STRING(str) && *str != '\0') {
 	for (ptr = tree; ptr != 0; ptr = ptr->sibling) {
 	    if (UChar(*str) == UChar(ptr->ch)) {
 		if (str[1] == '\0' && ptr->child != 0) {
diff --git a/ncurses/base/keybound.c b/ncurses/base/keybound.c
index 72790e8..bbd912a 100644
--- a/ncurses/base/keybound.c
+++ b/ncurses/base/keybound.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1999-2009,2011 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1999-2009,2011 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -33,7 +34,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: keybound.c,v 1.11 2011/10/22 16:47:05 tom Exp $")
+MODULE_ID("$Id: keybound.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
 
 /*
  * Returns the count'th string definition which is associated with the
diff --git a/ncurses/base/keyok.c b/ncurses/base/keyok.c
index 37fddec..945228a 100644
--- a/ncurses/base/keyok.c
+++ b/ncurses/base/keyok.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2021 Thomas E. Dickey                                *
+ * Copyright 1998-2012,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -33,13 +34,13 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: keyok.c,v 1.14 2014/03/08 20:32:59 tom Exp $")
+MODULE_ID("$Id: keyok.c,v 1.17 2021/06/17 21:26:02 tom Exp $")
 
 /*
  * Enable (or disable) ncurses' interpretation of a keycode by adding (or
  * removing) the corresponding 'tries' entry.
  *
- * Do this by storing a second tree of tries, which records the disabled keys. 
+ * Do this by storing a second tree of tries, which records the disabled keys.
  * The simplest way to copy is to make a function that returns the string (with
  * nulls set to 0200), then use that to reinsert the string into the
  * corresponding tree.
@@ -55,7 +56,6 @@
 #ifdef USE_TERM_DRIVER
 	code = CallDriver_2(sp, td_kyOk, c, flag);
 #else
-	T((T_CALLED("keyok(%d,%d)"), c, flag));
 	if (c >= 0) {
 	    int count = 0;
 	    char *s;
diff --git a/ncurses/base/legacy_coding.c b/ncurses/base/legacy_coding.c
index d8c8020..a71aee0 100644
--- a/ncurses/base/legacy_coding.c
+++ b/ncurses/base/legacy_coding.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2005,2009 Free Software Foundation, Inc.                   *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2005,2009 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -33,7 +34,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: legacy_coding.c,v 1.5 2009/10/24 22:15:00 tom Exp $")
+MODULE_ID("$Id: legacy_coding.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(use_legacy_coding) (NCURSES_SP_DCLx int level)
diff --git a/ncurses/base/lib_addch.c b/ncurses/base/lib_addch.c
index 4b16a47..a14bfd3 100644
--- a/ncurses/base/lib_addch.c
+++ b/ncurses/base/lib_addch.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019-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  *
  * copy of this software and associated documentation files (the            *
@@ -36,7 +37,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_addch.c,v 1.129 2014/08/16 20:41:04 tom Exp $")
+MODULE_ID("$Id: lib_addch.c,v 1.141 2022/06/12 15:16:41 tom Exp $")
 
 static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
 
@@ -51,7 +52,7 @@
  */
 
 /* Return bit mask for clearing color pair number if given ch has color */
-#define COLOR_MASK(ch) (~(attr_t)((ch) & A_COLOR ? A_COLOR : 0))
+#define COLOR_MASK(ch) (~(attr_t)(((ch) & A_COLOR) ? A_COLOR : 0))
 
 static NCURSES_INLINE NCURSES_CH_T
 render_char(WINDOW *win, NCURSES_CH_T ch)
@@ -117,14 +118,18 @@
 #endif
 
 static bool
-newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T * ypos)
+newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T *ypos)
 {
     bool result = FALSE;
 
-    if (*ypos >= win->_regtop && *ypos == win->_regbottom) {
-	*ypos = win->_regbottom;
-	result = TRUE;
-    } else {
+    if (*ypos >= win->_regtop && *ypos <= win->_regbottom) {
+	if (*ypos == win->_regbottom) {
+	    *ypos = win->_regbottom;
+	    result = TRUE;
+	} else if (*ypos < win->_maxy) {
+	    *ypos = (NCURSES_SIZE_T) (*ypos + 1);
+	}
+    } else if (*ypos < win->_maxy) {
 	*ypos = (NCURSES_SIZE_T) (*ypos + 1);
     }
     return result;
@@ -135,7 +140,7 @@
  * wrapped the cursor.  We don't do anything with this flag except set it when
  * wrapping, and clear it whenever we move the cursor.  If we try to wrap at
  * the lower-right corner of a window, we cannot move the cursor (since that
- * wouldn't be legal).  So we return an error (which is what SVr4 does). 
+ * wouldn't be legal).  So we return an error (which is what SVr4 does).
  * Unlike SVr4, we can successfully add a character to the lower-right corner
  * (Solaris 2.6 does this also, however).
  */
@@ -203,6 +208,20 @@
     WINDOW_EXT(win, addch_x) = x;
     WINDOW_EXT(win, addch_y) = y;
 
+    /*
+     * If the background character is a wide-character, that may interfere with
+     * processing multibyte characters in this function.
+     */
+    if (!is8bits(CharOf(CHDEREF(ch)))) {
+	if (WINDOW_EXT(win, addch_used) != 0) {
+	    /* discard the incomplete multibyte character */
+	    WINDOW_EXT(win, addch_used) = 0;
+	    TR(TRACE_VIRTPUT,
+	       ("Alert discarded incomplete multibyte"));
+	}
+	return 1;
+    }
+
     init_mb(state);
     buffer[WINDOW_EXT(win, addch_used)] = (char) CharOf(CHDEREF(ch));
     WINDOW_EXT(win, addch_used) += 1;
@@ -270,11 +289,11 @@
 
 		/* handle EILSEQ (i.e., when len >= -1) */
 		if (len == -1 && is8bits(CharOf(ch))) {
-		    int rc = OK;
 		    const char *s = NCURSES_SP_NAME(unctrl)
 		      (NCURSES_SP_ARGx (chtype) CharOf(ch));
 
 		    if (s[1] != '\0') {
+			int rc = OK;
 			while (*s != '\0') {
 			    rc = waddch(win, UChar(*s) | attr);
 			    if (rc != OK)
@@ -299,23 +318,32 @@
      * adjustments.
      */
     if_WIDEC({
-	int len = wcwidth(CharOf(ch));
+	int len = _nc_wacs_width(CharOf(ch));
 	int i;
 	int j;
-	wchar_t *chars;
 
 	if (len == 0) {		/* non-spacing */
 	    if ((x > 0 && y >= 0)
 		|| (win->_maxx >= 0 && win->_cury >= 1)) {
-		if (x > 0 && y >= 0)
-		    chars = (win->_line[y].text[x - 1].chars);
-		else
-		    chars = (win->_line[y - 1].text[win->_maxx].chars);
+		NCURSES_CH_T *dst;
+		wchar_t *chars;
+		if (x > 0 && y >= 0) {
+		    for (j = x - 1; j >= 0; --j) {
+			if (!isWidecExt(win->_line[y].text[j])) {
+			    win->_curx = (NCURSES_SIZE_T) j;
+			    break;
+			}
+		    }
+		    dst = &(win->_line[y].text[j]);
+		} else {
+		    dst = &(win->_line[y - 1].text[win->_maxx]);
+		}
+		chars = dst->chars;
 		for (i = 0; i < CCHARW_MAX; ++i) {
 		    if (chars[i] == 0) {
 			TR(TRACE_VIRTPUT,
-			   ("added non-spacing %d: %x",
-			    x, (int) CharOf(ch)));
+			   ("adding non-spacing %s (level %d)",
+			    _tracech_t(CHREF(ch)), i));
 			chars[i] = CharOf(ch);
 			break;
 		    }
@@ -339,6 +367,7 @@
 		    return ERR;
 		x = win->_curx;
 		y = win->_cury;
+		CHECK_POSITION(win, x, y);
 		line = win->_line + y;
 	    }
 	    /*
@@ -390,9 +419,9 @@
   testwrapping:
     );
 
-    TR(TRACE_VIRTPUT, ("cell (%ld, %ld..%d) = %s",
-		       (long) win->_cury, (long) win->_curx, x - 1,
-		       _tracech_t(CHREF(ch))));
+    TR(TRACE_VIRTPUT, ("cell (%d, %d..%d) = %s",
+		       win->_cury, win->_curx, x - 1,
+		       _tracech_t(CHREF(line->text[win->_curx]))));
 
     if (x > win->_maxx) {
 	return wrap_to_next_line(win);
@@ -427,7 +456,7 @@
 	       s[1] == 0
 	)
 	|| (
-	       (isprint((int)t) && !iscntrl((int)t))
+	       (isprint((int) t) && !iscntrl((int) t))
 #if USE_WIDEC_SUPPORT
 	       || ((sp == 0 || !sp->_legacy_coding) &&
 		   (WINDOW_EXT(win, addch_used)
@@ -443,6 +472,7 @@
      */
     x = win->_curx;
     y = win->_cury;
+    CHECK_POSITION(win, x, y);
 
     switch (t) {
     case '\t':
diff --git a/ncurses/base/lib_addstr.c b/ncurses/base/lib_addstr.c
index a1a55cb..a3753af 100644
--- a/ncurses/base/lib_addstr.c
+++ b/ncurses/base/lib_addstr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc.              *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -44,7 +45,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_addstr.c,v 1.52 2011/05/28 23:02:09 tom Exp $")
+MODULE_ID("$Id: lib_addstr.c,v 1.62 2023/11/21 21:47:23 tom Exp $")
 
 NCURSES_EXPORT(int)
 waddnstr(WINDOW *win, const char *astr, int n)
@@ -54,14 +55,17 @@
 
     T((T_CALLED("waddnstr(%p,%s,%d)"), (void *) win, _nc_visbufn(astr, n), n));
 
-    if (win && (str != 0)) {
+    if (win && (str != 0) && (n != 0)) {
+	bool explicit = (n > 0);
+
 	TR(TRACE_VIRTPUT | TRACE_ATTRS,
 	   ("... current %s", _traceattr(WINDOW_ATTRS(win))));
 	code = OK;
-	if (n < 0)
-	    n = (int) strlen(astr);
 
-	TR(TRACE_VIRTPUT, ("str is not null, length = %d", n));
+	TR(TRACE_VIRTPUT, ("str is not null, length = %d",
+			   (explicit ? n : (int) strlen(str))));
+	if (!explicit)
+	    n = INT_MAX;
 	while ((n-- > 0) && (*str != '\0')) {
 	    NCURSES_CH_T ch;
 	    TR(TRACE_VIRTPUT, ("*str = %#o", UChar(*str)));
@@ -87,7 +91,7 @@
 
     T((T_CALLED("waddchnstr(%p,%p,%d)"), (void *) win, (const void *) astr, n));
 
-    if (!win)
+    if (!win || !astr)
 	returnCode(ERR);
 
     y = win->_cury;
@@ -142,7 +146,7 @@
        _nc_viscbuf(astr, n),
        n));
 
-    if (!win)
+    if (!win || !astr)
 	returnCode(ERR);
 
     y = win->_cury;
@@ -183,7 +187,7 @@
 	if (isWidecExt(astr[i]))
 	    continue;
 
-	len = wcwidth(CharOf(astr[i]));
+	len = _nc_wacs_width(CharOf(astr[i]));
 
 	if (x + len - 1 <= win->_maxx) {
 	    line->text[x] = _nc_render(win, astr[i]);
@@ -194,6 +198,8 @@
 		    }
 		    SetWidecExt(line->text[x + j], j);
 		}
+	    } else {
+		len = 1;
 	    }
 	    x = (NCURSES_SIZE_T) (x + len);
 	    end += len - 1;
@@ -224,14 +230,17 @@
 
     T((T_CALLED("waddnwstr(%p,%s,%d)"), (void *) win, _nc_viswbufn(str, n), n));
 
-    if (win && (str != 0)) {
+    if (win && (str != 0) && (n != 0)) {
+	bool explicit = (n > 0);
+
 	TR(TRACE_VIRTPUT | TRACE_ATTRS,
 	   ("... current %s", _traceattr(WINDOW_ATTRS(win))));
 	code = OK;
-	if (n < 0)
-	    n = (int) wcslen(str);
 
-	TR(TRACE_VIRTPUT, ("str is not null, length = %d", n));
+	TR(TRACE_VIRTPUT, ("str is not null, length = %d",
+			   (explicit ? n : (int) wcslen(str))));
+	if (!explicit)
+	    n = INT_MAX;
 	while ((n-- > 0) && (*str != L('\0'))) {
 	    NCURSES_CH_T ch;
 	    TR(TRACE_VIRTPUT, ("*str[0] = %#lx", (unsigned long) *str));
diff --git a/ncurses/base/lib_beep.c b/ncurses/base/lib_beep.c
index b775d56..b1a60b9 100644
--- a/ncurses/base/lib_beep.c
+++ b/ncurses/base/lib_beep.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2013,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -46,7 +47,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_beep.c,v 1.17 2014/03/08 20:32:59 tom Exp $")
+MODULE_ID("$Id: lib_beep.c,v 1.18 2020/02/02 23:34:34 tom Exp $")
 
 /*
  *	beep()
diff --git a/ncurses/base/lib_bkgd.c b/ncurses/base/lib_bkgd.c
index c46ca42..4f99080 100644
--- a/ncurses/base/lib_bkgd.c
+++ b/ncurses/base/lib_bkgd.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-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  *
  * copy of this software and associated documentation files (the            *
@@ -36,7 +37,9 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_bkgd.c,v 1.49 2014/09/04 09:36:20 tom Exp $")
+MODULE_ID("$Id: lib_bkgd.c,v 1.63 2021/05/08 14:58:12 tom Exp $")
+
+static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
 
 /*
  * Set the window's background information.
@@ -48,7 +51,7 @@
 #endif
 wbkgrndset(WINDOW *win, const ARG_CH_T ch)
 {
-    T((T_CALLED("wbkgdset(%p,%s)"), (void *) win, _tracech_t(ch)));
+    T((T_CALLED("wbkgrndset(%p,%s)"), (void *) win, _tracech_t(ch)));
 
     if (win) {
 	attr_t off = AttrOf(win->_nc_bkgd);
@@ -61,7 +64,7 @@
 	{
 	    int pair;
 
-	    if ((pair = GetPair(win->_nc_bkgd)) != 0)
+	    if (GetPair(win->_nc_bkgd) != 0)
 		SET_WINDOW_PAIR(win, 0);
 	    if ((pair = GetPair(CHDEREF(ch))) != 0)
 		SET_WINDOW_PAIR(win, pair);
@@ -102,44 +105,147 @@
 wbkgdset(WINDOW *win, chtype ch)
 {
     NCURSES_CH_T wch;
+    T((T_CALLED("wbkgdset(%p,%s)"), (void *) win, _tracechtype(ch)));
     SetChar2(wch, ch);
     wbkgrndset(win, CHREF(wch));
+    returnVoid;
 }
 
 /*
  * Set the window's background information and apply it to each cell.
  */
-#if USE_WIDEC_SUPPORT
-NCURSES_EXPORT(int)
-#else
 static NCURSES_INLINE int
-#undef wbkgrnd
-#endif
-wbkgrnd(WINDOW *win, const ARG_CH_T ch)
+_nc_background(WINDOW *win, const ARG_CH_T ch, bool narrow)
 {
+#undef  SP_PARM
+#define SP_PARM SP		/* to use Charable() */
     int code = ERR;
-    int x, y;
 
-    T((T_CALLED("wbkgd(%p,%s)"), (void *) win, _tracech_t(ch)));
+#if USE_WIDEC_SUPPORT
+    T((T_CALLED("%s(%p,%s)"),
+       narrow ? "wbkgd" : "wbkgrnd",
+       (void *) win,
+       _tracecchar_t(ch)));
+#define TraceChar(c) _tracecchar_t2(1, &(c))
+#else
+    T((T_CALLED("%s(%p,%s)"),
+       "wbkgd",
+       (void *) win,
+       _tracech_t(ch)));
+    (void) narrow;
+#define TraceChar(c) _tracechar(CharOf(c))
+#endif
 
-    if (win) {
+    if (SP == 0) {
+	;
+    } else if (win) {
 	NCURSES_CH_T new_bkgd = CHDEREF(ch);
-	NCURSES_CH_T old_bkgrnd;
+	NCURSES_CH_T old_bkgd;
+	int y;
+	NCURSES_CH_T old_char;
+	attr_t old_attr;
+	int old_pair;
+	NCURSES_CH_T new_char;
+	attr_t new_attr;
+	int new_pair;
 
-	memset(&old_bkgrnd, 0, sizeof(old_bkgrnd));
-	(void) wgetbkgrnd(win, &old_bkgrnd);
+	/* SVr4 trims color info if non-color terminal */
+	if (!SP->_pair_limit) {
+	    RemAttr(new_bkgd, A_COLOR);
+	    SetPair(new_bkgd, 0);
+	}
+
+	/* avoid setting background-character to a null */
+	if (CharOf(new_bkgd) == 0) {
+	    NCURSES_CH_T tmp_bkgd = blank;
+	    SetAttr(tmp_bkgd, AttrOf(new_bkgd));
+	    SetPair(tmp_bkgd, GetPair(new_bkgd));
+	    new_bkgd = tmp_bkgd;
+	}
+
+	memset(&old_bkgd, 0, sizeof(old_bkgd));
+	(void) wgetbkgrnd(win, &old_bkgd);
+
+	if (!memcmp(&old_bkgd, &new_bkgd, sizeof(new_bkgd))) {
+	    T(("...unchanged"));
+	    returnCode(OK);
+	}
+
+	old_char = old_bkgd;
+	RemAttr(old_char, ~A_CHARTEXT);
+	old_attr = AttrOf(old_bkgd);
+	old_pair = GetPair(old_bkgd);
+
+	if (!(old_attr & A_COLOR)) {
+	    old_pair = 0;
+	}
+	T(("... old background char %s, attr %s, pair %d",
+	   TraceChar(old_char), _traceattr(old_attr), old_pair));
+
+	new_char = new_bkgd;
+	RemAttr(new_char, ~A_CHARTEXT);
+	new_attr = AttrOf(new_bkgd);
+	new_pair = GetPair(new_bkgd);
+
+	/* SVr4 limits background character to printable 7-bits */
+	if (
+#if USE_WIDEC_SUPPORT
+	       narrow &&
+#endif
+	       !Charable(new_bkgd)) {
+	    new_char = old_char;
+	}
+	if (!(new_attr & A_COLOR)) {
+	    new_pair = 0;
+	}
+	T(("... new background char %s, attr %s, pair %d",
+	   TraceChar(new_char), _traceattr(new_attr), new_pair));
 
 	(void) wbkgrndset(win, CHREF(new_bkgd));
-	(void) wattrset(win, (int) AttrOf(win->_nc_bkgd));
+
+	/* SVr4 updates color pair if old/new match, otherwise just attrs */
+	if ((new_pair != 0) && (new_pair == old_pair)) {
+	    WINDOW_ATTRS(win) = new_attr;
+	    SET_WINDOW_PAIR(win, new_pair);
+	} else {
+	    WINDOW_ATTRS(win) = new_attr;
+	}
 
 	for (y = 0; y <= win->_maxy; y++) {
+	    int x;
+
 	    for (x = 0; x <= win->_maxx; x++) {
-		if (CharEq(win->_line[y].text[x], old_bkgrnd)) {
-		    win->_line[y].text[x] = win->_nc_bkgd;
+		NCURSES_CH_T *cp = &(win->_line[y].text[x]);
+		int tmp_pair = GetPair(*cp);
+		attr_t tmp_attr = AttrOf(*cp);
+
+		if (CharEq(*cp, old_bkgd)) {
+#if USE_WIDEC_SUPPORT
+		    if (!narrow) {
+			if (Charable(new_bkgd)) {
+			    SetChar2(*cp, CharOf(new_char));
+			} else {
+			    SetChar(*cp, L' ', AttrOf(new_char));
+			}
+			memcpy(cp->chars,
+			       new_char.chars,
+			       CCHARW_MAX * sizeof(cp->chars[0]));
+		    } else
+#endif
+			SetChar2(*cp, CharOf(new_char));
+		}
+		if (tmp_pair != 0) {
+		    if (tmp_pair == old_pair) {
+			SetAttr(*cp, (tmp_attr & ~old_attr) | new_attr);
+			SetPair(*cp, new_pair);
+		    } else {
+			SetAttr(*cp,
+				(tmp_attr & (~old_attr | A_COLOR))
+				| (new_attr & ALL_BUT_COLOR));
+		    }
 		} else {
-		    NCURSES_CH_T wch = win->_line[y].text[x];
-		    RemAttr(wch, (~(A_ALTCHARSET | A_CHARTEXT)));
-		    win->_line[y].text[x] = _nc_render(win, wch);
+		    SetAttr(*cp, (tmp_attr & ~old_attr) | new_attr);
+		    SetPair(*cp, new_pair);
 		}
 	    }
 	}
@@ -150,10 +256,18 @@
     returnCode(code);
 }
 
+#if USE_WIDEC_SUPPORT
+NCURSES_EXPORT(int)
+wbkgrnd(WINDOW *win, const ARG_CH_T ch)
+{
+    return _nc_background(win, ch, FALSE);
+}
+#endif
+
 NCURSES_EXPORT(int)
 wbkgd(WINDOW *win, chtype ch)
 {
     NCURSES_CH_T wch;
     SetChar2(wch, ch);
-    return wbkgrnd(win, CHREF(wch));
+    return _nc_background(win, CHREF(wch), TRUE);
 }
diff --git a/ncurses/base/lib_box.c b/ncurses/base/lib_box.c
index 6f17c97..186f112 100644
--- a/ncurses/base/lib_box.c
+++ b/ncurses/base/lib_box.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_box.c,v 1.24 2010/04/24 23:51:57 tom Exp $")
+MODULE_ID("$Id: lib_box.c,v 1.26 2020/02/02 23:34:34 tom Exp $")
 
 #if USE_WIDEC_SUPPORT
 static NCURSES_INLINE chtype
@@ -114,10 +115,20 @@
     win->_line[endy].lastchar = win->_line[0].lastchar = endx;
 
     for (i = 0; i <= endy; i++) {
+#if USE_WIDEC_SUPPORT
+	if (endx > 0 && isWidecExt(win->_line[i].text[endx])) {
+	    SetChar2(win->_line[i].text[endx - 1], ' ');
+	}
+#endif
 	SetChar2(win->_line[i].text[0], wls);
 	SetChar2(win->_line[i].text[endx], wrs);
 	win->_line[i].firstchar = 0;
 	win->_line[i].lastchar = endx;
+#if USE_WIDEC_SUPPORT
+	if (isWidecExt(win->_line[i].text[1])) {
+	    SetChar2(win->_line[i].text[1], ' ');
+	}
+#endif
     }
     SetChar2(win->_line[0].text[0], wtl);
     SetChar2(win->_line[0].text[endx], wtr);
diff --git a/ncurses/base/lib_chgat.c b/ncurses/base/lib_chgat.c
index 1eb1f59..74c4f75 100644
--- a/ncurses/base/lib_chgat.c
+++ b/ncurses/base/lib_chgat.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,35 +43,38 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_chgat.c,v 1.10 2014/02/01 22:13:31 tom Exp $")
+MODULE_ID("$Id: lib_chgat.c,v 1.13 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 wchgat(WINDOW *win,
        int n,
        attr_t attr,
-       NCURSES_PAIRS_T color,
+       NCURSES_PAIRS_T pair_arg,
        const void *opts GCC_UNUSED)
 {
-    int i;
+    int code = ERR;
+    int color_pair = pair_arg;
 
     T((T_CALLED("wchgat(%p,%d,%s,%d)"),
        (void *) win,
        n,
        _traceattr(attr),
-       (int) color));
+       color_pair));
 
+    set_extended_pair(opts, color_pair);
     if (win) {
 	struct ldat *line = &(win->_line[win->_cury]);
+	int i;
 
-	toggle_attr_on(attr, ColorPair(color));
+	toggle_attr_on(attr, ColorPair(color_pair));
 
 	for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++) {
 	    SetAttr(line->text[i], attr);
-	    SetPair(line->text[i], color);
+	    SetPair(line->text[i], color_pair);
 	    CHANGED_CELL(line, i);
 	}
 
-	returnCode(OK);
-    } else
-	returnCode(ERR);
+	code = OK;
+    }
+    returnCode(code);
 }
diff --git a/ncurses/base/lib_clear.c b/ncurses/base/lib_clear.c
index 008744c..2a1c97c 100644
--- a/ncurses/base/lib_clear.c
+++ b/ncurses/base/lib_clear.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2000,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_clear.c,v 1.8 2009/10/24 22:33:29 tom Exp $")
+MODULE_ID("$Id: lib_clear.c,v 1.9 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 wclear(WINDOW *win)
diff --git a/ncurses/base/lib_clearok.c b/ncurses/base/lib_clearok.c
index ffc7d02..d98287c 100644
--- a/ncurses/base/lib_clearok.c
+++ b/ncurses/base/lib_clearok.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2000,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_clearok.c,v 1.5 2009/10/24 22:34:53 tom Exp $")
+MODULE_ID("$Id: lib_clearok.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 clearok(WINDOW *win, bool flag)
diff --git a/ncurses/base/lib_clrbot.c b/ncurses/base/lib_clrbot.c
index cbf2206..e5482b9 100644
--- a/ncurses/base/lib_clrbot.c
+++ b/ncurses/base/lib_clrbot.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2006,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2006,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_clrbot.c,v 1.21 2009/10/24 22:33:19 tom Exp $")
+MODULE_ID("$Id: lib_clrbot.c,v 1.22 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 wclrtobot(WINDOW *win)
diff --git a/ncurses/base/lib_clreol.c b/ncurses/base/lib_clreol.c
index 7aff84b..0b6b0ff 100644
--- a/ncurses/base/lib_clreol.c
+++ b/ncurses/base/lib_clreol.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 1998-2001,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_clreol.c,v 1.22 2009/10/24 22:33:06 tom Exp $")
+MODULE_ID("$Id: lib_clreol.c,v 1.24 2021/10/23 19:06:01 tom Exp $")
 
 NCURSES_EXPORT(int)
 wclrtoeol(WINDOW *win)
@@ -60,7 +61,7 @@
 	 * If we have just wrapped the cursor, the clear applies to the
 	 * new line, unless we are at the lower right corner.
 	 */
-	if ((win->_flags & _WRAPPED) != 0
+	if (IS_WRAPPED(win) != 0
 	    && y < win->_maxy) {
 	    win->_flags &= ~_WRAPPED;
 	}
@@ -69,7 +70,7 @@
 	 * There's no point in clearing if we're not on a legal
 	 * position, either.
 	 */
-	if ((win->_flags & _WRAPPED) != 0
+	if (IS_WRAPPED(win)
 	    || y > win->_maxy
 	    || x > win->_maxx)
 	    returnCode(ERR);
diff --git a/ncurses/base/lib_color.c b/ncurses/base/lib_color.c
index 1322600..f001b22 100644
--- a/ncurses/base/lib_color.c
+++ b/ncurses/base/lib_color.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -38,14 +39,17 @@
  * Handles color emulation of SYS V curses
  */
 
+#define NEW_PAIR_INTERNAL 1
+
 #include <curses.priv.h>
+#include <new_pair.h>
 #include <tic.h>
 
 #ifndef CUR
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_color.c,v 1.110 2014/03/08 20:04:44 tom Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.150 2023/09/16 16:39:15 tom Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define CanChange      InfoOf(SP_PARM).canchange
@@ -90,8 +94,6 @@
 
 #define DATA(r,g,b) {r,g,b, 0,0,0, 0}
 
-#define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
-
 #define MAX_PALETTE	8
 
 #define OkColorHi(n)	(((n) < COLORS) && ((n) < maxcolors))
@@ -136,14 +138,6 @@
 #endif
 
 /* *INDENT-ON* */
-
-/*
- * Ensure that we use color pairs only when colors have been started, and also
- * that the index is within the limits of the table which we allocated.
- */
-#define ValidPair(pair) \
-    ((SP_PARM != 0) && (pair >= 0) && (pair < SP_PARM->_pair_limit) && SP_PARM->_coloron)
-
 #if NCURSES_EXT_FUNCS
 /*
  * These are called from _nc_do_color(), which in turn is called from
@@ -193,12 +187,12 @@
     if (set_a_background) {
 	TPUTS_TRACE("set_a_background");
 	NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				TPARM_1(set_a_background, bg),
+				TIPARM_1(set_a_background, bg),
 				1, outc);
     } else {
 	TPUTS_TRACE("set_background");
 	NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				TPARM_1(set_background, toggled_colors(bg)),
+				TIPARM_1(set_background, toggled_colors(bg)),
 				1, outc);
     }
 #endif
@@ -213,12 +207,12 @@
     if (set_a_foreground) {
 	TPUTS_TRACE("set_a_foreground");
 	NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				TPARM_1(set_a_foreground, fg),
+				TIPARM_1(set_a_foreground, fg),
 				1, outc);
     } else {
 	TPUTS_TRACE("set_foreground");
 	NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				TPARM_1(set_foreground, toggled_colors(fg)),
+				TIPARM_1(set_foreground, toggled_colors(fg)),
 				1, outc);
     }
 #endif
@@ -251,6 +245,61 @@
     }
 }
 
+static bool
+init_direct_colors(NCURSES_SP_DCL0)
+{
+    static NCURSES_CONST char name[] = "RGB";
+
+    rgb_bits_t *result = &(SP_PARM->_direct_color);
+
+    result->value = 0;
+
+    if (COLORS >= 8) {
+	int n;
+	const char *s;
+	int width;
+
+	/* find the number of bits needed for the maximum color value */
+	for (width = 0; (1 << width) - 1 < (COLORS - 1); ++width) {
+	    ;
+	}
+
+	if (tigetflag(name) > 0) {
+	    n = (width + 2) / 3;
+	    result->bits.red = UChar(n);
+	    result->bits.green = UChar(n);
+	    result->bits.blue = UChar(width - (2 * n));
+	} else if ((n = tigetnum(name)) > 0) {
+	    result->bits.red = UChar(n);
+	    result->bits.green = UChar(n);
+	    result->bits.blue = UChar(n);
+	} else if ((s = tigetstr(name)) != 0 && VALID_STRING(s)) {
+	    int red = n;
+	    int green = n;
+	    int blue = width - (2 * n);
+
+	    switch (sscanf(s, "%d/%d/%d", &red, &green, &blue)) {
+	    default:
+		blue = width - (2 * n);
+		/* FALLTHRU */
+	    case 1:
+		green = n;
+		/* FALLTHRU */
+	    case 2:
+		red = n;
+		/* FALLTHRU */
+	    case 3:
+		/* okay */
+		break;
+	    }
+	    result->bits.red = UChar(red);
+	    result->bits.green = UChar(green);
+	    result->bits.blue = UChar(blue);
+	}
+    }
+    return (result->value != 0);
+}
+
 /*
  * Reset the color pair, e.g., to whatever color pair 0 is.
  */
@@ -310,7 +359,6 @@
 NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0)
 {
     int result = ERR;
-    int maxpairs = 0, maxcolors = 0;
 
     T((T_CALLED("start_color(%p)"), (void *) SP_PARM));
 
@@ -319,8 +367,8 @@
     } else if (SP_PARM->_coloron) {
 	result = OK;
     } else {
-	maxpairs = MaxPairs;
-	maxcolors = MaxColors;
+	int maxpairs = MaxPairs;
+	int maxcolors = MaxColors;
 	if (reset_color_pair(NCURSES_SP_ARG) != TRUE) {
 	    set_foreground_color(NCURSES_SP_ARGx
 				 default_fg(NCURSES_SP_ARG),
@@ -346,7 +394,10 @@
 	     * allow for default-color as a component of a color-pair.
 	     */
 	    SP_PARM->_pair_limit += (1 + (2 * maxcolors));
+#if !NCURSES_EXT_COLORS
+	    SP_PARM->_pair_limit = limit_PAIRS(SP_PARM->_pair_limit);
 #endif
+#endif /* NCURSES_EXT_FUNCS */
 	    SP_PARM->_pair_count = maxpairs;
 	    SP_PARM->_color_count = maxcolors;
 #if !USE_REENTRANT
@@ -354,19 +405,26 @@
 	    COLORS = maxcolors;
 #endif
 
-	    SP_PARM->_color_pairs = TYPE_CALLOC(colorpair_t, SP_PARM->_pair_limit);
+	    ReservePairs(SP_PARM, 16);
 	    if (SP_PARM->_color_pairs != 0) {
-		SP_PARM->_color_table = TYPE_CALLOC(color_t, maxcolors);
-		if (SP_PARM->_color_table != 0) {
-		    SP_PARM->_color_pairs[0] = PAIR_OF(default_fg(NCURSES_SP_ARG),
-						       default_bg(NCURSES_SP_ARG));
-		    init_color_table(NCURSES_SP_ARG);
+		if (init_direct_colors(NCURSES_SP_ARG)) {
+		    result = OK;
+		} else {
+		    TYPE_CALLOC(color_t, maxcolors, SP_PARM->_color_table);
+		    if (SP_PARM->_color_table != 0) {
+			MakeColorPair(SP_PARM->_color_pairs[0],
+				      default_fg(NCURSES_SP_ARG),
+				      default_bg(NCURSES_SP_ARG));
+			init_color_table(NCURSES_SP_ARG);
 
+			result = OK;
+		    }
+		}
+		if (result == OK) {
 		    T(("started color: COLORS = %d, COLOR_PAIRS = %d",
 		       COLORS, COLOR_PAIRS));
 
 		    SP_PARM->_coloron = 1;
-		    result = OK;
 		} else if (SP_PARM->_color_pairs != 0) {
 		    FreeAndNull(SP_PARM->_color_pairs);
 		}
@@ -388,7 +446,7 @@
 
 /* This function was originally written by Daniel Weaver <danw@znyx.com> */
 static void
-rgb2hls(int r, int g, int b, NCURSES_COLOR_T *h, NCURSES_COLOR_T *l, NCURSES_COLOR_T *s)
+rgb2hls(int r, int g, int b, int *h, int *l, int *s)
 /* convert RGB to HLS system */
 {
     int min, max, t;
@@ -399,7 +457,7 @@
 	max = b;
 
     /* calculate lightness */
-    *l = (NCURSES_COLOR_T) ((min + max) / 20);
+    *l = ((min + max) / 20);
 
     if (min == max) {		/* black, white and all shades of gray */
 	*h = 0;
@@ -409,19 +467,88 @@
 
     /* calculate saturation */
     if (*l < 50)
-	*s = (NCURSES_COLOR_T) (((max - min) * 100) / (max + min));
+	*s = (((max - min) * 100) / (max + min));
     else
-	*s = (NCURSES_COLOR_T) (((max - min) * 100) / (2000 - max - min));
+	*s = (((max - min) * 100) / (2000 - max - min));
 
     /* calculate hue */
     if (r == max)
-	t = (NCURSES_COLOR_T) (120 + ((g - b) * 60) / (max - min));
+	t = (120 + ((g - b) * 60) / (max - min));
     else if (g == max)
-	t = (NCURSES_COLOR_T) (240 + ((b - r) * 60) / (max - min));
+	t = (240 + ((b - r) * 60) / (max - min));
     else
-	t = (NCURSES_COLOR_T) (360 + ((r - g) * 60) / (max - min));
+	t = (360 + ((r - g) * 60) / (max - min));
 
-    *h = (NCURSES_COLOR_T) (t % 360);
+    *h = (t % 360);
+}
+
+/*
+ * Change all cells which use(d) a given color pair to force a repaint.
+ */
+NCURSES_EXPORT(void)
+_nc_change_pair(SCREEN *sp, int pair)
+{
+    int y, x;
+
+    if (CurScreen(sp)->_clear)
+	return;
+#if NO_LEAKS
+    if (_nc_globals.leak_checking)
+	return;
+#endif
+
+    for (y = 0; y <= CurScreen(sp)->_maxy; y++) {
+	struct ldat *ptr = &(CurScreen(sp)->_line[y]);
+	bool changed = FALSE;
+	for (x = 0; x <= CurScreen(sp)->_maxx; x++) {
+	    if (GetPair(ptr->text[x]) == pair) {
+		/* Set the old cell to zero to ensure it will be
+		   updated on the next doupdate() */
+		SetChar(ptr->text[x], 0, 0);
+		CHANGED_CELL(ptr, x);
+		changed = TRUE;
+	    }
+	}
+	if (changed)
+	    NCURSES_SP_NAME(_nc_make_oldhash) (NCURSES_SP_ARGx y);
+    }
+}
+
+NCURSES_EXPORT(void)
+_nc_reserve_pairs(SCREEN *sp, int want)
+{
+    int have = sp->_pair_alloc;
+
+    if (have == 0)
+	have = 1;
+    while (have <= want)
+	have *= 2;
+    if (have > sp->_pair_limit)
+	have = sp->_pair_limit;
+
+    if (sp->_color_pairs == 0) {
+	TYPE_CALLOC(colorpair_t, have, sp->_color_pairs);
+    } else if (have > sp->_pair_alloc) {
+#if NCURSES_EXT_COLORS
+	colorpair_t *next;
+
+	if ((next = typeCalloc(colorpair_t, have)) == 0)
+	    _nc_err_abort(MSG_NO_MEMORY);
+	memcpy(next, sp->_color_pairs, (size_t) sp->_pair_alloc * sizeof(*next));
+	_nc_copy_pairs(sp, next, sp->_color_pairs, sp->_pair_alloc);
+	free(sp->_color_pairs);
+	sp->_color_pairs = next;
+#else
+	TYPE_REALLOC(colorpair_t, have, sp->_color_pairs);
+	if (sp->_color_pairs != 0) {
+	    memset(sp->_color_pairs + sp->_pair_alloc, 0,
+		   sizeof(colorpair_t) * (size_t) (have - sp->_pair_alloc));
+	}
+#endif
+    }
+    if (sp->_color_pairs != 0) {
+	sp->_pair_alloc = have;
+    }
 }
 
 /*
@@ -429,32 +556,27 @@
  * values.
  */
 NCURSES_EXPORT(int)
-NCURSES_SP_NAME(init_pair) (NCURSES_SP_DCLx
-			    NCURSES_PAIRS_T pair,
-			    NCURSES_COLOR_T f,
-			    NCURSES_COLOR_T b)
+_nc_init_pair(SCREEN *sp, int pair, int f, int b)
 {
-    colorpair_t result;
+    static colorpair_t null_pair;
+    colorpair_t result = null_pair;
     colorpair_t previous;
     int maxcolors;
 
-    T((T_CALLED("init_pair(%p,%d,%d,%d)"),
-       (void *) SP_PARM,
-       (int) pair,
-       (int) f,
-       (int) b));
+    T((T_CALLED("init_pair(%p,%d,%d,%d)"), (void *) sp, pair, f, b));
 
-    if (!ValidPair(pair))
+    if (!ValidPair(sp, pair))
 	returnCode(ERR);
 
     maxcolors = MaxColors;
 
-    previous = SP_PARM->_color_pairs[pair];
+    ReservePairs(sp, pair);
+    previous = sp->_color_pairs[pair];
 #if NCURSES_EXT_FUNCS
-    if (SP_PARM->_default_color || SP_PARM->_assumed_color) {
+    if (sp->_default_color || sp->_assumed_color) {
 	bool isDefault = FALSE;
 	bool wasDefault = FALSE;
-	int default_pairs = SP_PARM->_default_pairs;
+	int default_pairs = sp->_default_pairs;
 
 	/*
 	 * Map caller's color number, e.g., -1, 0, 1, .., 7, etc., into
@@ -479,8 +601,8 @@
 	 * Check if the table entry that we are going to init/update used
 	 * default colors.
 	 */
-	if ((FORE_OF(previous) == COLOR_DEFAULT)
-	    || (BACK_OF(previous) == COLOR_DEFAULT))
+	if (isDefaultColor(FORE_OF(previous))
+	    || isDefaultColor(BACK_OF(previous)))
 	    wasDefault = TRUE;
 
 	/*
@@ -501,10 +623,10 @@
 	 * that does not will decrement the count - and possibly interfere
 	 * with sequentially adding new pairs.
 	 */
-	if (pair > (SP_PARM->_pair_count + default_pairs)) {
+	if (pair > (sp->_pair_count + default_pairs)) {
 	    returnCode(ERR);
 	}
-	SP_PARM->_default_pairs = default_pairs;
+	sp->_default_pairs = default_pairs;
     } else
 #endif
     {
@@ -520,34 +642,22 @@
      * initialized before a screen update is performed replacing original
      * pair colors with the new ones).
      */
-    result = PAIR_OF(f, b);
-    if (previous != 0
-	&& previous != result) {
-	int y, x;
-
-	for (y = 0; y <= CurScreen(SP_PARM)->_maxy; y++) {
-	    struct ldat *ptr = &(CurScreen(SP_PARM)->_line[y]);
-	    bool changed = FALSE;
-	    for (x = 0; x <= CurScreen(SP_PARM)->_maxx; x++) {
-		if (GetPair(ptr->text[x]) == pair) {
-		    /* Set the old cell to zero to ensure it will be
-		       updated on the next doupdate() */
-		    SetChar(ptr->text[x], 0, 0);
-		    CHANGED_CELL(ptr, x);
-		    changed = TRUE;
-		}
-	    }
-	    if (changed)
-		NCURSES_SP_NAME(_nc_make_oldhash) (NCURSES_SP_ARGx y);
-	}
+    MakeColorPair(result, f, b);
+    if ((FORE_OF(previous) != 0
+	 || BACK_OF(previous) != 0)
+	&& !isSamePair(previous, result)) {
+	_nc_change_pair(sp, pair);
     }
 
-    SP_PARM->_color_pairs[pair] = result;
-    if (GET_SCREEN_PAIR(SP_PARM) == pair)
-	SET_SCREEN_PAIR(SP_PARM, (chtype) (~0));	/* force attribute update */
+    _nc_reset_color_pair(sp, pair, &result);
+    sp->_color_pairs[pair] = result;
+    _nc_set_color_pair(sp, pair, cpINIT);
+
+    if (GET_SCREEN_PAIR(sp) == pair)
+	SET_SCREEN_PAIR(sp, (int) (~0));	/* force attribute update */
 
 #ifdef USE_TERM_DRIVER
-    CallDriver_3(SP_PARM, td_initpair, pair, f, b);
+    CallDriver_3(sp, td_initpair, pair, f, b);
 #else
     if (initialize_pair && InPalette(f) && InPalette(b)) {
 	const color_t *tp = DefaultPalette;
@@ -559,20 +669,29 @@
 	    (int) tp[b].red, (int) tp[b].green, (int) tp[b].blue));
 
 	NCURSES_PUTP2("initialize_pair",
-		      TPARM_7(initialize_pair,
-			      pair,
-			      (int) tp[f].red,
-			      (int) tp[f].green,
-			      (int) tp[f].blue,
-			      (int) tp[b].red,
-			      (int) tp[b].green,
-			      (int) tp[b].blue));
+		      TIPARM_7(initialize_pair,
+			       pair,
+			       (int) tp[f].red,
+			       (int) tp[f].green,
+			       (int) tp[f].blue,
+			       (int) tp[b].red,
+			       (int) tp[b].green,
+			       (int) tp[b].blue));
     }
 #endif
 
     returnCode(OK);
 }
 
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(init_pair) (NCURSES_SP_DCLx
+			    NCURSES_PAIRS_T pair,
+			    NCURSES_COLOR_T f,
+			    NCURSES_COLOR_T b)
+{
+    return _nc_init_pair(SP_PARM, pair, f, b);
+}
+
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(int)
 init_pair(NCURSES_COLOR_T pair, NCURSES_COLOR_T f, NCURSES_COLOR_T b)
@@ -584,57 +703,63 @@
 #define okRGB(n) ((n) >= 0 && (n) <= 1000)
 
 NCURSES_EXPORT(int)
+_nc_init_color(SCREEN *sp, int color, int r, int g, int b)
+{
+    int result = ERR;
+    int maxcolors;
+
+    T((T_CALLED("init_color(%p,%d,%d,%d,%d)"),
+       (void *) sp,
+       color,
+       r, g, b));
+
+    if (sp == 0 || sp->_direct_color.value)
+	returnCode(result);
+
+    maxcolors = MaxColors;
+
+    if (InitColor
+	&& sp->_coloron
+	&& (color >= 0 && OkColorHi(color))
+	&& (okRGB(r) && okRGB(g) && okRGB(b))) {
+
+	sp->_color_table[color].init = 1;
+	sp->_color_table[color].r = r;
+	sp->_color_table[color].g = g;
+	sp->_color_table[color].b = b;
+
+	if (UseHlsPalette) {
+	    rgb2hls(r, g, b,
+		    &sp->_color_table[color].red,
+		    &sp->_color_table[color].green,
+		    &sp->_color_table[color].blue);
+	} else {
+	    sp->_color_table[color].red = r;
+	    sp->_color_table[color].green = g;
+	    sp->_color_table[color].blue = b;
+	}
+
+#ifdef USE_TERM_DRIVER
+	CallDriver_4(sp, td_initcolor, color, r, g, b);
+#else
+	NCURSES_PUTP2("initialize_color",
+		      TIPARM_4(initialize_color, color, r, g, b));
+#endif
+	sp->_color_defs = Max(color + 1, sp->_color_defs);
+
+	result = OK;
+    }
+    returnCode(result);
+}
+
+NCURSES_EXPORT(int)
 NCURSES_SP_NAME(init_color) (NCURSES_SP_DCLx
 			     NCURSES_COLOR_T color,
 			     NCURSES_COLOR_T r,
 			     NCURSES_COLOR_T g,
 			     NCURSES_COLOR_T b)
 {
-    int result = ERR;
-    int maxcolors;
-
-    T((T_CALLED("init_color(%p,%d,%d,%d,%d)"),
-       (void *) SP_PARM,
-       color,
-       r, g, b));
-
-    if (SP_PARM == 0)
-	returnCode(result);
-
-    maxcolors = MaxColors;
-
-    if (InitColor
-	&& SP_PARM->_coloron
-	&& (color >= 0 && OkColorHi(color))
-	&& (okRGB(r) && okRGB(g) && okRGB(b))) {
-
-	SP_PARM->_color_table[color].init = 1;
-	SP_PARM->_color_table[color].r = r;
-	SP_PARM->_color_table[color].g = g;
-	SP_PARM->_color_table[color].b = b;
-
-	if (UseHlsPalette) {
-	    rgb2hls(r, g, b,
-		    &SP_PARM->_color_table[color].red,
-		    &SP_PARM->_color_table[color].green,
-		    &SP_PARM->_color_table[color].blue);
-	} else {
-	    SP_PARM->_color_table[color].red = r;
-	    SP_PARM->_color_table[color].green = g;
-	    SP_PARM->_color_table[color].blue = b;
-	}
-
-#ifdef USE_TERM_DRIVER
-	CallDriver_4(SP_PARM, td_initcolor, color, r, g, b);
-#else
-	NCURSES_PUTP2("initialize_color",
-		      TPARM_4(initialize_color, color, r, g, b));
-#endif
-	SP_PARM->_color_defs = max(color + 1, SP_PARM->_color_defs);
-
-	result = OK;
-    }
-    returnCode(result);
+    return _nc_init_color(SP_PARM, color, r, g, b);
 }
 
 #if NCURSES_SP_FUNCS
@@ -676,7 +801,7 @@
     int code = FALSE;
 
     (void) SP_PARM;
-    T((T_CALLED("has_colors()")));
+    T((T_CALLED("has_colors(%p)"), (void *) SP_PARM));
     if (HasTerminal(SP_PARM)) {
 #ifdef USE_TERM_DRIVER
 	code = HasColor;
@@ -700,6 +825,73 @@
 }
 #endif
 
+static int
+_nc_color_content(SCREEN *sp, int color, int *r, int *g, int *b)
+{
+    int result = ERR;
+
+    T((T_CALLED("color_content(%p,%d,%p,%p,%p)"),
+       (void *) sp,
+       color,
+       (void *) r,
+       (void *) g,
+       (void *) b));
+
+    if (sp != 0) {
+	int maxcolors = MaxColors;
+
+	if (color >= 0 && OkColorHi(color) && sp->_coloron) {
+	    int c_r, c_g, c_b;
+
+	    if (sp->_direct_color.value) {
+		rgb_bits_t *work = &(sp->_direct_color);
+
+#define max_direct_color(name)	((1 << work->bits.name) - 1)
+#define value_direct_color(max) (1000 * ((color >> bitoff) & max)) / max
+
+		int max_r = max_direct_color(red);
+		int max_g = max_direct_color(green);
+		int max_b = max_direct_color(blue);
+
+		int bitoff = 0;
+
+		c_b = value_direct_color(max_b);
+		bitoff += work->bits.blue;
+
+		c_g = value_direct_color(max_g);
+		bitoff += work->bits.green;
+
+		c_r = value_direct_color(max_r);
+
+	    } else {
+		c_r = sp->_color_table[color].red;
+		c_g = sp->_color_table[color].green;
+		c_b = sp->_color_table[color].blue;
+	    }
+
+	    if (r)
+		*r = c_r;
+	    if (g)
+		*g = c_g;
+	    if (b)
+		*b = c_b;
+
+	    TR(TRACE_ATTRS, ("...color_content(%d,%d,%d,%d)",
+			     color, c_r, c_g, c_b));
+	    result = OK;
+	}
+    }
+    if (result != OK) {
+	if (r)
+	    *r = 0;
+	if (g)
+	    *g = 0;
+	if (b)
+	    *b = 0;
+    }
+    returnCode(result);
+}
+
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(color_content) (NCURSES_SP_DCLx
 				NCURSES_COLOR_T color,
@@ -707,40 +899,14 @@
 				NCURSES_COLOR_T *g,
 				NCURSES_COLOR_T *b)
 {
-    int result = ERR;
-    int maxcolors;
-
-    T((T_CALLED("color_content(%p,%d,%p,%p,%p)"),
-       (void *) SP_PARM,
-       color,
-       (void *) r,
-       (void *) g,
-       (void *) b));
-
-    if (SP_PARM == 0)
-	returnCode(result);
-
-    maxcolors = MaxColors;
-
-    if (color < 0 || !OkColorHi(color) || !SP_PARM->_coloron) {
-	result = ERR;
-    } else {
-	NCURSES_COLOR_T c_r = SP_PARM->_color_table[color].red;
-	NCURSES_COLOR_T c_g = SP_PARM->_color_table[color].green;
-	NCURSES_COLOR_T c_b = SP_PARM->_color_table[color].blue;
-
-	if (r)
-	    *r = c_r;
-	if (g)
-	    *g = c_g;
-	if (b)
-	    *b = c_b;
-
-	TR(TRACE_ATTRS, ("...color_content(%d,%d,%d,%d)",
-			 color, c_r, c_g, c_b));
-	result = OK;
+    int my_r, my_g, my_b;
+    int rc = _nc_color_content(SP_PARM, color, &my_r, &my_g, &my_b);
+    if (rc == OK) {
+	*r = limit_COLOR(my_r);
+	*g = limit_COLOR(my_g);
+	*b = limit_COLOR(my_b);
     }
-    returnCode(result);
+    return rc;
 }
 
 #if NCURSES_SP_FUNCS
@@ -755,29 +921,29 @@
 #endif
 
 NCURSES_EXPORT(int)
-NCURSES_SP_NAME(pair_content) (NCURSES_SP_DCLx
-			       NCURSES_PAIRS_T pair,
-			       NCURSES_COLOR_T *f,
-			       NCURSES_COLOR_T *b)
+_nc_pair_content(SCREEN *sp, int pair, int *f, int *b)
 {
     int result;
 
     T((T_CALLED("pair_content(%p,%d,%p,%p)"),
-       (void *) SP_PARM,
+       (void *) sp,
        (int) pair,
        (void *) f,
        (void *) b));
 
-    if (!ValidPair(pair)) {
+    if (!ValidPair(sp, pair)) {
 	result = ERR;
     } else {
-	NCURSES_COLOR_T fg = (NCURSES_COLOR_T) FORE_OF(SP_PARM->_color_pairs[pair]);
-	NCURSES_COLOR_T bg = (NCURSES_COLOR_T) BACK_OF(SP_PARM->_color_pairs[pair]);
+	int fg;
+	int bg;
 
+	ReservePairs(sp, pair);
+	fg = FORE_OF(sp->_color_pairs[pair]);
+	bg = BACK_OF(sp->_color_pairs[pair]);
 #if NCURSES_EXT_FUNCS
-	if (fg == COLOR_DEFAULT)
+	if (isDefaultColor(fg))
 	    fg = -1;
-	if (bg == COLOR_DEFAULT)
+	if (isDefaultColor(bg))
 	    bg = -1;
 #endif
 
@@ -787,7 +953,7 @@
 	    *b = bg;
 
 	TR(TRACE_ATTRS, ("...pair_content(%p,%d,%d,%d)",
-			 (void *) SP_PARM,
+			 (void *) sp,
 			 (int) pair,
 			 (int) fg, (int) bg));
 	result = OK;
@@ -795,6 +961,21 @@
     returnCode(result);
 }
 
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(pair_content) (NCURSES_SP_DCLx
+			       NCURSES_PAIRS_T pair,
+			       NCURSES_COLOR_T *f,
+			       NCURSES_COLOR_T *b)
+{
+    int my_f, my_b;
+    int rc = _nc_pair_content(SP_PARM, pair, &my_f, &my_b);
+    if (rc == OK) {
+	*f = limit_COLOR(my_f);
+	*b = limit_COLOR(my_b);
+    }
+    return rc;
+}
+
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(int)
 pair_content(NCURSES_COLOR_T pair, NCURSES_COLOR_T *f, NCURSES_COLOR_T *b)
@@ -813,29 +994,29 @@
 #ifdef USE_TERM_DRIVER
     CallDriver_4(SP_PARM, td_docolor, old_pair, pair, reverse, outc);
 #else
-    NCURSES_COLOR_T fg = COLOR_DEFAULT;
-    NCURSES_COLOR_T bg = COLOR_DEFAULT;
-    NCURSES_COLOR_T old_fg = -1;
-    NCURSES_COLOR_T old_bg = -1;
+    int fg = COLOR_DEFAULT;
+    int bg = COLOR_DEFAULT;
+    int old_fg = -1;
+    int old_bg = -1;
 
-    if (!ValidPair(pair)) {
+    if (!ValidPair(SP_PARM, pair)) {
 	return;
     } else if (pair != 0) {
 	if (set_color_pair) {
 	    TPUTS_TRACE("set_color_pair");
 	    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				    TPARM_1(set_color_pair, pair),
+				    TIPARM_1(set_color_pair, pair),
 				    1, outc);
 	    return;
 	} else if (SP_PARM != 0) {
-	    if (pair_content((NCURSES_COLOR_T) pair, &fg, &bg) == ERR)
+	    if (_nc_pair_content(SP_PARM, pair, &fg, &bg) == ERR)
 		return;
 	}
     }
 
     if (old_pair >= 0
 	&& SP_PARM != 0
-	&& pair_content((NCURSES_COLOR_T) old_pair, &old_fg, &old_bg) != ERR) {
+	&& _nc_pair_content(SP_PARM, old_pair, &old_fg, &old_bg) != ERR) {
 	if ((isDefaultColor(fg) && !isDefaultColor(old_fg))
 	    || (isDefaultColor(bg) && !isDefaultColor(old_bg))) {
 #if NCURSES_EXT_FUNCS
@@ -858,19 +1039,19 @@
 	}
     } else {
 	reset_color_pair(NCURSES_SP_ARG);
-	if (old_pair < 0)
+	if (old_pair < 0 && pair <= 0)
 	    return;
     }
 
 #if NCURSES_EXT_FUNCS
     if (isDefaultColor(fg))
-	fg = (NCURSES_COLOR_T) default_fg(NCURSES_SP_ARG);
+	fg = default_fg(NCURSES_SP_ARG);
     if (isDefaultColor(bg))
-	bg = (NCURSES_COLOR_T) default_bg(NCURSES_SP_ARG);
+	bg = default_bg(NCURSES_SP_ARG);
 #endif
 
     if (reverse) {
-	NCURSES_COLOR_T xx = fg;
+	int xx = fg;
 	fg = bg;
 	bg = xx;
     }
@@ -899,3 +1080,87 @@
 				   _nc_outc_wrapper);
 }
 #endif
+
+#if NCURSES_EXT_COLORS
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(init_extended_pair) (NCURSES_SP_DCLx int pair, int f, int b)
+{
+    return _nc_init_pair(SP_PARM, pair, f, b);
+}
+
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(init_extended_color) (NCURSES_SP_DCLx
+				      int color,
+				      int r, int g, int b)
+{
+    return _nc_init_color(SP_PARM, color, r, g, b);
+}
+
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(extended_color_content) (NCURSES_SP_DCLx
+					 int color,
+					 int *r, int *g, int *b)
+{
+    return _nc_color_content(SP_PARM, color, r, g, b);
+}
+
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(extended_pair_content) (NCURSES_SP_DCLx
+					int pair,
+					int *f, int *b)
+{
+    return _nc_pair_content(SP_PARM, pair, f, b);
+}
+
+NCURSES_EXPORT(void)
+NCURSES_SP_NAME(reset_color_pairs) (NCURSES_SP_DCL0)
+{
+    if (SP_PARM != 0) {
+	if (SP_PARM->_color_pairs) {
+	    _nc_free_ordered_pairs(SP_PARM);
+	    free(SP_PARM->_color_pairs);
+	    SP_PARM->_color_pairs = 0;
+	    SP_PARM->_pair_alloc = 0;
+	    ReservePairs(SP_PARM, 16);
+	    clearok(CurScreen(SP_PARM), TRUE);
+	    touchwin(StdScreen(SP_PARM));
+	}
+    }
+}
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+init_extended_pair(int pair, int f, int b)
+{
+    return NCURSES_SP_NAME(init_extended_pair) (CURRENT_SCREEN, pair, f, b);
+}
+
+NCURSES_EXPORT(int)
+init_extended_color(int color, int r, int g, int b)
+{
+    return NCURSES_SP_NAME(init_extended_color) (CURRENT_SCREEN,
+						 color,
+						 r, g, b);
+}
+
+NCURSES_EXPORT(int)
+extended_color_content(int color, int *r, int *g, int *b)
+{
+    return NCURSES_SP_NAME(extended_color_content) (CURRENT_SCREEN,
+						    color,
+						    r, g, b);
+}
+
+NCURSES_EXPORT(int)
+extended_pair_content(int pair, int *f, int *b)
+{
+    return NCURSES_SP_NAME(extended_pair_content) (CURRENT_SCREEN, pair, f, b);
+}
+
+NCURSES_EXPORT(void)
+reset_color_pairs(void)
+{
+    NCURSES_SP_NAME(reset_color_pairs) (CURRENT_SCREEN);
+}
+#endif /* NCURSES_SP_FUNCS */
+#endif /* NCURSES_EXT_COLORS */
diff --git a/ncurses/base/lib_colorset.c b/ncurses/base/lib_colorset.c
index e935486..387edef 100644
--- a/ncurses/base/lib_colorset.c
+++ b/ncurses/base/lib_colorset.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -41,22 +42,23 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_colorset.c,v 1.14 2014/02/01 22:10:42 tom Exp $")
+MODULE_ID("$Id: lib_colorset.c,v 1.16 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
-wcolor_set(WINDOW *win, NCURSES_PAIRS_T color_pair_number, void *opts)
+wcolor_set(WINDOW *win, NCURSES_PAIRS_T pair_arg, void *opts)
 {
     int code = ERR;
+    int color_pair = pair_arg;
 
-    T((T_CALLED("wcolor_set(%p,%d)"), (void *) win, (int) color_pair_number));
+    T((T_CALLED("wcolor_set(%p,%d)"), (void *) win, color_pair));
+    set_extended_pair(opts, color_pair);
     if (win
-	&& !opts
 	&& (SP != 0)
-	&& (color_pair_number >= 0)
-	&& (color_pair_number < SP->_pair_limit)) {
+	&& (color_pair >= 0)
+	&& (color_pair < SP->_pair_limit)) {
 	TR(TRACE_ATTRS, ("... current %ld", (long) GET_WINDOW_PAIR(win)));
-	SET_WINDOW_PAIR(win, color_pair_number);
-	if_EXT_COLORS(win->_color = color_pair_number);
+	SET_WINDOW_PAIR(win, color_pair);
+	if_EXT_COLORS(win->_color = color_pair);
 	code = OK;
     }
     returnCode(code);
diff --git a/ncurses/base/lib_delch.c b/ncurses/base/lib_delch.c
index 64c9da7..d39a8eb 100644
--- a/ncurses/base/lib_delch.c
+++ b/ncurses/base/lib_delch.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2001,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_delch.c,v 1.13 2009/10/24 22:32:47 tom Exp $")
+MODULE_ID("$Id: lib_delch.c,v 1.14 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 wdelch(WINDOW *win)
diff --git a/ncurses/base/lib_delwin.c b/ncurses/base/lib_delwin.c
index 4bb536c..c96e417 100644
--- a/ncurses/base/lib_delwin.c
+++ b/ncurses/base/lib_delwin.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2008,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,24 +43,29 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_delwin.c,v 1.20 2009/10/24 22:02:14 tom Exp $")
+MODULE_ID("$Id: lib_delwin.c,v 1.25 2023/10/21 11:12:44 tom Exp $")
 
 static bool
 cannot_delete(WINDOW *win)
 {
-    WINDOWLIST *p;
     bool result = TRUE;
-#ifdef USE_SP_WINDOWLIST
-    SCREEN *sp = _nc_screen_of(win);
+
+    if (IS_PAD(win)) {
+	result = FALSE;
+    } else {
+	WINDOWLIST *p;
+#if NCURSES_SP_FUNCS && defined(USE_SP_WINDOWLIST)
+	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;
@@ -76,15 +82,18 @@
 	if (win == 0
 	    || cannot_delete(win)) {
 	    result = ERR;
+	} else if (IS_PAD(win)) {
+	    win->_parent = NULL;
+	    result = _nc_freewin(win);
 	} 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);
diff --git a/ncurses/base/lib_dft_fgbg.c b/ncurses/base/lib_dft_fgbg.c
index 4d7fdd0..4dd43bb 100644
--- a/ncurses/base/lib_dft_fgbg.c
+++ b/ncurses/base/lib_dft_fgbg.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -37,7 +38,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_dft_fgbg.c,v 1.27 2014/03/08 20:32:59 tom Exp $")
+MODULE_ID("$Id: lib_dft_fgbg.c,v 1.31 2021/04/03 22:27:18 tom Exp $")
 
 /*
  * Modify the behavior of color-pair 0 so that the library doesn't assume that
@@ -68,26 +69,29 @@
     int code = ERR;
 
     T((T_CALLED("assume_default_colors(%p,%d,%d)"), (void *) SP_PARM, fg, bg));
+    if (SP_PARM != 0) {
 #ifdef USE_TERM_DRIVER
-    if (sp != 0)
-	code = CallDriver_2(sp, td_defaultcolors, fg, bg);
+	code = CallDriver_2(SP_PARM, td_defaultcolors, fg, bg);
 #else
-    if ((orig_pair || orig_colors) && !initialize_pair) {
+	if ((orig_pair || orig_colors) && !initialize_pair) {
 
-	SP_PARM->_default_color = isDefaultColor(fg) || isDefaultColor(bg);
-	SP_PARM->_has_sgr_39_49 = (tigetflag("AX") == TRUE);
-	SP_PARM->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : (fg & C_MASK);
-	SP_PARM->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : (bg & C_MASK);
-	if (SP_PARM->_color_pairs != 0) {
-	    bool save = SP_PARM->_default_color;
-	    SP_PARM->_assumed_color = TRUE;
-	    SP_PARM->_default_color = TRUE;
-	    init_pair(0, (short) fg, (short) bg);
-	    SP_PARM->_default_color = save;
+	    SP_PARM->_default_color = isDefaultColor(fg) || isDefaultColor(bg);
+	    SP_PARM->_has_sgr_39_49 = (tigetflag("AX") == TRUE);
+	    SP_PARM->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : fg;
+	    SP_PARM->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : bg;
+	    if (SP_PARM->_color_pairs != 0) {
+		bool save = SP_PARM->_default_color;
+		SP_PARM->_assumed_color = TRUE;
+		SP_PARM->_default_color = TRUE;
+		NCURSES_SP_NAME(init_pair) (NCURSES_SP_ARGx 0,
+					    (short)fg,
+					    (short)bg);
+		SP_PARM->_default_color = save;
+	    }
+	    code = OK;
 	}
-	code = OK;
-    }
 #endif
+    }
     returnCode(code);
 }
 
diff --git a/ncurses/base/lib_driver.c b/ncurses/base/lib_driver.c
index fb63b3c..c53802f 100644
--- a/ncurses/base/lib_driver.c
+++ b/ncurses/base/lib_driver.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2008-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2009-2012,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -33,8 +34,9 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_driver.c,v 1.6 2014/04/11 08:21:23 jpf Exp $")
+MODULE_ID("$Id: lib_driver.c,v 1.9 2020/08/29 19:53:35 tom Exp $")
 
+#ifndef EXP_WIN32_DRIVER
 typedef struct DriverEntry {
     const char *name;
     TERM_DRIVER *driver;
@@ -42,7 +44,7 @@
 
 static DRIVER_ENTRY DriverTable[] =
 {
-#ifdef __MINGW32__
+#ifdef _WIN32
     {"win32console", &_nc_WIN_DRIVER},
 #endif
     {"tinfo", &_nc_TINFO_DRIVER}	/* must be last */
@@ -76,6 +78,7 @@
     }
     returnCode(code);
 }
+#endif /* !EXP_WIN32_DRIVER */
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(has_key) (SCREEN *sp, int keycode)
diff --git a/ncurses/base/lib_echo.c b/ncurses/base/lib_echo.c
index 9e1d3c2..de7832f 100644
--- a/ncurses/base/lib_echo.c
+++ b/ncurses/base/lib_echo.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 1998-2000,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -44,7 +45,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_echo.c,v 1.8 2009/10/24 22:02:14 tom Exp $")
+MODULE_ID("$Id: lib_echo.c,v 1.10 2023/04/29 18:57:12 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(echo) (NCURSES_SP_DCL0)
@@ -52,7 +53,7 @@
     T((T_CALLED("echo(%p)"), (void *) SP_PARM));
     if (0 == SP_PARM)
 	returnCode(ERR);
-    SP_PARM->_echo = TRUE;
+    IsEcho(SP_PARM) = TRUE;
     returnCode(OK);
 }
 
@@ -70,7 +71,7 @@
     T((T_CALLED("noecho(%p)"), (void *) SP_PARM));
     if (0 == SP_PARM)
 	returnCode(ERR);
-    SP_PARM->_echo = FALSE;
+    IsEcho(SP_PARM) = FALSE;
     returnCode(OK);
 }
 
diff --git a/ncurses/base/lib_endwin.c b/ncurses/base/lib_endwin.c
index 9ebf769..85d2bdb 100644
--- a/ncurses/base/lib_endwin.c
+++ b/ncurses/base/lib_endwin.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_endwin.c,v 1.23 2014/03/08 20:32:59 tom Exp $")
+MODULE_ID("$Id: lib_endwin.c,v 1.28 2023/11/11 21:27:32 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(endwin) (NCURSES_SP_DCL0)
@@ -51,20 +52,24 @@
 
     T((T_CALLED("endwin(%p)"), (void *) SP_PARM));
 
-    if (SP_PARM) {
+    if (SP_PARM != NULL) {
+	if (SP_PARM->_endwin != ewSuspend) {
 #ifdef USE_TERM_DRIVER
-	TERMINAL_CONTROL_BLOCK *TCB = TCBOf(SP_PARM);
+	    TERMINAL_CONTROL_BLOCK *TCB = TCBOf(SP_PARM);
 
-	SP_PARM->_endwin = TRUE;
-	if (TCB && TCB->drv && TCB->drv->td_scexit)
-	    TCB->drv->td_scexit(SP_PARM);
+	    SP_PARM->_endwin = ewSuspend;
+	    if (TCB && TCB->drv && TCB->drv->td_scexit)
+		TCB->drv->td_scexit(SP_PARM);
 #else
-	SP_PARM->_endwin = TRUE;
-	SP_PARM->_mouse_wrap(SP_PARM);
-	_nc_screen_wrap();
-	_nc_mvcur_wrap();	/* wrap up cursor addressing */
+	    SP_PARM->_endwin = ewSuspend;
+	    SP_PARM->_mouse_wrap(SP_PARM);
+	    _nc_screen_wrap();
+	    _nc_mvcur_wrap();	/* wrap up cursor addressing */
 #endif
-	code = NCURSES_SP_NAME(reset_shell_mode) (NCURSES_SP_ARG);
+	    code = OK;
+	}
+	if (NCURSES_SP_NAME(reset_shell_mode) (NCURSES_SP_ARG) == ERR)
+	    code = ERR;
     }
 
     returnCode(code);
diff --git a/ncurses/base/lib_erase.c b/ncurses/base/lib_erase.c
index bbf10ef..aa9437a 100644
--- a/ncurses/base/lib_erase.c
+++ b/ncurses/base/lib_erase.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2005,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 1998-2009,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -41,21 +42,25 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_erase.c,v 1.17 2009/10/24 22:32:29 tom Exp $")
+MODULE_ID("$Id: lib_erase.c,v 1.20 2022/09/03 21:40:27 tom Exp $")
 
 NCURSES_EXPORT(int)
 werase(WINDOW *win)
 {
     int code = ERR;
-    int y;
-    NCURSES_CH_T blank;
-    NCURSES_CH_T *sp, *end, *start;
+    NCURSES_CH_T *start;
 
     T((T_CALLED("werase(%p)"), (void *) win));
 
     if (win) {
+	NCURSES_CH_T blank;
+	NCURSES_CH_T *sp;
+	int y;
+
 	blank = win->_nc_bkgd;
 	for (y = 0; y <= win->_maxy; y++) {
+	    NCURSES_CH_T *end;
+
 	    start = win->_line[y].text;
 	    end = &start[win->_maxx];
 
diff --git a/ncurses/base/lib_flash.c b/ncurses/base/lib_flash.c
index 7f25038..975d5f5 100644
--- a/ncurses/base/lib_flash.c
+++ b/ncurses/base/lib_flash.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2013,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -46,7 +47,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_flash.c,v 1.14 2014/03/08 20:32:59 tom Exp $")
+MODULE_ID("$Id: lib_flash.c,v 1.15 2020/02/02 23:34:34 tom Exp $")
 
 /*
  *	flash()
diff --git a/ncurses/base/lib_freeall.c b/ncurses/base/lib_freeall.c
index 3936c92..75bbe77 100644
--- a/ncurses/base/lib_freeall.c
+++ b/ncurses/base/lib_freeall.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-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  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
 extern int malloc_errfd;	/* FIXME */
 #endif
 
-MODULE_ID("$Id: lib_freeall.c,v 1.63 2015/05/02 23:46:26 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
@@ -48,11 +49,11 @@
 NCURSES_EXPORT(void)
 NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0)
 {
-    WINDOWLIST *p, *q;
     static va_list empty_va;
 
     T((T_CALLED("_nc_freeall()")));
 #if NO_LEAKS
+    _nc_globals.leak_checking = TRUE;
     if (SP_PARM != 0) {
 	if (SP_PARM->_oldnum_list != 0) {
 	    FreeAndNull(SP_PARM->_oldnum_list);
@@ -60,12 +61,16 @@
 	if (SP_PARM->_panelHook.destroy != 0) {
 	    SP_PARM->_panelHook.destroy(SP_PARM->_panelHook.stdscr_pseudo_panel);
 	}
+#if NCURSES_EXT_COLORS
+	_nc_new_pair_leaks(SP_PARM);
+#endif
     }
 #endif
     if (SP_PARM != 0) {
 	_nc_lock_global(curses);
 
 	while (WindowList(SP_PARM) != 0) {
+	    WINDOWLIST *p, *q;
 	    bool deleted = FALSE;
 
 	    /* Delete only windows that're not a parent */
@@ -73,10 +78,24 @@
 		WINDOW *p_win = &(p->win);
 		bool found = FALSE;
 
+		if (IS_PAD(p_win))
+		    continue;
+
+#ifndef USE_SP_WINDOWLIST
+		if (p->screen != SP_PARM)
+		    continue;
+#endif
+
 		for (each_window(SP_PARM, q)) {
 		    WINDOW *q_win = &(q->win);
+
+#ifndef USE_SP_WINDOWLIST
+		    if (q->screen != SP_PARM)
+			continue;
+#endif
+
 		    if ((p != q)
-			&& (q_win->_flags & _SUBWIN)
+			&& IS_SUBWIN(q_win)
 			&& (p_win == q_win->_parent)) {
 			found = TRUE;
 			break;
@@ -131,10 +150,11 @@
 NCURSES_EXPORT(void)
 NCURSES_SP_NAME(_nc_free_and_exit) (NCURSES_SP_DCLx int code)
 {
+    T((T_CALLED("_nc_free_and_exit(%d)"), code));
     NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
     NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_ARG);
 #ifdef TRACE
-    trace(0);			/* close trace file, freeing its setbuf */
+    curses_trace(0);		/* close trace file, freeing its setbuf */
     {
 	static va_list fake;
 	free(_nc_varargs("?", fake));
@@ -143,7 +163,7 @@
     exit(code);
 }
 
-#else
+#else /* !HAVE_NC_FREEALL */
 NCURSES_EXPORT(void)
 _nc_freeall(void)
 {
@@ -154,12 +174,10 @@
 {
     if (SP_PARM) {
 	delscreen(SP_PARM);
-	if (SP_PARM->_term)
-	    NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx SP_PARM->_term);
     }
     exit(code);
 }
-#endif
+#endif /* HAVE_NC_FREEALL */
 
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(void)
@@ -168,3 +186,16 @@
     NCURSES_SP_NAME(_nc_free_and_exit) (CURRENT_SCREEN, code);
 }
 #endif
+
+NCURSES_EXPORT(void)
+exit_curses(int code)
+{
+#if NO_LEAKS
+#if NCURSES_SP_FUNCS
+    NCURSES_SP_NAME(_nc_free_and_exit) (CURRENT_SCREEN, code);
+#else
+    _nc_free_and_exit(code);	/* deprecated... */
+#endif
+#endif
+    exit(code);
+}
diff --git a/ncurses/base/lib_getch.c b/ncurses/base/lib_getch.c
index 42eb9cc..8e47679 100644
--- a/ncurses/base/lib_getch.c
+++ b/ncurses/base/lib_getch.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,9 +41,10 @@
 **
 */
 
+#define NEED_KEY_EVENT
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getch.c,v 1.132 2015/05/09 17:10:41 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.146 2023/04/29 18:57:12 tom Exp $")
 
 #include <fifo_defs.h>
 
@@ -69,16 +71,20 @@
 NCURSES_SP_NAME(set_escdelay) (NCURSES_SP_DCLx int value)
 {
     int code = OK;
-#if USE_REENTRANT
-    if (SP_PARM) {
-	SET_ESCDELAY(value);
-    } else {
+    if (value < 0) {
 	code = ERR;
-    }
+    } else {
+#if USE_REENTRANT
+	if (SP_PARM) {
+	    SET_ESCDELAY(value);
+	} else {
+	    code = ERR;
+	}
 #else
-    (void) SP_PARM;
-    ESCDELAY = value;
+	(void) SP_PARM;
+	ESCDELAY = value;
 #endif
+    }
     return code;
 }
 
@@ -87,12 +93,16 @@
 set_escdelay(int value)
 {
     int code;
+    if (value < 0) {
+	code = ERR;
+    } else {
 #if USE_REENTRANT
-    code = NCURSES_SP_NAME(set_escdelay) (CURRENT_SCREEN, value);
+	code = NCURSES_SP_NAME(set_escdelay) (CURRENT_SCREEN, value);
 #else
-    ESCDELAY = value;
-    code = OK;
+	ESCDELAY = value;
+	code = OK;
 #endif
+    }
     return code;
 }
 #endif
@@ -125,7 +135,7 @@
 }
 
 #ifdef USE_TERM_DRIVER
-# ifdef __MINGW32__
+# if defined(_NC_WINDOWS) && !defined(EXP_WIN32_DRIVER)
 static HANDLE
 _nc_get_handle(int fd)
 {
@@ -146,7 +156,14 @@
 #ifdef USE_TERM_DRIVER
     TERMINAL_CONTROL_BLOCK *TCB = TCBOf(sp);
     rc = TCBOf(sp)->drv->td_testmouse(TCBOf(sp), delay EVENTLIST_2nd(evl));
-# ifdef __MINGW32__
+# if defined(EXP_WIN32_DRIVER)
+    /* if we emulate terminfo on console, we have to use the console routine */
+    if (IsTermInfoOnConsole(sp)) {
+	rc = _nc_console_testmouse(sp,
+				   _nc_console_handle(sp->_ifd),
+				   delay EVENTLIST_2nd(evl));
+    } else
+# elif defined(_NC_WINDOWS)
     /* if we emulate terminfo on console, we have to use the console routine */
     if (IsTermInfoOnConsole(sp)) {
 	HANDLE fd = _nc_get_handle(sp->_ifd);
@@ -154,29 +171,36 @@
     } else
 # endif
 	rc = TCB->drv->td_testmouse(TCB, delay EVENTLIST_2nd(evl));
-#else
-#if USE_SYSMOUSE
+#else /* !USE_TERM_DRIVER */
+# if USE_SYSMOUSE
     if ((sp->_mouse_type == M_SYSMOUSE)
 	&& (sp->_sysmouse_head < sp->_sysmouse_tail)) {
 	rc = TW_MOUSE;
     } else
-#endif
+# endif
     {
+# if defined(EXP_WIN32_DRIVER)
+	rc = _nc_console_testmouse(sp,
+				   _nc_console_handle(sp->_ifd),
+				   delay
+				   EVENTLIST_2nd(evl));
+# else
 	rc = _nc_timed_wait(sp,
 			    TWAIT_MASK,
 			    delay,
 			    (int *) 0
 			    EVENTLIST_2nd(evl));
-#if USE_SYSMOUSE
+# endif
+# if USE_SYSMOUSE
 	if ((sp->_mouse_type == M_SYSMOUSE)
 	    && (sp->_sysmouse_head < sp->_sysmouse_tail)
 	    && (rc == 0)
 	    && (errno == EINTR)) {
 	    rc |= TW_MOUSE;
 	}
-#endif
+# endif
     }
-#endif
+#endif /* USE_TERM_DRIVER */
     return rc;
 }
 
@@ -224,11 +248,6 @@
     if (tail < 0)
 	return ERR;
 
-#ifdef HIDE_EINTR
-  again:
-    errno = 0;
-#endif
-
 #ifdef NCURSES_WGETCH_EVENTS
     if (evl
 #if USE_GPM_SUPPORT || USE_EMX_MOUSE || USE_SYSMOUSE
@@ -279,57 +298,51 @@
     } else
 #endif
 #if USE_KLIBC_KBD
-    if (NC_ISATTY(sp->_ifd) && sp->_cbreak) {
-	ch = _read_kbd(0, 1, !sp->_raw);
+    if (NC_ISATTY(sp->_ifd) && IsCbreak(sp)) {
+	ch = _read_kbd(0, 1, !IsRaw(sp));
 	n = (ch == -1) ? -1 : 1;
 	sp->_extended_key = (ch == 0);
     } else
 #endif
     {				/* Can block... */
-#ifdef USE_TERM_DRIVER
+#if defined(USE_TERM_DRIVER)
 	int buf;
-#ifdef __MINGW32__
-	if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && sp->_cbreak)
+# if defined(EXP_WIN32_DRIVER)
+	if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && IsCbreak(sp)) {
+	    _nc_set_read_thread(TRUE);
+	    n = _nc_console_read(sp,
+				 _nc_console_handle(sp->_ifd),
+				 &buf);
+	    _nc_set_read_thread(FALSE);
+	} else
+# elif defined(_NC_WINDOWS)
+	if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && IsCbreak(sp))
 	    n = _nc_mingw_console_read(sp,
 				       _nc_get_handle(sp->_ifd),
 				       &buf);
 	else
-#endif
+# endif	/* EXP_WIN32_DRIVER */
 	    n = CallDriver_1(sp, td_read, &buf);
 	ch = buf;
-#else
+#else /* !USE_TERM_DRIVER */
+#if defined(EXP_WIN32_DRIVER)
+	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
-	n = (int) read(sp->_ifd, &c2, (size_t) 1);
-#if USE_PTHREADS_EINTR
-	_nc_globals.read_thread = 0;
-#endif
-	ch = c2;
-#endif
-    }
 
-#ifdef HIDE_EINTR
-    /*
-     * Under System V curses with non-restarting signals, getch() returns
-     * with value ERR when a handled signal keeps it from completing.
-     * If signals restart system calls, OTOH, the signal is invisible
-     * except to its handler.
-     *
-     * We don't want this difference to show.  This piece of code
-     * tries to make it look like we always have restarting signals.
-     */
-    if (n <= 0 && errno == EINTR
-# if USE_PTHREADS_EINTR
-	&& (_nc_globals.have_sigwinch == 0)
-# endif
-	)
-	goto again;
+	_nc_set_read_thread(TRUE);
+#if defined(EXP_WIN32_DRIVER)
+	n = _nc_console_read(sp,
+			     _nc_console_handle(sp->_ifd),
+			     &buf);
+	c2 = buf;
+#else
+	n = (int) read(sp->_ifd, &c2, (size_t) 1);
 #endif
+	_nc_set_read_thread(FALSE);
+	ch = c2;
+#endif /* USE_TERM_DRIVER */
+    }
 
     if ((n == -1) || (n == 0)) {
 	TR(TRACE_IEVENT, ("read(%d,&ch,1)=%d, errno=%d", sp->_ifd, n, errno));
@@ -360,14 +373,24 @@
     tail = peek = 0;
 }
 
-static int kgetch(SCREEN *EVENTLIST_2nd(_nc_eventlist * evl));
+static int kgetch(SCREEN *, bool EVENTLIST_2nd(_nc_eventlist *));
 
 static void
 recur_wrefresh(WINDOW *win)
 {
 #ifdef USE_PTHREADS
     SCREEN *sp = _nc_screen_of(win);
-    if (_nc_use_pthreads && sp != CURRENT_SCREEN) {
+    bool same_sp;
+
+    if (_nc_use_pthreads) {
+	_nc_lock_global(curses);
+	same_sp = (sp == CURRENT_SCREEN);
+	_nc_unlock_global(curses);
+    } else {
+	same_sp = (sp == CURRENT_SCREEN);
+    }
+
+    if (_nc_use_pthreads && !same_sp) {
 	SCREEN *save_SP;
 
 	/* temporarily switch to the window's screen to check/refresh */
@@ -380,7 +403,7 @@
     } else
 #endif
 	if ((is_wintouched(win) || (win->_flags & _HASMOVED))
-	    && !(win->_flags & _ISPAD)) {
+	    && !IS_PAD(win)) {
 	wrefresh(win);
     }
 }
@@ -456,8 +479,8 @@
      */
     if (head == -1 &&
 	!sp->_notty &&
-	!sp->_raw &&
-	!sp->_cbreak &&
+	!IsRaw(sp) &&
+	!IsCbreak(sp) &&
 	!sp->_called_wgetch) {
 	char buf[MAXCOLUMNS], *bufp;
 
@@ -490,13 +513,13 @@
 
     recur_wrefresh(win);
 
-    if (win->_notimeout || (win->_delay >= 0) || (sp->_cbreak > 1)) {
+    if (win->_notimeout || (win->_delay >= 0) || (IsCbreak(sp) > 1)) {
 	if (head == -1) {	/* fifo is empty */
 	    int delay;
 
 	    TR(TRACE_IEVENT, ("timed delay in wgetch()"));
-	    if (sp->_cbreak > 1)
-		delay = (sp->_cbreak - 1) * 100;
+	    if (IsCbreak(sp) > 1)
+		delay = (IsCbreak(sp) - 1) * 100;
 	    else
 		delay = win->_delay;
 
@@ -527,7 +550,7 @@
 	 * This is tricky.  We only want to get special-key
 	 * events one at a time.  But we want to accumulate
 	 * mouse events until either (a) the mouse logic tells
-	 * us it's picked up a complete gesture, or (b)
+	 * us it has picked up a complete gesture, or (b)
 	 * there's a detectable time lapse after one.
 	 *
 	 * Note: if the mouse code starts failing to compose
@@ -537,7 +560,7 @@
 	int runcount = 0;
 
 	do {
-	    ch = kgetch(sp EVENTLIST_2nd(evl));
+	    ch = kgetch(sp, win->_notimeout EVENTLIST_2nd(evl));
 	    if (ch == KEY_MOUSE) {
 		++runcount;
 		if (sp->_mouse_inline(sp))
@@ -615,7 +638,7 @@
      * However, we provide the same visual result as Solaris, moving the
      * cursor to the left.
      */
-    if (sp->_echo && !(win->_flags & _ISPAD)) {
+    if (IsEcho(sp) && !IS_PAD(win)) {
 	chtype backup = (chtype) ((ch == KEY_BACKSPACE) ? '\b' : ch);
 	if (backup < KEY_MIN)
 	    wechochar(win, backup);
@@ -624,7 +647,7 @@
     /*
      * Simulate ICRNL mode
      */
-    if ((ch == '\r') && sp->_nl)
+    if ((ch == '\r') && IsNl(sp))
 	ch = '\n';
 
     /* Strip 8th-bit if so desired.  We do this only for characters that
@@ -649,7 +672,7 @@
     int code;
     int value;
 
-    T((T_CALLED("wgetch_events(%p,%p)"), win, evl));
+    T((T_CALLED("wgetch_events(%p,%p)"), (void *) win, (void *) evl));
     code = _nc_wgetch(win,
 		      &value,
 		      _nc_use_meta(win)
@@ -692,11 +715,11 @@
 */
 
 static int
-kgetch(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
+kgetch(SCREEN *sp, bool forever EVENTLIST_2nd(_nc_eventlist * evl))
 {
     TRIES *ptr;
     int ch = 0;
-    int timeleft = GetEscdelay(sp);
+    int timeleft = forever ? 9999999 : GetEscdelay(sp);
 
     TR(TRACE_IEVENT, ("kgetch() called"));
 
diff --git a/ncurses/base/lib_getstr.c b/ncurses/base/lib_getstr.c
index 0e44634..cac21fc 100644
--- a/ncurses/base/lib_getstr.c
+++ b/ncurses/base/lib_getstr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2011 Free Software Foundation, Inc.              *
+ * Copyright 2018-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2011,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -38,9 +39,10 @@
 **
 */
 
+#define NEED_KEY_EVENT
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getstr.c,v 1.30 2011/10/22 16:31:35 tom Exp $")
+MODULE_ID("$Id: lib_getstr.c,v 1.39 2023/04/29 19:00:17 tom Exp $")
 
 /*
  * This wipes out the last character, no matter whether it was a tab, control
@@ -76,7 +78,7 @@
 {
     SCREEN *sp = _nc_screen_of(win);
     TTY buf;
-    bool oldnl, oldecho, oldraw, oldcbreak;
+    TTY_FLAGS save_flags;
     char erasec;
     char killc;
     char *oldstr;
@@ -85,19 +87,18 @@
 
     T((T_CALLED("wgetnstr(%p,%p,%d)"), (void *) win, (void *) str, maxlen));
 
-    if (!win)
+    if (!win || !str)
 	returnCode(ERR);
 
+    maxlen = _nc_getstr_limit(maxlen);
+
     NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_ARGx &buf);
 
-    oldnl = sp->_nl;
-    oldecho = sp->_echo;
-    oldraw = sp->_raw;
-    oldcbreak = sp->_cbreak;
+    save_flags = sp->_tty_flags;
     NCURSES_SP_NAME(nl) (NCURSES_SP_ARG);
     NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG);
-    NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG);
-    NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG);
+    if (!save_flags._raw)
+	NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG);
 
     erasec = NCURSES_SP_NAME(erasechar) (NCURSES_SP_ARG);
     killc = NCURSES_SP_NAME(killchar) (NCURSES_SP_ARG);
@@ -111,7 +112,7 @@
     while ((ch = wgetch_events(win, evl)) != ERR) {
 	/*
 	 * Some terminals (the Wyse-50 is the most common) generate
-	 * a \n from the down-arrow key.  With this logic, it's the
+	 * a \n from the down-arrow key.  With this logic, it is the
 	 * user's choice whether to set kcud=\n for wgetch();
 	 * terminating *getstr() with \n should work either way.
 	 */
@@ -119,7 +120,7 @@
 	    || ch == '\r'
 	    || ch == KEY_DOWN
 	    || ch == KEY_ENTER) {
-	    if (oldecho == TRUE
+	    if (save_flags._echo == TRUE
 		&& win->_cury == win->_maxy
 		&& win->_scroll)
 		wechochar(win, (chtype) '\n');
@@ -135,18 +136,18 @@
 #endif
 	if (ch == erasec || ch == KEY_LEFT || ch == KEY_BACKSPACE) {
 	    if (str > oldstr) {
-		str = WipeOut(win, y, x, oldstr, str, oldecho);
+		str = WipeOut(win, y, x, oldstr, str, save_flags._echo);
 	    }
 	} else if (ch == killc) {
 	    while (str > oldstr) {
-		str = WipeOut(win, y, x, oldstr, str, oldecho);
+		str = WipeOut(win, y, x, oldstr, str, save_flags._echo);
 	    }
 	} else if (ch >= KEY_MIN
-		   || (maxlen >= 0 && str - oldstr >= maxlen)) {
+		   || (str - oldstr >= maxlen)) {
 	    NCURSES_SP_NAME(beep) (NCURSES_SP_ARG);
 	} else {
 	    *str++ = (char) ch;
-	    if (oldecho == TRUE) {
+	    if (save_flags._echo == TRUE) {
 		int oldy = win->_cury;
 		if (waddch(win, (chtype) ch) == ERR) {
 		    /*
@@ -156,9 +157,9 @@
 		     */
 		    win->_flags &= ~_WRAPPED;
 		    waddch(win, (chtype) ' ');
-		    str = WipeOut(win, y, x, oldstr, str, oldecho);
+		    str = WipeOut(win, y, x, oldstr, str, save_flags._echo);
 		    continue;
-		} else if (win->_flags & _WRAPPED) {
+		} else if (IS_WRAPPED(win)) {
 		    /*
 		     * If the last waddch forced a wrap &
 		     * scroll, adjust our reference point
@@ -187,11 +188,7 @@
     /* Restore with a single I/O call, to fix minor asymmetry between
      * raw/noraw, etc.
      */
-    sp->_nl = oldnl;
-    sp->_echo = oldecho;
-    sp->_raw = oldraw;
-    sp->_cbreak = oldcbreak;
-
+    sp->_tty_flags = save_flags;
     NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
 
     *str = '\0';
diff --git a/ncurses/base/lib_hline.c b/ncurses/base/lib_hline.c
index 1f03808..938c499 100644
--- a/ncurses/base/lib_hline.c
+++ b/ncurses/base/lib_hline.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -29,6 +30,8 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1996-on                 *
+ *     and: Sven Verdoolaege                        2001                    *
  ****************************************************************************/
 
 /*
@@ -40,23 +43,21 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_hline.c,v 1.13 2010/12/19 01:48:39 tom Exp $")
+MODULE_ID("$Id: lib_hline.c,v 1.16 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 whline(WINDOW *win, chtype ch, int n)
 {
     int code = ERR;
-    int start;
-    int end;
 
     T((T_CALLED("whline(%p,%s,%d)"), (void *) win, _tracechtype(ch), n));
 
     if (win) {
 	struct ldat *line = &(win->_line[win->_cury]);
 	NCURSES_CH_T wch;
+	int start = win->_curx;
+	int end = start + n - 1;
 
-	start = win->_curx;
-	end = start + n - 1;
 	if (end > win->_maxx)
 	    end = win->_maxx;
 
@@ -68,6 +69,14 @@
 	    SetChar2(wch, ch);
 	wch = _nc_render(win, wch);
 
+#if USE_WIDEC_SUPPORT
+	if (start > 0 && isWidecExt(line->text[start])) {
+	    SetChar2(line->text[start - 1], ' ');
+	}
+	if (end < win->_maxx && isWidecExt(line->text[end + 1])) {
+	    SetChar2(line->text[end + 1], ' ');
+	}
+#endif
 	while (end >= start) {
 	    line->text[end] = wch;
 	    end--;
diff --git a/ncurses/base/lib_immedok.c b/ncurses/base/lib_immedok.c
index d51b60a..23afe5b 100644
--- a/ncurses/base/lib_immedok.c
+++ b/ncurses/base/lib_immedok.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2000,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_immedok.c,v 1.5 2009/10/24 22:32:11 tom Exp $")
+MODULE_ID("$Id: lib_immedok.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(void)
 immedok(WINDOW *win, bool flag)
diff --git a/ncurses/base/lib_inchstr.c b/ncurses/base/lib_inchstr.c
index aebb6d6..38af239 100644
--- a/ncurses/base/lib_inchstr.c
+++ b/ncurses/base/lib_inchstr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -41,7 +42,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_inchstr.c,v 1.12 2010/12/20 01:37:41 tom Exp $")
+MODULE_ID("$Id: lib_inchstr.c,v 1.17 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 winchnstr(WINDOW *win, chtype *str, int n)
@@ -50,16 +51,19 @@
 
     T((T_CALLED("winchnstr(%p,%p,%d)"), (void *) win, (void *) str, n));
 
-    if (!str)
-	returnCode(0);
+    if (!win || !str) {
+	i = ERR;
+    } else {
+	int row = win->_cury;
+	int col = win->_curx;
+	NCURSES_CH_T *text = win->_line[row].text;
 
-    if (win) {
-	for (; (n < 0 || (i < n)) && (win->_curx + i <= win->_maxx); i++)
-	    str[i] =
-		(chtype) CharOf(win->_line[win->_cury].text[win->_curx + i]) |
-		AttrOf(win->_line[win->_cury].text[win->_curx + i]);
+	for (; (n < 0 || (i < n)) && (col + i <= win->_maxx); i++) {
+	    str[i] = (((chtype) CharOf(text[col + i]) & A_CHARTEXT) |
+		      AttrOf(text[col + i]));
+	}
+	str[i] = (chtype) 0;
     }
-    str[i] = (chtype) 0;
 
     returnCode(i);
 }
diff --git a/ncurses/base/lib_initscr.c b/ncurses/base/lib_initscr.c
index 0e8a297..6b91491 100644
--- a/ncurses/base/lib_initscr.c
+++ b/ncurses/base/lib_initscr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -29,7 +30,7 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
- *     and: Thomas E. Dickey                        1996-2003               *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
 /*
@@ -45,15 +46,13 @@
 #include <sys/termio.h>		/* needed for ISC */
 #endif
 
-MODULE_ID("$Id: lib_initscr.c,v 1.40 2014/04/26 18:47:51 juergen Exp $")
+MODULE_ID("$Id: lib_initscr.c,v 1.48 2020/09/07 14:26:48 tom Exp $")
 
 NCURSES_EXPORT(WINDOW *)
 initscr(void)
 {
     WINDOW *result;
 
-    NCURSES_CONST char *name;
-
     START_TRACE();
     T((T_CALLED("initscr()")));
 
@@ -62,11 +61,18 @@
 
     /* Portable applications must not call initscr() more than once */
     if (!_nc_globals.init_screen) {
+	const char *env;
+	char *name;
+
 	_nc_globals.init_screen = TRUE;
 
-	if ((name = getenv("TERM")) == 0
-	    || *name == '\0')
-	    name = "unknown";
+	env = getenv("TERM");
+	(void) VALID_TERM_ENV(env, "unknown");
+
+	if ((name = strdup(env)) == NULL) {
+	    fprintf(stderr, "Error opening allocating $TERM.\n");
+	    ExitProgram(EXIT_FAILURE);
+	}
 #ifdef __CYGWIN__
 	/*
 	 * 2002/9/21
@@ -86,7 +92,7 @@
 #endif
 	if (newterm(name, stdout, stdin) == 0) {
 	    fprintf(stderr, "Error opening terminal: %s.\n", name);
-	    exit(EXIT_FAILURE);
+	    ExitProgram(EXIT_FAILURE);
 	}
 
 	/* def_shell_mode - done in newterm/_nc_setupscreen */
@@ -95,6 +101,7 @@
 #else
 	def_prog_mode();
 #endif
+	free(name);
     }
     result = stdscr;
     _nc_unlock_global(curses);
diff --git a/ncurses/base/lib_insch.c b/ncurses/base/lib_insch.c
index 32eaed7..894605c 100644
--- a/ncurses/base/lib_insch.c
+++ b/ncurses/base/lib_insch.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2013,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -43,7 +44,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_insch.c,v 1.35 2013/05/18 21:58:56 tom Exp $")
+MODULE_ID("$Id: lib_insch.c,v 1.37 2020/02/02 23:34:34 tom Exp $")
 
 /*
  * Insert the given character, updating the current location to simplify
@@ -56,7 +57,6 @@
     int ch8 = (int) ChCharOf(ch);
     NCURSES_CH_T wch;
     int count;
-    NCURSES_CONST char *s;
     int tabsize = (
 #if USE_REENTRANT
 		      sp->_TABSIZE
@@ -102,6 +102,7 @@
 		win->_curx++;
 	    }
 	} else if (iscntrl(ch8)) {
+	    NCURSES_CONST char *s;
 	    s = NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx (chtype) ch8);
 	    while (*s != '\0') {
 		code = _nc_insert_ch(sp, win, ChAttrOf(ch) | UChar(*s));
@@ -121,6 +122,7 @@
 	    if (count > 0) {
 		code = _nc_insert_wch(win, &wch);
 	    } else if (count == -1) {
+		NCURSES_CONST char *s;
 		/* handle EILSEQ */
 		s = NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx (chtype) ch8);
 		if (strlen(s) > 1) {
@@ -145,15 +147,13 @@
 NCURSES_EXPORT(int)
 winsch(WINDOW *win, chtype c)
 {
-    NCURSES_SIZE_T oy;
-    NCURSES_SIZE_T ox;
     int code = ERR;
 
     T((T_CALLED("winsch(%p, %s)"), (void *) win, _tracechtype(c)));
 
     if (win != 0) {
-	oy = win->_cury;
-	ox = win->_curx;
+	NCURSES_SIZE_T oy = win->_cury;
+	NCURSES_SIZE_T ox = win->_curx;
 
 	code = _nc_insert_ch(_nc_screen_of(win), win, c);
 
diff --git a/ncurses/base/lib_insdel.c b/ncurses/base/lib_insdel.c
index 8f51bbe..7c00739 100644
--- a/ncurses/base/lib_insdel.c
+++ b/ncurses/base/lib_insdel.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2003,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2003,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_insdel.c,v 1.13 2009/10/24 22:34:41 tom Exp $")
+MODULE_ID("$Id: lib_insdel.c,v 1.14 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 winsdelln(WINDOW *win, int n)
diff --git a/ncurses/base/lib_insnstr.c b/ncurses/base/lib_insnstr.c
index ce03e64..caec48e 100644
--- a/ncurses/base/lib_insnstr.c
+++ b/ncurses/base/lib_insnstr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2004,2009 Free Software Foundation, Inc.                   *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2004-2009,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,31 +41,56 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_insnstr.c,v 1.3 2009/10/24 22:04:35 tom Exp $")
+MODULE_ID("$Id: lib_insnstr.c,v 1.10 2023/11/21 21:58:03 tom Exp $")
 
 NCURSES_EXPORT(int)
 winsnstr(WINDOW *win, const char *s, int n)
 {
     int code = ERR;
-    NCURSES_SIZE_T oy;
-    NCURSES_SIZE_T ox;
     const unsigned char *str = (const unsigned char *) s;
-    const unsigned char *cp;
 
     T((T_CALLED("winsnstr(%p,%s,%d)"), (void *) win, _nc_visbufn(s, n), n));
 
-    if (win != 0 && str != 0) {
+    if (win != 0 && str != 0 && n != 0) {
 	SCREEN *sp = _nc_screen_of(win);
-
-	oy = win->_cury;
-	ox = win->_curx;
-	for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) {
-	    _nc_insert_ch(sp, win, (chtype) UChar(*cp));
+#if USE_WIDEC_SUPPORT
+	/*
+	 * If the output contains "wide" (multibyte) characters, we will not
+	 * really know the width of a character until we get the last byte
+	 * of the character.  Since the preceding byte(s) may use more columns
+	 * on the screen than the final character, it is best to route the
+	 * call to the wins_nwstr() function.
+	 */
+	if (sp->_screen_unicode) {
+	    size_t nn = (n > 0) ? (size_t) n : strlen(s);
+	    wchar_t *buffer = typeMalloc(wchar_t, nn + 1);
+	    if (buffer != 0) {
+		mbstate_t state;
+		size_t n3;
+		init_mb(state);
+		n3 = mbstowcs(buffer, s, nn);
+		if (n3 != (size_t) (-1)) {
+		    buffer[n3] = '\0';
+		    code = wins_nwstr(win, buffer, (int) n3);
+		}
+		free(buffer);
+	    }
 	}
-	win->_curx = ox;
-	win->_cury = oy;
-	_nc_synchook(win);
-	code = OK;
+	if (code == ERR)
+#endif
+	{
+	    NCURSES_SIZE_T oy = win->_cury;
+	    NCURSES_SIZE_T ox = win->_curx;
+	    const unsigned char *cp;
+
+	    for (cp = str; (n < 0 || (cp - str) < n) && *cp; cp++) {
+		_nc_insert_ch(sp, win, (chtype) UChar(*cp));
+	    }
+	    win->_curx = ox;
+	    win->_cury = oy;
+	    _nc_synchook(win);
+	    code = OK;
+	}
     }
     returnCode(code);
 }
diff --git a/ncurses/base/lib_instr.c b/ncurses/base/lib_instr.c
index f708ecc..221ebd2 100644
--- a/ncurses/base/lib_instr.c
+++ b/ncurses/base/lib_instr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -41,45 +42,48 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_instr.c,v 1.21 2014/02/01 22:09:27 tom Exp $")
+MODULE_ID("$Id: lib_instr.c,v 1.26 2023/06/03 12:37:04 tom Exp $")
 
 NCURSES_EXPORT(int)
 winnstr(WINDOW *win, char *str, int n)
 {
-    int i = 0, row, col;
+    int i = 0;
 
     T((T_CALLED("winnstr(%p,%p,%d)"), (void *) win, str, n));
 
-    if (!str)
-	returnCode(0);
-
-    if (win) {
-	getyx(win, row, col);
+    if (!win || !str) {
+	i = ERR;
+    } else {
+	int row = win->_cury;
+	int col = win->_curx;
+	NCURSES_CH_T *text = win->_line[row].text;
 
 	if (n < 0)
-	    n = win->_maxx - win->_curx + 1;
+	    n = win->_maxx - col + 1;
 
 	for (; i < n;) {
 #if USE_WIDEC_SUPPORT
-	    cchar_t *cell = &(win->_line[row].text[col]);
-	    wchar_t *wch;
+	    cchar_t *cell = &(text[col]);
 	    attr_t attrs;
 	    NCURSES_PAIRS_T pair;
-	    int n2;
-	    bool done = FALSE;
-	    mbstate_t state;
-	    size_t i3, n3;
 	    char *tmp;
 
 	    if (!isWidecExt(*cell)) {
+		wchar_t *wch;
+		int n2;
+
 		n2 = getcchar(cell, 0, 0, 0, 0);
 		if (n2 > 0
 		    && (wch = typeCalloc(wchar_t, (unsigned) n2 + 1)) != 0) {
+		    bool done = FALSE;
+
 		    if (getcchar(cell, wch, &attrs, &pair, 0) == OK) {
+			mbstate_t state;
+			size_t n3;
 
 			init_mb(state);
 			n3 = wcstombs(0, wch, (size_t) 0);
-			if (!isEILSEQ(n3) && (n3 != 0)) {
+			if (!isEILSEQ(n3) && (n3 != 0) && (n3 <= MB_LEN_MAX)) {
 			    size_t need = n3 + 10 + (size_t) i;
 			    int have = (int) n3 + i;
 
@@ -89,6 +93,8 @@
 			    } else if ((tmp = typeCalloc(char, need)) == 0) {
 				done = TRUE;
 			    } else {
+				size_t i3;
+
 				init_mb(state);
 				wcstombs(tmp, wch, n3);
 				for (i3 = 0; i3 < n3; ++i3)
@@ -103,14 +109,14 @@
 		}
 	    }
 #else
-	    str[i++] = (char) CharOf(win->_line[row].text[col]);
+	    str[i++] = (char) CharOf(text[col]);
 #endif
 	    if (++col > win->_maxx) {
 		break;
 	    }
 	}
+	str[i] = '\0';		/* SVr4 does not seem to count the null */
     }
-    str[i] = '\0';		/* SVr4 does not seem to count the null */
     T(("winnstr returns %s", _nc_visbuf(str)));
     returnCode(i);
 }
diff --git a/ncurses/base/lib_isendwin.c b/ncurses/base/lib_isendwin.c
index 923e35b..a54d500 100644
--- a/ncurses/base/lib_isendwin.c
+++ b/ncurses/base/lib_isendwin.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2009,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,14 +43,14 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_isendwin.c,v 1.7 2009/02/15 00:36:24 tom Exp $")
+MODULE_ID("$Id: lib_isendwin.c,v 1.9 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(bool)
 NCURSES_SP_NAME(isendwin) (NCURSES_SP_DCL0)
 {
     if (SP_PARM == NULL)
 	return FALSE;
-    return SP_PARM->_endwin;
+    return (SP_PARM->_endwin == ewSuspend);
 }
 
 #if NCURSES_SP_FUNCS
diff --git a/ncurses/base/lib_leaveok.c b/ncurses/base/lib_leaveok.c
index e6995f8..4d05b2c 100644
--- a/ncurses/base/lib_leaveok.c
+++ b/ncurses/base/lib_leaveok.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2000,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_leaveok.c,v 1.6 2009/10/24 22:34:23 tom Exp $")
+MODULE_ID("$Id: lib_leaveok.c,v 1.7 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 leaveok(WINDOW *win, bool flag)
diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c
index 36b6e1e..a03d8b8 100644
--- a/ncurses/base/lib_mouse.c
+++ b/ncurses/base/lib_mouse.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -84,7 +85,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_mouse.c,v 1.166 2015/07/05 00:28:27 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.200 2024/02/17 21:13:01 tom Exp $")
 
 #include <tic.h>
 
@@ -141,19 +142,29 @@
 #define	MASK_RESERVED_EVENT(x)	(mmask_t) NCURSES_MOUSE_MASK(x, 040)
 
 #if NCURSES_MOUSE_VERSION == 1
+
 #define BUTTON_CLICKED        (BUTTON1_CLICKED        | BUTTON2_CLICKED        | BUTTON3_CLICKED        | BUTTON4_CLICKED)
 #define BUTTON_PRESSED        (BUTTON1_PRESSED        | BUTTON2_PRESSED        | BUTTON3_PRESSED        | BUTTON4_PRESSED)
 #define BUTTON_RELEASED       (BUTTON1_RELEASED       | BUTTON2_RELEASED       | BUTTON3_RELEASED       | BUTTON4_RELEASED)
 #define BUTTON_DOUBLE_CLICKED (BUTTON1_DOUBLE_CLICKED | BUTTON2_DOUBLE_CLICKED | BUTTON3_DOUBLE_CLICKED | BUTTON4_DOUBLE_CLICKED)
 #define BUTTON_TRIPLE_CLICKED (BUTTON1_TRIPLE_CLICKED | BUTTON2_TRIPLE_CLICKED | BUTTON3_TRIPLE_CLICKED | BUTTON4_TRIPLE_CLICKED)
+
 #define MAX_BUTTONS  4
+
 #else
+
 #define BUTTON_CLICKED        (BUTTON1_CLICKED        | BUTTON2_CLICKED        | BUTTON3_CLICKED        | BUTTON4_CLICKED        | BUTTON5_CLICKED)
 #define BUTTON_PRESSED        (BUTTON1_PRESSED        | BUTTON2_PRESSED        | BUTTON3_PRESSED        | BUTTON4_PRESSED        | BUTTON5_PRESSED)
 #define BUTTON_RELEASED       (BUTTON1_RELEASED       | BUTTON2_RELEASED       | BUTTON3_RELEASED       | BUTTON4_RELEASED       | BUTTON5_RELEASED)
 #define BUTTON_DOUBLE_CLICKED (BUTTON1_DOUBLE_CLICKED | BUTTON2_DOUBLE_CLICKED | BUTTON3_DOUBLE_CLICKED | BUTTON4_DOUBLE_CLICKED | BUTTON5_DOUBLE_CLICKED)
 #define BUTTON_TRIPLE_CLICKED (BUTTON1_TRIPLE_CLICKED | BUTTON2_TRIPLE_CLICKED | BUTTON3_TRIPLE_CLICKED | BUTTON4_TRIPLE_CLICKED | BUTTON5_TRIPLE_CLICKED)
+
+#if NCURSES_MOUSE_VERSION == 2
 #define MAX_BUTTONS  5
+#else
+#define MAX_BUTTONS  11
+#endif
+
 #endif
 
 #define INVALID_EVENT	-1
@@ -225,7 +236,7 @@
     char buf[6];
     unsigned long ignore;
 
-    strcpy(buf, "\033[M");	/* should be the same as key_mouse */
+    _nc_STRCPY(buf, "\033[M", sizeof(buf));	/* should be the same as key_mouse */
     buf[3] = ' ' + (button - 1) + (down ? 0 : 0x40);
     buf[4] = ' ' + x - LEFT_COL + 1;
     buf[5] = ' ' + y - TOP_ROW + 1;
@@ -369,7 +380,7 @@
 }
 #endif /* USE_SYSMOUSE */
 
-#ifndef USE_TERM_DRIVER
+#if !defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER)
 #define xterm_kmous "\033[M"
 
 static void
@@ -408,13 +419,22 @@
     } else {
 	int code = tigetnum("XM");
 	switch (code) {
+#ifdef EXP_XTERM_1005
+	case 1005:
+	    /* see "xterm+sm+1005" */
+	    sp->_mouse_xtermcap = "\033[?1005;1000%?%p1%{1}%=%th%el%;";
+	    sp->_mouse_format = MF_XTERM_1005;
+	    break;
+#endif
 	case 1006:
+	    /* see "xterm+sm+1006" */
+	    sp->_mouse_xtermcap = "\033[?1006;1000%?%p1%{1}%=%th%el%;";
+	    sp->_mouse_format = MF_SGR1006;
 	    break;
 	default:
-	    code = 1000;
+	    sp->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;";
 	    break;
 	}
-	sp->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;";
     }
 }
 #endif
@@ -422,14 +442,29 @@
 static void
 enable_xterm_mouse(SCREEN *sp, int enable)
 {
+    TPUTS_TRACE(enable
+		? "xterm mouse initialization"
+		: "xterm mouse deinitialization");
 #if USE_EMX_MOUSE
     sp->_emxmouse_activated = enable;
 #else
-    NCURSES_PUTP2("xterm-mouse", TPARM_1(sp->_mouse_xtermcap, enable));
+    NCURSES_PUTP2("xterm-mouse", TIPARM_1(sp->_mouse_xtermcap, enable));
 #endif
     sp->_mouse_active = enable;
 }
 
+#if defined(USE_TERM_DRIVER)
+static void
+enable_win32_mouse(SCREEN *sp, int enable)
+{
+#if defined(EXP_WIN32_DRIVER)
+    enable_xterm_mouse(sp, enable);
+#else
+    sp->_mouse_active = enable;
+#endif
+}
+#endif
+
 #if USE_GPM_SUPPORT
 static bool
 allow_gpm_mouse(SCREEN *sp GCC_UNUSED)
@@ -438,7 +473,7 @@
 
 #if USE_WEAK_SYMBOLS
     /* Danger Robinson: do not use dlopen for libgpm if already loaded */
-    if ((Gpm_Wgetch)) {
+    if ((Gpm_Wgetch) != 0) {
 	if (!sp->_mouse_gpm_loaded) {
 	    T(("GPM library was already dlopen'd, not by us"));
 	}
@@ -476,8 +511,6 @@
 	T(("unload GPM library"));
 	sp->_mouse_gpm_loaded = FALSE;
 	sp->_mouse_fd = -1;
-	dlclose(sp->_dlopen_gpm);
-	sp->_dlopen_gpm = 0;
     }
 }
 
@@ -485,20 +518,36 @@
 load_gpm_library(SCREEN *sp)
 {
     sp->_mouse_gpm_found = FALSE;
-    if ((sp->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) {
+
+    /*
+     * If we already had a successful dlopen, reuse it.
+     */
+    if (sp->_dlopen_gpm != 0) {
+	sp->_mouse_gpm_found = TRUE;
+	sp->_mouse_gpm_loaded = TRUE;
+    } else if ((sp->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) {
+#if (defined(__GNUC__) && (__GNUC__ >= 5)) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
 	if (GET_DLSYM(gpm_fd) == 0 ||
 	    GET_DLSYM(Gpm_Open) == 0 ||
 	    GET_DLSYM(Gpm_Close) == 0 ||
 	    GET_DLSYM(Gpm_GetEvent) == 0) {
+#if (defined(__GNUC__) && (__GNUC__ >= 5)) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
 	    T(("GPM initialization failed: %s", dlerror()));
 	    unload_gpm_library(sp);
+	    dlclose(sp->_dlopen_gpm);
+	    sp->_dlopen_gpm = 0;
 	} else {
 	    sp->_mouse_gpm_found = TRUE;
 	    sp->_mouse_gpm_loaded = TRUE;
 	}
     }
 }
-#endif
+#endif /* HAVE_LIBDL */
 
 static bool
 enable_gpm_mouse(SCREEN *sp, bool enable)
@@ -597,8 +646,8 @@
     /* OS/2 VIO */
 #if USE_EMX_MOUSE
     if (!sp->_emxmouse_thread
-	&& strstr(TerminalOf(sp)->type.term_names, "xterm") == 0
-	&& key_mouse) {
+	&& strstr(SP_TERMTYPE term_names, "xterm") == 0
+	&& NonEmpty(key_mouse)) {
 	int handles[2];
 
 	if (pipe(handles) < 0) {
@@ -641,13 +690,14 @@
 
 #if USE_SYSMOUSE
     {
+	static char dev_tty[] = "/dev/tty";
 	struct mouse_info the_mouse;
 	char *the_device = 0;
 
 	if (NC_ISATTY(sp->_ifd))
 	    the_device = ttyname(sp->_ifd);
 	if (the_device == 0)
-	    the_device = "/dev/tty";
+	    the_device = dev_tty;
 
 	sp->_mouse_fd = open(the_device, O_RDWR);
 
@@ -706,14 +756,12 @@
 
 #ifdef USE_TERM_DRIVER
     CallDriver(sp, td_initmouse);
-#else
+#endif
+#if !defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER)
     /* we know how to recognize mouse events under "xterm" */
-    if (key_mouse != 0) {
-	if (!strcmp(key_mouse, xterm_kmous)
-	    || strstr(TerminalOf(sp)->type.term_names, "xterm") != 0) {
-	    init_xterm_mouse(sp);
-	}
-    } else if (strstr(TerminalOf(sp)->type.term_names, "xterm") != 0) {
+    if (NonEmpty(key_mouse)) {
+	init_xterm_mouse(sp);
+    } else if (strstr(SP_TERMTYPE term_names, "xterm") != 0) {
 	if (_nc_add_to_try(&(sp->_keytry), xterm_kmous, KEY_MOUSE) == OK)
 	    init_xterm_mouse(sp);
     }
@@ -727,13 +775,16 @@
 /* initialize the mouse */
 {
     bool result = FALSE;
-    int i;
+
+    T((T_CALLED("_nc_mouse_init(%p)"), (void *) sp));
 
     if (sp != 0) {
 	if (!sp->_mouse_initialized) {
+	    int i;
+
 	    sp->_mouse_initialized = TRUE;
 
-	    TR(MY_TRACE, ("_nc_mouse_init() called"));
+	    TR(MY_TRACE, ("set _mouse_initialized"));
 
 	    sp->_mouse_eventp = FirstEV(sp);
 	    for (i = 0; i < EV_MAX; i++)
@@ -741,11 +792,11 @@
 
 	    initialize_mousetype(sp);
 
-	    T(("_nc_mouse_init() set mousetype to %d", sp->_mouse_type));
+	    T(("set _mouse_type to %d", sp->_mouse_type));
 	}
 	result = sp->_mouse_initialized;
     }
-    return result;
+    returnCode(result);
 }
 
 /*
@@ -888,7 +939,7 @@
     do { \
 	    eventp->bstate = MASK_PRESS(n); \
 	    sp->_mouse_bstate |= MASK_PRESS(n); \
-	    if (kbuf[0] & 0x40) { \
+	    if (button & 0x40) { \
 		    eventp->bstate = MASK_RELEASE(n); \
 		    sp->_mouse_bstate &= ~MASK_PRESS(n); \
 	    } \
@@ -896,7 +947,7 @@
 #else
 #define PRESS_POSITION(n) \
     do { \
-	    eventp->bstate = (mmask_t) (sp->_mouse_bstate & MASK_PRESS(n) \
+	    eventp->bstate = (mmask_t) ((sp->_mouse_bstate & MASK_PRESS(n)) \
 				    ? REPORT_MOUSE_POSITION \
 				    : MASK_PRESS(n)); \
 	    sp->_mouse_bstate |= MASK_PRESS(n); \
@@ -921,7 +972,7 @@
 	break;
     case 1:
 	if (wheel) {
-#if NCURSES_MOUSE_VERSION == 2
+#if NCURSES_MOUSE_VERSION >= 2
 	    eventp->bstate = MASK_PRESS(5);
 	    /* See comment above for button 4 */
 #else
@@ -936,6 +987,17 @@
 	PRESS_POSITION(3);
 	break;
     default:
+	/*
+	 * case 3 is sent when the mouse buttons are released.
+	 *
+	 * If the terminal uses xterm mode 1003, a continuous series of
+	 * button-release events is sent as the mouse moves around the screen,
+	 * or as the wheel mouse is rotated.
+	 *
+	 * Return false in this case, so that when running in X10 mode, we will
+	 * recalculate bstate.
+	 */
+	eventp->bstate = REPORT_MOUSE_POSITION;
 	result = FALSE;
 	break;
     }
@@ -946,11 +1008,25 @@
 decode_X10_bstate(SCREEN *sp, MEVENT * eventp, unsigned intro)
 {
     bool result;
-    int b;
+    int button = 0;
+    int wheel = (intro & 96) == 96;
 
     eventp->bstate = 0;
 
-    if (!handle_wheel(sp, eventp, (int) intro, (intro & 96) == 96)) {
+    if (intro >= 96) {
+	if (intro >= 160) {
+	    button = (int) (intro - 152);	/* buttons 8-11 */
+	} else {
+	    button = (int) (intro - 92);	/* buttons 4-7 */
+	}
+    } else {
+	button = (intro & 3);
+    }
+
+    if (button > MAX_BUTTONS) {
+	eventp->bstate = REPORT_MOUSE_POSITION;
+    } else if (!handle_wheel(sp, eventp, (int) intro, wheel)) {
+
 	/*
 	 * Release events aren't reported for individual buttons, just for
 	 * the button set as a whole.  However, because there are normally
@@ -959,6 +1035,8 @@
 	 * the previous event.
 	 */
 	if (sp->_mouse_bstate & BUTTON_PRESSED) {
+	    int b;
+
 	    eventp->bstate = BUTTON_RELEASED;
 	    for (b = 1; b <= MAX_BUTTONS; ++b) {
 		if (!(sp->_mouse_bstate & MASK_PRESS(b)))
@@ -1019,18 +1097,14 @@
 static bool
 decode_xterm_X10(SCREEN *sp, MEVENT * eventp)
 {
-    unsigned char kbuf[4];
+#define MAX_KBUF 3
+    unsigned char kbuf[MAX_KBUF + 1];
     size_t grabbed;
     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
-    for (grabbed = 0; grabbed < 3; grabbed += (size_t) res) {
+    _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. */
 	res = (int) read(
@@ -1039,14 +1113,12 @@
 #else
 			    sp->_ifd,
 #endif
-			    kbuf + grabbed, 3 - grabbed);
+			    kbuf + grabbed, (size_t) (MAX_KBUF - (int) grabbed));
 	if (res == -1)
 	    break;
     }
-#if USE_PTHREADS_EINTR
-    _nc_globals.read_thread = 0;
-#endif
-    kbuf[3] = '\0';
+    _nc_set_read_thread(FALSE);
+    kbuf[MAX_KBUF] = '\0';
 
     TR(TRACE_IEVENT,
        ("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
@@ -1074,19 +1146,14 @@
     size_t grabbed;
     size_t limit = (sizeof(kbuf) - 1);
     unsigned coords[2];
-    int res;
     bool result;
 
     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;
 
 	res = (int) read(
 #if USE_EMX_MOUSE
@@ -1094,15 +1161,17 @@
 #else
 			    sp->_ifd,
 #endif
-			    kbuf + grabbed, 1);
+			    (kbuf + grabbed), (size_t) 1);
 	if (res == -1)
 	    break;
 	grabbed += (size_t) res;
 	if (grabbed > 1) {
 	    size_t check = 1;
 	    int n;
-	    int rc;
+
 	    for (n = 0; n < 2; ++n) {
+		int rc;
+
 		if (check >= grabbed)
 		    break;
 		rc = _nc_conv_to_utf32(&coords[n], kbuf + check, (unsigned)
@@ -1115,9 +1184,7 @@
 		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",
@@ -1156,29 +1223,26 @@
 {
     char kbuf[80];		/* bigger than any possible mouse response */
     int grabbed = 0;
-    int res;
     int ch = 0;
     int now = -1;
     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;
+
 	res = (int) read(
 #if USE_EMX_MOUSE
 			    (M_FD(sp) >= 0) ? M_FD(sp) : sp->_ifd,
 #else
 			    sp->_ifd,
 #endif
-			    kbuf + grabbed, 1);
+			    (kbuf + grabbed), (size_t) 1);
 	if (res == -1)
 	    break;
-	if ((grabbed + 3) >= (int) sizeof(kbuf)) {
+	if ((grabbed + MAX_KBUF) >= (int) sizeof(kbuf)) {
 	    result->nerror++;
 	    break;
 	}
@@ -1229,9 +1293,7 @@
 	}
 	++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,
@@ -1247,10 +1309,21 @@
     if (read_SGR(sp, &data)) {
 	int b = data.params[0];
 	int b3 = 1 + (b & 3);
+	int wheel = ((b & 64) == 64);
+
+	if (b >= 132) {
+	    b3 = MAX_BUTTONS + 1;
+	} else if (b >= 128) {
+	    b3 = (b - 120);	/* buttons 8-11 */
+	} else if (b >= 64) {
+	    b3 = (b - 60);	/* buttons 6-7 */
+	}
 
 	eventp->id = NORMAL_EVENT;
 	if (data.final == 'M') {
-	    (void) handle_wheel(sp, eventp, b, (b & 64) == 64);
+	    (void) handle_wheel(sp, eventp, b, wheel);
+	} else if (b3 > MAX_BUTTONS) {
+	    eventp->bstate = REPORT_MOUSE_POSITION;
 	} else {
 	    mmask_t pressed = (mmask_t) NCURSES_MOUSE_MASK(b3, NCURSES_BUTTON_PRESSED);
 	    mmask_t release = (mmask_t) NCURSES_MOUSE_MASK(b3, NCURSES_BUTTON_RELEASED);
@@ -1261,6 +1334,15 @@
 		eventp->bstate = REPORT_MOUSE_POSITION;
 	    }
 	}
+	if (b & 4) {
+	    eventp->bstate |= BUTTON_SHIFT;
+	}
+	if (b & 8) {
+	    eventp->bstate |= BUTTON_ALT;
+	}
+	if (b & 16) {
+	    eventp->bstate |= BUTTON_CTRL;
+	}
 	result = (eventp->bstate & REPORT_MOUSE_POSITION) ? TRUE : FALSE;
 	eventp->x = (data.params[1] ? (data.params[1] - 1) : 0);
 	eventp->y = (data.params[2] ? (data.params[2] - 1) : 0);
@@ -1324,11 +1406,14 @@
 static void
 mouse_activate(SCREEN *sp, int on)
 {
+    T((T_CALLED("mouse_activate(%p,%s)"),
+       (void *) SP_PARM, on ? "on" : "off"));
+
     if (!on && !sp->_mouse_initialized)
-	return;
+	returnVoid;
 
     if (!_nc_mouse_init(sp))
-	return;
+	returnVoid;
 
     if (on) {
 	sp->_mouse_bstate = 0;
@@ -1337,7 +1422,6 @@
 #if NCURSES_EXT_FUNCS
 	    NCURSES_SP_NAME(keyok) (NCURSES_SP_ARGx KEY_MOUSE, on);
 #endif
-	    TPUTS_TRACE("xterm mouse initialization");
 	    enable_xterm_mouse(sp, 1);
 	    break;
 #if USE_GPM_SUPPORT
@@ -1356,25 +1440,28 @@
 #endif
 #ifdef USE_TERM_DRIVER
 	case M_TERM_DRIVER:
-	    sp->_mouse_active = TRUE;
+	    enable_win32_mouse(sp, TRUE);
 	    break;
 #endif
 	case M_NONE:
-	    return;
+	    returnVoid;
+	default:
+	    T(("unexpected mouse mode"));
+	    break;
 	}
 	/* Make runtime binding to cut down on object size of applications that
 	 * do not use the mouse (e.g., 'clear').
 	 */
-	sp->_mouse_event = _nc_mouse_event;
+	/* *INDENT-EQLS* */
+	sp->_mouse_event  = _nc_mouse_event;
 	sp->_mouse_inline = _nc_mouse_inline;
-	sp->_mouse_parse = _nc_mouse_parse;
+	sp->_mouse_parse  = _nc_mouse_parse;
 	sp->_mouse_resume = _nc_mouse_resume;
-	sp->_mouse_wrap = _nc_mouse_wrap;
+	sp->_mouse_wrap   = _nc_mouse_wrap;
     } else {
 
 	switch (sp->_mouse_type) {
 	case M_XTERM:
-	    TPUTS_TRACE("xterm mouse deinitialization");
 	    enable_xterm_mouse(sp, 0);
 	    break;
 #if USE_GPM_SUPPORT
@@ -1390,14 +1477,18 @@
 #endif
 #ifdef USE_TERM_DRIVER
 	case M_TERM_DRIVER:
-	    sp->_mouse_active = FALSE;
+	    enable_win32_mouse(sp, FALSE);
 	    break;
 #endif
 	case M_NONE:
-	    return;
+	    returnVoid;
+	default:
+	    T(("unexpected mouse mode"));
+	    break;
 	}
     }
     NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
+    returnVoid;
 }
 
 /**************************************************************************
@@ -1495,7 +1586,7 @@
 		if (changed) {
 		    merge = FALSE;
 		    for (b = 1; b <= MAX_BUTTONS; ++b) {
-			if ((sp->_mouse_mask & MASK_CLICK(b))
+			if ((sp->_mouse_mask2 & MASK_CLICK(b))
 			    && (ep->bstate & MASK_PRESS(b))) {
 			    next->bstate &= ~MASK_RELEASE(b);
 			    next->bstate |= MASK_CLICK(b);
@@ -1576,7 +1667,7 @@
 		&& (next->bstate & BUTTON_CLICKED)) {
 		merge = FALSE;
 		for (b = 1; b <= MAX_BUTTONS; ++b) {
-		    if ((sp->_mouse_mask & MASK_DOUBLE_CLICK(b))
+		    if ((sp->_mouse_mask2 & MASK_DOUBLE_CLICK(b))
 			&& (ep->bstate & MASK_CLICK(b))
 			&& (next->bstate & MASK_CLICK(b))) {
 			next->bstate &= ~MASK_CLICK(b);
@@ -1594,7 +1685,7 @@
 		&& (next->bstate & BUTTON_CLICKED)) {
 		merge = FALSE;
 		for (b = 1; b <= MAX_BUTTONS; ++b) {
-		    if ((sp->_mouse_mask & MASK_TRIPLE_CLICK(b))
+		    if ((sp->_mouse_mask2 & MASK_TRIPLE_CLICK(b))
 			&& (ep->bstate & MASK_DOUBLE_CLICK(b))
 			&& (next->bstate & MASK_CLICK(b))) {
 			next->bstate &= ~MASK_CLICK(b);
@@ -1654,7 +1745,8 @@
 #endif /* TRACE */
 
     /* after all this, do we have a valid event? */
-    return ValidEvent(PREV(first_invalid));
+    ep = PREV(first_invalid);
+    return ValidEvent(ep) && ((ep->bstate & sp->_mouse_mask) != 0);
 }
 
 static void
@@ -1738,11 +1830,14 @@
 NCURSES_SP_NAME(getmouse) (NCURSES_SP_DCLx MEVENT * aevent)
 {
     int result = ERR;
+    MEVENT *eventp;
 
     T((T_CALLED("getmouse(%p,%p)"), (void *) SP_PARM, (void *) aevent));
 
-    if ((aevent != 0) && (SP_PARM != 0) && (SP_PARM->_mouse_type != M_NONE)) {
-	MEVENT *eventp = SP_PARM->_mouse_eventp;
+    if ((aevent != 0) &&
+	(SP_PARM != 0) &&
+	(SP_PARM->_mouse_type != M_NONE) &&
+	(eventp = SP_PARM->_mouse_eventp) != 0) {
 	/* compute the current-event pointer */
 	MEVENT *prev = PREV(eventp);
 
@@ -1791,11 +1886,13 @@
 NCURSES_SP_NAME(ungetmouse) (NCURSES_SP_DCLx MEVENT * aevent)
 {
     int result = ERR;
+    MEVENT *eventp;
 
     T((T_CALLED("ungetmouse(%p,%p)"), (void *) SP_PARM, (void *) aevent));
 
-    if (aevent != 0 && SP_PARM != 0) {
-	MEVENT *eventp = SP_PARM->_mouse_eventp;
+    if (aevent != 0 &&
+	SP_PARM != 0 &&
+	(eventp = SP_PARM->_mouse_eventp) != 0) {
 
 	/* stick the given event in the next-free slot */
 	*eventp = *aevent;
@@ -1823,7 +1920,6 @@
 /* set the mouse event mask */
 {
     mmask_t result = 0;
-    int b;
 
     T((T_CALLED("mousemask(%p,%#lx,%p)"),
        (void *) SP_PARM,
@@ -1836,7 +1932,10 @@
 
 	if (newmask || SP_PARM->_mouse_initialized) {
 	    _nc_mouse_init(SP_PARM);
+
 	    if (SP_PARM->_mouse_type != M_NONE) {
+		int b;
+
 		result = newmask &
 		    (REPORT_MOUSE_POSITION
 		     | BUTTON_ALT
@@ -1891,10 +1990,24 @@
 
     if (win != 0) {
 	y -= win->_yoffset;
-	result = ((win->_begy <= y &&
-		   win->_begx <= x &&
-		   (win->_begx + win->_maxx) >= x &&
-		   (win->_begy + win->_maxy) >= y) ? TRUE : FALSE);
+	if (IS_PAD(win)) {
+	    if (win->_pad._pad_y >= 0 &&
+		win->_pad._pad_x >= 0 &&
+		win->_pad._pad_top >= 0 &&
+		win->_pad._pad_left >= 0 &&
+		win->_pad._pad_right >= 0 &&
+		win->_pad._pad_bottom >= 0) {
+		result = ((win->_pad._pad_top <= y &&
+			   win->_pad._pad_left <= x &&
+			   win->_pad._pad_right >= x &&
+			   win->_pad._pad_bottom >= y) ? TRUE : FALSE);
+	    }
+	} else {
+	    result = ((win->_begy <= y &&
+		       win->_begx <= x &&
+		       (win->_begx + win->_maxx) >= x &&
+		       (win->_begy + win->_maxy) >= y) ? TRUE : FALSE);
+	}
     }
     returnBool(result);
 }
@@ -1963,6 +2076,7 @@
 	int y = *pY;
 	int x = *pX;
 
+	T(("transform input %d,%d", y, x));
 	if (to_screen) {
 	    y += win->_begy + win->_yoffset;
 	    x += win->_begx;
@@ -1978,6 +2092,7 @@
 	if (result) {
 	    *pX = x;
 	    *pY = y;
+	    T(("output transform %d,%d", y, x));
 	}
     }
     returnBool(result);
diff --git a/ncurses/base/lib_move.c b/ncurses/base/lib_move.c
index 488b195..d9ba8c0 100644
--- a/ncurses/base/lib_move.c
+++ b/ncurses/base/lib_move.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2004,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2004,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -41,7 +42,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_move.c,v 1.13 2009/10/24 22:34:07 tom Exp $")
+MODULE_ID("$Id: lib_move.c,v 1.14 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 wmove(WINDOW *win, int y, int x)
diff --git a/ncurses/base/lib_mvwin.c b/ncurses/base/lib_mvwin.c
index 18d31c1..fca014e 100644
--- a/ncurses/base/lib_mvwin.c
+++ b/ncurses/base/lib_mvwin.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_mvwin.c,v 1.18 2010/12/19 01:22:58 tom Exp $")
+MODULE_ID("$Id: lib_mvwin.c,v 1.20 2021/10/23 18:57:41 tom Exp $")
 
 NCURSES_EXPORT(int)
 mvwin(WINDOW *win, int by, int bx)
@@ -53,7 +54,7 @@
 
     T((T_CALLED("mvwin(%p,%d,%d)"), (void *) win, by, bx));
 
-    if (!win || (win->_flags & _ISPAD))
+    if (!win || IS_PAD(win))
 	returnCode(ERR);
 
     /*
@@ -62,7 +63,7 @@
      */
 #if 0
     /* Copying subwindows is allowed, but it is expensive... */
-    if (win->_flags & _SUBWIN) {
+    if (IS_SUBWIN(win)) {
 	int err = ERR;
 	WINDOW *parent = win->_parent;
 	if (parent) {		/* Now comes the complicated and costly part, you should really
diff --git a/ncurses/base/lib_newterm.c b/ncurses/base/lib_newterm.c
index edbf956..15d05a3 100644
--- a/ncurses/base/lib_newterm.c
+++ b/ncurses/base/lib_newterm.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2020,2022 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -48,7 +49,7 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: lib_newterm.c,v 1.92 2014/04/26 18:00:39 tom Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.104 2022/07/09 18:58:58 tom Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define NumLabels      InfoOf(SP_PARM).numlabels
@@ -76,6 +77,7 @@
 
     /* for extended XPG4 conformance requires cbreak() at this point */
     /* (SVr4 curses does this anyway) */
+    T((T_CALLED("_nc_initscr(%p) ->term %p"), (void *) SP_PARM, (void *) term));
     if (NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG) == OK) {
 	TTY buf;
 
@@ -86,6 +88,12 @@
 	buf.c_oflag &= (unsigned) ~(ONLCR);
 #elif HAVE_SGTTY_H
 	buf.sg_flags &= ~(ECHO | CRMOD);
+#elif defined(EXP_WIN32_DRIVER)
+	buf.dwFlagIn = CONMODE_IN_DEFAULT;
+	buf.dwFlagOut = CONMODE_OUT_DEFAULT | VT_FLAG_OUT;
+	if (WINCONSOLE.isTermInfoConsole) {
+	    buf.dwFlagIn |= VT_FLAG_IN;
+	}
 #else
 	memset(&buf, 0, sizeof(buf));
 #endif
@@ -93,7 +101,7 @@
 	if (result == OK)
 	    term->Nttyb = buf;
     }
-    return result;
+    returnCode(result);
 }
 
 /*
@@ -162,20 +170,16 @@
 
 NCURSES_EXPORT(SCREEN *)
 NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
-			  NCURSES_CONST char *name,
+			  const char *name,
 			  FILE *ofp,
 			  FILE *ifp)
 {
-    int value;
     int errret;
     SCREEN *result = 0;
     SCREEN *current;
     TERMINAL *its_term;
     FILE *_ofp = ofp ? ofp : stdout;
     FILE *_ifp = ifp ? ifp : stdin;
-    int cols;
-    int slk_format;
-    int filter_mode;
     TERMINAL *new_term = 0;
 
     START_TRACE();
@@ -197,11 +201,18 @@
     current = CURRENT_SCREEN;
     its_term = (current ? current->_term : 0);
 
+#if defined(EXP_WIN32_DRIVER)
+    _setmode(fileno(_ifp), _O_BINARY);
+    _setmode(fileno(_ofp), _O_BINARY);
+#endif
+
     INIT_TERM_DRIVER();
     /* this loads the capability entry, then sets LINES and COLS */
     if (
 	   TINFO_SETUP_TERM(&new_term, name,
 			    fileno(_ofp), &errret, FALSE) != ERR) {
+	int slk_format;
+	int filter_mode;
 
 	_nc_set_screen(0);
 #ifdef USE_TERM_DRIVER
@@ -232,6 +243,9 @@
 	    _nc_set_screen(current);
 	    result = 0;
 	} else {
+	    int value;
+	    int cols;
+
 #ifdef USE_TERM_DRIVER
 	    TERMINAL_CONTROL_BLOCK *TCB;
 #elif !NCURSES_SP_FUNCS
@@ -265,7 +279,11 @@
 
 	    /* allow user to set maximum escape delay from the environment */
 	    if ((value = _nc_getenv_num("ESCDELAY")) >= 0) {
+#if NCURSES_EXT_FUNCS
 		NCURSES_SP_NAME(set_escdelay) (NCURSES_SP_ARGx value);
+#else
+		ESCDELAY = value;
+#endif
 	    }
 
 	    /* if the terminal type has real soft labels, set those up */
@@ -281,7 +299,7 @@
 #else
 	    SP_PARM->_use_meta = FALSE;
 #endif
-	    SP_PARM->_endwin = FALSE;
+	    SP_PARM->_endwin = ewInitial;
 #ifndef USE_TERM_DRIVER
 	    /*
 	     * Check whether we can optimize scrolling under dumb terminals in
@@ -341,8 +359,17 @@
 
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(SCREEN *)
-newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
+newterm(const char *name, FILE *ofp, FILE *ifp)
 {
-    return NCURSES_SP_NAME(newterm) (CURRENT_SCREEN_PRE, name, ofp, ifp);
+    SCREEN *rc;
+
+    _nc_init_pthreads();
+    _nc_lock_global(prescreen);
+    START_TRACE();
+    rc = NCURSES_SP_NAME(newterm) (CURRENT_SCREEN_PRE, name, ofp, ifp);
+    _nc_forget_prescr();
+    _nc_unlock_global(prescreen);
+
+    return rc;
 }
 #endif
diff --git a/ncurses/base/lib_newwin.c b/ncurses/base/lib_newwin.c
index a6c64be..a672319 100644
--- a/ncurses/base/lib_newwin.c
+++ b/ncurses/base/lib_newwin.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc.              *
+ * 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  *
  * copy of this software and associated documentation files (the            *
@@ -43,7 +44,7 @@
 #include <curses.priv.h>
 #include <stddef.h>
 
-MODULE_ID("$Id: lib_newwin.c,v 1.71 2011/05/28 21:32:51 tom Exp $")
+MODULE_ID("$Id: lib_newwin.c,v 1.76 2021/10/23 18:53:38 tom Exp $")
 
 #define window_is(name) ((sp)->_##name == win)
 
@@ -91,8 +92,6 @@
 NCURSES_EXPORT(int)
 _nc_freewin(WINDOW *win)
 {
-    WINDOWLIST *p, *q;
-    int i;
     int result = ERR;
 #ifdef USE_SP_WINDOWLIST
     SCREEN *sp = _nc_screen_of(win);	/* pretend this is parameter */
@@ -101,17 +100,23 @@
     T((T_CALLED("_nc_freewin(%p)"), (void *) win));
 
     if (win != 0) {
+
 	if (_nc_nonsp_try_global(curses) == 0) {
+	    WINDOWLIST *p, *q;
+
 	    q = 0;
-	    for (each_window(SP_PARM, p)) {
+	    for (each_window(sp, p)) {
+
 		if (&(p->win) == win) {
 		    remove_window_from_screen(win);
 		    if (q == 0)
-			WindowList(SP_PARM) = p->next;
+			WindowList(sp) = p->next;
 		    else
 			q->next = p->next;
 
-		    if (!(win->_flags & _SUBWIN)) {
+		    if (!IS_SUBWIN(win)) {
+			int i;
+
 			for (i = 0; i <= win->_maxy; i++)
 			    FreeIfNeeded(win->_line[i].text);
 		    }
@@ -214,7 +219,7 @@
     if (num_columns == 0)
 	num_columns = orig->_maxx + 1 - begx;
 
-    if (orig->_flags & _ISPAD)
+    if (IS_PAD(orig))
 	flags |= _ISPAD;
 
     win = NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_ARGx num_lines, num_columns,
@@ -384,18 +389,18 @@
 NCURSES_EXPORT(WINDOW *)
 _nc_curscr_of(SCREEN *sp)
 {
-    return sp == 0 ? 0 : CurScreen(sp);
+    return (sp == 0) ? NULL : CurScreen(sp);
 }
 
 NCURSES_EXPORT(WINDOW *)
 _nc_newscr_of(SCREEN *sp)
 {
-    return sp == 0 ? 0 : NewScreen(sp);
+    return (sp == 0) ? NULL : NewScreen(sp);
 }
 
 NCURSES_EXPORT(WINDOW *)
 _nc_stdscr_of(SCREEN *sp)
 {
-    return sp == 0 ? 0 : StdScreen(sp);
+    return (sp == 0) ? NULL : StdScreen(sp);
 }
 #endif
diff --git a/ncurses/base/lib_nl.c b/ncurses/base/lib_nl.c
index 3425487..417b257 100644
--- a/ncurses/base/lib_nl.c
+++ b/ncurses/base/lib_nl.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 1998-2000,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -44,7 +45,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_nl.c,v 1.12 2009/10/24 22:05:55 tom Exp $")
+MODULE_ID("$Id: lib_nl.c,v 1.14 2023/04/29 18:51:49 tom Exp $")
 
 #ifdef __EMX__
 #include <io.h>
@@ -56,7 +57,7 @@
     T((T_CALLED("nl(%p)"), (void *) SP_PARM));
     if (0 == SP_PARM)
 	returnCode(ERR);
-    SP_PARM->_nl = TRUE;
+    IsNl(SP_PARM) = TRUE;
 #ifdef __EMX__
     _nc_flush();
     _fsetmode(NC_OUTPUT(SP_PARM), "t");
@@ -78,7 +79,7 @@
     T((T_CALLED("nonl(%p)"), (void *) SP_PARM));
     if (0 == SP_PARM)
 	returnCode(ERR);
-    SP_PARM->_nl = FALSE;
+    IsNl(SP_PARM) = FALSE;
 #ifdef __EMX__
     _nc_flush();
     _fsetmode(NC_OUTPUT(SP_PARM), "b");
diff --git a/ncurses/base/lib_overlay.c b/ncurses/base/lib_overlay.c
index a206248..6d21c76 100644
--- a/ncurses/base/lib_overlay.c
+++ b/ncurses/base/lib_overlay.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2013 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 1998-2013,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,21 +41,19 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_overlay.c,v 1.31 2013/04/06 23:47:13 tom Exp $")
+MODULE_ID("$Id: lib_overlay.c,v 1.34 2023/09/16 16:39:07 tom Exp $")
 
 static int
 overlap(const WINDOW *const src, WINDOW *const dst, int const flag)
 {
     int rc = ERR;
-    int sx1, sy1, sx2, sy2;
-    int dx1, dy1, dx2, dy2;
-    int sminrow, smincol;
-    int dminrow, dmincol;
-    int dmaxrow, dmaxcol;
 
     T((T_CALLED("overlap(%p,%p,%d)"), (const void *) src, (void *) dst, flag));
 
     if (src != 0 && dst != 0) {
+	int sx1, sy1, sx2, sy2;
+	int dx1, dy1, dx2, dy2;
+
 	_nc_lock_global(curses);
 
 	T(("src : begy %ld, begx %ld, maxy %ld, maxx %ld",
@@ -79,12 +78,12 @@
 	dy2 = dy1 + dst->_maxy;
 
 	if (dx2 >= sx1 && dx1 <= sx2 && dy2 >= sy1 && dy1 <= sy2) {
-	    sminrow = max(sy1, dy1) - sy1;
-	    smincol = max(sx1, dx1) - sx1;
-	    dminrow = max(sy1, dy1) - dy1;
-	    dmincol = max(sx1, dx1) - dx1;
-	    dmaxrow = min(sy2, dy2) - dy1;
-	    dmaxcol = min(sx2, dx2) - dx1;
+	    int sminrow = Max(sy1, dy1) - sy1;
+	    int smincol = Max(sx1, dx1) - sx1;
+	    int dminrow = Max(sy1, dy1) - dy1;
+	    int dmincol = Max(sx1, dx1) - dx1;
+	    int dmaxrow = Min(sy2, dy2) - dy1;
+	    int dmaxcol = Min(sx2, dx2) - dx1;
 
 	    rc = copywin(src, dst,
 			 sminrow, smincol,
@@ -139,10 +138,6 @@
 	int over)
 {
     int rc = ERR;
-    int sx, sy, dx, dy;
-    bool touched;
-    attr_t bk;
-    attr_t mask;
 
     T((T_CALLED("copywin(%p, %p, %d, %d, %d, %d, %d, %d, %d)"),
        (const void *) src,
@@ -155,6 +150,9 @@
 	&& dst != 0
 	&& dmaxrow >= dminrow
 	&& dmaxcol >= dmincol) {
+	attr_t bk;
+	attr_t mask;
+
 	_nc_lock_global(curses);
 
 	bk = AttrOf(dst->_nc_bkgd);
@@ -163,18 +161,20 @@
 	/* make sure rectangle exists in source */
 	if ((sminrow + dmaxrow - dminrow) <= (src->_maxy + 1) &&
 	    (smincol + dmaxcol - dmincol) <= (src->_maxx + 1)) {
-	    bool copied = FALSE;
 
 	    T(("rectangle exists in source"));
 
 	    /* make sure rectangle fits in destination */
 	    if (dmaxrow <= dst->_maxy && dmaxcol <= dst->_maxx) {
+		int sx, sy, dx, dy;
+		bool copied = FALSE;
 
 		T(("rectangle fits in destination"));
 
 		for (dy = dminrow, sy = sminrow;
 		     dy <= dmaxrow;
 		     sy++, dy++) {
+		    bool touched;
 
 		    if (dy < 0 || sy < 0)
 			continue;
diff --git a/ncurses/base/lib_pad.c b/ncurses/base/lib_pad.c
index b87498b..d4bd7f1 100644
--- a/ncurses/base/lib_pad.c
+++ b/ncurses/base/lib_pad.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_pad.c,v 1.46 2010/04/24 23:50:45 tom Exp $")
+MODULE_ID("$Id: lib_pad.c,v 1.50 2021/10/23 22:57:27 tom Exp $")
 
 NCURSES_EXPORT(WINDOW *)
 NCURSES_SP_NAME(newpad) (NCURSES_SP_DCLx int l, int c)
@@ -89,7 +90,7 @@
     T((T_CALLED("subpad(%d, %d)"), l, c));
 
     if (orig) {
-	if (!(orig->_flags & _ISPAD)
+	if (!IS_PAD(orig)
 	    || ((win = derwin(orig, l, c, begy, begx)) == NULL))
 	    returnWin(0);
     }
@@ -145,7 +146,7 @@
     if (win == 0)
 	returnCode(ERR);
 
-    if (!(win->_flags & _ISPAD))
+    if (!IS_PAD(win))
 	returnCode(ERR);
 
     sp = _nc_screen_of(win);
@@ -188,6 +189,12 @@
 
     T(("pad being refreshed"));
 
+#ifdef TRACE
+    if (USE_TRACEF(TRACE_UPDATE)) {
+	_tracedump("...pad", win);
+	_nc_unlock_global(tracef);
+    }
+#endif /* TRACE */
 #if USE_SCROLL_HINTS
     if (win->_pad._pad_y >= 0) {
 	displaced = pminrow - win->_pad._pad_y
@@ -289,7 +296,7 @@
 
     /*
      * Use the pad's current position, if it will be visible.
-     * If not, don't do anything; it's not an error.
+     * If not, don't do anything; it is not an error.
      */
     if (win->_leaveok == FALSE
 	&& win->_cury >= pminrow
@@ -327,7 +334,7 @@
     if (pad == 0)
 	returnCode(ERR);
 
-    if (!(pad->_flags & _ISPAD))
+    if (!IS_PAD(pad))
 	returnCode(wechochar(pad, ch));
 
     waddch(pad, ch);
diff --git a/ncurses/base/lib_printw.c b/ncurses/base/lib_printw.c
index 56528f6..d901b72 100644
--- a/ncurses/base/lib_printw.c
+++ b/ncurses/base/lib_printw.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2012 Free Software Foundation, Inc.              *
+ * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 1998-2012,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,10 +40,10 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_printw.c,v 1.23 2012/09/03 17:55:28 tom Exp $")
+MODULE_ID("$Id: lib_printw.c,v 1.28 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
-printw(const char *fmt,...)
+printw(const char *fmt, ...)
 {
     va_list argp;
     int code;
@@ -56,14 +57,14 @@
 #endif
 
     va_start(argp, fmt);
-    code = vwprintw(stdscr, fmt, argp);
+    code = vw_printw(stdscr, fmt, argp);
     va_end(argp);
 
     returnCode(code);
 }
 
 NCURSES_EXPORT(int)
-wprintw(WINDOW *win, const char *fmt,...)
+wprintw(WINDOW *win, const char *fmt, ...)
 {
     va_list argp;
     int code;
@@ -77,16 +78,15 @@
 #endif
 
     va_start(argp, fmt);
-    code = vwprintw(win, fmt, argp);
+    code = vw_printw(win, fmt, argp);
     va_end(argp);
 
     returnCode(code);
 }
 
 NCURSES_EXPORT(int)
-mvprintw(int y, int x, const char *fmt,...)
+mvprintw(int y, int x, const char *fmt, ...)
 {
-    va_list argp;
     int code;
 
 #ifdef TRACE
@@ -98,17 +98,18 @@
 #endif
 
     if ((code = move(y, x)) != ERR) {
+	va_list argp;
+
 	va_start(argp, fmt);
-	code = vwprintw(stdscr, fmt, argp);
+	code = vw_printw(stdscr, fmt, argp);
 	va_end(argp);
     }
     returnCode(code);
 }
 
 NCURSES_EXPORT(int)
-mvwprintw(WINDOW *win, int y, int x, const char *fmt,...)
+mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...)
 {
-    va_list argp;
     int code;
 
 #ifdef TRACE
@@ -120,8 +121,10 @@
 #endif
 
     if ((code = wmove(win, y, x)) != ERR) {
+	va_list argp;
+
 	va_start(argp, fmt);
-	code = vwprintw(win, fmt, argp);
+	code = vw_printw(win, fmt, argp);
 	va_end(argp);
     }
     returnCode(code);
@@ -144,3 +147,21 @@
     }
     returnCode(code);
 }
+
+NCURSES_EXPORT(int)
+vw_printw(WINDOW *win, const char *fmt, va_list argp)
+{
+    char *buf;
+    int code = ERR;
+#if NCURSES_SP_FUNCS
+    SCREEN *sp = _nc_screen_of(win);
+#endif
+
+    T((T_CALLED("vw_printw(%p,%s,va_list)"), (void *) win, _nc_visbuf(fmt)));
+
+    buf = NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_ARGx fmt, argp);
+    if (buf != 0) {
+	code = waddstr(win, buf);
+    }
+    returnCode(code);
+}
diff --git a/ncurses/base/lib_redrawln.c b/ncurses/base/lib_redrawln.c
index 72905f8..c99d699 100644
--- a/ncurses/base/lib_redrawln.c
+++ b/ncurses/base/lib_redrawln.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_redrawln.c,v 1.17 2010/12/19 00:03:23 tom Exp $")
+MODULE_ID("$Id: lib_redrawln.c,v 1.18 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 wredrawln(WINDOW *win, int beg, int num)
diff --git a/ncurses/base/lib_refresh.c b/ncurses/base/lib_refresh.c
index a77bc48..bcaa462 100644
--- a/ncurses/base/lib_refresh.c
+++ b/ncurses/base/lib_refresh.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc.              *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2010,2011 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_refresh.c,v 1.45 2011/06/25 19:02:22 Vassili.Courzakis Exp $")
+MODULE_ID("$Id: lib_refresh.c,v 1.48 2023/05/27 20:13:10 tom Exp $")
 
 NCURSES_EXPORT(int)
 wrefresh(WINDOW *win)
@@ -91,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);
@@ -199,7 +208,6 @@
 	    });
 
 	    if_WIDEC({
-		static cchar_t blank = BLANK;
 		int last_dst = begx + ((last_src < win->_maxx)
 				       ? last_src
 				       : win->_maxx);
@@ -245,6 +253,7 @@
 		 */
 		if (fix_left < dst_col || fix_right > last_dst) {
 		    for (j = fix_left; j <= fix_right; ++j) {
+			static cchar_t blank = BLANK;
 			nline->text[j] = blank;
 			CHANGED_CELL(nline, j);
 		    }
diff --git a/ncurses/base/lib_restart.c b/ncurses/base/lib_restart.c
index 5bfb078..0c61cb7 100644
--- a/ncurses/base/lib_restart.c
+++ b/ncurses/base/lib_restart.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2015 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 1998-2012,2015 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -41,7 +42,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_restart.c,v 1.16 2015/06/27 18:12:15 tom Exp $")
+MODULE_ID("$Id: lib_restart.c,v 1.18 2023/04/29 19:01:25 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx
@@ -64,31 +65,28 @@
     if (TINFO_SETUP_TERM(&new_term, termp, filenum, errret, FALSE) != OK) {
 	result = ERR;
     } else if (SP_PARM != 0) {
-	int saveecho = SP_PARM->_echo;
-	int savecbreak = SP_PARM->_cbreak;
-	int saveraw = SP_PARM->_raw;
-	int savenl = SP_PARM->_nl;
+	TTY_FLAGS save_flags = SP_PARM->_tty_flags;
 
 #ifdef USE_TERM_DRIVER
 	SP_PARM->_term = new_term;
 #endif
-	if (saveecho) {
+	if (save_flags._echo) {
 	    NCURSES_SP_NAME(echo) (NCURSES_SP_ARG);
 	} else {
 	    NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG);
 	}
 
-	if (savecbreak) {
+	if (save_flags._cbreak) {
 	    NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG);
 	    NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG);
-	} else if (saveraw) {
+	} else if (save_flags._raw) {
 	    NCURSES_SP_NAME(nocbreak) (NCURSES_SP_ARG);
 	    NCURSES_SP_NAME(raw) (NCURSES_SP_ARG);
 	} else {
 	    NCURSES_SP_NAME(nocbreak) (NCURSES_SP_ARG);
 	    NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG);
 	}
-	if (savenl) {
+	if (save_flags._nl) {
 	    NCURSES_SP_NAME(nl) (NCURSES_SP_ARG);
 	} else {
 	    NCURSES_SP_NAME(nonl) (NCURSES_SP_ARG);
diff --git a/ncurses/base/lib_scanw.c b/ncurses/base/lib_scanw.c
index 637aa46..1ed36a5 100644
--- a/ncurses/base/lib_scanw.c
+++ b/ncurses/base/lib_scanw.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2011 Free Software Foundation, Inc.              *
+ * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 1998-2009,2011 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,21 +41,40 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_scanw.c,v 1.13 2011/10/22 16:31:35 tom Exp $")
+MODULE_ID("$Id: lib_scanw.c,v 1.19 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
-vwscanw(WINDOW *win, NCURSES_CONST char *fmt, va_list argp)
+vwscanw(WINDOW *win, const char *fmt, va_list argp)
 {
     char buf[BUFSIZ];
+    int code = ERR;
 
-    if (wgetnstr(win, buf, (int) sizeof(buf) - 1) == ERR)
-	return (ERR);
+    if (wgetnstr(win, buf, (int) sizeof(buf) - 1) != ERR) {
+	if ((code = vsscanf(buf, fmt, argp)) == EOF) {
+	    code = ERR;
+	}
+    }
 
-    return (vsscanf(buf, fmt, argp));
+    return code;
 }
 
 NCURSES_EXPORT(int)
-scanw(NCURSES_CONST char *fmt,...)
+vw_scanw(WINDOW *win, const char *fmt, va_list argp)
+{
+    char buf[BUFSIZ];
+    int code = ERR;
+
+    if (wgetnstr(win, buf, (int) sizeof(buf) - 1) != ERR) {
+	if ((code = vsscanf(buf, fmt, argp)) == EOF) {
+	    code = ERR;
+	}
+    }
+
+    return code;
+}
+
+NCURSES_EXPORT(int)
+scanw(const char *fmt, ...)
 {
     int code;
     va_list ap;
@@ -62,13 +82,13 @@
     T(("scanw(\"%s\",...) called", fmt));
 
     va_start(ap, fmt);
-    code = vwscanw(stdscr, fmt, ap);
+    code = vw_scanw(stdscr, fmt, ap);
     va_end(ap);
     return (code);
 }
 
 NCURSES_EXPORT(int)
-wscanw(WINDOW *win, NCURSES_CONST char *fmt,...)
+wscanw(WINDOW *win, const char *fmt, ...)
 {
     int code;
     va_list ap;
@@ -76,31 +96,31 @@
     T(("wscanw(%p,\"%s\",...) called", (void *) win, fmt));
 
     va_start(ap, fmt);
-    code = vwscanw(win, fmt, ap);
+    code = vw_scanw(win, fmt, ap);
     va_end(ap);
     return (code);
 }
 
 NCURSES_EXPORT(int)
-mvscanw(int y, int x, NCURSES_CONST char *fmt,...)
+mvscanw(int y, int x, const char *fmt, ...)
 {
     int code;
     va_list ap;
 
     va_start(ap, fmt);
-    code = (move(y, x) == OK) ? vwscanw(stdscr, fmt, ap) : ERR;
+    code = (move(y, x) == OK) ? vw_scanw(stdscr, fmt, ap) : ERR;
     va_end(ap);
     return (code);
 }
 
 NCURSES_EXPORT(int)
-mvwscanw(WINDOW *win, int y, int x, NCURSES_CONST char *fmt,...)
+mvwscanw(WINDOW *win, int y, int x, const char *fmt, ...)
 {
     int code;
     va_list ap;
 
     va_start(ap, fmt);
-    code = (wmove(win, y, x) == OK) ? vwscanw(win, fmt, ap) : ERR;
+    code = (wmove(win, y, x) == OK) ? vw_scanw(win, fmt, ap) : ERR;
     va_end(ap);
     return (code);
 }
diff --git a/ncurses/base/lib_screen.c b/ncurses/base/lib_screen.c
index a03ceec..e2647b5 100644
--- a/ncurses/base/lib_screen.c
+++ b/ncurses/base/lib_screen.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2015 Free Software Foundation, Inc.              *
+ * Copyright 2019-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -41,7 +42,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_screen.c,v 1.77 2015/07/04 22:54:14 tom Exp $")
+MODULE_ID("$Id: lib_screen.c,v 1.105 2023/04/28 20:58:54 tom Exp $")
 
 #define MAX_SIZE 0x3fff		/* 16k is big enough for a window or pad */
 
@@ -51,13 +52,22 @@
 #define L_CURL '{'
 #define R_CURL '}'
 
+#if USE_STRING_HACKS && HAVE_SNPRINTF
+#define ARG_SLIMIT(name) size_t name,
+#else
+#define ARG_SLIMIT(name)	/* nothing */
+#endif
+
+#define CUR_SLIMIT _nc_SLIMIT(limit - (size_t) (target - base))
+#define TOP_SLIMIT _nc_SLIMIT(sizeof(buffer))
+
 /*
- * Use 0x8888 as the magic number for new-format files, since it cannot be
+ * Use 0x888888 as the magic number for new-format files, since it cannot be
  * mistaken for the _cury/_curx pair of 16-bit numbers which start the old
  * format.  It happens to be unused in the file 5.22 database (2015/03/07).
  */
 static const char my_magic[] =
-{'\210', '\210', '\210', '\210'};
+{'\210', '\210', '\210', '\210', 0};
 
 #if NCURSES_EXT_PUTWIN
 typedef enum {
@@ -80,7 +90,6 @@
 typedef struct {
     const char name[17];
     PARAM_TYPE type;
-    size_t size;
     size_t offset;
 } SCR_PARAMS;
 
@@ -110,8 +119,7 @@
 };
 #undef DATA
 
-#define sizeof2(type,name) sizeof(((type *)0)->name)
-#define DATA(name, type) { { #name }, type, sizeof2(WINDOW, name), offsetof(WINDOW, name) }
+#define DATA(name, type) { { #name }, type, offsetof(WINDOW, name) }
 
 static const SCR_PARAMS scr_params[] =
 {
@@ -161,12 +169,12 @@
 read_txt(FILE *fp)
 {
     size_t limit = 1024;
-    size_t used = 0;
     char *result = malloc(limit);
     char *buffer;
 
     if (result != 0) {
 	int ch = 0;
+	size_t used = 0;
 
 	clearerr(fp);
 	result[used] = '\0';
@@ -190,7 +198,7 @@
 
 	if (ch == '\n') {
 	    result[--used] = '\0';
-	    T(("READ:%s", result));
+	    TR(TRACE_IEVENT, ("READ:%s", result));
 	} else if (used == 0) {
 	    free(result);
 	    result = 0;
@@ -204,7 +212,7 @@
 {
     bool found = FALSE;
 
-    T(("decode_attr   '%s'", source));
+    TR(TRACE_IEVENT, ("decode_attr   '%s'", source));
 
     while (*source) {
 	if (source[0] == MARKER && source[1] == L_CURL) {
@@ -262,7 +270,7 @@
     int base = 16;
     const char digits[] = "0123456789abcdef";
 
-    T(("decode_char   '%s'", source));
+    TR(TRACE_IEVENT, ("decode_char   '%s'", source));
     *target = ' ';
     switch (*source) {
     case MARKER:
@@ -319,7 +327,7 @@
     int color = PAIR_NUMBER((int) attr);
     int value;
 
-    T(("decode_chtype '%s'", source));
+    TR(TRACE_IEVENT, ("decode_chtype '%s'", source));
     source = decode_attr(source, &attr, &color);
     source = decode_char(source, &value);
     *target = (ChCharOf(value) | attr | (chtype) COLOR_PAIR(color));
@@ -337,7 +345,7 @@
     int append = 0;
     int value = 0;
 
-    T(("decode_cchar  '%s'", source));
+    TR(TRACE_IEVENT, ("decode_cchar  '%s'", source));
     *target = blank;
 #if NCURSES_EXT_COLORS
     color = fillin->ext_color;
@@ -356,7 +364,7 @@
 	    chars[append] = (wchar_t) value;
 	}
     }
-    setcchar(target, chars, attr, (short) color, NULL);
+    setcchar(target, chars, attr, (short) color, &color);
     return source;
 }
 #endif
@@ -365,9 +373,6 @@
 read_win(WINDOW *win, FILE *fp)
 {
     int code = ERR;
-    char *txt;
-    char *name;
-    char *value;
     size_t n;
     int color;
 #if NCURSES_WIDECHAR
@@ -377,7 +382,10 @@
 
     memset(win, 0, sizeof(WINDOW));
     for (;;) {
-	txt = read_txt(fp);
+	char *name;
+	char *value;
+	char *txt = read_txt(fp);
+
 	if (txt == 0)
 	    break;
 	if (!strcmp(txt, "rows:")) {
@@ -431,14 +439,17 @@
 }
 
 static int
-read_row(char *source, NCURSES_CH_T * prior, NCURSES_CH_T * target, int length)
+read_row(char *source, NCURSES_CH_T *prior, NCURSES_CH_T *target, int length)
 {
     while (*source != '\0' && length > 0) {
 #if NCURSES_WIDECHAR
-	int n, len;
+	int len;
+
 	source = decode_cchar(source, prior, target);
-	len = wcwidth(target->chars[0]);
+	len = _nc_wacs_width(target->chars[0]);
 	if (len > 1) {
+	    int n;
+
 	    SetWidecExt(CHDEREF(target), 0);
 	    for (n = 1; n < len; ++n) {
 		target[n] = target[0];
@@ -490,7 +501,6 @@
 NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep)
 {
     WINDOW tmp, *nwin;
-    int n;
     bool old_format = FALSE;
 
     T((T_CALLED("getwin(%p)"), (void *) filep));
@@ -503,13 +513,13 @@
      * Read the first 4 bytes to determine first if this is an old-format
      * screen-dump, or new-format.
      */
-    if (read_block(&tmp, 4, filep) < 0) {
+    if (read_block(&tmp, (size_t) 4, filep) < 0) {
 	returnWin(0);
     }
     /*
      * If this is a new-format file, and we do not support it, give up.
      */
-    if (!memcmp(&tmp, my_magic, 4)) {
+    if (!memcmp(&tmp, my_magic, (size_t) 4)) {
 #if NCURSES_EXT_PUTWIN
 	if (read_win(&tmp, filep) < 0)
 #endif
@@ -530,7 +540,7 @@
 	returnWin(0);
     }
 
-    if (tmp._flags & _ISPAD) {
+    if (IS_PAD(&tmp)) {
 	nwin = NCURSES_SP_NAME(newpad) (NCURSES_SP_ARGx
 					tmp._maxy + 1,
 					tmp._maxx + 1);
@@ -546,6 +556,7 @@
      * made sense is probably gone.
      */
     if (nwin != 0) {
+	int n;
 	size_t linesize = sizeof(NCURSES_CH_T) * (size_t) (tmp._maxx + 1);
 
 	nwin->_curx = tmp._curx;
@@ -574,7 +585,7 @@
 	nwin->_regtop = tmp._regtop;
 	nwin->_regbottom = tmp._regbottom;
 
-	if (tmp._flags & _ISPAD)
+	if (IS_PAD(&tmp))
 	    nwin->_pad = tmp._pad;
 
 	if (old_format) {
@@ -588,7 +599,7 @@
 	}
 #if NCURSES_EXT_PUTWIN
 	else {
-	    char *txt;
+	    char *txt = 0;
 	    bool success = TRUE;
 	    NCURSES_CH_T prior = blank;
 
@@ -641,13 +652,20 @@
 
 #if NCURSES_EXT_PUTWIN
 static void
-encode_attr(char *target, attr_t source, attr_t prior)
+encode_attr(char *target, ARG_SLIMIT(limit)
+	    attr_t source,
+	    attr_t prior,
+	    int source_color,
+	    int prior_color)
 {
+#if USE_STRING_HACKS && HAVE_SNPRINTF
+    char *base = target;
+#endif
     source &= ~A_CHARTEXT;
     prior &= ~A_CHARTEXT;
 
     *target = '\0';
-    if (source != prior) {
+    if ((source != prior) || (source_color != prior_color)) {
 	size_t n;
 	bool first = TRUE;
 
@@ -663,14 +681,14 @@
 		} else {
 		    *target++ = '|';
 		}
-		strcpy(target, scr_attrs[n].name);
+		_nc_STRCPY(target, scr_attrs[n].name, limit);
 		target += strlen(target);
 	    }
 	}
-	if ((source & A_COLOR) != (prior & A_COLOR)) {
+	if (source_color != prior_color) {
 	    if (!first)
 		*target++ = '|';
-	    sprintf(target, "C%d", PAIR_NUMBER((int) source));
+	    _nc_SPRINTF(target, CUR_SLIMIT "C%d", source_color);
 	    target += strlen(target);
 	}
 
@@ -680,19 +698,29 @@
 }
 
 static void
-encode_cell(char *target, CARG_CH_T source, CARG_CH_T previous)
+encode_cell(char *target, ARG_SLIMIT(limit) CARG_CH_T source, CARG_CH_T previous)
 {
+#if USE_STRING_HACKS && HAVE_SNPRINTF
+    char *base = target;
+#endif
 #if NCURSES_WIDECHAR
     size_t n;
+    int source_pair = GetPair(*source);
+    int previous_pair = GetPair(*previous);
 
     *target = '\0';
-    if (previous->attr != source->attr) {
-	encode_attr(target, source->attr, previous->attr);
+    if ((previous->attr != source->attr) || (previous_pair != source_pair)) {
+	encode_attr(target, CUR_SLIMIT
+		    source->attr,
+		    previous->attr,
+		    source_pair,
+		    previous_pair);
     }
     target += strlen(target);
 #if NCURSES_EXT_COLORS
     if (previous->ext_color != source->ext_color) {
-	sprintf(target, "%c%cC%d%c", MARKER, L_CURL, source->ext_color, R_CURL);
+	_nc_SPRINTF(target, CUR_SLIMIT
+		    "%c%cC%d%c", MARKER, L_CURL, source->ext_color, R_CURL);
     }
 #endif
     for (n = 0; n < SIZEOF(source->chars); ++n) {
@@ -705,22 +733,23 @@
 	}
 	*target++ = MARKER;
 	if (uch > 0xffff) {
-	    sprintf(target, "U%08x", uch);
+	    _nc_SPRINTF(target, CUR_SLIMIT "U%08x", uch);
 	} else if (uch > 0xff) {
-	    sprintf(target, "u%04x", uch);
+	    _nc_SPRINTF(target, CUR_SLIMIT "u%04x", uch);
 	} else if (uch < 32 || uch >= 127) {
-	    sprintf(target, "%03o", uch & 0xff);
+	    _nc_SPRINTF(target, CUR_SLIMIT "%03o", uch & 0xff);
 	} else {
 	    switch (uch) {
 	    case ' ':
-		strcpy(target, "s");
+		_nc_STRCPY(target, "s", limit);
 		break;
 	    case MARKER:
 		*target++ = MARKER;
 		*target = '\0';
 		break;
 	    default:
-		sprintf(--target, "%c", uch);
+		--target;
+		_nc_SPRINTF(target, CUR_SLIMIT "%c", uch);
 		break;
 	    }
 	}
@@ -731,27 +760,31 @@
 
     *target = '\0';
     if (AttrOfD(previous) != AttrOfD(source)) {
-	encode_attr(target, AttrOfD(source), AttrOfD(previous));
+	encode_attr(target, CUR_SLIMIT
+		    AttrOfD(source),
+		    AttrOfD(previous),
+		    GetPair(source),
+		    GetPair(previous));
     }
     target += strlen(target);
     *target++ = MARKER;
     if (ch < 32 || ch >= 127) {
-	sprintf(target, "%03o", UChar(ch));
+	_nc_SPRINTF(target, CUR_SLIMIT "%03o", UChar(ch));
     } else {
 	switch (ch) {
 	case ' ':
-	    strcpy(target, "s");
+	    _nc_STRCPY(target, "s", limit);
 	    break;
 	case MARKER:
 	    *target++ = MARKER;
 	    *target = '\0';
 	    break;
 	default:
-	    sprintf(--target, "%c", UChar(ch));
+	    --target;
+	    _nc_SPRINTF(target, CUR_SLIMIT "%c", UChar(ch));
 	    break;
 	}
     }
-    target += strlen(target);
 #endif
 }
 #endif
@@ -760,7 +793,6 @@
 putwin(WINDOW *win, FILE *filep)
 {
     int code = ERR;
-    int y;
 
     T((T_CALLED("putwin(%p,%p)"), (void *) win, (void *) filep));
 
@@ -769,6 +801,7 @@
 	const char *version = curses_version();
 	char buffer[1024];
 	NCURSES_CH_T last_cell;
+	int y;
 
 	memset(&last_cell, 0, sizeof(last_cell));
 
@@ -786,43 +819,58 @@
 	    const char *name = scr_params[y].name;
 	    const char *data = (char *) win + scr_params[y].offset;
 	    const void *dp = (const void *) data;
+	    attr_t attr;
 
 	    *buffer = '\0';
-	    if (!strncmp(name, "_pad.", 5) && !(win->_flags & _ISPAD)) {
+	    if (!strncmp(name, "_pad.", (size_t) 5) && !IS_PAD(win)) {
 		continue;
 	    }
 	    switch (scr_params[y].type) {
 	    case pATTR:
-		encode_attr(buffer, (*(const attr_t *) dp) & ~A_CHARTEXT, A_NORMAL);
+		attr = (*(const attr_t *) dp) & ~A_CHARTEXT;
+		encode_attr(buffer, TOP_SLIMIT
+			    (*(const attr_t *) dp) & ~A_CHARTEXT,
+			    A_NORMAL,
+			    COLOR_PAIR((int) attr),
+			    0);
 		break;
 	    case pBOOL:
 		if (!(*(const bool *) data)) {
 		    continue;
 		}
-		strcpy(buffer, name);
+		_nc_STRCPY(buffer, name, sizeof(buffer));
 		name = "flag";
 		break;
 	    case pCHAR:
-		encode_attr(buffer, *(const attr_t *) dp, A_NORMAL);
+		attr = (*(const attr_t *) dp);
+		encode_attr(buffer, TOP_SLIMIT
+			    * (const attr_t *) dp,
+			    A_NORMAL,
+			    COLOR_PAIR((int) attr),
+			    0);
 		break;
 	    case pINT:
 		if (!(*(const int *) dp))
 		    continue;
-		sprintf(buffer, "%d", *(const int *) dp);
+		_nc_SPRINTF(buffer, TOP_SLIMIT
+			    "%d", *(const int *) dp);
 		break;
 	    case pSHORT:
 		if (!(*(const short *) dp))
 		    continue;
-		sprintf(buffer, "%d", *(const short *) dp);
+		_nc_SPRINTF(buffer, TOP_SLIMIT
+			    "%d", *(const short *) dp);
 		break;
 	    case pSIZE:
 		if (!(*(const NCURSES_SIZE_T *) dp))
 		    continue;
-		sprintf(buffer, "%d", *(const NCURSES_SIZE_T *) dp);
+		_nc_SPRINTF(buffer, TOP_SLIMIT
+			    "%d", *(const NCURSES_SIZE_T *) dp);
 		break;
 #if NCURSES_WIDECHAR
 	    case pCCHAR:
-		encode_cell(buffer, (CARG_CH_T) dp, CHREF(last_cell));
+		encode_cell(buffer, TOP_SLIMIT
+			    (CARG_CH_T) dp, CHREF(last_cell));
 		break;
 #endif
 	    }
@@ -845,20 +893,21 @@
 		returnCode(code);
 	    for (x = 0; x <= win->_maxx; x++) {
 #if NCURSES_WIDECHAR
-		int len = wcwidth(data[x].chars[0]);
-		encode_cell(buffer, CHREF(data[x]), CHREF(last_cell));
+		int len = _nc_wacs_width(data[x].chars[0]);
+		encode_cell(buffer, TOP_SLIMIT CHREF(data[x]), CHREF(last_cell));
 		last_cell = data[x];
 		PUTS(buffer);
 		if (len > 1)
 		    x += (len - 1);
 #else
-		encode_cell(buffer, CHREF(data[x]), CHREF(last_cell));
+		encode_cell(buffer, TOP_SLIMIT CHREF(data[x]), CHREF(last_cell));
 		last_cell = data[x];
 		PUTS(buffer);
 #endif
 	    }
 	    PUTS("\n");
 	}
+	code = OK;
     }
 #else
     /*
@@ -869,6 +918,7 @@
      */
     if (win != 0) {
 	size_t len = (size_t) (win->_maxx + 1);
+	int y;
 
 	clearerr(filep);
 	if (fwrite(win, sizeof(WINDOW), (size_t) 1, filep) != 1
@@ -888,6 +938,31 @@
     returnCode(code);
 }
 
+/*
+ * Replace a window covering the whole screen, i.e., newscr or curscr.
+ */
+static WINDOW *
+replace_window(WINDOW *target, FILE *source)
+{
+    WINDOW *result = getwin(source);
+#if NCURSES_EXT_FUNCS
+    if (result != NULL) {
+	if (getmaxx(result) != getmaxx(target)
+	    || getmaxy(result) != getmaxy(target)) {
+	    int code = wresize(result,
+			       1 + getmaxy(target),
+			       1 + getmaxx(target));
+	    if (code != OK) {
+		delwin(result);
+		result = NULL;
+	    }
+	}
+    }
+#endif
+    delwin(target);
+    return result;
+}
+
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(scr_restore) (NCURSES_SP_DCLx const char *file)
 {
@@ -897,9 +972,8 @@
     T((T_CALLED("scr_restore(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));
 
     if (_nc_access(file, R_OK) >= 0
-	&& (fp = fopen(file, "rb")) != 0) {
-	delwin(NewScreen(SP_PARM));
-	NewScreen(SP_PARM) = getwin(fp);
+	&& (fp = safe_fopen(file, BIN_R)) != 0) {
+	NewScreen(SP_PARM) = replace_window(NewScreen(SP_PARM), fp);
 #if !USE_REENTRANT
 	newscr = NewScreen(SP_PARM);
 #endif
@@ -928,7 +1002,7 @@
     T((T_CALLED("scr_dump(%s)"), _nc_visbuf(file)));
 
     if (_nc_access(file, W_OK) < 0
-	|| (fp = fopen(file, "wb")) == 0) {
+	|| (fp = safe_fopen(file, BIN_W)) == 0) {
 	result = ERR;
     } else {
 	(void) putwin(newscr, fp);
@@ -941,7 +1015,6 @@
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(scr_init) (NCURSES_SP_DCLx const char *file)
 {
-    FILE *fp = 0;
     int code = ERR;
 
     T((T_CALLED("scr_init(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));
@@ -953,10 +1026,11 @@
 	!(exit_ca_mode && non_rev_rmcup)
 #endif
 	) {
+	FILE *fp = 0;
+
 	if (_nc_access(file, R_OK) >= 0
-	    && (fp = fopen(file, "rb")) != 0) {
-	    delwin(CurScreen(SP_PARM));
-	    CurScreen(SP_PARM) = getwin(fp);
+	    && (fp = safe_fopen(file, BIN_R)) != 0) {
+	    CurScreen(SP_PARM) = replace_window(CurScreen(SP_PARM), fp);
 #if !USE_REENTRANT
 	    curscr = CurScreen(SP_PARM);
 #endif
diff --git a/ncurses/base/lib_scroll.c b/ncurses/base/lib_scroll.c
index 8684e25..ecc0ba5 100644
--- a/ncurses/base/lib_scroll.c
+++ b/ncurses/base/lib_scroll.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc.              *
+ * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2010,2011 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -43,7 +44,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_scroll.c,v 1.29 2011/10/22 16:34:50 tom Exp $")
+MODULE_ID("$Id: lib_scroll.c,v 1.32 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(void)
 _nc_scroll_window(WINDOW *win,
@@ -77,11 +78,13 @@
      * setup cost.  So there is no point in trying to be excessively
      * clever -- esr.
      */
+#define BottomLimit(n) ((n) >= 0 && (n) >= top)
+#define TopLimit(n)    ((n) <= win->_maxy && (n) <= bottom)
 
     /* shift n lines downwards */
     if (n < 0) {
 	limit = top - n;
-	for (line = bottom; line >= limit && line >= 0; line--) {
+	for (line = bottom; line >= limit && BottomLimit(line); line--) {
 	    TR(TRACE_MOVE, ("...copying %d to %d", line + n, line));
 	    memcpy(win->_line[line].text,
 		   win->_line[line + n].text,
@@ -89,7 +92,7 @@
 	    if_USE_SCROLL_HINTS(win->_line[line].oldindex =
 				win->_line[line + n].oldindex);
 	}
-	for (line = top; line < limit && line <= win->_maxy; line++) {
+	for (line = top; line < limit && TopLimit(line); line++) {
 	    TR(TRACE_MOVE, ("...filling %d", line));
 	    for (j = 0; j <= win->_maxx; j++)
 		win->_line[line].text[j] = blank;
@@ -100,14 +103,14 @@
     /* shift n lines upwards */
     if (n > 0) {
 	limit = bottom - n;
-	for (line = top; line <= limit && line <= win->_maxy; line++) {
+	for (line = top; line <= limit && TopLimit(line); line++) {
 	    memcpy(win->_line[line].text,
 		   win->_line[line + n].text,
 		   to_copy);
 	    if_USE_SCROLL_HINTS(win->_line[line].oldindex =
 				win->_line[line + n].oldindex);
 	}
-	for (line = bottom; line > limit && line >= 0; line--) {
+	for (line = bottom; line > limit && BottomLimit(line); line--) {
 	    for (j = 0; j <= win->_maxx; j++)
 		win->_line[line].text[j] = blank;
 	    if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX);
diff --git a/ncurses/base/lib_scrollok.c b/ncurses/base/lib_scrollok.c
index 6a698a3..c9462c3 100644
--- a/ncurses/base/lib_scrollok.c
+++ b/ncurses/base/lib_scrollok.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2000,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_scrollok.c,v 1.5 2009/10/24 22:35:38 tom Exp $")
+MODULE_ID("$Id: lib_scrollok.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 scrollok(WINDOW *win, bool flag)
diff --git a/ncurses/base/lib_scrreg.c b/ncurses/base/lib_scrreg.c
index 546fbc1..5207f6f 100644
--- a/ncurses/base/lib_scrreg.c
+++ b/ncurses/base/lib_scrreg.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2000,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_scrreg.c,v 1.11 2009/10/24 22:35:28 tom Exp $")
+MODULE_ID("$Id: lib_scrreg.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 wsetscrreg(WINDOW *win, int top, int bottom)
diff --git a/ncurses/base/lib_set_term.c b/ncurses/base/lib_set_term.c
index f787a88..78de859 100644
--- a/ncurses/base/lib_set_term.c
+++ b/ncurses/base/lib_set_term.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
+ * 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  *
  * copy of this software and associated documentation files (the            *
@@ -40,14 +41,23 @@
 **
 */
 
+#define NEW_PAIR_INTERNAL 1
+
 #include <curses.priv.h>
 #include <tic.h>
+#include <new_pair.h>
 
-#ifndef CUR
-#define CUR SP_TERMTYPE
+#if USE_GPM_SUPPORT
+#ifdef HAVE_LIBDL
+/* use dynamic loader to avoid linkage dependency */
+#include <dlfcn.h>
+#endif
 #endif
 
-MODULE_ID("$Id: lib_set_term.c,v 1.153 2015/08/07 23:57:58 tom Exp $")
+#undef CUR
+#define CUR SP_TERMTYPE
+
+MODULE_ID("$Id: lib_set_term.c,v 1.184 2022/12/10 21:34:12 tom Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define MaxColors      InfoOf(sp).maxcolors
@@ -134,15 +144,17 @@
 NCURSES_EXPORT(void)
 delscreen(SCREEN *sp)
 {
-    int i;
 
     T((T_CALLED("delscreen(%p)"), (void *) sp));
 
     _nc_lock_global(curses);
     if (delink_screen(sp)) {
+	WINDOWLIST *wl;
+	bool is_current = (sp == CURRENT_SCREEN);
+
 #ifdef USE_SP_RIPOFF
-	ripoff_t *rop;
 	if (safe_ripoff_sp && safe_ripoff_sp != safe_ripoff_stack) {
+	    ripoff_t *rop;
 	    for (rop = safe_ripoff_stack;
 		 rop != safe_ripoff_sp && (rop - safe_ripoff_stack) < N_RIPS;
 		 rop++) {
@@ -154,12 +166,19 @@
 	}
 #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) {
+
 	    if (sp->_slk->ent != 0) {
+		int i;
+
 		for (i = 0; i < sp->_slk->labcnt; ++i) {
 		    FreeIfNeeded(sp->_slk->ent[i].ent_text);
 		    FreeIfNeeded(sp->_slk->ent[i].form_text);
@@ -178,9 +197,11 @@
 
 	FreeIfNeeded(sp->_current_attr);
 
+	_nc_free_ordered_pairs(sp);
 	FreeIfNeeded(sp->_color_table);
 	FreeIfNeeded(sp->_color_pairs);
 
+	FreeIfNeeded(sp->_oldnum_list);
 	FreeIfNeeded(sp->oldhash);
 	FreeIfNeeded(sp->newhash);
 	FreeIfNeeded(sp->hashtab);
@@ -191,6 +212,17 @@
 	NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
 	NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx sp->_term);
 	FreeIfNeeded(sp->out_buffer);
+	if (_nc_find_prescr() == sp) {
+	    _nc_forget_prescr();
+	}
+#if USE_GPM_SUPPORT
+#ifdef HAVE_LIBDL
+	if (sp->_dlopen_gpm != 0) {
+	    dlclose(sp->_dlopen_gpm);
+	    sp->_dlopen_gpm = 0;
+	}
+#endif
+#endif /* USE_GPM_SUPPORT */
 	free(sp);
 
 	/*
@@ -198,7 +230,7 @@
 	 * 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;
@@ -213,6 +245,8 @@
 		_nc_wacs = 0;
 	    }
 #endif
+	} else {
+	    set_term(CURRENT_SCREEN);
 	}
     }
     _nc_unlock_global(curses);
@@ -259,7 +293,7 @@
     if ((dst = tmp) == 0) {
 	dst = src;
     } else if (value >= 0) {
-	*result = value;
+	*result = (int) value;
     }
     while (*dst != 0 && *dst != ';')
 	dst++;
@@ -284,9 +318,11 @@
 				     int filtered,
 				     int slk_format)
 {
+#ifndef USE_TERM_DRIVER
+    static const TTY null_TTY;	/* all zeros iff uninitialized */
+#endif
     char *env;
     int bottom_stolen = 0;
-    ripoff_t *rop;
     SCREEN *sp;
 #ifndef USE_TERM_DRIVER
     bool support_cookies = USE_XMC_SUPPORT;
@@ -303,11 +339,17 @@
 
     if (!sp) {
 	sp = _nc_alloc_screen_sp();
+	T(("_nc_alloc_screen_sp %p", (void *) sp));
 	*spp = sp;
     }
-    if (!sp
-	|| ((sp->_acs_map = typeCalloc(chtype, ACS_LEN)) == 0)
-	|| ((sp->_screen_acs_map = typeCalloc(bool, ACS_LEN)) == 0)) {
+    if (sp == NULL) {
+	ReturnScreenError();
+    }
+    if ((sp->_acs_map = typeCalloc(chtype, ACS_LEN)) == NULL) {
+	ReturnScreenError();
+    }
+    if ((sp->_screen_acs_map = typeCalloc(bool, ACS_LEN)) == NULL) {
+	free(sp->_acs_map);
 	ReturnScreenError();
     }
 
@@ -331,8 +373,9 @@
     sp->_next_screen = _nc_screen_chain;
     _nc_screen_chain = sp;
 
-    if ((sp->_current_attr = typeCalloc(NCURSES_CH_T, 1)) == 0)
+    if ((sp->_current_attr = typeCalloc(NCURSES_CH_T, 1)) == 0) {
 	returnCode(ERR);
+    }
 #endif
 
     /*
@@ -361,13 +404,19 @@
 #ifdef USE_TERM_DRIVER
 	CallDriver(sp, td_setfilter);
 #else
-	clear_screen = 0;
-	cursor_down = parm_down_cursor = 0;
-	cursor_address = 0;
-	cursor_up = parm_up_cursor = 0;
-	row_address = 0;
+	/* *INDENT-EQLS* */
+	clear_screen     = ABSENT_STRING;
+	cursor_address   = ABSENT_STRING;
+	cursor_down      = ABSENT_STRING;
+	cursor_up        = ABSENT_STRING;
+	parm_down_cursor = ABSENT_STRING;
+	parm_up_cursor   = ABSENT_STRING;
+	row_address      = ABSENT_STRING;
+	cursor_home      = carriage_return;
 
-	cursor_home = carriage_return;
+	if (back_color_erase)
+	    clr_eos = ABSENT_STRING;
+
 #endif
 	T(("filter screensize %dx%d", slines, scolumns));
     }
@@ -376,7 +425,11 @@
     fflush(output);
     setmode(output, O_BINARY);
 #endif
-    NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_ARGx output, TRUE);
+#if defined(EXP_WIN32_DRIVER)
+    T(("setting output mode to binary"));
+    fflush(output);
+    _setmode(fileno(output), _O_BINARY);
+#endif
     sp->_lines = (NCURSES_SIZE_T) slines;
     sp->_lines_avail = (NCURSES_SIZE_T) slines;
     sp->_columns = (NCURSES_SIZE_T) scolumns;
@@ -384,6 +437,10 @@
     fflush(output);
     sp->_ofd = output ? fileno(output) : -1;
     sp->_ofp = output;
+#if defined(EXP_WIN32_DRIVER)
+    if (output)
+	_setmode(fileno(output), _O_BINARY);
+#endif
     sp->out_limit = (size_t) ((2 + slines) * (6 + scolumns));
     if ((sp->out_buffer = malloc(sp->out_limit)) == 0)
 	sp->out_limit = 0;
@@ -419,8 +476,8 @@
     sp->_default_fg = COLOR_WHITE;
     sp->_default_bg = COLOR_BLACK;
 #else
-    sp->_default_fg = C_MASK;
-    sp->_default_bg = C_MASK;
+    sp->_default_fg = COLOR_DEFAULT;
+    sp->_default_bg = COLOR_DEFAULT;
 #endif
 
     /*
@@ -432,9 +489,9 @@
 	char sep1, sep2;
 	int count = sscanf(env, "%d%c%d%c", &fg, &sep1, &bg, &sep2);
 	if (count >= 1) {
-	    sp->_default_fg = ((fg >= 0 && fg < MaxColors) ? fg : C_MASK);
+	    sp->_default_fg = ((fg >= 0 && fg < MaxColors) ? fg : COLOR_DEFAULT);
 	    if (count >= 3) {
-		sp->_default_bg = ((bg >= 0 && bg < MaxColors) ? bg : C_MASK);
+		sp->_default_bg = ((bg >= 0 && bg < MaxColors) ? bg : COLOR_DEFAULT);
 	    }
 	    TR(TRACE_CHARPUT | TRACE_MOVE,
 	       ("from environment assumed fg=%d, bg=%d",
@@ -455,7 +512,7 @@
 	p = extract_fgbg(p, &(sp->_default_fg));
 	p = extract_fgbg(p, &(sp->_default_bg));
 	if (*p)			/* assume rxvt was compiled with xpm support */
-	    p = extract_fgbg(p, &(sp->_default_bg));
+	    extract_fgbg(p, &(sp->_default_bg));
 	TR(TRACE_CHARPUT | TRACE_MOVE, ("decoded fg=%d, bg=%d",
 					sp->_default_fg, sp->_default_bg));
 	if (sp->_default_fg >= MaxColors) {
@@ -627,10 +684,22 @@
     NewScreen(sp)->_clear = TRUE;
     CurScreen(sp)->_clear = FALSE;
 
-    NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_ARG);
-    NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_ARG);
+    /*
+     * Get the current tty-modes. setupterm() may already have done this,
+     * unless we use the term-driver.
+     */
+#ifndef USE_TERM_DRIVER
+    if (cur_term != 0 &&
+	!memcmp(&cur_term->Ottyb, &null_TTY, sizeof(TTY)))
+#endif
+    {
+	NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_ARG);
+	NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_ARG);
+    }
 
     if (safe_ripoff_sp && safe_ripoff_sp != safe_ripoff_stack) {
+	ripoff_t *rop;
+
 	for (rop = safe_ripoff_stack;
 	     rop != safe_ripoff_sp && (rop - safe_ripoff_stack) < N_RIPS;
 	     rop++) {
@@ -640,6 +709,9 @@
 	       formats (4-4 or 3-2-3) for which there may be some hardware
 	       support. */
 	    if (rop->hook == _nc_slk_initialize) {
+		if (!TerminalOf(sp)) {
+		    continue;
+		}
 		if (!(NumLabels <= 0 || !SLK_STDFMT(slk_format))) {
 		    continue;
 		}
@@ -679,6 +751,7 @@
     }
 
     T(("creating stdscr"));
+    (void) bottom_stolen;
     assert((sp->_lines_avail + sp->_topstolen + bottom_stolen) == slines);
     if ((StdScreen(sp) = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx
 						  sp->_lines_avail,
@@ -724,9 +797,12 @@
 				 int (*init) (WINDOW *, int))
 {
     int code = ERR;
+    TR_FUNC_BFR(1);
 
     START_TRACE();
-    T((T_CALLED("ripoffline(%p,%d,%p)"), (void *) SP_PARM, line, init));
+    T((T_CALLED("ripoffline(%p,%d,%s)"),
+       (void *) SP_PARM, line,
+       TR_FUNC_ARG(0, init)));
 
 #if NCURSES_SP_FUNCS
     if (SP_PARM != 0 && SP_PARM->_prescreen)
@@ -735,12 +811,15 @@
 	if (line == 0) {
 	    code = OK;
 	} else {
-	    if (safe_ripoff_sp == 0)
+	    if (safe_ripoff_sp == 0) {
 		safe_ripoff_sp = safe_ripoff_stack;
+	    }
 	    if (safe_ripoff_sp < safe_ripoff_stack + N_RIPS) {
 		safe_ripoff_sp->line = line;
 		safe_ripoff_sp->hook = init;
 		(safe_ripoff_sp)++;
+		T(("ripped-off %d:%d chunks",
+		   (int) (safe_ripoff_sp - safe_ripoff_stack), N_RIPS));
 		code = OK;
 	    }
 	}
@@ -753,7 +832,15 @@
 NCURSES_EXPORT(int)
 _nc_ripoffline(int line, int (*init) (WINDOW *, int))
 {
-    return NCURSES_SP_NAME(_nc_ripoffline) (CURRENT_SCREEN_PRE, line, init);
+    int rc;
+
+    _nc_init_pthreads();
+    _nc_lock_global(prescreen);
+    START_TRACE();
+    rc = NCURSES_SP_NAME(_nc_ripoffline) (CURRENT_SCREEN_PRE, line, init);
+    _nc_unlock_global(prescreen);
+
+    return rc;
 }
 #endif
 
@@ -772,6 +859,14 @@
 NCURSES_EXPORT(int)
 ripoffline(int line, int (*init) (WINDOW *, int))
 {
-    return NCURSES_SP_NAME(ripoffline) (CURRENT_SCREEN_PRE, line, init);
+    int rc;
+
+    _nc_init_pthreads();
+    _nc_lock_global(prescreen);
+    START_TRACE();
+    rc = NCURSES_SP_NAME(ripoffline) (CURRENT_SCREEN_PRE, line, init);
+    _nc_unlock_global(prescreen);
+
+    return rc;
 }
 #endif
diff --git a/ncurses/base/lib_slk.c b/ncurses/base/lib_slk.c
index 84f17ae..47e57e0 100644
--- a/ncurses/base/lib_slk.c
+++ b/ncurses/base/lib_slk.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 1998-2010,2011 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -47,7 +48,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_slk.c,v 1.48 2011/03/05 21:21:52 tom Exp $")
+MODULE_ID("$Id: lib_slk.c,v 1.50 2022/08/20 18:29:22 tom Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define NumLabels    InfoOf(SP_PARM).numlabels
@@ -186,8 +187,10 @@
 	|| SP_PARM->_slk->labcnt <= 0
 	|| (SP_PARM->_slk->ent = typeCalloc(slk_ent,
 					    (size_t) SP_PARM->_slk->labcnt))
-	== NULL)
+	== NULL) {
+	free(SP_PARM->_slk->ent);
 	returnCode(slk_failed(NCURSES_SP_ARG));
+    }
 
     max_length = (size_t) SP_PARM->_slk->maxlen;
     for (i = 0; i < SP_PARM->_slk->labcnt; i++) {
diff --git a/ncurses/base/lib_slkatr_set.c b/ncurses/base/lib_slkatr_set.c
index a3132e9..7c5a23a 100644
--- a/ncurses/base/lib_slkatr_set.c
+++ b/ncurses/base/lib_slkatr_set.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -38,30 +39,31 @@
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slkatr_set.c,v 1.15 2014/02/01 22:10:42 tom Exp $")
+MODULE_ID("$Id: lib_slkatr_set.c,v 1.17 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(slk_attr_set) (NCURSES_SP_DCLx
 			       const attr_t attr,
-			       NCURSES_PAIRS_T color_pair_number,
+			       NCURSES_PAIRS_T pair_arg,
 			       void *opts)
 {
     int code = ERR;
+    int color_pair = pair_arg;
 
     T((T_CALLED("slk_attr_set(%p,%s,%d)"),
        (void *) SP_PARM,
        _traceattr(attr),
-       (int) color_pair_number));
+       color_pair));
 
+    set_extended_pair(opts, color_pair);
     if (SP_PARM != 0
 	&& SP_PARM->_slk != 0
-	&& !opts
-	&& color_pair_number >= 0
-	&& color_pair_number < SP_PARM->_pair_limit) {
+	&& color_pair >= 0
+	&& color_pair < SP_PARM->_pair_limit) {
 	TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP_PARM->_slk->attr))));
 	SetAttr(SP_PARM->_slk->attr, attr);
-	if (color_pair_number > 0) {
-	    SetPair(SP_PARM->_slk->attr, color_pair_number);
+	if (color_pair > 0) {
+	    SetPair(SP_PARM->_slk->attr, color_pair);
 	}
 	TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP_PARM->_slk->attr))));
 	code = OK;
@@ -71,9 +73,9 @@
 
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(int)
-slk_attr_set(const attr_t attr, NCURSES_COLOR_T color_pair_number, void *opts)
+slk_attr_set(const attr_t attr, NCURSES_COLOR_T pair_arg, void *opts)
 {
     return NCURSES_SP_NAME(slk_attr_set) (CURRENT_SCREEN, attr,
-					  color_pair_number, opts);
+					  pair_arg, opts);
 }
 #endif
diff --git a/ncurses/base/lib_slkatrof.c b/ncurses/base/lib_slkatrof.c
index bb980ab..2d53ab2 100644
--- a/ncurses/base/lib_slkatrof.c
+++ b/ncurses/base/lib_slkatrof.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2005,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2005,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -38,7 +39,7 @@
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slkatrof.c,v 1.11 2009/10/24 22:12:21 tom Exp $")
+MODULE_ID("$Id: lib_slkatrof.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(slk_attroff) (NCURSES_SP_DCLx const chtype attr)
diff --git a/ncurses/base/lib_slkatron.c b/ncurses/base/lib_slkatron.c
index bc2fb33..accc2f2 100644
--- a/ncurses/base/lib_slkatron.c
+++ b/ncurses/base/lib_slkatron.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -38,7 +39,7 @@
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slkatron.c,v 1.12 2010/03/31 23:38:02 tom Exp $")
+MODULE_ID("$Id: lib_slkatron.c,v 1.13 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(slk_attron) (NCURSES_SP_DCLx const chtype attr)
diff --git a/ncurses/base/lib_slkatrset.c b/ncurses/base/lib_slkatrset.c
index 544b8d0..11fa7e6 100644
--- a/ncurses/base/lib_slkatrset.c
+++ b/ncurses/base/lib_slkatrset.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2005,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2005,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -38,7 +39,7 @@
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slkatrset.c,v 1.10 2009/10/24 22:12:21 tom Exp $")
+MODULE_ID("$Id: lib_slkatrset.c,v 1.11 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(slk_attrset) (NCURSES_SP_DCLx const chtype attr)
diff --git a/ncurses/base/lib_slkattr.c b/ncurses/base/lib_slkattr.c
index bec11e8..af49f3b 100644
--- a/ncurses/base/lib_slkattr.c
+++ b/ncurses/base/lib_slkattr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -38,7 +39,7 @@
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slkattr.c,v 1.11 2010/12/20 01:41:25 tom Exp $")
+MODULE_ID("$Id: lib_slkattr.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(attr_t)
 NCURSES_SP_NAME(slk_attr) (NCURSES_SP_DCL0)
diff --git a/ncurses/base/lib_slkclear.c b/ncurses/base/lib_slkclear.c
index 264c8c4..10531e4 100644
--- a/ncurses/base/lib_slkclear.c
+++ b/ncurses/base/lib_slkclear.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2007,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2007,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +41,7 @@
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slkclear.c,v 1.14 2009/11/07 16:27:05 tom Exp $")
+MODULE_ID("$Id: lib_slkclear.c,v 1.15 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(slk_clear) (NCURSES_SP_DCL0)
diff --git a/ncurses/base/lib_slkcolor.c b/ncurses/base/lib_slkcolor.c
index 2cf9e5d..00d1eaa 100644
--- a/ncurses/base/lib_slkcolor.c
+++ b/ncurses/base/lib_slkcolor.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -38,31 +39,53 @@
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slkcolor.c,v 1.17 2014/02/01 22:10:42 tom Exp $")
+MODULE_ID("$Id: lib_slkcolor.c,v 1.20 2020/02/02 23:34:34 tom Exp $")
 
-NCURSES_EXPORT(int)
-NCURSES_SP_NAME(slk_color) (NCURSES_SP_DCLx NCURSES_PAIRS_T color_pair_number)
+static int
+_nc_slk_color(SCREEN *sp, int pair_arg)
 {
     int code = ERR;
 
-    T((T_CALLED("slk_color(%p,%d)"), (void *) SP_PARM, (int) color_pair_number));
+    T((T_CALLED("slk_color(%p,%d)"), (void *) sp, pair_arg));
 
-    if (SP_PARM != 0
-	&& SP_PARM->_slk != 0
-	&& color_pair_number >= 0
-	&& color_pair_number < SP_PARM->_pair_limit) {
-	TR(TRACE_ATTRS, ("... current is %s", _tracech_t(CHREF(SP_PARM->_slk->attr))));
-	SetPair(SP_PARM->_slk->attr, color_pair_number);
-	TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP_PARM->_slk->attr))));
+    if (sp != 0
+	&& sp->_slk != 0
+	&& pair_arg >= 0
+	&& pair_arg < sp->_pair_limit) {
+	TR(TRACE_ATTRS, ("... current is %s", _tracech_t(CHREF(sp->_slk->attr))));
+	SetPair(sp->_slk->attr, pair_arg);
+	TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(sp->_slk->attr))));
 	code = OK;
     }
     returnCode(code);
 }
 
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(slk_color) (NCURSES_SP_DCLx NCURSES_PAIRS_T pair_arg)
+{
+    return _nc_slk_color(SP_PARM, pair_arg);
+}
+
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(int)
-slk_color(NCURSES_PAIRS_T color_pair_number)
+slk_color(NCURSES_PAIRS_T pair_arg)
 {
-    return NCURSES_SP_NAME(slk_color) (CURRENT_SCREEN, color_pair_number);
+    return NCURSES_SP_NAME(slk_color) (CURRENT_SCREEN, pair_arg);
 }
 #endif
+
+#if NCURSES_EXT_COLORS
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(extended_slk_color) (NCURSES_SP_DCLx int pair_arg)
+{
+    return _nc_slk_color(SP_PARM, pair_arg);
+}
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+extended_slk_color(int pair_arg)
+{
+    return NCURSES_SP_NAME(extended_slk_color) (CURRENT_SCREEN, pair_arg);
+}
+#endif
+#endif
diff --git a/ncurses/base/lib_slkinit.c b/ncurses/base/lib_slkinit.c
index 9cbdfea..318077f 100644
--- a/ncurses/base/lib_slkinit.c
+++ b/ncurses/base/lib_slkinit.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 1998-2009,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +41,7 @@
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slkinit.c,v 1.13 2009/10/31 00:10:46 tom Exp $")
+MODULE_ID("$Id: lib_slkinit.c,v 1.16 2022/07/09 18:58:58 tom Exp $")
 
 #ifdef USE_SP_RIPOFF
 #define SoftkeyFormat SP_PARM->slk_format
@@ -75,6 +76,14 @@
 NCURSES_EXPORT(int)
 slk_init(int format)
 {
-    return NCURSES_SP_NAME(slk_init) (CURRENT_SCREEN_PRE, format);
+    int rc;
+
+    _nc_init_pthreads();
+    _nc_lock_global(prescreen);
+    START_TRACE();
+    rc = NCURSES_SP_NAME(slk_init) (CURRENT_SCREEN_PRE, format);
+    _nc_unlock_global(prescreen);
+
+    return rc;
 }
 #endif
diff --git a/ncurses/base/lib_slklab.c b/ncurses/base/lib_slklab.c
index d0b2a23..894ff26 100644
--- a/ncurses/base/lib_slklab.c
+++ b/ncurses/base/lib_slklab.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2003,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2003,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +41,7 @@
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slklab.c,v 1.10 2009/10/24 22:12:21 tom Exp $")
+MODULE_ID("$Id: lib_slklab.c,v 1.11 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(char *)
 NCURSES_SP_NAME(slk_label) (NCURSES_SP_DCLx int n)
diff --git a/ncurses/base/lib_slkrefr.c b/ncurses/base/lib_slkrefr.c
index 382f9c4..7a40624 100644
--- a/ncurses/base/lib_slkrefr.c
+++ b/ncurses/base/lib_slkrefr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 1998-2013,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -43,7 +44,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_slkrefr.c,v 1.30 2014/03/08 20:32:59 tom Exp $")
+MODULE_ID("$Id: lib_slkrefr.c,v 1.32 2021/09/04 10:54:35 tom Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define NumLabels    InfoOf(SP_PARM).numlabels
@@ -112,7 +113,7 @@
 		    wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x);
 		    (void) wattrset(slk->win, (int) AttrOf(slk->attr));
 		    waddstr(slk->win, slk->ent[i].form_text);
-		    /* if we simulate SLK's, it's looking much more
+		    /* if we simulate SLK's, it is looking much more
 		       natural to use the current ATTRIBUTE also
 		       for the label window */
 		    (void) wattrset(slk->win, (int) WINDOW_ATTRS(StdScreen(sp)));
diff --git a/ncurses/base/lib_slkset.c b/ncurses/base/lib_slkset.c
index 9091e00..3e777f1 100644
--- a/ncurses/base/lib_slkset.c
+++ b/ncurses/base/lib_slkset.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2011,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -44,7 +45,7 @@
 #endif
 #endif
 
-MODULE_ID("$Id: lib_slkset.c,v 1.24 2012/12/08 23:09:25 tom Exp $")
+MODULE_ID("$Id: lib_slkset.c,v 1.26 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(slk_set) (NCURSES_SP_DCLx int i, const char *astr, int format)
@@ -89,9 +90,9 @@
 	mbrtowc(&wc, p, need, &state);
 	if (!iswprint((wint_t) wc))
 	    break;
-	if (wcwidth(wc) + numcols > limit)
+	if (_nc_wacs_width(wc) + numcols > limit)
 	    break;
-	numcols += wcwidth(wc);
+	numcols += _nc_wacs_width(wc);
 	p += need;
     }
     numchrs = (int) (p - str);
diff --git a/ncurses/base/lib_slktouch.c b/ncurses/base/lib_slktouch.c
index ba77fd2..6696a25 100644
--- a/ncurses/base/lib_slktouch.c
+++ b/ncurses/base/lib_slktouch.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2000,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -38,7 +39,7 @@
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slktouch.c,v 1.8 2009/10/24 22:12:21 tom Exp $")
+MODULE_ID("$Id: lib_slktouch.c,v 1.9 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(slk_touch) (NCURSES_SP_DCL0)
diff --git a/ncurses/base/lib_touch.c b/ncurses/base/lib_touch.c
index 20ac945..d8d59e1 100644
--- a/ncurses/base/lib_touch.c
+++ b/ncurses/base/lib_touch.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -43,16 +44,19 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_touch.c,v 1.12 2012/06/09 20:29:33 tom Exp $")
+MODULE_ID("$Id: lib_touch.c,v 1.16 2020/02/02 23:34:34 tom Exp $")
+
+#undef is_linetouched
 
 NCURSES_EXPORT(bool)
 is_linetouched(WINDOW *win, int line)
 {
     T((T_CALLED("is_linetouched(%p,%d)"), (void *) win, line));
 
-    /* XSI doesn't define any error */
-    if (!win || (line > win->_maxy) || (line < 0))
-	returnCode((bool) ERR);
+    /* XSI doesn't define any error, and gcc ultimately made it impossible */
+    if (!win || (line > win->_maxy) || (line < 0)) {
+	returnCode(FALSE);
+    }
 
     returnCode(win->_line[line].firstchar != _NOCHANGE ? TRUE : FALSE);
 }
@@ -60,14 +64,15 @@
 NCURSES_EXPORT(bool)
 is_wintouched(WINDOW *win)
 {
-    int i;
-
     T((T_CALLED("is_wintouched(%p)"), (void *) win));
 
-    if (win)
+    if (win) {
+	int i;
+
 	for (i = 0; i <= win->_maxy; i++)
 	    if (win->_line[i].firstchar != _NOCHANGE)
 		returnCode(TRUE);
+    }
     returnCode(FALSE);
 }
 
diff --git a/ncurses/base/lib_ungetch.c b/ncurses/base/lib_ungetch.c
index 4ee9119..fcbe6f4 100644
--- a/ncurses/base/lib_ungetch.c
+++ b/ncurses/base/lib_ungetch.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2011,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_ungetch.c,v 1.16 2012/08/04 17:38:53 tom Exp $")
+MODULE_ID("$Id: lib_ungetch.c,v 1.17 2020/02/02 23:34:34 tom Exp $")
 
 #include <fifo_defs.h>
 
diff --git a/ncurses/base/lib_vline.c b/ncurses/base/lib_vline.c
index 2f3148e..ae4af62 100644
--- a/ncurses/base/lib_vline.c
+++ b/ncurses/base/lib_vline.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -29,6 +30,8 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1996-on                 *
+ *     and: Sven Verdoolaege                        2001                    *
  ****************************************************************************/
 
 /*
@@ -40,22 +43,21 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_vline.c,v 1.12 2010/12/19 01:22:58 tom Exp $")
+MODULE_ID("$Id: lib_vline.c,v 1.15 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 wvline(WINDOW *win, chtype ch, int n)
 {
     int code = ERR;
-    int row, col;
-    int end;
 
     T((T_CALLED("wvline(%p,%s,%d)"), (void *) win, _tracechtype(ch), n));
 
     if (win) {
 	NCURSES_CH_T wch;
-	row = win->_cury;
-	col = win->_curx;
-	end = row + n - 1;
+	int row = win->_cury;
+	int col = win->_curx;
+	int end = row + n - 1;
+
 	if (end > win->_maxy)
 	    end = win->_maxy;
 
@@ -67,6 +69,14 @@
 
 	while (end >= row) {
 	    struct ldat *line = &(win->_line[end]);
+#if USE_WIDEC_SUPPORT
+	    if (col > 0 && isWidecExt(line->text[col])) {
+		SetChar2(line->text[col - 1], ' ');
+	    }
+	    if (col < win->_maxx && isWidecExt(line->text[col + 1])) {
+		SetChar2(line->text[col + 1], ' ');
+	    }
+#endif
 	    line->text[col] = wch;
 	    CHANGED_CELL(line, col);
 	    end--;
diff --git a/ncurses/base/lib_wattroff.c b/ncurses/base/lib_wattroff.c
index fff0b39..eac07f0 100644
--- a/ncurses/base/lib_wattroff.c
+++ b/ncurses/base/lib_wattroff.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2006,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2006,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +43,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_wattroff.c,v 1.10 2009/10/24 22:36:08 tom Exp $")
+MODULE_ID("$Id: lib_wattroff.c,v 1.11 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 wattr_off(WINDOW *win, attr_t at, void *opts GCC_UNUSED)
diff --git a/ncurses/base/lib_wattron.c b/ncurses/base/lib_wattron.c
index 3806285..906021d 100644
--- a/ncurses/base/lib_wattron.c
+++ b/ncurses/base/lib_wattron.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +43,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_wattron.c,v 1.11 2010/03/31 23:38:02 tom Exp $")
+MODULE_ID("$Id: lib_wattron.c,v 1.13 2022/04/15 22:34:38 tom Exp $")
 
 NCURSES_EXPORT(int)
 wattr_on(WINDOW *win, attr_t at, void *opts GCC_UNUSED)
@@ -54,8 +55,10 @@
 	   GET_WINDOW_PAIR(win)));
 
 	if_EXT_COLORS({
-	    if (at & A_COLOR)
+	    if (at & A_COLOR) {
 		win->_color = PairNumber(at);
+		set_extended_pair(opts, win->_color);
+	    }
 	});
 	toggle_attr_on(WINDOW_ATTRS(win), at);
 	returnCode(OK);
diff --git a/ncurses/base/lib_winch.c b/ncurses/base/lib_winch.c
index 7e75f85..91253d1 100644
--- a/ncurses/base/lib_winch.c
+++ b/ncurses/base/lib_winch.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_winch.c,v 1.8 2010/12/19 01:22:58 tom Exp $")
+MODULE_ID("$Id: lib_winch.c,v 1.9 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(chtype)
 winch(WINDOW *win)
diff --git a/ncurses/base/lib_window.c b/ncurses/base/lib_window.c
index 4baa369..5323fbf 100644
--- a/ncurses/base/lib_window.c
+++ b/ncurses/base/lib_window.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 1998-2010,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_window.c,v 1.29 2010/12/19 01:47:22 tom Exp $")
+MODULE_ID("$Id: lib_window.c,v 1.32 2021/10/23 23:06:24 tom Exp $")
 
 NCURSES_EXPORT(void)
 _nc_synchook(WINDOW *win)
@@ -56,7 +57,6 @@
 /* move a derived window */
 {
     WINDOW *orig;
-    int i;
     int rc = ERR;
 
     T((T_CALLED("mvderwin(%p,%d,%d)"), (void *) win, y, x));
@@ -66,6 +66,8 @@
 	&& (x >= 0 && y >= 0)
 	&& (x + getmaxx(win) <= getmaxx(orig))
 	&& (y + getmaxy(win) <= getmaxy(orig))) {
+	int i;
+
 	wsyncup(win);
 	win->_parx = x;
 	win->_pary = y;
@@ -128,7 +130,7 @@
 {
     T((T_CALLED("wsyncdown(%p)"), (void *) win));
 
-    if (win && win->_parent) {
+    if (win != NULL && win->_parent != NULL) {
 	WINDOW *pp = win->_parent;
 	int y;
 
@@ -177,8 +179,6 @@
 /* make an exact duplicate of the given window */
 {
     WINDOW *nwin = 0;
-    size_t linesize;
-    int i;
 
     T((T_CALLED("dupwin(%p)"), (void *) win));
 
@@ -187,7 +187,7 @@
 	SCREEN *sp = _nc_screen_of(win);
 #endif
 	_nc_lock_global(curses);
-	if (win->_flags & _ISPAD) {
+	if (IS_PAD(win)) {
 	    nwin = NCURSES_SP_NAME(newpad) (NCURSES_SP_ARGx
 					    win->_maxy + 1,
 					    win->_maxx + 1);
@@ -200,6 +200,8 @@
 	}
 
 	if (nwin != 0) {
+	    int i;
+	    size_t linesize;
 
 	    nwin->_curx = win->_curx;
 	    nwin->_cury = win->_cury;
@@ -236,7 +238,7 @@
 	    nwin->_regtop = win->_regtop;
 	    nwin->_regbottom = win->_regbottom;
 
-	    if (win->_flags & _ISPAD)
+	    if (IS_PAD(win))
 		nwin->_pad = win->_pad;
 
 	    linesize = (unsigned) (win->_maxx + 1) * sizeof(NCURSES_CH_T);
diff --git a/ncurses/base/nc_panel.c b/ncurses/base/nc_panel.c
index 69b10bc..002f118 100644
--- a/ncurses/base/nc_panel.c
+++ b/ncurses/base/nc_panel.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2000,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,7 +33,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: nc_panel.c,v 1.5 2009/04/11 21:05:10 tom Exp $")
+MODULE_ID("$Id: nc_panel.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(struct panelhook *)
 NCURSES_SP_NAME(_nc_panelhook) (NCURSES_SP_DCL0)
diff --git a/ncurses/base/new_pair.c b/ncurses/base/new_pair.c
new file mode 100644
index 0000000..70866c6
--- /dev/null
+++ b/ncurses/base/new_pair.c
@@ -0,0 +1,393 @@
+/****************************************************************************
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2017 Free Software Foundation, Inc.                            *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "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.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *  Author: Thomas E. Dickey                                                *
+ ****************************************************************************/
+
+/* new_pair.c
+ *
+ * New color-pair functions, alloc_pair and free_pair
+ */
+
+#define NEW_PAIR_INTERNAL 1
+#include <curses.priv.h>
+
+#ifndef CUR
+#define CUR SP_TERMTYPE
+#endif
+
+#ifdef USE_TERM_DRIVER
+#define MaxColors      InfoOf(SP_PARM).maxcolors
+#else
+#define MaxColors      max_colors
+#endif
+
+#if NCURSES_EXT_COLORS
+
+/* fix redefinition versys tic.h */
+#undef entry
+#define entry my_entry
+#undef ENTRY
+#define ENTRY my_ENTRY
+
+#include <search.h>
+
+#endif
+
+MODULE_ID("$Id: new_pair.c,v 1.23 2021/08/16 22:11:26 tom Exp $")
+
+#if NCURSES_EXT_COLORS
+
+#ifdef NEW_PAIR_DEBUG
+
+static int
+prev_len(SCREEN *sp, int pair)
+{
+    int result = 1;
+    int base = pair;
+    colorpair_t *list = sp->_color_pairs;
+    while (list[pair].prev != base) {
+	result++;
+	pair = list[pair].prev;
+    }
+    return result;
+}
+
+static int
+next_len(SCREEN *sp, int pair)
+{
+    int result = 1;
+    int base = pair;
+    colorpair_t *list = sp->_color_pairs;
+    while (list[pair].next != base) {
+	result++;
+	pair = list[pair].next;
+    }
+    return result;
+}
+
+/*
+ * Trace the contents of LRU color-pairs.
+ */
+static void
+dumpit(SCREEN *sp, int pair, const char *tag)
+{
+    colorpair_t *list = sp->_color_pairs;
+    char bigbuf[256 * 20];
+    char *p = bigbuf;
+    int n;
+    size_t have = sizeof(bigbuf);
+
+    _nc_STRCPY(p, tag, have);
+    for (n = 0; n < sp->_pair_alloc; ++n) {
+	if (list[n].mode != cpFREE) {
+	    p += strlen(p);
+	    if ((size_t) (p - bigbuf) + 50 > have)
+		break;
+	    _nc_SPRINTF(p, _nc_SLIMIT(have - (p - bigbuf))
+			" %d%c(%d,%d)",
+			n, n == pair ? '@' : ':', list[n].next, list[n].prev);
+	}
+    }
+    T(("(%d/%d) %ld - %s",
+       next_len(sp, 0),
+       prev_len(sp, 0),
+       strlen(bigbuf), bigbuf));
+
+    if (next_len(sp, 0) != prev_len(sp, 0)) {
+	endwin();
+	ExitProgram(EXIT_FAILURE);
+    }
+}
+#else
+#define dumpit(sp, pair, tag)	/* nothing */
+#endif
+
+static int
+compare_data(const void *a, const void *b)
+{
+    const colorpair_t *p = (const colorpair_t *) a;
+    const colorpair_t *q = (const colorpair_t *) b;
+    return ((p->fg == q->fg)
+	    ? (p->bg - q->bg)
+	    : (p->fg - q->fg));
+}
+
+static int
+_nc_find_color_pair(SCREEN *sp, int fg, int bg)
+{
+    colorpair_t find;
+    int result = -1;
+
+    find.fg = fg;
+    find.bg = bg;
+    if (sp != 0) {
+	void *pp;
+	if ((pp = tfind(&find, &sp->_ordered_pairs, compare_data)) != 0) {
+	    colorpair_t *temp = *(colorpair_t **) pp;
+	    result = (int) (temp - sp->_color_pairs);
+	}
+    }
+    return result;
+}
+
+static void
+delink_color_pair(SCREEN *sp, int pair)
+{
+    colorpair_t *list = sp->_color_pairs;
+    int prev = list[pair].prev;
+    int next = list[pair].next;
+
+    /* delink this from its current location */
+    if (list[prev].next == pair &&
+	list[next].prev == pair) {
+	list[prev].next = next;
+	list[next].prev = prev;
+	dumpit(sp, pair, "delinked");
+    }
+}
+
+/*
+ * Discard all nodes in the fast-index.
+ */
+NCURSES_EXPORT(void)
+_nc_free_ordered_pairs(SCREEN *sp)
+{
+    if (sp && sp->_ordered_pairs && sp->_pair_alloc) {
+	int n;
+	for (n = 0; n < sp->_pair_alloc; ++n) {
+	    tdelete(&sp->_color_pairs[n], &sp->_ordered_pairs, compare_data);
+	}
+    }
+}
+
+/*
+ * Use this call to update the fast-index when modifying an entry in the color
+ * pair table.
+ */
+NCURSES_EXPORT(void)
+_nc_reset_color_pair(SCREEN *sp, int pair, colorpair_t * next)
+{
+    colorpair_t *last;
+
+    if (ValidPair(sp, pair)) {
+	bool used;
+
+	ReservePairs(sp, pair);
+	last = &(sp->_color_pairs[pair]);
+	delink_color_pair(sp, pair);
+	if (last->mode > cpFREE &&
+	    (last->fg != next->fg || last->bg != next->bg)) {
+	    /* remove the old entry from fast index */
+	    tdelete(last, &sp->_ordered_pairs, compare_data);
+	    used = FALSE;
+	} else {
+	    used = (last->mode != cpFREE);
+	}
+	if (!used) {
+	    /* create a new entry in fast index */
+	    *last = *next;
+	    tsearch(last, &sp->_ordered_pairs, compare_data);
+	}
+    }
+}
+
+/*
+ * Use this call to relink the newest pair to the front of the list, keeping
+ * "0" first.
+ */
+NCURSES_EXPORT(void)
+_nc_set_color_pair(SCREEN *sp, int pair, int mode)
+{
+    if (ValidPair(sp, pair)) {
+	colorpair_t *list = sp->_color_pairs;
+	dumpit(sp, pair, "SET_PAIR");
+	list[0].mode = cpKEEP;
+	if (list[pair].mode <= cpFREE)
+	    sp->_pairs_used++;
+	list[pair].mode = mode;
+	if (list[0].next != pair) {
+	    /* link it at the front of the list */
+	    list[pair].next = list[0].next;
+	    list[list[pair].next].prev = pair;
+	    list[pair].prev = 0;
+	    list[0].next = pair;
+	}
+	dumpit(sp, pair, "...after");
+    }
+}
+
+/*
+ * If we reallocate the color-pair array, we have to adjust the fast-index.
+ */
+NCURSES_EXPORT(void)
+_nc_copy_pairs(SCREEN *sp, colorpair_t * target, colorpair_t * source, int length)
+{
+    int n;
+    for (n = 0; n < length; ++n) {
+	void *find = tfind(source + n, &sp->_ordered_pairs, compare_data);
+	if (find != 0) {
+	    tdelete(source + n, &sp->_ordered_pairs, compare_data);
+	    tsearch(target + n, &sp->_ordered_pairs, compare_data);
+	}
+    }
+}
+
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(alloc_pair) (NCURSES_SP_DCLx int fg, int bg)
+{
+    int pair;
+
+    T((T_CALLED("alloc_pair(%d,%d)"), fg, bg));
+    if (SP_PARM == 0) {
+	pair = -1;
+    } else if ((pair = _nc_find_color_pair(SP_PARM, fg, bg)) < 0) {
+	/*
+	 * Check if all of the slots have been used.  If not, find one and
+	 * use that.
+	 */
+	if (SP_PARM->_pairs_used + 1 < SP_PARM->_pair_limit) {
+	    bool found = FALSE;
+	    int hint = SP_PARM->_recent_pair;
+
+	    /*
+	     * The linear search is done to allow mixing calls to init_pair()
+	     * and alloc_pair().  The former can make gaps...
+	     */
+	    for (pair = hint + 1; pair < SP_PARM->_pair_alloc; pair++) {
+		if (SP_PARM->_color_pairs[pair].mode == cpFREE) {
+		    T(("found gap %d", pair));
+		    found = TRUE;
+		    break;
+		}
+	    }
+	    if (!found && (SP_PARM->_pair_alloc < SP_PARM->_pair_limit)) {
+		pair = SP_PARM->_pair_alloc;
+		ReservePairs(SP_PARM, pair);
+		if (SP_PARM->_color_pairs == 0) {
+		    pair = -1;
+		} else {
+		    found = TRUE;
+		}
+	    }
+	    if (!found && SP_PARM->_color_pairs != NULL) {
+		for (pair = 1; pair <= hint; pair++) {
+		    if (SP_PARM->_color_pairs[pair].mode == cpFREE) {
+			T(("found gap %d", pair));
+			found = TRUE;
+			break;
+		    }
+		}
+	    }
+	    if (found) {
+		SP_PARM->_recent_pair = pair;
+	    } else {
+		pair = ERR;
+	    }
+	} else {
+	    /* reuse the oldest one */
+	    pair = SP_PARM->_color_pairs[0].prev;
+	    T(("reusing %d", pair));
+	}
+
+	if (_nc_init_pair(SP_PARM, pair, fg, bg) == ERR)
+	    pair = ERR;
+    }
+    returnCode(pair);
+}
+
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(find_pair) (NCURSES_SP_DCLx int fg, int bg)
+{
+    int pair;
+
+    T((T_CALLED("find_pair(%d,%d)"), fg, bg));
+    pair = _nc_find_color_pair(SP_PARM, fg, bg);
+    returnCode(pair);
+}
+
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(free_pair) (NCURSES_SP_DCLx int pair)
+{
+    int result = ERR;
+    T((T_CALLED("free_pair(%d)"), pair));
+    if (ValidPair(SP_PARM, pair) && pair < SP_PARM->_pair_alloc) {
+	colorpair_t *cp = &(SP_PARM->_color_pairs[pair]);
+	if (pair != 0) {
+	    _nc_change_pair(SP_PARM, pair);
+	    delink_color_pair(SP_PARM, pair);
+	    tdelete(cp, &SP_PARM->_ordered_pairs, compare_data);
+	    cp->mode = cpFREE;
+	    result = OK;
+	    SP_PARM->_pairs_used--;
+	}
+    }
+    returnCode(result);
+}
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+alloc_pair(int f, int b)
+{
+    return NCURSES_SP_NAME(alloc_pair) (CURRENT_SCREEN, f, b);
+}
+
+NCURSES_EXPORT(int)
+find_pair(int f, int b)
+{
+    return NCURSES_SP_NAME(find_pair) (CURRENT_SCREEN, f, b);
+}
+
+NCURSES_EXPORT(int)
+free_pair(int pair)
+{
+    return NCURSES_SP_NAME(free_pair) (CURRENT_SCREEN, pair);
+}
+#endif
+
+#if NO_LEAKS
+NCURSES_EXPORT(void)
+_nc_new_pair_leaks(SCREEN *sp)
+{
+    if (sp->_color_pairs) {
+	while (sp->_color_pairs[0].next) {
+	    free_pair(sp->_color_pairs[0].next);
+	}
+    }
+}
+#endif
+
+#else
+void _nc_new_pair(void);
+void
+_nc_new_pair(void)
+{
+}
+#endif /* NCURSES_EXT_COLORS */
diff --git a/ncurses/base/resizeterm.c b/ncurses/base/resizeterm.c
index 1eca279..1a2ddb3 100644
--- a/ncurses/base/resizeterm.c
+++ b/ncurses/base/resizeterm.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020-2021,2024 Thomas E. Dickey                                *
+ * Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -45,7 +46,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: resizeterm.c,v 1.47 2014/10/13 08:56:49 tom Exp $")
+MODULE_ID("$Id: resizeterm.c,v 1.53 2024/04/20 21:54:14 tom Exp $")
 
 /*
  * If we're trying to be reentrant, do not want any local statics.
@@ -62,6 +63,12 @@
 #define EXTRA_DCLS		/* nothing */
 #endif
 
+#if NCURSES_SP_FUNCS && !defined(USE_SP_WINDOWLIST)
+#define UNUSED_SP  (void) sp
+#else
+#define UNUSED_SP		/* nothing */
+#endif
+
 #ifdef TRACE
 static void
 show_window_sizes(const char *name)
@@ -140,9 +147,10 @@
 ripped_bottom(WINDOW *win)
 {
     int result = 0;
-    ripoff_t *rop;
 
     if (win != 0) {
+	ripoff_t *rop;
+
 #ifdef USE_SP_RIPOFF
 	SCREEN *sp = _nc_screen_of(win);
 #endif
@@ -202,7 +210,7 @@
 }
 
 /*
- * FIXME: must adjust position so it's within the parent!
+ * FIXME: must adjust position so it is within the parent!
  */
 static int
 adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen EXTRA_DCLS)
@@ -276,6 +284,7 @@
     WINDOWLIST *wp;
 
     T((T_CALLED("decrease_size(%p, %d, %d)"), (void *) SP_PARM, ToLines, ToCols));
+    UNUSED_SP;
 
     do {
 	found = FALSE;
@@ -284,7 +293,7 @@
 	for (each_window(SP_PARM, wp)) {
 	    WINDOW *win = &(wp->win);
 
-	    if (!(win->_flags & _ISPAD)) {
+	    if (!IS_PAD(win)) {
 		if (child_depth(win) == depth) {
 		    found = TRUE;
 		    if (adjust_window(win, ToLines, ToCols,
@@ -310,6 +319,7 @@
     WINDOWLIST *wp;
 
     T((T_CALLED("increase_size(%p, %d, %d)"), (void *) SP_PARM, ToLines, ToCols));
+    UNUSED_SP;
 
     do {
 	found = FALSE;
@@ -318,7 +328,7 @@
 	for (each_window(SP_PARM, wp)) {
 	    WINDOW *win = &(wp->win);
 
-	    if (!(win->_flags & _ISPAD)) {
+	    if (!IS_PAD(win)) {
 		if (parent_depth(win) == depth) {
 		    found = TRUE;
 		    if (adjust_window(win, ToLines, ToCols,
@@ -399,8 +409,8 @@
 #ifdef USE_TERM_DRIVER
 	    CallDriver_2(SP_PARM, td_setsize, ToLines, ToCols);
 #else
-	    lines = (NCURSES_SIZE_T) ToLines;
-	    columns = (NCURSES_SIZE_T) ToCols;
+	    lines = (NCURSES_INT2) ToLines;
+	    columns = (NCURSES_INT2) ToCols;
 #endif
 
 	    SP_PARM->_lines_avail = (NCURSES_SIZE_T) (ToLines - was_stolen);
@@ -440,7 +450,7 @@
 NCURSES_EXPORT(int)
 resize_term(int ToLines, int ToCols)
 {
-    int res = ERR;
+    int res;
     _nc_sp_lock_global(curses);
     res = NCURSES_SP_NAME(resize_term) (CURRENT_SCREEN, ToLines, ToCols);
     _nc_sp_unlock_global(curses);
diff --git a/ncurses/base/safe_sprintf.c b/ncurses/base/safe_sprintf.c
index 34abd2f..8816e58 100644
--- a/ncurses/base/safe_sprintf.c
+++ b/ncurses/base/safe_sprintf.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2012,2013 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -33,7 +34,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: safe_sprintf.c,v 1.27 2013/01/20 01:04:32 tom Exp $")
+MODULE_ID("$Id: safe_sprintf.c,v 1.37 2023/09/30 10:42:42 tom Exp $")
 
 #if USE_SAFE_SPRINTF
 
@@ -41,7 +42,7 @@
     Flags, Width, Prec, Type, Format
 } PRINTF;
 
-#define VA_INTGR(type) ival = va_arg(ap, type)
+#define VA_INTGR(type) ival = (int) va_arg(ap, type)
 #define VA_FLOAT(type) fval = va_arg(ap, type)
 #define VA_POINT(type) pval = (void *)va_arg(ap, type)
 
@@ -157,9 +158,9 @@
 		    case 's':
 			VA_POINT(char *);
 			if (prec < 0)
-			    prec = strlen(pval);
+			    prec = (int) strlen(pval);
 			if (prec > (int) length) {
-			    length = length + prec;
+			    length = length + (size_t) prec;
 			    buffer = typeRealloc(char, length, buffer);
 			    if (buffer == 0) {
 				free(format);
@@ -222,9 +223,9 @@
 				    const char *fmt,
 				    va_list ap)
 {
-    char *result = 0;
+    char *result = NULL;
 
-    if (fmt != 0) {
+    if (SP_PARM != NULL && fmt != NULL) {
 #if USE_SAFE_SPRINTF
 	va_list ap2;
 	int len;
@@ -234,10 +235,10 @@
 	end_va_copy(ap2);
 
 	if ((int) my_length < len + 1) {
-	    my_length = 2 * (len + 1);
+	    my_length = (size_t) (2 * (len + 1));
 	    my_buffer = typeRealloc(char, my_length, my_buffer);
 	}
-	if (my_buffer != 0) {
+	if (my_buffer != NULL) {
 	    *my_buffer = '\0';
 	    if (len >= 0) {
 		vsprintf(my_buffer, fmt, ap);
@@ -254,21 +255,37 @@
 	    if (screen_columns(SP_PARM) > MyCols)
 		MyCols = screen_columns(SP_PARM);
 	    my_length = (size_t) (MyRows * (MyCols + 1)) + 1;
+	    if (my_length < 80)
+		my_length = 80;
 	    my_buffer = typeRealloc(char, my_length, my_buffer);
 	}
 
-	if (my_buffer != 0) {
+	if (my_buffer != NULL) {
 # if HAVE_VSNPRINTF
-	    vsnprintf(my_buffer, my_length, fmt, ap);	/* GNU extension */
+	    /* SUSv2, 1997 */
+	    int used;
+
+	    do {
+		va_list ap2;
+
+		begin_va_copy(ap2, ap);
+		used = vsnprintf(my_buffer, my_length, fmt, ap2);
+		end_va_copy(ap2);
+		if (used < (int) my_length)
+		    break;
+		my_length = (size_t) ((3 * used) / 2);
+		my_buffer = typeRealloc(char, my_length, my_buffer);
+	    } while (my_buffer != NULL);
 # else
-	    vsprintf(my_buffer, fmt, ap);	/* ANSI */
+	    /* ISO/ANSI C, 1989 */
+	    vsprintf(my_buffer, fmt, ap);
 # endif
 	    result = my_buffer;
 	}
 #endif
-    } else if (my_buffer != 0) {	/* see _nc_freeall() */
+    } else if (my_buffer != NULL) {	/* see _nc_freeall() */
 	free(my_buffer);
-	my_buffer = 0;
+	my_buffer = NULL;
 	my_length = 0;
     }
     return result;
diff --git a/ncurses/base/sigaction.c b/ncurses/base/sigaction.c
index 36442e0..9688c69 100644
--- a/ncurses/base/sigaction.c
+++ b/ncurses/base/sigaction.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2002,2003 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -35,7 +36,7 @@
 /* This file provides sigaction() emulation using sigvec() */
 /* Use only if this is non POSIX system */
 
-MODULE_ID("$Id: sigaction.c,v 1.14 2003/12/07 01:06:52 tom Exp $")
+MODULE_ID("$Id: sigaction.c,v 1.15 2020/02/02 23:34:34 tom Exp $")
 
 static int
 _nc_sigaction(int sig, sigaction_t * sigact, sigaction_t * osigact)
diff --git a/ncurses/base/tries.c b/ncurses/base/tries.c
index ad85d22..0f8c051 100644
--- a/ncurses/base/tries.c
+++ b/ncurses/base/tries.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -38,8 +39,9 @@
 */
 
 #include <curses.priv.h>
+#include <tic.h>
 
-MODULE_ID("$Id: tries.c,v 1.30 2010/08/28 21:08:23 tom Exp $")
+MODULE_ID("$Id: tries.c,v 1.32 2023/06/24 15:36:23 tom Exp $")
 
 /*
  * Expand a keycode into the string that it corresponds to, returning null if
@@ -123,7 +125,7 @@
 {
     T((T_CALLED("_nc_remove_string(%p,%s)"), (void *) tree, _nc_visbuf(string)));
 
-    if (string == 0 || *string == 0)
+    if (!VALID_STRING(string) || *string == 0)
 	returnCode(FALSE);
 
     while (*tree != 0) {
diff --git a/ncurses/base/use_window.c b/ncurses/base/use_window.c
index 8eb7339..4893053 100644
--- a/ncurses/base/use_window.c
+++ b/ncurses/base/use_window.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2007-2009,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,14 +33,19 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: use_window.c,v 1.9 2009/10/24 22:40:24 tom Exp $")
+MODULE_ID("$Id: use_window.c,v 1.13 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data)
 {
     int code = OK;
+    TR_FUNC_BFR(1);
 
-    T((T_CALLED("use_window(%p,%p,%p)"), (void *) win, func, data));
+    T((T_CALLED("use_window(%p,%s,%p)"),
+       (void *) win,
+       TR_FUNC_ARG(0, func),
+       data));
+
     _nc_lock_global(curses);
     code = func(win, data);
     _nc_unlock_global(curses);
diff --git a/ncurses/base/version.c b/ncurses/base/version.c
index ef83967..4d8ee81 100644
--- a/ncurses/base/version.c
+++ b/ncurses/base/version.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1999-2004,2005 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1999-2004,2005 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,7 +33,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: version.c,v 1.6 2005/01/02 01:23:54 tom Exp $")
+MODULE_ID("$Id: version.c,v 1.7 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(const char *)
 curses_version(void)
diff --git a/ncurses/base/vsscanf.c b/ncurses/base/vsscanf.c
index 38c7926..40ee8bb 100644
--- a/ncurses/base/vsscanf.c
+++ b/ncurses/base/vsscanf.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2004,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 1998-2004,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -38,15 +39,12 @@
 
 #if !HAVE_VSSCANF
 
-MODULE_ID("$Id: vsscanf.c,v 1.20 2012/02/22 22:26:58 tom Exp $")
+MODULE_ID("$Id: vsscanf.c,v 1.22 2023/09/23 18:48:57 tom Exp $")
 
 #if !(HAVE_VFSCANF || HAVE__DOSCAN)
 
 #include <ctype.h>
 
-#define L_SQUARE '['
-#define R_SQUARE ']'
-
 typedef enum {
     cUnknown
     ,cError			/* anything that isn't ANSI */
@@ -242,7 +240,7 @@
 		    case sPercent:
 			if (format[n] == '%') {
 			    state = sUnknown;
-			} else if (format[n] == L_SQUARE) {
+			} else if (format[n] == L_BLOCK) {
 			    state = sLeft;
 			} else {
 			    state = sNormal;
@@ -257,7 +255,7 @@
 			}
 			break;
 		    case sRange:
-			if (format[n] == R_SQUARE) {
+			if (format[n] == R_BLOCK) {
 			    state = sFinal;
 			    chunk = cRange;
 			}
diff --git a/ncurses/base/wresize.c b/ncurses/base/wresize.c
index bc6b573..6d5589e 100644
--- a/ncurses/base/wresize.c
+++ b/ncurses/base/wresize.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc.              *
+ * Copyright 2019-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2010,2011 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -33,13 +34,13 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: wresize.c,v 1.35 2011/05/21 18:55:07 tom Exp $")
+MODULE_ID("$Id: wresize.c,v 1.43 2023/10/21 11:13:03 tom Exp $")
 
 static int
 cleanup_lines(struct ldat *data, int length)
 {
     while (--length >= 0)
-	free(data[length].text);
+	FreeAndNull(data[length].text);
     free(data);
     return ERR;
 }
@@ -54,7 +55,7 @@
     WINDOWLIST *wp;
     struct ldat *pline = cmp->_line;
     int row;
-#ifdef USE_SP_WINDOWLIST
+#if NCURSES_SP_FUNCS && defined(USE_SP_WINDOWLIST)
     SCREEN *sp = _nc_screen_of(cmp);
 #endif
 
@@ -65,15 +66,29 @@
 
 	if (tst->_parent == cmp) {
 
-	    if (tst->_pary > cmp->_maxy)
-		tst->_pary = cmp->_maxy;
-	    if (tst->_parx > cmp->_maxx)
-		tst->_parx = cmp->_maxx;
+#define REPAIR1(field, limit) \
+	    if (tst->field > cmp->limit) \
+		tst->field = cmp->limit
 
-	    if (tst->_maxy + tst->_pary > cmp->_maxy)
-		tst->_maxy = (NCURSES_SIZE_T) (cmp->_maxy - tst->_pary);
-	    if (tst->_maxx + tst->_parx > cmp->_maxx)
-		tst->_maxx = (NCURSES_SIZE_T) (cmp->_maxx - tst->_parx);
+	    REPAIR1(_pary, _maxy);
+	    REPAIR1(_parx, _maxx);
+
+#define REPAIR2(field, limit) \
+	    if (tst->limit + tst->field > cmp->limit) \
+		tst->limit = (NCURSES_SIZE_T) (cmp->limit - tst->field)
+
+	    REPAIR2(_pary, _maxy);
+	    REPAIR2(_parx, _maxx);
+
+#define REPAIR3(field, limit) \
+	    if (tst->field > tst->limit) \
+		tst->field = tst->limit
+
+	    REPAIR3(_cury, _maxy);
+	    REPAIR3(_curx, _maxx);
+
+	    REPAIR3(_regtop, _maxy);
+	    REPAIR3(_regbottom, _maxy);
 
 	    for (row = 0; row <= tst->_maxy; ++row) {
 		tst->_line[row].text = &pline[tst->_pary + row].text[tst->_parx];
@@ -120,7 +135,7 @@
 	&& ToCols == size_x)
 	returnCode(OK);
 
-    if ((win->_flags & _SUBWIN)) {
+    if (IS_SUBWIN(win)) {
 	/*
 	 * Check if the new limits will fit into the parent window's size.  If
 	 * not, do not resize.  We could adjust the location of the subwindow,
@@ -154,14 +169,22 @@
 	int end = ToCols;
 	NCURSES_CH_T *s;
 
-	if (!(win->_flags & _SUBWIN)) {
+	if (!IS_SUBWIN(win)) {
 	    if (row <= size_y) {
 		if (ToCols != size_x) {
 		    s = typeMalloc(NCURSES_CH_T, (unsigned) ToCols + 1);
 		    if (s == 0)
 			returnCode(cleanup_lines(new_lines, row));
 		    for (col = 0; col <= ToCols; ++col) {
-			s[col] = (col <= size_x
+			bool valid = (col <= size_x);
+			if_WIDEC({
+			    if (col == ToCols
+				&& col < size_x
+				&& isWidecBase(win->_line[row].text[col])) {
+				valid = FALSE;
+			    }
+			});
+			s[col] = (valid
 				  ? win->_line[row].text[col]
 				  : win->_nc_bkgd);
 		    }
@@ -204,16 +227,16 @@
     if (!(win->_flags & _SUBWIN)) {
 	if (ToCols == size_x) {
 	    for (row = ToLines + 1; row <= size_y; row++) {
-		free(win->_line[row].text);
+		FreeAndNull(win->_line[row].text);
 	    }
 	} else {
 	    for (row = 0; row <= size_y; row++) {
-		free(win->_line[row].text);
+		FreeAndNull(win->_line[row].text);
 	    }
 	}
     }
 
-    free(win->_line);
+    FreeAndNull(win->_line);
     win->_line = new_lines;
 
     /*
diff --git a/ncurses/build.priv.h b/ncurses/build.priv.h
index 096a443..9014e74 100644
--- a/ncurses/build.priv.h
+++ b/ncurses/build.priv.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2010,2012 Free Software Foundation, Inc.                   *
+ * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2010,2012 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -31,11 +32,11 @@
  ****************************************************************************/
 
 /*
- * $Id: build.priv.h,v 1.9 2012/02/22 22:17:02 tom Exp $
+ * $Id: build.priv.h,v 1.12 2020/02/02 23:34:34 tom Exp $
  *
  *	build.priv.h
  *
- *	This is a reduced version of curses.priv.h, for build-time utilties.
+ *	This is a reduced version of curses.priv.h, for build-time utilities.
  *	Because it has fewer dependencies, this simplifies cross-compiling.
  *
  */
@@ -54,7 +55,7 @@
 #if USE_RCS_IDS
 #define MODULE_ID(id) static const char Ident[] = id;
 #else
-#define MODULE_ID(id) /*nothing*/
+#define MODULE_ID(id)		/*nothing */
 #endif
 
 #include <stdlib.h>
@@ -66,7 +67,7 @@
 
 #include <errno.h>
 
-#include <curses.h>	/* we'll use -Ipath directive to get the right one! */
+#include <curses.h>		/* we'll use -Ipath directive to get the right one! */
 
 /* usually in <unistd.h> */
 #ifndef EXIT_SUCCESS
@@ -77,7 +78,7 @@
 #define EXIT_FAILURE 1
 #endif
 
-#define FreeAndNull(p)   free(p); p = 0
+#define FreeAndNull(p)   do { free(p); p = 0; } while (0)
 #define UChar(c)         ((unsigned char)(c))
 #define SIZEOF(v)        (sizeof(v) / sizeof(v[0]))
 
@@ -89,20 +90,19 @@
 #define NCURSES_ARRAY(name) \
 	NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, name)
 
-NCURSES_ARRAY(boolnames);
-NCURSES_ARRAY(boolfnames);
-NCURSES_ARRAY(numnames);
-NCURSES_ARRAY(numfnames);
-NCURSES_ARRAY(strnames);
-NCURSES_ARRAY(strfnames);
+    NCURSES_ARRAY(boolnames);
+    NCURSES_ARRAY(boolfnames);
+    NCURSES_ARRAY(numnames);
+    NCURSES_ARRAY(numfnames);
+    NCURSES_ARRAY(strnames);
+    NCURSES_ARRAY(strfnames);
 #endif
 
 #if NO_LEAKS
-NCURSES_EXPORT(void) _nc_names_leaks(void);
+    NCURSES_EXPORT(void) _nc_names_leaks(void);
 #endif
 
 #ifdef __cplusplus
 }
 #endif
-
-#endif /* CURSES_PRIV_H */
+#endif				/* CURSES_PRIV_H */
diff --git a/ncurses/codes.c b/ncurses/codes.c
deleted file mode 100644
index d0c7bad..0000000
--- a/ncurses/codes.c
+++ /dev/null
@@ -1,675 +0,0 @@
-/* This file was generated by MKcodes.awk */
-
-#include <curses.priv.h>
-
-#define IT NCURSES_CONST char * const
-
-
-#if BROKEN_LINKER || USE_REENTRANT
-
-static const char _nc_code_blob[] = 
-"bw\0" "am\0" "xb\0" "xs\0" "xn\0" "eo\0" "gn\0" "hc\0" "km\0" "hs\0" "in\0" \
-"da\0" "db\0" "mi\0" "ms\0" "os\0" "es\0" "xt\0" "hz\0" "ul\0" "xo\0" "nx\0" \
-"5i\0" "HC\0" "NR\0" "NP\0" "ND\0" "cc\0" "ut\0" "hl\0" "YA\0" "YB\0" "YC\0" \
-"YD\0" "YE\0" "YF\0" "YG\0" "co\0" "it\0" "li\0" "lm\0" "sg\0" "pb\0" "vt\0" \
-"ws\0" "Nl\0" "lh\0" "lw\0" "ma\0" "MW\0" "Co\0" "pa\0" "NC\0" "Ya\0" "Yb\0" \
-"Yc\0" "Yd\0" "Ye\0" "Yf\0" "Yg\0" "Yh\0" "Yi\0" "Yj\0" "Yk\0" "Yl\0" "Ym\0" \
-"Yn\0" "BT\0" "Yo\0" "Yp\0" "bt\0" "bl\0" "cr\0" "cs\0" "ct\0" "cl\0" "ce\0" \
-"cd\0" "ch\0" "CC\0" "cm\0" "do\0" "ho\0" "vi\0" "le\0" "CM\0" "ve\0" "nd\0" \
-"ll\0" "up\0" "vs\0" "dc\0" "dl\0" "ds\0" "hd\0" "as\0" "mb\0" "md\0" "ti\0" \
-"dm\0" "mh\0" "im\0" "mk\0" "mp\0" "mr\0" "so\0" "us\0" "ec\0" "ae\0" "me\0" \
-"te\0" "ed\0" "ei\0" "se\0" "ue\0" "vb\0" "ff\0" "fs\0" "i1\0" "is\0" "i3\0" \
-"if\0" "ic\0" "al\0" "ip\0" "kb\0" "ka\0" "kC\0" "kt\0" "kD\0" "kL\0" "kd\0" \
-"kM\0" "kE\0" "kS\0" "k0\0" "k1\0" "k;\0" "k2\0" "k3\0" "k4\0" "k5\0" "k6\0" \
-"k7\0" "k8\0" "k9\0" "kh\0" "kI\0" "kA\0" "kl\0" "kH\0" "kN\0" "kP\0" "kr\0" \
-"kF\0" "kR\0" "kT\0" "ku\0" "ke\0" "ks\0" "l0\0" "l1\0" "la\0" "l2\0" "l3\0" \
-"l4\0" "l5\0" "l6\0" "l7\0" "l8\0" "l9\0" "mo\0" "mm\0" "nw\0" "pc\0" "DC\0" \
-"DL\0" "DO\0" "IC\0" "SF\0" "AL\0" "LE\0" "RI\0" "SR\0" "UP\0" "pk\0" "pl\0" \
-"px\0" "ps\0" "pf\0" "po\0" "rp\0" "r1\0" "r2\0" "r3\0" "rf\0" "rc\0" "cv\0" \
-"sc\0" "sf\0" "sr\0" "sa\0" "st\0" "wi\0" "ta\0" "ts\0" "uc\0" "hu\0" "iP\0" \
-"K1\0" "K3\0" "K2\0" "K4\0" "K5\0" "pO\0" "rP\0" "ac\0" "pn\0" "kB\0" "SX\0" \
-"RX\0" "SA\0" "RA\0" "XN\0" "XF\0" "eA\0" "LO\0" "LF\0" "@1\0" "@2\0" "@3\0" \
-"@4\0" "@5\0" "@6\0" "@7\0" "@8\0" "@9\0" "@0\0" "%1\0" "%2\0" "%3\0" "%4\0" \
-"%5\0" "%6\0" "%7\0" "%8\0" "%9\0" "%0\0" "&1\0" "&2\0" "&3\0" "&4\0" "&5\0" \
-"&6\0" "&7\0" "&8\0" "&9\0" "&0\0" "*1\0" "*2\0" "*3\0" "*4\0" "*5\0" "*6\0" \
-"*7\0" "*8\0" "*9\0" "*0\0" "#1\0" "#2\0" "#3\0" "#4\0" "%a\0" "%b\0" "%c\0" \
-"%d\0" "%e\0" "%f\0" "%g\0" "%h\0" "%i\0" "%j\0" "!1\0" "!2\0" "!3\0" "RF\0" \
-"F1\0" "F2\0" "F3\0" "F4\0" "F5\0" "F6\0" "F7\0" "F8\0" "F9\0" "FA\0" "FB\0" \
-"FC\0" "FD\0" "FE\0" "FF\0" "FG\0" "FH\0" "FI\0" "FJ\0" "FK\0" "FL\0" "FM\0" \
-"FN\0" "FO\0" "FP\0" "FQ\0" "FR\0" "FS\0" "FT\0" "FU\0" "FV\0" "FW\0" "FX\0" \
-"FY\0" "FZ\0" "Fa\0" "Fb\0" "Fc\0" "Fd\0" "Fe\0" "Ff\0" "Fg\0" "Fh\0" "Fi\0" \
-"Fj\0" "Fk\0" "Fl\0" "Fm\0" "Fn\0" "Fo\0" "Fp\0" "Fq\0" "Fr\0" "cb\0" "MC\0" \
-"ML\0" "MR\0" "Lf\0" "SC\0" "DK\0" "RC\0" "CW\0" "WG\0" "HU\0" "DI\0" "QD\0" \
-"TO\0" "PU\0" "fh\0" "PA\0" "WA\0" "u0\0" "u1\0" "u2\0" "u3\0" "u4\0" "u5\0" \
-"u6\0" "u7\0" "u8\0" "u9\0" "op\0" "oc\0" "Ic\0" "Ip\0" "sp\0" "Sf\0" "Sb\0" \
-"ZA\0" "ZB\0" "ZC\0" "ZD\0" "ZE\0" "ZF\0" "ZG\0" "ZH\0" "ZI\0" "ZJ\0" "ZK\0" \
-"ZL\0" "ZM\0" "ZN\0" "ZO\0" "ZP\0" "ZQ\0" "ZR\0" "ZS\0" "ZT\0" "ZU\0" "ZV\0" \
-"ZW\0" "ZX\0" "ZY\0" "ZZ\0" "Za\0" "Zb\0" "Zc\0" "Zd\0" "Ze\0" "Zf\0" "Zg\0" \
-"Zh\0" "Zi\0" "Zj\0" "Zk\0" "Zl\0" "Zm\0" "Zn\0" "Zo\0" "Zp\0" "Zq\0" "Zr\0" \
-"Zs\0" "Zt\0" "Zu\0" "Zv\0" "Zw\0" "Zx\0" "Zy\0" "Km\0" "Mi\0" "RQ\0" "Gm\0" \
-"AF\0" "AB\0" "xl\0" "dv\0" "ci\0" "s0\0" "s1\0" "s2\0" "s3\0" "ML\0" "MT\0" \
-"Xy\0" "Zz\0" "Yv\0" "Yw\0" "Yx\0" "Yy\0" "Yz\0" "YZ\0" "S1\0" "S2\0" "S3\0" \
-"S4\0" "S5\0" "S6\0" "S7\0" "S8\0" "Xh\0" "Xl\0" "Xo\0" "Xr\0" "Xt\0" "Xv\0" \
-"sA\0" "YI\0" "i2\0" "rs\0" "ug\0" "bs\0" "ns\0" "nc\0" "dC\0" "dN\0" "nl\0" \
-"bc\0" "MT\0" "NL\0" "dB\0" "dT\0" "kn\0" "ko\0" "ma\0" "pt\0" "xr\0" "G2\0" \
-"G3\0" "G1\0" "G4\0" "GR\0" "GL\0" "GU\0" "GD\0" "GH\0" "GV\0" "GC\0" "ml\0" \
-"mu\0" "bx\0" ;
-static const short _nc_offset_boolcodes[] = {
-0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42,
-45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87,
-90, 93, 96, 99, 102, 105, 108, 1401, 1404, 1407, 1422, 1425, 1443, 1446, };
-
-static NCURSES_CONST char ** ptr_boolcodes = 0;
-
-static const short _nc_offset_numcodes[] = {
-111, 114, 117, 120, 123, 126,
-129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162,
-165, 168, 171, 174, 177, 180, 183, 186, 189, 192, 195, 198,
-201, 204, 207, 1398, 1410, 1413, 1428, 1431, 1434, };
-
-static NCURSES_CONST char ** ptr_numcodes = 0;
-
-static const short _nc_offset_strcodes[] = {
-210, 213, 216, 219, 222, 225, 228, 231, 234,
-237, 240, 243, 246, 249, 252, 255, 258, 261, 264, 267, 270,
-273, 276, 279, 282, 285, 288, 291, 294, 297, 300, 303, 306,
-309, 312, 315, 318, 321, 324, 327, 330, 333, 336, 339, 342,
-345, 348, 351, 354, 357, 360, 363, 366, 369, 372, 375, 378,
-381, 384, 387, 390, 393, 396, 399, 402, 405, 408, 411, 414,
-417, 420, 423, 426, 429, 432, 435, 438, 441, 444, 447, 450,
-453, 456, 459, 462, 465, 468, 471, 474, 477, 480, 483, 486,
-489, 492, 495, 498, 501, 504, 507, 510, 513, 516, 519, 522,
-525, 528, 531, 534, 537, 540, 543, 546, 549, 552, 555, 558,
-561, 564, 567, 570, 573, 576, 579, 582, 585, 588, 591, 594,
-597, 600, 603, 606, 609, 612, 615, 618, 621, 624, 627, 630,
-633, 636, 639, 642, 645, 648, 651, 654, 657, 660, 663, 666,
-669, 672, 675, 678, 681, 684, 687, 690, 693, 696, 699, 702,
-705, 708, 711, 714, 717, 720, 723, 726, 729, 732, 735, 738,
-741, 744, 747, 750, 753, 756, 759, 762, 765, 768, 771, 774,
-777, 780, 783, 786, 789, 792, 795, 798, 801, 804, 807, 810,
-813, 816, 819, 822, 825, 828, 831, 834, 837, 840, 843, 846,
-849, 852, 855, 858, 861, 864, 867, 870, 873, 876, 879, 882,
-885, 888, 891, 894, 897, 900, 903, 906, 909, 912, 915, 918,
-921, 924, 927, 930, 933, 936, 939, 942, 945, 948, 951, 954,
-957, 960, 963, 966, 969, 972, 975, 978, 981, 984, 987, 990,
-993, 996, 999, 1002, 1005, 1008, 1011, 1014, 1017, 1020, 1023,
-1026, 1029, 1032, 1035, 1038, 1041, 1044, 1047, 1050, 1053, 1056,
-1059, 1062, 1065, 1068, 1071, 1074, 1077, 1080, 1083, 1086, 1089,
-1092, 1095, 1098, 1101, 1104, 1107, 1110, 1113, 1116, 1119, 1122,
-1125, 1128, 1131, 1134, 1137, 1140, 1143, 1146, 1149, 1152, 1155,
-1158, 1161, 1164, 1167, 1170, 1173, 1176, 1179, 1182, 1185, 1188,
-1191, 1194, 1197, 1200, 1203, 1206, 1209, 1212, 1215, 1218, 1221,
-1224, 1227, 1230, 1233, 1236, 1239, 1242, 1245, 1248, 1251, 1254,
-1257, 1260, 1263, 1266, 1269, 1272, 1275, 1278, 1281, 1284, 1287,
-1290, 1293, 1296, 1299, 1302, 1305, 1308, 1311, 1314, 1317, 1320,
-1323, 1326, 1329, 1332, 1335, 1338, 1341, 1344, 1347, 1350, 1353,
-1356, 1359, 1362, 1365, 1368, 1371, 1374, 1377, 1380, 1383, 1386,
-1389, 1392, 1395, 1416, 1419,
-1437, 1440, 1449, 1452,
-1455, 1458, 1461, 1464, 1467, 1470, 1473, 1476, 1479, 1482, 1485,
-1488, };
-
-static NCURSES_CONST char ** ptr_strcodes = 0;
-
-
-static IT *
-alloc_array(NCURSES_CONST char ***value, const short *offsets, unsigned size)
-{
-	if (*value == 0) {
-		if ((*value = typeCalloc(NCURSES_CONST char *, size + 1)) != 0) {
-			unsigned n;
-			for (n = 0; n < size; ++n) {
-				(*value)[n] = (NCURSES_CONST char *) _nc_code_blob + offsets[n];
-			}
-		}
-	}
-	return *value;
-}
-
-#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API NCURSES_PUBLIC_VAR(it)(void) { return alloc_array(&ptr_##it, _nc_offset_##it, SIZEOF(_nc_offset_##it)); }
-
-/* remove public definition which conflicts with FIX() */
-#undef boolcodes
-#undef numcodes
-#undef strcodes
-
-/* add local definition */
-FIX(boolcodes)
-FIX(numcodes)
-FIX(strcodes)
-
-/* restore the public definition */
-
-#define FREE_FIX(it) if (ptr_##it) { FreeAndNull(ptr_##it); }
-#define boolcodes  NCURSES_PUBLIC_VAR(boolcodes())
-#define numcodes   NCURSES_PUBLIC_VAR(numcodes())
-#define strcodes   NCURSES_PUBLIC_VAR(strcodes())
-
-#if NO_LEAKS
-NCURSES_EXPORT(void)
-_nc_codes_leaks(void)
-{
-FREE_FIX(boolcodes)
-FREE_FIX(numcodes)
-FREE_FIX(strcodes)
-}
-#endif
-
-#else
-
-#define DCL(it) NCURSES_EXPORT_VAR(IT) it[]
-
-DCL(boolcodes) = {
-		"bw",
-		"am",
-		"xb",
-		"xs",
-		"xn",
-		"eo",
-		"gn",
-		"hc",
-		"km",
-		"hs",
-		"in",
-		"da",
-		"db",
-		"mi",
-		"ms",
-		"os",
-		"es",
-		"xt",
-		"hz",
-		"ul",
-		"xo",
-		"nx",
-		"5i",
-		"HC",
-		"NR",
-		"NP",
-		"ND",
-		"cc",
-		"ut",
-		"hl",
-		"YA",
-		"YB",
-		"YC",
-		"YD",
-		"YE",
-		"YF",
-		"YG",
-		"bs",
-		"ns",
-		"nc",
-		"MT",
-		"NL",
-		"pt",
-		"xr",
-
-		(NCURSES_CONST char *)0,
-};
-
-DCL(numcodes) = {
-		"co",
-		"it",
-		"li",
-		"lm",
-		"sg",
-		"pb",
-		"vt",
-		"ws",
-		"Nl",
-		"lh",
-		"lw",
-		"ma",
-		"MW",
-		"Co",
-		"pa",
-		"NC",
-		"Ya",
-		"Yb",
-		"Yc",
-		"Yd",
-		"Ye",
-		"Yf",
-		"Yg",
-		"Yh",
-		"Yi",
-		"Yj",
-		"Yk",
-		"Yl",
-		"Ym",
-		"Yn",
-		"BT",
-		"Yo",
-		"Yp",
-		"ug",
-		"dC",
-		"dN",
-		"dB",
-		"dT",
-		"kn",
-
-		(NCURSES_CONST char *)0,
-};
-
-DCL(strcodes) = {
-		"bt",
-		"bl",
-		"cr",
-		"cs",
-		"ct",
-		"cl",
-		"ce",
-		"cd",
-		"ch",
-		"CC",
-		"cm",
-		"do",
-		"ho",
-		"vi",
-		"le",
-		"CM",
-		"ve",
-		"nd",
-		"ll",
-		"up",
-		"vs",
-		"dc",
-		"dl",
-		"ds",
-		"hd",
-		"as",
-		"mb",
-		"md",
-		"ti",
-		"dm",
-		"mh",
-		"im",
-		"mk",
-		"mp",
-		"mr",
-		"so",
-		"us",
-		"ec",
-		"ae",
-		"me",
-		"te",
-		"ed",
-		"ei",
-		"se",
-		"ue",
-		"vb",
-		"ff",
-		"fs",
-		"i1",
-		"is",
-		"i3",
-		"if",
-		"ic",
-		"al",
-		"ip",
-		"kb",
-		"ka",
-		"kC",
-		"kt",
-		"kD",
-		"kL",
-		"kd",
-		"kM",
-		"kE",
-		"kS",
-		"k0",
-		"k1",
-		"k;",
-		"k2",
-		"k3",
-		"k4",
-		"k5",
-		"k6",
-		"k7",
-		"k8",
-		"k9",
-		"kh",
-		"kI",
-		"kA",
-		"kl",
-		"kH",
-		"kN",
-		"kP",
-		"kr",
-		"kF",
-		"kR",
-		"kT",
-		"ku",
-		"ke",
-		"ks",
-		"l0",
-		"l1",
-		"la",
-		"l2",
-		"l3",
-		"l4",
-		"l5",
-		"l6",
-		"l7",
-		"l8",
-		"l9",
-		"mo",
-		"mm",
-		"nw",
-		"pc",
-		"DC",
-		"DL",
-		"DO",
-		"IC",
-		"SF",
-		"AL",
-		"LE",
-		"RI",
-		"SR",
-		"UP",
-		"pk",
-		"pl",
-		"px",
-		"ps",
-		"pf",
-		"po",
-		"rp",
-		"r1",
-		"r2",
-		"r3",
-		"rf",
-		"rc",
-		"cv",
-		"sc",
-		"sf",
-		"sr",
-		"sa",
-		"st",
-		"wi",
-		"ta",
-		"ts",
-		"uc",
-		"hu",
-		"iP",
-		"K1",
-		"K3",
-		"K2",
-		"K4",
-		"K5",
-		"pO",
-		"rP",
-		"ac",
-		"pn",
-		"kB",
-		"SX",
-		"RX",
-		"SA",
-		"RA",
-		"XN",
-		"XF",
-		"eA",
-		"LO",
-		"LF",
-		"@1",
-		"@2",
-		"@3",
-		"@4",
-		"@5",
-		"@6",
-		"@7",
-		"@8",
-		"@9",
-		"@0",
-		"%1",
-		"%2",
-		"%3",
-		"%4",
-		"%5",
-		"%6",
-		"%7",
-		"%8",
-		"%9",
-		"%0",
-		"&1",
-		"&2",
-		"&3",
-		"&4",
-		"&5",
-		"&6",
-		"&7",
-		"&8",
-		"&9",
-		"&0",
-		"*1",
-		"*2",
-		"*3",
-		"*4",
-		"*5",
-		"*6",
-		"*7",
-		"*8",
-		"*9",
-		"*0",
-		"#1",
-		"#2",
-		"#3",
-		"#4",
-		"%a",
-		"%b",
-		"%c",
-		"%d",
-		"%e",
-		"%f",
-		"%g",
-		"%h",
-		"%i",
-		"%j",
-		"!1",
-		"!2",
-		"!3",
-		"RF",
-		"F1",
-		"F2",
-		"F3",
-		"F4",
-		"F5",
-		"F6",
-		"F7",
-		"F8",
-		"F9",
-		"FA",
-		"FB",
-		"FC",
-		"FD",
-		"FE",
-		"FF",
-		"FG",
-		"FH",
-		"FI",
-		"FJ",
-		"FK",
-		"FL",
-		"FM",
-		"FN",
-		"FO",
-		"FP",
-		"FQ",
-		"FR",
-		"FS",
-		"FT",
-		"FU",
-		"FV",
-		"FW",
-		"FX",
-		"FY",
-		"FZ",
-		"Fa",
-		"Fb",
-		"Fc",
-		"Fd",
-		"Fe",
-		"Ff",
-		"Fg",
-		"Fh",
-		"Fi",
-		"Fj",
-		"Fk",
-		"Fl",
-		"Fm",
-		"Fn",
-		"Fo",
-		"Fp",
-		"Fq",
-		"Fr",
-		"cb",
-		"MC",
-		"ML",
-		"MR",
-		"Lf",
-		"SC",
-		"DK",
-		"RC",
-		"CW",
-		"WG",
-		"HU",
-		"DI",
-		"QD",
-		"TO",
-		"PU",
-		"fh",
-		"PA",
-		"WA",
-		"u0",
-		"u1",
-		"u2",
-		"u3",
-		"u4",
-		"u5",
-		"u6",
-		"u7",
-		"u8",
-		"u9",
-		"op",
-		"oc",
-		"Ic",
-		"Ip",
-		"sp",
-		"Sf",
-		"Sb",
-		"ZA",
-		"ZB",
-		"ZC",
-		"ZD",
-		"ZE",
-		"ZF",
-		"ZG",
-		"ZH",
-		"ZI",
-		"ZJ",
-		"ZK",
-		"ZL",
-		"ZM",
-		"ZN",
-		"ZO",
-		"ZP",
-		"ZQ",
-		"ZR",
-		"ZS",
-		"ZT",
-		"ZU",
-		"ZV",
-		"ZW",
-		"ZX",
-		"ZY",
-		"ZZ",
-		"Za",
-		"Zb",
-		"Zc",
-		"Zd",
-		"Ze",
-		"Zf",
-		"Zg",
-		"Zh",
-		"Zi",
-		"Zj",
-		"Zk",
-		"Zl",
-		"Zm",
-		"Zn",
-		"Zo",
-		"Zp",
-		"Zq",
-		"Zr",
-		"Zs",
-		"Zt",
-		"Zu",
-		"Zv",
-		"Zw",
-		"Zx",
-		"Zy",
-		"Km",
-		"Mi",
-		"RQ",
-		"Gm",
-		"AF",
-		"AB",
-		"xl",
-		"dv",
-		"ci",
-		"s0",
-		"s1",
-		"s2",
-		"s3",
-		"ML",
-		"MT",
-		"Xy",
-		"Zz",
-		"Yv",
-		"Yw",
-		"Yx",
-		"Yy",
-		"Yz",
-		"YZ",
-		"S1",
-		"S2",
-		"S3",
-		"S4",
-		"S5",
-		"S6",
-		"S7",
-		"S8",
-		"Xh",
-		"Xl",
-		"Xo",
-		"Xr",
-		"Xt",
-		"Xv",
-		"sA",
-		"YI",
-		"i2",
-		"rs",
-		"nl",
-		"bc",
-		"ko",
-		"ma",
-		"G2",
-		"G3",
-		"G1",
-		"G4",
-		"GR",
-		"GL",
-		"GU",
-		"GD",
-		"GH",
-		"GV",
-		"GC",
-		"ml",
-		"mu",
-		"bx",
-
-		(NCURSES_CONST char *)0,
-};
-
-
-#endif /* BROKEN_LINKER */
diff --git a/ncurses/comp_captab.c b/ncurses/comp_captab.c
deleted file mode 100644
index 0903c4e..0000000
--- a/ncurses/comp_captab.c
+++ /dev/null
@@ -1,3416 +0,0 @@
-/*
- * generated by ./tinfo/MKcaptab.sh
- */
-
-/*
- *	comp_captab.c -- The names of the capabilities indexed via a hash
- *		         table for the compiler.
- *
- */
-
-#include <curses.priv.h>
-#include <tic.h>
-#include <hashsize.h>
-
-/* 147 collisions out of 497 entries */
-static const char info_names_text[] = \
-"bw\0" "am\0" "xsb\0" "xhp\0" "xenl\0" "eo\0" "gn\0" "hc\0" "km\0" \
-"hs\0" "in\0" "da\0" "db\0" "mir\0" "msgr\0" "os\0" "eslok\0" "xt\0" \
-"hz\0" "ul\0" "xon\0" "nxon\0" "mc5i\0" "chts\0" "nrrmc\0" "npc\0" \
-"ndscr\0" "ccc\0" "bce\0" "hls\0" "xhpa\0" "crxm\0" "daisy\0" "xvpa\0" \
-"sam\0" "cpix\0" "lpix\0" "cols\0" "it\0" "lines\0" "lm\0" "xmc\0" \
-"pb\0" "vt\0" "wsl\0" "nlab\0" "lh\0" "lw\0" "ma\0" "wnum\0" "colors\0" \
-"pairs\0" "ncv\0" "bufsz\0" "spinv\0" "spinh\0" "maddr\0" "mjump\0" \
-"mcs\0" "mls\0" "npins\0" "orc\0" "orl\0" "orhi\0" "orvi\0" "cps\0" \
-"widcs\0" "btns\0" "bitwin\0" "bitype\0" "cbt\0" "bel\0" "cr\0" "csr\0" \
-"tbc\0" "clear\0" "el\0" "ed\0" "hpa\0" "cmdch\0" "cup\0" "cud1\0" \
-"home\0" "civis\0" "cub1\0" "mrcup\0" "cnorm\0" "cuf1\0" "ll\0" \
-"cuu1\0" "cvvis\0" "dch1\0" "dl1\0" "dsl\0" "hd\0" "smacs\0" "blink\0" \
-"bold\0" "smcup\0" "smdc\0" "dim\0" "smir\0" "invis\0" "prot\0" "rev\0" \
-"smso\0" "smul\0" "ech\0" "rmacs\0" "sgr0\0" "rmcup\0" "rmdc\0" \
-"rmir\0" "rmso\0" "rmul\0" "flash\0" "ff\0" "fsl\0" "is1\0" "is2\0" \
-"is3\0" "if\0" "ich1\0" "il1\0" "ip\0" "kbs\0" "ktbc\0" "kclr\0" \
-"kctab\0" "kdch1\0" "kdl1\0" "kcud1\0" "krmir\0" "kel\0" "ked\0" \
-"kf0\0" "kf1\0" "kf10\0" "kf2\0" "kf3\0" "kf4\0" "kf5\0" "kf6\0" \
-"kf7\0" "kf8\0" "kf9\0" "khome\0" "kich1\0" "kil1\0" "kcub1\0" "kll\0" \
-"knp\0" "kpp\0" "kcuf1\0" "kind\0" "kri\0" "khts\0" "kcuu1\0" "rmkx\0" \
-"smkx\0" "lf0\0" "lf1\0" "lf10\0" "lf2\0" "lf3\0" "lf4\0" "lf5\0" \
-"lf6\0" "lf7\0" "lf8\0" "lf9\0" "rmm\0" "smm\0" "nel\0" "pad\0" "dch\0" \
-"dl\0" "cud\0" "ich\0" "indn\0" "il\0" "cub\0" "cuf\0" "rin\0" "cuu\0" \
-"pfkey\0" "pfloc\0" "pfx\0" "mc0\0" "mc4\0" "mc5\0" "rep\0" "rs1\0" \
-"rs2\0" "rs3\0" "rf\0" "rc\0" "vpa\0" "sc\0" "ind\0" "ri\0" "sgr\0" \
-"hts\0" "wind\0" "ht\0" "tsl\0" "uc\0" "hu\0" "iprog\0" "ka1\0" "ka3\0" \
-"kb2\0" "kc1\0" "kc3\0" "mc5p\0" "rmp\0" "acsc\0" "pln\0" "kcbt\0" \
-"smxon\0" "rmxon\0" "smam\0" "rmam\0" "xonc\0" "xoffc\0" "enacs\0" \
-"smln\0" "rmln\0" "kbeg\0" "kcan\0" "kclo\0" "kcmd\0" "kcpy\0" "kcrt\0" \
-"kend\0" "kent\0" "kext\0" "kfnd\0" "khlp\0" "kmrk\0" "kmsg\0" "kmov\0" \
-"knxt\0" "kopn\0" "kopt\0" "kprv\0" "kprt\0" "krdo\0" "kref\0" "krfr\0" \
-"krpl\0" "krst\0" "kres\0" "ksav\0" "kspd\0" "kund\0" "kBEG\0" "kCAN\0" \
-"kCMD\0" "kCPY\0" "kCRT\0" "kDC\0" "kDL\0" "kslt\0" "kEND\0" "kEOL\0" \
-"kEXT\0" "kFND\0" "kHLP\0" "kHOM\0" "kIC\0" "kLFT\0" "kMSG\0" "kMOV\0" \
-"kNXT\0" "kOPT\0" "kPRV\0" "kPRT\0" "kRDO\0" "kRPL\0" "kRIT\0" "kRES\0" \
-"kSAV\0" "kSPD\0" "kUND\0" "rfi\0" "kf11\0" "kf12\0" "kf13\0" "kf14\0" \
-"kf15\0" "kf16\0" "kf17\0" "kf18\0" "kf19\0" "kf20\0" "kf21\0" "kf22\0" \
-"kf23\0" "kf24\0" "kf25\0" "kf26\0" "kf27\0" "kf28\0" "kf29\0" "kf30\0" \
-"kf31\0" "kf32\0" "kf33\0" "kf34\0" "kf35\0" "kf36\0" "kf37\0" "kf38\0" \
-"kf39\0" "kf40\0" "kf41\0" "kf42\0" "kf43\0" "kf44\0" "kf45\0" "kf46\0" \
-"kf47\0" "kf48\0" "kf49\0" "kf50\0" "kf51\0" "kf52\0" "kf53\0" "kf54\0" \
-"kf55\0" "kf56\0" "kf57\0" "kf58\0" "kf59\0" "kf60\0" "kf61\0" "kf62\0" \
-"kf63\0" "el1\0" "mgc\0" "smgl\0" "smgr\0" "fln\0" "sclk\0" "dclk\0" \
-"rmclk\0" "cwin\0" "wingo\0" "hup\0" "dial\0" "qdial\0" "tone\0" \
-"pulse\0" "hook\0" "pause\0" "wait\0" "u0\0" "u1\0" "u2\0" "u3\0" \
-"u4\0" "u5\0" "u6\0" "u7\0" "u8\0" "u9\0" "op\0" "oc\0" "initc\0" \
-"initp\0" "scp\0" "setf\0" "setb\0" "cpi\0" "lpi\0" "chr\0" "cvr\0" \
-"defc\0" "swidm\0" "sdrfq\0" "sitm\0" "slm\0" "smicm\0" "snlq\0" \
-"snrmq\0" "sshm\0" "ssubm\0" "ssupm\0" "sum\0" "rwidm\0" "ritm\0" \
-"rlm\0" "rmicm\0" "rshm\0" "rsubm\0" "rsupm\0" "rum\0" "mhpa\0" \
-"mcud1\0" "mcub1\0" "mcuf1\0" "mvpa\0" "mcuu1\0" "porder\0" "mcud\0" \
-"mcub\0" "mcuf\0" "mcuu\0" "scs\0" "smgb\0" "smgbp\0" "smglp\0" \
-"smgrp\0" "smgt\0" "smgtp\0" "sbim\0" "scsd\0" "rbim\0" "rcsd\0" \
-"subcs\0" "supcs\0" "docr\0" "zerom\0" "csnm\0" "kmous\0" "minfo\0" \
-"reqmp\0" "getm\0" "setaf\0" "setab\0" "pfxl\0" "devt\0" "csin\0" \
-"s0ds\0" "s1ds\0" "s2ds\0" "s3ds\0" "smglr\0" "smgtb\0" "birep\0" \
-"binel\0" "bicr\0" "colornm\0" "defbi\0" "endbi\0" "setcolor\0" \
-"slines\0" "dispc\0" "smpch\0" "rmpch\0" "smsc\0" "rmsc\0" "pctrm\0" \
-"scesc\0" "scesa\0" "ehhlm\0" "elhlm\0" "elohlm\0" "erhlm\0" "ethlm\0" \
-"evhlm\0" "sgr1\0" "slength\0" "OTi2\0" "OTrs\0" "OTug\0" "OTbs\0" \
-"OTns\0" "OTnc\0" "OTdC\0" "OTdN\0" "OTnl\0" "OTbc\0" "OTMT\0" "OTNL\0" \
-"OTdB\0" "OTdT\0" "OTkn\0" "OTko\0" "OTma\0" "OTpt\0" "OTxr\0" "OTG2\0" \
-"OTG3\0" "OTG1\0" "OTG4\0" "OTGR\0" "OTGL\0" "OTGU\0" "OTGD\0" "OTGH\0" \
-"OTGV\0" "OTGC\0" "meml\0" "memu\0" "box1\0" ;
-
-static name_table_data const info_names_data[] =
-{
-	{               0,	   BOOLEAN,	  0,  -1 },
-	{               3,	   BOOLEAN,	  1,  -1 },
-	{               6,	   BOOLEAN,	  2,  -1 },
-	{              10,	   BOOLEAN,	  3,  -1 },
-	{              14,	   BOOLEAN,	  4,  -1 },
-	{              19,	   BOOLEAN,	  5,  -1 },
-	{              22,	   BOOLEAN,	  6,  -1 },
-	{              25,	   BOOLEAN,	  7,  -1 },
-	{              28,	   BOOLEAN,	  8,  -1 },
-	{              31,	   BOOLEAN,	  9,  -1 },
-	{              34,	   BOOLEAN,	 10,  -1 },
-	{              37,	   BOOLEAN,	 11,  -1 },
-	{              40,	   BOOLEAN,	 12,  -1 },
-	{              43,	   BOOLEAN,	 13,  -1 },
-	{              47,	   BOOLEAN,	 14,  -1 },
-	{              52,	   BOOLEAN,	 15,  -1 },
-	{              55,	   BOOLEAN,	 16,  -1 },
-	{              61,	   BOOLEAN,	 17,  -1 },
-	{              64,	   BOOLEAN,	 18,  -1 },
-	{              67,	   BOOLEAN,	 19,  -1 },
-	{              70,	   BOOLEAN,	 20,  -1 },
-	{              74,	   BOOLEAN,	 21,  -1 },
-	{              79,	   BOOLEAN,	 22,  -1 },
-	{              84,	   BOOLEAN,	 23,  -1 },
-	{              89,	   BOOLEAN,	 24,  -1 },
-	{              95,	   BOOLEAN,	 25,  -1 },
-	{              99,	   BOOLEAN,	 26,  -1 },
-	{             105,	   BOOLEAN,	 27,  -1 },
-	{             109,	   BOOLEAN,	 28,  -1 },
-	{             113,	   BOOLEAN,	 29,  -1 },
-	{             117,	   BOOLEAN,	 30,  -1 },
-	{             122,	   BOOLEAN,	 31,  -1 },
-	{             127,	   BOOLEAN,	 32,  -1 },
-	{             133,	   BOOLEAN,	 33,  -1 },
-	{             138,	   BOOLEAN,	 34,  -1 },
-	{             142,	   BOOLEAN,	 35,  -1 },
-	{             147,	   BOOLEAN,	 36,  -1 },
-	{             152,	    NUMBER,	  0,  -1 },
-	{             157,	    NUMBER,	  1,  -1 },
-	{             160,	    NUMBER,	  2,   6 },
-	{             166,	    NUMBER,	  3,  -1 },
-	{             169,	    NUMBER,	  4,  -1 },
-	{             173,	    NUMBER,	  5,  -1 },
-	{             176,	    NUMBER,	  6,  -1 },
-	{             179,	    NUMBER,	  7,  -1 },
-	{             183,	    NUMBER,	  8,  -1 },
-	{             188,	    NUMBER,	  9,  -1 },
-	{             191,	    NUMBER,	 10,  -1 },
-	{             194,	    NUMBER,	 11,  -1 },
-	{             197,	    NUMBER,	 12,  -1 },
-	{             202,	    NUMBER,	 13,  -1 },
-	{             209,	    NUMBER,	 14,  -1 },
-	{             215,	    NUMBER,	 15,  -1 },
-	{             219,	    NUMBER,	 16,  46 },
-	{             225,	    NUMBER,	 17,  -1 },
-	{             231,	    NUMBER,	 18,  -1 },
-	{             237,	    NUMBER,	 19,  -1 },
-	{             243,	    NUMBER,	 20,  -1 },
-	{             249,	    NUMBER,	 21,  -1 },
-	{             253,	    NUMBER,	 22,  -1 },
-	{             257,	    NUMBER,	 23,  -1 },
-	{             263,	    NUMBER,	 24,  -1 },
-	{             267,	    NUMBER,	 25,  -1 },
-	{             271,	    NUMBER,	 26,  -1 },
-	{             276,	    NUMBER,	 27,  -1 },
-	{             281,	    NUMBER,	 28,  -1 },
-	{             285,	    NUMBER,	 29,  -1 },
-	{             291,	    NUMBER,	 30,  -1 },
-	{             296,	    NUMBER,	 31,  -1 },
-	{             303,	    NUMBER,	 32,  68 },
-	{             310,	    STRING,	  0,  -1 },
-	{             314,	    STRING,	  1,  -1 },
-	{             318,	    STRING,	  2,  -1 },
-	{             321,	    STRING,	  3,  -1 },
-	{             325,	    STRING,	  4,  -1 },
-	{             329,	    STRING,	  5,  -1 },
-	{             335,	    STRING,	  6,  -1 },
-	{             338,	    STRING,	  7,  -1 },
-	{             341,	    STRING,	  8,  -1 },
-	{             345,	    STRING,	  9,  -1 },
-	{             351,	    STRING,	 10,  73 },
-	{             355,	    STRING,	 11,  -1 },
-	{             360,	    STRING,	 12,  -1 },
-	{             365,	    STRING,	 13,  -1 },
-	{             371,	    STRING,	 14,  -1 },
-	{             376,	    STRING,	 15,  -1 },
-	{             382,	    STRING,	 16,  -1 },
-	{             388,	    STRING,	 17,  -1 },
-	{             393,	    STRING,	 18,  -1 },
-	{             396,	    STRING,	 19,  -1 },
-	{             401,	    STRING,	 20,  -1 },
-	{             407,	    STRING,	 21,  -1 },
-	{             412,	    STRING,	 22,  -1 },
-	{             416,	    STRING,	 23,  -1 },
-	{             420,	    STRING,	 24,  -1 },
-	{             423,	    STRING,	 25,  -1 },
-	{             429,	    STRING,	 26,  -1 },
-	{             435,	    STRING,	 27,  -1 },
-	{             440,	    STRING,	 28,  -1 },
-	{             446,	    STRING,	 29,  -1 },
-	{             451,	    STRING,	 30,  -1 },
-	{             455,	    STRING,	 31,  -1 },
-	{             460,	    STRING,	 32,  -1 },
-	{             466,	    STRING,	 33,  -1 },
-	{             471,	    STRING,	 34,  -1 },
-	{             475,	    STRING,	 35,  -1 },
-	{             480,	    STRING,	 36,  -1 },
-	{             485,	    STRING,	 37,  -1 },
-	{             489,	    STRING,	 38,  -1 },
-	{             495,	    STRING,	 39,  -1 },
-	{             500,	    STRING,	 40,  -1 },
-	{             506,	    STRING,	 41,  -1 },
-	{             511,	    STRING,	 42,  -1 },
-	{             516,	    STRING,	 43,  -1 },
-	{             521,	    STRING,	 44,  -1 },
-	{             526,	    STRING,	 45,  -1 },
-	{             532,	    STRING,	 46,  -1 },
-	{             535,	    STRING,	 47,  -1 },
-	{             539,	    STRING,	 48,  -1 },
-	{             543,	    STRING,	 49,  59 },
-	{             547,	    STRING,	 50,  76 },
-	{             551,	    STRING,	 51,  -1 },
-	{             554,	    STRING,	 52,  20 },
-	{             559,	    STRING,	 53,  -1 },
-	{             563,	    STRING,	 54,  -1 },
-	{             566,	    STRING,	 55,  -1 },
-	{             570,	    STRING,	 56,  -1 },
-	{             575,	    STRING,	 57,  98 },
-	{             580,	    STRING,	 58,  -1 },
-	{             586,	    STRING,	 59,  -1 },
-	{             592,	    STRING,	 60,  -1 },
-	{             597,	    STRING,	 61,  -1 },
-	{             603,	    STRING,	 62,  -1 },
-	{             609,	    STRING,	 63,  -1 },
-	{             613,	    STRING,	 64,  -1 },
-	{             617,	    STRING,	 65,  -1 },
-	{             621,	    STRING,	 66,  -1 },
-	{             625,	    STRING,	 67,  -1 },
-	{             630,	    STRING,	 68,  -1 },
-	{             634,	    STRING,	 69,  -1 },
-	{             638,	    STRING,	 70,  -1 },
-	{             642,	    STRING,	 71,  61 },
-	{             646,	    STRING,	 72,  -1 },
-	{             650,	    STRING,	 73,  -1 },
-	{             654,	    STRING,	 74,  -1 },
-	{             658,	    STRING,	 75,  -1 },
-	{             662,	    STRING,	 76,  -1 },
-	{             668,	    STRING,	 77,  -1 },
-	{             674,	    STRING,	 78,  -1 },
-	{             679,	    STRING,	 79,  -1 },
-	{             685,	    STRING,	 80,  -1 },
-	{             689,	    STRING,	 81,  -1 },
-	{             693,	    STRING,	 82,  -1 },
-	{             697,	    STRING,	 83,  -1 },
-	{             703,	    STRING,	 84,  55 },
-	{             708,	    STRING,	 85, 105 },
-	{             712,	    STRING,	 86,  -1 },
-	{             717,	    STRING,	 87,  81 },
-	{             723,	    STRING,	 88,  -1 },
-	{             728,	    STRING,	 89,  -1 },
-	{             733,	    STRING,	 90,  -1 },
-	{             737,	    STRING,	 91,  -1 },
-	{             741,	    STRING,	 92,  -1 },
-	{             746,	    STRING,	 93,  -1 },
-	{             750,	    STRING,	 94,  33 },
-	{             754,	    STRING,	 95,  -1 },
-	{             758,	    STRING,	 96,  -1 },
-	{             762,	    STRING,	 97,  -1 },
-	{             766,	    STRING,	 98,   7 },
-	{             770,	    STRING,	 99,  94 },
-	{             774,	    STRING,	100,  -1 },
-	{             778,	    STRING,	101, 131 },
-	{             782,	    STRING,	102,  -1 },
-	{             786,	    STRING,	103,  -1 },
-	{             790,	    STRING,	104,  30 },
-	{             794,	    STRING,	105,  -1 },
-	{             798,	    STRING,	106,  -1 },
-	{             801,	    STRING,	107,  -1 },
-	{             805,	    STRING,	108,  -1 },
-	{             809,	    STRING,	109,  -1 },
-	{             814,	    STRING,	110,  -1 },
-	{             817,	    STRING,	111,  -1 },
-	{             821,	    STRING,	112, 156 },
-	{             825,	    STRING,	113,  -1 },
-	{             829,	    STRING,	114,  -1 },
-	{             833,	    STRING,	115,  51 },
-	{             839,	    STRING,	116,  -1 },
-	{             845,	    STRING,	117,  -1 },
-	{             849,	    STRING,	118,  -1 },
-	{             853,	    STRING,	119,  -1 },
-	{             857,	    STRING,	120,  -1 },
-	{             861,	    STRING,	121,  -1 },
-	{             865,	    STRING,	122,  -1 },
-	{             869,	    STRING,	123,  -1 },
-	{             873,	    STRING,	124, 126 },
-	{             877,	    STRING,	125,  -1 },
-	{             880,	    STRING,	126,  -1 },
-	{             883,	    STRING,	127,  -1 },
-	{             887,	    STRING,	128,  -1 },
-	{             890,	    STRING,	129,  -1 },
-	{             894,	    STRING,	130,  -1 },
-	{             897,	    STRING,	131,  -1 },
-	{             901,	    STRING,	132,  -1 },
-	{             905,	    STRING,	133,  -1 },
-	{             910,	    STRING,	134,  -1 },
-	{             913,	    STRING,	135,  -1 },
-	{             917,	    STRING,	136,  23 },
-	{             920,	    STRING,	137,  -1 },
-	{             923,	    STRING,	138,  -1 },
-	{             929,	    STRING,	139,  -1 },
-	{             933,	    STRING,	140,  -1 },
-	{             937,	    STRING,	141, 210 },
-	{             941,	    STRING,	142, 211 },
-	{             945,	    STRING,	143, 135 },
-	{             949,	    STRING,	144,  -1 },
-	{             954,	    STRING,	145,  -1 },
-	{             958,	    STRING,	146, 176 },
-	{             963,	    STRING,	147,  -1 },
-	{             967,	    STRING,	148, 194 },
-	{             972,	    STRING,	149,  -1 },
-	{             978,	    STRING,	150,  -1 },
-	{             984,	    STRING,	151, 137 },
-	{             989,	    STRING,	152,  -1 },
-	{             994,	    STRING,	153,  -1 },
-	{             999,	    STRING,	154,  -1 },
-	{            1005,	    STRING,	155,  -1 },
-	{            1011,	    STRING,	156,  -1 },
-	{            1016,	    STRING,	157,  -1 },
-	{            1021,	    STRING,	158,  -1 },
-	{            1026,	    STRING,	159,  -1 },
-	{            1031,	    STRING,	160,  -1 },
-	{            1036,	    STRING,	161,  -1 },
-	{            1041,	    STRING,	162,  -1 },
-	{            1046,	    STRING,	163,  54 },
-	{            1051,	    STRING,	164, 192 },
-	{            1056,	    STRING,	165,  -1 },
-	{            1061,	    STRING,	166,  -1 },
-	{            1066,	    STRING,	167, 193 },
-	{            1071,	    STRING,	168,  -1 },
-	{            1076,	    STRING,	169,  70 },
-	{            1081,	    STRING,	170, 235 },
-	{            1086,	    STRING,	171,  -1 },
-	{            1091,	    STRING,	172,  -1 },
-	{            1096,	    STRING,	173, 177 },
-	{            1101,	    STRING,	174,  -1 },
-	{            1106,	    STRING,	175,  -1 },
-	{            1111,	    STRING,	176,  -1 },
-	{            1116,	    STRING,	177,  -1 },
-	{            1121,	    STRING,	178,  -1 },
-	{            1126,	    STRING,	179, 239 },
-	{            1131,	    STRING,	180, 219 },
-	{            1136,	    STRING,	181,  80 },
-	{            1141,	    STRING,	182, 249 },
-	{            1146,	    STRING,	183, 252 },
-	{            1151,	    STRING,	184, 240 },
-	{            1156,	    STRING,	185, 254 },
-	{            1161,	    STRING,	186,  -1 },
-	{            1166,	    STRING,	187,  -1 },
-	{            1171,	    STRING,	188, 101 },
-	{            1176,	    STRING,	189,  -1 },
-	{            1181,	    STRING,	190,  -1 },
-	{            1186,	    STRING,	191,  -1 },
-	{            1190,	    STRING,	192,  -1 },
-	{            1194,	    STRING,	193, 244 },
-	{            1199,	    STRING,	194,  -1 },
-	{            1204,	    STRING,	195, 152 },
-	{            1209,	    STRING,	196,  -1 },
-	{            1214,	    STRING,	197, 150 },
-	{            1219,	    STRING,	198,  -1 },
-	{            1224,	    STRING,	199, 268 },
-	{            1229,	    STRING,	200,  -1 },
-	{            1233,	    STRING,	201,  72 },
-	{            1238,	    STRING,	202,  -1 },
-	{            1243,	    STRING,	203,  -1 },
-	{            1248,	    STRING,	204,  -1 },
-	{            1253,	    STRING,	205,  -1 },
-	{            1258,	    STRING,	206,  -1 },
-	{            1263,	    STRING,	207, 196 },
-	{            1268,	    STRING,	208,  -1 },
-	{            1273,	    STRING,	209,  -1 },
-	{            1278,	    STRING,	210,  -1 },
-	{            1283,	    STRING,	211,  -1 },
-	{            1288,	    STRING,	212, 281 },
-	{            1293,	    STRING,	213, 272 },
-	{            1298,	    STRING,	214, 283 },
-	{            1303,	    STRING,	215,  -1 },
-	{            1307,	    STRING,	216,  -1 },
-	{            1312,	    STRING,	217, 134 },
-	{            1317,	    STRING,	218,  -1 },
-	{            1322,	    STRING,	219,  -1 },
-	{            1327,	    STRING,	220,  -1 },
-	{            1332,	    STRING,	221,  43 },
-	{            1337,	    STRING,	222, 256 },
-	{            1342,	    STRING,	223,  -1 },
-	{            1347,	    STRING,	224,  -1 },
-	{            1352,	    STRING,	225, 286 },
-	{            1357,	    STRING,	226, 287 },
-	{            1362,	    STRING,	227, 288 },
-	{            1367,	    STRING,	228, 289 },
-	{            1372,	    STRING,	229, 290 },
-	{            1377,	    STRING,	230, 291 },
-	{            1382,	    STRING,	231, 292 },
-	{            1387,	    STRING,	232, 293 },
-	{            1392,	    STRING,	233, 294 },
-	{            1397,	    STRING,	234, 133 },
-	{            1402,	    STRING,	235, 296 },
-	{            1407,	    STRING,	236, 297 },
-	{            1412,	    STRING,	237, 298 },
-	{            1417,	    STRING,	238, 299 },
-	{            1422,	    STRING,	239, 300 },
-	{            1427,	    STRING,	240, 301 },
-	{            1432,	    STRING,	241, 302 },
-	{            1437,	    STRING,	242, 303 },
-	{            1442,	    STRING,	243, 304 },
-	{            1447,	    STRING,	244, 257 },
-	{            1452,	    STRING,	245, 306 },
-	{            1457,	    STRING,	246, 307 },
-	{            1462,	    STRING,	247, 308 },
-	{            1467,	    STRING,	248, 309 },
-	{            1472,	    STRING,	249, 310 },
-	{            1477,	    STRING,	250, 311 },
-	{            1482,	    STRING,	251, 312 },
-	{            1487,	    STRING,	252, 313 },
-	{            1492,	    STRING,	253, 314 },
-	{            1497,	    STRING,	254, 226 },
-	{            1502,	    STRING,	255, 316 },
-	{            1507,	    STRING,	256, 317 },
-	{            1512,	    STRING,	257, 318 },
-	{            1517,	    STRING,	258, 319 },
-	{            1522,	    STRING,	259, 320 },
-	{            1527,	    STRING,	260, 321 },
-	{            1532,	    STRING,	261, 322 },
-	{            1537,	    STRING,	262, 323 },
-	{            1542,	    STRING,	263, 324 },
-	{            1547,	    STRING,	264, 258 },
-	{            1552,	    STRING,	265, 326 },
-	{            1557,	    STRING,	266, 327 },
-	{            1562,	    STRING,	267, 328 },
-	{            1567,	    STRING,	268, 329 },
-	{            1572,	    STRING,	269,  -1 },
-	{            1576,	    STRING,	270,  -1 },
-	{            1580,	    STRING,	271, 335 },
-	{            1585,	    STRING,	272, 332 },
-	{            1590,	    STRING,	273,  -1 },
-	{            1594,	    STRING,	274,  -1 },
-	{            1599,	    STRING,	275,  -1 },
-	{            1604,	    STRING,	276,  -1 },
-	{            1610,	    STRING,	277,  37 },
-	{            1615,	    STRING,	278,  -1 },
-	{            1621,	    STRING,	279,  -1 },
-	{            1625,	    STRING,	280,  -1 },
-	{            1630,	    STRING,	281,  -1 },
-	{            1636,	    STRING,	282,  -1 },
-	{            1641,	    STRING,	283,  -1 },
-	{            1647,	    STRING,	284,  -1 },
-	{            1652,	    STRING,	285,   8 },
-	{            1658,	    STRING,	286, 262 },
-	{            1663,	    STRING,	287,  -1 },
-	{            1666,	    STRING,	288,  -1 },
-	{            1669,	    STRING,	289,  -1 },
-	{            1672,	    STRING,	290,  -1 },
-	{            1675,	    STRING,	291,  -1 },
-	{            1678,	    STRING,	292,  -1 },
-	{            1681,	    STRING,	293,  -1 },
-	{            1684,	    STRING,	294,  -1 },
-	{            1687,	    STRING,	295,  -1 },
-	{            1690,	    STRING,	296,  -1 },
-	{            1693,	    STRING,	297,  -1 },
-	{            1696,	    STRING,	298,  -1 },
-	{            1699,	    STRING,	299,  -1 },
-	{            1705,	    STRING,	300,  -1 },
-	{            1711,	    STRING,	301,  -1 },
-	{            1715,	    STRING,	302, 325 },
-	{            1720,	    STRING,	303, 221 },
-	{            1725,	    STRING,	304, 243 },
-	{            1729,	    STRING,	305,  -1 },
-	{            1733,	    STRING,	306, 250 },
-	{            1737,	    STRING,	307,  -1 },
-	{            1741,	    STRING,	308, 141 },
-	{            1746,	    STRING,	309, 248 },
-	{            1752,	    STRING,	310, 218 },
-	{            1758,	    STRING,	311,  -1 },
-	{            1763,	    STRING,	312, 201 },
-	{            1767,	    STRING,	313, 229 },
-	{            1773,	    STRING,	314, 264 },
-	{            1778,	    STRING,	315, 253 },
-	{            1784,	    STRING,	316, 334 },
-	{            1789,	    STRING,	317,  -1 },
-	{            1795,	    STRING,	318, 236 },
-	{            1801,	    STRING,	319, 185 },
-	{            1805,	    STRING,	320,  -1 },
-	{            1811,	    STRING,	321,  -1 },
-	{            1816,	    STRING,	322,  -1 },
-	{            1820,	    STRING,	323,  -1 },
-	{            1826,	    STRING,	324, 112 },
-	{            1831,	    STRING,	325,  -1 },
-	{            1837,	    STRING,	326,  -1 },
-	{            1843,	    STRING,	327,  -1 },
-	{            1847,	    STRING,	328,  -1 },
-	{            1852,	    STRING,	329,  -1 },
-	{            1858,	    STRING,	330,  -1 },
-	{            1864,	    STRING,	331,  53 },
-	{            1870,	    STRING,	332,  -1 },
-	{            1875,	    STRING,	333,  47 },
-	{            1881,	    STRING,	334, 155 },
-	{            1888,	    STRING,	335,  -1 },
-	{            1893,	    STRING,	336,  -1 },
-	{            1898,	    STRING,	337,  -1 },
-	{            1903,	    STRING,	338,  -1 },
-	{            1908,	    STRING,	339,  -1 },
-	{            1912,	    STRING,	340,  -1 },
-	{            1917,	    STRING,	341, 383 },
-	{            1923,	    STRING,	342,  -1 },
-	{            1929,	    STRING,	343,  -1 },
-	{            1935,	    STRING,	344, 386 },
-	{            1940,	    STRING,	345, 238 },
-	{            1946,	    STRING,	346,  -1 },
-	{            1951,	    STRING,	347, 344 },
-	{            1956,	    STRING,	348,  31 },
-	{            1961,	    STRING,	349,  -1 },
-	{            1966,	    STRING,	350, 380 },
-	{            1972,	    STRING,	351, 255 },
-	{            1978,	    STRING,	352,  -1 },
-	{            1983,	    STRING,	353,  -1 },
-	{            1989,	    STRING,	354, 347 },
-	{            1994,	    STRING,	355,  -1 },
-	{            2000,	    STRING,	356,  -1 },
-	{            2006,	    STRING,	357,  -1 },
-	{            2012,	    STRING,	358,  87 },
-	{            2017,	    STRING,	359,  -1 },
-	{            2023,	    STRING,	360,  -1 },
-	{            2029,	    STRING,	361,  -1 },
-	{            2034,	    STRING,	362,  -1 },
-	{            2039,	    STRING,	363,  -1 },
-	{            2044,	    STRING,	364,  -1 },
-	{            2049,	    STRING,	365, 212 },
-	{            2054,	    STRING,	366, 109 },
-	{            2059,	    STRING,	367, 213 },
-	{            2064,	    STRING,	368, 230 },
-	{            2070,	    STRING,	369,  -1 },
-	{            2076,	    STRING,	370,  -1 },
-	{            2082,	    STRING,	371,  -1 },
-	{            2088,	    STRING,	372,  -1 },
-	{            2093,	    STRING,	373,  -1 },
-	{            2101,	    STRING,	374,  -1 },
-	{            2107,	    STRING,	375,  -1 },
-	{            2113,	    STRING,	376,  -1 },
-	{            2122,	    STRING,	377, 116 },
-	{            2129,	    STRING,	378,  -1 },
-	{            2135,	    STRING,	379, 231 },
-	{            2141,	    STRING,	380,  -1 },
-	{            2147,	    STRING,	381, 338 },
-	{            2152,	    STRING,	382,  -1 },
-	{            2157,	    STRING,	383,  -1 },
-	{            2163,	    STRING,	384, 197 },
-	{            2169,	    STRING,	385, 430 },
-	{            2175,	    STRING,	386,  -1 },
-	{            2181,	    STRING,	387,  -1 },
-	{            2187,	    STRING,	388,  -1 },
-	{            2194,	    STRING,	389,  -1 },
-	{            2200,	    STRING,	390,  -1 },
-	{            2206,	    STRING,	391,  -1 },
-	{            2212,	    STRING,	392, 437 },
-	{            2217,	    STRING,	393,  -1 },
-	{            2225,	    STRING,	394,  -1 },
-	{            2230,	    STRING,	395,  -1 },
-	{            2235,	    NUMBER,	 33,  -1 },
-	{            2240,	   BOOLEAN,	 37,  -1 },
-	{            2245,	   BOOLEAN,	 38,  -1 },
-	{            2250,	   BOOLEAN,	 39,  -1 },
-	{            2255,	    NUMBER,	 34,  -1 },
-	{            2260,	    NUMBER,	 35,  -1 },
-	{            2265,	    STRING,	396,  -1 },
-	{            2270,	    STRING,	397,  13 },
-	{            2275,	   BOOLEAN,	 40,  -1 },
-	{            2280,	   BOOLEAN,	 41, 446 },
-	{            2285,	    NUMBER,	 36,  -1 },
-	{            2290,	    NUMBER,	 37,  -1 },
-	{            2295,	    NUMBER,	 38,  -1 },
-	{            2300,	    STRING,	398, 472 },
-	{            2305,	    STRING,	399,  -1 },
-	{            2310,	   BOOLEAN,	 42,  -1 },
-	{            2315,	   BOOLEAN,	 43,  -1 },
-	{            2320,	    STRING,	400,  -1 },
-	{            2325,	    STRING,	401,  -1 },
-	{            2330,	    STRING,	402,  -1 },
-	{            2335,	    STRING,	403,  -1 },
-	{            2340,	    STRING,	404,  -1 },
-	{            2345,	    STRING,	405,  -1 },
-	{            2350,	    STRING,	406,  -1 },
-	{            2355,	    STRING,	407,  -1 },
-	{            2360,	    STRING,	408,  26 },
-	{            2365,	    STRING,	409,  60 },
-	{            2370,	    STRING,	410, 121 },
-	{            2375,	    STRING,	411, 407 },
-	{            2380,	    STRING,	412, 402 },
-	{            2385,	    STRING,	413,  -1 } 
-};
-
-static struct name_table_entry *_nc_info_table = 0;
-
-static const HashValue _nc_info_hash_table[995] =
-{
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	465,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	261,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	457,
-	 -1,
-	 -1,
-	265,
-	216,
-	120,
-	 -1,
-	 -1,
-	 -1,
-	180,
-	 -1,
-	 -1,
-	 88,
-	 -1,
-	420,
-	 -1,
-	398,
-	 -1,
-	348,
-	 -1,
-	 -1,
-	 19,
-	 -1,
-	 -1,
-	 -1,
-	359,
-	 -1,
-	174,
-	 -1,
-	245,
-	 -1,
-	 74,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	269,
-	 -1,
-	480,
-	 -1,
-	 -1,
-	 -1,
-	124,
-	 -1,
-	 -1,
-	 -1,
-	390,
-	379,
-	367,
-	 -1,
-	 -1,
-	444,
-	 -1,
-	 -1,
-	 -1,
-	305,
-	 -1,
-	 -1,
-	363,
-	 -1,
-	 -1,
-	483,
-	377,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	460,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	204,
-	 38,
-	 -1,
-	 82,
-	 -1,
-	110,
-	127,
-	 -1,
-	 -1,
-	463,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	336,
-	 -1,
-	 17,
-	128,
-	434,
-	 -1,
-	188,
-	129,
-	 -1,
-	351,
-	 -1,
-	 -1,
-	 16,
-	 -1,
-	 -1,
-	259,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	489,
-	 -1,
-	353,
-	 -1,
-	 71,
-	247,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 78,
-	 -1,
-	 -1,
-	331,
-	 -1,
-	 -1,
-	173,
-	136,
-	161,
-	189,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	454,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	224,
-	479,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	354,
-	 -1,
-	 -1,
-	233,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	125,
-	 11,
-	 -1,
-	 -1,
-	378,
-	166,
-	 -1,
-	191,
-	 -1,
-	 -1,
-	 48,
-	228,
-	 -1,
-	  2,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	374,
-	 -1,
-	408,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	375,
-	 -1,
-	 52,
-	145,
-	170,
-	 -1,
-	392,
-	382,
-	 -1,
-	393,
-	411,
-	 -1,
-	 -1,
-	 -1,
-	276,
-	 -1,
-	 -1,
-	 35,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	396,
-	388,
-	 36,
-	 -1,
-	 -1,
-	 64,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	350,
-	 -1,
-	 -1,
-	215,
-	 91,
-	 -1,
-	 -1,
-	439,
-	 -1,
-	122,
-	 -1,
-	200,
-	 -1,
-	 67,
-	 -1,
-	410,
-	 -1,
-	 -1,
-	 89,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 96,
-	 21,
-	 -1,
-	103,
-	  1,
-	 -1,
-	 -1,
-	369,
-	 -1,
-	 -1,
-	345,
-	 -1,
-	 -1,
-	 -1,
-	355,
-	 40,
-	 -1,
-	 27,
-	 -1,
-	406,
-	 -1,
-	 -1,
-	 -1,
-	482,
-	419,
-	417,
-	 -1,
-	 -1,
-	360,
-	270,
-	 -1,
-	 -1,
-	251,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	349,
-	 -1,
-	 -1,
-	278,
-	 -1,
-	442,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	438,
-	 -1,
-	494,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	315,
-	 -1,
-	340,
-	364,
-	356,
-	 -1,
-	484,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 32,
-	 -1,
-	 -1,
-	 -1,
-	260,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	207,
-	487,
-	 84,
-	453,
-	 -1,
-	 -1,
-	413,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	214,
-	 -1,
-	337,
-	352,
-	477,
-	 -1,
-	435,
-	 56,
-	 -1,
-	 -1,
-	 34,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	132,
-	 -1,
-	 85,
-	492,
-	428,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	199,
-	 -1,
-	342,
-	 -1,
-	 -1,
-	 -1,
-	138,
-	163,
-	190,
-	147,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	266,
-	 -1,
-	 -1,
-	433,
-	 -1,
-	 -1,
-	474,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	385,
-	100,
-	 -1,
-	 -1,
-	 -1,
-	431,
-	 -1,
-	391,
-	381,
-	 12,
-	 58,
-	 -1,
-	142,
-	167,
-	 -1,
-	 -1,
-	409,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 42,
-	 45,
-	 66,
-	 -1,
-	 -1,
-	424,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	220,
-	376,
-	 -1,
-	 -1,
-	343,
-	 -1,
-	 -1,
-	 -1,
-	114,
-	106,
-	 -1,
-	 -1,
-	447,
-	 -1,
-	217,
-	493,
-	171,
-	172,
-	399,
-	346,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	195,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	496,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	241,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	151,
-	 -1,
-	118,
-	 -1,
-	 62,
-	187,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	234,
-	 -1,
-	443,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	357,
-	 -1,
-	 -1,
-	 -1,
-	246,
-	 -1,
-	 -1,
-	 -1,
-	448,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 39,
-	 -1,
-	 10,
-	397,
-	389,
-	 -1,
-	 -1,
-	154,
-	 -1,
-	 -1,
-	 -1,
-	130,
-	 -1,
-	 22,
-	222,
-	373,
-	162,
-	 -1,
-	361,
-	203,
-	 -1,
-	 -1,
-	242,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	459,
-	 -1,
-	 -1,
-	271,
-	 -1,
-	 97,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	427,
-	 -1,
-	175,
-	107,
-	 -1,
-	 -1,
-	 -1,
-	178,
-	423,
-	372,
-	 69,
-	 -1,
-	365,
-	 -1,
-	  4,
-	486,
-	184,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	461,
-	 -1,
-	 -1,
-	282,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	475,
-	 -1,
-	 -1,
-	 -1,
-	395,
-	387,
-	 -1,
-	 -1,
-	 79,
-	 63,
-	 -1,
-	 -1,
-	452,
-	451,
-	 -1,
-	 50,
-	 -1,
-	436,
-	 -1,
-	 -1,
-	285,
-	 -1,
-	 -1,
-	 83,
-	455,
-	 -1,
-	 -1,
-	 -1,
-	279,
-	370,
-	 -1,
-	 -1,
-	 -1,
-	 18,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	421,
-	 -1,
-	495,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	227,
-	333,
-	 -1,
-	 -1,
-	 25,
-	139,
-	164,
-	 -1,
-	 -1,
-	371,
-	 -1,
-	 -1,
-	429,
-	 -1,
-	 -1,
-	 -1,
-	273,
-	 -1,
-	466,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	181,
-	 -1,
-	 -1,
-	 75,
-	 -1,
-	 92,
-	339,
-	 -1,
-	384,
-	 -1,
-	123,
-	 -1,
-	143,
-	168,
-	 -1,
-	183,
-	186,
-	 -1,
-	108,
-	 95,
-	368,
-	 -1,
-	 -1,
-	277,
-	198,
-	 -1,
-	206,
-	432,
-	 -1,
-	476,
-	 -1,
-	458,
-	 -1,
-	 -1,
-	182,
-	 -1,
-	441,
-	 -1,
-	 -1,
-	 -1,
-	115,
-	113,
-	404,
-	 -1,
-	473,
-	 -1,
-	 -1,
-	 -1,
-	490,
-	104,
-	 -1,
-	 -1,
-	450,
-	449,
-	 -1,
-	 -1,
-	 -1,
-	274,
-	 -1,
-	481,
-	111,
-	 99,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	263,
-	 93,
-	 -1,
-	117,
-	 -1,
-	 29,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	119,
-	 -1,
-	 -1,
-	426,
-	491,
-	 -1,
-	 -1,
-	205,
-	 -1,
-	237,
-	 44,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	418,
-	416,
-	 -1,
-	 -1,
-	358,
-	 -1,
-	 -1,
-	 -1,
-	 65,
-	 -1,
-	440,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	  5,
-	 -1,
-	 -1,
-	 -1,
-	488,
-	 -1,
-	 -1,
-	 -1,
-	 28,
-	412,
-	 -1,
-	405,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	295,
-	 -1,
-	471,
-	362,
-	 -1,
-	 -1,
-	485,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	202,
-	 -1,
-	 -1,
-	284,
-	 -1,
-	469,
-	 -1,
-	 -1,
-	  9,
-	 24,
-	 -1,
-	 -1,
-	179,
-	 -1,
-	 -1,
-	 15,
-	 -1,
-	 -1,
-	148,
-	 -1,
-	 -1,
-	 -1,
-	341,
-	 -1,
-	 -1,
-	366,
-	209,
-	223,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	  0,
-	 -1,
-	208,
-	467,
-	 -1,
-	422,
-	 -1,
-	464,
-	157,
-	 -1,
-	403,
-	 -1,
-	415,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	445,
-	 -1,
-	 -1,
-	330,
-	 -1,
-	 -1,
-	 -1,
-	462,
-	160,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 86,
-	 -1,
-	 -1,
-	 41,
-	 -1,
-	280,
-	 -1,
-	478,
-	 -1,
-	 -1,
-	 57,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	394,
-	414,
-	 -1,
-	 -1,
-	 -1,
-	140,
-	165,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	275,
-	102,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	232,
-	 -1,
-	 14,
-	 -1,
-	 -1,
-	225,
-	 -1,
-	 -1,
-	267,
-	 -1,
-	 77,
-	 -1,
-	144,
-	169,
-	 -1,
-	149,
-	 -1,
-	400,
-	 -1,
-	 -1,
-	 -1,
-	  3,
-	 -1,
-	 -1,
-	 -1,
-	468,
-	425,
-	 -1,
-	 -1,
-	470,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	456,
-	 -1,
-	158,
-	159,
-	 -1,
-	 -1,
-	146,
-	 49,
-	 -1,
-	 -1,
-	153,
-	 -1,
-	401,
-	 90,
-	0	/* base-of-table */
-};
-
-#if (BOOLCOUNT!=44)||(NUMCOUNT!=39)||(STRCOUNT!=414)
-#error	--> term.h and comp_captab.c disagree about the <--
-#error	--> numbers of booleans, numbers and/or strings <--
-#endif
-
-/* 103 collisions out of 497 entries */
-static const char cap_names_text[] = \
-"bw\0" "am\0" "xb\0" "xs\0" "xn\0" "eo\0" "gn\0" "hc\0" "km\0" "hs\0" \
-"in\0" "da\0" "db\0" "mi\0" "ms\0" "os\0" "es\0" "xt\0" "hz\0" "ul\0" \
-"xo\0" "nx\0" "5i\0" "HC\0" "NR\0" "NP\0" "ND\0" "cc\0" "ut\0" "hl\0" \
-"YA\0" "YB\0" "YC\0" "YD\0" "YE\0" "YF\0" "YG\0" "co\0" "it\0" "li\0" \
-"lm\0" "sg\0" "pb\0" "vt\0" "ws\0" "Nl\0" "lh\0" "lw\0" "ma\0" "MW\0" \
-"Co\0" "pa\0" "NC\0" "Ya\0" "Yb\0" "Yc\0" "Yd\0" "Ye\0" "Yf\0" "Yg\0" \
-"Yh\0" "Yi\0" "Yj\0" "Yk\0" "Yl\0" "Ym\0" "Yn\0" "BT\0" "Yo\0" "Yp\0" \
-"bt\0" "bl\0" "cr\0" "cs\0" "ct\0" "cl\0" "ce\0" "cd\0" "ch\0" "CC\0" \
-"cm\0" "do\0" "ho\0" "vi\0" "le\0" "CM\0" "ve\0" "nd\0" "ll\0" "up\0" \
-"vs\0" "dc\0" "dl\0" "ds\0" "hd\0" "as\0" "mb\0" "md\0" "ti\0" "dm\0" \
-"mh\0" "im\0" "mk\0" "mp\0" "mr\0" "so\0" "us\0" "ec\0" "ae\0" "me\0" \
-"te\0" "ed\0" "ei\0" "se\0" "ue\0" "vb\0" "ff\0" "fs\0" "i1\0" "is\0" \
-"i3\0" "if\0" "ic\0" "al\0" "ip\0" "kb\0" "ka\0" "kC\0" "kt\0" "kD\0" \
-"kL\0" "kd\0" "kM\0" "kE\0" "kS\0" "k0\0" "k1\0" "k;\0" "k2\0" "k3\0" \
-"k4\0" "k5\0" "k6\0" "k7\0" "k8\0" "k9\0" "kh\0" "kI\0" "kA\0" "kl\0" \
-"kH\0" "kN\0" "kP\0" "kr\0" "kF\0" "kR\0" "kT\0" "ku\0" "ke\0" "ks\0" \
-"l0\0" "l1\0" "la\0" "l2\0" "l3\0" "l4\0" "l5\0" "l6\0" "l7\0" "l8\0" \
-"l9\0" "mo\0" "mm\0" "nw\0" "pc\0" "DC\0" "DL\0" "DO\0" "IC\0" "SF\0" \
-"AL\0" "LE\0" "RI\0" "SR\0" "UP\0" "pk\0" "pl\0" "px\0" "ps\0" "pf\0" \
-"po\0" "rp\0" "r1\0" "r2\0" "r3\0" "rf\0" "rc\0" "cv\0" "sc\0" "sf\0" \
-"sr\0" "sa\0" "st\0" "wi\0" "ta\0" "ts\0" "uc\0" "hu\0" "iP\0" "K1\0" \
-"K3\0" "K2\0" "K4\0" "K5\0" "pO\0" "rP\0" "ac\0" "pn\0" "kB\0" "SX\0" \
-"RX\0" "SA\0" "RA\0" "XN\0" "XF\0" "eA\0" "LO\0" "LF\0" "@1\0" "@2\0" \
-"@3\0" "@4\0" "@5\0" "@6\0" "@7\0" "@8\0" "@9\0" "@0\0" "%1\0" "%2\0" \
-"%3\0" "%4\0" "%5\0" "%6\0" "%7\0" "%8\0" "%9\0" "%0\0" "&1\0" "&2\0" \
-"&3\0" "&4\0" "&5\0" "&6\0" "&7\0" "&8\0" "&9\0" "&0\0" "*1\0" "*2\0" \
-"*3\0" "*4\0" "*5\0" "*6\0" "*7\0" "*8\0" "*9\0" "*0\0" "#1\0" "#2\0" \
-"#3\0" "#4\0" "%a\0" "%b\0" "%c\0" "%d\0" "%e\0" "%f\0" "%g\0" "%h\0" \
-"%i\0" "%j\0" "!1\0" "!2\0" "!3\0" "RF\0" "F1\0" "F2\0" "F3\0" "F4\0" \
-"F5\0" "F6\0" "F7\0" "F8\0" "F9\0" "FA\0" "FB\0" "FC\0" "FD\0" "FE\0" \
-"FF\0" "FG\0" "FH\0" "FI\0" "FJ\0" "FK\0" "FL\0" "FM\0" "FN\0" "FO\0" \
-"FP\0" "FQ\0" "FR\0" "FS\0" "FT\0" "FU\0" "FV\0" "FW\0" "FX\0" "FY\0" \
-"FZ\0" "Fa\0" "Fb\0" "Fc\0" "Fd\0" "Fe\0" "Ff\0" "Fg\0" "Fh\0" "Fi\0" \
-"Fj\0" "Fk\0" "Fl\0" "Fm\0" "Fn\0" "Fo\0" "Fp\0" "Fq\0" "Fr\0" "cb\0" \
-"MC\0" "ML\0" "MR\0" "Lf\0" "SC\0" "DK\0" "RC\0" "CW\0" "WG\0" "HU\0" \
-"DI\0" "QD\0" "TO\0" "PU\0" "fh\0" "PA\0" "WA\0" "u0\0" "u1\0" "u2\0" \
-"u3\0" "u4\0" "u5\0" "u6\0" "u7\0" "u8\0" "u9\0" "op\0" "oc\0" "Ic\0" \
-"Ip\0" "sp\0" "Sf\0" "Sb\0" "ZA\0" "ZB\0" "ZC\0" "ZD\0" "ZE\0" "ZF\0" \
-"ZG\0" "ZH\0" "ZI\0" "ZJ\0" "ZK\0" "ZL\0" "ZM\0" "ZN\0" "ZO\0" "ZP\0" \
-"ZQ\0" "ZR\0" "ZS\0" "ZT\0" "ZU\0" "ZV\0" "ZW\0" "ZX\0" "ZY\0" "ZZ\0" \
-"Za\0" "Zb\0" "Zc\0" "Zd\0" "Ze\0" "Zf\0" "Zg\0" "Zh\0" "Zi\0" "Zj\0" \
-"Zk\0" "Zl\0" "Zm\0" "Zn\0" "Zo\0" "Zp\0" "Zq\0" "Zr\0" "Zs\0" "Zt\0" \
-"Zu\0" "Zv\0" "Zw\0" "Zx\0" "Zy\0" "Km\0" "Mi\0" "RQ\0" "Gm\0" "AF\0" \
-"AB\0" "xl\0" "dv\0" "ci\0" "s0\0" "s1\0" "s2\0" "s3\0" "ML\0" "MT\0" \
-"Xy\0" "Zz\0" "Yv\0" "Yw\0" "Yx\0" "Yy\0" "Yz\0" "YZ\0" "S1\0" "S2\0" \
-"S3\0" "S4\0" "S5\0" "S6\0" "S7\0" "S8\0" "Xh\0" "Xl\0" "Xo\0" "Xr\0" \
-"Xt\0" "Xv\0" "sA\0" "YI\0" "i2\0" "rs\0" "ug\0" "bs\0" "ns\0" "nc\0" \
-"dC\0" "dN\0" "nl\0" "bc\0" "MT\0" "NL\0" "dB\0" "dT\0" "kn\0" "ko\0" \
-"ma\0" "pt\0" "xr\0" "G2\0" "G3\0" "G1\0" "G4\0" "GR\0" "GL\0" "GU\0" \
-"GD\0" "GH\0" "GV\0" "GC\0" "ml\0" "mu\0" "bx\0" ;
-
-static name_table_data const cap_names_data[] =
-{
-	{               0,	   BOOLEAN,	  0,  -1 },
-	{               3,	   BOOLEAN,	  1,  -1 },
-	{               6,	   BOOLEAN,	  2,  -1 },
-	{               9,	   BOOLEAN,	  3,  -1 },
-	{              12,	   BOOLEAN,	  4,  -1 },
-	{              15,	   BOOLEAN,	  5,  -1 },
-	{              18,	   BOOLEAN,	  6,  -1 },
-	{              21,	   BOOLEAN,	  7,  -1 },
-	{              24,	   BOOLEAN,	  8,  -1 },
-	{              27,	   BOOLEAN,	  9,  -1 },
-	{              30,	   BOOLEAN,	 10,  -1 },
-	{              33,	   BOOLEAN,	 11,  -1 },
-	{              36,	   BOOLEAN,	 12,  -1 },
-	{              39,	   BOOLEAN,	 13,  -1 },
-	{              42,	   BOOLEAN,	 14,  -1 },
-	{              45,	   BOOLEAN,	 15,  -1 },
-	{              48,	   BOOLEAN,	 16,  -1 },
-	{              51,	   BOOLEAN,	 17,  -1 },
-	{              54,	   BOOLEAN,	 18,  -1 },
-	{              57,	   BOOLEAN,	 19,  -1 },
-	{              60,	   BOOLEAN,	 20,  -1 },
-	{              63,	   BOOLEAN,	 21,  -1 },
-	{              66,	   BOOLEAN,	 22,  -1 },
-	{              69,	   BOOLEAN,	 23,  -1 },
-	{              72,	   BOOLEAN,	 24,   1 },
-	{              75,	   BOOLEAN,	 25,  -1 },
-	{              78,	   BOOLEAN,	 26,  -1 },
-	{              81,	   BOOLEAN,	 27,  -1 },
-	{              84,	   BOOLEAN,	 28,  -1 },
-	{              87,	   BOOLEAN,	 29,  -1 },
-	{              90,	   BOOLEAN,	 30,  -1 },
-	{              93,	   BOOLEAN,	 31,  -1 },
-	{              96,	   BOOLEAN,	 32,  -1 },
-	{              99,	   BOOLEAN,	 33,  -1 },
-	{             102,	   BOOLEAN,	 34,  -1 },
-	{             105,	   BOOLEAN,	 35,  -1 },
-	{             108,	   BOOLEAN,	 36,  -1 },
-	{             111,	    NUMBER,	  0,  -1 },
-	{             114,	    NUMBER,	  1,  -1 },
-	{             117,	    NUMBER,	  2,  -1 },
-	{             120,	    NUMBER,	  3,  -1 },
-	{             123,	    NUMBER,	  4,  -1 },
-	{             126,	    NUMBER,	  5,  -1 },
-	{             129,	    NUMBER,	  6,  -1 },
-	{             132,	    NUMBER,	  7,  -1 },
-	{             135,	    NUMBER,	  8,  -1 },
-	{             138,	    NUMBER,	  9,  -1 },
-	{             141,	    NUMBER,	 10,  -1 },
-	{             144,	    NUMBER,	 11,  -1 },
-	{             147,	    NUMBER,	 12,  -1 },
-	{             150,	    NUMBER,	 13,  -1 },
-	{             153,	    NUMBER,	 14,  -1 },
-	{             156,	    NUMBER,	 15,  -1 },
-	{             159,	    NUMBER,	 16,  -1 },
-	{             162,	    NUMBER,	 17,  -1 },
-	{             165,	    NUMBER,	 18,  -1 },
-	{             168,	    NUMBER,	 19,  -1 },
-	{             171,	    NUMBER,	 20,  -1 },
-	{             174,	    NUMBER,	 21,  -1 },
-	{             177,	    NUMBER,	 22,  -1 },
-	{             180,	    NUMBER,	 23,  -1 },
-	{             183,	    NUMBER,	 24,  -1 },
-	{             186,	    NUMBER,	 25,  -1 },
-	{             189,	    NUMBER,	 26,  -1 },
-	{             192,	    NUMBER,	 27,  -1 },
-	{             195,	    NUMBER,	 28,  -1 },
-	{             198,	    NUMBER,	 29,  -1 },
-	{             201,	    NUMBER,	 30,  -1 },
-	{             204,	    NUMBER,	 31,  -1 },
-	{             207,	    NUMBER,	 32,  -1 },
-	{             210,	    STRING,	  0,  -1 },
-	{             213,	    STRING,	  1,  -1 },
-	{             216,	    STRING,	  2,  -1 },
-	{             219,	    STRING,	  3,  -1 },
-	{             222,	    STRING,	  4,  -1 },
-	{             225,	    STRING,	  5,  -1 },
-	{             228,	    STRING,	  6,  -1 },
-	{             231,	    STRING,	  7,  -1 },
-	{             234,	    STRING,	  8,  -1 },
-	{             237,	    STRING,	  9,  -1 },
-	{             240,	    STRING,	 10,  -1 },
-	{             243,	    STRING,	 11,  -1 },
-	{             246,	    STRING,	 12,  -1 },
-	{             249,	    STRING,	 13,  -1 },
-	{             252,	    STRING,	 14,  -1 },
-	{             255,	    STRING,	 15,  -1 },
-	{             258,	    STRING,	 16,  -1 },
-	{             261,	    STRING,	 17,  -1 },
-	{             264,	    STRING,	 18,  -1 },
-	{             267,	    STRING,	 19,  -1 },
-	{             270,	    STRING,	 20,  -1 },
-	{             273,	    STRING,	 21,  -1 },
-	{             276,	    STRING,	 22,  -1 },
-	{             279,	    STRING,	 23,  -1 },
-	{             282,	    STRING,	 24,  -1 },
-	{             285,	    STRING,	 25,  -1 },
-	{             288,	    STRING,	 26,  -1 },
-	{             291,	    STRING,	 27,  -1 },
-	{             294,	    STRING,	 28,  -1 },
-	{             297,	    STRING,	 29,  -1 },
-	{             300,	    STRING,	 30,  -1 },
-	{             303,	    STRING,	 31,  -1 },
-	{             306,	    STRING,	 32,  -1 },
-	{             309,	    STRING,	 33,  -1 },
-	{             312,	    STRING,	 34,  -1 },
-	{             315,	    STRING,	 35,  -1 },
-	{             318,	    STRING,	 36,  -1 },
-	{             321,	    STRING,	 37,  -1 },
-	{             324,	    STRING,	 38,  -1 },
-	{             327,	    STRING,	 39,  -1 },
-	{             330,	    STRING,	 40,  -1 },
-	{             333,	    STRING,	 41,  -1 },
-	{             336,	    STRING,	 42,  -1 },
-	{             339,	    STRING,	 43,  -1 },
-	{             342,	    STRING,	 44,  -1 },
-	{             345,	    STRING,	 45,  -1 },
-	{             348,	    STRING,	 46,  -1 },
-	{             351,	    STRING,	 47,  -1 },
-	{             354,	    STRING,	 48, 102 },
-	{             357,	    STRING,	 49,  -1 },
-	{             360,	    STRING,	 50,  -1 },
-	{             363,	    STRING,	 51,  -1 },
-	{             366,	    STRING,	 52,  -1 },
-	{             369,	    STRING,	 53,  -1 },
-	{             372,	    STRING,	 54,  -1 },
-	{             375,	    STRING,	 55,  -1 },
-	{             378,	    STRING,	 56,  -1 },
-	{             381,	    STRING,	 57,  -1 },
-	{             384,	    STRING,	 58,  -1 },
-	{             387,	    STRING,	 59,  -1 },
-	{             390,	    STRING,	 60,  -1 },
-	{             393,	    STRING,	 61,  -1 },
-	{             396,	    STRING,	 62,  -1 },
-	{             399,	    STRING,	 63,  -1 },
-	{             402,	    STRING,	 64,  -1 },
-	{             405,	    STRING,	 65,  -1 },
-	{             408,	    STRING,	 66,  -1 },
-	{             411,	    STRING,	 67,  -1 },
-	{             414,	    STRING,	 68,  -1 },
-	{             417,	    STRING,	 69,  -1 },
-	{             420,	    STRING,	 70,  -1 },
-	{             423,	    STRING,	 71,  -1 },
-	{             426,	    STRING,	 72,  -1 },
-	{             429,	    STRING,	 73,  -1 },
-	{             432,	    STRING,	 74,  -1 },
-	{             435,	    STRING,	 75,  15 },
-	{             438,	    STRING,	 76,  -1 },
-	{             441,	    STRING,	 77,  -1 },
-	{             444,	    STRING,	 78,  -1 },
-	{             447,	    STRING,	 79,  -1 },
-	{             450,	    STRING,	 80,  -1 },
-	{             453,	    STRING,	 81,  -1 },
-	{             456,	    STRING,	 82,  -1 },
-	{             459,	    STRING,	 83,  -1 },
-	{             462,	    STRING,	 84,  -1 },
-	{             465,	    STRING,	 85,  -1 },
-	{             468,	    STRING,	 86,  -1 },
-	{             471,	    STRING,	 87,  -1 },
-	{             474,	    STRING,	 88,  -1 },
-	{             477,	    STRING,	 89,  -1 },
-	{             480,	    STRING,	 90,  -1 },
-	{             483,	    STRING,	 91,  -1 },
-	{             486,	    STRING,	 92,  35 },
-	{             489,	    STRING,	 93,  -1 },
-	{             492,	    STRING,	 94,  -1 },
-	{             495,	    STRING,	 95,  -1 },
-	{             498,	    STRING,	 96,  -1 },
-	{             501,	    STRING,	 97,  -1 },
-	{             504,	    STRING,	 98,  -1 },
-	{             507,	    STRING,	 99,  -1 },
-	{             510,	    STRING,	100,  -1 },
-	{             513,	    STRING,	101,  -1 },
-	{             516,	    STRING,	102, 120 },
-	{             519,	    STRING,	103,  -1 },
-	{             522,	    STRING,	104,  -1 },
-	{             525,	    STRING,	105,  -1 },
-	{             528,	    STRING,	106,  -1 },
-	{             531,	    STRING,	107,  -1 },
-	{             534,	    STRING,	108,  -1 },
-	{             537,	    STRING,	109,  -1 },
-	{             540,	    STRING,	110,  -1 },
-	{             543,	    STRING,	111,  -1 },
-	{             546,	    STRING,	112, 111 },
-	{             549,	    STRING,	113,  -1 },
-	{             552,	    STRING,	114,  -1 },
-	{             555,	    STRING,	115, 161 },
-	{             558,	    STRING,	116, 163 },
-	{             561,	    STRING,	117,  -1 },
-	{             564,	    STRING,	118, 170 },
-	{             567,	    STRING,	119,  -1 },
-	{             570,	    STRING,	120, 166 },
-	{             573,	    STRING,	121,  -1 },
-	{             576,	    STRING,	122,  -1 },
-	{             579,	    STRING,	123,  -1 },
-	{             582,	    STRING,	124,  -1 },
-	{             585,	    STRING,	125,  -1 },
-	{             588,	    STRING,	126,  -1 },
-	{             591,	    STRING,	127,  -1 },
-	{             594,	    STRING,	128,  -1 },
-	{             597,	    STRING,	129,  -1 },
-	{             600,	    STRING,	130,  -1 },
-	{             603,	    STRING,	131,  -1 },
-	{             606,	    STRING,	132,  -1 },
-	{             609,	    STRING,	133,  -1 },
-	{             612,	    STRING,	134,  -1 },
-	{             615,	    STRING,	135,  -1 },
-	{             618,	    STRING,	136,  -1 },
-	{             621,	    STRING,	137,  -1 },
-	{             624,	    STRING,	138,  -1 },
-	{             627,	    STRING,	139,  -1 },
-	{             630,	    STRING,	140,  -1 },
-	{             633,	    STRING,	141,  -1 },
-	{             636,	    STRING,	142,  -1 },
-	{             639,	    STRING,	143,  -1 },
-	{             642,	    STRING,	144,  -1 },
-	{             645,	    STRING,	145,  37 },
-	{             648,	    STRING,	146,  -1 },
-	{             651,	    STRING,	147, 165 },
-	{             654,	    STRING,	148,  -1 },
-	{             657,	    STRING,	149, 117 },
-	{             660,	    STRING,	150,  16 },
-	{             663,	    STRING,	151,  -1 },
-	{             666,	    STRING,	152,  -1 },
-	{             669,	    STRING,	153,  -1 },
-	{             672,	    STRING,	154, 126 },
-	{             675,	    STRING,	155,  -1 },
-	{             678,	    STRING,	156,  -1 },
-	{             681,	    STRING,	157,  -1 },
-	{             684,	    STRING,	158,  -1 },
-	{             687,	    STRING,	159,  -1 },
-	{             690,	    STRING,	160,  -1 },
-	{             693,	    STRING,	161,  -1 },
-	{             696,	    STRING,	162,  -1 },
-	{             699,	    STRING,	163,  -1 },
-	{             702,	    STRING,	164, 183 },
-	{             705,	    STRING,	165,  -1 },
-	{             708,	    STRING,	166,  -1 },
-	{             711,	    STRING,	167, 116 },
-	{             714,	    STRING,	168,  -1 },
-	{             717,	    STRING,	169,  97 },
-	{             720,	    STRING,	170, 109 },
-	{             723,	    STRING,	171,  -1 },
-	{             726,	    STRING,	172,  -1 },
-	{             729,	    STRING,	173, 100 },
-	{             732,	    STRING,	174,  13 },
-	{             735,	    STRING,	175,  -1 },
-	{             738,	    STRING,	176, 118 },
-	{             741,	    STRING,	177,  96 },
-	{             744,	    STRING,	178,  -1 },
-	{             747,	    STRING,	179,  87 },
-	{             750,	    STRING,	180,  -1 },
-	{             753,	    STRING,	181,  -1 },
-	{             756,	    STRING,	182,  -1 },
-	{             759,	    STRING,	183,  -1 },
-	{             762,	    STRING,	184,  -1 },
-	{             765,	    STRING,	185,  -1 },
-	{             768,	    STRING,	186,  -1 },
-	{             771,	    STRING,	187,  -1 },
-	{             774,	    STRING,	188, 196 },
-	{             777,	    STRING,	189,  -1 },
-	{             780,	    STRING,	190,  -1 },
-	{             783,	    STRING,	191, 195 },
-	{             786,	    STRING,	192,  -1 },
-	{             789,	    STRING,	193,  -1 },
-	{             792,	    STRING,	194,  -1 },
-	{             795,	    STRING,	195,  -1 },
-	{             798,	    STRING,	196,  -1 },
-	{             801,	    STRING,	197,  -1 },
-	{             804,	    STRING,	198,  -1 },
-	{             807,	    STRING,	199, 131 },
-	{             810,	    STRING,	200, 158 },
-	{             813,	    STRING,	201,  -1 },
-	{             816,	    STRING,	202,  -1 },
-	{             819,	    STRING,	203,  -1 },
-	{             822,	    STRING,	204,  -1 },
-	{             825,	    STRING,	205,  -1 },
-	{             828,	    STRING,	206,  -1 },
-	{             831,	    STRING,	207,  -1 },
-	{             834,	    STRING,	208,  -1 },
-	{             837,	    STRING,	209,  -1 },
-	{             840,	    STRING,	210,  -1 },
-	{             843,	    STRING,	211,  -1 },
-	{             846,	    STRING,	212, 122 },
-	{             849,	    STRING,	213,  -1 },
-	{             852,	    STRING,	214,  -1 },
-	{             855,	    STRING,	215,  -1 },
-	{             858,	    STRING,	216,  -1 },
-	{             861,	    STRING,	217,  46 },
-	{             864,	    STRING,	218,  39 },
-	{             867,	    STRING,	219,  -1 },
-	{             870,	    STRING,	220,  -1 },
-	{             873,	    STRING,	221,  88 },
-	{             876,	    STRING,	222,  40 },
-	{             879,	    STRING,	223,  -1 },
-	{             882,	    STRING,	224,  -1 },
-	{             885,	    STRING,	225,  47 },
-	{             888,	    STRING,	226,  -1 },
-	{             891,	    STRING,	227,  -1 },
-	{             894,	    STRING,	228,  -1 },
-	{             897,	    STRING,	229,  -1 },
-	{             900,	    STRING,	230,  53 },
-	{             903,	    STRING,	231,  54 },
-	{             906,	    STRING,	232,  55 },
-	{             909,	    STRING,	233,  56 },
-	{             912,	    STRING,	234,  57 },
-	{             915,	    STRING,	235,  58 },
-	{             918,	    STRING,	236,  59 },
-	{             921,	    STRING,	237,  60 },
-	{             924,	    STRING,	238,  61 },
-	{             927,	    STRING,	239,  62 },
-	{             930,	    STRING,	240,  63 },
-	{             933,	    STRING,	241,  64 },
-	{             936,	    STRING,	242,  65 },
-	{             939,	    STRING,	243,  66 },
-	{             942,	    STRING,	244,  68 },
-	{             945,	    STRING,	245,  69 },
-	{             948,	    STRING,	246,  -1 },
-	{             951,	    STRING,	247,  -1 },
-	{             954,	    STRING,	248,  -1 },
-	{             957,	    STRING,	249,  -1 },
-	{             960,	    STRING,	250,  -1 },
-	{             963,	    STRING,	251,  -1 },
-	{             966,	    STRING,	252,  -1 },
-	{             969,	    STRING,	253,  -1 },
-	{             972,	    STRING,	254,  -1 },
-	{             975,	    STRING,	255,  -1 },
-	{             978,	    STRING,	256,  -1 },
-	{             981,	    STRING,	257,   7 },
-	{             984,	    STRING,	258,  94 },
-	{             987,	    STRING,	259,  -1 },
-	{             990,	    STRING,	260,  -1 },
-	{             993,	    STRING,	261,  -1 },
-	{             996,	    STRING,	262,  -1 },
-	{             999,	    STRING,	263,  -1 },
-	{            1002,	    STRING,	264,  -1 },
-	{            1005,	    STRING,	265, 184 },
-	{            1008,	    STRING,	266,  29 },
-	{            1011,	    STRING,	267,  -1 },
-	{            1014,	    STRING,	268,  -1 },
-	{            1017,	    STRING,	269,  -1 },
-	{            1020,	    STRING,	270,  -1 },
-	{            1023,	    STRING,	271,  -1 },
-	{            1026,	    STRING,	272,  -1 },
-	{            1029,	    STRING,	273, 257 },
-	{            1032,	    STRING,	274,  -1 },
-	{            1035,	    STRING,	275,  -1 },
-	{            1038,	    STRING,	276,  -1 },
-	{            1041,	    STRING,	277,   4 },
-	{            1044,	    STRING,	278,  -1 },
-	{            1047,	    STRING,	279,  -1 },
-	{            1050,	    STRING,	280,  -1 },
-	{            1053,	    STRING,	281,  -1 },
-	{            1056,	    STRING,	282,  -1 },
-	{            1059,	    STRING,	283,  -1 },
-	{            1062,	    STRING,	284, 229 },
-	{            1065,	    STRING,	285,  -1 },
-	{            1068,	    STRING,	286,  -1 },
-	{            1071,	    STRING,	287,  -1 },
-	{            1074,	    STRING,	288,  -1 },
-	{            1077,	    STRING,	289,  -1 },
-	{            1080,	    STRING,	290,  -1 },
-	{            1083,	    STRING,	291,  -1 },
-	{            1086,	    STRING,	292,  -1 },
-	{            1089,	    STRING,	293,  -1 },
-	{            1092,	    STRING,	294,  -1 },
-	{            1095,	    STRING,	295,  -1 },
-	{            1098,	    STRING,	296,  -1 },
-	{            1101,	    STRING,	297, 142 },
-	{            1104,	    STRING,	298,  -1 },
-	{            1107,	    STRING,	299,  -1 },
-	{            1110,	    STRING,	300, 149 },
-	{            1113,	    STRING,	301,  -1 },
-	{            1116,	    STRING,	302,  -1 },
-	{            1119,	    STRING,	303,  -1 },
-	{            1122,	    STRING,	304,  -1 },
-	{            1125,	    STRING,	305,  -1 },
-	{            1128,	    STRING,	306,  -1 },
-	{            1131,	    STRING,	307,  -1 },
-	{            1134,	    STRING,	308,  -1 },
-	{            1137,	    STRING,	309,  48 },
-	{            1140,	    STRING,	310, 247 },
-	{            1143,	    STRING,	311, 238 },
-	{            1146,	    STRING,	312, 239 },
-	{            1149,	    STRING,	313, 240 },
-	{            1152,	    STRING,	314, 241 },
-	{            1155,	    STRING,	315, 242 },
-	{            1158,	    STRING,	316, 243 },
-	{            1161,	    STRING,	317, 244 },
-	{            1164,	    STRING,	318, 245 },
-	{            1167,	    STRING,	319, 246 },
-	{            1170,	    STRING,	320,  -1 },
-	{            1173,	    STRING,	321, 172 },
-	{            1176,	    STRING,	322,  -1 },
-	{            1179,	    STRING,	323, 171 },
-	{            1182,	    STRING,	324, 103 },
-	{            1185,	    STRING,	325,  -1 },
-	{            1188,	    STRING,	326, 104 },
-	{            1191,	    STRING,	327,  14 },
-	{            1194,	    STRING,	328,  -1 },
-	{            1197,	    STRING,	329,  -1 },
-	{            1200,	    STRING,	330,  -1 },
-	{            1203,	    STRING,	331,  -1 },
-	{            1206,	    STRING,	332,  -1 },
-	{            1209,	    STRING,	333,  -1 },
-	{            1212,	    STRING,	334,  -1 },
-	{            1215,	    STRING,	335,  -1 },
-	{            1218,	    STRING,	336,  -1 },
-	{            1221,	    STRING,	337,  -1 },
-	{            1224,	    STRING,	338,  -1 },
-	{            1227,	    STRING,	339,  -1 },
-	{            1230,	    STRING,	340,  -1 },
-	{            1233,	    STRING,	341,  -1 },
-	{            1236,	    STRING,	342,  -1 },
-	{            1239,	    STRING,	343,  -1 },
-	{            1242,	    STRING,	344, 208 },
-	{            1245,	    STRING,	345,  -1 },
-	{            1248,	    STRING,	346,  -1 },
-	{            1251,	    STRING,	347,  -1 },
-	{            1254,	    STRING,	348,  -1 },
-	{            1257,	    STRING,	349,  -1 },
-	{            1260,	    STRING,	350,  -1 },
-	{            1263,	    STRING,	351,  -1 },
-	{            1266,	    STRING,	352,  -1 },
-	{            1269,	    STRING,	353, 272 },
-	{            1272,	    STRING,	354, 273 },
-	{            1275,	    STRING,	355, 387 },
-	{            1278,	    STRING,	356,  -1 },
-	{            1281,	    STRING,	357,  -1 },
-	{            1284,	    STRING,	358,  -1 },
-	{            1287,	    STRING,	359,  -1 },
-	{            1290,	    STRING,	360,  -1 },
-	{            1293,	    STRING,	361,  -1 },
-	{            1296,	    STRING,	362,  -1 },
-	{            1299,	    STRING,	363,  -1 },
-	{            1302,	    STRING,	364,  -1 },
-	{            1305,	    STRING,	365,  67 },
-	{            1308,	    STRING,	366,  -1 },
-	{            1311,	    STRING,	367,  -1 },
-	{            1314,	    STRING,	368, 341 },
-	{            1317,	    STRING,	369,  -1 },
-	{            1320,	    STRING,	370,  -1 },
-	{            1323,	    STRING,	371, 274 },
-	{            1326,	    STRING,	372,  -1 },
-	{            1329,	    STRING,	373,  -1 },
-	{            1332,	    STRING,	374,  -1 },
-	{            1335,	    STRING,	375,  -1 },
-	{            1338,	    STRING,	376,  -1 },
-	{            1341,	    STRING,	377,  -1 },
-	{            1344,	    STRING,	378,  -1 },
-	{            1347,	    STRING,	379,  -1 },
-	{            1350,	    STRING,	380,  -1 },
-	{            1353,	    STRING,	381, 357 },
-	{            1356,	    STRING,	382, 358 },
-	{            1359,	    STRING,	383, 359 },
-	{            1362,	    STRING,	384, 360 },
-	{            1365,	    STRING,	385, 361 },
-	{            1368,	    STRING,	386,  -1 },
-	{            1371,	    STRING,	387,  -1 },
-	{            1374,	    STRING,	388,  -1 },
-	{            1377,	    STRING,	389,  -1 },
-	{            1380,	    STRING,	390,  -1 },
-	{            1383,	    STRING,	391,  -1 },
-	{            1386,	    STRING,	392,  -1 },
-	{            1389,	    STRING,	393,  -1 },
-	{            1392,	    STRING,	394, 390 },
-	{            1395,	    STRING,	395,  -1 },
-	{            1398,	    NUMBER,	 33,  -1 },
-	{            1401,	   BOOLEAN,	 37,  -1 },
-	{            1404,	   BOOLEAN,	 38,  -1 },
-	{            1407,	   BOOLEAN,	 39, 248 },
-	{            1410,	    NUMBER,	 34,  -1 },
-	{            1413,	    NUMBER,	 35, 203 },
-	{            1416,	    STRING,	396,  -1 },
-	{            1419,	    STRING,	397,  -1 },
-	{            1422,	   BOOLEAN,	 40, 439 },
-	{            1425,	   BOOLEAN,	 41,  -1 },
-	{            1428,	    NUMBER,	 36,  -1 },
-	{            1431,	    NUMBER,	 37,  -1 },
-	{            1434,	    NUMBER,	 38,  -1 },
-	{            1437,	    STRING,	398,  -1 },
-	{            1440,	    STRING,	399, 379 },
-	{            1443,	   BOOLEAN,	 42,  -1 },
-	{            1446,	   BOOLEAN,	 43,  -1 },
-	{            1449,	    STRING,	400, 386 },
-	{            1452,	    STRING,	401, 425 },
-	{            1455,	    STRING,	402, 385 },
-	{            1458,	    STRING,	403, 388 },
-	{            1461,	    STRING,	404, 412 },
-	{            1464,	    STRING,	405, 406 },
-	{            1467,	    STRING,	406, 415 },
-	{            1470,	    STRING,	407,  -1 },
-	{            1473,	    STRING,	408, 402 },
-	{            1476,	    STRING,	409, 416 },
-	{            1479,	    STRING,	410,  -1 },
-	{            1482,	    STRING,	411, 464 },
-	{            1485,	    STRING,	412, 399 },
-	{            1488,	    STRING,	413,  -1 } 
-};
-
-static struct name_table_entry *_nc_cap_table = 0;
-
-static const HashValue _nc_cap_hash_table[995] =
-{
-	253,
-	 -1,
-	 45,
-	211,
-	263,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	449,
-	457,
-	311,
-	411,
-	 -1,
-	132,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	123,
-	 71,
-	 75,
-	 92,
-	427,
-	233,
-	 -1,
-	336,
-	 -1,
-	 -1,
-	370,
-	291,
-	494,
-	472,
-	138,
-	186,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 19,
-	193,
-	436,
-	431,
-	453,
-	 -1,
-	315,
-	489,
-	349,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	353,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	124,
-	 -1,
-	 -1,
-	 -1,
-	394,
-	 -1,
-	367,
-	167,
-	 -1,
-	191,
-	371,
-	 -1,
-	 89,
-	 -1,
-	 -1,
-	 -1,
-	363,
-	460,
-	319,
-	419,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 70,
-	 74,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 38,
-	 -1,
-	128,
-	 -1,
-	398,
-	 -1,
-	 -1,
-	481,
-	 -1,
-	 -1,
-	202,
-	 -1,
-	 28,
-	 43,
-	 -1,
-	 17,
-	 -1,
-	 -1,
-	444,
-	423,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	496,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	430,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	296,
-	 -1,
-	 21,
-	 -1,
-	187,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	321,
-	276,
-	 -1,
-	 -1,
-	 31,
-	375,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	429,
-	476,
-	 -1,
-	 -1,
-	 -1,
-	300,
-	400,
-	 -1,
-	218,
-	 -1,
-	 -1,
-	227,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 11,
-	285,
-	179,
-	 -1,
-	325,
-	280,
-	 -1,
-	224,
-	162,
-	480,
-	 -1,
-	 -1,
-	 51,
-	 -1,
-	 -1,
-	201,
-	204,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 22,
-	 -1,
-	304,
-	404,
-	 -1,
-	154,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	108,
-	 -1,
-	 76,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	329,
-	284,
-	 -1,
-	270,
-	 84,
-	383,
-	250,
-	426,
-	 -1,
-	 -1,
-	260,
-	113,
-	110,
-	114,
-	 86,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	308,
-	408,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	433,
-	 -1,
-	112,
-	230,
-	 -1,
-	333,
-	428,
-	 -1,
-	223,
-	288,
-	484,
-	254,
-	 -1,
-	 -1,
-	210,
-	264,
-	 -1,
-	 98,
-	 -1,
-	 83,
-	471,
-	 -1,
-	450,
-	 -1,
-	312,
-	487,
-	 -1,
-	151,
-	 -1,
-	 -1,
-	 -1,
-	342,
-	 24,
-	 -1,
-	 80,
-	 99,
-	 -1,
-	234,
-	 -1,
-	337,
-	101,
-	 -1,
-	  8,
-	292,
-	391,
-	 -1,
-	139,
-	164,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	194,
-	437,
-	 -1,
-	454,
-	 -1,
-	316,
-	492,
-	 -1,
-	155,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	395,
-	 -1,
-	143,
-	168,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	364,
-	 -1,
-	320,
-	420,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	207,
-	 -1,
-	 -1,
-	157,
-	447,
-	495,
-	 -1,
-	137,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	440,
-	445,
-	424,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 79,
-	175,
-	 -1,
-	297,
-	493,
-	 23,
-	178,
-	 -1,
-	 -1,
-	 -1,
-	340,
-	 52,
-	 -1,
-	 -1,
-	 -1,
-	346,
-	344,
-	 -1,
-	322,
-	277,
-	 -1,
-	 -1,
-	 32,
-	376,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	373,
-	 -1,
-	470,
-	 -1,
-	 -1,
-	 -1,
-	301,
-	401,
-	 -1,
-	127,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	339,
-	 12,
-	 -1,
-	 -1,
-	 -1,
-	326,
-	281,
-	348,
-	125,
-	 36,
-	380,
-	343,
-	 -1,
-	 42,
-	 -1,
-	267,
-	 -1,
-	 -1,
-	372,
-	115,
-	 -1,
-	  2,
-	345,
-	 -1,
-	305,
-	405,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	237,
-	 -1,
-	330,
-	121,
-	 -1,
-	271,
-	 -1,
-	384,
-	251,
-	 -1,
-	189,
-	 -1,
-	261,
-	199,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	177,
-	 -1,
-	309,
-	409,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	226,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	231,
-	352,
-	334,
-	 -1,
-	 -1,
-	 -1,
-	289,
-	486,
-	255,
-	135,
-	160,
-	212,
-	265,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	434,
-	 -1,
-	451,
-	 -1,
-	313,
-	413,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	214,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	235,
-	  6,
-	338,
-	 10,
-	 -1,
-	478,
-	293,
-	392,
-	 -1,
-	140,
-	217,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	347,
-	455,
-	459,
-	317,
-	417,
-	 -1,
-	134,
-	 -1,
-	 -1,
-	 -1,
-	 49,
-	 -1,
-	 -1,
-	 72,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	153,
-	 -1,
-	396,
-	 -1,
-	144,
-	169,
-	 -1,
-	 -1,
-	200,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	482,
-	365,
-	461,
-	442,
-	421,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	197,
-	432,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	446,
-	441,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 18,
-	 -1,
-	 -1,
-	 -1,
-	298,
-	490,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 26,
-	 -1,
-	 -1,
-	351,
-	 -1,
-	 -1,
-	 -1,
-	323,
-	278,
-	 -1,
-	369,
-	 33,
-	377,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	302,
-	491,
-	 -1,
-	129,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	216,
-	473,
-	 27,
-	 91,
-	107,
-	 -1,
-	 -1,
-	327,
-	282,
-	 -1,
-	268,
-	 -1,
-	381,
-	469,
-	368,
-	174,
-	 -1,
-	258,
-	198,
-	 -1,
-	206,
-	180,
-	 -1,
-	 -1,
-	176,
-	 -1,
-	306,
-	488,
-	 -1,
-	150,
-	 -1,
-	 -1,
-	 -1,
-	438,
-	475,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	228,
-	 -1,
-	331,
-	 -1,
-	 -1,
-	 -1,
-	286,
-	485,
-	252,
-	 -1,
-	 -1,
-	209,
-	262,
-	 41,
-	 -1,
-	466,
-	 -1,
-	 -1,
-	 -1,
-	448,
-	 -1,
-	310,
-	410,
-	 -1,
-	130,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 25,
-	 -1,
-	 -1,
-	 -1,
-	 50,
-	232,
-	 -1,
-	335,
-	 -1,
-	 -1,
-	 -1,
-	290,
-	389,
-	256,
-	136,
-	185,
-	213,
-	266,
-	 -1,
-	 -1,
-	 -1,
-	192,
-	435,
-	 -1,
-	452,
-	458,
-	314,
-	414,
-	 -1,
-	152,
-	 -1,
-	 -1,
-	 -1,
-	474,
-	 -1,
-	 -1,
-	215,
-	 81,
-	  5,
-	236,
-	 -1,
-	 82,
-	 -1,
-	 -1,
-	479,
-	294,
-	393,
-	 -1,
-	141,
-	190,
-	 -1,
-	 -1,
-	105,
-	 -1,
-	 -1,
-	 -1,
-	477,
-	 20,
-	362,
-	 -1,
-	318,
-	418,
-	 -1,
-	156,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 95,
-	467,
-	 73,
-	 93,
-	220,
-	219,
-	 -1,
-	  9,
-	119,
-	 -1,
-	159,
-	 -1,
-	397,
-	468,
-	145,
-	188,
-	 -1,
-	465,
-	 -1,
-	205,
-	106,
-	 90,
-	 44,
-	  3,
-	366,
-	 -1,
-	443,
-	422,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	  0,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	295,
-	 -1,
-	173,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	355,
-	 -1,
-	222,
-	221,
-	 -1,
-	 -1,
-	275,
-	356,
-	 -1,
-	 30,
-	374,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	225,
-	 -1,
-	 -1,
-	299,
-	 -1,
-	 -1,
-	148,
-	 -1,
-	 -1,
-	181,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	462,
-	 -1,
-	 -1,
-	 -1,
-	324,
-	279,
-	 -1,
-	 -1,
-	 34,
-	378,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	350,
-	 -1,
-	303,
-	403,
-	 -1,
-	133,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 77,
-	 -1,
-	182,
-	 -1,
-	 -1,
-	328,
-	283,
-	 -1,
-	269,
-	463,
-	382,
-	249,
-	 -1,
-	 -1,
-	 -1,
-	259,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 85,
-	 -1,
-	456,
-	307,
-	407,
-	 -1,
-	147,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 -1,
-	 78,
-	 -1,
-	 -1,
-	354,
-	 -1,
-	332,
-	 -1,
-	 -1,
-	146,
-	287,
-	483,
-	0	/* base-of-table */
-};
-
-#if (BOOLCOUNT!=44)||(NUMCOUNT!=39)||(STRCOUNT!=414)
-#error	--> term.h and comp_captab.c disagree about the <--
-#error	--> numbers of booleans, numbers and/or strings <--
-#endif
-
-/* generated by MKcaptab.awk capalias(1) */
-
-static struct alias *_nc_capalias_table = 0;
-
-static const char capalias_text[] = "\
-sb\0sr\0BSD\0\
-BO\0mr\0AT&T\0\
-CI\0vi\0AT&T\0\
-CV\0ve\0AT&T\0\
-DS\0mh\0AT&T\0\
-FE\0LF\0AT&T\0\
-FL\0LO\0AT&T\0\
-XS\0mk\0AT&T\0\
-EE\0mh\0XENIX\0\
-GE\0ae\0XENIX\0\
-GS\0as\0XENIX\0\
-CF\0vi\0XENIX\0\
-CO\0ve\0XENIX\0\
-EN\0@7\0XENIX\0\
-HM\0kh\0XENIX\0\
-LD\0kL\0XENIX\0\
-PD\0kN\0XENIX\0\
-PN\0po\0XENIX\0\
-PS\0pf\0XENIX\0\
-PU\0kP\0XENIX\0\
-RT\0@8\0XENIX\0\
-UP\0ku\0XENIX\0\
-G6\0XENIX\0\
-G7\0XENIX\0\
-G5\0XENIX\0\
-G8\0XENIX\0\
-Gr\0XENIX\0\
-Gr\0XENIX\0\
-Gu\0XENIX\0\
-Gd\0XENIX\0\
-Gh\0XENIX\0\
-Gv\0XENIX\0\
-Gc\0XENIX\0\
-GG\0XENIX\0\
-kq\0%1\0IBM\0\
-HS\0mh\0IRIS\0\
-KA\0k;\0Tek\0\
-KB\0F1\0Tek\0\
-KC\0F2\0Tek\0\
-KD\0F3\0Tek\0\
-KE\0F4\0Tek\0\
-KF\0F5\0Tek\0\
-BC\0Sb\0Tek\0\
-FC\0Sf\0Tek\0\
-";
-
-static const alias_table_data capalias_data[] = {
-	{    0,     3,     6},	 /* scroll */
-	{   10,    13,    16},	 /* enter_reverse_mode */
-	{   21,    24,    27},	 /* cursor_invisible */
-	{   32,    35,    38},	 /* cursor_normal */
-	{   43,    46,    49},	 /* enter_dim_mode */
-	{   54,    57,    60},	 /* label_on */
-	{   65,    68,    71},	 /* label_off */
-	{   76,    79,    82},	 /* enter_secure_mode */
-	{   87,    90,    93},	 /* exit_attribute_mode */
-	{   99,   102,   105},	 /* exit_alt_charset_mode */
-	{  111,   114,   117},	 /* enter_alt_charset_mode */
-	{  123,   126,   129},	 /* cursor_invis */
-	{  135,   138,   141},	 /* cursor_normal */
-	{  147,   150,   153},	 /* key_end */
-	{  159,   162,   165},	 /* key_home */
-	{  171,   174,   177},	 /* key_dl */
-	{  183,   186,   189},	 /* key_npage */
-	{  195,   198,   201},	 /* prtr_off */
-	{  207,   210,   213},	 /* prtr_on */
-	{  219,   222,   225},	 /* key_ppage */
-	{  231,   234,   237},	 /* kent */
-	{  243,   246,   249},	 /* kcuu1 */
-	{  255,    -1,   258},	 /* double-ACS_ULCORNER */
-	{  264,    -1,   267},	 /* double-ACS_LLCORNER */
-	{  273,    -1,   276},	 /* double-ACS_URCORNER */
-	{  282,    -1,   285},	 /* double-ACS_LRCORNER */
-	{  291,    -1,   294},	 /* double-ACS_LTEE */
-	{  300,    -1,   303},	 /* double-ACS_RTEE */
-	{  309,    -1,   312},	 /* double-ACS_BTEE */
-	{  318,    -1,   321},	 /* double */
-	{  327,    -1,   330},	 /* double-ACS_HLINE */
-	{  336,    -1,   339},	 /* double-ACS_VLINE */
-	{  345,    -1,   348},	 /* double-ACS_PLUS */
-	{  354,    -1,   357},	 /* acs-glitch */
-	{  363,   366,   369},	 /* key_help */
-	{  373,   376,   379},	 /* enter_dim_mode */
-	{  384,   387,   390},	 /* key_f10 */
-	{  394,   397,   400},	 /* key_f11 */
-	{  404,   407,   410},	 /* key_f12 */
-	{  414,   417,   420},	 /* key_f13 */
-	{  424,   427,   430},	 /* key_f14 */
-	{  434,   437,   440},	 /* key_f15 */
-	{  444,   447,   450},	 /* set_background */
-	{  454,   457,   460},	 /* set_foreground */
-};
-
-/* generated by MKcaptab.awk infoalias(1) */
-
-static struct alias *_nc_infoalias_table = 0;
-
-static const char infoalias_text[] = "\
-font0\0s0ds\0IBM\0\
-font1\0s1ds\0IBM\0\
-font2\0s2ds\0IBM\0\
-font3\0s3ds\0IBM\0\
-kbtab\0kcbt\0IBM\0\
-ksel\0kslt\0IBM\0\
-";
-
-static const alias_table_data infoalias_data[] = {
-	{    0,     6,    11},	 /* set0_des_seq */
-	{   15,    21,    26},	 /* set1_des_seq */
-	{   30,    36,    41},	 /* set2_des_seq */
-	{   45,    51,    56},	 /* set3_des_seq */
-	{   60,    66,    71},	 /* key_backtab */
-	{   75,    80,    85},	 /* key_select */
-};
-
-
-#if 1
-static void
-next_string(const char *strings, unsigned *offset)
-{
-    *offset += (unsigned) strlen(strings + *offset) + 1;
-}
-
-static const struct name_table_entry *
-_nc_build_names(struct name_table_entry **actual,
-		const name_table_data *source,
-		const char *strings)
-{
-    if (*actual == 0) {
-	*actual = typeCalloc(struct name_table_entry, CAPTABSIZE);
-	if (*actual != 0) {
-	    unsigned n;
-	    unsigned len = 0;
-	    for (n = 0; n < CAPTABSIZE; ++n) {
-		(*actual)[n].nte_name = strings + len;
-		(*actual)[n].nte_type = source[n].nte_type;
-		(*actual)[n].nte_index = source[n].nte_index;
-		(*actual)[n].nte_link = source[n].nte_link;
-		next_string(strings, &len);
-	    }
-	}
-    }
-    return *actual;
-}
-
-#define add_alias(field) \
-	if (source[n].field >= 0) { \
-		(*actual)[n].field = strings + source[n].field; \
-	}
-
-static const struct alias *
-_nc_build_alias(struct alias **actual,
-		const alias_table_data *source,
-		const char *strings,
-		size_t tablesize)
-{
-    if (*actual == 0) {
-	*actual = typeCalloc(struct alias, tablesize + 1);
-	if (*actual != 0) {
-	    size_t n;
-	    for (n = 0; n < tablesize; ++n) {
-		add_alias(from);
-		add_alias(to);
-		add_alias(source);
-	    }
-	}
-    }
-    return *actual;
-}
-
-#define build_names(root) _nc_build_names(&_nc_##root##_table, \
-					  root##_names_data, \
-					  root##_names_text)
-#define build_alias(root) _nc_build_alias(&_nc_##root##alias_table, \
-					  root##alias_data, \
-					  root##alias_text, \
-					  SIZEOF(root##alias_data))
-#else
-#define build_names(root) _nc_ ## root ## _table
-#define build_alias(root) _nc_ ## root ## alias_table
-#endif
-
-NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool termcap)
-{
-    return termcap ? build_names(cap) : build_names(info) ;
-}
-
-/* entrypoint used by tack (do not alter) */
-NCURSES_EXPORT(const HashValue *) _nc_get_hash_table (bool termcap)
-{
-    return termcap ? _nc_cap_hash_table: _nc_info_hash_table ;
-}
-
-NCURSES_EXPORT(const struct alias *) _nc_get_alias_table (bool termcap)
-{
-    return termcap ? build_alias(cap) : build_alias(info) ;
-}
-
-static HashValue
-info_hash(const char *string)
-{
-    long sum = 0;
-
-    DEBUG(9, ("hashing %s", string));
-    while (*string) {
-	sum += (long) (*string + (*(string + 1) << 8));
-	string++;
-    }
-
-    DEBUG(9, ("sum is %ld", sum));
-    return (HashValue) (sum % HASHTABSIZE);
-}
-
-#define TCAP_LEN 2		/* only 1- or 2-character names are used */
-
-static HashValue
-tcap_hash(const char *string)
-{
-    char temp[TCAP_LEN + 1];
-    int limit = 0;
-
-    while (*string) {
-	temp[limit++] = *string++;
-	if (limit >= TCAP_LEN)
-	    break;
-    }
-    temp[limit] = '\0';
-    return info_hash(temp);
-}
-
-static int
-compare_tcap_names(const char *a, const char *b)
-{
-    return !strncmp(a, b, (size_t) TCAP_LEN);
-}
-
-static int
-compare_info_names(const char *a, const char *b)
-{
-    return !strcmp(a, b);
-}
-
-static const HashData hash_data[2] = {
-    { HASHTABSIZE, _nc_info_hash_table, info_hash, compare_info_names },
-    { HASHTABSIZE, _nc_cap_hash_table, tcap_hash, compare_tcap_names }
-};
-
-NCURSES_EXPORT(const HashData *) _nc_get_hash_info (bool termcap)
-{
-    return &hash_data[(termcap != FALSE)];
-}
-
-#if NO_LEAKS
-NCURSES_EXPORT(void) _nc_comp_captab_leaks(void)
-{
-#if 1
-    FreeIfNeeded(_nc_cap_table);
-    FreeIfNeeded(_nc_info_table);
-    FreeIfNeeded(_nc_capalias_table);
-    FreeIfNeeded(_nc_infoalias_table);
-#endif
-}
-#endif /* NO_LEAKS */
diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h
index ec17d88..68cda17 100644
--- a/ncurses/curses.priv.h
+++ b/ncurses/curses.priv.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
+ * Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,7 +35,7 @@
  ****************************************************************************/
 
 /*
- * $Id: curses.priv.h,v 1.547 2015/06/27 01:22:16 tom Exp $
+ * $Id: curses.priv.h,v 1.687 2024/04/23 22:28:25 tom Exp $
  *
  *	curses.priv.h
  *
@@ -71,16 +72,6 @@
 #include <unistd.h>
 #endif
 
-#if HAVE_SYS_BSDTYPES_H
-#include <sys/bsdtypes.h>	/* needed for ISC */
-#endif
-
-#if HAVE_LIMITS_H
-# include <limits.h>
-#elif HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-
 #include <assert.h>
 #include <stdio.h>
 
@@ -92,20 +83,28 @@
 #  endif
 #endif
 
-#ifndef PATH_MAX
-# if defined(_POSIX_PATH_MAX)
-#  define PATH_MAX _POSIX_PATH_MAX
-# elif defined(MAXPATHLEN)
-#  define PATH_MAX MAXPATHLEN
-# else
-#  define PATH_MAX 255	/* the Posix minimum path-size */
-# endif
-#endif
-
 #if DECL_ERRNO
 extern int errno;
 #endif
 
+/* Some Windows related defines */
+#undef _NC_WINDOWS
+#if (defined(_WIN32) || defined(_WIN64))
+#define _NC_WINDOWS
+#else
+#undef EXP_WIN32_DRIVER
+#endif
+
+#undef _NC_MINGW
+#if (defined(__MINGW32__) || defined(__MINGW64__))
+#define _NC_MINGW
+#endif
+
+#undef _NC_MSC
+#ifdef _MSC_VER
+#define _NC_MSC
+#endif
+
 /* Some systems have a broken 'select()', but workable 'poll()'.  Use that */
 #if HAVE_WORKING_POLL
 #define USE_FUNC_POLL 1
@@ -126,6 +125,20 @@
 # endif
 #endif
 
+#if (defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO != 0) && (defined(__GNUC__) && (__GNUC__ < 12))
+# undef PRIxPTR		/* gcc bug fixed in 12.x */
+# define PRIxPTR	"lX"
+# define CASTxPTR(n)    (unsigned long)(intptr_t)(void*)(n)
+#else
+# define CASTxPTR(n)    (intptr_t)(n)
+#endif
+
+#ifndef PRIxPTR
+# define PRIxPTR	"lx"
+# undef CASTxPTR
+# define CASTxPTR(n)    (long)(void*)(n)
+#endif
+
 /* include signal.h before curses.h to work-around defect in glibc 2.1.3 */
 #include <signal.h>
 
@@ -184,7 +197,7 @@
  * the path separator in configure doesn't work properly. So, if building
  * for MinGW, we enforce the correct Windows PATH separator
  */
-#ifdef __MINGW32__
+#if defined(_NC_WINDOWS)
 #  ifdef NCURSES_PATHSEP
 #    undef NCURSES_PATHSEP
 #  endif
@@ -192,14 +205,21 @@
 #endif
 
 /*
- * If desired, one can configure this, disabling environment variables that
- * point to custom terminfo/termcap locations.
+ * When the standard handles have been redirected (such as inside a text editor
+ * or the less utility), keystrokes must be read from the console rather than
+ * the redirected handle.  The standard output handle suffers from a similar
+ * problem.  Both handles are not closed once opened.  The console shall be
+ * considered reachable throughout the process.
  */
-#ifdef USE_ROOT_ENVIRON
-#define use_terminfo_vars() 1
-#else
-#define use_terminfo_vars() _nc_env_access()
-extern NCURSES_EXPORT(int) _nc_env_access (void);
+#if defined(_NC_WINDOWS)
+#define GetDirectHandle(fileName, shareMode) \
+	CreateFile(TEXT(fileName), \
+		   GENERIC_READ | GENERIC_WRITE, \
+		   shareMode, \
+		   0, \
+		   OPEN_EXISTING, \
+		   0, \
+		   0)
 #endif
 
 /*
@@ -240,6 +260,18 @@
 #endif
 
 /*
+ * POSIX ignores the "b", which c89 specified.  Some very old systems do not
+ * accept it.
+ */
+#if USE_FOPEN_BIN_R
+#define BIN_R	"rb"
+#define BIN_W	"wb"
+#else
+#define BIN_R	"r"
+#define BIN_W	"w"
+#endif
+
+/*
  * Scroll hints are useless when hashmap is used
  */
 #if !USE_SCROLL_HINTS
@@ -262,11 +294,25 @@
  * Options for terminal drivers, etc...
  */
 #ifdef USE_TERM_DRIVER
+#define NO_TERMINAL "unknown"
 #define USE_SP_RIPOFF     1
 #define USE_SP_TERMTYPE   1
-#define USE_SP_WINDOWLIST 1
+#else
+#define NO_TERMINAL 0
 #endif
 
+#define VALID_TERM_ENV(term_env, no_terminal) \
+	(term_env = (NonEmpty(term_env) \
+		     ? term_env \
+		     : no_terminal), \
+	 NonEmpty(term_env))
+
+/*
+ * Originally a terminal-driver option, the window-list is per-screen to allow
+ * freeing memory used for windows when a screen is deleted.
+ */
+#define USE_SP_WINDOWLIST 1
+
 /*
  * Note:  ht/cbt expansion flakes out randomly under Linux 1.1.47, but only
  * when we're throwing control codes at the screen at high volume.  To see
@@ -289,6 +335,11 @@
  */
 #define StringOf(ch) {ch, 0}
 
+#define CSI_CHR 0x9b
+#define ESC_CHR 0x1b
+
+#define L_BLOCK '['
+#define R_BLOCK ']'
 #define L_BRACE '{'
 #define R_BRACE '}'
 #define S_QUOTE '\''
@@ -324,14 +375,27 @@
 
 #include <curses.h>	/* we'll use -Ipath directive to get the right one! */
 
+#if !(defined(NCURSES_WGETCH_EVENTS) && defined(NEED_KEY_EVENT))
+#undef KEY_EVENT		/* reduce compiler-warnings with Visual C++ */
+#endif
+
 typedef struct
 {
-    NCURSES_COLOR_T red, green, blue;	/* what color_content() returns */
-    NCURSES_COLOR_T r, g, b;		/* params to init_color() */
+    int red, green, blue;	/* what color_content() returns */
+    int r, g, b;		/* params to init_color() */
     int init;			/* true if we called init_color() */
 }
 color_t;
 
+typedef union {
+    struct {
+	unsigned char red;
+	unsigned char green;
+	unsigned char blue;
+    } bits;			/* bits per color-value in RGB */
+    unsigned value;
+} rgb_bits_t;
+
 /*
  * If curses.h did not expose the SCREEN-functions, then we do not need the
  * parameter in the corresponding unextended functions.
@@ -358,6 +422,9 @@
 
 #include <nc_panel.h>
 
+#include <term.priv.h>
+#include <nc_termios.h>
+
 #define IsPreScreen(sp)      (((sp) != 0) && sp->_prescreen)
 #define HasTerminal(sp)      (((sp) != 0) && (0 != ((sp)->_term)))
 #define IsValidScreen(sp)    (HasTerminal(sp) && !IsPreScreen(sp))
@@ -374,8 +441,31 @@
 #define TerminalOf(sp)       CurTerm
 #endif
 
-#include <term.h>
-#include <nc_termios.h>
+/*
+ * The legacy layout for TERMTYPE uses "short" for all of the numbers.  Moving
+ * past that, numeric capabilities can be "int" by using a TERMTYPE2 structure
+ * in TERMINAL, and doing most of the internal work using TERMTYPE2.  There are
+ * a few places (mostly to expose the legacy layout) where the distinction
+ * needs attention.
+ */
+#if NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR
+#define NCURSES_EXT_NUMBERS  1
+#define NCURSES_INT2         int
+#define SIZEOF_INT2          4
+#define TerminalType(tp)     (tp)->type2
+#else
+#define NCURSES_EXT_NUMBERS  0
+#define NCURSES_INT2         short
+#define SIZEOF_INT2          2
+#define TerminalType(tp)     (tp)->type
+#endif
+
+#define SIZEOF_SHORT         2
+
+#ifdef CUR
+#undef CUR
+#define CUR TerminalType(cur_term).
+#endif
 
 /*
  * Reduce dependency on cur_term global by using terminfo data from SCREEN's
@@ -385,7 +475,7 @@
 #undef CUR
 #endif
 
-#define SP_TERMTYPE TerminalOf(sp)->type.
+#define SP_TERMTYPE TerminalType(TerminalOf(sp)).
 
 #include <term_entry.h>
 
@@ -394,10 +484,11 @@
 /*
  * Simplify ifdef's for the "*_ATTR" macros in case italics are not configured.
  */
-#ifdef A_ITALIC
+#if defined(A_ITALIC) && defined(exit_italics_mode)
 #define USE_ITALIC 1
 #else
 #define USE_ITALIC 0
+#undef  A_ITALIC
 #define A_ITALIC 0
 #endif
 
@@ -406,7 +497,7 @@
  * option for compiling the tracing into the library.
  */
 #if 1
-#define ColorPair(n)		NCURSES_BITS(n, 0)
+#define ColorPair(n)		(NCURSES_BITS(n, 0) & A_COLOR)
 #define PairNumber(a)		(NCURSES_CAST(int,(((unsigned long)(a) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
 #else
 #define ColorPair(pair)		COLOR_PAIR(pair)
@@ -426,7 +517,7 @@
 #define if_EXT_COLORS(stmt)	stmt
 #define SetPair(value,p)	SetPair2((value).ext_color, AttrOf(value), p)
 #define SetPair2(c,a,p)		c = (p), \
-				a = (unColor2(a) | (A_COLOR & (unsigned) ColorPair(oldColor(c))))
+				a = (unColor2(a) | ColorPair(oldColor(c)))
 #define GetPair(value)		GetPair2((value).ext_color, AttrOf(value))
 #define GetPair2(c,a)		((c) ? (c) : PairNumber(a))
 #define oldColor(p)		(((p) > 255) ? 255 : (p))
@@ -434,20 +525,27 @@
 #define SET_WINDOW_PAIR(w,p)	(w)->_color = (p)
 #define SameAttrOf(a,b)		(AttrOf(a) == AttrOf(b) && GetPair(a) == GetPair(b))
 
-#define VIDATTR(sp,attr,pair)	NCURSES_SP_NAME(vid_puts)(NCURSES_SP_ARGx attr, (short) pair, 0, NCURSES_OUTC_FUNC)
+#define VIDPUTS(sp,attr,pair)	do { \
+				    int vid_pair = pair; \
+				    NCURSES_SP_NAME(vid_puts)( \
+					NCURSES_SP_ARGx attr, \
+					(NCURSES_PAIRS_T) pair, \
+					&vid_pair, \
+					NCURSES_OUTC_FUNC); \
+				} while (0)
 
 #else /* !NCURSES_EXT_COLORS */
 
 #define if_EXT_COLORS(stmt)	/* nothing */
 #define SetPair(value,p)	RemAttr(value, A_COLOR), \
-				SetAttr(value, AttrOf(value) | (A_COLOR & (attr_t) ColorPair(p)))
+				SetAttr(value, AttrOf(value) | ColorPair(p))
 #define GetPair(value)		PairNumber(AttrOf(value))
 #define GET_WINDOW_PAIR(w)	PairNumber(WINDOW_ATTRS(w))
 #define SET_WINDOW_PAIR(w,p)	WINDOW_ATTRS(w) &= ALL_BUT_COLOR, \
-				WINDOW_ATTRS(w) |= (A_COLOR & (attr_t) ColorPair(p))
+				WINDOW_ATTRS(w) |= ColorPair(p)
 #define SameAttrOf(a,b)		(AttrOf(a) == AttrOf(b))
 
-#define VIDATTR(sp,attr,pair)	NCURSES_SP_NAME(vidputs)(NCURSES_SP_ARGx attr, NCURSES_OUTC_FUNC)
+#define VIDPUTS(sp,attr,pair)	NCURSES_SP_NAME(vidputs)(NCURSES_SP_ARGx attr, NCURSES_OUTC_FUNC)
 
 #endif /* NCURSES_EXT_COLORS */
 
@@ -471,10 +569,10 @@
 #define SET_SCREEN_PAIR(s,p)	SetPair(SCREEN_ATTRS(s), p)
 
 #if USE_REENTRANT || NCURSES_SP_FUNCS
-NCURSES_EXPORT(int *)        _nc_ptr_Lines (SCREEN *);
-NCURSES_EXPORT(int *)        _nc_ptr_Cols (SCREEN *);
-NCURSES_EXPORT(int *)        _nc_ptr_Tabsize (SCREEN *);
-NCURSES_EXPORT(int *)        _nc_ptr_Escdelay (SCREEN *);
+extern NCURSES_EXPORT(int *)    _nc_ptr_Lines (SCREEN *);
+extern NCURSES_EXPORT(int *)    _nc_ptr_Cols (SCREEN *);
+extern NCURSES_EXPORT(int *)    _nc_ptr_Tabsize (SCREEN *);
+extern NCURSES_EXPORT(int *)    _nc_ptr_Escdelay (SCREEN *);
 #endif
 
 #if USE_REENTRANT
@@ -503,6 +601,12 @@
 
 #endif
 
+#define IS_SUBWIN(w)         ((w)->_flags & _SUBWIN)
+#define IS_PAD(w)            ((w)->_flags & _ISPAD)
+#define IS_WRAPPED(w)        ((w)->_flags & _WRAPPED)
+
+#define HasHardTabs()	(NonEmpty(clear_all_tabs) && NonEmpty(set_tab))
+
 #define TR_MUTEX(data) _tracef("%s@%d: me:%08lX COUNT:%2u/%2d/%6d/%2d/%s%9u: " #data, \
 	    __FILE__, __LINE__, \
 	    (unsigned long) (pthread_self()), \
@@ -561,7 +665,10 @@
 weak_symbol(pthread_mutexattr_init);
 extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *);
 #    undef  sigprocmask
-#    define sigprocmask _nc_sigprocmask
+#    define sigprocmask(a, b, c) _nc_sigprocmask(a, b, c)
+#    define GetThreadID() (((pthread_self)) ? pthread_self() : (pthread_t) getpid())
+#  else
+#    define GetThreadID() pthread_self()
 #  endif
 #endif
 
@@ -581,7 +688,7 @@
 weak_symbol(pthread_equal);
 extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *);
 #    undef  sigprocmask
-#    define sigprocmask _nc_sigprocmask
+#    define sigprocmask(a, b, c) _nc_sigprocmask(a, b, c)
 #  endif
 #endif /* USE_PTHREADS_EINTR */
 
@@ -591,9 +698,14 @@
 #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
+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
@@ -624,9 +736,18 @@
 
 #endif
 
-#if HAVE_GETTIMEOFDAY
+#if HAVE_CLOCK_GETTIME
 # define PRECISE_GETTIME 1
+# define GetClockTime(t) clock_gettime(CLOCK_REALTIME, t)
+# define TimeType struct timespec
+# define TimeScale 1000000000L		/* 1e9 */
+# define sub_secs tv_nsec
+#elif HAVE_GETTIMEOFDAY
+# define PRECISE_GETTIME 1
+# define GetClockTime(t) gettimeofday(t, 0)
 # define TimeType struct timeval
+# define TimeScale 1000000L		/* 1e6 */
+# define sub_secs tv_usec
 #else
 # define PRECISE_GETTIME 0
 # define TimeType time_t
@@ -635,15 +756,13 @@
 /*
  * Definitions for color pairs
  */
-typedef unsigned colorpair_t;	/* type big enough to store PAIR_OF() */
-#define C_SHIFT 9		/* we need more bits than there are colors */
-#define C_MASK			((1 << C_SHIFT) - 1)
-#define PAIR_OF(fg, bg)		(colorpair_t) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
-#define FORE_OF(c)		(((c) >> C_SHIFT) & C_MASK)
-#define BACK_OF(c)		((c) & C_MASK)
-#define isDefaultColor(c)	((c) >= COLOR_DEFAULT || (c) < 0)
 
-#define COLOR_DEFAULT		C_MASK
+#define MAX_OF_TYPE(t)   (int)(((unsigned t)(~0))>>1)
+
+#include <new_pair.h>
+
+#define isDefaultColor(c)	((c) < 0)
+#define COLOR_DEFAULT		-1
 
 #if defined(USE_BUILD_CC) || (defined(USE_TERMLIB) && !defined(NEED_NCURSES_CH_T))
 
@@ -724,12 +843,6 @@
 
 #endif	/* USE_TERMLIB */
 
-typedef	struct {
-	WINDOW *win;		/* the window used in the hook      */
-	int	line;		/* lines to take, < 0 => from bottom*/
-	int	(*hook)(WINDOW *, int); /* callback for user	    */
-} ripoff_t;
-
 #if USE_GPM_SUPPORT
 #undef buttons			/* term.h defines this, and gpm uses it! */
 #include <gpm.h>
@@ -757,55 +870,21 @@
 #endif /* HAVE_LIBDL */
 #endif /* USE_GPM_SUPPORT */
 
-typedef struct {
-    long sequence;
-    bool last_used;
-    char *fix_sgr0;		/* this holds the filtered sgr0 string */
-    char *last_bufp;		/* help with fix_sgr0 leak */
-    TERMINAL *last_term;
-} TGETENT_CACHE;
-
-#define TGETENT_MAX 4
+/*
+ * Limit delay-times to 30 seconds, which is consistent with signed 16-bit
+ * numbers in legacy terminfo.
+ */
+#define MAX_DELAY_MSECS 30000
 
 /*
- * State of tparm().
+ * When converting from terminfo to termcap, check for cases where we can trim
+ * octal escapes down to 2-character form.  It is useful for terminfo format
+ * also, but not as important.
  */
-#define STACKSIZE 20
+#define MAX_TC_FIXUPS	10
+#define MIN_TC_FIXUPS	4
 
-typedef struct {
-	union {
-		int	num;
-		char	*str;
-	} data;
-	bool num_type;
-} STACK_FRAME;
-
-#define NUM_VARS 26
-
-typedef struct {
-#ifdef TRACE
-	const char	*tname;
-#endif
-	const char	*tparam_base;
-
-	STACK_FRAME	stack[STACKSIZE];
-	int		stack_ptr;
-
-	char		*out_buff;
-	size_t		out_size;
-	size_t		out_used;
-
-	char		*fmt_buff;
-	size_t		fmt_size;
-
-	int		dynamic_var[NUM_VARS];
-	int		static_vars[NUM_VARS];
-} TPARM_STATE;
-
-typedef struct {
-    char *text;
-    size_t size;
-} TRACEBUF;
+#define isoctal(c) ((c) >= '0' && (c) <= '7')
 
 /*
  * The filesystem database normally uses a single-letter for the lower level
@@ -827,6 +906,7 @@
  * string is less than 80 columns, but this buffer size is an absolute
  * limit.
  */
+#define TRACECHR_BUF	40
 #define TRACEMSE_MAX	(80 + (5 * 10) + (32 * 15))
 #define TRACEMSE_FMT	"id %2d  at (%2d, %2d, %2d) state %4lx = {" /* } */
 
@@ -837,146 +917,16 @@
 #define INIT_TERM_DRIVER()	/* nothing */
 #endif
 
-typedef struct {
-    const char *name;
-    char *value;
-} ITERATOR_VARS;
-
-/*
- * Global data which is not specific to a screen.
- */
-typedef struct {
-	SIG_ATOMIC_T	have_sigtstp;
-	SIG_ATOMIC_T	have_sigwinch;
-	SIG_ATOMIC_T	cleanup_nested;
-
-	bool		init_signals;
-	bool		init_screen;
-
-	char		*comp_sourcename;
-	char		*comp_termtype;
-
-	bool		have_tic_directory;
-	bool		keep_tic_directory;
-	const char	*tic_directory;
-
-	char		*dbi_list;
-	int		dbi_size;
-
-	char		*first_name;
-	char		**keyname_table;
-	int		init_keyname;
-
-	int		slk_format;
-
-	char		*safeprint_buf;
-	size_t		safeprint_used;
-
-	TGETENT_CACHE	tgetent_cache[TGETENT_MAX];
-	int		tgetent_index;
-	long		tgetent_sequence;
-
-	char		*dbd_blob;	/* string-heap for dbd_list[] */
-	char		**dbd_list;	/* distinct places to look for data */
-	int		dbd_size;	/* length of dbd_list[] */
-	time_t		dbd_time;	/* cache last updated */
-	ITERATOR_VARS	dbd_vars[dbdLAST];
-
-#ifndef USE_SP_WINDOWLIST
-	WINDOWLIST	*_nc_windowlist;
-#define WindowList(sp)	_nc_globals._nc_windowlist
-#endif
-
-#if USE_HOME_TERMINFO
-	char		*home_terminfo;
-#endif
-
-#if !USE_SAFE_SPRINTF
-	int		safeprint_cols;
-	int		safeprint_rows;
-#endif
-
-#ifdef USE_TERM_DRIVER
-	int		(*term_driver)(struct DriverTCB*, const char*, int*);
-#endif
-
-#ifdef TRACE
-	bool		init_trace;
-	char		trace_fname[PATH_MAX];
-	int		trace_level;
-	FILE		*trace_fp;
-
-	char		*tracearg_buf;
-	size_t		tracearg_used;
-
-	TRACEBUF	*tracebuf_ptr;
-	size_t		tracebuf_used;
-
-	char		tracechr_buf[40];
-
-	char		*tracedmp_buf;
-	size_t		tracedmp_used;
-
-	unsigned char	*tracetry_buf;
-	size_t		tracetry_used;
-
-	char		traceatr_color_buf[2][80];
-	int		traceatr_color_sel;
-	int		traceatr_color_last;
-#if !defined(USE_PTHREADS) && USE_REENTRANT
-	int		nested_tracef;
-#endif
-#endif	/* TRACE */
-
-#ifdef USE_PTHREADS
-	pthread_mutex_t	mutex_curses;
-	pthread_mutex_t	mutex_tst_tracef;
-	pthread_mutex_t	mutex_tracef;
-	int		nested_tracef;
-	int		use_pthreads;
-#define _nc_use_pthreads	_nc_globals.use_pthreads
-#endif
-#if USE_PTHREADS_EINTR
-	pthread_t	read_thread;		/* The reading thread */
-#endif
-} NCURSES_GLOBALS;
-
 extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals;
 
-#define N_RIPS 5
-
-/*
- * Global data which can be swept up into a SCREEN when one is created.
- * It may be modified before the next SCREEN is created.
- */
-typedef struct {
-	bool		use_env;
-	bool		filter_mode;
-	attr_t		previous_attr;
-#ifndef USE_SP_RIPOFF
-	ripoff_t	rippedoff[N_RIPS];
-	ripoff_t	*rsp;
-#endif
-	TPARM_STATE	tparm_state;
-	TTY		*saved_tty;	/* savetty/resetty information	    */
-#if NCURSES_NO_PADDING
-	bool		_no_padding;	/* flag to set if padding disabled  */
-#endif
-	NCURSES_SP_OUTC	_outch;		/* output handler if not putc */
-#if BROKEN_LINKER || USE_REENTRANT
-	chtype		*real_acs_map;
-	int		_LINES;
-	int		_COLS;
-	int		_TABSIZE;
-	int		_ESCDELAY;
-	TERMINAL	*_cur_term;
-#ifdef TRACE
-	long		_outchars;
-	const char	*_tputs_trace;
-#endif
-#endif
-	bool		use_tioctl;
-} NCURSES_PRESCREEN;
+/* The limit reserves one byte for a terminating NUL */
+#define my_getstr_limit	(_nc_globals.getstr_limit - 1)
+#define _nc_getstr_limit(n) \
+	(((n) < 0) \
+	 ? my_getstr_limit \
+	 : (((n) > my_getstr_limit) \
+	    ? my_getstr_limit \
+	    : (n)))
 
 /*
  * Use screen-specific ripoff data (for softkeys) rather than global.
@@ -991,11 +941,30 @@
 
 extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen;
 
+typedef enum {
+    ewUnknown = 0,
+    ewInitial,
+    ewRunning,
+    ewSuspend
+} ENDWIN;
+
+typedef struct {
+	int		_nl;		/* True if NL -> CR/NL is on	    */
+	int		_raw;		/* True if in raw mode		    */
+	int		_cbreak;	/* 1 if in cbreak mode		    */
+					/* > 1 if in halfdelay mode	    */
+	int		_echo;		/* True if echo on		    */
+} TTY_FLAGS;
+
+#define IsNl(sp)        (sp)->_tty_flags._nl
+#define IsRaw(sp)       (sp)->_tty_flags._raw
+#define IsCbreak(sp)    (sp)->_tty_flags._cbreak
+#define IsEcho(sp)      (sp)->_tty_flags._echo
+
 /*
  * The SCREEN structure.
  */
-
-struct screen {
+typedef struct screen {
 	int		_ifd;		/* input file descriptor for screen */
 	int		_ofd;		/* output file descriptor for screen */
 	FILE		*_ofp;		/* output file ptr for screen	    */
@@ -1042,27 +1011,16 @@
 	int		_cursrow;	/* physical cursor row		    */
 	int		_curscol;	/* physical cursor column	    */
 	bool		_notty;		/* true if we cannot switch non-tty */
-	int		_nl;		/* True if NL -> CR/NL is on	    */
-	int		_raw;		/* True if in raw mode		    */
-	int		_cbreak;	/* 1 if in cbreak mode		    */
-					/* > 1 if in halfdelay mode	    */
-	int		_echo;		/* True if echo on		    */
+	TTY_FLAGS	_tty_flags;
 	int		_use_meta;	/* use the meta key?		    */
 	struct _SLK	*_slk;		/* ptr to soft key struct / NULL    */
 	int		slk_format;	/* selected format for this screen  */
 	/* cursor movement costs; units are 10ths of milliseconds */
-#if NCURSES_NO_PADDING
-	bool		_no_padding;	/* flag to set if padding disabled  */
-#endif
 	int		_char_padding;	/* cost of character put	    */
 	int		_cr_cost;	/* cost of (carriage_return)	    */
 	int		_cup_cost;	/* cost of (cursor_address)	    */
 	int		_home_cost;	/* cost of (cursor_home)	    */
 	int		_ll_cost;	/* cost of (cursor_to_ll)	    */
-#if USE_HARD_TABS
-	int		_ht_cost;	/* cost of (tab)		    */
-	int		_cbt_cost;	/* cost of (backtab)		    */
-#endif /* USE_HARD_TABS */
 	int		_cub1_cost;	/* cost of (cursor_left)	    */
 	int		_cuf1_cost;	/* cost of (cursor_right)	    */
 	int		_cud1_cost;	/* cost of (cursor_down)	    */
@@ -1096,19 +1054,13 @@
 	int		_scrolling;	/* 1 if terminal's smart enough to  */
 
 	/* used in lib_color.c */
+	rgb_bits_t	_direct_color;	/* RGB overrides color-table	     */
 	color_t		*_color_table;	/* screen's color palette	     */
 	int		_color_count;	/* count of colors in palette	     */
 	colorpair_t	*_color_pairs;	/* screen's color pair list	     */
-	int		_pair_count;	/* count of color pairs		     */
+	int		_pair_count;	/* same as COLOR_PAIRS               */
 	int		_pair_limit;	/* actual limit of color-pairs       */
-#if NCURSES_EXT_FUNCS
-	bool		_assumed_color; /* use assumed colors		     */
-	bool		_default_color; /* use default colors		     */
-	bool		_has_sgr_39_49; /* has ECMA default color support    */
-	int		_default_fg;	/* assumed default foreground	     */
-	int		_default_bg;	/* assumed default background	     */
-	int		_default_pairs;	/* count pairs using default color   */
-#endif
+	int		_pair_alloc;	/* current table-size of color-pairs */
 	chtype		_ok_attributes; /* valid attributes for terminal     */
 	chtype		_xmc_suppress;	/* attributes to suppress if xmc     */
 	chtype		_xmc_triggers;	/* attributes to process if xmc	     */
@@ -1119,13 +1071,6 @@
 	/* used in lib_vidattr.c */
 	bool		_use_rmso;	/* true if we may use 'rmso'	     */
 	bool		_use_rmul;	/* true if we may use 'rmul'	     */
-#if USE_ITALIC
-	bool		_use_ritm;	/* true if we may use 'ritm'	     */
-#endif
-
-#if USE_KLIBC_KBD
-	bool		_extended_key;	/* true if an extended key	     */
-#endif
 
 	/*
 	 * These data correspond to the state of the idcok() and idlok()
@@ -1158,6 +1103,60 @@
 	MEVENT		_mouse_events[EV_MAX];	/* hold the last mouse event seen */
 	MEVENT		*_mouse_eventp;	/* next free slot in event queue */
 
+	/*
+	 * These are data that support the proper handling of the panel stack on an
+	 * per screen basis.
+	 */
+	struct panelhook _panelHook;
+
+	bool		_sig_winch;
+	SCREEN		*_next_screen;
+
+	/* hashes for old and new lines */
+	unsigned long	*oldhash, *newhash;
+	HASHMAP		*hashtab;
+	int		hashtab_len;
+	int		*_oldnum_list;
+	int		_oldnum_size;
+
+	NCURSES_SP_OUTC	_outch;		/* output handler if not putc */
+	NCURSES_OUTC	jump;
+
+	ripoff_t	rippedoff[N_RIPS];
+	ripoff_t	*rsp;
+
+	int		_legacy_coding;	/* see use_legacy_coding() */
+
+#if NCURSES_NO_PADDING
+	bool		_no_padding;	/* flag to set if padding disabled  */
+#endif
+
+#if USE_HARD_TABS
+	int		_ht_cost;	/* cost of (tab)		    */
+	int		_cbt_cost;	/* cost of (backtab)		    */
+#endif /* USE_HARD_TABS */
+
+	/* used in lib_vidattr.c */
+#if USE_ITALIC
+	bool		_use_ritm;	/* true if we may use 'ritm'	     */
+#endif
+
+	/* used in getch/twait */
+#if USE_KLIBC_KBD
+	bool		_extended_key;	/* true if an extended key	     */
+#endif
+
+	/* used in lib_color.c */
+#if NCURSES_EXT_FUNCS
+	bool		_assumed_color; /* use assumed colors		     */
+	bool		_default_color; /* use default colors		     */
+	bool		_has_sgr_39_49; /* has ECMA default color support    */
+	int		_default_fg;	/* assumed default foreground	     */
+	int		_default_bg;	/* assumed default background	     */
+	int		_default_pairs;	/* count pairs using default color   */
+#endif
+
+	/* system-dependent mouse data */
 #if USE_GPM_SUPPORT
 	bool		_mouse_gpm_loaded;
 	bool		_mouse_gpm_found;
@@ -1188,7 +1187,7 @@
 	int		_sysmouse_new_buttons;
 #endif
 
-#ifdef USE_TERM_DRIVER
+#if defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER)
 	MEVENT		_drv_mouse_fifo[FIFO_SIZE];
 	int		_drv_mouse_head;
 	int		_drv_mouse_tail;
@@ -1203,25 +1202,10 @@
 	int		(*_ungetch)(SCREEN *, int);
 #endif
 
-	/*
-	 * These are data that support the proper handling of the panel stack on an
-	 * per screen basis.
-	 */
-	struct panelhook _panelHook;
-
-	bool		_sig_winch;
-	SCREEN		*_next_screen;
-
-	/* hashes for old and new lines */
-	unsigned long	*oldhash, *newhash;
-	HASHMAP		*hashtab;
-	int		hashtab_len;
-	int		*_oldnum_list;
-	int		_oldnum_size;
-
-	NCURSES_SP_OUTC	_outch;		/* output handler if not putc */
-
-	int		_legacy_coding;	/* see use_legacy_coding() */
+#ifdef USE_SP_WINDOWLIST
+	WINDOWLIST*	_windowlist;
+#define WindowList(sp)  (sp)->_windowlist
+#endif
 
 #if USE_REENTRANT
 	char		_ttytype[NAMESIZE];
@@ -1229,24 +1213,11 @@
 	int		_TABSIZE;
 	int		_LINES;
 	int		_COLS;
-#ifdef TRACE
-	long		_outchars;
-	const char	*_tputs_trace;
-#endif
 #endif
 
-#ifdef TRACE
-	char		tracechr_buf[40];
-	char		tracemse_buf[TRACEMSE_MAX];
+#if NCURSES_SP_FUNCS
+	bool		use_tioctl;
 #endif
-#ifdef USE_SP_WINDOWLIST
-	WINDOWLIST*	_windowlist;
-#define WindowList(sp)  (sp)->_windowlist
-#endif
-	NCURSES_OUTC	jump;
-
-	ripoff_t	rippedoff[N_RIPS];
-	ripoff_t	*rsp;
 
 	/*
 	 * ncurses/ncursesw are the same up to this point.
@@ -1259,8 +1230,22 @@
 	bool		_screen_unicode;
 #endif
 
-	bool		_use_tioctl;
-};
+#if NCURSES_EXT_FUNCS && NCURSES_EXT_COLORS
+	void		*_ordered_pairs; /* index used by alloc_pair()	     */
+	int		_pairs_used;	/* actual number of color-pairs used */
+	int		_recent_pair;	/* number for most recent free-pair  */
+#endif
+
+#ifdef TRACE
+	char		tracechr_buf[TRACECHR_BUF];
+	char		tracemse_buf[TRACEMSE_MAX];
+#if USE_REENTRANT
+	long		_outchars;
+	const char	*_tputs_trace;
+#endif
+#endif
+#undef SCREEN
+} SCREEN;
 
 extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
 extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
@@ -1279,19 +1264,25 @@
 
 #define WINDOW_EXT(w,m) (((WINDOWLIST *)((void *)((char *)(w) - offsetof(WINDOWLIST, win))))->m)
 
+#ifdef USE_SP_WINDOWLIST
+#define SP_INIT_WINDOWLIST(sp)	WindowList(sp) = 0
+#else
+#define SP_INIT_WINDOWLIST(sp)	/* nothing */
+#endif
+
 #define SP_PRE_INIT(sp)                         \
-    sp->_cursrow = -1;                          \
-    sp->_curscol = -1;                          \
-    sp->_nl = TRUE;                             \
-    sp->_raw = FALSE;                           \
-    sp->_cbreak = 0;                            \
-    sp->_echo = TRUE;                           \
-    sp->_fifohead = -1;                         \
-    sp->_endwin = TRUE;                         \
-    sp->_cursor = -1;                           \
-    WindowList(sp) = 0;                         \
-    sp->_outch = NCURSES_OUTC_FUNC;             \
-    sp->jump = 0                                \
+    sp->_cursrow           = -1;                \
+    sp->_curscol           = -1;                \
+    IsNl(sp)               = TRUE;              \
+    IsRaw(sp)              = FALSE;             \
+    IsCbreak(sp)           = 0;                 \
+    IsEcho(sp)             = TRUE;              \
+    sp->_fifohead          = -1;                \
+    sp->_endwin            = ewSuspend;         \
+    sp->_cursor            = -1;                \
+    SP_INIT_WINDOWLIST(sp);                     \
+    sp->_outch             = NCURSES_OUTC_FUNC; \
+    sp->jump               = 0                  \
 
 /* usually in <limits.h> */
 #ifndef UCHAR_MAX
@@ -1304,12 +1295,12 @@
 /* Checks for isprint() should be done on 8-bit characters (non-wide) */
 #define is8bits(c)	((unsigned)(c) <= UCHAR_MAX)
 
-#ifndef min
-#define min(a,b)	((a) > (b)  ?  (b)  :  (a))
+#ifndef Min
+#define Min(a,b)	((a) > (b)  ?  (b)  :  (a))
 #endif
 
-#ifndef max
-#define max(a,b)	((a) < (b)  ?  (b)  :  (a))
+#ifndef Max
+#define Max(a,b)	((a) < (b)  ?  (b)  :  (a))
 #endif
 
 /* usually in <unistd.h> */
@@ -1371,14 +1362,13 @@
 #define ChCharOf(c)	((chtype)(c) & (chtype)A_CHARTEXT)
 #define ChAttrOf(c)	((chtype)(c) & (chtype)A_ATTRIBUTES)
 
-#ifndef MB_LEN_MAX
-#define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
-#endif
+#define TR_PUTC(c)	TR(TRACE_CHARPUT, ("PUTC %#x", UChar(c)))
 
 #if USE_WIDEC_SUPPORT /* { */
+/* true if the status/errno indicate an illegal multibyte sequence */
 #define isEILSEQ(status) (((size_t)status == (size_t)-1) && (errno == EILSEQ))
 
-#define init_mb(state)	memset(&state, 0, sizeof(state))
+#define init_mb(state)	memset(&(state), 0, sizeof(state))
 
 #if NCURSES_EXT_COLORS
 #define NulColor	, 0
@@ -1386,7 +1376,20 @@
 #define NulColor	/* nothing */
 #endif
 
-#define NulChar		0,0,0,0	/* FIXME: see CCHARW_MAX */
+#if CCHARW_MAX > 6
+#define NulChar		0,0,0,0,0
+#elif CCHARW_MAX > 5
+#define NulChar		0,0,0,0		/* ncurses7 */
+#elif CCHARW_MAX > 4
+#define NulChar		0,0,0		/* ncurses6 */
+#elif CCHARW_MAX > 3
+#define NulChar		0,0
+#elif CCHARW_MAX > 2
+#define NulChar		0
+#else
+#define NulChar		/* nothing */
+#endif
+
 #define CharOf(c)	((c).chars[0])
 #define AttrOf(c)	((c).attr)
 
@@ -1397,27 +1400,25 @@
 #define NewChar2(c,a)	{ a, { c, NulChar } NulColor }
 #define NewChar(ch)	NewChar2(ChCharOf(ch), ChAttrOf(ch))
 
-#if CCHARW_MAX == 5
+#if CCHARW_MAX > 1
 #define CharEq(a,b)	(((a).attr == (b).attr) \
-		       && (a).chars[0] == (b).chars[0] \
-		       && (a).chars[1] == (b).chars[1] \
-		       && (a).chars[2] == (b).chars[2] \
-		       && (a).chars[3] == (b).chars[3] \
-		       && (a).chars[4] == (b).chars[4] \
+			 && !memcmp((a).chars, \
+				    (b).chars, \
+				    CCHARW_MAX * sizeof((b).chars[0])) \
 			if_EXT_COLORS(&& (a).ext_color == (b).ext_color))
 #else
 #define CharEq(a,b)	(!memcmp(&(a), &(b), sizeof(a)))
 #endif
 
 #define SetChar(ch,c,a) do {							    \
-			    NCURSES_CH_T *_cp = &ch;				    \
+			    NCURSES_CH_T *_cp = &(ch);				    \
 			    memset(_cp, 0, sizeof(ch));				    \
 			    _cp->chars[0] = (wchar_t) (c);			    \
 			    _cp->attr = (a);					    \
 			    if_EXT_COLORS(SetPair(ch, PairNumber(a)));		    \
 			} while (0)
-#define CHREF(wch)	(&wch)
-#define CHDEREF(wch)	(*wch)
+#define CHREF(wch)	(&(wch))
+#define CHDEREF(wch)	(*(wch))
 #define ARG_CH_T	NCURSES_CH_T *
 #define CARG_CH_T	const NCURSES_CH_T *
 #define PUTC_DATA	char PUTC_buf[MB_LEN_MAX]; int PUTC_i, PUTC_n; \
@@ -1425,23 +1426,27 @@
 #define PUTC_INIT	init_mb (PUT_st)
 #define PUTC(ch)	do { if(!isWidecExt(ch)) {				    \
 			if (Charable(ch)) {					    \
-			    NCURSES_OUTC_FUNC (NCURSES_SP_ARGx CharOf(ch)); \
+			    TR_PUTC(CharOf(ch));				    \
+			    NCURSES_OUTC_FUNC (NCURSES_SP_ARGx CharOf(ch));	    \
 			    COUNT_OUTCHARS(1);					    \
 			} else {						    \
-			    PUTC_INIT;						    \
 			    for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {	    \
 				PUTC_ch = (ch).chars[PUTC_i];			    \
 				if (PUTC_ch == L'\0')				    \
 				    break;					    \
+				PUTC_INIT;					    \
 				PUTC_n = (int) wcrtomb(PUTC_buf,		    \
 						       (ch).chars[PUTC_i], &PUT_st); \
 				if (PUTC_n <= 0) {				    \
-				    if (PUTC_ch && is8bits(PUTC_ch) && PUTC_i == 0) \
+				    if (PUTC_ch && is8bits(PUTC_ch) && PUTC_i == 0) { \
+					TR_PUTC(CharOf(ch));			    \
 					NCURSES_OUTC_FUNC (NCURSES_SP_ARGx CharOf(ch)); \
+				    }						    \
 				    break;					    \
 				} else {					    \
 				    int PUTC_j;					    \
 				    for (PUTC_j = 0; PUTC_j < PUTC_n; ++PUTC_j) {   \
+					TR_PUTC(PUTC_buf[PUTC_j]);		    \
 					NCURSES_OUTC_FUNC (NCURSES_SP_ARGx PUTC_buf[PUTC_j]); \
 				    }						    \
 				}						    \
@@ -1489,7 +1494,10 @@
 #define ARG_CH_T	NCURSES_CH_T
 #define CARG_CH_T	NCURSES_CH_T
 #define PUTC_DATA	/* nothing */
-#define PUTC(ch)	NCURSES_OUTC_FUNC (NCURSES_SP_ARGx (int) ch)
+#define PUTC(ch)	{ \
+			    TR_PUTC(ch); \
+			    NCURSES_OUTC_FUNC (NCURSES_SP_ARGx (int) ch); \
+			}
 
 #define BLANK		(' '|A_NORMAL)
 #define ZEROS		('\0'|A_NORMAL)
@@ -1498,6 +1506,7 @@
 #define isWidecExt(ch)	(0)
 #define if_WIDEC(code) /* nothing */
 
+#define Charable(ch)	(CharOf(ch) >= ' ' && CharOf(ch) <= '~')
 #define L(ch)		ch
 #endif /* } */
 
@@ -1539,28 +1548,53 @@
 
 #define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
 
+#include <nc_alloc.h>
+#include <nc_access.h>
+
 #define FreeIfNeeded(p)  if ((p) != 0) free(p)
 
 /* FreeAndNull() is not a comma-separated expression because some compilers
  * do not accept a mixture of void with values.
  */
-#define FreeAndNull(p)   free(p); p = 0
+#define FreeAndNull(p)   do { free(p); p = 0; } while (0)
 
-#include <nc_alloc.h>
+#ifdef EXP_OOM_TESTING
+extern NCURSES_EXPORT(void *)	_nc_oom_malloc(size_t size);
+extern NCURSES_EXPORT(void *)	_nc_oom_calloc(size_t nmemb, size_t size);
+extern NCURSES_EXPORT(void *)	_nc_oom_realloc(void *ptr, size_t size);
+extern NCURSES_EXPORT(void)	_nc_oom_free(void *ptr);
+extern NCURSES_EXPORT(char *)	_nc_oom_strdup(const char *ptr);
+#define malloc(size)		_nc_oom_malloc(size)
+#define calloc(nmemb, size)	_nc_oom_calloc(nmemb, size)
+#define realloc(ptr, size)	_nc_oom_realloc(ptr, size)
+#define free(ptr)		_nc_oom_free(ptr)
+#define strdup(ptr)		_nc_oom_strdup(ptr)
+#endif
 
 /*
  * Use these for tic/infocmp malloc failures.  Generally the ncurses library
  * tries to limp along after a failure.
  */
 #define TYPE_MALLOC(type, size, name) \
-	name = typeMalloc(type, size); \
-	if (name == 0) \
-	    _nc_err_abort(MSG_NO_MEMORY)
+	do { \
+	    name = typeMalloc(type, size); \
+	    if (name == 0) \
+		_nc_err_abort(MSG_NO_MEMORY); \
+	} while (0)
+
+#define TYPE_CALLOC(type, size, name) \
+	do { \
+	    name = typeCalloc(type, size); \
+	    if (name == 0) \
+		_nc_err_abort(MSG_NO_MEMORY); \
+	} while (0)
 
 #define TYPE_REALLOC(type, size, name) \
-	name = typeRealloc(type, size, name); \
-	if (name == 0) \
-	    _nc_err_abort(MSG_NO_MEMORY)
+	do { \
+	    name = typeRealloc(type, size, name); \
+	    if (name == 0) \
+		_nc_err_abort(MSG_NO_MEMORY); \
+	} while (0)
 
 /*
  * TTY bit definition for converting tabs to spaces.
@@ -1579,6 +1613,14 @@
 # endif
 #endif
 
+#ifdef __TANDEM
+#define ROOT_UID 65535
+#endif
+
+#ifndef ROOT_UID
+#define ROOT_UID 0
+#endif
+
 /*
  * Standardize/simplify common loops
  */
@@ -1595,6 +1637,9 @@
 #define T_CREATE(fmt) "create :" fmt
 #define T_RETURN(fmt) "return }" fmt
 
+#define NonNull(s)              ((s) != 0 ? s : "<null>")
+#define NonEmpty(s)             ((s) != 0 && *(s) != '\0')
+
 #ifdef TRACE
 
 #if USE_REENTRANT
@@ -1603,12 +1648,16 @@
 #define TPUTS_TRACE(s)	_nc_tputs_trace = s;
 #endif
 
+#ifdef HAVE_CONSISTENT_GETENV
 #define START_TRACE() \
 	if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \
 	    int t = _nc_getenv_num("NCURSES_TRACE"); \
 	    if (t >= 0) \
-		trace((unsigned) t); \
+		curses_trace((unsigned) t); \
 	}
+#else
+#define START_TRACE() /* nothing */
+#endif
 
 /*
  * Many of the _tracef() calls use static buffers; lock the trace state before
@@ -1630,7 +1679,11 @@
 #define TRACE_RETURN2(value,dst,src) return _nc_retrace_##dst##_##src(value)
 #define TRACE_RETURN_SP(value,type)  return _nc_retrace_##type(SP_PARM, value)
 
-#define NonNull(s)	((s) != 0 ? s : "<null>")
+typedef void VoidFunc(void);
+
+#define TR_FUNC_LEN		((sizeof(void *) + sizeof(void (*)(void))) * 2 + 4)
+#define TR_FUNC_BFR(max)	char tr_func_data[max][TR_FUNC_LEN]
+#define TR_FUNC_ARG(num,func)	_nc_fmt_funcptr(&tr_func_data[num][0], (const char *)&(func), sizeof((func)))
 
 #define returnAttr(code)	TRACE_RETURN(code,attr_t)
 #define returnBits(code)	TRACE_RETURN(code,unsigned)
@@ -1644,17 +1697,21 @@
 #define returnMMask(code)	TRACE_RETURN_SP(code,mmask_t)
 #define returnPtr(code)		TRACE_RETURN1(code,ptr)
 #define returnSP(code)		TRACE_RETURN1(code,sp)
-#define returnVoid		T((T_RETURN(""))); return
+#define returnVoid		{ T((T_RETURN(""))); return; }
 #define returnVoidPtr(code)	TRACE_RETURN1(code,void_ptr)
 #define returnWin(code)		TRACE_RETURN1(code,win)
 
+#define returnDB(rc)		do { TR(TRACE_DATABASE,(T_RETURN("code %d"), (rc))); return (rc); } while (0)
+#define returnPtrDB(rc)		do { TR(TRACE_DATABASE,(T_RETURN("%p"), (rc))); return (rc); } while (0)
+#define returnVoidDB		do { TR(TRACE_DATABASE,(T_RETURN(""))); return; } while (0)
+
 extern NCURSES_EXPORT(NCURSES_BOOL)     _nc_retrace_bool (int);
 extern NCURSES_EXPORT(NCURSES_CONST void *) _nc_retrace_cvoid_ptr (NCURSES_CONST void *);
 extern NCURSES_EXPORT(SCREEN *)         _nc_retrace_sp (SCREEN *);
 extern NCURSES_EXPORT(WINDOW *)         _nc_retrace_win (WINDOW *);
 extern NCURSES_EXPORT(attr_t)           _nc_retrace_attr_t (attr_t);
 extern NCURSES_EXPORT(char *)           _nc_retrace_ptr (char *);
-extern NCURSES_EXPORT(char *)           _nc_trace_ttymode(TTY *tty);
+extern NCURSES_EXPORT(char *)           _nc_trace_ttymode(const TTY *tty);
 extern NCURSES_EXPORT(char *)           _nc_varargs (const char *, va_list);
 extern NCURSES_EXPORT(chtype)           _nc_retrace_chtype (chtype);
 extern NCURSES_EXPORT(const char *)     _nc_altcharset_name(attr_t, chtype);
@@ -1667,6 +1724,8 @@
 extern NCURSES_EXPORT(void *)           _nc_retrace_void_ptr (void *);
 extern NCURSES_EXPORT(void)             _nc_fifo_dump (SCREEN *);
 
+extern NCURSES_EXPORT(char *)           _nc_fmt_funcptr(char *, const char *, size_t);
+
 #if USE_REENTRANT
 NCURSES_WRAPPED_VAR(long, _nc_outchars);
 NCURSES_WRAPPED_VAR(const char *, _nc_tputs_trace);
@@ -1681,6 +1740,10 @@
 
 extern NCURSES_EXPORT_VAR(unsigned)     _nc_tracing;
 
+extern NCURSES_EXPORT(char *) _nc_tracebits (void);
+extern NCURSES_EXPORT(char *) _tracemouse (const MEVENT *);
+extern NCURSES_EXPORT(void) _tracedump (const char *, WINDOW *);
+
 #if USE_WIDEC_SUPPORT
 extern NCURSES_EXPORT(const char *) _nc_viswbuf2 (int, const wchar_t *);
 extern NCURSES_EXPORT(const char *) _nc_viswbufn (const wchar_t *, int);
@@ -1696,6 +1759,7 @@
 #define T(a)
 #define TR(n, a)
 #define TPUTS_TRACE(s)
+#define TR_FUNC_BFR(max)
 
 #define returnAttr(code)	return code
 #define returnBits(code)	return code
@@ -1713,6 +1777,10 @@
 #define returnVoidPtr(code)	return code
 #define returnWin(code)		return code
 
+#define returnDB(code)		return code
+#define returnPtrDB(rc)		return rc
+#define returnVoidDB		return
+
 #endif /* TRACE/!TRACE */
 
 /*
@@ -1780,7 +1848,7 @@
 #if USE_XMC_SUPPORT
 #define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \
 				attr_t chg = AttrOf(SCREEN_ATTRS(sp)); \
-				VIDATTR(sp, AttrOf(c), GetPair(c)); \
+				VIDPUTS(sp, AttrOf(c), GetPair(c)); \
 				if (magic_cookie_glitch > 0 \
 				 && XMC_CHANGES((chg ^ AttrOf(SCREEN_ATTRS(sp))))) { \
 					T(("%s @%d before glitch %d,%d", \
@@ -1792,7 +1860,7 @@
 			}
 #else
 #define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \
-				    VIDATTR(sp, AttrOf(c), GetPair(c)); \
+				    VIDPUTS(sp, AttrOf(c), GetPair(c)); \
 			}
 #endif
 
@@ -1859,6 +1927,20 @@
 #define getcwd(buf,len) getwd(buf)
 #endif
 
+#define save_ttytype(termp) \
+	if (TerminalType(termp).term_names != 0) { \
+	    _nc_STRNCPY(ttytype, \
+	    		TerminalType(termp).term_names, \
+			NAMESIZE - 1); \
+	    ttytype[NAMESIZE - 1] = '\0'; \
+	}
+
+#if !NCURSES_WCWIDTH_GRAPHICS
+extern NCURSES_EXPORT(int) _nc_wacs_width(unsigned);
+#else
+#define _nc_wacs_width(ch) wcwidth(ch)
+#endif
+
 /* charable.c */
 #if USE_WIDEC_SUPPORT
 extern NCURSES_EXPORT(bool) _nc_is_charable(wchar_t);
@@ -1881,6 +1963,16 @@
 	short	source;
 } alias_table_data;
 
+/* comp_userdefs.c */
+typedef struct {
+	short	ute_name;	/* offset of name to hash on */
+	unsigned ute_type;	/* mask (BOOLEAN, NUMBER, STRING) */
+	unsigned ute_argc;	/* number of parameters */
+	unsigned ute_args;	/* bit-mask for string parameters */
+	short	ute_index;	/* index of associated variable in its array */
+	short	ute_link;	/* index in table of next hash, or -1 */
+} user_table_data;
+
 /* doupdate.c */
 #if USE_XMC_SUPPORT
 extern NCURSES_EXPORT(void) _nc_do_xmc_glitch (attr_t);
@@ -1893,11 +1985,11 @@
 
 /* lib_acs.c */
 extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
-extern NCURSES_EXPORT(int)  _nc_msec_cost (const char *const, int);  /* used by 'tack' program */
+extern NCURSES_EXPORT(int)  _nc_msec_cost (const char *const, int);
 
 /* lib_addch.c */
 #if USE_WIDEC_SUPPORT
-NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch);
+extern NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch);
 #endif
 
 /* lib_addstr.c */
@@ -1906,7 +1998,16 @@
 #endif
 
 /* lib_color.c */
+extern NCURSES_EXPORT(int) _nc_init_color(SCREEN *, int, int, int, int);
+extern NCURSES_EXPORT(int) _nc_init_pair(SCREEN *, int, int, int);
+extern NCURSES_EXPORT(int) _nc_pair_content(SCREEN *, int, int *, int *);
 extern NCURSES_EXPORT(bool) _nc_reset_colors(void);
+extern NCURSES_EXPORT(void) _nc_reserve_pairs(SCREEN *, int);
+extern NCURSES_EXPORT(void) _nc_change_pair(SCREEN *, int);
+
+#define ReservePairs(sp,want) \
+	    if ((sp->_color_pairs == 0) || (want >= sp->_pair_alloc)) \
+		_nc_reserve_pairs(sp, want)
 
 /* lib_getch.c */
 extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, int *, int EVENTLIST_2nd(_nc_eventlist *));
@@ -1940,30 +2041,43 @@
 extern NCURSES_EXPORT(char *) _nc_get_locale(void);
 extern NCURSES_EXPORT(int)    _nc_unicode_locale(void);
 extern NCURSES_EXPORT(int)    _nc_locale_breaks_acs(TERMINAL *);
-extern NCURSES_EXPORT(int)    _nc_setupterm(NCURSES_CONST char *, int, int *, int);
+extern NCURSES_EXPORT(int)    _nc_setupterm(const char *, int, int *, int);
 extern NCURSES_EXPORT(void)   _nc_tinfo_cmdch(TERMINAL *, int);
 
+#ifdef USE_PTHREADS
+extern NCURSES_EXPORT(SCREEN *) _nc_find_prescr(void);
+extern NCURSES_EXPORT(void)   _nc_forget_prescr(void);
+#else
+#define _nc_find_prescr()     _nc_prescreen.allocated
+#define _nc_forget_prescr()   _nc_prescreen.allocated = 0
+#endif
+
 /* lib_set_term.c */
 extern NCURSES_EXPORT(int)    _nc_ripoffline(int, int(*)(WINDOW*, int));
 
 /* lib_setup.c */
+#define ExitTerminfo(code)    exit_terminfo(code)
+
 #define SETUP_FAIL ERR
-#define ret_error(code, fmt, arg)	if (errret) {\
-					    *errret = code;\
+
+#define ret_error(rc, fmt, p, q)	if (errret) {\
+					    *errret = rc;\
+					    q;\
 					    returnCode(SETUP_FAIL);\
 					} else {\
-					    fprintf(stderr, fmt, arg);\
-					    exit(EXIT_FAILURE);\
+					    fprintf(stderr, fmt, p);\
+					    q;\
+					    ExitTerminfo(EXIT_FAILURE);\
 					}
 
-#define ret_error1(code, fmt, arg)	ret_error(code, "'%s': " fmt, arg)
+#define ret_error1(rc, fmt, p, q)	ret_error(rc, "'%s': " fmt, p, q)
 
-#define ret_error0(code, msg)		if (errret) {\
-					    *errret = code;\
+#define ret_error0(rc, msg)		if (errret) {\
+					    *errret = rc;\
 					    returnCode(SETUP_FAIL);\
 					} else {\
 					    fprintf(stderr, msg);\
-					    exit(EXIT_FAILURE);\
+					    ExitTerminfo(EXIT_FAILURE);\
 					}
 
 /* lib_tstp.c */
@@ -1988,7 +2102,7 @@
 /* strings.c */
 extern NCURSES_EXPORT(string_desc *) _nc_str_init (string_desc *, char *, size_t);
 extern NCURSES_EXPORT(string_desc *) _nc_str_null (string_desc *, size_t);
-extern NCURSES_EXPORT(string_desc *) _nc_str_copy (string_desc *, string_desc *);
+extern NCURSES_EXPORT(string_desc *) _nc_str_copy (string_desc *, const string_desc *);
 extern NCURSES_EXPORT(bool) _nc_safe_strcat (string_desc *, const char *);
 extern NCURSES_EXPORT(bool) _nc_safe_strcpy (string_desc *, const char *);
 
@@ -2007,7 +2121,6 @@
 extern NCURSES_EXPORT(int) _nc_remove_string (TRIES **, const char *);
 
 /* elsewhere ... */
-extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry (ENTRY *, TERMTYPE *);
 extern NCURSES_EXPORT(SCREEN *) _nc_screen_of (WINDOW *);
 extern NCURSES_EXPORT(TERMINAL*) _nc_get_cur_term (void);
 extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int);
@@ -2026,19 +2139,21 @@
 extern NCURSES_EXPORT(int) _nc_putchar (int);
 extern NCURSES_EXPORT(int) _nc_putp(const char *, const char *);
 extern NCURSES_EXPORT(int) _nc_putp_flush(const char *, const char *);
-extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE *const);
-extern NCURSES_EXPORT(int) _nc_setup_tinfo(const char *, TERMTYPE *);
+extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE2 *const);
+extern NCURSES_EXPORT(int) _nc_setup_tinfo(const char *, TERMTYPE2 *);
 extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, int, int);
 extern NCURSES_EXPORT(int) _nc_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *));
+extern NCURSES_EXPORT(int) _nc_trans_string (char *, const char *);
+extern NCURSES_EXPORT(void) _nc_init_termtype (TERMTYPE2 *const);
 extern NCURSES_EXPORT(void) _nc_do_color (int, int, int, NCURSES_OUTC);
 extern NCURSES_EXPORT(void) _nc_flush (void);
-extern NCURSES_EXPORT(void) _nc_free_and_exit (int) GCC_NORETURN;
-extern NCURSES_EXPORT(void) _nc_free_entry (ENTRY *, TERMTYPE *);
+extern NCURSES_EXPORT(void) _nc_free_entry (ENTRY *, TERMTYPE2 *);
 extern NCURSES_EXPORT(void) _nc_freeall (void);
 extern NCURSES_EXPORT(void) _nc_hash_map (void);
 extern NCURSES_EXPORT(void) _nc_init_keytry (SCREEN *);
 extern NCURSES_EXPORT(void) _nc_keep_tic_dir (const char *);
 extern NCURSES_EXPORT(void) _nc_make_oldhash (int i);
+extern NCURSES_EXPORT(void) _nc_reset_input (FILE *, char *);
 extern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot);
 extern NCURSES_EXPORT(void) _nc_scroll_optimize (void);
 extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, int);
@@ -2047,6 +2162,25 @@
 extern NCURSES_EXPORT(void) _nc_synchook (WINDOW *);
 extern NCURSES_EXPORT(void) _nc_trace_tries (TRIES *);
 
+#if NCURSES_EXT_NUMBERS
+extern NCURSES_EXPORT(const TERMTYPE2 *) _nc_fallback2 (const char *);
+#else
+#define _nc_fallback2(tp) _nc_fallback(tp)
+#endif
+
+extern NCURSES_EXPORT(void) _nc_copy_termtype(TERMTYPE *, const TERMTYPE *);
+
+#if NCURSES_EXT_NUMBERS
+extern NCURSES_EXPORT(void) _nc_copy_termtype2 (TERMTYPE2 *, const TERMTYPE2 *);
+extern NCURSES_EXPORT(void) _nc_export_termtype2(TERMTYPE *, const TERMTYPE2 *);
+#else
+#define _nc_copy_termtype2(dst,src) _nc_copy_termtype((dst),(src))
+#define _nc_export_termtype2(dst,src) /* nothing */
+#define _nc_free_termtype2(t) _nc_free_termtype(t)
+/* also... */
+#define _nc_read_entry2 _nc_read_entry
+#endif
+
 #if NO_LEAKS
 extern NCURSES_EXPORT(void) _nc_alloc_entry_leaks(void);
 extern NCURSES_EXPORT(void) _nc_captoinfo_leaks(void);
@@ -2054,9 +2188,11 @@
 extern NCURSES_EXPORT(void) _nc_comp_captab_leaks(void);
 extern NCURSES_EXPORT(void) _nc_comp_error_leaks(void);
 extern NCURSES_EXPORT(void) _nc_comp_scan_leaks(void);
+extern NCURSES_EXPORT(void) _nc_comp_userdefs_leaks(void);
 extern NCURSES_EXPORT(void) _nc_db_iterator_leaks(void);
 extern NCURSES_EXPORT(void) _nc_keyname_leaks(void);
 extern NCURSES_EXPORT(void) _nc_names_leaks(void);
+extern NCURSES_EXPORT(void) _nc_tgetent_leak(const TERMINAL *);
 extern NCURSES_EXPORT(void) _nc_tgetent_leaks(void);
 #endif
 
@@ -2096,11 +2232,10 @@
  */
 #if USE_WIDEC_SUPPORT
 
-#if defined(__MINGW32__)
+#if defined(_NC_WINDOWS) && !defined(_NC_MSC) && !defined(EXP_WIN32_DRIVER)
 /*
  * MinGW has wide-character functions, but they do not work correctly.
  */
-
 extern int __MINGW_NOTHROW _nc_wctomb(char *, wchar_t);
 #define wctomb(s,wc) _nc_wctomb(s,wc)
 #define wcrtomb(s,wc,n) _nc_wctomb(s,wc)
@@ -2111,19 +2246,25 @@
 extern int __MINGW_NOTHROW _nc_mblen(const char *, size_t);
 #define mblen(s,n) _nc_mblen(s, n)
 
-#endif /* __MINGW32__ */
+#endif /* _NC_WINDOWS && !_NC_MSC */
+
+#if defined(_NC_WINDOWS) || defined(_NC_MINGW)
+/* see wcwidth.c */
+extern NCURSES_EXPORT(int) mk_wcwidth(wchar_t);
+#define wcwidth(ucs) _nc_wcwidth(ucs)
+#endif
 
 #if HAVE_MBTOWC && HAVE_MBLEN
 #define reset_mbytes(state) IGNORE_RC(mblen(NULL, (size_t) 0)), IGNORE_RC(mbtowc(NULL, NULL, (size_t) 0))
 #define count_mbytes(buffer,length,state) mblen(buffer,length)
 #define check_mbytes(wch,buffer,length,state) \
-	(int) mbtowc(&wch, buffer, length)
+	(int) mbtowc(&(wch), buffer, length)
 #define state_unused
 #elif HAVE_MBRTOWC && HAVE_MBRLEN
 #define reset_mbytes(state) init_mb(state)
-#define count_mbytes(buffer,length,state) mbrlen(buffer,length,&state)
+#define count_mbytes(buffer,length,state) mbrlen(buffer,length,&(state))
 #define check_mbytes(wch,buffer,length,state) \
-	(int) mbrtowc(&wch, buffer, length, &state)
+	(int) mbrtowc(&(wch), buffer, length, &(state))
 #else
 make an error
 #endif
@@ -2142,7 +2283,7 @@
 
 #define USE_SETBUF_0 0
 
-#define NC_OUTPUT(sp) ((sp != 0) ? sp->_ofp : stdout)
+#define NC_OUTPUT(sp) ((sp != 0 && sp->_ofp != 0) ? sp->_ofp : stdout)
 
 /*
  * On systems with a broken linker, define 'SP' as a function to force the
@@ -2172,7 +2313,7 @@
 
 /*
  * We don't want to use the lines or columns capabilities internally, because
- * if the application is running multiple screens under X, it's quite possible
+ * if the application is running multiple screens under X, it is quite possible
  * they could all have type xterm but have different sizes!  So...
  */
 #define screen_lines(sp)        (sp)->_lines
@@ -2333,12 +2474,16 @@
 #define TINFO_MVCUR             NCURSES_SP_NAME(_nc_mvcur)
 #endif
 
+#if defined(EXP_WIN32_DRIVER)
+#include <nc_win32.h>
+#endif
+
 /*
  * Entrypoints using an extra parameter with the terminal driver.
  */
 #ifdef USE_TERM_DRIVER
 extern NCURSES_EXPORT(void)   _nc_get_screensize(SCREEN *, TERMINAL *, int *, int *);
-extern NCURSES_EXPORT(int)    _nc_setupterm_ex(TERMINAL **, NCURSES_CONST char *, int , int *, int);
+extern NCURSES_EXPORT(int)    _nc_setupterm_ex(TERMINAL **, const char *, int , int *, int);
 #define TINFO_GET_SIZE(sp, tp, lp, cp) \
 	_nc_get_screensize(sp, tp, lp, cp)
 #define TINFO_SET_CURTERM(sp, tp) \
@@ -2355,6 +2500,9 @@
 	_nc_setupterm(name, fd, err, reuse)
 #endif /* !USE_TERM_DRIVER */
 
+#ifdef EXP_WIN32_DRIVER
+extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER;
+#else
 #ifdef USE_TERM_DRIVER
 #if defined(USE_WIN32CON_DRIVER)
 #include <nc_mingw.h>
@@ -2368,30 +2516,47 @@
 extern NCURSES_EXPORT(int) _nc_mingw_testmouse(
     SCREEN * sp,
     HANDLE fd,
-    int delay);
+    int delay EVENTLIST_2nd(_nc_eventlist*));
 #else
 #endif
 extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER;
-#endif
+#endif /* USE_TERM_DRIVER */
+#endif /* EXP_WIN32_DRIVER */
 
-#if defined(USE_TERM_DRIVER) && defined(USE_WIN32CON_DRIVER)
+#if defined(USE_TERM_DRIVER) && defined(EXP_WIN32_DRIVER)
+#define NC_ISATTY(fd) (0 != _nc_console_isatty(fd))
+#elif defined(USE_TERM_DRIVER) && defined(USE_WIN32CON_DRIVER)
 #define NC_ISATTY(fd) _nc_mingw_isatty(fd)
 #else
 #define NC_ISATTY(fd) isatty(fd)
 #endif
 
+/*
+ * Perhaps not "real" but possibly not "fake".
+ */
+#define IsRealTty(fd,value) \
+	(NC_ISATTY(fd) \
+	 && (value = ttyname(fd)) != NULL \
+	 && strncmp(value, "/dev/pts/", 9))
+
 #ifdef USE_TERM_DRIVER
 #  define IsTermInfo(sp)       ((TCBOf(sp) != 0) && ((TCBOf(sp)->drv->isTerminfo)))
 #  define HasTInfoTerminal(sp) ((0 != TerminalOf(sp)) && IsTermInfo(sp))
-#  if defined(USE_WIN32CON_DRIVER)
-#    define IsTermInfoOnConsole(sp) (IsTermInfo(sp)&&_nc_mingw_isconsole(TerminalOf(sp)->Filedes))
-#else
+#  if defined(EXP_WIN32_DRIVER)
+#    define IsTermInfoOnConsole(sp) (IsTermInfo(sp) && _nc_console_test(TerminalOf(sp)->Filedes))
+#  elif defined(USE_WIN32CON_DRIVER)
+#    define IsTermInfoOnConsole(sp) (IsTermInfo(sp) && _nc_mingw_isconsole(TerminalOf(sp)->Filedes))
+#  else
 #    define IsTermInfoOnConsole(sp) FALSE
 #  endif
 #else
 #  define IsTermInfo(sp)       TRUE
 #  define HasTInfoTerminal(sp) (0 != TerminalOf(sp))
-#  define IsTermInfoOnConsole(sp) FALSE
+#  if defined(EXP_WIN32_DRIVER)
+#    define IsTermInfoOnConsole(sp) _nc_console_test(TerminalOf(sp)->Filedes)
+#  else
+#    define IsTermInfoOnConsole(sp) FALSE
+#  endif
 #endif
 
 #define IsValidTIScreen(sp)  (HasTInfoTerminal(sp))
@@ -2423,7 +2588,6 @@
 extern NCURSES_EXPORT(bool)     NCURSES_SP_NAME(_nc_reset_colors)(SCREEN*);
 extern NCURSES_EXPORT(char *)   NCURSES_SP_NAME(_nc_printf_string)(SCREEN*, const char *, va_list);
 extern NCURSES_EXPORT(chtype)   NCURSES_SP_NAME(_nc_acs_char)(SCREEN*,int);
-extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_curs_set)(SCREEN*,int);
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_get_tty_mode)(SCREEN*,TTY*);
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_mcprint)(SCREEN*,char*, int);
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_msec_cost)(SCREEN*, const char *, int);
@@ -2432,23 +2596,15 @@
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_putchar)(SCREEN*, int);
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_putp)(SCREEN*, const char *, const char*);
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_putp_flush)(SCREEN*, const char *, const char *);
-extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_resetty)(SCREEN*);
-extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_resize_term)(SCREEN*,int,int);
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_ripoffline)(SCREEN*, int, int (*)(WINDOW *,int));
-extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_savetty)(SCREEN*);
-extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_scr_init)(SCREEN*,const char*);
-extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_scr_restore)(SCREEN*, const char*);
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_scrolln)(SCREEN*, int, int, int, int);
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_set_tty_mode)(SCREEN*, TTY*);
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_setupscreen)(SCREEN**, int, int, FILE *, int, int);
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_tgetent)(SCREEN*,char*,const char *);
-extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_tigetnum)(SCREEN*,NCURSES_CONST char*);
-extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_vid_attr)(SCREEN *, attr_t, NCURSES_COLOR_T, void *);
-extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_vidputs)(SCREEN*,chtype,int(*) (SCREEN*, int));
 extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_do_color)(SCREEN*, int, int, int, NCURSES_SP_OUTC);
 extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_do_xmc_glitch)(SCREEN*, attr_t);
 extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_flush)(SCREEN*);
-extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int) GCC_NORETURN;
+extern GCC_NORETURN NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int);
 extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_freeall)(SCREEN*);
 extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_hash_map)(SCREEN*);
 extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_init_acs)(SCREEN*);
@@ -2494,8 +2650,8 @@
 #endif
 
 #ifdef EXP_XTERM_1005
-NCURSES_EXPORT(int) _nc_conv_to_utf8(unsigned char *, unsigned, unsigned);
-NCURSES_EXPORT(int) _nc_conv_to_utf32(unsigned *, const char *, unsigned);
+extern NCURSES_EXPORT(int) _nc_conv_to_utf8(unsigned char *, unsigned, unsigned);
+extern NCURSES_EXPORT(int) _nc_conv_to_utf32(unsigned *, const char *, unsigned);
 #endif
 
 #ifdef __cplusplus
diff --git a/ncurses/expanded.c b/ncurses/expanded.c
deleted file mode 100644
index de27cd7..0000000
--- a/ncurses/expanded.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* generated by MKexpanded.sh */
-#define NEED_NCURSES_CH_T 1
-#include <curses.priv.h>
-
-#ifndef CUR
-#define CUR SP_TERMTYPE
-#endif
-
-#if NCURSES_EXPANDED
- void
-_nc_toggle_attr_on (attr_t *S, attr_t at)
-{
- { if (((int)((((unsigned long)(at) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))) >> 8))) > 0) { (*S) = ((*S) & ALL_BUT_COLOR) | (attr_t) (at); } else { (*S) |= (attr_t) (at); } ;};
-}
-
- void
-_nc_toggle_attr_off (attr_t *S, attr_t at)
-{
- { if (((int)((((unsigned long)(at) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))) >> 8))) > 0) { (*S) &= ~(at|((chtype)((((1U) << 8) - 1U)) << ((0) + 8))); } else { (*S) &= ~(at); } ;};
-}
-
- int
-_nc_DelCharCost_sp (SCREEN *sp, int count)
-{
- return ((cur_term->type. Strings[105] != 0) ? sp->_dch_cost : ((cur_term->type. Strings[21] != 0) ? (sp->_dch1_cost * count) : 1000000));
-}
-
- int
-_nc_InsCharCost_sp (SCREEN *sp, int count)
-{
- return ((cur_term->type. Strings[108] != 0) ? sp->_ich_cost : ((cur_term->type. Strings[31] && cur_term->type. Strings[42]) ? sp->_smir_cost + sp->_rmir_cost + (sp->_ip_cost * count) : ((cur_term->type. Strings[52] != 0) ? ((sp->_ich1_cost + sp->_ip_cost) * count) : 1000000)));
-}
-
- void
-_nc_UpdateAttrs_sp (SCREEN *sp, chtype c)
-{
- if (!(((chtype)((*((sp)->_current_attr))) & (chtype)((chtype)((~(1U - 1U))) << ((0) + 8))) == ((chtype)(c) & (chtype)((chtype)((~(1U - 1U))) << ((0) + 8))))) { vidputs_sp(sp, ((chtype)(c) & (chtype)((chtype)((~(1U - 1U))) << ((0) + 8))), _nc_outch_sp); };
-}
-
-#if NCURSES_SP_FUNCS
- int
-_nc_DelCharCost (int count)
-{
- return _nc_DelCharCost_sp (SP, count);
-}
-
- int
-_nc_InsCharCost (int count)
-{
- return _nc_InsCharCost_sp(SP, count);
-}
-
- void
-_nc_UpdateAttrs (chtype c)
-{
- _nc_UpdateAttrs_sp(SP,c);
-}
-#endif
-#else /* ! NCURSES_EXPANDED */
-NCURSES_EXPORT(void) _nc_expanded (void) { }
-#endif /* NCURSES_EXPANDED */
diff --git a/ncurses/fallback.c b/ncurses/fallback.c
deleted file mode 100644
index 71daf2c..0000000
--- a/ncurses/fallback.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * DO NOT EDIT THIS FILE BY HAND!  It is generated by MKfallback.sh.
- */
-
-#include <curses.priv.h>
-
-NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *name GCC_UNUSED)
-{
-	/* the fallback list is empty */
-	return((TERMTYPE *)0);
-}
diff --git a/ncurses/fifo_defs.h b/ncurses/fifo_defs.h
index c0c795a..ab9266d 100644
--- a/ncurses/fifo_defs.h
+++ b/ncurses/fifo_defs.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2012,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,7 +35,7 @@
 /*
  * Common macros for lib_getch.c, lib_ungetch.c
  *
- * $Id: fifo_defs.h,v 1.7 2012/08/04 15:59:17 tom Exp $
+ * $Id: fifo_defs.h,v 1.9 2020/02/02 23:34:34 tom Exp $
  */
 
 #ifndef FIFO_DEFS_H
@@ -82,6 +83,4 @@
 #define cooked_key_in_fifo()	((head >= 0) && (peek != head))
 #define raw_key_in_fifo()	((head >= 0) && (peek != tail))
 
-#undef HIDE_EINTR
-
 #endif /* FIFO_DEFS_H */
diff --git a/ncurses/init_keytry.h b/ncurses/init_keytry.h
deleted file mode 100644
index c89150d..0000000
--- a/ncurses/init_keytry.h
+++ /dev/null
@@ -1,162 +0,0 @@
-#ifndef NCU_KEYS_H
-#define NCU_KEYS_H 1
-
-/* This file was generated by MAKE_KEYS */
-
-#if BROKEN_LINKER
-static
-#endif
-const struct tinfo_fkeys _nc_tinfo_fkeys[] = {
-	{  139, KEY_A1           },	/* key_a1 */
-	{  140, KEY_A3           },	/* key_a3 */
-	{  141, KEY_B2           },	/* key_b2 */
-	{   55, KEY_BACKSPACE    },	/* key_backspace */
-	{  158, KEY_BEG          },	/* key_beg */
-	{  148, KEY_BTAB         },	/* key_btab */
-	{  142, KEY_C1           },	/* key_c1 */
-	{  143, KEY_C3           },	/* key_c3 */
-	{  159, KEY_CANCEL       },	/* key_cancel */
-	{   56, KEY_CATAB        },	/* key_catab */
-	{   57, KEY_CLEAR        },	/* key_clear */
-	{  160, KEY_CLOSE        },	/* key_close */
-	{  161, KEY_COMMAND      },	/* key_command */
-	{  162, KEY_COPY         },	/* key_copy */
-	{  163, KEY_CREATE       },	/* key_create */
-	{   58, KEY_CTAB         },	/* key_ctab */
-	{   59, KEY_DC           },	/* key_dc */
-	{   60, KEY_DL           },	/* key_dl */
-	{   61, KEY_DOWN         },	/* key_down */
-	{   62, KEY_EIC          },	/* key_eic */
-	{  164, KEY_END          },	/* key_end */
-	{  165, KEY_ENTER        },	/* key_enter */
-	{   63, KEY_EOL          },	/* key_eol */
-	{   64, KEY_EOS          },	/* key_eos */
-	{  166, KEY_EXIT         },	/* key_exit */
-	{   65, KEY_F(0)         },	/* key_f0 */
-	{   67, KEY_F(10)        },	/* key_f10 */
-	{  216, KEY_F(11)        },	/* key_f11 */
-	{  217, KEY_F(12)        },	/* key_f12 */
-	{  218, KEY_F(13)        },	/* key_f13 */
-	{  219, KEY_F(14)        },	/* key_f14 */
-	{  220, KEY_F(15)        },	/* key_f15 */
-	{  221, KEY_F(16)        },	/* key_f16 */
-	{  222, KEY_F(17)        },	/* key_f17 */
-	{  223, KEY_F(18)        },	/* key_f18 */
-	{  224, KEY_F(19)        },	/* key_f19 */
-	{   66, KEY_F(1)         },	/* key_f1 */
-	{  225, KEY_F(20)        },	/* key_f20 */
-	{  226, KEY_F(21)        },	/* key_f21 */
-	{  227, KEY_F(22)        },	/* key_f22 */
-	{  228, KEY_F(23)        },	/* key_f23 */
-	{  229, KEY_F(24)        },	/* key_f24 */
-	{  230, KEY_F(25)        },	/* key_f25 */
-	{  231, KEY_F(26)        },	/* key_f26 */
-	{  232, KEY_F(27)        },	/* key_f27 */
-	{  233, KEY_F(28)        },	/* key_f28 */
-	{  234, KEY_F(29)        },	/* key_f29 */
-	{   68, KEY_F(2)         },	/* key_f2 */
-	{  235, KEY_F(30)        },	/* key_f30 */
-	{  236, KEY_F(31)        },	/* key_f31 */
-	{  237, KEY_F(32)        },	/* key_f32 */
-	{  238, KEY_F(33)        },	/* key_f33 */
-	{  239, KEY_F(34)        },	/* key_f34 */
-	{  240, KEY_F(35)        },	/* key_f35 */
-	{  241, KEY_F(36)        },	/* key_f36 */
-	{  242, KEY_F(37)        },	/* key_f37 */
-	{  243, KEY_F(38)        },	/* key_f38 */
-	{  244, KEY_F(39)        },	/* key_f39 */
-	{   69, KEY_F(3)         },	/* key_f3 */
-	{  245, KEY_F(40)        },	/* key_f40 */
-	{  246, KEY_F(41)        },	/* key_f41 */
-	{  247, KEY_F(42)        },	/* key_f42 */
-	{  248, KEY_F(43)        },	/* key_f43 */
-	{  249, KEY_F(44)        },	/* key_f44 */
-	{  250, KEY_F(45)        },	/* key_f45 */
-	{  251, KEY_F(46)        },	/* key_f46 */
-	{  252, KEY_F(47)        },	/* key_f47 */
-	{  253, KEY_F(48)        },	/* key_f48 */
-	{  254, KEY_F(49)        },	/* key_f49 */
-	{   70, KEY_F(4)         },	/* key_f4 */
-	{  255, KEY_F(50)        },	/* key_f50 */
-	{  256, KEY_F(51)        },	/* key_f51 */
-	{  257, KEY_F(52)        },	/* key_f52 */
-	{  258, KEY_F(53)        },	/* key_f53 */
-	{  259, KEY_F(54)        },	/* key_f54 */
-	{  260, KEY_F(55)        },	/* key_f55 */
-	{  261, KEY_F(56)        },	/* key_f56 */
-	{  262, KEY_F(57)        },	/* key_f57 */
-	{  263, KEY_F(58)        },	/* key_f58 */
-	{  264, KEY_F(59)        },	/* key_f59 */
-	{   71, KEY_F(5)         },	/* key_f5 */
-	{  265, KEY_F(60)        },	/* key_f60 */
-	{  266, KEY_F(61)        },	/* key_f61 */
-	{  267, KEY_F(62)        },	/* key_f62 */
-	{  268, KEY_F(63)        },	/* key_f63 */
-	{   72, KEY_F(6)         },	/* key_f6 */
-	{   73, KEY_F(7)         },	/* key_f7 */
-	{   74, KEY_F(8)         },	/* key_f8 */
-	{   75, KEY_F(9)         },	/* key_f9 */
-	{  167, KEY_FIND         },	/* key_find */
-	{  168, KEY_HELP         },	/* key_help */
-	{   76, KEY_HOME         },	/* key_home */
-	{   77, KEY_IC           },	/* key_ic */
-	{   78, KEY_IL           },	/* key_il */
-	{   79, KEY_LEFT         },	/* key_left */
-	{   80, KEY_LL           },	/* key_ll */
-	{  169, KEY_MARK         },	/* key_mark */
-	{  170, KEY_MESSAGE      },	/* key_message */
-	{  355, KEY_MOUSE        },	/* key_mouse */
-	{  171, KEY_MOVE         },	/* key_move */
-	{  172, KEY_NEXT         },	/* key_next */
-	{   81, KEY_NPAGE        },	/* key_npage */
-	{  173, KEY_OPEN         },	/* key_open */
-	{  174, KEY_OPTIONS      },	/* key_options */
-	{   82, KEY_PPAGE        },	/* key_ppage */
-	{  175, KEY_PREVIOUS     },	/* key_previous */
-	{  176, KEY_PRINT        },	/* key_print */
-	{  177, KEY_REDO         },	/* key_redo */
-	{  178, KEY_REFERENCE    },	/* key_reference */
-	{  179, KEY_REFRESH      },	/* key_refresh */
-	{  180, KEY_REPLACE      },	/* key_replace */
-	{  181, KEY_RESTART      },	/* key_restart */
-	{  182, KEY_RESUME       },	/* key_resume */
-	{   83, KEY_RIGHT        },	/* key_right */
-	{  183, KEY_SAVE         },	/* key_save */
-	{  186, KEY_SBEG         },	/* key_sbeg */
-	{  187, KEY_SCANCEL      },	/* key_scancel */
-	{  188, KEY_SCOMMAND     },	/* key_scommand */
-	{  189, KEY_SCOPY        },	/* key_scopy */
-	{  190, KEY_SCREATE      },	/* key_screate */
-	{  191, KEY_SDC          },	/* key_sdc */
-	{  192, KEY_SDL          },	/* key_sdl */
-	{  193, KEY_SELECT       },	/* key_select */
-	{  194, KEY_SEND         },	/* key_send */
-	{  195, KEY_SEOL         },	/* key_seol */
-	{  196, KEY_SEXIT        },	/* key_sexit */
-	{  197, KEY_SFIND        },	/* key_sfind */
-	{   84, KEY_SF           },	/* key_sf */
-	{  198, KEY_SHELP        },	/* key_shelp */
-	{  199, KEY_SHOME        },	/* key_shome */
-	{  200, KEY_SIC          },	/* key_sic */
-	{  201, KEY_SLEFT        },	/* key_sleft */
-	{  202, KEY_SMESSAGE     },	/* key_smessage */
-	{  203, KEY_SMOVE        },	/* key_smove */
-	{  204, KEY_SNEXT        },	/* key_snext */
-	{  205, KEY_SOPTIONS     },	/* key_soptions */
-	{  206, KEY_SPREVIOUS    },	/* key_sprevious */
-	{  207, KEY_SPRINT       },	/* key_sprint */
-	{  208, KEY_SREDO        },	/* key_sredo */
-	{  209, KEY_SREPLACE     },	/* key_sreplace */
-	{  210, KEY_SRIGHT       },	/* key_sright */
-	{   85, KEY_SR           },	/* key_sr */
-	{  211, KEY_SRSUME       },	/* key_srsume */
-	{  212, KEY_SSAVE        },	/* key_ssave */
-	{  213, KEY_SSUSPEND     },	/* key_ssuspend */
-	{   86, KEY_STAB         },	/* key_stab */
-	{  214, KEY_SUNDO        },	/* key_sundo */
-	{  184, KEY_SUSPEND      },	/* key_suspend */
-	{  185, KEY_UNDO         },	/* key_undo */
-	{   87, KEY_UP           },	/* key_up */
-	{ 0, 0} };
-
-#endif /* NCU_KEYS_H */
diff --git a/ncurses/keys.list b/ncurses/keys.list
deleted file mode 100644
index 1bca98f..0000000
--- a/ncurses/keys.list
+++ /dev/null
@@ -1,155 +0,0 @@
-KEY_A1	key_a1
-KEY_A3	key_a3
-KEY_B2	key_b2
-KEY_BACKSPACE	key_backspace
-KEY_BEG	key_beg
-KEY_BREAK
-KEY_BTAB	key_btab
-KEY_C1	key_c1
-KEY_C3	key_c3
-KEY_CANCEL	key_cancel
-KEY_CATAB	key_catab
-KEY_CLEAR	key_clear
-KEY_CLOSE	key_close
-KEY_COMMAND	key_command
-KEY_COPY	key_copy
-KEY_CREATE	key_create
-KEY_CTAB	key_ctab
-KEY_DC	key_dc
-KEY_DL	key_dl
-KEY_DOWN	key_down
-KEY_EIC	key_eic
-KEY_END	key_end
-KEY_ENTER	key_enter
-KEY_EOL	key_eol
-KEY_EOS	key_eos
-KEY_EXIT	key_exit
-KEY_F(0)	key_f0
-KEY_F(10)	key_f10
-KEY_F(11)	key_f11
-KEY_F(12)	key_f12
-KEY_F(13)	key_f13
-KEY_F(14)	key_f14
-KEY_F(15)	key_f15
-KEY_F(16)	key_f16
-KEY_F(17)	key_f17
-KEY_F(18)	key_f18
-KEY_F(19)	key_f19
-KEY_F(1)	key_f1
-KEY_F(20)	key_f20
-KEY_F(21)	key_f21
-KEY_F(22)	key_f22
-KEY_F(23)	key_f23
-KEY_F(24)	key_f24
-KEY_F(25)	key_f25
-KEY_F(26)	key_f26
-KEY_F(27)	key_f27
-KEY_F(28)	key_f28
-KEY_F(29)	key_f29
-KEY_F(2)	key_f2
-KEY_F(30)	key_f30
-KEY_F(31)	key_f31
-KEY_F(32)	key_f32
-KEY_F(33)	key_f33
-KEY_F(34)	key_f34
-KEY_F(35)	key_f35
-KEY_F(36)	key_f36
-KEY_F(37)	key_f37
-KEY_F(38)	key_f38
-KEY_F(39)	key_f39
-KEY_F(3)	key_f3
-KEY_F(40)	key_f40
-KEY_F(41)	key_f41
-KEY_F(42)	key_f42
-KEY_F(43)	key_f43
-KEY_F(44)	key_f44
-KEY_F(45)	key_f45
-KEY_F(46)	key_f46
-KEY_F(47)	key_f47
-KEY_F(48)	key_f48
-KEY_F(49)	key_f49
-KEY_F(4)	key_f4
-KEY_F(50)	key_f50
-KEY_F(51)	key_f51
-KEY_F(52)	key_f52
-KEY_F(53)	key_f53
-KEY_F(54)	key_f54
-KEY_F(55)	key_f55
-KEY_F(56)	key_f56
-KEY_F(57)	key_f57
-KEY_F(58)	key_f58
-KEY_F(59)	key_f59
-KEY_F(5)	key_f5
-KEY_F(60)	key_f60
-KEY_F(61)	key_f61
-KEY_F(62)	key_f62
-KEY_F(63)	key_f63
-KEY_F(6)	key_f6
-KEY_F(7)	key_f7
-KEY_F(8)	key_f8
-KEY_F(9)	key_f9
-KEY_FIND	key_find
-KEY_HELP	key_help
-KEY_HOME	key_home
-KEY_IC	key_ic
-KEY_IL	key_il
-KEY_LEFT	key_left
-KEY_LL	key_ll
-KEY_MARK	key_mark
-KEY_MESSAGE	key_message
-KEY_MOUSE	key_mouse
-KEY_MOVE	key_move
-KEY_NEXT	key_next
-KEY_NPAGE	key_npage
-KEY_OPEN	key_open
-KEY_OPTIONS	key_options
-KEY_PPAGE	key_ppage
-KEY_PREVIOUS	key_previous
-KEY_PRINT	key_print
-KEY_REDO	key_redo
-KEY_REFERENCE	key_reference
-KEY_REFRESH	key_refresh
-KEY_REPLACE	key_replace
-KEY_RESET
-KEY_RESIZE
-KEY_RESTART	key_restart
-KEY_RESUME	key_resume
-KEY_RIGHT	key_right
-KEY_SAVE	key_save
-KEY_SBEG	key_sbeg
-KEY_SCANCEL	key_scancel
-KEY_SCOMMAND	key_scommand
-KEY_SCOPY	key_scopy
-KEY_SCREATE	key_screate
-KEY_SDC	key_sdc
-KEY_SDL	key_sdl
-KEY_SELECT	key_select
-KEY_SEND	key_send
-KEY_SEOL	key_seol
-KEY_SEXIT	key_sexit
-KEY_SFIND	key_sfind
-KEY_SF	key_sf
-KEY_SHELP	key_shelp
-KEY_SHOME	key_shome
-KEY_SIC	key_sic
-KEY_SLEFT	key_sleft
-KEY_SMESSAGE	key_smessage
-KEY_SMOVE	key_smove
-KEY_SNEXT	key_snext
-KEY_SOPTIONS	key_soptions
-KEY_SPREVIOUS	key_sprevious
-KEY_SPRINT	key_sprint
-KEY_SREDO	key_sredo
-KEY_SREPLACE	key_sreplace
-KEY_SRESET
-KEY_SRIGHT	key_sright
-KEY_SR	key_sr
-KEY_SRSUME	key_srsume
-KEY_SSAVE	key_ssave
-KEY_SSUSPEND	key_ssuspend
-KEY_STAB	key_stab
-KEY_SUNDO	key_sundo
-KEY_SUSPEND	key_suspend
-KEY_UNDO	key_undo
-KEY_UP	key_up
-# These definitions were generated by ./tinfo/MKkeys_list.sh ../include/Caps
diff --git a/ncurses/lib_gen.c b/ncurses/lib_gen.c
deleted file mode 100644
index b06cdb8..0000000
--- a/ncurses/lib_gen.c
+++ /dev/null
@@ -1,864 +0,0 @@
-/*
- * DO NOT EDIT THIS FILE BY HAND!
- * It is generated by ./base/MKlib_gen.sh generated.
- *
- * This is a file of trivial functions generated from macro
- * definitions in curses.h to satisfy the XSI Curses requirement
- * that every macro also exist as a callable function.
- *
- * It will never be linked unless you call one of the entry
- * points with its normal macro definition disabled. In that
- * case, if you have no shared libraries, it will indirectly
- * pull most of the rest of the library into your link image.
- */
-#define NCURSES_ATTR_T int
-#include <ncurses_cfg.h>
-
-#undef NCURSES_NOMACROS /* _this_ file uses macros */
-
-#include <curses.priv.h>
-
-#undef vw_scanw
-#undef vwscanw
-
-#undef vw_printw
-#undef vwprintw
-
-NCURSES_EXPORT(int) (addch) (const chtype z)
-{
-	T((T_CALLED("addch(%s)"), _tracechtype2(0,z))); returnCode(waddch(stdscr,(z)));
-}
-
-
-NCURSES_EXPORT(int) (addchnstr) (const chtype * a1, int z)
-{
-	T((T_CALLED("addchnstr(%p,%d)"), (const void *)a1, z)); returnCode(waddchnstr(stdscr,(a1),(z)));
-}
-
-
-NCURSES_EXPORT(int) (addchstr) (const chtype * z)
-{
-	T((T_CALLED("addchstr(%p)"), (const void *)z)); returnCode(waddchnstr(stdscr,(z),-1));
-}
-
-
-NCURSES_EXPORT(int) (addnstr) (const char * a1, int z)
-{
-	T((T_CALLED("addnstr(%s,%d)"), _nc_visbuf2(0,a1), z)); returnCode(waddnstr(stdscr,(a1),(z)));
-}
-
-
-NCURSES_EXPORT(int) (addstr) (const char * z)
-{
-	T((T_CALLED("addstr(%s)"), _nc_visbuf2(0,z))); returnCode(waddnstr(stdscr,(z),-1));
-}
-
-
-NCURSES_EXPORT(int) (attroff) (int z)
-{
-	T((T_CALLED("attroff(%s)"), _traceattr2(0,(chtype)z))); returnCode(wattr_off(stdscr, (attr_t)((z)), ((void*)0)));
-}
-
-
-NCURSES_EXPORT(int) (attron) (int z)
-{
-	T((T_CALLED("attron(%s)"), _traceattr2(0,(chtype)z))); returnCode(wattr_on(stdscr, (attr_t)((z)), ((void*)0)));
-}
-
-
-NCURSES_EXPORT(int) (attrset) (int z)
-{
-	T((T_CALLED("attrset(%s)"), _traceattr2(0,(chtype)z))); returnIntAttr((attr_t)((stdscr) ? ((stdscr)->_attrs = (attr_t)((z)), (0)) : (-1)));
-}
-
-
-NCURSES_EXPORT(int) (attr_get) (attr_t * a1, short * a2, void * z)
-{
-	T((T_CALLED("attr_get(%p,%p,%p)"), (const void *)a1, (const void *)a2, (const void *)z)); returnCode(((void)((((a1)) != (void *)0) ? (*((a1)) = (stdscr) ? (stdscr)->_attrs : 0) : (0)), (void)((((a2)) != (void *)0) ? (*((a2)) = (short) ((stdscr) ? ((int)((((unsigned long)(((stdscr)->_attrs)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))) >> 8))) : 0)) : (0)), (0)));
-}
-
-
-NCURSES_EXPORT(int) (attr_off) (attr_t a1, void * z)
-{
-	T((T_CALLED("attr_off(%s,%p)"), _traceattr2(0,a1), (const void *)z)); returnCode(wattr_off(stdscr,(a1),(z)));
-}
-
-
-NCURSES_EXPORT(int) (attr_on) (attr_t a1, void * z)
-{
-	T((T_CALLED("attr_on(%s,%p)"), _traceattr2(0,a1), (const void *)z)); returnCode(wattr_on(stdscr,(a1),(z)));
-}
-
-
-NCURSES_EXPORT(int) (attr_set) (attr_t a1, short a2, void * z)
-{
-	T((T_CALLED("attr_set(%s,%#lx,%p)"), _traceattr2(0,a1), (long)a2, (const void *)z)); returnCode((((stdscr) ? ((stdscr)->_attrs = ((((a1)) & ~((chtype)((((1U) << 8) - 1U)) << ((0) + 8))) | (attr_t)((chtype)((((a2)))) << ((0) + 8)))) : (0)), (0)));
-}
-
-
-NCURSES_EXPORT(int) (bkgd) (chtype z)
-{
-	T((T_CALLED("bkgd(%s)"), _tracechtype2(0,z))); returnCode(wbkgd(stdscr,(z)));
-}
-
-
-NCURSES_EXPORT(void) (bkgdset) (chtype z)
-{
-	T((T_CALLED("bkgdset(%s)"), _tracechtype2(0,z))); wbkgdset(stdscr,(z));
-	returnVoid;
-}
-
-
-NCURSES_EXPORT(int) (border) (chtype a1, chtype a2, chtype a3, chtype a4, chtype a5, chtype a6, chtype a7, chtype z)
-{
-	T((T_CALLED("border(%s,%s,%s,%s,%s,%s,%s,%s)"), _tracechtype2(0,a1), _tracechtype2(1,a2), _tracechtype2(2,a3), _tracechtype2(3,a4), _tracechtype2(4,a5), _tracechtype2(5,a6), _tracechtype2(6,a7), _tracechtype2(7,z))); returnCode(wborder(stdscr, a1, a2, a3, a4, a5, a6, a7, z));
-}
-
-
-NCURSES_EXPORT(int) (box) (WINDOW * a1, chtype a2, chtype z)
-{
-	T((T_CALLED("box(%p,%s,%s)"), (const void *)a1, _tracechtype2(1,a2), _tracechtype2(2,z))); returnCode(wborder(a1, a2, a2, z, z, 0, 0, 0, 0));
-}
-
-
-NCURSES_EXPORT(int) (chgat) (int a1, attr_t a2, short a3, const void * z)
-{
-	T((T_CALLED("chgat(%d,%s,%#lx,%p)"), a1, _traceattr2(1,a2), (long)a3, (const void *)z)); returnCode(wchgat(stdscr,(a1),(a2),(a3),(z)));
-}
-
-
-NCURSES_EXPORT(int) (clear) (void)
-{
-	T((T_CALLED("clear()"))); returnCode(wclear(stdscr));
-}
-
-
-NCURSES_EXPORT(int) (clrtobot) (void)
-{
-	T((T_CALLED("clrtobot()"))); returnCode(wclrtobot(stdscr));
-}
-
-
-NCURSES_EXPORT(int) (clrtoeol) (void)
-{
-	T((T_CALLED("clrtoeol()"))); returnCode(wclrtoeol(stdscr));
-}
-
-
-NCURSES_EXPORT(int) (color_set) (short a1, void * z)
-{
-	T((T_CALLED("color_set(%#lx,%p)"), (long)a1, (const void *)z)); returnCode(wcolor_set(stdscr,(a1),(z)));
-}
-
-
-NCURSES_EXPORT(int) (COLOR_PAIR) (int z)
-{
-	T((T_CALLED("COLOR_PAIR(%d)"), z)); returnCode(((chtype)(((z))) << ((0) + 8)));
-}
-
-
-NCURSES_EXPORT(int) (delch) (void)
-{
-	T((T_CALLED("delch()"))); returnCode(wdelch(stdscr));
-}
-
-
-NCURSES_EXPORT(int) (deleteln) (void)
-{
-	T((T_CALLED("deleteln()"))); returnCode(winsdelln(stdscr,-1));
-}
-
-
-NCURSES_EXPORT(int) (echochar) (const chtype z)
-{
-	T((T_CALLED("echochar(%s)"), _tracechtype2(0,z))); returnCode(wechochar(stdscr,(z)));
-}
-
-
-NCURSES_EXPORT(int) (erase) (void)
-{
-	T((T_CALLED("erase()"))); returnCode(werase(stdscr));
-}
-
-
-NCURSES_EXPORT(chtype) (getbkgd) (WINDOW * z)
-{
-	T((T_CALLED("getbkgd(%p)"), (const void *)z)); returnChtype(((z) ? ((z)->_bkgd) : 0));
-}
-
-
-NCURSES_EXPORT(int) (getch) (void)
-{
-	T((T_CALLED("getch()"))); returnCode(wgetch(stdscr));
-}
-
-
-NCURSES_EXPORT(int) (getnstr) (char * a1, int z)
-{
-	T((T_CALLED("getnstr(%s,%d)"), _nc_visbuf2(0,a1), z)); returnCode(wgetnstr(stdscr, a1, (z)));
-}
-
-
-NCURSES_EXPORT(int) (getstr) (char * z)
-{
-	T((T_CALLED("getstr(%s)"), _nc_visbuf2(0,z))); returnCode(wgetnstr(stdscr, (z), -1));
-}
-
-
-NCURSES_EXPORT(int) (hline) (chtype a1, int z)
-{
-	T((T_CALLED("hline(%s,%d)"), _tracechtype2(0,a1), z)); returnCode(whline(stdscr, a1, (z)));
-}
-
-
-NCURSES_EXPORT(chtype) (inch) (void)
-{
-	T((T_CALLED("inch()"))); returnChtype(winch(stdscr));
-}
-
-
-NCURSES_EXPORT(int) (inchnstr) (chtype * a1, int z)
-{
-	T((T_CALLED("inchnstr(%p,%d)"), (const void *)a1, z)); returnCode(winchnstr(stdscr,(a1),(z)));
-}
-
-
-NCURSES_EXPORT(int) (inchstr) (chtype * z)
-{
-	T((T_CALLED("inchstr(%p)"), (const void *)z)); returnCode(winchnstr(stdscr, (z), -1));
-}
-
-
-NCURSES_EXPORT(int) (innstr) (char * a1, int z)
-{
-	return winnstr(stdscr,(a1),(z)) ;
-}
-
-
-NCURSES_EXPORT(int) (insch) (chtype z)
-{
-	T((T_CALLED("insch(%s)"), _tracechtype2(0,z))); returnCode(winsch(stdscr,(z)));
-}
-
-
-NCURSES_EXPORT(int) (insdelln) (int z)
-{
-	T((T_CALLED("insdelln(%d)"), z)); returnCode(winsdelln(stdscr,(z)));
-}
-
-
-NCURSES_EXPORT(int) (insertln) (void)
-{
-	T((T_CALLED("insertln()"))); returnCode(winsdelln(stdscr,1));
-}
-
-
-NCURSES_EXPORT(int) (insnstr) (const char * a1, int z)
-{
-	T((T_CALLED("insnstr(%s,%d)"), _nc_visbuf2(0,a1), z)); returnCode(winsnstr(stdscr,(a1),(z)));
-}
-
-
-NCURSES_EXPORT(int) (insstr) (const char * z)
-{
-	T((T_CALLED("insstr(%s)"), _nc_visbuf2(0,z))); returnCode(winsnstr(stdscr, (z), -1));
-}
-
-
-NCURSES_EXPORT(int) (instr) (char * z)
-{
-	T((T_CALLED("instr(%s)"), _nc_visbuf2(0,z))); returnCode(winnstr(stdscr, (z), -1));
-}
-
-
-NCURSES_EXPORT(int) (move) (int a1, int z)
-{
-	T((T_CALLED("move(%d,%d)"), a1, z)); returnCode(wmove(stdscr,(a1),(z)));
-}
-
-
-NCURSES_EXPORT(int) (mvaddch) (int a1, int a2, const chtype z)
-{
-	T((T_CALLED("mvaddch(%d,%d,%s)"), a1, a2, _tracechtype2(2,z))); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : waddch((stdscr),((z)))));
-}
-
-
-NCURSES_EXPORT(int) (mvaddchnstr) (int a1, int a2, const chtype * a3, int z)
-{
-	T((T_CALLED("mvaddchnstr(%d,%d,%p,%d)"), a1, a2, (const void *)a3, z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : waddchnstr((stdscr),((a3)),((z)))));
-}
-
-
-NCURSES_EXPORT(int) (mvaddchstr) (int a1, int a2, const chtype * z)
-{
-	T((T_CALLED("mvaddchstr(%d,%d,%p)"), a1, a2, (const void *)z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : waddchnstr((stdscr),((z)),-1)));
-}
-
-
-NCURSES_EXPORT(int) (mvaddnstr) (int a1, int a2, const char * a3, int z)
-{
-	T((T_CALLED("mvaddnstr(%d,%d,%s,%d)"), a1, a2, _nc_visbuf2(2,a3), z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : waddnstr((stdscr),((a3)),((z)))));
-}
-
-
-NCURSES_EXPORT(int) (mvaddstr) (int a1, int a2, const char * z)
-{
-	T((T_CALLED("mvaddstr(%d,%d,%s)"), a1, a2, _nc_visbuf2(2,z))); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : waddnstr((stdscr),((z)),-1)));
-}
-
-
-NCURSES_EXPORT(int) (mvchgat) (int a1, int a2, int a3, attr_t a4, short a5, const void * z)
-{
-	T((T_CALLED("mvchgat(%d,%d,%d,%s,%#lx,%p)"), a1, a2, a3, _traceattr2(3,a4), (long)a5, (const void *)z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : wchgat((stdscr),((a3)),((a4)),((a5)),((z)))));
-}
-
-
-NCURSES_EXPORT(int) (mvdelch) (int a1, int z)
-{
-	T((T_CALLED("mvdelch(%d,%d)"), a1, z)); returnCode((wmove((stdscr),((a1)),((z))) == (-1) ? (-1) : wdelch(stdscr)));
-}
-
-
-NCURSES_EXPORT(int) (mvgetch) (int a1, int z)
-{
-	T((T_CALLED("mvgetch(%d,%d)"), a1, z)); returnCode((wmove((stdscr),((a1)),((z))) == (-1) ? (-1) : wgetch(stdscr)));
-}
-
-
-NCURSES_EXPORT(int) (mvgetnstr) (int a1, int a2, char * a3, int z)
-{
-	T((T_CALLED("mvgetnstr(%d,%d,%s,%d)"), a1, a2, _nc_visbuf2(2,a3), z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : wgetnstr((stdscr),((a3)),((z)))));
-}
-
-
-NCURSES_EXPORT(int) (mvgetstr) (int a1, int a2, char * z)
-{
-	T((T_CALLED("mvgetstr(%d,%d,%s)"), a1, a2, _nc_visbuf2(2,z))); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : wgetnstr((stdscr), ((z)), -1)));
-}
-
-
-NCURSES_EXPORT(int) (mvhline) (int a1, int a2, chtype a3, int z)
-{
-	T((T_CALLED("mvhline(%d,%d,%s,%d)"), a1, a2, _tracechtype2(2,a3), z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : whline((stdscr),((a3)),((z)))));
-}
-
-
-NCURSES_EXPORT(chtype) (mvinch) (int a1, int z)
-{
-	T((T_CALLED("mvinch(%d,%d)"), a1, z)); returnChtype((wmove((stdscr),((a1)),((z))) == (-1) ? (chtype)((-1)) : winch(stdscr)));
-}
-
-
-NCURSES_EXPORT(int) (mvinchnstr) (int a1, int a2, chtype * a3, int z)
-{
-	T((T_CALLED("mvinchnstr(%d,%d,%p,%d)"), a1, a2, (const void *)a3, z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : winchnstr((stdscr),((a3)),((z)))));
-}
-
-
-NCURSES_EXPORT(int) (mvinchstr) (int a1, int a2, chtype * z)
-{
-	T((T_CALLED("mvinchstr(%d,%d,%p)"), a1, a2, (const void *)z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : winchnstr((stdscr), ((z)), -1)));
-}
-
-
-NCURSES_EXPORT(int) (mvinnstr) (int a1, int a2, char * a3, int z)
-{
-	return (wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : winnstr((stdscr),((a3)),((z)))) ;
-}
-
-
-NCURSES_EXPORT(int) (mvinsch) (int a1, int a2, chtype z)
-{
-	T((T_CALLED("mvinsch(%d,%d,%s)"), a1, a2, _tracechtype2(2,z))); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : winsch((stdscr),((z)))));
-}
-
-
-NCURSES_EXPORT(int) (mvinsnstr) (int a1, int a2, const char * a3, int z)
-{
-	T((T_CALLED("mvinsnstr(%d,%d,%s,%d)"), a1, a2, _nc_visbuf2(2,a3), z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : winsnstr((stdscr),((a3)),((z)))));
-}
-
-
-NCURSES_EXPORT(int) (mvinsstr) (int a1, int a2, const char * z)
-{
-	T((T_CALLED("mvinsstr(%d,%d,%s)"), a1, a2, _nc_visbuf2(2,z))); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : winsnstr((stdscr), ((z)), -1)));
-}
-
-
-NCURSES_EXPORT(int) (mvinstr) (int a1, int a2, char * z)
-{
-	T((T_CALLED("mvinstr(%d,%d,%s)"), a1, a2, _nc_visbuf2(2,z))); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : winnstr((stdscr), ((z)), -1)));
-}
-
-
-NCURSES_EXPORT(int) (mvvline) (int a1, int a2, chtype a3, int z)
-{
-	T((T_CALLED("mvvline(%d,%d,%s,%d)"), a1, a2, _tracechtype2(2,a3), z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : wvline((stdscr),((a3)),((z)))));
-}
-
-
-NCURSES_EXPORT(int) (mvwaddch) (WINDOW * a1, int a2, int a3, const chtype z)
-{
-	T((T_CALLED("mvwaddch(%p,%d,%d,%s)"), (const void *)a1, a2, a3, _tracechtype2(3,z))); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : waddch((a1),(z))));
-}
-
-
-NCURSES_EXPORT(int) (mvwaddchnstr) (WINDOW * a1, int a2, int a3, const chtype * a4, int z)
-{
-	T((T_CALLED("mvwaddchnstr(%p,%d,%d,%p,%d)"), (const void *)a1, a2, a3, (const void *)a4, z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : waddchnstr((a1),(a4),(z))));
-}
-
-
-NCURSES_EXPORT(int) (mvwaddchstr) (WINDOW * a1, int a2, int a3, const chtype * z)
-{
-	T((T_CALLED("mvwaddchstr(%p,%d,%d,%p)"), (const void *)a1, a2, a3, (const void *)z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : waddchnstr((a1),(z),-1)));
-}
-
-
-NCURSES_EXPORT(int) (mvwaddnstr) (WINDOW * a1, int a2, int a3, const char * a4, int z)
-{
-	T((T_CALLED("mvwaddnstr(%p,%d,%d,%s,%d)"), (const void *)a1, a2, a3, _nc_visbuf2(3,a4), z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : waddnstr((a1),(a4),(z))));
-}
-
-
-NCURSES_EXPORT(int) (mvwaddstr) (WINDOW * a1, int a2, int a3, const char * z)
-{
-	T((T_CALLED("mvwaddstr(%p,%d,%d,%s)"), (const void *)a1, a2, a3, _nc_visbuf2(3,z))); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : waddnstr((a1),(z),-1)));
-}
-
-
-NCURSES_EXPORT(int) (mvwchgat) (WINDOW * a1, int a2, int a3, int a4, attr_t a5, short a6, const void * z)
-{
-	T((T_CALLED("mvwchgat(%p,%d,%d,%d,%s,%#lx,%p)"), (const void *)a1, a2, a3, a4, _traceattr2(4,a5), (long)a6, (const void *)z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : wchgat((a1),(a4),(a5),(a6),(z))));
-}
-
-
-NCURSES_EXPORT(int) (mvwdelch) (WINDOW * a1, int a2, int z)
-{
-	T((T_CALLED("mvwdelch(%p,%d,%d)"), (const void *)a1, a2, z)); returnCode((wmove((a1),(a2),(z)) == (-1) ? (-1) : wdelch(a1)));
-}
-
-
-NCURSES_EXPORT(int) (mvwgetch) (WINDOW * a1, int a2, int z)
-{
-	T((T_CALLED("mvwgetch(%p,%d,%d)"), (const void *)a1, a2, z)); returnCode((wmove((a1),(a2),(z)) == (-1) ? (-1) : wgetch(a1)));
-}
-
-
-NCURSES_EXPORT(int) (mvwgetnstr) (WINDOW * a1, int a2, int a3, char * a4, int z)
-{
-	T((T_CALLED("mvwgetnstr(%p,%d,%d,%s,%d)"), (const void *)a1, a2, a3, _nc_visbuf2(3,a4), z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : wgetnstr((a1),(a4),(z))));
-}
-
-
-NCURSES_EXPORT(int) (mvwgetstr) (WINDOW * a1, int a2, int a3, char * z)
-{
-	T((T_CALLED("mvwgetstr(%p,%d,%d,%s)"), (const void *)a1, a2, a3, _nc_visbuf2(3,z))); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : wgetnstr((a1), (z), -1)));
-}
-
-
-NCURSES_EXPORT(int) (mvwhline) (WINDOW * a1, int a2, int a3, chtype a4, int z)
-{
-	T((T_CALLED("mvwhline(%p,%d,%d,%s,%d)"), (const void *)a1, a2, a3, _tracechtype2(3,a4), z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : whline((a1),(a4),(z))));
-}
-
-
-NCURSES_EXPORT(chtype) (mvwinch) (WINDOW * a1, int a2, int z)
-{
-	T((T_CALLED("mvwinch(%p,%d,%d)"), (const void *)a1, a2, z)); returnChtype((wmove((a1),(a2),(z)) == (-1) ? (chtype)((-1)) : winch(a1)));
-}
-
-
-NCURSES_EXPORT(int) (mvwinchnstr) (WINDOW * a1, int a2, int a3, chtype * a4, int z)
-{
-	T((T_CALLED("mvwinchnstr(%p,%d,%d,%p,%d)"), (const void *)a1, a2, a3, (const void *)a4, z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : winchnstr((a1),(a4),(z))));
-}
-
-
-NCURSES_EXPORT(int) (mvwinchstr) (WINDOW * a1, int a2, int a3, chtype * z)
-{
-	T((T_CALLED("mvwinchstr(%p,%d,%d,%p)"), (const void *)a1, a2, a3, (const void *)z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : winchnstr((a1), (z), -1)));
-}
-
-
-NCURSES_EXPORT(int) (mvwinnstr) (WINDOW * a1, int a2, int a3, char * a4, int z)
-{
-	return (wmove((a1),(a2),(a3)) == (-1) ? (-1) : winnstr((a1),(a4),(z))) ;
-}
-
-
-NCURSES_EXPORT(int) (mvwinsch) (WINDOW * a1, int a2, int a3, chtype z)
-{
-	T((T_CALLED("mvwinsch(%p,%d,%d,%s)"), (const void *)a1, a2, a3, _tracechtype2(3,z))); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : winsch((a1),(z))));
-}
-
-
-NCURSES_EXPORT(int) (mvwinsnstr) (WINDOW * a1, int a2, int a3, const char * a4, int z)
-{
-	T((T_CALLED("mvwinsnstr(%p,%d,%d,%s,%d)"), (const void *)a1, a2, a3, _nc_visbuf2(3,a4), z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : winsnstr((a1),(a4),(z))));
-}
-
-
-NCURSES_EXPORT(int) (mvwinsstr) (WINDOW * a1, int a2, int a3, const char * z)
-{
-	T((T_CALLED("mvwinsstr(%p,%d,%d,%s)"), (const void *)a1, a2, a3, _nc_visbuf2(3,z))); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : winsnstr((a1), (z), -1)));
-}
-
-
-NCURSES_EXPORT(int) (mvwinstr) (WINDOW * a1, int a2, int a3, char * z)
-{
-	T((T_CALLED("mvwinstr(%p,%d,%d,%s)"), (const void *)a1, a2, a3, _nc_visbuf2(3,z))); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : winnstr((a1), (z), -1)));
-}
-
-
-NCURSES_EXPORT(int) (mvwvline) (WINDOW * a1, int a2, int a3, chtype a4, int z)
-{
-	T((T_CALLED("mvwvline(%p,%d,%d,%s,%d)"), (const void *)a1, a2, a3, _tracechtype2(3,a4), z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : wvline((a1),(a4),(z))));
-}
-
-
-NCURSES_EXPORT(int) (PAIR_NUMBER) (int z)
-{
-	T((T_CALLED("PAIR_NUMBER(%d)"), z)); returnCode(((int)((((unsigned long)((z)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))) >> 8))));
-}
-
-
-NCURSES_EXPORT(int) (redrawwin) (WINDOW * z)
-{
-	T((T_CALLED("redrawwin(%p)"), (const void *)z)); returnCode(wredrawln(z, 0, ((z) ? (z)->_maxy+1 : -1)));
-}
-
-
-NCURSES_EXPORT(int) (refresh) (void)
-{
-	T((T_CALLED("refresh()"))); returnCode(wrefresh(stdscr));
-}
-
-
-NCURSES_EXPORT(int) (scrl) (int z)
-{
-	T((T_CALLED("scrl(%d)"), z)); returnCode(wscrl(stdscr,(z)));
-}
-
-
-NCURSES_EXPORT(int) (scroll) (WINDOW * z)
-{
-	T((T_CALLED("scroll(%p)"), (const void *)z)); returnCode(wscrl(z,1));
-}
-
-
-NCURSES_EXPORT(int) (setscrreg) (int a1, int z)
-{
-	T((T_CALLED("setscrreg(%d,%d)"), a1, z)); returnCode(wsetscrreg(stdscr,(a1),(z)));
-}
-
-
-#if USE_WIDEC_SUPPORT
-NCURSES_EXPORT(int) (slk_attr_off) (const attr_t a1, void * z)
-{
-	T((T_CALLED("slk_attr_off(%s,%p)"), _traceattr2(0,a1), (const void *)z)); returnCode(((z) ? (-1) : slk_attroff(a1)));
-}
-#endif
-
-
-#if USE_WIDEC_SUPPORT
-NCURSES_EXPORT(int) (slk_attr_on) (attr_t a1, void * z)
-{
-	T((T_CALLED("slk_attr_on(%s,%p)"), _traceattr2(0,a1), (const void *)z)); returnCode(((z) ? (-1) : slk_attron(a1)));
-}
-#endif
-
-
-NCURSES_EXPORT(int) (standout) (void)
-{
-	T((T_CALLED("standout()"))); returnIntAttr((attr_t)(((stdscr) ? ((stdscr)->_attrs = (attr_t)(((chtype)((1U)) << ((8) + 8))), (0)) : (-1))));
-}
-
-
-NCURSES_EXPORT(int) (standend) (void)
-{
-	T((T_CALLED("standend()"))); returnIntAttr((attr_t)(((stdscr) ? ((stdscr)->_attrs = (attr_t)((1U - 1U)), (0)) : (-1))));
-}
-
-
-NCURSES_EXPORT(void) (timeout) (int z)
-{
-	T((T_CALLED("timeout(%d)"), z)); wtimeout(stdscr,(z));
-	returnVoid;
-}
-
-
-NCURSES_EXPORT(int) (touchline) (WINDOW * a1, int a2, int z)
-{
-	T((T_CALLED("touchline(%p,%d,%d)"), (const void *)a1, a2, z)); returnCode(wtouchln((a1), a2, z, 1));
-}
-
-
-NCURSES_EXPORT(int) (touchwin) (WINDOW * z)
-{
-	T((T_CALLED("touchwin(%p)"), (const void *)z)); returnCode(wtouchln((z), 0, ((z) ? ((z)->_maxy + 1) : (-1)), 1));
-}
-
-
-NCURSES_EXPORT(int) (untouchwin) (WINDOW * z)
-{
-	T((T_CALLED("untouchwin(%p)"), (const void *)z)); returnCode(wtouchln((z), 0, ((z) ? ((z)->_maxy + 1) : (-1)), 0));
-}
-
-
-NCURSES_EXPORT(int) (vline) (chtype a1, int z)
-{
-	T((T_CALLED("vline(%s,%d)"), _tracechtype2(0,a1), z)); returnCode(wvline(stdscr, a1, (z)));
-}
-
-
-NCURSES_EXPORT(int) (vw_printw) (WINDOW * a1, const char * a2, va_list z)
-{
-	T((T_CALLED("vw_printw(%p,%s,%s)"), (const void *)a1, _nc_visbuf2(1,a2), "va_list")); returnCode(vwprintw(a1, a2, z));
-}
-
-
-NCURSES_EXPORT(int) (vw_scanw) (WINDOW * a1, const char * a2, va_list z)
-{
-	T((T_CALLED("vw_scanw(%p,%s,%s)"), (const void *)a1, _nc_visbuf2(1,a2), "va_list")); returnCode(vwscanw(a1, a2, z));
-}
-
-
-NCURSES_EXPORT(int) (waddchstr) (WINDOW * a1, const chtype * z)
-{
-	T((T_CALLED("waddchstr(%p,%p)"), (const void *)a1, (const void *)z)); returnCode(waddchnstr(a1,z,-1));
-}
-
-
-NCURSES_EXPORT(int) (waddstr) (WINDOW * a1, const char * z)
-{
-	T((T_CALLED("waddstr(%p,%s)"), (const void *)a1, _nc_visbuf2(1,z))); returnCode(waddnstr(a1,z,-1));
-}
-
-
-NCURSES_EXPORT(int) (wattron) (WINDOW * a1, int z)
-{
-	T((T_CALLED("wattron(%p,%d)"), (const void *)a1, z)); returnCode(wattr_on(a1, (attr_t)(z), ((void*)0)));
-}
-
-
-NCURSES_EXPORT(int) (wattroff) (WINDOW * a1, int z)
-{
-	T((T_CALLED("wattroff(%p,%d)"), (const void *)a1, z)); returnCode(wattr_off(a1, (attr_t)(z), ((void*)0)));
-}
-
-
-NCURSES_EXPORT(int) (wattrset) (WINDOW * a1, int z)
-{
-	T((T_CALLED("wattrset(%p,%d)"), (const void *)a1, z)); returnIntAttr((attr_t)((a1) ? ((a1)->_attrs = (attr_t)(z), (0)) : (-1)));
-}
-
-
-NCURSES_EXPORT(int) (wattr_get) (WINDOW * a1, attr_t * a2, short * a3, void * z)
-{
-	T((T_CALLED("wattr_get(%p,%p,%p,%p)"), (const void *)a1, (const void *)a2, (const void *)a3, (const void *)z)); returnCode(((void)(((a2) != (void *)0) ? (*(a2) = (a1) ? (a1)->_attrs : 0) : (0)), (void)(((a3) != (void *)0) ? (*(a3) = (short) ((a1) ? ((int)((((unsigned long)(((a1)->_attrs)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))) >> 8))) : 0)) : (0)), (0)));
-}
-
-
-NCURSES_EXPORT(int) (wattr_set) (WINDOW * a1, attr_t a2, short a3, void * z)
-{
-	T((T_CALLED("wattr_set(%p,%s,%#lx,%p)"), (const void *)a1, _traceattr2(1,a2), (long)a3, (const void *)z)); returnCode((((a1) ? ((a1)->_attrs = (((a2) & ~((chtype)((((1U) << 8) - 1U)) << ((0) + 8))) | (attr_t)((chtype)(((a3))) << ((0) + 8)))) : (0)), (0)));
-}
-
-
-NCURSES_EXPORT(int) (wdeleteln) (WINDOW * z)
-{
-	T((T_CALLED("wdeleteln(%p)"), (const void *)z)); returnCode(winsdelln(z,-1));
-}
-
-
-NCURSES_EXPORT(int) (wgetstr) (WINDOW * a1, char * z)
-{
-	T((T_CALLED("wgetstr(%p,%s)"), (const void *)a1, _nc_visbuf2(1,z))); returnCode(wgetnstr(a1, z, -1));
-}
-
-
-NCURSES_EXPORT(int) (winchstr) (WINDOW * a1, chtype * z)
-{
-	T((T_CALLED("winchstr(%p,%p)"), (const void *)a1, (const void *)z)); returnCode(winchnstr(a1, z, -1));
-}
-
-
-NCURSES_EXPORT(int) (winsertln) (WINDOW * z)
-{
-	T((T_CALLED("winsertln(%p)"), (const void *)z)); returnCode(winsdelln(z,1));
-}
-
-
-NCURSES_EXPORT(int) (winsstr) (WINDOW * a1, const char * z)
-{
-	T((T_CALLED("winsstr(%p,%s)"), (const void *)a1, _nc_visbuf2(1,z))); returnCode(winsnstr(a1, z, -1));
-}
-
-
-NCURSES_EXPORT(int) (winstr) (WINDOW * a1, char * z)
-{
-	T((T_CALLED("winstr(%p,%s)"), (const void *)a1, _nc_visbuf2(1,z))); returnCode(winnstr(a1, z, -1));
-}
-
-
-NCURSES_EXPORT(int) (wstandout) (WINDOW * z)
-{
-	T((T_CALLED("wstandout(%p)"), (const void *)z)); returnIntAttr((attr_t)(((z) ? ((z)->_attrs = (attr_t)(((chtype)((1U)) << ((8) + 8))), (0)) : (-1))));
-}
-
-
-NCURSES_EXPORT(int) (wstandend) (WINDOW * z)
-{
-	T((T_CALLED("wstandend(%p)"), (const void *)z)); returnIntAttr((attr_t)(((z) ? ((z)->_attrs = (attr_t)((1U - 1U)), (0)) : (-1))));
-}
-
-
-NCURSES_EXPORT(int) (getattrs) (const WINDOW * z)
-{
-	T((T_CALLED("getattrs(%p)"), (const void *)z)); returnCode((int)((z) ? (z)->_attrs : (1U - 1U)));
-}
-
-
-NCURSES_EXPORT(int) (getcurx) (const WINDOW * z)
-{
-	T((T_CALLED("getcurx(%p)"), (const void *)z)); returnCode(((z) ? (z)->_curx : (-1)));
-}
-
-
-NCURSES_EXPORT(int) (getcury) (const WINDOW * z)
-{
-	T((T_CALLED("getcury(%p)"), (const void *)z)); returnCode(((z) ? (z)->_cury : (-1)));
-}
-
-
-NCURSES_EXPORT(int) (getbegx) (const WINDOW * z)
-{
-	T((T_CALLED("getbegx(%p)"), (const void *)z)); returnCode(((z) ? (z)->_begx : (-1)));
-}
-
-
-NCURSES_EXPORT(int) (getbegy) (const WINDOW * z)
-{
-	T((T_CALLED("getbegy(%p)"), (const void *)z)); returnCode(((z) ? (z)->_begy : (-1)));
-}
-
-
-NCURSES_EXPORT(int) (getmaxx) (const WINDOW * z)
-{
-	T((T_CALLED("getmaxx(%p)"), (const void *)z)); returnCode(((z) ? ((z)->_maxx + 1) : (-1)));
-}
-
-
-NCURSES_EXPORT(int) (getmaxy) (const WINDOW * z)
-{
-	T((T_CALLED("getmaxy(%p)"), (const void *)z)); returnCode(((z) ? ((z)->_maxy + 1) : (-1)));
-}
-
-
-NCURSES_EXPORT(int) (getparx) (const WINDOW * z)
-{
-	T((T_CALLED("getparx(%p)"), (const void *)z)); returnCode(((z) ? (z)->_parx : (-1)));
-}
-
-
-NCURSES_EXPORT(int) (getpary) (const WINDOW * z)
-{
-	T((T_CALLED("getpary(%p)"), (const void *)z)); returnCode(((z) ? (z)->_pary : (-1)));
-}
-
-
-NCURSES_EXPORT(WINDOW *) (wgetparent) (const WINDOW * z)
-{
-	T((T_CALLED("wgetparent(%p)"), (const void *)z)); returnWin(((z) ? (z)->_parent : 0));
-}
-
-
-NCURSES_EXPORT(NCURSES_BOOL) (is_cleared) (const WINDOW * z)
-{
-	T((T_CALLED("is_cleared(%p)"), (const void *)z)); returnBool(((z) ? (z)->_clear : 0));
-}
-
-
-NCURSES_EXPORT(NCURSES_BOOL) (is_idcok) (const WINDOW * z)
-{
-	T((T_CALLED("is_idcok(%p)"), (const void *)z)); returnBool(((z) ? (z)->_idcok : 0));
-}
-
-
-NCURSES_EXPORT(NCURSES_BOOL) (is_idlok) (const WINDOW * z)
-{
-	T((T_CALLED("is_idlok(%p)"), (const void *)z)); returnBool(((z) ? (z)->_idlok : 0));
-}
-
-
-NCURSES_EXPORT(NCURSES_BOOL) (is_immedok) (const WINDOW * z)
-{
-	T((T_CALLED("is_immedok(%p)"), (const void *)z)); returnBool(((z) ? (z)->_immed : 0));
-}
-
-
-NCURSES_EXPORT(NCURSES_BOOL) (is_keypad) (const WINDOW * z)
-{
-	T((T_CALLED("is_keypad(%p)"), (const void *)z)); returnBool(((z) ? (z)->_use_keypad : 0));
-}
-
-
-NCURSES_EXPORT(NCURSES_BOOL) (is_leaveok) (const WINDOW * z)
-{
-	T((T_CALLED("is_leaveok(%p)"), (const void *)z)); returnBool(((z) ? (z)->_leaveok : 0));
-}
-
-
-NCURSES_EXPORT(NCURSES_BOOL) (is_nodelay) (const WINDOW * z)
-{
-	T((T_CALLED("is_nodelay(%p)"), (const void *)z)); returnBool(((z) ? ((z)->_delay == 0) : 0));
-}
-
-
-NCURSES_EXPORT(NCURSES_BOOL) (is_notimeout) (const WINDOW * z)
-{
-	T((T_CALLED("is_notimeout(%p)"), (const void *)z)); returnBool(((z) ? (z)->_notimeout : 0));
-}
-
-
-NCURSES_EXPORT(NCURSES_BOOL) (is_pad) (const WINDOW * z)
-{
-	T((T_CALLED("is_pad(%p)"), (const void *)z)); returnBool(((z) ? ((z)->_flags & 0x10) != 0 : 0));
-}
-
-
-NCURSES_EXPORT(NCURSES_BOOL) (is_scrollok) (const WINDOW * z)
-{
-	T((T_CALLED("is_scrollok(%p)"), (const void *)z)); returnBool(((z) ? (z)->_scroll : 0));
-}
-
-
-NCURSES_EXPORT(NCURSES_BOOL) (is_subwin) (const WINDOW * z)
-{
-	T((T_CALLED("is_subwin(%p)"), (const void *)z)); returnBool(((z) ? ((z)->_flags & 0x01) != 0 : 0));
-}
-
-
-NCURSES_EXPORT(NCURSES_BOOL) (is_syncok) (const WINDOW * z)
-{
-	T((T_CALLED("is_syncok(%p)"), (const void *)z)); returnBool(((z) ? (z)->_sync : 0));
-}
-
-
-NCURSES_EXPORT(int) (wgetdelay) (const WINDOW * z)
-{
-	T((T_CALLED("wgetdelay(%p)"), (const void *)z)); returnCode(((z) ? (z)->_delay : 0));
-}
-
-
-NCURSES_EXPORT(int) (wgetscrreg) (const WINDOW * a1, int * a2, int * z)
-{
-	T((T_CALLED("wgetscrreg(%p,%p,%p)"), (const void *)a1, (const void *)a2, (const void *)z)); returnCode(((a1) ? (*(a2) = (a1)->_regtop, *(z) = (a1)->_regbottom, (0)) : (-1)));
-}
-
-
-NCURSES_EXPORT(NCURSES_BOOL) (mouse_trafo) (int * a1, int * a2, NCURSES_BOOL z)
-{
-	T((T_CALLED("mouse_trafo(%p,%p,%#lx)"), (const void *)a1, (const void *)a2, (long)z)); returnBool(wmouse_trafo(stdscr,a1,a2,z));
-}
diff --git a/ncurses/lib_keyname.c b/ncurses/lib_keyname.c
deleted file mode 100644
index 7e1eb25..0000000
--- a/ncurses/lib_keyname.c
+++ /dev/null
@@ -1,422 +0,0 @@
-/* generated by MKkeyname.awk */
-
-#include <curses.priv.h>
-#include <tic.h>
-
-struct kn { short offset; int code; };
-static const struct kn _nc_key_names[] = {
-	{ 0, KEY_A1 },
-	{ 7, KEY_A3 },
-	{ 14, KEY_B2 },
-	{ 21, KEY_BACKSPACE },
-	{ 35, KEY_BEG },
-	{ 43, KEY_BREAK },
-	{ 53, KEY_BTAB },
-	{ 62, KEY_C1 },
-	{ 69, KEY_C3 },
-	{ 76, KEY_CANCEL },
-	{ 87, KEY_CATAB },
-	{ 97, KEY_CLEAR },
-	{ 107, KEY_CLOSE },
-	{ 117, KEY_COMMAND },
-	{ 129, KEY_COPY },
-	{ 138, KEY_CREATE },
-	{ 149, KEY_CTAB },
-	{ 158, KEY_DC },
-	{ 165, KEY_DL },
-	{ 172, KEY_DOWN },
-	{ 181, KEY_EIC },
-	{ 189, KEY_END },
-	{ 197, KEY_ENTER },
-	{ 207, KEY_EOL },
-	{ 215, KEY_EOS },
-	{ 223, KEY_EXIT },
-	{ 232, KEY_F(0) },
-	{ 241, KEY_F(10) },
-	{ 251, KEY_F(11) },
-	{ 261, KEY_F(12) },
-	{ 271, KEY_F(13) },
-	{ 281, KEY_F(14) },
-	{ 291, KEY_F(15) },
-	{ 301, KEY_F(16) },
-	{ 311, KEY_F(17) },
-	{ 321, KEY_F(18) },
-	{ 331, KEY_F(19) },
-	{ 341, KEY_F(1) },
-	{ 350, KEY_F(20) },
-	{ 360, KEY_F(21) },
-	{ 370, KEY_F(22) },
-	{ 380, KEY_F(23) },
-	{ 390, KEY_F(24) },
-	{ 400, KEY_F(25) },
-	{ 410, KEY_F(26) },
-	{ 420, KEY_F(27) },
-	{ 430, KEY_F(28) },
-	{ 440, KEY_F(29) },
-	{ 450, KEY_F(2) },
-	{ 459, KEY_F(30) },
-	{ 469, KEY_F(31) },
-	{ 479, KEY_F(32) },
-	{ 489, KEY_F(33) },
-	{ 499, KEY_F(34) },
-	{ 509, KEY_F(35) },
-	{ 519, KEY_F(36) },
-	{ 529, KEY_F(37) },
-	{ 539, KEY_F(38) },
-	{ 549, KEY_F(39) },
-	{ 559, KEY_F(3) },
-	{ 568, KEY_F(40) },
-	{ 578, KEY_F(41) },
-	{ 588, KEY_F(42) },
-	{ 598, KEY_F(43) },
-	{ 608, KEY_F(44) },
-	{ 618, KEY_F(45) },
-	{ 628, KEY_F(46) },
-	{ 638, KEY_F(47) },
-	{ 648, KEY_F(48) },
-	{ 658, KEY_F(49) },
-	{ 668, KEY_F(4) },
-	{ 677, KEY_F(50) },
-	{ 687, KEY_F(51) },
-	{ 697, KEY_F(52) },
-	{ 707, KEY_F(53) },
-	{ 717, KEY_F(54) },
-	{ 727, KEY_F(55) },
-	{ 737, KEY_F(56) },
-	{ 747, KEY_F(57) },
-	{ 757, KEY_F(58) },
-	{ 767, KEY_F(59) },
-	{ 777, KEY_F(5) },
-	{ 786, KEY_F(60) },
-	{ 796, KEY_F(61) },
-	{ 806, KEY_F(62) },
-	{ 816, KEY_F(63) },
-	{ 826, KEY_F(6) },
-	{ 835, KEY_F(7) },
-	{ 844, KEY_F(8) },
-	{ 853, KEY_F(9) },
-	{ 862, KEY_FIND },
-	{ 871, KEY_HELP },
-	{ 880, KEY_HOME },
-	{ 889, KEY_IC },
-	{ 896, KEY_IL },
-	{ 903, KEY_LEFT },
-	{ 912, KEY_LL },
-	{ 919, KEY_MARK },
-	{ 928, KEY_MESSAGE },
-	{ 940, KEY_MOUSE },
-	{ 950, KEY_MOVE },
-	{ 959, KEY_NEXT },
-	{ 968, KEY_NPAGE },
-	{ 978, KEY_OPEN },
-	{ 987, KEY_OPTIONS },
-	{ 999, KEY_PPAGE },
-	{ 1009, KEY_PREVIOUS },
-	{ 1022, KEY_PRINT },
-	{ 1032, KEY_REDO },
-	{ 1041, KEY_REFERENCE },
-	{ 1055, KEY_REFRESH },
-	{ 1067, KEY_REPLACE },
-	{ 1079, KEY_RESET },
-	{ 1089, KEY_RESIZE },
-	{ 1100, KEY_RESTART },
-	{ 1112, KEY_RESUME },
-	{ 1123, KEY_RIGHT },
-	{ 1133, KEY_SAVE },
-	{ 1142, KEY_SBEG },
-	{ 1151, KEY_SCANCEL },
-	{ 1163, KEY_SCOMMAND },
-	{ 1176, KEY_SCOPY },
-	{ 1186, KEY_SCREATE },
-	{ 1198, KEY_SDC },
-	{ 1206, KEY_SDL },
-	{ 1214, KEY_SELECT },
-	{ 1225, KEY_SEND },
-	{ 1234, KEY_SEOL },
-	{ 1243, KEY_SEXIT },
-	{ 1253, KEY_SFIND },
-	{ 1263, KEY_SF },
-	{ 1270, KEY_SHELP },
-	{ 1280, KEY_SHOME },
-	{ 1290, KEY_SIC },
-	{ 1298, KEY_SLEFT },
-	{ 1308, KEY_SMESSAGE },
-	{ 1321, KEY_SMOVE },
-	{ 1331, KEY_SNEXT },
-	{ 1341, KEY_SOPTIONS },
-	{ 1354, KEY_SPREVIOUS },
-	{ 1368, KEY_SPRINT },
-	{ 1379, KEY_SREDO },
-	{ 1389, KEY_SREPLACE },
-	{ 1402, KEY_SRESET },
-	{ 1413, KEY_SRIGHT },
-	{ 1424, KEY_SR },
-	{ 1431, KEY_SRSUME },
-	{ 1442, KEY_SSAVE },
-	{ 1452, KEY_SSUSPEND },
-	{ 1465, KEY_STAB },
-	{ 1474, KEY_SUNDO },
-	{ 1484, KEY_SUSPEND },
-	{ 1496, KEY_UNDO },
-	{ 1505, KEY_UP },
-	{ -1, 0 }};
-
-static const char key_names[] = 
-	"KEY_A1\0"
-	"KEY_A3\0"
-	"KEY_B2\0"
-	"KEY_BACKSPACE\0"
-	"KEY_BEG\0"
-	"KEY_BREAK\0"
-	"KEY_BTAB\0"
-	"KEY_C1\0"
-	"KEY_C3\0"
-	"KEY_CANCEL\0"
-	"KEY_CATAB\0"
-	"KEY_CLEAR\0"
-	"KEY_CLOSE\0"
-	"KEY_COMMAND\0"
-	"KEY_COPY\0"
-	"KEY_CREATE\0"
-	"KEY_CTAB\0"
-	"KEY_DC\0"
-	"KEY_DL\0"
-	"KEY_DOWN\0"
-	"KEY_EIC\0"
-	"KEY_END\0"
-	"KEY_ENTER\0"
-	"KEY_EOL\0"
-	"KEY_EOS\0"
-	"KEY_EXIT\0"
-	"KEY_F(0)\0"
-	"KEY_F(10)\0"
-	"KEY_F(11)\0"
-	"KEY_F(12)\0"
-	"KEY_F(13)\0"
-	"KEY_F(14)\0"
-	"KEY_F(15)\0"
-	"KEY_F(16)\0"
-	"KEY_F(17)\0"
-	"KEY_F(18)\0"
-	"KEY_F(19)\0"
-	"KEY_F(1)\0"
-	"KEY_F(20)\0"
-	"KEY_F(21)\0"
-	"KEY_F(22)\0"
-	"KEY_F(23)\0"
-	"KEY_F(24)\0"
-	"KEY_F(25)\0"
-	"KEY_F(26)\0"
-	"KEY_F(27)\0"
-	"KEY_F(28)\0"
-	"KEY_F(29)\0"
-	"KEY_F(2)\0"
-	"KEY_F(30)\0"
-	"KEY_F(31)\0"
-	"KEY_F(32)\0"
-	"KEY_F(33)\0"
-	"KEY_F(34)\0"
-	"KEY_F(35)\0"
-	"KEY_F(36)\0"
-	"KEY_F(37)\0"
-	"KEY_F(38)\0"
-	"KEY_F(39)\0"
-	"KEY_F(3)\0"
-	"KEY_F(40)\0"
-	"KEY_F(41)\0"
-	"KEY_F(42)\0"
-	"KEY_F(43)\0"
-	"KEY_F(44)\0"
-	"KEY_F(45)\0"
-	"KEY_F(46)\0"
-	"KEY_F(47)\0"
-	"KEY_F(48)\0"
-	"KEY_F(49)\0"
-	"KEY_F(4)\0"
-	"KEY_F(50)\0"
-	"KEY_F(51)\0"
-	"KEY_F(52)\0"
-	"KEY_F(53)\0"
-	"KEY_F(54)\0"
-	"KEY_F(55)\0"
-	"KEY_F(56)\0"
-	"KEY_F(57)\0"
-	"KEY_F(58)\0"
-	"KEY_F(59)\0"
-	"KEY_F(5)\0"
-	"KEY_F(60)\0"
-	"KEY_F(61)\0"
-	"KEY_F(62)\0"
-	"KEY_F(63)\0"
-	"KEY_F(6)\0"
-	"KEY_F(7)\0"
-	"KEY_F(8)\0"
-	"KEY_F(9)\0"
-	"KEY_FIND\0"
-	"KEY_HELP\0"
-	"KEY_HOME\0"
-	"KEY_IC\0"
-	"KEY_IL\0"
-	"KEY_LEFT\0"
-	"KEY_LL\0"
-	"KEY_MARK\0"
-	"KEY_MESSAGE\0"
-	"KEY_MOUSE\0"
-	"KEY_MOVE\0"
-	"KEY_NEXT\0"
-	"KEY_NPAGE\0"
-	"KEY_OPEN\0"
-	"KEY_OPTIONS\0"
-	"KEY_PPAGE\0"
-	"KEY_PREVIOUS\0"
-	"KEY_PRINT\0"
-	"KEY_REDO\0"
-	"KEY_REFERENCE\0"
-	"KEY_REFRESH\0"
-	"KEY_REPLACE\0"
-	"KEY_RESET\0"
-	"KEY_RESIZE\0"
-	"KEY_RESTART\0"
-	"KEY_RESUME\0"
-	"KEY_RIGHT\0"
-	"KEY_SAVE\0"
-	"KEY_SBEG\0"
-	"KEY_SCANCEL\0"
-	"KEY_SCOMMAND\0"
-	"KEY_SCOPY\0"
-	"KEY_SCREATE\0"
-	"KEY_SDC\0"
-	"KEY_SDL\0"
-	"KEY_SELECT\0"
-	"KEY_SEND\0"
-	"KEY_SEOL\0"
-	"KEY_SEXIT\0"
-	"KEY_SFIND\0"
-	"KEY_SF\0"
-	"KEY_SHELP\0"
-	"KEY_SHOME\0"
-	"KEY_SIC\0"
-	"KEY_SLEFT\0"
-	"KEY_SMESSAGE\0"
-	"KEY_SMOVE\0"
-	"KEY_SNEXT\0"
-	"KEY_SOPTIONS\0"
-	"KEY_SPREVIOUS\0"
-	"KEY_SPRINT\0"
-	"KEY_SREDO\0"
-	"KEY_SREPLACE\0"
-	"KEY_SRESET\0"
-	"KEY_SRIGHT\0"
-	"KEY_SR\0"
-	"KEY_SRSUME\0"
-	"KEY_SSAVE\0"
-	"KEY_SSUSPEND\0"
-	"KEY_STAB\0"
-	"KEY_SUNDO\0"
-	"KEY_SUSPEND\0"
-	"KEY_UNDO\0"
-	"KEY_UP\0";
-
-#define SIZEOF_TABLE 256
-#define MyTable _nc_globals.keyname_table
-#define MyInit  _nc_globals.init_keyname
-
-NCURSES_EXPORT(NCURSES_CONST char *)
-safe_keyname (SCREEN *sp, int c)
-{
-	int i;
-	char name[20];
-	char *p;
-	NCURSES_CONST char *result = 0;
-
-	if (c == -1) {
-		result = "-1";
-	} else {
-		for (i = 0; _nc_key_names[i].offset != -1; i++) {
-			if (_nc_key_names[i].code == c) {
-				result = (NCURSES_CONST char *)key_names + _nc_key_names[i].offset;
-				break;
-			}
-		}
-
-		if (result == 0 && (c >= 0 && c < SIZEOF_TABLE)) {
-			if (MyTable == 0)
-				MyTable = typeCalloc(char *, SIZEOF_TABLE);
-
-			if (MyTable != 0) {
-				int m_prefix = (sp == 0 || sp->_use_meta);
-
-				/* if sense of meta() changed, discard cached data */
-				if (MyInit != (m_prefix + 1)) {
-					MyInit = m_prefix + 1;
-					for (i = 0; i < SIZEOF_TABLE; ++i) {
-						if (MyTable[i]) {
-							FreeAndNull(MyTable[i]);
-						}
-					}
-				}
-
-				/* create and cache result as needed */
-				if (MyTable[c] == 0) {
-					int cc = c;
-					p = name;
-#define P_LIMIT (sizeof(name) - (size_t) (p - name))
-					if (cc >= 128 && m_prefix) {
-						_nc_STRCPY(p, "M-", P_LIMIT);
-						p += 2;
-						cc -= 128;
-					}
-					if (cc < 32)
-						_nc_SPRINTF(p, _nc_SLIMIT(P_LIMIT) "^%c", cc + '@');
-					else if (cc == 127)
-						_nc_STRCPY(p, "^?", P_LIMIT);
-					else
-						_nc_SPRINTF(p, _nc_SLIMIT(P_LIMIT) "%c", cc);
-					MyTable[c] = strdup(name);
-				}
-				result = MyTable[c];
-			}
-#if NCURSES_EXT_FUNCS && NCURSES_XNAMES
-		} else if (result == 0 && HasTerminal(sp)) {
-			int j, k;
-			char * bound;
-			TERMTYPE *tp = &(TerminalOf(sp)->type);
-			unsigned save_trace = _nc_tracing;
-
-			_nc_tracing = 0;	/* prevent recursion via keybound() */
-			for (j = 0; (bound = NCURSES_SP_NAME(keybound)(NCURSES_SP_ARGx c, j)) != 0; ++j) {
-				for(k = STRCOUNT; k < (int) NUM_STRINGS(tp);  k++) {
-					if (tp->Strings[k] != 0 && !strcmp(bound, tp->Strings[k])) {
-						result = ExtStrname(tp, k, strnames);
-						break;
-					}
-				}
-				free(bound);
-				if (result != 0)
-					break;
-			}
-			_nc_tracing = save_trace;
-#endif
-		}
-	}
-	return result;
-}
-
-NCURSES_EXPORT(NCURSES_CONST char *)
-keyname (int c)
-{
-	return safe_keyname (CURRENT_SCREEN, c);
-}
-
-#if NO_LEAKS
-void _nc_keyname_leaks(void)
-{
-	int j;
-	if (MyTable != 0) {
-		for (j = 0; j < SIZEOF_TABLE; ++j) {
-			FreeIfNeeded(MyTable[j]);
-		}
-		FreeAndNull(MyTable);
-	}
-}
-#endif /* NO_LEAKS */
diff --git a/ncurses/link_test.c b/ncurses/link_test.c
deleted file mode 100644
index 714228f..0000000
--- a/ncurses/link_test.c
+++ /dev/null
@@ -1,3392 +0,0 @@
-/*
- * DO NOT EDIT THIS FILE BY HAND!
- * It is generated by ./base/MKlib_gen.sh implemented.
- */
-#define NCURSES_ATTR_T int
-#include <ncurses_cfg.h>
-
-#undef NCURSES_NOMACROS /* _this_ file uses macros */
-
-#include <curses.priv.h>
-
-#undef vw_scanw
-#undef vwscanw
-
-#undef vw_printw
-#undef vwprintw
-
-extern int call_addch (const chtype z);
-int call_addch (const chtype z)
-{
-	T((T_CALLED("addch(%s)"), _tracechtype2(0,z))); returnCode(waddch(stdscr,(z)));
-}
-
-
-extern int call_addchnstr (const chtype * a1, int z);
-int call_addchnstr (const chtype * a1, int z)
-{
-	T((T_CALLED("addchnstr(%p,%d)"), (const void *)a1, z)); returnCode(waddchnstr(stdscr,(a1),(z)));
-}
-
-
-extern int call_addchstr (const chtype * z);
-int call_addchstr (const chtype * z)
-{
-	T((T_CALLED("addchstr(%p)"), (const void *)z)); returnCode(waddchnstr(stdscr,(z),-1));
-}
-
-
-extern int call_addnstr (const char * a1, int z);
-int call_addnstr (const char * a1, int z)
-{
-	T((T_CALLED("addnstr(%s,%d)"), _nc_visbuf2(0,a1), z)); returnCode(waddnstr(stdscr,(a1),(z)));
-}
-
-
-extern int call_addstr (const char * z);
-int call_addstr (const char * z)
-{
-	T((T_CALLED("addstr(%s)"), _nc_visbuf2(0,z))); returnCode(waddnstr(stdscr,(z),-1));
-}
-
-
-extern int call_attroff (int z);
-int call_attroff (int z)
-{
-	T((T_CALLED("attroff(%s)"), _traceattr2(0,(chtype)z))); returnCode(wattr_off(stdscr, (attr_t)((z)), ((void*)0)));
-}
-
-
-extern int call_attron (int z);
-int call_attron (int z)
-{
-	T((T_CALLED("attron(%s)"), _traceattr2(0,(chtype)z))); returnCode(wattr_on(stdscr, (attr_t)((z)), ((void*)0)));
-}
-
-
-extern int call_attrset (int z);
-int call_attrset (int z)
-{
-	T((T_CALLED("attrset(%s)"), _traceattr2(0,(chtype)z))); returnIntAttr((attr_t)((stdscr) ? ((stdscr)->_attrs = (attr_t)((z)), (0)) : (-1)));
-}
-
-
-extern int call_attr_get (attr_t * a1, short * a2, void * z);
-int call_attr_get (attr_t * a1, short * a2, void * z)
-{
-	T((T_CALLED("attr_get(%p,%p,%p)"), (const void *)a1, (const void *)a2, (const void *)z)); returnCode(((void)((((a1)) != (void *)0) ? (*((a1)) = (stdscr) ? (stdscr)->_attrs : 0) : (0)), (void)((((a2)) != (void *)0) ? (*((a2)) = (short) ((stdscr) ? ((int)((((unsigned long)(((stdscr)->_attrs)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))) >> 8))) : 0)) : (0)), (0)));
-}
-
-
-extern int call_attr_off (attr_t a1, void * z);
-int call_attr_off (attr_t a1, void * z)
-{
-	T((T_CALLED("attr_off(%s,%p)"), _traceattr2(0,a1), (const void *)z)); returnCode(wattr_off(stdscr,(a1),(z)));
-}
-
-
-extern int call_attr_on (attr_t a1, void * z);
-int call_attr_on (attr_t a1, void * z)
-{
-	T((T_CALLED("attr_on(%s,%p)"), _traceattr2(0,a1), (const void *)z)); returnCode(wattr_on(stdscr,(a1),(z)));
-}
-
-
-extern int call_attr_set (attr_t a1, short a2, void * z);
-int call_attr_set (attr_t a1, short a2, void * z)
-{
-	T((T_CALLED("attr_set(%s,%#lx,%p)"), _traceattr2(0,a1), (long)a2, (const void *)z)); returnCode((((stdscr) ? ((stdscr)->_attrs = ((((a1)) & ~((chtype)((((1U) << 8) - 1U)) << ((0) + 8))) | (attr_t)((chtype)((((a2)))) << ((0) + 8)))) : (0)), (0)));
-}
-
-
-extern int call_baudrate (void);
-int call_baudrate (void)
-{
-	T((T_CALLED("baudrate()"))); returnCode(baudrate());
-}
-
-
-extern int call_beep (void);
-int call_beep (void)
-{
-	T((T_CALLED("beep()"))); returnCode(beep());
-}
-
-
-extern int call_bkgd (chtype z);
-int call_bkgd (chtype z)
-{
-	T((T_CALLED("bkgd(%s)"), _tracechtype2(0,z))); returnCode(wbkgd(stdscr,(z)));
-}
-
-
-extern void call_bkgdset (chtype z);
-void call_bkgdset (chtype z)
-{
-	T((T_CALLED("bkgdset(%s)"), _tracechtype2(0,z))); wbkgdset(stdscr,(z));
-	returnVoid;
-}
-
-
-extern int call_border (chtype a1, chtype a2, chtype a3, chtype a4, chtype a5, chtype a6, chtype a7, chtype z);
-int call_border (chtype a1, chtype a2, chtype a3, chtype a4, chtype a5, chtype a6, chtype a7, chtype z)
-{
-	T((T_CALLED("border(%s,%s,%s,%s,%s,%s,%s,%s)"), _tracechtype2(0,a1), _tracechtype2(1,a2), _tracechtype2(2,a3), _tracechtype2(3,a4), _tracechtype2(4,a5), _tracechtype2(5,a6), _tracechtype2(6,a7), _tracechtype2(7,z))); returnCode(wborder(stdscr, a1, a2, a3, a4, a5, a6, a7, z));
-}
-
-
-extern int call_box (WINDOW * a1, chtype a2, chtype z);
-int call_box (WINDOW * a1, chtype a2, chtype z)
-{
-	T((T_CALLED("box(%p,%s,%s)"), (const void *)a1, _tracechtype2(1,a2), _tracechtype2(2,z))); returnCode(wborder(a1, a2, a2, z, z, 0, 0, 0, 0));
-}
-
-
-extern NCURSES_BOOL call_can_change_color (void);
-NCURSES_BOOL call_can_change_color (void)
-{
-	T((T_CALLED("can_change_color()"))); returnBool(can_change_color());
-}
-
-
-extern int call_cbreak (void);
-int call_cbreak (void)
-{
-	T((T_CALLED("cbreak()"))); returnCode(cbreak());
-}
-
-
-extern int call_chgat (int a1, attr_t a2, short a3, const void * z);
-int call_chgat (int a1, attr_t a2, short a3, const void * z)
-{
-	T((T_CALLED("chgat(%d,%s,%#lx,%p)"), a1, _traceattr2(1,a2), (long)a3, (const void *)z)); returnCode(wchgat(stdscr,(a1),(a2),(a3),(z)));
-}
-
-
-extern int call_clear (void);
-int call_clear (void)
-{
-	T((T_CALLED("clear()"))); returnCode(wclear(stdscr));
-}
-
-
-extern int call_clearok (WINDOW * a1, NCURSES_BOOL z);
-int call_clearok (WINDOW * a1, NCURSES_BOOL z)
-{
-	T((T_CALLED("clearok(%p,%#lx)"), (const void *)a1, (long)z)); returnCode(clearok(a1, z));
-}
-
-
-extern int call_clrtobot (void);
-int call_clrtobot (void)
-{
-	T((T_CALLED("clrtobot()"))); returnCode(wclrtobot(stdscr));
-}
-
-
-extern int call_clrtoeol (void);
-int call_clrtoeol (void)
-{
-	T((T_CALLED("clrtoeol()"))); returnCode(wclrtoeol(stdscr));
-}
-
-
-extern int call_color_content (short a1, short * a2, short * a3, short * z);
-int call_color_content (short a1, short * a2, short * a3, short * z)
-{
-	T((T_CALLED("color_content(%#lx,%p,%p,%p)"), (long)a1, (const void *)a2, (const void *)a3, (const void *)z)); returnCode(color_content(a1, a2, a3, z));
-}
-
-
-extern int call_color_set (short a1, void * z);
-int call_color_set (short a1, void * z)
-{
-	T((T_CALLED("color_set(%#lx,%p)"), (long)a1, (const void *)z)); returnCode(wcolor_set(stdscr,(a1),(z)));
-}
-
-
-extern int call_COLOR_PAIR (int z);
-int call_COLOR_PAIR (int z)
-{
-	T((T_CALLED("COLOR_PAIR(%d)"), z)); returnCode(((chtype)(((z))) << ((0) + 8)));
-}
-
-
-extern int call_copywin (const WINDOW * a1, WINDOW * a2, int a3, int a4, int a5, int a6, int a7, int a8, int z);
-int call_copywin (const WINDOW * a1, WINDOW * a2, int a3, int a4, int a5, int a6, int a7, int a8, int z)
-{
-	T((T_CALLED("copywin(%p,%p,%d,%d,%d,%d,%d,%d,%d)"), (const void *)a1, (const void *)a2, a3, a4, a5, a6, a7, a8, z)); returnCode(copywin(a1, a2, a3, a4, a5, a6, a7, a8, z));
-}
-
-
-extern int call_curs_set (int z);
-int call_curs_set (int z)
-{
-	T((T_CALLED("curs_set(%d)"), z)); returnCode(curs_set(z));
-}
-
-
-extern int call_def_prog_mode (void);
-int call_def_prog_mode (void)
-{
-	T((T_CALLED("def_prog_mode()"))); returnCode(def_prog_mode());
-}
-
-
-extern int call_def_shell_mode (void);
-int call_def_shell_mode (void)
-{
-	T((T_CALLED("def_shell_mode()"))); returnCode(def_shell_mode());
-}
-
-
-extern int call_delay_output (int z);
-int call_delay_output (int z)
-{
-	T((T_CALLED("delay_output(%d)"), z)); returnCode(delay_output(z));
-}
-
-
-extern int call_delch (void);
-int call_delch (void)
-{
-	T((T_CALLED("delch()"))); returnCode(wdelch(stdscr));
-}
-
-
-extern void call_delscreen (SCREEN * z);
-void call_delscreen (SCREEN * z)
-{
-	T((T_CALLED("delscreen(%p)"), (const void *)z)); delscreen(z);
-	returnVoid;
-}
-
-
-extern int call_delwin (WINDOW * z);
-int call_delwin (WINDOW * z)
-{
-	T((T_CALLED("delwin(%p)"), (const void *)z)); returnCode(delwin(z));
-}
-
-
-extern int call_deleteln (void);
-int call_deleteln (void)
-{
-	T((T_CALLED("deleteln()"))); returnCode(winsdelln(stdscr,-1));
-}
-
-
-extern WINDOW * call_derwin (WINDOW * a1, int a2, int a3, int a4, int z);
-WINDOW * call_derwin (WINDOW * a1, int a2, int a3, int a4, int z)
-{
-	T((T_CALLED("derwin(%p,%d,%d,%d,%d)"), (const void *)a1, a2, a3, a4, z)); returnWin(derwin(a1, a2, a3, a4, z));
-}
-
-
-extern int call_doupdate (void);
-int call_doupdate (void)
-{
-	T((T_CALLED("doupdate()"))); returnCode(doupdate());
-}
-
-
-extern WINDOW * call_dupwin (WINDOW * z);
-WINDOW * call_dupwin (WINDOW * z)
-{
-	T((T_CALLED("dupwin(%p)"), (const void *)z)); returnWin(dupwin(z));
-}
-
-
-extern int call_echo (void);
-int call_echo (void)
-{
-	T((T_CALLED("echo()"))); returnCode(echo());
-}
-
-
-extern int call_echochar (const chtype z);
-int call_echochar (const chtype z)
-{
-	T((T_CALLED("echochar(%s)"), _tracechtype2(0,z))); returnCode(wechochar(stdscr,(z)));
-}
-
-
-extern int call_erase (void);
-int call_erase (void)
-{
-	T((T_CALLED("erase()"))); returnCode(werase(stdscr));
-}
-
-
-extern int call_endwin (void);
-int call_endwin (void)
-{
-	T((T_CALLED("endwin()"))); returnCode(endwin());
-}
-
-
-extern char call_erasechar (void);
-char call_erasechar (void)
-{
-	T((T_CALLED("erasechar()"))); returnCode(erasechar());
-}
-
-
-extern void call_filter (void);
-void call_filter (void)
-{
-	T((T_CALLED("filter()"))); filter();
-	returnVoid;
-}
-
-
-extern int call_flash (void);
-int call_flash (void)
-{
-	T((T_CALLED("flash()"))); returnCode(flash());
-}
-
-
-extern int call_flushinp (void);
-int call_flushinp (void)
-{
-	T((T_CALLED("flushinp()"))); returnCode(flushinp());
-}
-
-
-extern chtype call_getbkgd (WINDOW * z);
-chtype call_getbkgd (WINDOW * z)
-{
-	T((T_CALLED("getbkgd(%p)"), (const void *)z)); returnChtype(((z) ? ((z)->_bkgd) : 0));
-}
-
-
-extern int call_getch (void);
-int call_getch (void)
-{
-	T((T_CALLED("getch()"))); returnCode(wgetch(stdscr));
-}
-
-
-extern int call_getnstr (char * a1, int z);
-int call_getnstr (char * a1, int z)
-{
-	T((T_CALLED("getnstr(%s,%d)"), _nc_visbuf2(0,a1), z)); returnCode(wgetnstr(stdscr, a1, (z)));
-}
-
-
-extern int call_getstr (char * z);
-int call_getstr (char * z)
-{
-	T((T_CALLED("getstr(%s)"), _nc_visbuf2(0,z))); returnCode(wgetnstr(stdscr, (z), -1));
-}
-
-
-extern WINDOW * call_getwin (FILE * z);
-WINDOW * call_getwin (FILE * z)
-{
-	T((T_CALLED("getwin(%p)"), (const void *)z)); returnWin(getwin(z));
-}
-
-
-extern int call_halfdelay (int z);
-int call_halfdelay (int z)
-{
-	T((T_CALLED("halfdelay(%d)"), z)); returnCode(halfdelay(z));
-}
-
-
-extern NCURSES_BOOL call_has_colors (void);
-NCURSES_BOOL call_has_colors (void)
-{
-	T((T_CALLED("has_colors()"))); returnBool(has_colors());
-}
-
-
-extern NCURSES_BOOL call_has_ic (void);
-NCURSES_BOOL call_has_ic (void)
-{
-	T((T_CALLED("has_ic()"))); returnBool(has_ic());
-}
-
-
-extern NCURSES_BOOL call_has_il (void);
-NCURSES_BOOL call_has_il (void)
-{
-	T((T_CALLED("has_il()"))); returnBool(has_il());
-}
-
-
-extern int call_hline (chtype a1, int z);
-int call_hline (chtype a1, int z)
-{
-	T((T_CALLED("hline(%s,%d)"), _tracechtype2(0,a1), z)); returnCode(whline(stdscr, a1, (z)));
-}
-
-
-extern void call_idcok (WINDOW * a1, NCURSES_BOOL z);
-void call_idcok (WINDOW * a1, NCURSES_BOOL z)
-{
-	T((T_CALLED("idcok(%p,%#lx)"), (const void *)a1, (long)z)); idcok(a1, z);
-	returnVoid;
-}
-
-
-extern int call_idlok (WINDOW * a1, NCURSES_BOOL z);
-int call_idlok (WINDOW * a1, NCURSES_BOOL z)
-{
-	T((T_CALLED("idlok(%p,%#lx)"), (const void *)a1, (long)z)); returnCode(idlok(a1, z));
-}
-
-
-extern void call_immedok (WINDOW * a1, NCURSES_BOOL z);
-void call_immedok (WINDOW * a1, NCURSES_BOOL z)
-{
-	T((T_CALLED("immedok(%p,%#lx)"), (const void *)a1, (long)z)); immedok(a1, z);
-	returnVoid;
-}
-
-
-extern chtype call_inch (void);
-chtype call_inch (void)
-{
-	T((T_CALLED("inch()"))); returnChtype(winch(stdscr));
-}
-
-
-extern int call_inchnstr (chtype * a1, int z);
-int call_inchnstr (chtype * a1, int z)
-{
-	T((T_CALLED("inchnstr(%p,%d)"), (const void *)a1, z)); returnCode(winchnstr(stdscr,(a1),(z)));
-}
-
-
-extern int call_inchstr (chtype * z);
-int call_inchstr (chtype * z)
-{
-	T((T_CALLED("inchstr(%p)"), (const void *)z)); returnCode(winchnstr(stdscr, (z), -1));
-}
-
-
-extern WINDOW * call_initscr (void);
-WINDOW * call_initscr (void)
-{
-	T((T_CALLED("initscr()"))); returnWin(initscr());
-}
-
-
-extern int call_init_color (short a1, short a2, short a3, short z);
-int call_init_color (short a1, short a2, short a3, short z)
-{
-	T((T_CALLED("init_color(%#lx,%#lx,%#lx,%#lx)"), (long)a1, (long)a2, (long)a3, (long)z)); returnCode(init_color(a1, a2, a3, z));
-}
-
-
-extern int call_init_pair (short a1, short a2, short z);
-int call_init_pair (short a1, short a2, short z)
-{
-	T((T_CALLED("init_pair(%#lx,%#lx,%#lx)"), (long)a1, (long)a2, (long)z)); returnCode(init_pair(a1, a2, z));
-}
-
-
-extern int call_innstr (char * a1, int z);
-int call_innstr (char * a1, int z)
-{
-	return winnstr(stdscr,(a1),(z)) ;
-}
-
-
-extern int call_insch (chtype z);
-int call_insch (chtype z)
-{
-	T((T_CALLED("insch(%s)"), _tracechtype2(0,z))); returnCode(winsch(stdscr,(z)));
-}
-
-
-extern int call_insdelln (int z);
-int call_insdelln (int z)
-{
-	T((T_CALLED("insdelln(%d)"), z)); returnCode(winsdelln(stdscr,(z)));
-}
-
-
-extern int call_insertln (void);
-int call_insertln (void)
-{
-	T((T_CALLED("insertln()"))); returnCode(winsdelln(stdscr,1));
-}
-
-
-extern int call_insnstr (const char * a1, int z);
-int call_insnstr (const char * a1, int z)
-{
-	T((T_CALLED("insnstr(%s,%d)"), _nc_visbuf2(0,a1), z)); returnCode(winsnstr(stdscr,(a1),(z)));
-}
-
-
-extern int call_insstr (const char * z);
-int call_insstr (const char * z)
-{
-	T((T_CALLED("insstr(%s)"), _nc_visbuf2(0,z))); returnCode(winsnstr(stdscr, (z), -1));
-}
-
-
-extern int call_instr (char * z);
-int call_instr (char * z)
-{
-	T((T_CALLED("instr(%s)"), _nc_visbuf2(0,z))); returnCode(winnstr(stdscr, (z), -1));
-}
-
-
-extern int call_intrflush (WINDOW * a1, NCURSES_BOOL z);
-int call_intrflush (WINDOW * a1, NCURSES_BOOL z)
-{
-	T((T_CALLED("intrflush(%p,%#lx)"), (const void *)a1, (long)z)); returnCode(intrflush(a1, z));
-}
-
-
-extern NCURSES_BOOL call_isendwin (void);
-NCURSES_BOOL call_isendwin (void)
-{
-	T((T_CALLED("isendwin()"))); returnBool(isendwin());
-}
-
-
-extern NCURSES_BOOL call_is_linetouched (WINDOW * a1, int z);
-NCURSES_BOOL call_is_linetouched (WINDOW * a1, int z)
-{
-	T((T_CALLED("is_linetouched(%p,%d)"), (const void *)a1, z)); returnBool(is_linetouched(a1, z));
-}
-
-
-extern NCURSES_BOOL call_is_wintouched (WINDOW * z);
-NCURSES_BOOL call_is_wintouched (WINDOW * z)
-{
-	T((T_CALLED("is_wintouched(%p)"), (const void *)z)); returnBool(is_wintouched(z));
-}
-
-
-extern const char * call_keyname (int z);
-const char * call_keyname (int z)
-{
-	T((T_CALLED("keyname(%d)"), z)); returnPtr(keyname(z));
-}
-
-
-extern int call_keypad (WINDOW * a1, NCURSES_BOOL z);
-int call_keypad (WINDOW * a1, NCURSES_BOOL z)
-{
-	T((T_CALLED("keypad(%p,%#lx)"), (const void *)a1, (long)z)); returnCode(keypad(a1, z));
-}
-
-
-extern char call_killchar (void);
-char call_killchar (void)
-{
-	T((T_CALLED("killchar()"))); returnCode(killchar());
-}
-
-
-extern int call_leaveok (WINDOW * a1, NCURSES_BOOL z);
-int call_leaveok (WINDOW * a1, NCURSES_BOOL z)
-{
-	T((T_CALLED("leaveok(%p,%#lx)"), (const void *)a1, (long)z)); returnCode(leaveok(a1, z));
-}
-
-
-extern char * call_longname (void);
-char * call_longname (void)
-{
-	T((T_CALLED("longname()"))); returnPtr(longname());
-}
-
-
-extern int call_meta (WINDOW * a1, NCURSES_BOOL z);
-int call_meta (WINDOW * a1, NCURSES_BOOL z)
-{
-	T((T_CALLED("meta(%p,%#lx)"), (const void *)a1, (long)z)); returnCode(meta(a1, z));
-}
-
-
-extern int call_move (int a1, int z);
-int call_move (int a1, int z)
-{
-	T((T_CALLED("move(%d,%d)"), a1, z)); returnCode(wmove(stdscr,(a1),(z)));
-}
-
-
-extern int call_mvaddch (int a1, int a2, const chtype z);
-int call_mvaddch (int a1, int a2, const chtype z)
-{
-	T((T_CALLED("mvaddch(%d,%d,%s)"), a1, a2, _tracechtype2(2,z))); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : waddch((stdscr),((z)))));
-}
-
-
-extern int call_mvaddchnstr (int a1, int a2, const chtype * a3, int z);
-int call_mvaddchnstr (int a1, int a2, const chtype * a3, int z)
-{
-	T((T_CALLED("mvaddchnstr(%d,%d,%p,%d)"), a1, a2, (const void *)a3, z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : waddchnstr((stdscr),((a3)),((z)))));
-}
-
-
-extern int call_mvaddchstr (int a1, int a2, const chtype * z);
-int call_mvaddchstr (int a1, int a2, const chtype * z)
-{
-	T((T_CALLED("mvaddchstr(%d,%d,%p)"), a1, a2, (const void *)z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : waddchnstr((stdscr),((z)),-1)));
-}
-
-
-extern int call_mvaddnstr (int a1, int a2, const char * a3, int z);
-int call_mvaddnstr (int a1, int a2, const char * a3, int z)
-{
-	T((T_CALLED("mvaddnstr(%d,%d,%s,%d)"), a1, a2, _nc_visbuf2(2,a3), z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : waddnstr((stdscr),((a3)),((z)))));
-}
-
-
-extern int call_mvaddstr (int a1, int a2, const char * z);
-int call_mvaddstr (int a1, int a2, const char * z)
-{
-	T((T_CALLED("mvaddstr(%d,%d,%s)"), a1, a2, _nc_visbuf2(2,z))); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : waddnstr((stdscr),((z)),-1)));
-}
-
-
-extern int call_mvchgat (int a1, int a2, int a3, attr_t a4, short a5, const void * z);
-int call_mvchgat (int a1, int a2, int a3, attr_t a4, short a5, const void * z)
-{
-	T((T_CALLED("mvchgat(%d,%d,%d,%s,%#lx,%p)"), a1, a2, a3, _traceattr2(3,a4), (long)a5, (const void *)z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : wchgat((stdscr),((a3)),((a4)),((a5)),((z)))));
-}
-
-
-extern int call_mvcur (int a1, int a2, int a3, int z);
-int call_mvcur (int a1, int a2, int a3, int z)
-{
-	T((T_CALLED("mvcur(%d,%d,%d,%d)"), a1, a2, a3, z)); returnCode(mvcur(a1, a2, a3, z));
-}
-
-
-extern int call_mvdelch (int a1, int z);
-int call_mvdelch (int a1, int z)
-{
-	T((T_CALLED("mvdelch(%d,%d)"), a1, z)); returnCode((wmove((stdscr),((a1)),((z))) == (-1) ? (-1) : wdelch(stdscr)));
-}
-
-
-extern int call_mvderwin (WINDOW * a1, int a2, int z);
-int call_mvderwin (WINDOW * a1, int a2, int z)
-{
-	T((T_CALLED("mvderwin(%p,%d,%d)"), (const void *)a1, a2, z)); returnCode(mvderwin(a1, a2, z));
-}
-
-
-extern int call_mvgetch (int a1, int z);
-int call_mvgetch (int a1, int z)
-{
-	T((T_CALLED("mvgetch(%d,%d)"), a1, z)); returnCode((wmove((stdscr),((a1)),((z))) == (-1) ? (-1) : wgetch(stdscr)));
-}
-
-
-extern int call_mvgetnstr (int a1, int a2, char * a3, int z);
-int call_mvgetnstr (int a1, int a2, char * a3, int z)
-{
-	T((T_CALLED("mvgetnstr(%d,%d,%s,%d)"), a1, a2, _nc_visbuf2(2,a3), z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : wgetnstr((stdscr),((a3)),((z)))));
-}
-
-
-extern int call_mvgetstr (int a1, int a2, char * z);
-int call_mvgetstr (int a1, int a2, char * z)
-{
-	T((T_CALLED("mvgetstr(%d,%d,%s)"), a1, a2, _nc_visbuf2(2,z))); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : wgetnstr((stdscr), ((z)), -1)));
-}
-
-
-extern int call_mvhline (int a1, int a2, chtype a3, int z);
-int call_mvhline (int a1, int a2, chtype a3, int z)
-{
-	T((T_CALLED("mvhline(%d,%d,%s,%d)"), a1, a2, _tracechtype2(2,a3), z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : whline((stdscr),((a3)),((z)))));
-}
-
-
-extern chtype call_mvinch (int a1, int z);
-chtype call_mvinch (int a1, int z)
-{
-	T((T_CALLED("mvinch(%d,%d)"), a1, z)); returnChtype((wmove((stdscr),((a1)),((z))) == (-1) ? (chtype)((-1)) : winch(stdscr)));
-}
-
-
-extern int call_mvinchnstr (int a1, int a2, chtype * a3, int z);
-int call_mvinchnstr (int a1, int a2, chtype * a3, int z)
-{
-	T((T_CALLED("mvinchnstr(%d,%d,%p,%d)"), a1, a2, (const void *)a3, z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : winchnstr((stdscr),((a3)),((z)))));
-}
-
-
-extern int call_mvinchstr (int a1, int a2, chtype * z);
-int call_mvinchstr (int a1, int a2, chtype * z)
-{
-	T((T_CALLED("mvinchstr(%d,%d,%p)"), a1, a2, (const void *)z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : winchnstr((stdscr), ((z)), -1)));
-}
-
-
-extern int call_mvinnstr (int a1, int a2, char * a3, int z);
-int call_mvinnstr (int a1, int a2, char * a3, int z)
-{
-	return (wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : winnstr((stdscr),((a3)),((z)))) ;
-}
-
-
-extern int call_mvinsch (int a1, int a2, chtype z);
-int call_mvinsch (int a1, int a2, chtype z)
-{
-	T((T_CALLED("mvinsch(%d,%d,%s)"), a1, a2, _tracechtype2(2,z))); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : winsch((stdscr),((z)))));
-}
-
-
-extern int call_mvinsnstr (int a1, int a2, const char * a3, int z);
-int call_mvinsnstr (int a1, int a2, const char * a3, int z)
-{
-	T((T_CALLED("mvinsnstr(%d,%d,%s,%d)"), a1, a2, _nc_visbuf2(2,a3), z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : winsnstr((stdscr),((a3)),((z)))));
-}
-
-
-extern int call_mvinsstr (int a1, int a2, const char * z);
-int call_mvinsstr (int a1, int a2, const char * z)
-{
-	T((T_CALLED("mvinsstr(%d,%d,%s)"), a1, a2, _nc_visbuf2(2,z))); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : winsnstr((stdscr), ((z)), -1)));
-}
-
-
-extern int call_mvinstr (int a1, int a2, char * z);
-int call_mvinstr (int a1, int a2, char * z)
-{
-	T((T_CALLED("mvinstr(%d,%d,%s)"), a1, a2, _nc_visbuf2(2,z))); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : winnstr((stdscr), ((z)), -1)));
-}
-
-
-extern int call_mvvline (int a1, int a2, chtype a3, int z);
-int call_mvvline (int a1, int a2, chtype a3, int z)
-{
-	T((T_CALLED("mvvline(%d,%d,%s,%d)"), a1, a2, _tracechtype2(2,a3), z)); returnCode((wmove((stdscr),((a1)),((a2))) == (-1) ? (-1) : wvline((stdscr),((a3)),((z)))));
-}
-
-
-extern int call_mvwaddch (WINDOW * a1, int a2, int a3, const chtype z);
-int call_mvwaddch (WINDOW * a1, int a2, int a3, const chtype z)
-{
-	T((T_CALLED("mvwaddch(%p,%d,%d,%s)"), (const void *)a1, a2, a3, _tracechtype2(3,z))); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : waddch((a1),(z))));
-}
-
-
-extern int call_mvwaddchnstr (WINDOW * a1, int a2, int a3, const chtype * a4, int z);
-int call_mvwaddchnstr (WINDOW * a1, int a2, int a3, const chtype * a4, int z)
-{
-	T((T_CALLED("mvwaddchnstr(%p,%d,%d,%p,%d)"), (const void *)a1, a2, a3, (const void *)a4, z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : waddchnstr((a1),(a4),(z))));
-}
-
-
-extern int call_mvwaddchstr (WINDOW * a1, int a2, int a3, const chtype * z);
-int call_mvwaddchstr (WINDOW * a1, int a2, int a3, const chtype * z)
-{
-	T((T_CALLED("mvwaddchstr(%p,%d,%d,%p)"), (const void *)a1, a2, a3, (const void *)z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : waddchnstr((a1),(z),-1)));
-}
-
-
-extern int call_mvwaddnstr (WINDOW * a1, int a2, int a3, const char * a4, int z);
-int call_mvwaddnstr (WINDOW * a1, int a2, int a3, const char * a4, int z)
-{
-	T((T_CALLED("mvwaddnstr(%p,%d,%d,%s,%d)"), (const void *)a1, a2, a3, _nc_visbuf2(3,a4), z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : waddnstr((a1),(a4),(z))));
-}
-
-
-extern int call_mvwaddstr (WINDOW * a1, int a2, int a3, const char * z);
-int call_mvwaddstr (WINDOW * a1, int a2, int a3, const char * z)
-{
-	T((T_CALLED("mvwaddstr(%p,%d,%d,%s)"), (const void *)a1, a2, a3, _nc_visbuf2(3,z))); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : waddnstr((a1),(z),-1)));
-}
-
-
-extern int call_mvwchgat (WINDOW * a1, int a2, int a3, int a4, attr_t a5, short a6, const void * z);
-int call_mvwchgat (WINDOW * a1, int a2, int a3, int a4, attr_t a5, short a6, const void * z)
-{
-	T((T_CALLED("mvwchgat(%p,%d,%d,%d,%s,%#lx,%p)"), (const void *)a1, a2, a3, a4, _traceattr2(4,a5), (long)a6, (const void *)z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : wchgat((a1),(a4),(a5),(a6),(z))));
-}
-
-
-extern int call_mvwdelch (WINDOW * a1, int a2, int z);
-int call_mvwdelch (WINDOW * a1, int a2, int z)
-{
-	T((T_CALLED("mvwdelch(%p,%d,%d)"), (const void *)a1, a2, z)); returnCode((wmove((a1),(a2),(z)) == (-1) ? (-1) : wdelch(a1)));
-}
-
-
-extern int call_mvwgetch (WINDOW * a1, int a2, int z);
-int call_mvwgetch (WINDOW * a1, int a2, int z)
-{
-	T((T_CALLED("mvwgetch(%p,%d,%d)"), (const void *)a1, a2, z)); returnCode((wmove((a1),(a2),(z)) == (-1) ? (-1) : wgetch(a1)));
-}
-
-
-extern int call_mvwgetnstr (WINDOW * a1, int a2, int a3, char * a4, int z);
-int call_mvwgetnstr (WINDOW * a1, int a2, int a3, char * a4, int z)
-{
-	T((T_CALLED("mvwgetnstr(%p,%d,%d,%s,%d)"), (const void *)a1, a2, a3, _nc_visbuf2(3,a4), z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : wgetnstr((a1),(a4),(z))));
-}
-
-
-extern int call_mvwgetstr (WINDOW * a1, int a2, int a3, char * z);
-int call_mvwgetstr (WINDOW * a1, int a2, int a3, char * z)
-{
-	T((T_CALLED("mvwgetstr(%p,%d,%d,%s)"), (const void *)a1, a2, a3, _nc_visbuf2(3,z))); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : wgetnstr((a1), (z), -1)));
-}
-
-
-extern int call_mvwhline (WINDOW * a1, int a2, int a3, chtype a4, int z);
-int call_mvwhline (WINDOW * a1, int a2, int a3, chtype a4, int z)
-{
-	T((T_CALLED("mvwhline(%p,%d,%d,%s,%d)"), (const void *)a1, a2, a3, _tracechtype2(3,a4), z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : whline((a1),(a4),(z))));
-}
-
-
-extern int call_mvwin (WINDOW * a1, int a2, int z);
-int call_mvwin (WINDOW * a1, int a2, int z)
-{
-	T((T_CALLED("mvwin(%p,%d,%d)"), (const void *)a1, a2, z)); returnCode(mvwin(a1, a2, z));
-}
-
-
-extern chtype call_mvwinch (WINDOW * a1, int a2, int z);
-chtype call_mvwinch (WINDOW * a1, int a2, int z)
-{
-	T((T_CALLED("mvwinch(%p,%d,%d)"), (const void *)a1, a2, z)); returnChtype((wmove((a1),(a2),(z)) == (-1) ? (chtype)((-1)) : winch(a1)));
-}
-
-
-extern int call_mvwinchnstr (WINDOW * a1, int a2, int a3, chtype * a4, int z);
-int call_mvwinchnstr (WINDOW * a1, int a2, int a3, chtype * a4, int z)
-{
-	T((T_CALLED("mvwinchnstr(%p,%d,%d,%p,%d)"), (const void *)a1, a2, a3, (const void *)a4, z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : winchnstr((a1),(a4),(z))));
-}
-
-
-extern int call_mvwinchstr (WINDOW * a1, int a2, int a3, chtype * z);
-int call_mvwinchstr (WINDOW * a1, int a2, int a3, chtype * z)
-{
-	T((T_CALLED("mvwinchstr(%p,%d,%d,%p)"), (const void *)a1, a2, a3, (const void *)z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : winchnstr((a1), (z), -1)));
-}
-
-
-extern int call_mvwinnstr (WINDOW * a1, int a2, int a3, char * a4, int z);
-int call_mvwinnstr (WINDOW * a1, int a2, int a3, char * a4, int z)
-{
-	return (wmove((a1),(a2),(a3)) == (-1) ? (-1) : winnstr((a1),(a4),(z))) ;
-}
-
-
-extern int call_mvwinsch (WINDOW * a1, int a2, int a3, chtype z);
-int call_mvwinsch (WINDOW * a1, int a2, int a3, chtype z)
-{
-	T((T_CALLED("mvwinsch(%p,%d,%d,%s)"), (const void *)a1, a2, a3, _tracechtype2(3,z))); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : winsch((a1),(z))));
-}
-
-
-extern int call_mvwinsnstr (WINDOW * a1, int a2, int a3, const char * a4, int z);
-int call_mvwinsnstr (WINDOW * a1, int a2, int a3, const char * a4, int z)
-{
-	T((T_CALLED("mvwinsnstr(%p,%d,%d,%s,%d)"), (const void *)a1, a2, a3, _nc_visbuf2(3,a4), z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : winsnstr((a1),(a4),(z))));
-}
-
-
-extern int call_mvwinsstr (WINDOW * a1, int a2, int a3, const char * z);
-int call_mvwinsstr (WINDOW * a1, int a2, int a3, const char * z)
-{
-	T((T_CALLED("mvwinsstr(%p,%d,%d,%s)"), (const void *)a1, a2, a3, _nc_visbuf2(3,z))); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : winsnstr((a1), (z), -1)));
-}
-
-
-extern int call_mvwinstr (WINDOW * a1, int a2, int a3, char * z);
-int call_mvwinstr (WINDOW * a1, int a2, int a3, char * z)
-{
-	T((T_CALLED("mvwinstr(%p,%d,%d,%s)"), (const void *)a1, a2, a3, _nc_visbuf2(3,z))); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : winnstr((a1), (z), -1)));
-}
-
-
-extern int call_mvwvline (WINDOW * a1, int a2, int a3, chtype a4, int z);
-int call_mvwvline (WINDOW * a1, int a2, int a3, chtype a4, int z)
-{
-	T((T_CALLED("mvwvline(%p,%d,%d,%s,%d)"), (const void *)a1, a2, a3, _tracechtype2(3,a4), z)); returnCode((wmove((a1),(a2),(a3)) == (-1) ? (-1) : wvline((a1),(a4),(z))));
-}
-
-
-extern int call_napms (int z);
-int call_napms (int z)
-{
-	T((T_CALLED("napms(%d)"), z)); returnCode(napms(z));
-}
-
-
-extern WINDOW * call_newpad (int a1, int z);
-WINDOW * call_newpad (int a1, int z)
-{
-	T((T_CALLED("newpad(%d,%d)"), a1, z)); returnWin(newpad(a1, z));
-}
-
-
-extern SCREEN * call_newterm (const char * a1, FILE * a2, FILE * z);
-SCREEN * call_newterm (const char * a1, FILE * a2, FILE * z)
-{
-	T((T_CALLED("newterm(%s,%p,%p)"), _nc_visbuf2(0,a1), (const void *)a2, (const void *)z)); returnSP(newterm(a1, a2, z));
-}
-
-
-extern WINDOW * call_newwin (int a1, int a2, int a3, int z);
-WINDOW * call_newwin (int a1, int a2, int a3, int z)
-{
-	T((T_CALLED("newwin(%d,%d,%d,%d)"), a1, a2, a3, z)); returnWin(newwin(a1, a2, a3, z));
-}
-
-
-extern int call_nl (void);
-int call_nl (void)
-{
-	T((T_CALLED("nl()"))); returnCode(nl());
-}
-
-
-extern int call_nocbreak (void);
-int call_nocbreak (void)
-{
-	T((T_CALLED("nocbreak()"))); returnCode(nocbreak());
-}
-
-
-extern int call_nodelay (WINDOW * a1, NCURSES_BOOL z);
-int call_nodelay (WINDOW * a1, NCURSES_BOOL z)
-{
-	T((T_CALLED("nodelay(%p,%#lx)"), (const void *)a1, (long)z)); returnCode(nodelay(a1, z));
-}
-
-
-extern int call_noecho (void);
-int call_noecho (void)
-{
-	T((T_CALLED("noecho()"))); returnCode(noecho());
-}
-
-
-extern int call_nonl (void);
-int call_nonl (void)
-{
-	T((T_CALLED("nonl()"))); returnCode(nonl());
-}
-
-
-extern void call_noqiflush (void);
-void call_noqiflush (void)
-{
-	T((T_CALLED("noqiflush()"))); noqiflush();
-	returnVoid;
-}
-
-
-extern int call_noraw (void);
-int call_noraw (void)
-{
-	T((T_CALLED("noraw()"))); returnCode(noraw());
-}
-
-
-extern int call_notimeout (WINDOW * a1, NCURSES_BOOL z);
-int call_notimeout (WINDOW * a1, NCURSES_BOOL z)
-{
-	T((T_CALLED("notimeout(%p,%#lx)"), (const void *)a1, (long)z)); returnCode(notimeout(a1, z));
-}
-
-
-extern int call_overlay (const WINDOW * a1, WINDOW * z);
-int call_overlay (const WINDOW * a1, WINDOW * z)
-{
-	T((T_CALLED("overlay(%p,%p)"), (const void *)a1, (const void *)z)); returnCode(overlay(a1, z));
-}
-
-
-extern int call_overwrite (const WINDOW * a1, WINDOW * z);
-int call_overwrite (const WINDOW * a1, WINDOW * z)
-{
-	T((T_CALLED("overwrite(%p,%p)"), (const void *)a1, (const void *)z)); returnCode(overwrite(a1, z));
-}
-
-
-extern int call_pair_content (short a1, short * a2, short * z);
-int call_pair_content (short a1, short * a2, short * z)
-{
-	T((T_CALLED("pair_content(%#lx,%p,%p)"), (long)a1, (const void *)a2, (const void *)z)); returnCode(pair_content(a1, a2, z));
-}
-
-
-extern int call_PAIR_NUMBER (int z);
-int call_PAIR_NUMBER (int z)
-{
-	T((T_CALLED("PAIR_NUMBER(%d)"), z)); returnCode(((int)((((unsigned long)((z)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))) >> 8))));
-}
-
-
-extern int call_pechochar (WINDOW * a1, const chtype z);
-int call_pechochar (WINDOW * a1, const chtype z)
-{
-	T((T_CALLED("pechochar(%p,%s)"), (const void *)a1, _tracechtype2(1,z))); returnCode(pechochar(a1, z));
-}
-
-
-extern int call_pnoutrefresh (WINDOW * a1, int a2, int a3, int a4, int a5, int a6, int z);
-int call_pnoutrefresh (WINDOW * a1, int a2, int a3, int a4, int a5, int a6, int z)
-{
-	T((T_CALLED("pnoutrefresh(%p,%d,%d,%d,%d,%d,%d)"), (const void *)a1, a2, a3, a4, a5, a6, z)); returnCode(pnoutrefresh(a1, a2, a3, a4, a5, a6, z));
-}
-
-
-extern int call_prefresh (WINDOW * a1, int a2, int a3, int a4, int a5, int a6, int z);
-int call_prefresh (WINDOW * a1, int a2, int a3, int a4, int a5, int a6, int z)
-{
-	T((T_CALLED("prefresh(%p,%d,%d,%d,%d,%d,%d)"), (const void *)a1, a2, a3, a4, a5, a6, z)); returnCode(prefresh(a1, a2, a3, a4, a5, a6, z));
-}
-
-
-extern int call_putwin (WINDOW * a1, FILE * z);
-int call_putwin (WINDOW * a1, FILE * z)
-{
-	T((T_CALLED("putwin(%p,%p)"), (const void *)a1, (const void *)z)); returnCode(putwin(a1, z));
-}
-
-
-extern void call_qiflush (void);
-void call_qiflush (void)
-{
-	T((T_CALLED("qiflush()"))); qiflush();
-	returnVoid;
-}
-
-
-extern int call_raw (void);
-int call_raw (void)
-{
-	T((T_CALLED("raw()"))); returnCode(raw());
-}
-
-
-extern int call_redrawwin (WINDOW * z);
-int call_redrawwin (WINDOW * z)
-{
-	T((T_CALLED("redrawwin(%p)"), (const void *)z)); returnCode(wredrawln(z, 0, ((z) ? (z)->_maxy+1 : -1)));
-}
-
-
-extern int call_refresh (void);
-int call_refresh (void)
-{
-	T((T_CALLED("refresh()"))); returnCode(wrefresh(stdscr));
-}
-
-
-extern int call_resetty (void);
-int call_resetty (void)
-{
-	T((T_CALLED("resetty()"))); returnCode(resetty());
-}
-
-
-extern int call_reset_prog_mode (void);
-int call_reset_prog_mode (void)
-{
-	T((T_CALLED("reset_prog_mode()"))); returnCode(reset_prog_mode());
-}
-
-
-extern int call_reset_shell_mode (void);
-int call_reset_shell_mode (void)
-{
-	T((T_CALLED("reset_shell_mode()"))); returnCode(reset_shell_mode());
-}
-
-
-extern int call_ripoffline (int a1, int(* z)(WINDOW * a2, int));
-int call_ripoffline (int a1, int(* z)(WINDOW * a2, int))
-{
-	return ripoffline(a1, z) ;
-}
-
-
-extern int call_savetty (void);
-int call_savetty (void)
-{
-	T((T_CALLED("savetty()"))); returnCode(savetty());
-}
-
-
-extern int call_scr_dump (const char * z);
-int call_scr_dump (const char * z)
-{
-	T((T_CALLED("scr_dump(%s)"), _nc_visbuf2(0,z))); returnCode(scr_dump(z));
-}
-
-
-extern int call_scr_init (const char * z);
-int call_scr_init (const char * z)
-{
-	T((T_CALLED("scr_init(%s)"), _nc_visbuf2(0,z))); returnCode(scr_init(z));
-}
-
-
-extern int call_scrl (int z);
-int call_scrl (int z)
-{
-	T((T_CALLED("scrl(%d)"), z)); returnCode(wscrl(stdscr,(z)));
-}
-
-
-extern int call_scroll (WINDOW * z);
-int call_scroll (WINDOW * z)
-{
-	T((T_CALLED("scroll(%p)"), (const void *)z)); returnCode(wscrl(z,1));
-}
-
-
-extern int call_scrollok (WINDOW * a1, NCURSES_BOOL z);
-int call_scrollok (WINDOW * a1, NCURSES_BOOL z)
-{
-	T((T_CALLED("scrollok(%p,%#lx)"), (const void *)a1, (long)z)); returnCode(scrollok(a1, z));
-}
-
-
-extern int call_scr_restore (const char * z);
-int call_scr_restore (const char * z)
-{
-	T((T_CALLED("scr_restore(%s)"), _nc_visbuf2(0,z))); returnCode(scr_restore(z));
-}
-
-
-extern int call_scr_set (const char * z);
-int call_scr_set (const char * z)
-{
-	T((T_CALLED("scr_set(%s)"), _nc_visbuf2(0,z))); returnCode(scr_set(z));
-}
-
-
-extern int call_setscrreg (int a1, int z);
-int call_setscrreg (int a1, int z)
-{
-	T((T_CALLED("setscrreg(%d,%d)"), a1, z)); returnCode(wsetscrreg(stdscr,(a1),(z)));
-}
-
-
-extern SCREEN * call_set_term (SCREEN * z);
-SCREEN * call_set_term (SCREEN * z)
-{
-	T((T_CALLED("set_term(%p)"), (const void *)z)); returnSP(set_term(z));
-}
-
-
-extern int call_slk_attroff (const chtype z);
-int call_slk_attroff (const chtype z)
-{
-	T((T_CALLED("slk_attroff(%s)"), _tracechtype2(0,z))); returnCode(slk_attroff(z));
-}
-
-
-#if USE_WIDEC_SUPPORT
-extern int call_slk_attr_off (const attr_t a1, void * z);
-int call_slk_attr_off (const attr_t a1, void * z)
-{
-	T((T_CALLED("slk_attr_off(%s,%p)"), _traceattr2(0,a1), (const void *)z)); returnCode(((z) ? (-1) : slk_attroff(a1)));
-}
-#endif
-
-
-extern int call_slk_attron (const chtype z);
-int call_slk_attron (const chtype z)
-{
-	T((T_CALLED("slk_attron(%s)"), _tracechtype2(0,z))); returnCode(slk_attron(z));
-}
-
-
-#if USE_WIDEC_SUPPORT
-extern int call_slk_attr_on (attr_t a1, void * z);
-int call_slk_attr_on (attr_t a1, void * z)
-{
-	T((T_CALLED("slk_attr_on(%s,%p)"), _traceattr2(0,a1), (const void *)z)); returnCode(((z) ? (-1) : slk_attron(a1)));
-}
-#endif
-
-
-extern int call_slk_attrset (const chtype z);
-int call_slk_attrset (const chtype z)
-{
-	T((T_CALLED("slk_attrset(%s)"), _tracechtype2(0,z))); returnCode(slk_attrset(z));
-}
-
-
-extern attr_t call_slk_attr (void);
-attr_t call_slk_attr (void)
-{
-	T((T_CALLED("slk_attr()"))); returnIntAttr((attr_t)slk_attr());
-}
-
-
-extern int call_slk_attr_set (const attr_t a1, short a2, void * z);
-int call_slk_attr_set (const attr_t a1, short a2, void * z)
-{
-	T((T_CALLED("slk_attr_set(%s,%#lx,%p)"), _traceattr2(0,a1), (long)a2, (const void *)z)); returnCode(slk_attr_set(a1, a2, z));
-}
-
-
-extern int call_slk_clear (void);
-int call_slk_clear (void)
-{
-	T((T_CALLED("slk_clear()"))); returnCode(slk_clear());
-}
-
-
-extern int call_slk_color (short z);
-int call_slk_color (short z)
-{
-	T((T_CALLED("slk_color(%#lx)"), (long)z)); returnCode(slk_color(z));
-}
-
-
-extern int call_slk_init (int z);
-int call_slk_init (int z)
-{
-	T((T_CALLED("slk_init(%d)"), z)); returnCode(slk_init(z));
-}
-
-
-extern char * call_slk_label (int z);
-char * call_slk_label (int z)
-{
-	T((T_CALLED("slk_label(%d)"), z)); returnPtr(slk_label(z));
-}
-
-
-extern int call_slk_noutrefresh (void);
-int call_slk_noutrefresh (void)
-{
-	T((T_CALLED("slk_noutrefresh()"))); returnCode(slk_noutrefresh());
-}
-
-
-extern int call_slk_refresh (void);
-int call_slk_refresh (void)
-{
-	T((T_CALLED("slk_refresh()"))); returnCode(slk_refresh());
-}
-
-
-extern int call_slk_restore (void);
-int call_slk_restore (void)
-{
-	T((T_CALLED("slk_restore()"))); returnCode(slk_restore());
-}
-
-
-extern int call_slk_set (int a1, const char * a2, int z);
-int call_slk_set (int a1, const char * a2, int z)
-{
-	T((T_CALLED("slk_set(%d,%s,%d)"), a1, _nc_visbuf2(1,a2), z)); returnCode(slk_set(a1, a2, z));
-}
-
-
-extern int call_slk_touch (void);
-int call_slk_touch (void)
-{
-	T((T_CALLED("slk_touch()"))); returnCode(slk_touch());
-}
-
-
-extern int call_standout (void);
-int call_standout (void)
-{
-	T((T_CALLED("standout()"))); returnIntAttr((attr_t)(((stdscr) ? ((stdscr)->_attrs = (attr_t)(((chtype)((1U)) << ((8) + 8))), (0)) : (-1))));
-}
-
-
-extern int call_standend (void);
-int call_standend (void)
-{
-	T((T_CALLED("standend()"))); returnIntAttr((attr_t)(((stdscr) ? ((stdscr)->_attrs = (attr_t)((1U - 1U)), (0)) : (-1))));
-}
-
-
-extern int call_start_color (void);
-int call_start_color (void)
-{
-	T((T_CALLED("start_color()"))); returnCode(start_color());
-}
-
-
-extern WINDOW * call_subpad (WINDOW * a1, int a2, int a3, int a4, int z);
-WINDOW * call_subpad (WINDOW * a1, int a2, int a3, int a4, int z)
-{
-	T((T_CALLED("subpad(%p,%d,%d,%d,%d)"), (const void *)a1, a2, a3, a4, z)); returnWin(subpad(a1, a2, a3, a4, z));
-}
-
-
-extern WINDOW * call_subwin (WINDOW * a1, int a2, int a3, int a4, int z);
-WINDOW * call_subwin (WINDOW * a1, int a2, int a3, int a4, int z)
-{
-	T((T_CALLED("subwin(%p,%d,%d,%d,%d)"), (const void *)a1, a2, a3, a4, z)); returnWin(subwin(a1, a2, a3, a4, z));
-}
-
-
-extern int call_syncok (WINDOW * a1, NCURSES_BOOL z);
-int call_syncok (WINDOW * a1, NCURSES_BOOL z)
-{
-	T((T_CALLED("syncok(%p,%#lx)"), (const void *)a1, (long)z)); returnCode(syncok(a1, z));
-}
-
-
-extern chtype call_termattrs (void);
-chtype call_termattrs (void)
-{
-	T((T_CALLED("termattrs()"))); returnChtype(termattrs());
-}
-
-
-extern char * call_termname (void);
-char * call_termname (void)
-{
-	T((T_CALLED("termname()"))); returnPtr(termname());
-}
-
-
-extern void call_timeout (int z);
-void call_timeout (int z)
-{
-	T((T_CALLED("timeout(%d)"), z)); wtimeout(stdscr,(z));
-	returnVoid;
-}
-
-
-extern int call_touchline (WINDOW * a1, int a2, int z);
-int call_touchline (WINDOW * a1, int a2, int z)
-{
-	T((T_CALLED("touchline(%p,%d,%d)"), (const void *)a1, a2, z)); returnCode(wtouchln((a1), a2, z, 1));
-}
-
-
-extern int call_touchwin (WINDOW * z);
-int call_touchwin (WINDOW * z)
-{
-	T((T_CALLED("touchwin(%p)"), (const void *)z)); returnCode(wtouchln((z), 0, ((z) ? ((z)->_maxy + 1) : (-1)), 1));
-}
-
-
-extern int call_typeahead (int z);
-int call_typeahead (int z)
-{
-	T((T_CALLED("typeahead(%d)"), z)); returnCode(typeahead(z));
-}
-
-
-extern int call_ungetch (int z);
-int call_ungetch (int z)
-{
-	T((T_CALLED("ungetch(%d)"), z)); returnCode(ungetch(z));
-}
-
-
-extern int call_untouchwin (WINDOW * z);
-int call_untouchwin (WINDOW * z)
-{
-	T((T_CALLED("untouchwin(%p)"), (const void *)z)); returnCode(wtouchln((z), 0, ((z) ? ((z)->_maxy + 1) : (-1)), 0));
-}
-
-
-extern void call_use_env (NCURSES_BOOL z);
-void call_use_env (NCURSES_BOOL z)
-{
-	T((T_CALLED("use_env(%#lx)"), (long)z)); use_env(z);
-	returnVoid;
-}
-
-
-extern void call_use_tioctl (NCURSES_BOOL z);
-void call_use_tioctl (NCURSES_BOOL z)
-{
-	T((T_CALLED("use_tioctl(%#lx)"), (long)z)); use_tioctl(z);
-	returnVoid;
-}
-
-
-extern int call_vidattr (chtype z);
-int call_vidattr (chtype z)
-{
-	T((T_CALLED("vidattr(%s)"), _tracechtype2(0,z))); returnCode(vidattr(z));
-}
-
-
-extern int call_vidputs (chtype a1, NCURSES_OUTC z);
-int call_vidputs (chtype a1, NCURSES_OUTC z)
-{
-	T((T_CALLED("vidputs(%s,%#lx)"), _tracechtype2(0,a1), (long)z)); returnCode(vidputs(a1, z));
-}
-
-
-extern int call_vline (chtype a1, int z);
-int call_vline (chtype a1, int z)
-{
-	T((T_CALLED("vline(%s,%d)"), _tracechtype2(0,a1), z)); returnCode(wvline(stdscr, a1, (z)));
-}
-
-
-extern int call_vwprintw (WINDOW * a1, const char * a2, va_list z);
-int call_vwprintw (WINDOW * a1, const char * a2, va_list z)
-{
-	T((T_CALLED("vwprintw(%p,%s,%s)"), (const void *)a1, _nc_visbuf2(1,a2), "va_list")); returnCode(vwprintw(a1, a2, z));
-}
-
-
-extern int call_vw_printw (WINDOW * a1, const char * a2, va_list z);
-int call_vw_printw (WINDOW * a1, const char * a2, va_list z)
-{
-	T((T_CALLED("vw_printw(%p,%s,%s)"), (const void *)a1, _nc_visbuf2(1,a2), "va_list")); returnCode(vwprintw(a1, a2, z));
-}
-
-
-extern int call_vwscanw (WINDOW * a1, const char * a2, va_list z);
-int call_vwscanw (WINDOW * a1, const char * a2, va_list z)
-{
-	T((T_CALLED("vwscanw(%p,%s,%s)"), (const void *)a1, _nc_visbuf2(1,a2), "va_list")); returnCode(vwscanw(a1, a2, z));
-}
-
-
-extern int call_vw_scanw (WINDOW * a1, const char * a2, va_list z);
-int call_vw_scanw (WINDOW * a1, const char * a2, va_list z)
-{
-	T((T_CALLED("vw_scanw(%p,%s,%s)"), (const void *)a1, _nc_visbuf2(1,a2), "va_list")); returnCode(vwscanw(a1, a2, z));
-}
-
-
-extern int call_waddch (WINDOW * a1, const chtype z);
-int call_waddch (WINDOW * a1, const chtype z)
-{
-	T((T_CALLED("waddch(%p,%s)"), (const void *)a1, _tracechtype2(1,z))); returnCode(waddch(a1, z));
-}
-
-
-extern int call_waddchnstr (WINDOW * a1, const chtype * a2, int z);
-int call_waddchnstr (WINDOW * a1, const chtype * a2, int z)
-{
-	T((T_CALLED("waddchnstr(%p,%p,%d)"), (const void *)a1, (const void *)a2, z)); returnCode(waddchnstr(a1, a2, z));
-}
-
-
-extern int call_waddchstr (WINDOW * a1, const chtype * z);
-int call_waddchstr (WINDOW * a1, const chtype * z)
-{
-	T((T_CALLED("waddchstr(%p,%p)"), (const void *)a1, (const void *)z)); returnCode(waddchnstr(a1,z,-1));
-}
-
-
-extern int call_waddnstr (WINDOW * a1, const char * a2, int z);
-int call_waddnstr (WINDOW * a1, const char * a2, int z)
-{
-	T((T_CALLED("waddnstr(%p,%s,%d)"), (const void *)a1, _nc_visbuf2(1,a2), z)); returnCode(waddnstr(a1, a2, z));
-}
-
-
-extern int call_waddstr (WINDOW * a1, const char * z);
-int call_waddstr (WINDOW * a1, const char * z)
-{
-	T((T_CALLED("waddstr(%p,%s)"), (const void *)a1, _nc_visbuf2(1,z))); returnCode(waddnstr(a1,z,-1));
-}
-
-
-extern int call_wattron (WINDOW * a1, int z);
-int call_wattron (WINDOW * a1, int z)
-{
-	T((T_CALLED("wattron(%p,%d)"), (const void *)a1, z)); returnCode(wattr_on(a1, (attr_t)(z), ((void*)0)));
-}
-
-
-extern int call_wattroff (WINDOW * a1, int z);
-int call_wattroff (WINDOW * a1, int z)
-{
-	T((T_CALLED("wattroff(%p,%d)"), (const void *)a1, z)); returnCode(wattr_off(a1, (attr_t)(z), ((void*)0)));
-}
-
-
-extern int call_wattrset (WINDOW * a1, int z);
-int call_wattrset (WINDOW * a1, int z)
-{
-	T((T_CALLED("wattrset(%p,%d)"), (const void *)a1, z)); returnIntAttr((attr_t)((a1) ? ((a1)->_attrs = (attr_t)(z), (0)) : (-1)));
-}
-
-
-extern int call_wattr_get (WINDOW * a1, attr_t * a2, short * a3, void * z);
-int call_wattr_get (WINDOW * a1, attr_t * a2, short * a3, void * z)
-{
-	T((T_CALLED("wattr_get(%p,%p,%p,%p)"), (const void *)a1, (const void *)a2, (const void *)a3, (const void *)z)); returnCode(((void)(((a2) != (void *)0) ? (*(a2) = (a1) ? (a1)->_attrs : 0) : (0)), (void)(((a3) != (void *)0) ? (*(a3) = (short) ((a1) ? ((int)((((unsigned long)(((a1)->_attrs)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))) >> 8))) : 0)) : (0)), (0)));
-}
-
-
-extern int call_wattr_on (WINDOW * a1, attr_t a2, void * z);
-int call_wattr_on (WINDOW * a1, attr_t a2, void * z)
-{
-	T((T_CALLED("wattr_on(%p,%s,%p)"), (const void *)a1, _traceattr2(1,a2), (const void *)z)); returnCode(wattr_on(a1, a2, z));
-}
-
-
-extern int call_wattr_off (WINDOW * a1, attr_t a2, void * z);
-int call_wattr_off (WINDOW * a1, attr_t a2, void * z)
-{
-	T((T_CALLED("wattr_off(%p,%s,%p)"), (const void *)a1, _traceattr2(1,a2), (const void *)z)); returnCode(wattr_off(a1, a2, z));
-}
-
-
-extern int call_wattr_set (WINDOW * a1, attr_t a2, short a3, void * z);
-int call_wattr_set (WINDOW * a1, attr_t a2, short a3, void * z)
-{
-	T((T_CALLED("wattr_set(%p,%s,%#lx,%p)"), (const void *)a1, _traceattr2(1,a2), (long)a3, (const void *)z)); returnCode((((a1) ? ((a1)->_attrs = (((a2) & ~((chtype)((((1U) << 8) - 1U)) << ((0) + 8))) | (attr_t)((chtype)(((a3))) << ((0) + 8)))) : (0)), (0)));
-}
-
-
-extern int call_wbkgd (WINDOW * a1, chtype z);
-int call_wbkgd (WINDOW * a1, chtype z)
-{
-	T((T_CALLED("wbkgd(%p,%s)"), (const void *)a1, _tracechtype2(1,z))); returnCode(wbkgd(a1, z));
-}
-
-
-extern void call_wbkgdset (WINDOW * a1, chtype z);
-void call_wbkgdset (WINDOW * a1, chtype z)
-{
-	T((T_CALLED("wbkgdset(%p,%s)"), (const void *)a1, _tracechtype2(1,z))); wbkgdset(a1, z);
-	returnVoid;
-}
-
-
-extern int call_wborder (WINDOW * a1, chtype a2, chtype a3, chtype a4, chtype a5, chtype a6, chtype a7, chtype a8, chtype z);
-int call_wborder (WINDOW * a1, chtype a2, chtype a3, chtype a4, chtype a5, chtype a6, chtype a7, chtype a8, chtype z)
-{
-	T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"), (const void *)a1, _tracechtype2(1,a2), _tracechtype2(2,a3), _tracechtype2(3,a4), _tracechtype2(4,a5), _tracechtype2(5,a6), _tracechtype2(6,a7), _tracechtype2(7,a8), _tracechtype2(8,z))); returnCode(wborder(a1, a2, a3, a4, a5, a6, a7, a8, z));
-}
-
-
-extern int call_wchgat (WINDOW * a1, int a2, attr_t a3, short a4, const void * z);
-int call_wchgat (WINDOW * a1, int a2, attr_t a3, short a4, const void * z)
-{
-	T((T_CALLED("wchgat(%p,%d,%s,%#lx,%p)"), (const void *)a1, a2, _traceattr2(2,a3), (long)a4, (const void *)z)); returnCode(wchgat(a1, a2, a3, a4, z));
-}
-
-
-extern int call_wclear (WINDOW * z);
-int call_wclear (WINDOW * z)
-{
-	T((T_CALLED("wclear(%p)"), (const void *)z)); returnCode(wclear(z));
-}
-
-
-extern int call_wclrtobot (WINDOW * z);
-int call_wclrtobot (WINDOW * z)
-{
-	T((T_CALLED("wclrtobot(%p)"), (const void *)z)); returnCode(wclrtobot(z));
-}
-
-
-extern int call_wclrtoeol (WINDOW * z);
-int call_wclrtoeol (WINDOW * z)
-{
-	T((T_CALLED("wclrtoeol(%p)"), (const void *)z)); returnCode(wclrtoeol(z));
-}
-
-
-extern int call_wcolor_set (WINDOW * a1, short a2, void * z);
-int call_wcolor_set (WINDOW * a1, short a2, void * z)
-{
-	T((T_CALLED("wcolor_set(%p,%#lx,%p)"), (const void *)a1, (long)a2, (const void *)z)); returnCode(wcolor_set(a1, a2, z));
-}
-
-
-extern void call_wcursyncup (WINDOW * z);
-void call_wcursyncup (WINDOW * z)
-{
-	T((T_CALLED("wcursyncup(%p)"), (const void *)z)); wcursyncup(z);
-	returnVoid;
-}
-
-
-extern int call_wdelch (WINDOW * z);
-int call_wdelch (WINDOW * z)
-{
-	T((T_CALLED("wdelch(%p)"), (const void *)z)); returnCode(wdelch(z));
-}
-
-
-extern int call_wdeleteln (WINDOW * z);
-int call_wdeleteln (WINDOW * z)
-{
-	T((T_CALLED("wdeleteln(%p)"), (const void *)z)); returnCode(winsdelln(z,-1));
-}
-
-
-extern int call_wechochar (WINDOW * a1, const chtype z);
-int call_wechochar (WINDOW * a1, const chtype z)
-{
-	T((T_CALLED("wechochar(%p,%s)"), (const void *)a1, _tracechtype2(1,z))); returnCode(wechochar(a1, z));
-}
-
-
-extern int call_werase (WINDOW * z);
-int call_werase (WINDOW * z)
-{
-	T((T_CALLED("werase(%p)"), (const void *)z)); returnCode(werase(z));
-}
-
-
-extern int call_wgetch (WINDOW * z);
-int call_wgetch (WINDOW * z)
-{
-	T((T_CALLED("wgetch(%p)"), (const void *)z)); returnCode(wgetch(z));
-}
-
-
-extern int call_wgetnstr (WINDOW * a1, char * a2, int z);
-int call_wgetnstr (WINDOW * a1, char * a2, int z)
-{
-	T((T_CALLED("wgetnstr(%p,%s,%d)"), (const void *)a1, _nc_visbuf2(1,a2), z)); returnCode(wgetnstr(a1, a2, z));
-}
-
-
-extern int call_wgetstr (WINDOW * a1, char * z);
-int call_wgetstr (WINDOW * a1, char * z)
-{
-	T((T_CALLED("wgetstr(%p,%s)"), (const void *)a1, _nc_visbuf2(1,z))); returnCode(wgetnstr(a1, z, -1));
-}
-
-
-extern int call_whline (WINDOW * a1, chtype a2, int z);
-int call_whline (WINDOW * a1, chtype a2, int z)
-{
-	T((T_CALLED("whline(%p,%s,%d)"), (const void *)a1, _tracechtype2(1,a2), z)); returnCode(whline(a1, a2, z));
-}
-
-
-extern chtype call_winch (WINDOW * z);
-chtype call_winch (WINDOW * z)
-{
-	T((T_CALLED("winch(%p)"), (const void *)z)); returnChtype(winch(z));
-}
-
-
-extern int call_winchnstr (WINDOW * a1, chtype * a2, int z);
-int call_winchnstr (WINDOW * a1, chtype * a2, int z)
-{
-	T((T_CALLED("winchnstr(%p,%p,%d)"), (const void *)a1, (const void *)a2, z)); returnCode(winchnstr(a1, a2, z));
-}
-
-
-extern int call_winchstr (WINDOW * a1, chtype * z);
-int call_winchstr (WINDOW * a1, chtype * z)
-{
-	T((T_CALLED("winchstr(%p,%p)"), (const void *)a1, (const void *)z)); returnCode(winchnstr(a1, z, -1));
-}
-
-
-extern int call_winnstr (WINDOW * a1, char * a2, int z);
-int call_winnstr (WINDOW * a1, char * a2, int z)
-{
-	return winnstr(a1, a2, z) ;
-}
-
-
-extern int call_winsch (WINDOW * a1, chtype z);
-int call_winsch (WINDOW * a1, chtype z)
-{
-	T((T_CALLED("winsch(%p,%s)"), (const void *)a1, _tracechtype2(1,z))); returnCode(winsch(a1, z));
-}
-
-
-extern int call_winsdelln (WINDOW * a1, int z);
-int call_winsdelln (WINDOW * a1, int z)
-{
-	T((T_CALLED("winsdelln(%p,%d)"), (const void *)a1, z)); returnCode(winsdelln(a1, z));
-}
-
-
-extern int call_winsertln (WINDOW * z);
-int call_winsertln (WINDOW * z)
-{
-	T((T_CALLED("winsertln(%p)"), (const void *)z)); returnCode(winsdelln(z,1));
-}
-
-
-extern int call_winsnstr (WINDOW * a1, const char * a2, int z);
-int call_winsnstr (WINDOW * a1, const char * a2, int z)
-{
-	T((T_CALLED("winsnstr(%p,%s,%d)"), (const void *)a1, _nc_visbuf2(1,a2), z)); returnCode(winsnstr(a1, a2, z));
-}
-
-
-extern int call_winsstr (WINDOW * a1, const char * z);
-int call_winsstr (WINDOW * a1, const char * z)
-{
-	T((T_CALLED("winsstr(%p,%s)"), (const void *)a1, _nc_visbuf2(1,z))); returnCode(winsnstr(a1, z, -1));
-}
-
-
-extern int call_winstr (WINDOW * a1, char * z);
-int call_winstr (WINDOW * a1, char * z)
-{
-	T((T_CALLED("winstr(%p,%s)"), (const void *)a1, _nc_visbuf2(1,z))); returnCode(winnstr(a1, z, -1));
-}
-
-
-extern int call_wmove (WINDOW * a1, int a2, int z);
-int call_wmove (WINDOW * a1, int a2, int z)
-{
-	T((T_CALLED("wmove(%p,%d,%d)"), (const void *)a1, a2, z)); returnCode(wmove(a1, a2, z));
-}
-
-
-extern int call_wnoutrefresh (WINDOW * z);
-int call_wnoutrefresh (WINDOW * z)
-{
-	T((T_CALLED("wnoutrefresh(%p)"), (const void *)z)); returnCode(wnoutrefresh(z));
-}
-
-
-extern int call_wredrawln (WINDOW * a1, int a2, int z);
-int call_wredrawln (WINDOW * a1, int a2, int z)
-{
-	T((T_CALLED("wredrawln(%p,%d,%d)"), (const void *)a1, a2, z)); returnCode(wredrawln(a1, a2, z));
-}
-
-
-extern int call_wrefresh (WINDOW * z);
-int call_wrefresh (WINDOW * z)
-{
-	T((T_CALLED("wrefresh(%p)"), (const void *)z)); returnCode(wrefresh(z));
-}
-
-
-extern int call_wscrl (WINDOW * a1, int z);
-int call_wscrl (WINDOW * a1, int z)
-{
-	T((T_CALLED("wscrl(%p,%d)"), (const void *)a1, z)); returnCode(wscrl(a1, z));
-}
-
-
-extern int call_wsetscrreg (WINDOW * a1, int a2, int z);
-int call_wsetscrreg (WINDOW * a1, int a2, int z)
-{
-	T((T_CALLED("wsetscrreg(%p,%d,%d)"), (const void *)a1, a2, z)); returnCode(wsetscrreg(a1, a2, z));
-}
-
-
-extern int call_wstandout (WINDOW * z);
-int call_wstandout (WINDOW * z)
-{
-	T((T_CALLED("wstandout(%p)"), (const void *)z)); returnIntAttr((attr_t)(((z) ? ((z)->_attrs = (attr_t)(((chtype)((1U)) << ((8) + 8))), (0)) : (-1))));
-}
-
-
-extern int call_wstandend (WINDOW * z);
-int call_wstandend (WINDOW * z)
-{
-	T((T_CALLED("wstandend(%p)"), (const void *)z)); returnIntAttr((attr_t)(((z) ? ((z)->_attrs = (attr_t)((1U - 1U)), (0)) : (-1))));
-}
-
-
-extern void call_wsyncdown (WINDOW * z);
-void call_wsyncdown (WINDOW * z)
-{
-	T((T_CALLED("wsyncdown(%p)"), (const void *)z)); wsyncdown(z);
-	returnVoid;
-}
-
-
-extern void call_wsyncup (WINDOW * z);
-void call_wsyncup (WINDOW * z)
-{
-	T((T_CALLED("wsyncup(%p)"), (const void *)z)); wsyncup(z);
-	returnVoid;
-}
-
-
-extern void call_wtimeout (WINDOW * a1, int z);
-void call_wtimeout (WINDOW * a1, int z)
-{
-	T((T_CALLED("wtimeout(%p,%d)"), (const void *)a1, z)); wtimeout(a1, z);
-	returnVoid;
-}
-
-
-extern int call_wtouchln (WINDOW * a1, int a2, int a3, int z);
-int call_wtouchln (WINDOW * a1, int a2, int a3, int z)
-{
-	T((T_CALLED("wtouchln(%p,%d,%d,%d)"), (const void *)a1, a2, a3, z)); returnCode(wtouchln(a1, a2, a3, z));
-}
-
-
-extern int call_wvline (WINDOW * a1, chtype a2, int z);
-int call_wvline (WINDOW * a1, chtype a2, int z)
-{
-	T((T_CALLED("wvline(%p,%s,%d)"), (const void *)a1, _tracechtype2(1,a2), z)); returnCode(wvline(a1, a2, z));
-}
-
-
-extern int call_tigetflag (const char * z);
-int call_tigetflag (const char * z)
-{
-	T((T_CALLED("tigetflag(%s)"), _nc_visbuf2(0,z))); returnCode(tigetflag(z));
-}
-
-
-extern int call_tigetnum (const char * z);
-int call_tigetnum (const char * z)
-{
-	T((T_CALLED("tigetnum(%s)"), _nc_visbuf2(0,z))); returnCode(tigetnum(z));
-}
-
-
-extern char * call_tigetstr (const char * z);
-char * call_tigetstr (const char * z)
-{
-	T((T_CALLED("tigetstr(%s)"), _nc_visbuf2(0,z))); returnPtr(tigetstr(z));
-}
-
-
-extern int call_putp (const char * z);
-int call_putp (const char * z)
-{
-	T((T_CALLED("putp(%s)"), _nc_visbuf2(0,z))); returnCode(putp(z));
-}
-
-
-extern int call_getattrs (const WINDOW * z);
-int call_getattrs (const WINDOW * z)
-{
-	T((T_CALLED("getattrs(%p)"), (const void *)z)); returnCode((int)((z) ? (z)->_attrs : (1U - 1U)));
-}
-
-
-extern int call_getcurx (const WINDOW * z);
-int call_getcurx (const WINDOW * z)
-{
-	T((T_CALLED("getcurx(%p)"), (const void *)z)); returnCode(((z) ? (z)->_curx : (-1)));
-}
-
-
-extern int call_getcury (const WINDOW * z);
-int call_getcury (const WINDOW * z)
-{
-	T((T_CALLED("getcury(%p)"), (const void *)z)); returnCode(((z) ? (z)->_cury : (-1)));
-}
-
-
-extern int call_getbegx (const WINDOW * z);
-int call_getbegx (const WINDOW * z)
-{
-	T((T_CALLED("getbegx(%p)"), (const void *)z)); returnCode(((z) ? (z)->_begx : (-1)));
-}
-
-
-extern int call_getbegy (const WINDOW * z);
-int call_getbegy (const WINDOW * z)
-{
-	T((T_CALLED("getbegy(%p)"), (const void *)z)); returnCode(((z) ? (z)->_begy : (-1)));
-}
-
-
-extern int call_getmaxx (const WINDOW * z);
-int call_getmaxx (const WINDOW * z)
-{
-	T((T_CALLED("getmaxx(%p)"), (const void *)z)); returnCode(((z) ? ((z)->_maxx + 1) : (-1)));
-}
-
-
-extern int call_getmaxy (const WINDOW * z);
-int call_getmaxy (const WINDOW * z)
-{
-	T((T_CALLED("getmaxy(%p)"), (const void *)z)); returnCode(((z) ? ((z)->_maxy + 1) : (-1)));
-}
-
-
-extern int call_getparx (const WINDOW * z);
-int call_getparx (const WINDOW * z)
-{
-	T((T_CALLED("getparx(%p)"), (const void *)z)); returnCode(((z) ? (z)->_parx : (-1)));
-}
-
-
-extern int call_getpary (const WINDOW * z);
-int call_getpary (const WINDOW * z)
-{
-	T((T_CALLED("getpary(%p)"), (const void *)z)); returnCode(((z) ? (z)->_pary : (-1)));
-}
-
-
-extern WINDOW * call_wgetparent (const WINDOW * z);
-WINDOW * call_wgetparent (const WINDOW * z)
-{
-	T((T_CALLED("wgetparent(%p)"), (const void *)z)); returnWin(((z) ? (z)->_parent : 0));
-}
-
-
-extern NCURSES_BOOL call_is_cleared (const WINDOW * z);
-NCURSES_BOOL call_is_cleared (const WINDOW * z)
-{
-	T((T_CALLED("is_cleared(%p)"), (const void *)z)); returnBool(((z) ? (z)->_clear : 0));
-}
-
-
-extern NCURSES_BOOL call_is_idcok (const WINDOW * z);
-NCURSES_BOOL call_is_idcok (const WINDOW * z)
-{
-	T((T_CALLED("is_idcok(%p)"), (const void *)z)); returnBool(((z) ? (z)->_idcok : 0));
-}
-
-
-extern NCURSES_BOOL call_is_idlok (const WINDOW * z);
-NCURSES_BOOL call_is_idlok (const WINDOW * z)
-{
-	T((T_CALLED("is_idlok(%p)"), (const void *)z)); returnBool(((z) ? (z)->_idlok : 0));
-}
-
-
-extern NCURSES_BOOL call_is_immedok (const WINDOW * z);
-NCURSES_BOOL call_is_immedok (const WINDOW * z)
-{
-	T((T_CALLED("is_immedok(%p)"), (const void *)z)); returnBool(((z) ? (z)->_immed : 0));
-}
-
-
-extern NCURSES_BOOL call_is_keypad (const WINDOW * z);
-NCURSES_BOOL call_is_keypad (const WINDOW * z)
-{
-	T((T_CALLED("is_keypad(%p)"), (const void *)z)); returnBool(((z) ? (z)->_use_keypad : 0));
-}
-
-
-extern NCURSES_BOOL call_is_leaveok (const WINDOW * z);
-NCURSES_BOOL call_is_leaveok (const WINDOW * z)
-{
-	T((T_CALLED("is_leaveok(%p)"), (const void *)z)); returnBool(((z) ? (z)->_leaveok : 0));
-}
-
-
-extern NCURSES_BOOL call_is_nodelay (const WINDOW * z);
-NCURSES_BOOL call_is_nodelay (const WINDOW * z)
-{
-	T((T_CALLED("is_nodelay(%p)"), (const void *)z)); returnBool(((z) ? ((z)->_delay == 0) : 0));
-}
-
-
-extern NCURSES_BOOL call_is_notimeout (const WINDOW * z);
-NCURSES_BOOL call_is_notimeout (const WINDOW * z)
-{
-	T((T_CALLED("is_notimeout(%p)"), (const void *)z)); returnBool(((z) ? (z)->_notimeout : 0));
-}
-
-
-extern NCURSES_BOOL call_is_pad (const WINDOW * z);
-NCURSES_BOOL call_is_pad (const WINDOW * z)
-{
-	T((T_CALLED("is_pad(%p)"), (const void *)z)); returnBool(((z) ? ((z)->_flags & 0x10) != 0 : 0));
-}
-
-
-extern NCURSES_BOOL call_is_scrollok (const WINDOW * z);
-NCURSES_BOOL call_is_scrollok (const WINDOW * z)
-{
-	T((T_CALLED("is_scrollok(%p)"), (const void *)z)); returnBool(((z) ? (z)->_scroll : 0));
-}
-
-
-extern NCURSES_BOOL call_is_subwin (const WINDOW * z);
-NCURSES_BOOL call_is_subwin (const WINDOW * z)
-{
-	T((T_CALLED("is_subwin(%p)"), (const void *)z)); returnBool(((z) ? ((z)->_flags & 0x01) != 0 : 0));
-}
-
-
-extern NCURSES_BOOL call_is_syncok (const WINDOW * z);
-NCURSES_BOOL call_is_syncok (const WINDOW * z)
-{
-	T((T_CALLED("is_syncok(%p)"), (const void *)z)); returnBool(((z) ? (z)->_sync : 0));
-}
-
-
-extern int call_wgetdelay (const WINDOW * z);
-int call_wgetdelay (const WINDOW * z)
-{
-	T((T_CALLED("wgetdelay(%p)"), (const void *)z)); returnCode(((z) ? (z)->_delay : 0));
-}
-
-
-extern int call_wgetscrreg (const WINDOW * a1, int * a2, int * z);
-int call_wgetscrreg (const WINDOW * a1, int * a2, int * z)
-{
-	T((T_CALLED("wgetscrreg(%p,%p,%p)"), (const void *)a1, (const void *)a2, (const void *)z)); returnCode(((a1) ? (*(a2) = (a1)->_regtop, *(z) = (a1)->_regbottom, (0)) : (-1)));
-}
-
-
-#if USE_SP_FUNC_SUPPORT
-extern SCREEN * call_new_prescr (void);
-SCREEN * call_new_prescr (void)
-{
-	T((T_CALLED("new_prescr()"))); returnSP(new_prescr());
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___baudrate (SCREEN * z);
-int call_NCURSES_SP_NAME___baudrate (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(baudrate)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(baudrate)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___beep (SCREEN * z);
-int call_NCURSES_SP_NAME___beep (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(beep)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(beep)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern NCURSES_BOOL call_NCURSES_SP_NAME___can_change_color (SCREEN * z);
-NCURSES_BOOL call_NCURSES_SP_NAME___can_change_color (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(can_change_color)(%p)"), (const void *)z)); returnBool(NCURSES_SP_NAME(can_change_color)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___cbreak (SCREEN * z);
-int call_NCURSES_SP_NAME___cbreak (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(cbreak)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(cbreak)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___curs_set (SCREEN * a1, int z);
-int call_NCURSES_SP_NAME___curs_set (SCREEN * a1, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(curs_set)(%p,%d)"), (const void *)a1, z)); returnCode(NCURSES_SP_NAME(curs_set)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___color_content (SCREEN * a1, short a2, short * a3, short * a4, short * z);
-int call_NCURSES_SP_NAME___color_content (SCREEN * a1, short a2, short * a3, short * a4, short * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(color_content)(%p,%#lx,%p,%p,%p)"), (const void *)a1, (long)a2, (const void *)a3, (const void *)a4, (const void *)z)); returnCode(NCURSES_SP_NAME(color_content)(a1, a2, a3, a4, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___def_prog_mode (SCREEN * z);
-int call_NCURSES_SP_NAME___def_prog_mode (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(def_prog_mode)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(def_prog_mode)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___def_shell_mode (SCREEN * z);
-int call_NCURSES_SP_NAME___def_shell_mode (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(def_shell_mode)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(def_shell_mode)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___delay_output (SCREEN * a1, int z);
-int call_NCURSES_SP_NAME___delay_output (SCREEN * a1, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(delay_output)(%p,%d)"), (const void *)a1, z)); returnCode(NCURSES_SP_NAME(delay_output)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___doupdate (SCREEN * z);
-int call_NCURSES_SP_NAME___doupdate (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(doupdate)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(doupdate)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___echo (SCREEN * z);
-int call_NCURSES_SP_NAME___echo (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(echo)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(echo)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___endwin (SCREEN * z);
-int call_NCURSES_SP_NAME___endwin (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(endwin)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(endwin)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern char call_NCURSES_SP_NAME___erasechar (SCREEN * z);
-char call_NCURSES_SP_NAME___erasechar (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(erasechar)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(erasechar)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern void call_NCURSES_SP_NAME___filter (SCREEN * z);
-void call_NCURSES_SP_NAME___filter (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(filter)(%p)"), (const void *)z)); NCURSES_SP_NAME(filter)(z);
-	returnVoid;
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___flash (SCREEN * z);
-int call_NCURSES_SP_NAME___flash (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(flash)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(flash)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___flushinp (SCREEN * z);
-int call_NCURSES_SP_NAME___flushinp (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(flushinp)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(flushinp)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern WINDOW * call_NCURSES_SP_NAME___getwin (SCREEN * a1, FILE * z);
-WINDOW * call_NCURSES_SP_NAME___getwin (SCREEN * a1, FILE * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(getwin)(%p,%p)"), (const void *)a1, (const void *)z)); returnWin(NCURSES_SP_NAME(getwin)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___halfdelay (SCREEN * a1, int z);
-int call_NCURSES_SP_NAME___halfdelay (SCREEN * a1, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(halfdelay)(%p,%d)"), (const void *)a1, z)); returnCode(NCURSES_SP_NAME(halfdelay)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern NCURSES_BOOL call_NCURSES_SP_NAME___has_colors (SCREEN * z);
-NCURSES_BOOL call_NCURSES_SP_NAME___has_colors (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(has_colors)(%p)"), (const void *)z)); returnBool(NCURSES_SP_NAME(has_colors)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern NCURSES_BOOL call_NCURSES_SP_NAME___has_ic (SCREEN * z);
-NCURSES_BOOL call_NCURSES_SP_NAME___has_ic (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(has_ic)(%p)"), (const void *)z)); returnBool(NCURSES_SP_NAME(has_ic)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern NCURSES_BOOL call_NCURSES_SP_NAME___has_il (SCREEN * z);
-NCURSES_BOOL call_NCURSES_SP_NAME___has_il (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(has_il)(%p)"), (const void *)z)); returnBool(NCURSES_SP_NAME(has_il)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___init_color (SCREEN * a1, short a2, short a3, short a4, short z);
-int call_NCURSES_SP_NAME___init_color (SCREEN * a1, short a2, short a3, short a4, short z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(init_color)(%p,%#lx,%#lx,%#lx,%#lx)"), (const void *)a1, (long)a2, (long)a3, (long)a4, (long)z)); returnCode(NCURSES_SP_NAME(init_color)(a1, a2, a3, a4, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___init_pair (SCREEN * a1, short a2, short a3, short z);
-int call_NCURSES_SP_NAME___init_pair (SCREEN * a1, short a2, short a3, short z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(init_pair)(%p,%#lx,%#lx,%#lx)"), (const void *)a1, (long)a2, (long)a3, (long)z)); returnCode(NCURSES_SP_NAME(init_pair)(a1, a2, a3, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___intrflush (SCREEN * a1, WINDOW * a2, NCURSES_BOOL z);
-int call_NCURSES_SP_NAME___intrflush (SCREEN * a1, WINDOW * a2, NCURSES_BOOL z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(intrflush)(%p,%p,%#lx)"), (const void *)a1, (const void *)a2, (long)z)); returnCode(NCURSES_SP_NAME(intrflush)(a1, a2, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern NCURSES_BOOL call_NCURSES_SP_NAME___isendwin (SCREEN * z);
-NCURSES_BOOL call_NCURSES_SP_NAME___isendwin (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(isendwin)(%p)"), (const void *)z)); returnBool(NCURSES_SP_NAME(isendwin)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern const char * call_NCURSES_SP_NAME___keyname (SCREEN * a1, int z);
-const char * call_NCURSES_SP_NAME___keyname (SCREEN * a1, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(keyname)(%p,%d)"), (const void *)a1, z)); returnPtr(NCURSES_SP_NAME(keyname)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern char call_NCURSES_SP_NAME___killchar (SCREEN * z);
-char call_NCURSES_SP_NAME___killchar (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(killchar)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(killchar)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern char * call_NCURSES_SP_NAME___longname (SCREEN * z);
-char * call_NCURSES_SP_NAME___longname (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(longname)(%p)"), (const void *)z)); returnPtr(NCURSES_SP_NAME(longname)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___mvcur (SCREEN * a1, int a2, int a3, int a4, int z);
-int call_NCURSES_SP_NAME___mvcur (SCREEN * a1, int a2, int a3, int a4, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(mvcur)(%p,%d,%d,%d,%d)"), (const void *)a1, a2, a3, a4, z)); returnCode(NCURSES_SP_NAME(mvcur)(a1, a2, a3, a4, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___napms (SCREEN * a1, int z);
-int call_NCURSES_SP_NAME___napms (SCREEN * a1, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(napms)(%p,%d)"), (const void *)a1, z)); returnCode(NCURSES_SP_NAME(napms)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern WINDOW * call_NCURSES_SP_NAME___newpad (SCREEN * a1, int a2, int z);
-WINDOW * call_NCURSES_SP_NAME___newpad (SCREEN * a1, int a2, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(newpad)(%p,%d,%d)"), (const void *)a1, a2, z)); returnWin(NCURSES_SP_NAME(newpad)(a1, a2, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern SCREEN * call_NCURSES_SP_NAME___newterm (SCREEN * a1, const char * a2, FILE * a3, FILE * z);
-SCREEN * call_NCURSES_SP_NAME___newterm (SCREEN * a1, const char * a2, FILE * a3, FILE * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(newterm)(%p,%s,%p,%p)"), (const void *)a1, _nc_visbuf2(1,a2), (const void *)a3, (const void *)z)); returnSP(NCURSES_SP_NAME(newterm)(a1, a2, a3, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern WINDOW * call_NCURSES_SP_NAME___newwin (SCREEN * a1, int a2, int a3, int a4, int z);
-WINDOW * call_NCURSES_SP_NAME___newwin (SCREEN * a1, int a2, int a3, int a4, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(newwin)(%p,%d,%d,%d,%d)"), (const void *)a1, a2, a3, a4, z)); returnWin(NCURSES_SP_NAME(newwin)(a1, a2, a3, a4, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___nl (SCREEN * z);
-int call_NCURSES_SP_NAME___nl (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(nl)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(nl)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___nocbreak (SCREEN * z);
-int call_NCURSES_SP_NAME___nocbreak (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(nocbreak)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(nocbreak)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___noecho (SCREEN * z);
-int call_NCURSES_SP_NAME___noecho (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(noecho)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(noecho)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___nonl (SCREEN * z);
-int call_NCURSES_SP_NAME___nonl (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(nonl)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(nonl)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern void call_NCURSES_SP_NAME___noqiflush (SCREEN * z);
-void call_NCURSES_SP_NAME___noqiflush (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(noqiflush)(%p)"), (const void *)z)); NCURSES_SP_NAME(noqiflush)(z);
-	returnVoid;
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___noraw (SCREEN * z);
-int call_NCURSES_SP_NAME___noraw (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(noraw)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(noraw)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___pair_content (SCREEN * a1, short a2, short * a3, short * z);
-int call_NCURSES_SP_NAME___pair_content (SCREEN * a1, short a2, short * a3, short * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(pair_content)(%p,%#lx,%p,%p)"), (const void *)a1, (long)a2, (const void *)a3, (const void *)z)); returnCode(NCURSES_SP_NAME(pair_content)(a1, a2, a3, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern void call_NCURSES_SP_NAME___qiflush (SCREEN * z);
-void call_NCURSES_SP_NAME___qiflush (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(qiflush)(%p)"), (const void *)z)); NCURSES_SP_NAME(qiflush)(z);
-	returnVoid;
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___raw (SCREEN * z);
-int call_NCURSES_SP_NAME___raw (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(raw)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(raw)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___reset_prog_mode (SCREEN * z);
-int call_NCURSES_SP_NAME___reset_prog_mode (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(reset_prog_mode)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(reset_prog_mode)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___reset_shell_mode (SCREEN * z);
-int call_NCURSES_SP_NAME___reset_shell_mode (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(reset_shell_mode)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(reset_shell_mode)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___resetty (SCREEN * z);
-int call_NCURSES_SP_NAME___resetty (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(resetty)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(resetty)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___ripoffline (SCREEN * a1, int a2, int(* z)(WINDOW * a3, int));
-int call_NCURSES_SP_NAME___ripoffline (SCREEN * a1, int a2, int(* z)(WINDOW * a3, int))
-{
-	return NCURSES_SP_NAME(ripoffline)(a1, a2, z) ;
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___savetty (SCREEN * z);
-int call_NCURSES_SP_NAME___savetty (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(savetty)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(savetty)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___scr_init (SCREEN * a1, const char * z);
-int call_NCURSES_SP_NAME___scr_init (SCREEN * a1, const char * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(scr_init)(%p,%s)"), (const void *)a1, _nc_visbuf2(1,z))); returnCode(NCURSES_SP_NAME(scr_init)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___scr_restore (SCREEN * a1, const char * z);
-int call_NCURSES_SP_NAME___scr_restore (SCREEN * a1, const char * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(scr_restore)(%p,%s)"), (const void *)a1, _nc_visbuf2(1,z))); returnCode(NCURSES_SP_NAME(scr_restore)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___scr_set (SCREEN * a1, const char * z);
-int call_NCURSES_SP_NAME___scr_set (SCREEN * a1, const char * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(scr_set)(%p,%s)"), (const void *)a1, _nc_visbuf2(1,z))); returnCode(NCURSES_SP_NAME(scr_set)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___slk_attroff (SCREEN * a1, const chtype z);
-int call_NCURSES_SP_NAME___slk_attroff (SCREEN * a1, const chtype z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(slk_attroff)(%p,%s)"), (const void *)a1, _tracechtype2(1,z))); returnCode(NCURSES_SP_NAME(slk_attroff)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___slk_attron (SCREEN * a1, const chtype z);
-int call_NCURSES_SP_NAME___slk_attron (SCREEN * a1, const chtype z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(slk_attron)(%p,%s)"), (const void *)a1, _tracechtype2(1,z))); returnCode(NCURSES_SP_NAME(slk_attron)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___slk_attrset (SCREEN * a1, const chtype z);
-int call_NCURSES_SP_NAME___slk_attrset (SCREEN * a1, const chtype z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(slk_attrset)(%p,%s)"), (const void *)a1, _tracechtype2(1,z))); returnCode(NCURSES_SP_NAME(slk_attrset)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern attr_t call_NCURSES_SP_NAME___slk_attr (SCREEN * z);
-attr_t call_NCURSES_SP_NAME___slk_attr (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(slk_attr)(%p)"), (const void *)z)); returnIntAttr((attr_t)NCURSES_SP_NAME(slk_attr)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___slk_attr_set (SCREEN * a1, const attr_t a2, short a3, void * z);
-int call_NCURSES_SP_NAME___slk_attr_set (SCREEN * a1, const attr_t a2, short a3, void * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(slk_attr_set)(%p,%s,%#lx,%p)"), (const void *)a1, _traceattr2(1,a2), (long)a3, (const void *)z)); returnCode(NCURSES_SP_NAME(slk_attr_set)(a1, a2, a3, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___slk_clear (SCREEN * z);
-int call_NCURSES_SP_NAME___slk_clear (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(slk_clear)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(slk_clear)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___slk_color (SCREEN * a1, short z);
-int call_NCURSES_SP_NAME___slk_color (SCREEN * a1, short z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(slk_color)(%p,%#lx)"), (const void *)a1, (long)z)); returnCode(NCURSES_SP_NAME(slk_color)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___slk_init (SCREEN * a1, int z);
-int call_NCURSES_SP_NAME___slk_init (SCREEN * a1, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(slk_init)(%p,%d)"), (const void *)a1, z)); returnCode(NCURSES_SP_NAME(slk_init)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern char * call_NCURSES_SP_NAME___slk_label (SCREEN * a1, int z);
-char * call_NCURSES_SP_NAME___slk_label (SCREEN * a1, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(slk_label)(%p,%d)"), (const void *)a1, z)); returnPtr(NCURSES_SP_NAME(slk_label)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___slk_noutrefresh (SCREEN * z);
-int call_NCURSES_SP_NAME___slk_noutrefresh (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(slk_noutrefresh)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(slk_noutrefresh)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___slk_refresh (SCREEN * z);
-int call_NCURSES_SP_NAME___slk_refresh (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(slk_refresh)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(slk_refresh)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___slk_restore (SCREEN * z);
-int call_NCURSES_SP_NAME___slk_restore (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(slk_restore)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(slk_restore)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___slk_set (SCREEN * a1, int a2, const char * a3, int z);
-int call_NCURSES_SP_NAME___slk_set (SCREEN * a1, int a2, const char * a3, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(slk_set)(%p,%d,%s,%d)"), (const void *)a1, a2, _nc_visbuf2(2,a3), z)); returnCode(NCURSES_SP_NAME(slk_set)(a1, a2, a3, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___slk_touch (SCREEN * z);
-int call_NCURSES_SP_NAME___slk_touch (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(slk_touch)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(slk_touch)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___start_color (SCREEN * z);
-int call_NCURSES_SP_NAME___start_color (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(start_color)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(start_color)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern chtype call_NCURSES_SP_NAME___termattrs (SCREEN * z);
-chtype call_NCURSES_SP_NAME___termattrs (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(termattrs)(%p)"), (const void *)z)); returnChtype(NCURSES_SP_NAME(termattrs)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern char * call_NCURSES_SP_NAME___termname (SCREEN * z);
-char * call_NCURSES_SP_NAME___termname (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(termname)(%p)"), (const void *)z)); returnPtr(NCURSES_SP_NAME(termname)(z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___typeahead (SCREEN * a1, int z);
-int call_NCURSES_SP_NAME___typeahead (SCREEN * a1, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(typeahead)(%p,%d)"), (const void *)a1, z)); returnCode(NCURSES_SP_NAME(typeahead)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___ungetch (SCREEN * a1, int z);
-int call_NCURSES_SP_NAME___ungetch (SCREEN * a1, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(ungetch)(%p,%d)"), (const void *)a1, z)); returnCode(NCURSES_SP_NAME(ungetch)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern void call_NCURSES_SP_NAME___use_env (SCREEN * a1, NCURSES_BOOL z);
-void call_NCURSES_SP_NAME___use_env (SCREEN * a1, NCURSES_BOOL z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(use_env)(%p,%#lx)"), (const void *)a1, (long)z)); NCURSES_SP_NAME(use_env)(a1, z);
-	returnVoid;
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern void call_NCURSES_SP_NAME___use_tioctl (SCREEN * a1, NCURSES_BOOL z);
-void call_NCURSES_SP_NAME___use_tioctl (SCREEN * a1, NCURSES_BOOL z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(use_tioctl)(%p,%#lx)"), (const void *)a1, (long)z)); NCURSES_SP_NAME(use_tioctl)(a1, z);
-	returnVoid;
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___vidattr (SCREEN * a1, chtype z);
-int call_NCURSES_SP_NAME___vidattr (SCREEN * a1, chtype z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(vidattr)(%p,%s)"), (const void *)a1, _tracechtype2(1,z))); returnCode(NCURSES_SP_NAME(vidattr)(a1, z));
-}
-#endif
-
-
-#if USE_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___vidputs (SCREEN * a1, chtype a2, NCURSES_OUTC_sp z);
-int call_NCURSES_SP_NAME___vidputs (SCREEN * a1, chtype a2, NCURSES_OUTC_sp z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(vidputs)(%p,%s,%#lx)"), (const void *)a1, _tracechtype2(1,a2), (long)z)); returnCode(NCURSES_SP_NAME(vidputs)(a1, a2, z));
-}
-#endif
-
-
-#if USE_EXT_SP_FUNC_SUPPORT
-extern char * call_NCURSES_SP_NAME___keybound (SCREEN * a1, int a2, int z);
-char * call_NCURSES_SP_NAME___keybound (SCREEN * a1, int a2, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(keybound)(%p,%d,%d)"), (const void *)a1, a2, z)); returnPtr(NCURSES_SP_NAME(keybound)(a1, a2, z));
-}
-#endif
-
-
-#if USE_EXT_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___assume_default_colors (SCREEN * a1, int a2, int z);
-int call_NCURSES_SP_NAME___assume_default_colors (SCREEN * a1, int a2, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(assume_default_colors)(%p,%d,%d)"), (const void *)a1, a2, z)); returnCode(NCURSES_SP_NAME(assume_default_colors)(a1, a2, z));
-}
-#endif
-
-
-#if USE_EXT_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___define_key (SCREEN * a1, const char * a2, int z);
-int call_NCURSES_SP_NAME___define_key (SCREEN * a1, const char * a2, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(define_key)(%p,%s,%d)"), (const void *)a1, _nc_visbuf2(1,a2), z)); returnCode(NCURSES_SP_NAME(define_key)(a1, a2, z));
-}
-#endif
-
-
-#if USE_EXT_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___get_escdelay (SCREEN * z);
-int call_NCURSES_SP_NAME___get_escdelay (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(get_escdelay)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(get_escdelay)(z));
-}
-#endif
-
-
-#if USE_EXT_SP_FUNC_SUPPORT
-extern NCURSES_BOOL call_NCURSES_SP_NAME___is_term_resized (SCREEN * a1, int a2, int z);
-NCURSES_BOOL call_NCURSES_SP_NAME___is_term_resized (SCREEN * a1, int a2, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(is_term_resized)(%p,%d,%d)"), (const void *)a1, a2, z)); returnBool(NCURSES_SP_NAME(is_term_resized)(a1, a2, z));
-}
-#endif
-
-
-#if USE_EXT_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___key_defined (SCREEN * a1, const char * z);
-int call_NCURSES_SP_NAME___key_defined (SCREEN * a1, const char * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(key_defined)(%p,%s)"), (const void *)a1, _nc_visbuf2(1,z))); returnCode(NCURSES_SP_NAME(key_defined)(a1, z));
-}
-#endif
-
-
-#if USE_EXT_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___keyok (SCREEN * a1, int a2, NCURSES_BOOL z);
-int call_NCURSES_SP_NAME___keyok (SCREEN * a1, int a2, NCURSES_BOOL z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(keyok)(%p,%d,%#lx)"), (const void *)a1, a2, (long)z)); returnCode(NCURSES_SP_NAME(keyok)(a1, a2, z));
-}
-#endif
-
-
-#if USE_EXT_SP_FUNC_SUPPORT
-extern void call_NCURSES_SP_NAME___nofilter (SCREEN * z);
-void call_NCURSES_SP_NAME___nofilter (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(nofilter)(%p)"), (const void *)z)); NCURSES_SP_NAME(nofilter)(z);
-	returnVoid;
-}
-#endif
-
-
-#if USE_EXT_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___resize_term (SCREEN * a1, int a2, int z);
-int call_NCURSES_SP_NAME___resize_term (SCREEN * a1, int a2, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(resize_term)(%p,%d,%d)"), (const void *)a1, a2, z)); returnCode(NCURSES_SP_NAME(resize_term)(a1, a2, z));
-}
-#endif
-
-
-#if USE_EXT_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___resizeterm (SCREEN * a1, int a2, int z);
-int call_NCURSES_SP_NAME___resizeterm (SCREEN * a1, int a2, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(resizeterm)(%p,%d,%d)"), (const void *)a1, a2, z)); returnCode(NCURSES_SP_NAME(resizeterm)(a1, a2, z));
-}
-#endif
-
-
-#if USE_EXT_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___set_escdelay (SCREEN * a1, int z);
-int call_NCURSES_SP_NAME___set_escdelay (SCREEN * a1, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(set_escdelay)(%p,%d)"), (const void *)a1, z)); returnCode(NCURSES_SP_NAME(set_escdelay)(a1, z));
-}
-#endif
-
-
-#if USE_EXT_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___set_tabsize (SCREEN * a1, int z);
-int call_NCURSES_SP_NAME___set_tabsize (SCREEN * a1, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(set_tabsize)(%p,%d)"), (const void *)a1, z)); returnCode(NCURSES_SP_NAME(set_tabsize)(a1, z));
-}
-#endif
-
-
-#if USE_EXT_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___use_default_colors (SCREEN * z);
-int call_NCURSES_SP_NAME___use_default_colors (SCREEN * z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(use_default_colors)(%p)"), (const void *)z)); returnCode(NCURSES_SP_NAME(use_default_colors)(z));
-}
-#endif
-
-
-#if USE_EXT_SP_FUNC_SUPPORT
-extern int call_NCURSES_SP_NAME___use_legacy_coding (SCREEN * a1, int z);
-int call_NCURSES_SP_NAME___use_legacy_coding (SCREEN * a1, int z)
-{
-	T((T_CALLED("NCURSES_SP_NAME(use_legacy_coding)(%p,%d)"), (const void *)a1, z)); returnCode(NCURSES_SP_NAME(use_legacy_coding)(a1, z));
-}
-#endif
-
-
-extern NCURSES_BOOL call_mouse_trafo (int * a1, int * a2, NCURSES_BOOL z);
-NCURSES_BOOL call_mouse_trafo (int * a1, int * a2, NCURSES_BOOL z)
-{
-	T((T_CALLED("mouse_trafo(%p,%p,%#lx)"), (const void *)a1, (const void *)a2, (long)z)); returnBool(wmouse_trafo(stdscr,a1,a2,z));
-}
-int main(void)
-{
- call_int addch (0);
- call_int addchnstr (* a1, 0);
- call_int addchstr (* 0);
- call_int addnstr (char * a1, 0);
- call_int addstr (char * 0);
- call_int attroff (0);
- call_int attron (0);
- call_int attrset (0);
- call_int attr_get (* a1, * a2,* 0);
- call_int attr_off (a1,* 0);
- call_int attr_on (a1,* 0);
- call_int attr_set (a1, a2,* 0);
- call_int baudrate ();
- call_int beep ();
- call_int bkgd (0);
- call_void bkgdset (0);
- call_int border (a1, a2, a3, a4, a5, a6, a7, 0);
- call_int box (WINDOW * a1, a2, 0);
- call_NCURSES_BOOL can_change_color ();
- call_int cbreak ();
- call_int chgat (a1, a2, a3,* 0);
- call_int clear ();
- call_int clearok (WINDOW * a1, 0);
- call_int clrtobot ();
- call_int clrtoeol ();
- call_int color_content (a1, * a2, * a3, * 0);
- call_int color_set (a1,* 0);
- call_int COLOR_PAIR (0);
- call_int copywin (WINDOW * a1, WINDOW * a2, a3, a4, a5, a6, a7, a8, 0);
- call_int curs_set (0);
- call_int def_prog_mode ();
- call_int def_shell_mode ();
- call_int delay_output (0);
- call_int delch ();
- call_void delscreen (SCREEN * 0);
- call_int delwin (WINDOW * 0);
- call_int deleteln ();
- call_WINDOW * derwin (WINDOW * a1, a2, a3, a4, 0);
- call_int doupdate ();
- call_WINDOW * dupwin (WINDOW * 0);
- call_int echo ();
- call_int echochar (0);
- call_int erase ();
- call_int endwin ();
- call_char erasechar ();
- call_void filter ();
- call_int flash ();
- call_int flushinp ();
- call_chtype getbkgd (WINDOW * 0);
- call_int getch ();
- call_int getnstr (char * a1, 0);
- call_int getstr (char * 0);
- call_WINDOW * getwin (FILE * 0);
- call_int halfdelay (0);
- call_NCURSES_BOOL has_colors ();
- call_NCURSES_BOOL has_ic ();
- call_NCURSES_BOOL has_il ();
- call_int hline (a1, 0);
- call_void idcok (WINDOW * a1, 0);
- call_int idlok (WINDOW * a1, 0);
- call_void immedok (WINDOW * a1, 0);
- call_chtype inch ();
- call_int inchnstr (* a1, 0);
- call_int inchstr (* 0);
- call_WINDOW * initscr ();
- call_int init_color (a1, a2, a3, 0);
- call_int init_pair (a1, a2, 0);
- call_int innstr (char * a1, 0);
- call_int insch (0);
- call_int insdelln (0);
- call_int insertln ();
- call_int insnstr (char * a1, 0);
- call_int insstr (char * 0);
- call_int instr (char * 0);
- call_int intrflush (WINDOW * a1, 0);
- call_NCURSES_BOOL isendwin ();
- call_NCURSES_BOOL is_linetouched (WINDOW * a1, 0);
- call_NCURSES_BOOL is_wintouched (WINDOW * 0);
- call_const char * keyname (0);
- call_int keypad (WINDOW * a1, 0);
- call_char killchar ();
- call_int leaveok (WINDOW * a1, 0);
- call_char * longname ();
- call_int meta (WINDOW * a1, 0);
- call_int move (a1, 0);
- call_int mvaddch (a1, a2, 0);
- call_int mvaddchnstr (a1, a2, * a3, 0);
- call_int mvaddchstr (a1, a2, * 0);
- call_int mvaddnstr (a1, a2, char * a3, 0);
- call_int mvaddstr (a1, a2, char * 0);
- call_int mvchgat (a1, a2, a3, a4, a5,* 0);
- call_int mvcur (a1, a2, a3, 0);
- call_int mvdelch (a1, 0);
- call_int mvderwin (WINDOW * a1, a2, 0);
- call_int mvgetch (a1, 0);
- call_int mvgetnstr (a1, a2, char * a3, 0);
- call_int mvgetstr (a1, a2, char * 0);
- call_int mvhline (a1, a2, a3, 0);
- call_chtype mvinch (a1, 0);
- call_int mvinchnstr (a1, a2, * a3, 0);
- call_int mvinchstr (a1, a2, * 0);
- call_int mvinnstr (a1, a2, char * a3, 0);
- call_int mvinsch (a1, a2, 0);
- call_int mvinsnstr (a1, a2, char * a3, 0);
- call_int mvinsstr (a1, a2, char * 0);
- call_int mvinstr (a1, a2, char * 0);
- call_int mvvline (a1, a2, a3, 0);
- call_int mvwaddch (WINDOW * a1, a2, a3, 0);
- call_int mvwaddchnstr (WINDOW * a1, a2, a3, * a4, 0);
- call_int mvwaddchstr (WINDOW * a1, a2, a3, * 0);
- call_int mvwaddnstr (WINDOW * a1, a2, a3, char * a4, 0);
- call_int mvwaddstr (WINDOW * a1, a2, a3, char * 0);
- call_int mvwchgat (WINDOW * a1, a2, a3, a4, a5, a6,* 0);
- call_int mvwdelch (WINDOW * a1, a2, 0);
- call_int mvwgetch (WINDOW * a1, a2, 0);
- call_int mvwgetnstr (WINDOW * a1, a2, a3, char * a4, 0);
- call_int mvwgetstr (WINDOW * a1, a2, a3, char * 0);
- call_int mvwhline (WINDOW * a1, a2, a3, a4, 0);
- call_int mvwin (WINDOW * a1, a2, 0);
- call_chtype mvwinch (WINDOW * a1, a2, 0);
- call_int mvwinchnstr (WINDOW * a1, a2, a3, * a4, 0);
- call_int mvwinchstr (WINDOW * a1, a2, a3, * 0);
- call_int mvwinnstr (WINDOW * a1, a2, a3, char * a4, 0);
- call_int mvwinsch (WINDOW * a1, a2, a3, 0);
- call_int mvwinsnstr (WINDOW * a1, a2, a3, char * a4, 0);
- call_int mvwinsstr (WINDOW * a1, a2, a3, char * 0);
- call_int mvwinstr (WINDOW * a1, a2, a3, char * 0);
- call_int mvwvline (WINDOW * a1, a2, a3, a4, 0);
- call_int napms (0);
- call_WINDOW * newpad (a1, 0);
- call_SCREEN * newterm (char * a1, FILE * a2, FILE * 0);
- call_WINDOW * newwin (a1, a2, a3, 0);
- call_int nl ();
- call_int nocbreak ();
- call_int nodelay (WINDOW * a1, 0);
- call_int noecho ();
- call_int nonl ();
- call_void noqiflush ();
- call_int noraw ();
- call_int notimeout (WINDOW * a1, 0);
- call_int overlay (WINDOW * a1, WINDOW * 0);
- call_int overwrite (WINDOW * a1, WINDOW * 0);
- call_int pair_content (a1, * a2, * 0);
- call_int PAIR_NUMBER (0);
- call_int pechochar (WINDOW * a1, 0);
- call_int pnoutrefresh (WINDOW * a1, a2, a3, a4, a5, a6, 0);
- call_int prefresh (WINDOW * a1, a2, a3, a4, a5, a6, 0);
- call_int putwin (WINDOW * a1, FILE * 0);
- call_void qiflush ();
- call_int raw ();
- call_int redrawwin (WINDOW * 0);
- call_int refresh ();
- call_int resetty ();
- call_int reset_prog_mode ();
- call_int reset_shell_mode ();
- call_int ripoffline (a1, int(* 0)(WINDOW * a2, int));
- call_int savetty ();
- call_int scr_dump (char * 0);
- call_int scr_init (char * 0);
- call_int scrl (0);
- call_int scroll (WINDOW * 0);
- call_int scrollok (WINDOW * a1, 0);
- call_int scr_restore (char * 0);
- call_int scr_set (char * 0);
- call_int setscrreg (a1, 0);
- call_SCREEN * set_term (SCREEN * 0);
- call_int slk_attroff (0);
-#if USE_WIDEC_SUPPORT
- call_int slk_attr_off (a1,* 0);
-#endif
- call_int slk_attron (0);
-#if USE_WIDEC_SUPPORT
- call_int slk_attr_on (a1,* 0);
-#endif
- call_int slk_attrset (0);
- call_attr_t slk_attr ();
- call_int slk_attr_set (a1, a2,* 0);
- call_int slk_clear ();
- call_int slk_color (0);
- call_int slk_init (0);
- call_char * slk_label (0);
- call_int slk_noutrefresh ();
- call_int slk_refresh ();
- call_int slk_restore ();
- call_int slk_set (a1, char * a2, 0);
- call_int slk_touch ();
- call_int standout ();
- call_int standend ();
- call_int start_color ();
- call_WINDOW * subpad (WINDOW * a1, a2, a3, a4, 0);
- call_WINDOW * subwin (WINDOW * a1, a2, a3, a4, 0);
- call_int syncok (WINDOW * a1, 0);
- call_chtype termattrs ();
- call_char * termname ();
- call_void timeout (0);
- call_int touchline (WINDOW * a1, a2, 0);
- call_int touchwin (WINDOW * 0);
- call_int typeahead (0);
- call_int ungetch (0);
- call_int untouchwin (WINDOW * 0);
- call_void use_env (0);
- call_void use_tioctl (0);
- call_int vidattr (0);
- call_int vidputs (a1, 0);
- call_int vline (a1, 0);
- call_int vwprintw (WINDOW * a1, char * a2, 0);
- call_int vw_printw (WINDOW * a1, char * a2, 0);
- call_int vwscanw (WINDOW * a1, char * a2, 0);
- call_int vw_scanw (WINDOW * a1, char * a2, 0);
- call_int waddch (WINDOW * a1, 0);
- call_int waddchnstr (WINDOW * a1, * a2, 0);
- call_int waddchstr (WINDOW * a1, * 0);
- call_int waddnstr (WINDOW * a1, char * a2, 0);
- call_int waddstr (WINDOW * a1, char * 0);
- call_int wattron (WINDOW * a1, 0);
- call_int wattroff (WINDOW * a1, 0);
- call_int wattrset (WINDOW * a1, 0);
- call_int wattr_get (WINDOW * a1, * a2, * a3,* 0);
- call_int wattr_on (WINDOW * a1, a2,* 0);
- call_int wattr_off (WINDOW * a1, a2,* 0);
- call_int wattr_set (WINDOW * a1, a2, a3,* 0);
- call_int wbkgd (WINDOW * a1, 0);
- call_void wbkgdset (WINDOW * a1, 0);
- call_int wborder (WINDOW * a1, a2, a3, a4, a5, a6, a7, a8, 0);
- call_int wchgat (WINDOW * a1, a2, a3, a4,* 0);
- call_int wclear (WINDOW * 0);
- call_int wclrtobot (WINDOW * 0);
- call_int wclrtoeol (WINDOW * 0);
- call_int wcolor_set (WINDOW * a1, a2,* 0);
- call_void wcursyncup (WINDOW * 0);
- call_int wdelch (WINDOW * 0);
- call_int wdeleteln (WINDOW * 0);
- call_int wechochar (WINDOW * a1, 0);
- call_int werase (WINDOW * 0);
- call_int wgetch (WINDOW * 0);
- call_int wgetnstr (WINDOW * a1, char * a2, 0);
- call_int wgetstr (WINDOW * a1, char * 0);
- call_int whline (WINDOW * a1, a2, 0);
- call_chtype winch (WINDOW * 0);
- call_int winchnstr (WINDOW * a1, * a2, 0);
- call_int winchstr (WINDOW * a1, * 0);
- call_int winnstr (WINDOW * a1, char * a2, 0);
- call_int winsch (WINDOW * a1, 0);
- call_int winsdelln (WINDOW * a1, 0);
- call_int winsertln (WINDOW * 0);
- call_int winsnstr (WINDOW * a1, char * a2, 0);
- call_int winsstr (WINDOW * a1, char * 0);
- call_int winstr (WINDOW * a1, char * 0);
- call_int wmove (WINDOW * a1, a2, 0);
- call_int wnoutrefresh (WINDOW * 0);
- call_int wredrawln (WINDOW * a1, a2, 0);
- call_int wrefresh (WINDOW * 0);
- call_int wscrl (WINDOW * a1, 0);
- call_int wsetscrreg (WINDOW * a1, a2, 0);
- call_int wstandout (WINDOW * 0);
- call_int wstandend (WINDOW * 0);
- call_void wsyncdown (WINDOW * 0);
- call_void wsyncup (WINDOW * 0);
- call_void wtimeout (WINDOW * a1, 0);
- call_int wtouchln (WINDOW * a1, a2, a3, 0);
- call_int wvline (WINDOW * a1, a2, 0);
- call_int tigetflag (char * 0);
- call_int tigetnum (char * 0);
- call_char * tigetstr (char * 0);
- call_int putp (char * 0);
- call_int getattrs (WINDOW * 0);
- call_int getcurx (WINDOW * 0);
- call_int getcury (WINDOW * 0);
- call_int getbegx (WINDOW * 0);
- call_int getbegy (WINDOW * 0);
- call_int getmaxx (WINDOW * 0);
- call_int getmaxy (WINDOW * 0);
- call_int getparx (WINDOW * 0);
- call_int getpary (WINDOW * 0);
- call_WINDOW * wgetparent (WINDOW * 0);
- call_NCURSES_BOOL is_cleared (WINDOW * 0);
- call_NCURSES_BOOL is_idcok (WINDOW * 0);
- call_NCURSES_BOOL is_idlok (WINDOW * 0);
- call_NCURSES_BOOL is_immedok (WINDOW * 0);
- call_NCURSES_BOOL is_keypad (WINDOW * 0);
- call_NCURSES_BOOL is_leaveok (WINDOW * 0);
- call_NCURSES_BOOL is_nodelay (WINDOW * 0);
- call_NCURSES_BOOL is_notimeout (WINDOW * 0);
- call_NCURSES_BOOL is_pad (WINDOW * 0);
- call_NCURSES_BOOL is_scrollok (WINDOW * 0);
- call_NCURSES_BOOL is_subwin (WINDOW * 0);
- call_NCURSES_BOOL is_syncok (WINDOW * 0);
- call_int wgetdelay (WINDOW * 0);
- call_int wgetscrreg (WINDOW * a1, * a2, * 0);
-#if USE_SP_FUNC_SUPPORT
- call_SCREEN * new_prescr ();
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(baudrate) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(beep) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_NCURSES_BOOL NCURSES_SP_NAME(can_change_color) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(cbreak) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(curs_set) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(color_content) (SCREEN * a1, a2, * a3, * a4, * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(def_prog_mode) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(def_shell_mode) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(delay_output) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(doupdate) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(echo) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(endwin) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_char NCURSES_SP_NAME(erasechar) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_void NCURSES_SP_NAME(filter) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(flash) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(flushinp) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_WINDOW * NCURSES_SP_NAME(getwin) (SCREEN * a1, FILE * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(halfdelay) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_NCURSES_BOOL NCURSES_SP_NAME(has_colors) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_NCURSES_BOOL NCURSES_SP_NAME(has_ic) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_NCURSES_BOOL NCURSES_SP_NAME(has_il) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(init_color) (SCREEN * a1, a2, a3, a4, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(init_pair) (SCREEN * a1, a2, a3, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(intrflush) (SCREEN * a1, WINDOW * a2, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_NCURSES_BOOL NCURSES_SP_NAME(isendwin) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_const char * NCURSES_SP_NAME(keyname) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_char NCURSES_SP_NAME(killchar) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_char * NCURSES_SP_NAME(longname) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(mvcur) (SCREEN * a1, a2, a3, a4, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(napms) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_WINDOW * NCURSES_SP_NAME(newpad) (SCREEN * a1, a2, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_SCREEN * NCURSES_SP_NAME(newterm) (SCREEN * a1, char * a2, FILE * a3, FILE * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_WINDOW * NCURSES_SP_NAME(newwin) (SCREEN * a1, a2, a3, a4, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(nl) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(nocbreak) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(noecho) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(nonl) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_void NCURSES_SP_NAME(noqiflush) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(noraw) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(pair_content) (SCREEN * a1, a2, * a3, * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_void NCURSES_SP_NAME(qiflush) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(raw) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(reset_prog_mode) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(reset_shell_mode) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(resetty) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(ripoffline) (SCREEN * a1, a2, int(* 0)(WINDOW * a3, int));
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(savetty) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(scr_init) (SCREEN * a1, char * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(scr_restore) (SCREEN * a1, char * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(scr_set) (SCREEN * a1, char * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(slk_attroff) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(slk_attron) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(slk_attrset) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_attr_t NCURSES_SP_NAME(slk_attr) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(slk_attr_set) (SCREEN * a1, a2, a3,* 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(slk_clear) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(slk_color) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(slk_init) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_char * NCURSES_SP_NAME(slk_label) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(slk_noutrefresh) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(slk_refresh) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(slk_restore) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(slk_set) (SCREEN * a1, a2, char * a3, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(slk_touch) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(start_color) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_chtype NCURSES_SP_NAME(termattrs) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_char * NCURSES_SP_NAME(termname) (SCREEN * 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(typeahead) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(ungetch) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_void NCURSES_SP_NAME(use_env) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_void NCURSES_SP_NAME(use_tioctl) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(vidattr) (SCREEN * a1, 0);
-#endif
-#if USE_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(vidputs) (SCREEN * a1, a2, 0);
-#endif
-#if USE_EXT_SP_FUNC_SUPPORT
- call_char * NCURSES_SP_NAME(keybound) (SCREEN * a1, a2, 0);
-#endif
-#if USE_EXT_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(assume_default_colors) (SCREEN * a1, a2, 0);
-#endif
-#if USE_EXT_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(define_key) (SCREEN * a1, char * a2, 0);
-#endif
-#if USE_EXT_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(get_escdelay) (SCREEN * 0);
-#endif
-#if USE_EXT_SP_FUNC_SUPPORT
- call_NCURSES_BOOL NCURSES_SP_NAME(is_term_resized) (SCREEN * a1, a2, 0);
-#endif
-#if USE_EXT_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(key_defined) (SCREEN * a1, char * 0);
-#endif
-#if USE_EXT_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(keyok) (SCREEN * a1, a2, 0);
-#endif
-#if USE_EXT_SP_FUNC_SUPPORT
- call_void NCURSES_SP_NAME(nofilter) (SCREEN * 0);
-#endif
-#if USE_EXT_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(resize_term) (SCREEN * a1, a2, 0);
-#endif
-#if USE_EXT_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(resizeterm) (SCREEN * a1, a2, 0);
-#endif
-#if USE_EXT_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(set_escdelay) (SCREEN * a1, 0);
-#endif
-#if USE_EXT_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(set_tabsize) (SCREEN * a1, 0);
-#endif
-#if USE_EXT_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(use_default_colors) (SCREEN * 0);
-#endif
-#if USE_EXT_SP_FUNC_SUPPORT
- call_int NCURSES_SP_NAME(use_legacy_coding) (SCREEN * a1, 0);
-#endif
- call_NCURSES_BOOL mouse_trafo (* a1, * a2, 0);
- return 0;
-}
diff --git a/ncurses/llib-lncurses b/ncurses/llib-lncurses
index 4604fdd..5069c22 100644
--- a/ncurses/llib-lncurses
+++ b/ncurses/llib-lncurses
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2015 Free Software Foundation, Inc.              *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -69,7 +70,7 @@
 
 #undef _nc_make_oldhash_sp
 void	_nc_make_oldhash_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	i)
 		{ /* void */ }
 
@@ -80,16 +81,16 @@
 
 #undef _nc_scroll_oldhash_sp
 void	_nc_scroll_oldhash_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
 #undef _nc_scroll_oldhash
 void	_nc_scroll_oldhash(
-		int	n, 
-		int	top, 
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
@@ -97,25 +98,25 @@
 
 #undef _nc_render
 chtype	_nc_render(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(chtype *)0); }
 
 #undef _nc_waddch_nosync
 int	_nc_waddch_nosync(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype c)
 		{ return(*(int *)0); }
 
 #undef waddch
 int	waddch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
 #undef wechochar
 int	wechochar(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -123,15 +124,15 @@
 
 #undef waddnstr
 int	waddnstr(
-		WINDOW	*win, 
-		const char *astr, 
+		WINDOW	*win,
+		const char *astr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef waddchnstr
 int	waddchnstr(
-		WINDOW	*win, 
-		const chtype *astr, 
+		WINDOW	*win,
+		const chtype *astr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -150,13 +151,13 @@
 
 #undef wbkgdset
 void	wbkgdset(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ /* void */ }
 
 #undef wbkgd
 int	wbkgd(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
@@ -164,14 +165,14 @@
 
 #undef wborder
 int	wborder(
-		WINDOW	*win, 
-		chtype	ls, 
-		chtype	rs, 
-		chtype	ts, 
-		chtype	bs, 
-		chtype	tl, 
-		chtype	tr, 
-		chtype	bl, 
+		WINDOW	*win,
+		chtype	ls,
+		chtype	rs,
+		chtype	ts,
+		chtype	bs,
+		chtype	tl,
+		chtype	tr,
+		chtype	bl,
 		chtype	br)
 		{ return(*(int *)0); }
 
@@ -179,10 +180,10 @@
 
 #undef wchgat
 int	wchgat(
-		WINDOW	*win, 
-		int	n, 
-		attr_t	attr, 
-		short	color, 
+		WINDOW	*win,
+		int	n,
+		attr_t	attr,
+		short	pair_arg,
 		const void *opts)
 		{ return(*(int *)0); }
 
@@ -197,7 +198,7 @@
 
 #undef clearok
 int	clearok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -240,35 +241,64 @@
 int	start_color(void)
 		{ return(*(int *)0); }
 
+#undef _nc_change_pair
+void	_nc_change_pair(
+		SCREEN	*sp,
+		int	pair)
+		{ /* void */ }
+
+#undef _nc_reserve_pairs
+void	_nc_reserve_pairs(
+		SCREEN	*sp,
+		int	want)
+		{ /* void */ }
+
+#undef _nc_init_pair
+int	_nc_init_pair(
+		SCREEN	*sp,
+		int	pair,
+		int	f,
+		int	b)
+		{ return(*(int *)0); }
+
 #undef init_pair_sp
 int	init_pair_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	f, 
+		SCREEN	*sp,
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_pair
 int	init_pair(
-		short	pair, 
-		short	f, 
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
+#undef _nc_init_color
+int	_nc_init_color(
+		SCREEN	*sp,
+		int	color,
+		int	r,
+		int	g,
+		int	b)
+		{ return(*(int *)0); }
+
 #undef init_color_sp
 int	init_color_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	r, 
-		short	g, 
+		SCREEN	*sp,
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_color
 int	init_color(
-		short	color, 
-		short	r, 
-		short	g, 
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
@@ -292,50 +322,58 @@
 
 #undef color_content_sp
 int	color_content_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	*r, 
-		short	*g, 
+		SCREEN	*sp,
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef color_content
 int	color_content(
-		short	color, 
-		short	*r, 
-		short	*g, 
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
+#undef _nc_pair_content
+int	_nc_pair_content(
+		SCREEN	*sp,
+		int	pair,
+		int	*f,
+		int	*b)
+		{ return(*(int *)0); }
+
 #undef pair_content_sp
 int	pair_content_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	*f, 
+		SCREEN	*sp,
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef pair_content
 int	pair_content(
-		short	pair, 
-		short	*f, 
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef _nc_do_color_sp
 void	_nc_do_color_sp(
-		SCREEN	*sp, 
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		SCREEN	*sp,
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC_sp outc)
 		{ /* void */ }
 
 #undef _nc_do_color
 void	_nc_do_color(
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC outc)
 		{ /* void */ }
 
@@ -343,8 +381,8 @@
 
 #undef wcolor_set
 int	wcolor_set(
-		WINDOW	*win, 
-		short	color_pair_number, 
+		WINDOW	*win,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -414,845 +452,831 @@
 /* ./lib_gen.c */
 
 #undef addch
-int	(addch)(
+int	addch(
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef addchnstr
-int	(addchnstr)(
-		const chtype *a1, 
+int	addchnstr(
+		const chtype *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef addchstr
-int	(addchstr)(
+int	addchstr(
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef addnstr
-int	(addnstr)(
-		const char *a1, 
+int	addnstr(
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef addstr
-int	(addstr)(
+int	addstr(
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef attroff
-int	(attroff)(
+int	attroff(
 		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attron
-int	(attron)(
+int	attron(
 		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attrset
-int	(attrset)(
+int	attrset(
 		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attr_get
-int	(attr_get)(
-		attr_t	*a1, 
-		short	*a2, 
+int	attr_get(
+		attr_t	*a1,
+		short	*a2,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_off
-int	(attr_off)(
-		attr_t	a1, 
+int	attr_off(
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_on
-int	(attr_on)(
-		attr_t	a1, 
+int	attr_on(
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_set
-int	(attr_set)(
-		attr_t	a1, 
-		short	a2, 
+int	attr_set(
+		attr_t	a1,
+		short	a2,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef bkgd
-int	(bkgd)(
+int	bkgd(
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef bkgdset
-void	(bkgdset)(
+void	bkgdset(
 		chtype	z)
 		{ /* void */ }
 
 #undef border
-int	(border)(
-		chtype	a1, 
-		chtype	a2, 
-		chtype	a3, 
-		chtype	a4, 
-		chtype	a5, 
-		chtype	a6, 
-		chtype	a7, 
+int	border(
+		chtype	a1,
+		chtype	a2,
+		chtype	a3,
+		chtype	a4,
+		chtype	a5,
+		chtype	a6,
+		chtype	a7,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef box
-int	(box)(
-		WINDOW	*a1, 
-		chtype	a2, 
+int	box(
+		WINDOW	*a1,
+		chtype	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef chgat
-int	(chgat)(
-		int	a1, 
-		attr_t	a2, 
-		short	a3, 
+int	chgat(
+		int	a1,
+		attr_t	a2,
+		short	a3,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef clear
-int	(clear)(void)
+int	clear(void)
 		{ return(*(int *)0); }
 
 #undef clrtobot
-int	(clrtobot)(void)
+int	clrtobot(void)
 		{ return(*(int *)0); }
 
 #undef clrtoeol
-int	(clrtoeol)(void)
+int	clrtoeol(void)
 		{ return(*(int *)0); }
 
 #undef color_set
-int	(color_set)(
-		short	a1, 
+int	color_set(
+		short	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef COLOR_PAIR
-int	(COLOR_PAIR)(
+int	COLOR_PAIR(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef delch
-int	(delch)(void)
+int	delch(void)
 		{ return(*(int *)0); }
 
 #undef deleteln
-int	(deleteln)(void)
+int	deleteln(void)
 		{ return(*(int *)0); }
 
 #undef echochar
-int	(echochar)(
+int	echochar(
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef erase
-int	(erase)(void)
+int	erase(void)
 		{ return(*(int *)0); }
 
 #undef getbkgd
-chtype	(getbkgd)(
+chtype	getbkgd(
 		WINDOW	*z)
 		{ return(*(chtype *)0); }
 
 #undef getch
-int	(getch)(void)
+int	getch(void)
 		{ return(*(int *)0); }
 
 #undef getnstr
-int	(getnstr)(
-		char	*a1, 
+int	getnstr(
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef getstr
-int	(getstr)(
+int	getstr(
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef hline
-int	(hline)(
-		chtype	a1, 
+int	hline(
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef inch
-chtype	(inch)(void)
+chtype	inch(void)
 		{ return(*(chtype *)0); }
 
 #undef inchnstr
-int	(inchnstr)(
-		chtype	*a1, 
+int	inchnstr(
+		chtype	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef inchstr
-int	(inchstr)(
+int	inchstr(
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef innstr
-int	(innstr)(
-		char	*a1, 
+int	innstr(
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef insch
-int	(insch)(
+int	insch(
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef insdelln
-int	(insdelln)(
+int	insdelln(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef insertln
-int	(insertln)(void)
+int	insertln(void)
 		{ return(*(int *)0); }
 
 #undef insnstr
-int	(insnstr)(
-		const char *a1, 
+int	insnstr(
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef insstr
-int	(insstr)(
+int	insstr(
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef instr
-int	(instr)(
+int	instr(
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef move
-int	(move)(
-		int	a1, 
+int	move(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddch
-int	(mvaddch)(
-		int	a1, 
-		int	a2, 
+int	mvaddch(
+		int	a1,
+		int	a2,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvaddchnstr
-int	(mvaddchnstr)(
-		int	a1, 
-		int	a2, 
-		const chtype *a3, 
+int	mvaddchnstr(
+		int	a1,
+		int	a2,
+		const chtype *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddchstr
-int	(mvaddchstr)(
-		int	a1, 
-		int	a2, 
+int	mvaddchstr(
+		int	a1,
+		int	a2,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvaddnstr
-int	(mvaddnstr)(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+int	mvaddnstr(
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddstr
-int	(mvaddstr)(
-		int	a1, 
-		int	a2, 
+int	mvaddstr(
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvchgat
-int	(mvchgat)(
-		int	a1, 
-		int	a2, 
-		int	a3, 
-		attr_t	a4, 
-		short	a5, 
+int	mvchgat(
+		int	a1,
+		int	a2,
+		int	a3,
+		attr_t	a4,
+		short	a5,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvdelch
-int	(mvdelch)(
-		int	a1, 
+int	mvdelch(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetch
-int	(mvgetch)(
-		int	a1, 
+int	mvgetch(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetnstr
-int	(mvgetnstr)(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+int	mvgetnstr(
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetstr
-int	(mvgetstr)(
-		int	a1, 
-		int	a2, 
+int	mvgetstr(
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvhline
-int	(mvhline)(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+int	mvhline(
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinch
-chtype	(mvinch)(
-		int	a1, 
+chtype	mvinch(
+		int	a1,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvinchnstr
-int	(mvinchnstr)(
-		int	a1, 
-		int	a2, 
-		chtype	*a3, 
+int	mvinchnstr(
+		int	a1,
+		int	a2,
+		chtype	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinchstr
-int	(mvinchstr)(
-		int	a1, 
-		int	a2, 
+int	mvinchstr(
+		int	a1,
+		int	a2,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvinnstr
-int	(mvinnstr)(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+int	mvinnstr(
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsch
-int	(mvinsch)(
-		int	a1, 
-		int	a2, 
+int	mvinsch(
+		int	a1,
+		int	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvinsnstr
-int	(mvinsnstr)(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+int	mvinsnstr(
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsstr
-int	(mvinsstr)(
-		int	a1, 
-		int	a2, 
+int	mvinsstr(
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvinstr
-int	(mvinstr)(
-		int	a1, 
-		int	a2, 
+int	mvinstr(
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvvline
-int	(mvvline)(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+int	mvvline(
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddch
-int	(mvwaddch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwaddch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchnstr
-int	(mvwaddchnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const chtype *a4, 
+int	mvwaddchnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const chtype *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchstr
-int	(mvwaddchstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwaddchstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvwaddnstr
-int	(mvwaddnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+int	mvwaddnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddstr
-int	(mvwaddstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwaddstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwchgat
-int	(mvwchgat)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		int	a4, 
-		attr_t	a5, 
-		short	a6, 
+int	mvwchgat(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		int	a4,
+		attr_t	a5,
+		short	a6,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvwdelch
-int	(mvwdelch)(
-		WINDOW	*a1, 
-		int	a2, 
+int	mvwdelch(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetch
-int	(mvwgetch)(
-		WINDOW	*a1, 
-		int	a2, 
+int	mvwgetch(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetnstr
-int	(mvwgetnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+int	mvwgetnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetstr
-int	(mvwgetstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwgetstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwhline
-int	(mvwhline)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+int	mvwhline(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinch
-chtype	(mvwinch)(
-		WINDOW	*a1, 
-		int	a2, 
+chtype	mvwinch(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvwinchnstr
-int	(mvwinchnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	*a4, 
+int	mvwinchnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinchstr
-int	(mvwinchstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinchstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvwinnstr
-int	(mvwinnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+int	mvwinnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsch
-int	(mvwinsch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinsch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsnstr
-int	(mvwinsnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+int	mvwinsnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsstr
-int	(mvwinsstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinsstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwinstr
-int	(mvwinstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwvline
-int	(mvwvline)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+int	mvwvline(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef PAIR_NUMBER
-int	(PAIR_NUMBER)(
+int	PAIR_NUMBER(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef redrawwin
-int	(redrawwin)(
+int	redrawwin(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef refresh
-int	(refresh)(void)
+int	refresh(void)
 		{ return(*(int *)0); }
 
 #undef scrl
-int	(scrl)(
+int	scrl(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef scroll
-int	(scroll)(
+int	scroll(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef setscrreg
-int	(setscrreg)(
-		int	a1, 
+int	setscrreg(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef standout
-int	(standout)(void)
+int	standout(void)
 		{ return(*(int *)0); }
 
 #undef standend
-int	(standend)(void)
+int	standend(void)
 		{ return(*(int *)0); }
 
 #undef timeout
-void	(timeout)(
+void	timeout(
 		int	z)
 		{ /* void */ }
 
 #undef touchline
-int	(touchline)(
-		WINDOW	*a1, 
-		int	a2, 
+int	touchline(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef touchwin
-int	(touchwin)(
+int	touchwin(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef untouchwin
-int	(untouchwin)(
+int	untouchwin(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef vline
-int	(vline)(
-		chtype	a1, 
+int	vline(
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
-#undef vw_printw
-int	(vw_printw)(
-		WINDOW	*a1, 
-		const char *a2, 
-		va_list	z)
-		{ return(*(int *)0); }
-
-#undef vw_scanw
-int	(vw_scanw)(
-		WINDOW	*a1, 
-		const char *a2, 
-		va_list	z)
-		{ return(*(int *)0); }
-
 #undef waddchstr
-int	(waddchstr)(
-		WINDOW	*a1, 
+int	waddchstr(
+		WINDOW	*a1,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef waddstr
-int	(waddstr)(
-		WINDOW	*a1, 
+int	waddstr(
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef wattron
-int	(wattron)(
-		WINDOW	*a1, 
+int	wattron(
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattroff
-int	(wattroff)(
-		WINDOW	*a1, 
+int	wattroff(
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattrset
-int	(wattrset)(
-		WINDOW	*a1, 
+int	wattrset(
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattr_get
-int	(wattr_get)(
-		WINDOW	*a1, 
-		attr_t	*a2, 
-		short	*a3, 
+int	wattr_get(
+		WINDOW	*a1,
+		attr_t	*a2,
+		short	*a3,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef wattr_set
-int	(wattr_set)(
-		WINDOW	*a1, 
-		attr_t	a2, 
-		short	a3, 
+int	wattr_set(
+		WINDOW	*a1,
+		attr_t	a2,
+		short	a3,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef wdeleteln
-int	(wdeleteln)(
+int	wdeleteln(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef wgetstr
-int	(wgetstr)(
-		WINDOW	*a1, 
+int	wgetstr(
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef winchstr
-int	(winchstr)(
-		WINDOW	*a1, 
+int	winchstr(
+		WINDOW	*a1,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef winsertln
-int	(winsertln)(
+int	winsertln(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef winsstr
-int	(winsstr)(
-		WINDOW	*a1, 
+int	winsstr(
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef winstr
-int	(winstr)(
-		WINDOW	*a1, 
+int	winstr(
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef wstandout
-int	(wstandout)(
+int	wstandout(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef wstandend
-int	(wstandend)(
+int	wstandend(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef getattrs
-int	(getattrs)(
+int	getattrs(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getcurx
-int	(getcurx)(
+int	getcurx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getcury
-int	(getcury)(
+int	getcury(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getbegx
-int	(getbegx)(
+int	getbegx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getbegy
-int	(getbegy)(
+int	getbegy(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getmaxx
-int	(getmaxx)(
+int	getmaxx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getmaxy
-int	(getmaxy)(
+int	getmaxy(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getparx
-int	(getparx)(
+int	getparx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getpary
-int	(getpary)(
+int	getpary(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef wgetparent
-WINDOW	*(wgetparent)(
+WINDOW	*wgetparent(
 		const WINDOW *z)
 		{ return(*(WINDOW **)0); }
 
 #undef is_cleared
-NCURSES_BOOL (is_cleared)(
+NCURSES_BOOL is_cleared(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_idcok
-NCURSES_BOOL (is_idcok)(
+NCURSES_BOOL is_idcok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_idlok
-NCURSES_BOOL (is_idlok)(
+NCURSES_BOOL is_idlok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_immedok
-NCURSES_BOOL (is_immedok)(
+NCURSES_BOOL is_immedok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_keypad
-NCURSES_BOOL (is_keypad)(
+NCURSES_BOOL is_keypad(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_leaveok
-NCURSES_BOOL (is_leaveok)(
+NCURSES_BOOL is_leaveok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_nodelay
-NCURSES_BOOL (is_nodelay)(
+NCURSES_BOOL is_nodelay(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_notimeout
-NCURSES_BOOL (is_notimeout)(
+NCURSES_BOOL is_notimeout(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_pad
-NCURSES_BOOL (is_pad)(
+NCURSES_BOOL is_pad(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_scrollok
-NCURSES_BOOL (is_scrollok)(
+NCURSES_BOOL is_scrollok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_subwin
-NCURSES_BOOL (is_subwin)(
+NCURSES_BOOL is_subwin(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_syncok
-NCURSES_BOOL (is_syncok)(
+NCURSES_BOOL is_syncok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef wgetdelay
-int	(wgetdelay)(
+int	wgetdelay(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef wgetscrreg
-int	(wgetscrreg)(
-		const WINDOW *a1, 
-		int	*a2, 
+int	wgetscrreg(
+		const WINDOW *a1,
+		int	*a2,
 		int	*z)
 		{ return(*(int *)0); }
 
 #undef mouse_trafo
-NCURSES_BOOL (mouse_trafo)(
-		int	*a1, 
-		int	*a2, 
+NCURSES_BOOL mouse_trafo(
+		int	*a1,
+		int	*a2,
 		NCURSES_BOOL z)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1263,7 +1287,7 @@
 
 #undef set_escdelay_sp
 int	set_escdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -1283,8 +1307,8 @@
 
 #undef _nc_wgetch
 int	_nc_wgetch(
-		WINDOW	*win, 
-		int	*result, 
+		WINDOW	*win,
+		int	*result,
 		int	use_meta)
 		{ return(*(int *)0); }
 
@@ -1297,8 +1321,8 @@
 
 #undef wgetnstr
 int	wgetnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	maxlen)
 		{ return(*(int *)0); }
 
@@ -1306,8 +1330,8 @@
 
 #undef whline
 int	whline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1315,7 +1339,7 @@
 
 #undef immedok
 void	immedok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
@@ -1323,8 +1347,8 @@
 
 #undef winchnstr
 int	winchnstr(
-		WINDOW	*win, 
-		chtype	*str, 
+		WINDOW	*win,
+		chtype	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1338,14 +1362,14 @@
 
 #undef _nc_insert_ch
 int	_nc_insert_ch(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
 #undef winsch
 int	winsch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	c)
 		{ return(*(int *)0); }
 
@@ -1353,7 +1377,7 @@
 
 #undef winsdelln
 int	winsdelln(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1361,8 +1385,8 @@
 
 #undef winsnstr
 int	winsnstr(
-		WINDOW	*win, 
-		const char *s, 
+		WINDOW	*win,
+		const char *s,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1370,8 +1394,8 @@
 
 #undef winnstr
 int	winnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1390,7 +1414,7 @@
 
 #undef leaveok
 int	leaveok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -1398,7 +1422,7 @@
 
 #undef getmouse_sp
 int	getmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -1409,7 +1433,7 @@
 
 #undef ungetmouse_sp
 int	ungetmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -1420,27 +1444,27 @@
 
 #undef mousemask_sp
 mmask_t	mousemask_sp(
-		SCREEN	*sp, 
-		mmask_t	newmask, 
+		SCREEN	*sp,
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef mousemask
 mmask_t	mousemask(
-		mmask_t	newmask, 
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef wenclose
 NCURSES_BOOL wenclose(
-		const WINDOW *win, 
-		int	y, 
+		const WINDOW *win,
+		int	y,
 		int	x)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef mouseinterval_sp
 int	mouseinterval_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	maxclick)
 		{ return(*(int *)0); }
 
@@ -1465,9 +1489,9 @@
 
 #undef wmouse_trafo
 NCURSES_BOOL wmouse_trafo(
-		const WINDOW *win, 
-		int	*pY, 
-		int	*pX, 
+		const WINDOW *win,
+		int	*pY,
+		int	*pX,
 		NCURSES_BOOL to_screen)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1475,8 +1499,8 @@
 
 #undef wmove
 int	wmove(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
@@ -1484,14 +1508,14 @@
 
 #undef _nc_msec_cost_sp
 int	_nc_msec_cost_sp(
-		SCREEN	*sp, 
-		const char *const cap, 
+		SCREEN	*sp,
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
 #undef _nc_msec_cost
 int	_nc_msec_cost(
-		const char *const cap, 
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
@@ -1524,35 +1548,35 @@
 
 #undef _nc_mvcur_sp
 int	_nc_mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef _nc_mvcur
 int	_nc_mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur_sp
 int	mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur
 int	mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
@@ -1563,8 +1587,8 @@
 
 #undef mvwin
 int	mvwin(
-		WINDOW	*win, 
-		int	by, 
+		WINDOW	*win,
+		int	by,
 		int	bx)
 		{ return(*(int *)0); }
 
@@ -1590,16 +1614,16 @@
 
 #undef newterm_sp
 SCREEN	*newterm_sp(
-		SCREEN	*sp, 
-		const char *name, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
 #undef newterm
 SCREEN	*newterm(
-		const char *name, 
-		FILE	*ofp, 
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
@@ -1612,46 +1636,46 @@
 
 #undef newwin_sp
 WINDOW	*newwin_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef newwin
 WINDOW	*newwin(
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef derwin
 WINDOW	*derwin(
-		WINDOW	*orig, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		WINDOW	*orig,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef subwin
 WINDOW	*subwin(
-		WINDOW	*w, 
-		int	l, 
-		int	c, 
-		int	y, 
+		WINDOW	*w,
+		int	l,
+		int	c,
+		int	y,
 		int	x)
 		{ return(*(WINDOW **)0); }
 
 #undef _nc_makenew_sp
 WINDOW	*_nc_makenew_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
-		int	begx, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
+		int	begx,
 		int	flags)
 		{ return(*(WINDOW **)0); }
 
@@ -1694,26 +1718,26 @@
 
 #undef overlay
 int	overlay(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef overwrite
 int	overwrite(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef copywin
 int	copywin(
-		const WINDOW *src, 
-		WINDOW	*dst, 
-		int	sminrow, 
-		int	smincol, 
-		int	dminrow, 
-		int	dmincol, 
-		int	dmaxrow, 
-		int	dmaxcol, 
+		const WINDOW *src,
+		WINDOW	*dst,
+		int	sminrow,
+		int	smincol,
+		int	dminrow,
+		int	dmincol,
+		int	dmaxrow,
+		int	dmaxcol,
 		int	over)
 		{ return(*(int *)0); }
 
@@ -1721,51 +1745,51 @@
 
 #undef newpad_sp
 WINDOW	*newpad_sp(
-		SCREEN	*sp, 
-		int	l, 
+		SCREEN	*sp,
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef newpad
 WINDOW	*newpad(
-		int	l, 
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef subpad
 WINDOW	*subpad(
-		WINDOW	*orig, 
-		int	l, 
-		int	c, 
-		int	begy, 
+		WINDOW	*orig,
+		int	l,
+		int	c,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef prefresh
 int	prefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pnoutrefresh
 int	pnoutrefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pechochar
 int	pechochar(
-		WINDOW	*pad, 
+		WINDOW	*pad,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -1773,38 +1797,45 @@
 
 #undef printw
 int	printw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wprintw
 int	wprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvprintw
 int	mvprintw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwprintw
 int	mvwprintw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef vwprintw
 int	vwprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
+		va_list	argp)
+		{ return(*(int *)0); }
+
+#undef vw_printw
+int	vw_printw(
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
@@ -1812,8 +1843,8 @@
 
 #undef wredrawln
 int	wredrawln(
-		WINDOW	*win, 
-		int	beg, 
+		WINDOW	*win,
+		int	beg,
 		int	num)
 		{ return(*(int *)0); }
 
@@ -1833,16 +1864,16 @@
 
 #undef restartterm_sp
 int	restartterm_sp(
-		SCREEN	*sp, 
-		const char *termp, 
-		int	filenum, 
+		SCREEN	*sp,
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
 #undef restartterm
 int	restartterm(
-		const char *termp, 
-		int	filenum, 
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -1850,38 +1881,45 @@
 
 #undef vwscanw
 int	vwscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
+		va_list	argp)
+		{ return(*(int *)0); }
+
+#undef vw_scanw
+int	vw_scanw(
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef scanw
 int	scanw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wscanw
 int	wscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvscanw
 int	mvscanw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwscanw
 int	mvwscanw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
@@ -1889,7 +1927,7 @@
 
 #undef getwin_sp
 WINDOW	*getwin_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		FILE	*filep)
 		{ return(*(WINDOW **)0); }
 
@@ -1900,13 +1938,13 @@
 
 #undef putwin
 int	putwin(
-		WINDOW	*win, 
+		WINDOW	*win,
 		FILE	*filep)
 		{ return(*(int *)0); }
 
 #undef scr_restore_sp
 int	scr_restore_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -1922,7 +1960,7 @@
 
 #undef scr_init_sp
 int	scr_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -1933,7 +1971,7 @@
 
 #undef scr_set_sp
 int	scr_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -1946,16 +1984,16 @@
 
 #undef _nc_scroll_window
 void	_nc_scroll_window(
-		WINDOW	*win, 
-		int const n, 
-		int const top, 
-		int const bottom, 
+		WINDOW	*win,
+		int const n,
+		int const top,
+		int const bottom,
 		chtype	blank)
 		{ /* void */ }
 
 #undef wscrl
 int	wscrl(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1963,7 +2001,7 @@
 
 #undef scrollok
 int	scrollok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -1971,8 +2009,8 @@
 
 #undef wsetscrreg
 int	wsetscrreg(
-		WINDOW	*win, 
-		int	top, 
+		WINDOW	*win,
+		int	top,
 		int	bottom)
 		{ return(*(int *)0); }
 
@@ -1990,54 +2028,54 @@
 
 #undef _nc_setupscreen_sp
 int	_nc_setupscreen_sp(
-		SCREEN	**spp, 
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		SCREEN	**spp,
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_setupscreen
 int	_nc_setupscreen(
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline_sp
 int	_nc_ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline
 int	_nc_ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline_sp
 int	ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline
 int	ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
@@ -2045,13 +2083,13 @@
 
 #undef _nc_format_slks
 int	_nc_format_slks(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	cols)
 		{ return(*(int *)0); }
 
 #undef _nc_slk_initialize
 int	_nc_slk_initialize(
-		WINDOW	*stwin, 
+		WINDOW	*stwin,
 		int	cols)
 		{ return(*(int *)0); }
 
@@ -2068,16 +2106,16 @@
 
 #undef slk_attr_set_sp
 int	slk_attr_set_sp(
-		SCREEN	*sp, 
-		const attr_t attr, 
-		short	color_pair_number, 
+		SCREEN	*sp,
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 #undef slk_attr_set
 int	slk_attr_set(
-		const attr_t attr, 
-		short	color_pair_number, 
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2085,7 +2123,7 @@
 
 #undef slk_attroff_sp
 int	slk_attroff_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2098,7 +2136,7 @@
 
 #undef slk_attron_sp
 int	slk_attron_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2111,7 +2149,7 @@
 
 #undef slk_attrset_sp
 int	slk_attrset_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2146,20 +2184,20 @@
 
 #undef slk_color_sp
 int	slk_color_sp(
-		SCREEN	*sp, 
-		short	color_pair_number)
+		SCREEN	*sp,
+		short	pair_arg)
 		{ return(*(int *)0); }
 
 #undef slk_color
 int	slk_color(
-		short	color_pair_number)
+		short	pair_arg)
 		{ return(*(int *)0); }
 
 /* ./base/lib_slkinit.c */
 
 #undef slk_init_sp
 int	slk_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2172,7 +2210,7 @@
 
 #undef slk_label_sp
 char	*slk_label_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	n)
 		{ return(*(char **)0); }
 
@@ -2205,16 +2243,16 @@
 
 #undef slk_set_sp
 int	slk_set_sp(
-		SCREEN	*sp, 
-		int	i, 
-		const char *astr, 
+		SCREEN	*sp,
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
 #undef slk_set
 int	slk_set(
-		int	i, 
-		const char *astr, 
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2233,7 +2271,7 @@
 
 #undef is_linetouched
 NCURSES_BOOL is_linetouched(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	line)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -2244,9 +2282,9 @@
 
 #undef wtouchln
 int	wtouchln(
-		WINDOW	*win, 
-		int	y, 
-		int	n, 
+		WINDOW	*win,
+		int	y,
+		int	n,
 		int	changed)
 		{ return(*(int *)0); }
 
@@ -2254,7 +2292,7 @@
 
 #undef _tracedump
 void	_tracedump(
-		const char *name, 
+		const char *name,
 		WINDOW	*win)
 		{ /* void */ }
 
@@ -2262,19 +2300,19 @@
 
 #undef _nc_trace_mmask_t
 char	*_nc_trace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(char **)0); }
 
 #undef _nc_tracemouse
 char	*_nc_tracemouse(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT const *ep)
 		{ return(*(char **)0); }
 
 #undef _nc_retrace_mmask_t
 mmask_t	_nc_retrace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(mmask_t *)0); }
 
@@ -2299,7 +2337,7 @@
 
 #undef ungetch_sp
 int	ungetch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -2312,20 +2350,20 @@
 
 #undef vidputs_sp
 int	vidputs_sp(
-		SCREEN	*sp, 
-		chtype	newmode, 
+		SCREEN	*sp,
+		chtype	newmode,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef vidputs
 int	vidputs(
-		chtype	newmode, 
+		chtype	newmode,
 		NCURSES_OUTC outc)
 		{ return(*(int *)0); }
 
 #undef vidattr_sp
 int	vidattr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	newmode)
 		{ return(*(int *)0); }
 
@@ -2347,8 +2385,8 @@
 
 #undef wvline
 int	wvline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2356,8 +2394,8 @@
 
 #undef wattr_off
 int	wattr_off(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2365,8 +2403,8 @@
 
 #undef wattr_on
 int	wattr_on(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2386,14 +2424,14 @@
 
 #undef mvderwin
 int	mvderwin(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
 #undef syncok
 int	syncok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL bf)
 		{ return(*(int *)0); }
 
@@ -2432,14 +2470,14 @@
 
 #undef _nc_printf_string_sp
 char	*_nc_printf_string_sp(
-		SCREEN	*sp, 
-		const char *fmt, 
+		SCREEN	*sp,
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
 #undef _nc_printf_string
 char	*_nc_printf_string(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -2456,18 +2494,18 @@
 
 #undef _nc_scrolln_sp
 int	_nc_scrolln_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
-		int	bot, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
 #undef _nc_scrolln
 int	_nc_scrolln(
-		int	n, 
-		int	top, 
-		int	bot, 
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
@@ -2500,7 +2538,7 @@
 
 #undef _nc_do_xmc_glitch_sp
 void	_nc_do_xmc_glitch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		attr_t	previous)
 		{ /* void */ }
 
@@ -2511,13 +2549,9 @@
 
 /* ./trace/varargs.c */
 
-typedef enum {
-    atUnknown = 0, atInteger, atFloat, atPoint, atString
-} ARGTYPE;
-
 #undef _nc_varargs
 char	*_nc_varargs(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -2535,7 +2569,7 @@
 
 #undef _nc_free_and_exit_sp
 void	_nc_free_and_exit_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	code)
 		{ /* void */ }
 
@@ -2544,35 +2578,40 @@
 		int	code)
 		{ /* void */ }
 
+#undef exit_curses
+void	exit_curses(
+		int	code)
+		{ /* void */ }
+
 /* ./expanded.c */
 
 #undef _nc_toggle_attr_on
 void	_nc_toggle_attr_on(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_toggle_attr_off
 void	_nc_toggle_attr_off(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_DelCharCost_sp
 int	_nc_DelCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_InsCharCost_sp
 int	_nc_InsCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_UpdateAttrs_sp
 void	_nc_UpdateAttrs_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	c)
 		{ /* void */ }
 
@@ -2595,7 +2634,7 @@
 
 #undef use_legacy_coding_sp
 int	use_legacy_coding_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	level)
 		{ return(*(int *)0); }
 
@@ -2617,14 +2656,14 @@
 
 #undef assume_default_colors_sp
 int	assume_default_colors_sp(
-		SCREEN	*sp, 
-		int	fg, 
+		SCREEN	*sp,
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
 #undef assume_default_colors
 int	assume_default_colors(
-		int	fg, 
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
@@ -2632,55 +2671,61 @@
 
 #undef mcprint_sp
 int	mcprint_sp(
-		SCREEN	*sp, 
-		char	*data, 
+		SCREEN	*sp,
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
 #undef mcprint
 int	mcprint(
-		char	*data, 
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
+/* ./base/new_pair.c */
+
+#undef _nc_new_pair
+void	_nc_new_pair(void)
+		{ /* void */ }
+
 /* ./base/resizeterm.c */
 
 #undef is_term_resized_sp
 NCURSES_BOOL is_term_resized_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_term_resized
 NCURSES_BOOL is_term_resized(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef resize_term_sp
 int	resize_term_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resize_term
 int	resize_term(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm_sp
 int	resizeterm_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm
 int	resizeterm(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -2695,8 +2740,8 @@
 
 #undef use_screen
 int	use_screen(
-		SCREEN	*screen, 
-		NCURSES_SCREEN_CB func, 
+		SCREEN	*screen,
+		NCURSES_SCREEN_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -2704,8 +2749,8 @@
 
 #undef use_window
 int	use_window(
-		WINDOW	*win, 
-		NCURSES_WINDOW_CB func, 
+		WINDOW	*win,
+		NCURSES_WINDOW_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -2713,8 +2758,8 @@
 
 #undef wresize
 int	wresize(
-		WINDOW	*win, 
-		int	ToLines, 
+		WINDOW	*win,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -2742,7 +2787,7 @@
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -2760,12 +2805,25 @@
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -2773,13 +2831,13 @@
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE *to, 
+		TERMTYPE *to,
 		TERMTYPE *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
@@ -2844,19 +2902,19 @@
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -2864,17 +2922,32 @@
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
+#undef _nc_find_user_entry
+struct user_table_entry const *_nc_find_user_entry(
+		const char *string)
+		{ return(*(struct user_table_entry const **)0); }
+
+/* ./comp_userdefs.c */
+
+#undef _nc_get_userdefs_table
+const struct user_table_entry *_nc_get_userdefs_table(void)
+		{ return(*(const struct user_table_entry **)0); }
+
+#undef _nc_get_hash_user
+const HashData *_nc_get_hash_user(void)
+		{ return(*(const HashData **)0); }
+
 /* ./tinfo/db_iterator.c */
 
 #undef _nc_tic_dir
@@ -2893,13 +2966,13 @@
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -2907,7 +2980,7 @@
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -2920,7 +2993,7 @@
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
+		ENTRY	*headp,
 		TERMTYPE *tterm)
 		{ /* void */ }
 
@@ -2929,16 +3002,15 @@
 		ENTRY	*headp)
 		{ /* void */ }
 
-#undef _nc_delink_entry
-ENTRY	*_nc_delink_entry(
-		ENTRY	*headp, 
-		TERMTYPE *tterm)
-		{ return(*(ENTRY **)0); }
-
 #undef _nc_leaks_tinfo
 void	_nc_leaks_tinfo(void)
 		{ /* void */ }
 
+#undef exit_terminfo
+void	exit_terminfo(
+		int	code)
+		{ /* void */ }
+
 /* ./fallback.c */
 
 #undef _nc_fallback
@@ -2953,6 +3025,11 @@
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
 #undef _nc_user_definable
 NCURSES_BOOL _nc_user_definable;
 
@@ -2970,7 +3047,7 @@
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -3004,8 +3081,8 @@
 /* ./tinfo/lib_baudrate.c */
 
 struct speed {
-    short s; 
-    int sp; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -3034,7 +3111,7 @@
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -3045,7 +3122,7 @@
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -3131,7 +3208,7 @@
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -3155,7 +3232,7 @@
 
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -3168,19 +3245,19 @@
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -3191,37 +3268,37 @@
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -3232,7 +3309,7 @@
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -3243,7 +3320,7 @@
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -3254,14 +3331,14 @@
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -3323,17 +3400,53 @@
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
 /* ./tinfo/lib_setup.c */
 
 #undef ttytype
@@ -3347,7 +3460,7 @@
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -3363,13 +3476,13 @@
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -3385,8 +3498,8 @@
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -3397,13 +3510,13 @@
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
+		const char *const tn,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -3422,9 +3535,9 @@
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
@@ -3434,8 +3547,8 @@
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -3448,20 +3561,20 @@
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -3472,7 +3585,7 @@
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -3483,14 +3596,14 @@
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -3509,8 +3622,8 @@
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -3518,7 +3631,7 @@
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -3529,7 +3642,7 @@
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -3540,7 +3653,7 @@
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -3554,25 +3667,58 @@
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
+#undef _nc_tiparm
+char	*_nc_tiparm(
+		int	expected,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -3589,7 +3735,7 @@
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -3609,7 +3755,7 @@
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -3620,7 +3766,7 @@
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -3631,7 +3777,7 @@
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -3642,35 +3788,35 @@
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -3684,6 +3830,11 @@
 #undef _nc_outchars
 long	_nc_outchars;
 
+#undef curses_trace
+unsigned curses_trace(
+		unsigned tracelevel)
+		{ return(*(unsigned *)0); }
+
 #undef trace
 void	trace(
 		const unsigned int tracelevel)
@@ -3691,7 +3842,7 @@
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -3745,11 +3896,18 @@
 		WINDOW	*code)
 		{ return(*(WINDOW **)0); }
 
+#undef _nc_fmt_funcptr
+char	*_nc_fmt_funcptr(
+		char	*target,
+		const char *source,
+		size_t	size)
+		{ return(*(char **)0); }
+
 /* ./trace/lib_traceatr.c */
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -3770,13 +3928,13 @@
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -3792,14 +3950,9 @@
 
 /* ./trace/lib_tracebits.c */
 
-typedef struct {
-    unsigned int val;
-    const char name[8];
-} BITNAMES;
-
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -3810,7 +3963,7 @@
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -3823,7 +3976,7 @@
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -3834,7 +3987,7 @@
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -3901,9 +4054,9 @@
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -3916,8 +4069,8 @@
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -3940,14 +4093,14 @@
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
@@ -3960,60 +4113,62 @@
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE *ptr, 
-		char	*buffer, 
+		TERMTYPE *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
+		const char *const filename,
 		TERMTYPE *ptr)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/read_termcap.c */
 
-#undef _nc_read_termcap
-void	_nc_read_termcap(void)
-		{ /* void */ }
+#undef _nc_read_termcap_entry
+int	_nc_read_termcap_entry(
+		const char *const tn,
+		TERMTYPE *const tp)
+		{ return(*(int *)0); }
 
 /* ./tinfo/strings.c */
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -4021,13 +4176,13 @@
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -4042,21 +4197,21 @@
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -4071,7 +4226,7 @@
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -4084,7 +4239,7 @@
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -4095,20 +4250,20 @@
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const chtype *buf, 
+		int	bufnum,
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const chtype *buf, 
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -4116,7 +4271,7 @@
 
 #undef _nc_init_entry
 void	_nc_init_entry(
-		TERMTYPE *const tp)
+		ENTRY	*const tp)
 		{ /* void */ }
 
 #undef _nc_copy_entry
@@ -4126,34 +4281,34 @@
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		TERMTYPE *const to, 
-		TERMTYPE *const from)
+		ENTRY	*const target,
+		ENTRY	*const source)
 		{ /* void */ }
 
 /* ./tinfo/captoinfo.c */
 
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -4161,8 +4316,8 @@
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -4170,39 +4325,31 @@
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE *p1, 
+		TERMTYPE *p1,
 		NCURSES_BOOL p2);
-#undef _nc_check_termtype
-void	(*_nc_check_termtype)(
-		TERMTYPE *p1);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
-#undef _nc_resolve_uses
-int	_nc_resolve_uses(
-		NCURSES_BOOL fullresolve)
-		{ return(*(int *)0); }
-
 /* ./tinfo/comp_scan.c */
 
 #undef _nc_syntax
@@ -4224,7 +4371,7 @@
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -4235,8 +4382,8 @@
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -4253,22 +4400,17 @@
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		struct entry *entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
-typedef struct {
-    const char from[3];
-    const char to[6];
-} assoc;
-
 /* ./tinfo/write_entry.c */
 
 #undef _nc_set_writedir
@@ -4281,6 +4423,14 @@
 		TERMTYPE *const tp)
 		{ /* void */ }
 
+#undef _nc_write_object
+int	_nc_write_object(
+		TERMTYPE *tp,
+		char	*buffer,
+		unsigned *offset,
+		unsigned limit)
+		{ return(*(int *)0); }
+
 #undef _nc_tic_written
 int	_nc_tic_written(void)
 		{ return(*(int *)0); }
@@ -4289,14 +4439,14 @@
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -4310,7 +4460,7 @@
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -4323,14 +4473,14 @@
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -4338,14 +4488,14 @@
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/ncurses/llib-lncursest b/ncurses/llib-lncursest
index c787f30..7c8bac9 100644
--- a/ncurses/llib-lncursest
+++ b/ncurses/llib-lncursest
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2008-2013,2015 Free Software Foundation, Inc.              *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2008-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -69,7 +70,7 @@
 
 #undef _nc_make_oldhash_sp
 void	_nc_make_oldhash_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	i)
 		{ /* void */ }
 
@@ -80,16 +81,16 @@
 
 #undef _nc_scroll_oldhash_sp
 void	_nc_scroll_oldhash_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
 #undef _nc_scroll_oldhash
 void	_nc_scroll_oldhash(
-		int	n, 
-		int	top, 
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
@@ -97,25 +98,25 @@
 
 #undef _nc_render
 chtype	_nc_render(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(chtype *)0); }
 
 #undef _nc_waddch_nosync
 int	_nc_waddch_nosync(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype c)
 		{ return(*(int *)0); }
 
 #undef waddch
 int	waddch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
 #undef wechochar
 int	wechochar(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -123,15 +124,15 @@
 
 #undef waddnstr
 int	waddnstr(
-		WINDOW	*win, 
-		const char *astr, 
+		WINDOW	*win,
+		const char *astr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef waddchnstr
 int	waddchnstr(
-		WINDOW	*win, 
-		const chtype *astr, 
+		WINDOW	*win,
+		const chtype *astr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -150,13 +151,13 @@
 
 #undef wbkgdset
 void	wbkgdset(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ /* void */ }
 
 #undef wbkgd
 int	wbkgd(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
@@ -164,14 +165,14 @@
 
 #undef wborder
 int	wborder(
-		WINDOW	*win, 
-		chtype	ls, 
-		chtype	rs, 
-		chtype	ts, 
-		chtype	bs, 
-		chtype	tl, 
-		chtype	tr, 
-		chtype	bl, 
+		WINDOW	*win,
+		chtype	ls,
+		chtype	rs,
+		chtype	ts,
+		chtype	bs,
+		chtype	tl,
+		chtype	tr,
+		chtype	bl,
 		chtype	br)
 		{ return(*(int *)0); }
 
@@ -179,10 +180,10 @@
 
 #undef wchgat
 int	wchgat(
-		WINDOW	*win, 
-		int	n, 
-		attr_t	attr, 
-		short	color, 
+		WINDOW	*win,
+		int	n,
+		attr_t	attr,
+		short	pair_arg,
 		const void *opts)
 		{ return(*(int *)0); }
 
@@ -197,7 +198,7 @@
 
 #undef clearok
 int	clearok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -243,35 +244,64 @@
 int	start_color(void)
 		{ return(*(int *)0); }
 
+#undef _nc_change_pair
+void	_nc_change_pair(
+		SCREEN	*sp,
+		int	pair)
+		{ /* void */ }
+
+#undef _nc_reserve_pairs
+void	_nc_reserve_pairs(
+		SCREEN	*sp,
+		int	want)
+		{ /* void */ }
+
+#undef _nc_init_pair
+int	_nc_init_pair(
+		SCREEN	*sp,
+		int	pair,
+		int	f,
+		int	b)
+		{ return(*(int *)0); }
+
 #undef init_pair_sp
 int	init_pair_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	f, 
+		SCREEN	*sp,
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_pair
 int	init_pair(
-		short	pair, 
-		short	f, 
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
+#undef _nc_init_color
+int	_nc_init_color(
+		SCREEN	*sp,
+		int	color,
+		int	r,
+		int	g,
+		int	b)
+		{ return(*(int *)0); }
+
 #undef init_color_sp
 int	init_color_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	r, 
-		short	g, 
+		SCREEN	*sp,
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_color
 int	init_color(
-		short	color, 
-		short	r, 
-		short	g, 
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
@@ -295,50 +325,58 @@
 
 #undef color_content_sp
 int	color_content_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	*r, 
-		short	*g, 
+		SCREEN	*sp,
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef color_content
 int	color_content(
-		short	color, 
-		short	*r, 
-		short	*g, 
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
+#undef _nc_pair_content
+int	_nc_pair_content(
+		SCREEN	*sp,
+		int	pair,
+		int	*f,
+		int	*b)
+		{ return(*(int *)0); }
+
 #undef pair_content_sp
 int	pair_content_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	*f, 
+		SCREEN	*sp,
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef pair_content
 int	pair_content(
-		short	pair, 
-		short	*f, 
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef _nc_do_color_sp
 void	_nc_do_color_sp(
-		SCREEN	*sp, 
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		SCREEN	*sp,
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC_sp outc)
 		{ /* void */ }
 
 #undef _nc_do_color
 void	_nc_do_color(
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC outc)
 		{ /* void */ }
 
@@ -346,8 +384,8 @@
 
 #undef wcolor_set
 int	wcolor_set(
-		WINDOW	*win, 
-		short	color_pair_number, 
+		WINDOW	*win,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -417,845 +455,831 @@
 /* ./lib_gen.c */
 
 #undef addch
-int	(addch)(
+int	addch(
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef addchnstr
-int	(addchnstr)(
-		const chtype *a1, 
+int	addchnstr(
+		const chtype *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef addchstr
-int	(addchstr)(
+int	addchstr(
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef addnstr
-int	(addnstr)(
-		const char *a1, 
+int	addnstr(
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef addstr
-int	(addstr)(
+int	addstr(
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef attroff
-int	(attroff)(
+int	attroff(
 		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attron
-int	(attron)(
+int	attron(
 		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attrset
-int	(attrset)(
+int	attrset(
 		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attr_get
-int	(attr_get)(
-		attr_t	*a1, 
-		short	*a2, 
+int	attr_get(
+		attr_t	*a1,
+		short	*a2,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_off
-int	(attr_off)(
-		attr_t	a1, 
+int	attr_off(
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_on
-int	(attr_on)(
-		attr_t	a1, 
+int	attr_on(
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_set
-int	(attr_set)(
-		attr_t	a1, 
-		short	a2, 
+int	attr_set(
+		attr_t	a1,
+		short	a2,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef bkgd
-int	(bkgd)(
+int	bkgd(
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef bkgdset
-void	(bkgdset)(
+void	bkgdset(
 		chtype	z)
 		{ /* void */ }
 
 #undef border
-int	(border)(
-		chtype	a1, 
-		chtype	a2, 
-		chtype	a3, 
-		chtype	a4, 
-		chtype	a5, 
-		chtype	a6, 
-		chtype	a7, 
+int	border(
+		chtype	a1,
+		chtype	a2,
+		chtype	a3,
+		chtype	a4,
+		chtype	a5,
+		chtype	a6,
+		chtype	a7,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef box
-int	(box)(
-		WINDOW	*a1, 
-		chtype	a2, 
+int	box(
+		WINDOW	*a1,
+		chtype	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef chgat
-int	(chgat)(
-		int	a1, 
-		attr_t	a2, 
-		short	a3, 
+int	chgat(
+		int	a1,
+		attr_t	a2,
+		short	a3,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef clear
-int	(clear)(void)
+int	clear(void)
 		{ return(*(int *)0); }
 
 #undef clrtobot
-int	(clrtobot)(void)
+int	clrtobot(void)
 		{ return(*(int *)0); }
 
 #undef clrtoeol
-int	(clrtoeol)(void)
+int	clrtoeol(void)
 		{ return(*(int *)0); }
 
 #undef color_set
-int	(color_set)(
-		short	a1, 
+int	color_set(
+		short	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef COLOR_PAIR
-int	(COLOR_PAIR)(
+int	COLOR_PAIR(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef delch
-int	(delch)(void)
+int	delch(void)
 		{ return(*(int *)0); }
 
 #undef deleteln
-int	(deleteln)(void)
+int	deleteln(void)
 		{ return(*(int *)0); }
 
 #undef echochar
-int	(echochar)(
+int	echochar(
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef erase
-int	(erase)(void)
+int	erase(void)
 		{ return(*(int *)0); }
 
 #undef getbkgd
-chtype	(getbkgd)(
+chtype	getbkgd(
 		WINDOW	*z)
 		{ return(*(chtype *)0); }
 
 #undef getch
-int	(getch)(void)
+int	getch(void)
 		{ return(*(int *)0); }
 
 #undef getnstr
-int	(getnstr)(
-		char	*a1, 
+int	getnstr(
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef getstr
-int	(getstr)(
+int	getstr(
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef hline
-int	(hline)(
-		chtype	a1, 
+int	hline(
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef inch
-chtype	(inch)(void)
+chtype	inch(void)
 		{ return(*(chtype *)0); }
 
 #undef inchnstr
-int	(inchnstr)(
-		chtype	*a1, 
+int	inchnstr(
+		chtype	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef inchstr
-int	(inchstr)(
+int	inchstr(
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef innstr
-int	(innstr)(
-		char	*a1, 
+int	innstr(
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef insch
-int	(insch)(
+int	insch(
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef insdelln
-int	(insdelln)(
+int	insdelln(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef insertln
-int	(insertln)(void)
+int	insertln(void)
 		{ return(*(int *)0); }
 
 #undef insnstr
-int	(insnstr)(
-		const char *a1, 
+int	insnstr(
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef insstr
-int	(insstr)(
+int	insstr(
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef instr
-int	(instr)(
+int	instr(
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef move
-int	(move)(
-		int	a1, 
+int	move(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddch
-int	(mvaddch)(
-		int	a1, 
-		int	a2, 
+int	mvaddch(
+		int	a1,
+		int	a2,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvaddchnstr
-int	(mvaddchnstr)(
-		int	a1, 
-		int	a2, 
-		const chtype *a3, 
+int	mvaddchnstr(
+		int	a1,
+		int	a2,
+		const chtype *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddchstr
-int	(mvaddchstr)(
-		int	a1, 
-		int	a2, 
+int	mvaddchstr(
+		int	a1,
+		int	a2,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvaddnstr
-int	(mvaddnstr)(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+int	mvaddnstr(
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddstr
-int	(mvaddstr)(
-		int	a1, 
-		int	a2, 
+int	mvaddstr(
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvchgat
-int	(mvchgat)(
-		int	a1, 
-		int	a2, 
-		int	a3, 
-		attr_t	a4, 
-		short	a5, 
+int	mvchgat(
+		int	a1,
+		int	a2,
+		int	a3,
+		attr_t	a4,
+		short	a5,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvdelch
-int	(mvdelch)(
-		int	a1, 
+int	mvdelch(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetch
-int	(mvgetch)(
-		int	a1, 
+int	mvgetch(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetnstr
-int	(mvgetnstr)(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+int	mvgetnstr(
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetstr
-int	(mvgetstr)(
-		int	a1, 
-		int	a2, 
+int	mvgetstr(
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvhline
-int	(mvhline)(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+int	mvhline(
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinch
-chtype	(mvinch)(
-		int	a1, 
+chtype	mvinch(
+		int	a1,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvinchnstr
-int	(mvinchnstr)(
-		int	a1, 
-		int	a2, 
-		chtype	*a3, 
+int	mvinchnstr(
+		int	a1,
+		int	a2,
+		chtype	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinchstr
-int	(mvinchstr)(
-		int	a1, 
-		int	a2, 
+int	mvinchstr(
+		int	a1,
+		int	a2,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvinnstr
-int	(mvinnstr)(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+int	mvinnstr(
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsch
-int	(mvinsch)(
-		int	a1, 
-		int	a2, 
+int	mvinsch(
+		int	a1,
+		int	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvinsnstr
-int	(mvinsnstr)(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+int	mvinsnstr(
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsstr
-int	(mvinsstr)(
-		int	a1, 
-		int	a2, 
+int	mvinsstr(
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvinstr
-int	(mvinstr)(
-		int	a1, 
-		int	a2, 
+int	mvinstr(
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvvline
-int	(mvvline)(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+int	mvvline(
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddch
-int	(mvwaddch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwaddch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchnstr
-int	(mvwaddchnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const chtype *a4, 
+int	mvwaddchnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const chtype *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchstr
-int	(mvwaddchstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwaddchstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvwaddnstr
-int	(mvwaddnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+int	mvwaddnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddstr
-int	(mvwaddstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwaddstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwchgat
-int	(mvwchgat)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		int	a4, 
-		attr_t	a5, 
-		short	a6, 
+int	mvwchgat(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		int	a4,
+		attr_t	a5,
+		short	a6,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvwdelch
-int	(mvwdelch)(
-		WINDOW	*a1, 
-		int	a2, 
+int	mvwdelch(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetch
-int	(mvwgetch)(
-		WINDOW	*a1, 
-		int	a2, 
+int	mvwgetch(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetnstr
-int	(mvwgetnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+int	mvwgetnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetstr
-int	(mvwgetstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwgetstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwhline
-int	(mvwhline)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+int	mvwhline(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinch
-chtype	(mvwinch)(
-		WINDOW	*a1, 
-		int	a2, 
+chtype	mvwinch(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvwinchnstr
-int	(mvwinchnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	*a4, 
+int	mvwinchnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinchstr
-int	(mvwinchstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinchstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvwinnstr
-int	(mvwinnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+int	mvwinnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsch
-int	(mvwinsch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinsch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsnstr
-int	(mvwinsnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+int	mvwinsnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsstr
-int	(mvwinsstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinsstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwinstr
-int	(mvwinstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwvline
-int	(mvwvline)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+int	mvwvline(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef PAIR_NUMBER
-int	(PAIR_NUMBER)(
+int	PAIR_NUMBER(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef redrawwin
-int	(redrawwin)(
+int	redrawwin(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef refresh
-int	(refresh)(void)
+int	refresh(void)
 		{ return(*(int *)0); }
 
 #undef scrl
-int	(scrl)(
+int	scrl(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef scroll
-int	(scroll)(
+int	scroll(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef setscrreg
-int	(setscrreg)(
-		int	a1, 
+int	setscrreg(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef standout
-int	(standout)(void)
+int	standout(void)
 		{ return(*(int *)0); }
 
 #undef standend
-int	(standend)(void)
+int	standend(void)
 		{ return(*(int *)0); }
 
 #undef timeout
-void	(timeout)(
+void	timeout(
 		int	z)
 		{ /* void */ }
 
 #undef touchline
-int	(touchline)(
-		WINDOW	*a1, 
-		int	a2, 
+int	touchline(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef touchwin
-int	(touchwin)(
+int	touchwin(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef untouchwin
-int	(untouchwin)(
+int	untouchwin(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef vline
-int	(vline)(
-		chtype	a1, 
+int	vline(
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
-#undef vw_printw
-int	(vw_printw)(
-		WINDOW	*a1, 
-		const char *a2, 
-		va_list	z)
-		{ return(*(int *)0); }
-
-#undef vw_scanw
-int	(vw_scanw)(
-		WINDOW	*a1, 
-		const char *a2, 
-		va_list	z)
-		{ return(*(int *)0); }
-
 #undef waddchstr
-int	(waddchstr)(
-		WINDOW	*a1, 
+int	waddchstr(
+		WINDOW	*a1,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef waddstr
-int	(waddstr)(
-		WINDOW	*a1, 
+int	waddstr(
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef wattron
-int	(wattron)(
-		WINDOW	*a1, 
+int	wattron(
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattroff
-int	(wattroff)(
-		WINDOW	*a1, 
+int	wattroff(
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattrset
-int	(wattrset)(
-		WINDOW	*a1, 
+int	wattrset(
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattr_get
-int	(wattr_get)(
-		WINDOW	*a1, 
-		attr_t	*a2, 
-		short	*a3, 
+int	wattr_get(
+		WINDOW	*a1,
+		attr_t	*a2,
+		short	*a3,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef wattr_set
-int	(wattr_set)(
-		WINDOW	*a1, 
-		attr_t	a2, 
-		short	a3, 
+int	wattr_set(
+		WINDOW	*a1,
+		attr_t	a2,
+		short	a3,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef wdeleteln
-int	(wdeleteln)(
+int	wdeleteln(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef wgetstr
-int	(wgetstr)(
-		WINDOW	*a1, 
+int	wgetstr(
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef winchstr
-int	(winchstr)(
-		WINDOW	*a1, 
+int	winchstr(
+		WINDOW	*a1,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef winsertln
-int	(winsertln)(
+int	winsertln(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef winsstr
-int	(winsstr)(
-		WINDOW	*a1, 
+int	winsstr(
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef winstr
-int	(winstr)(
-		WINDOW	*a1, 
+int	winstr(
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef wstandout
-int	(wstandout)(
+int	wstandout(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef wstandend
-int	(wstandend)(
+int	wstandend(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef getattrs
-int	(getattrs)(
+int	getattrs(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getcurx
-int	(getcurx)(
+int	getcurx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getcury
-int	(getcury)(
+int	getcury(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getbegx
-int	(getbegx)(
+int	getbegx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getbegy
-int	(getbegy)(
+int	getbegy(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getmaxx
-int	(getmaxx)(
+int	getmaxx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getmaxy
-int	(getmaxy)(
+int	getmaxy(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getparx
-int	(getparx)(
+int	getparx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getpary
-int	(getpary)(
+int	getpary(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef wgetparent
-WINDOW	*(wgetparent)(
+WINDOW	*wgetparent(
 		const WINDOW *z)
 		{ return(*(WINDOW **)0); }
 
 #undef is_cleared
-NCURSES_BOOL (is_cleared)(
+NCURSES_BOOL is_cleared(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_idcok
-NCURSES_BOOL (is_idcok)(
+NCURSES_BOOL is_idcok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_idlok
-NCURSES_BOOL (is_idlok)(
+NCURSES_BOOL is_idlok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_immedok
-NCURSES_BOOL (is_immedok)(
+NCURSES_BOOL is_immedok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_keypad
-NCURSES_BOOL (is_keypad)(
+NCURSES_BOOL is_keypad(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_leaveok
-NCURSES_BOOL (is_leaveok)(
+NCURSES_BOOL is_leaveok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_nodelay
-NCURSES_BOOL (is_nodelay)(
+NCURSES_BOOL is_nodelay(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_notimeout
-NCURSES_BOOL (is_notimeout)(
+NCURSES_BOOL is_notimeout(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_pad
-NCURSES_BOOL (is_pad)(
+NCURSES_BOOL is_pad(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_scrollok
-NCURSES_BOOL (is_scrollok)(
+NCURSES_BOOL is_scrollok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_subwin
-NCURSES_BOOL (is_subwin)(
+NCURSES_BOOL is_subwin(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_syncok
-NCURSES_BOOL (is_syncok)(
+NCURSES_BOOL is_syncok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef wgetdelay
-int	(wgetdelay)(
+int	wgetdelay(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef wgetscrreg
-int	(wgetscrreg)(
-		const WINDOW *a1, 
-		int	*a2, 
+int	wgetscrreg(
+		const WINDOW *a1,
+		int	*a2,
 		int	*z)
 		{ return(*(int *)0); }
 
 #undef mouse_trafo
-NCURSES_BOOL (mouse_trafo)(
-		int	*a1, 
-		int	*a2, 
+NCURSES_BOOL mouse_trafo(
+		int	*a1,
+		int	*a2,
 		NCURSES_BOOL z)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1272,7 +1296,7 @@
 
 #undef set_escdelay_sp
 int	set_escdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -1292,8 +1316,8 @@
 
 #undef _nc_wgetch
 int	_nc_wgetch(
-		WINDOW	*win, 
-		int	*result, 
+		WINDOW	*win,
+		int	*result,
 		int	use_meta)
 		{ return(*(int *)0); }
 
@@ -1306,8 +1330,8 @@
 
 #undef wgetnstr
 int	wgetnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	maxlen)
 		{ return(*(int *)0); }
 
@@ -1315,8 +1339,8 @@
 
 #undef whline
 int	whline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1324,7 +1348,7 @@
 
 #undef immedok
 void	immedok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
@@ -1332,8 +1356,8 @@
 
 #undef winchnstr
 int	winchnstr(
-		WINDOW	*win, 
-		chtype	*str, 
+		WINDOW	*win,
+		chtype	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1347,14 +1371,14 @@
 
 #undef _nc_insert_ch
 int	_nc_insert_ch(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
 #undef winsch
 int	winsch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	c)
 		{ return(*(int *)0); }
 
@@ -1362,7 +1386,7 @@
 
 #undef winsdelln
 int	winsdelln(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1370,8 +1394,8 @@
 
 #undef winsnstr
 int	winsnstr(
-		WINDOW	*win, 
-		const char *s, 
+		WINDOW	*win,
+		const char *s,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1379,8 +1403,8 @@
 
 #undef winnstr
 int	winnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1399,7 +1423,7 @@
 
 #undef leaveok
 int	leaveok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -1407,7 +1431,7 @@
 
 #undef getmouse_sp
 int	getmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -1418,7 +1442,7 @@
 
 #undef ungetmouse_sp
 int	ungetmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -1429,27 +1453,27 @@
 
 #undef mousemask_sp
 mmask_t	mousemask_sp(
-		SCREEN	*sp, 
-		mmask_t	newmask, 
+		SCREEN	*sp,
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef mousemask
 mmask_t	mousemask(
-		mmask_t	newmask, 
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef wenclose
 NCURSES_BOOL wenclose(
-		const WINDOW *win, 
-		int	y, 
+		const WINDOW *win,
+		int	y,
 		int	x)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef mouseinterval_sp
 int	mouseinterval_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	maxclick)
 		{ return(*(int *)0); }
 
@@ -1474,9 +1498,9 @@
 
 #undef wmouse_trafo
 NCURSES_BOOL wmouse_trafo(
-		const WINDOW *win, 
-		int	*pY, 
-		int	*pX, 
+		const WINDOW *win,
+		int	*pY,
+		int	*pX,
 		NCURSES_BOOL to_screen)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1484,8 +1508,8 @@
 
 #undef wmove
 int	wmove(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
@@ -1493,14 +1517,14 @@
 
 #undef _nc_msec_cost_sp
 int	_nc_msec_cost_sp(
-		SCREEN	*sp, 
-		const char *const cap, 
+		SCREEN	*sp,
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
 #undef _nc_msec_cost
 int	_nc_msec_cost(
-		const char *const cap, 
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
@@ -1533,35 +1557,35 @@
 
 #undef _nc_mvcur_sp
 int	_nc_mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef _nc_mvcur
 int	_nc_mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur_sp
 int	mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur
 int	mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
@@ -1572,8 +1596,8 @@
 
 #undef mvwin
 int	mvwin(
-		WINDOW	*win, 
-		int	by, 
+		WINDOW	*win,
+		int	by,
 		int	bx)
 		{ return(*(int *)0); }
 
@@ -1599,16 +1623,16 @@
 
 #undef newterm_sp
 SCREEN	*newterm_sp(
-		SCREEN	*sp, 
-		const char *name, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
 #undef newterm
 SCREEN	*newterm(
-		const char *name, 
-		FILE	*ofp, 
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
@@ -1621,46 +1645,46 @@
 
 #undef newwin_sp
 WINDOW	*newwin_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef newwin
 WINDOW	*newwin(
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef derwin
 WINDOW	*derwin(
-		WINDOW	*orig, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		WINDOW	*orig,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef subwin
 WINDOW	*subwin(
-		WINDOW	*w, 
-		int	l, 
-		int	c, 
-		int	y, 
+		WINDOW	*w,
+		int	l,
+		int	c,
+		int	y,
 		int	x)
 		{ return(*(WINDOW **)0); }
 
 #undef _nc_makenew_sp
 WINDOW	*_nc_makenew_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
-		int	begx, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
+		int	begx,
 		int	flags)
 		{ return(*(WINDOW **)0); }
 
@@ -1703,26 +1727,26 @@
 
 #undef overlay
 int	overlay(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef overwrite
 int	overwrite(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef copywin
 int	copywin(
-		const WINDOW *src, 
-		WINDOW	*dst, 
-		int	sminrow, 
-		int	smincol, 
-		int	dminrow, 
-		int	dmincol, 
-		int	dmaxrow, 
-		int	dmaxcol, 
+		const WINDOW *src,
+		WINDOW	*dst,
+		int	sminrow,
+		int	smincol,
+		int	dminrow,
+		int	dmincol,
+		int	dmaxrow,
+		int	dmaxcol,
 		int	over)
 		{ return(*(int *)0); }
 
@@ -1730,51 +1754,51 @@
 
 #undef newpad_sp
 WINDOW	*newpad_sp(
-		SCREEN	*sp, 
-		int	l, 
+		SCREEN	*sp,
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef newpad
 WINDOW	*newpad(
-		int	l, 
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef subpad
 WINDOW	*subpad(
-		WINDOW	*orig, 
-		int	l, 
-		int	c, 
-		int	begy, 
+		WINDOW	*orig,
+		int	l,
+		int	c,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef prefresh
 int	prefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pnoutrefresh
 int	pnoutrefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pechochar
 int	pechochar(
-		WINDOW	*pad, 
+		WINDOW	*pad,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -1782,38 +1806,45 @@
 
 #undef printw
 int	printw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wprintw
 int	wprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvprintw
 int	mvprintw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwprintw
 int	mvwprintw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef vwprintw
 int	vwprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
+		va_list	argp)
+		{ return(*(int *)0); }
+
+#undef vw_printw
+int	vw_printw(
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
@@ -1821,8 +1852,8 @@
 
 #undef wredrawln
 int	wredrawln(
-		WINDOW	*win, 
-		int	beg, 
+		WINDOW	*win,
+		int	beg,
 		int	num)
 		{ return(*(int *)0); }
 
@@ -1842,16 +1873,16 @@
 
 #undef restartterm_sp
 int	restartterm_sp(
-		SCREEN	*sp, 
-		const char *termp, 
-		int	filenum, 
+		SCREEN	*sp,
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
 #undef restartterm
 int	restartterm(
-		const char *termp, 
-		int	filenum, 
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -1859,38 +1890,45 @@
 
 #undef vwscanw
 int	vwscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
+		va_list	argp)
+		{ return(*(int *)0); }
+
+#undef vw_scanw
+int	vw_scanw(
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef scanw
 int	scanw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wscanw
 int	wscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvscanw
 int	mvscanw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwscanw
 int	mvwscanw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
@@ -1898,7 +1936,7 @@
 
 #undef getwin_sp
 WINDOW	*getwin_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		FILE	*filep)
 		{ return(*(WINDOW **)0); }
 
@@ -1909,13 +1947,13 @@
 
 #undef putwin
 int	putwin(
-		WINDOW	*win, 
+		WINDOW	*win,
 		FILE	*filep)
 		{ return(*(int *)0); }
 
 #undef scr_restore_sp
 int	scr_restore_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -1931,7 +1969,7 @@
 
 #undef scr_init_sp
 int	scr_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -1942,7 +1980,7 @@
 
 #undef scr_set_sp
 int	scr_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -1955,16 +1993,16 @@
 
 #undef _nc_scroll_window
 void	_nc_scroll_window(
-		WINDOW	*win, 
-		int const n, 
-		int const top, 
-		int const bottom, 
+		WINDOW	*win,
+		int const n,
+		int const top,
+		int const bottom,
 		chtype	blank)
 		{ /* void */ }
 
 #undef wscrl
 int	wscrl(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1972,7 +2010,7 @@
 
 #undef scrollok
 int	scrollok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -1980,8 +2018,8 @@
 
 #undef wsetscrreg
 int	wsetscrreg(
-		WINDOW	*win, 
-		int	top, 
+		WINDOW	*win,
+		int	top,
 		int	bottom)
 		{ return(*(int *)0); }
 
@@ -1999,54 +2037,54 @@
 
 #undef _nc_setupscreen_sp
 int	_nc_setupscreen_sp(
-		SCREEN	**spp, 
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		SCREEN	**spp,
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_setupscreen
 int	_nc_setupscreen(
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline_sp
 int	_nc_ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline
 int	_nc_ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline_sp
 int	ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline
 int	ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
@@ -2054,13 +2092,13 @@
 
 #undef _nc_format_slks
 int	_nc_format_slks(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	cols)
 		{ return(*(int *)0); }
 
 #undef _nc_slk_initialize
 int	_nc_slk_initialize(
-		WINDOW	*stwin, 
+		WINDOW	*stwin,
 		int	cols)
 		{ return(*(int *)0); }
 
@@ -2077,16 +2115,16 @@
 
 #undef slk_attr_set_sp
 int	slk_attr_set_sp(
-		SCREEN	*sp, 
-		const attr_t attr, 
-		short	color_pair_number, 
+		SCREEN	*sp,
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 #undef slk_attr_set
 int	slk_attr_set(
-		const attr_t attr, 
-		short	color_pair_number, 
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2094,7 +2132,7 @@
 
 #undef slk_attroff_sp
 int	slk_attroff_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2107,7 +2145,7 @@
 
 #undef slk_attron_sp
 int	slk_attron_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2120,7 +2158,7 @@
 
 #undef slk_attrset_sp
 int	slk_attrset_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2155,20 +2193,20 @@
 
 #undef slk_color_sp
 int	slk_color_sp(
-		SCREEN	*sp, 
-		short	color_pair_number)
+		SCREEN	*sp,
+		short	pair_arg)
 		{ return(*(int *)0); }
 
 #undef slk_color
 int	slk_color(
-		short	color_pair_number)
+		short	pair_arg)
 		{ return(*(int *)0); }
 
 /* ./base/lib_slkinit.c */
 
 #undef slk_init_sp
 int	slk_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2181,7 +2219,7 @@
 
 #undef slk_label_sp
 char	*slk_label_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	n)
 		{ return(*(char **)0); }
 
@@ -2214,16 +2252,16 @@
 
 #undef slk_set_sp
 int	slk_set_sp(
-		SCREEN	*sp, 
-		int	i, 
-		const char *astr, 
+		SCREEN	*sp,
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
 #undef slk_set
 int	slk_set(
-		int	i, 
-		const char *astr, 
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2242,7 +2280,7 @@
 
 #undef is_linetouched
 NCURSES_BOOL is_linetouched(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	line)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -2253,9 +2291,9 @@
 
 #undef wtouchln
 int	wtouchln(
-		WINDOW	*win, 
-		int	y, 
-		int	n, 
+		WINDOW	*win,
+		int	y,
+		int	n,
 		int	changed)
 		{ return(*(int *)0); }
 
@@ -2263,7 +2301,7 @@
 
 #undef _tracedump
 void	_tracedump(
-		const char *name, 
+		const char *name,
 		WINDOW	*win)
 		{ /* void */ }
 
@@ -2271,19 +2309,19 @@
 
 #undef _nc_trace_mmask_t
 char	*_nc_trace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(char **)0); }
 
 #undef _nc_tracemouse
 char	*_nc_tracemouse(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT const *ep)
 		{ return(*(char **)0); }
 
 #undef _nc_retrace_mmask_t
 mmask_t	_nc_retrace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(mmask_t *)0); }
 
@@ -2308,7 +2346,7 @@
 
 #undef ungetch_sp
 int	ungetch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -2321,20 +2359,20 @@
 
 #undef vidputs_sp
 int	vidputs_sp(
-		SCREEN	*sp, 
-		chtype	newmode, 
+		SCREEN	*sp,
+		chtype	newmode,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef vidputs
 int	vidputs(
-		chtype	newmode, 
+		chtype	newmode,
 		NCURSES_OUTC outc)
 		{ return(*(int *)0); }
 
 #undef vidattr_sp
 int	vidattr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	newmode)
 		{ return(*(int *)0); }
 
@@ -2356,8 +2394,8 @@
 
 #undef wvline
 int	wvline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2365,8 +2403,8 @@
 
 #undef wattr_off
 int	wattr_off(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2374,8 +2412,8 @@
 
 #undef wattr_on
 int	wattr_on(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2395,14 +2433,14 @@
 
 #undef mvderwin
 int	mvderwin(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
 #undef syncok
 int	syncok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL bf)
 		{ return(*(int *)0); }
 
@@ -2441,14 +2479,14 @@
 
 #undef _nc_printf_string_sp
 char	*_nc_printf_string_sp(
-		SCREEN	*sp, 
-		const char *fmt, 
+		SCREEN	*sp,
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
 #undef _nc_printf_string
 char	*_nc_printf_string(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -2465,18 +2503,18 @@
 
 #undef _nc_scrolln_sp
 int	_nc_scrolln_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
-		int	bot, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
 #undef _nc_scrolln
 int	_nc_scrolln(
-		int	n, 
-		int	top, 
-		int	bot, 
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
@@ -2509,7 +2547,7 @@
 
 #undef _nc_do_xmc_glitch_sp
 void	_nc_do_xmc_glitch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		attr_t	previous)
 		{ /* void */ }
 
@@ -2520,13 +2558,9 @@
 
 /* ./trace/varargs.c */
 
-typedef enum {
-    atUnknown = 0, atInteger, atFloat, atPoint, atString
-} ARGTYPE;
-
 #undef _nc_varargs
 char	*_nc_varargs(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -2544,7 +2578,7 @@
 
 #undef _nc_free_and_exit_sp
 void	_nc_free_and_exit_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	code)
 		{ /* void */ }
 
@@ -2553,35 +2587,40 @@
 		int	code)
 		{ /* void */ }
 
+#undef exit_curses
+void	exit_curses(
+		int	code)
+		{ /* void */ }
+
 /* ./expanded.c */
 
 #undef _nc_toggle_attr_on
 void	_nc_toggle_attr_on(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_toggle_attr_off
 void	_nc_toggle_attr_off(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_DelCharCost_sp
 int	_nc_DelCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_InsCharCost_sp
 int	_nc_InsCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_UpdateAttrs_sp
 void	_nc_UpdateAttrs_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	c)
 		{ /* void */ }
 
@@ -2604,7 +2643,7 @@
 
 #undef use_legacy_coding_sp
 int	use_legacy_coding_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	level)
 		{ return(*(int *)0); }
 
@@ -2626,14 +2665,14 @@
 
 #undef assume_default_colors_sp
 int	assume_default_colors_sp(
-		SCREEN	*sp, 
-		int	fg, 
+		SCREEN	*sp,
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
 #undef assume_default_colors
 int	assume_default_colors(
-		int	fg, 
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
@@ -2641,55 +2680,61 @@
 
 #undef mcprint_sp
 int	mcprint_sp(
-		SCREEN	*sp, 
-		char	*data, 
+		SCREEN	*sp,
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
 #undef mcprint
 int	mcprint(
-		char	*data, 
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
+/* ./base/new_pair.c */
+
+#undef _nc_new_pair
+void	_nc_new_pair(void)
+		{ /* void */ }
+
 /* ./base/resizeterm.c */
 
 #undef is_term_resized_sp
 NCURSES_BOOL is_term_resized_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_term_resized
 NCURSES_BOOL is_term_resized(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef resize_term_sp
 int	resize_term_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resize_term
 int	resize_term(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm_sp
 int	resizeterm_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm
 int	resizeterm(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -2704,8 +2749,8 @@
 
 #undef use_screen
 int	use_screen(
-		SCREEN	*screen, 
-		NCURSES_SCREEN_CB func, 
+		SCREEN	*screen,
+		NCURSES_SCREEN_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -2713,8 +2758,8 @@
 
 #undef use_window
 int	use_window(
-		WINDOW	*win, 
-		NCURSES_WINDOW_CB func, 
+		WINDOW	*win,
+		NCURSES_WINDOW_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -2722,8 +2767,8 @@
 
 #undef wresize
 int	wresize(
-		WINDOW	*win, 
-		int	ToLines, 
+		WINDOW	*win,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -2751,7 +2796,7 @@
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -2769,12 +2814,25 @@
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -2782,13 +2840,13 @@
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE *to, 
+		TERMTYPE *to,
 		TERMTYPE *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
@@ -2858,19 +2916,19 @@
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -2878,17 +2936,32 @@
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
+#undef _nc_find_user_entry
+struct user_table_entry const *_nc_find_user_entry(
+		const char *string)
+		{ return(*(struct user_table_entry const **)0); }
+
+/* ./comp_userdefs.c */
+
+#undef _nc_get_userdefs_table
+const struct user_table_entry *_nc_get_userdefs_table(void)
+		{ return(*(const struct user_table_entry **)0); }
+
+#undef _nc_get_hash_user
+const HashData *_nc_get_hash_user(void)
+		{ return(*(const HashData **)0); }
+
 /* ./tinfo/db_iterator.c */
 
 #undef _nc_tic_dir
@@ -2907,13 +2980,13 @@
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -2921,7 +2994,7 @@
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -2934,7 +3007,7 @@
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
+		ENTRY	*headp,
 		TERMTYPE *tterm)
 		{ /* void */ }
 
@@ -2943,16 +3016,15 @@
 		ENTRY	*headp)
 		{ /* void */ }
 
-#undef _nc_delink_entry
-ENTRY	*_nc_delink_entry(
-		ENTRY	*headp, 
-		TERMTYPE *tterm)
-		{ return(*(ENTRY **)0); }
-
 #undef _nc_leaks_tinfo
 void	_nc_leaks_tinfo(void)
 		{ /* void */ }
 
+#undef exit_terminfo
+void	exit_terminfo(
+		int	code)
+		{ /* void */ }
+
 /* ./fallback.c */
 
 #undef _nc_fallback
@@ -2967,6 +3039,11 @@
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
 #undef _nc_user_definable
 NCURSES_BOOL _nc_user_definable;
 
@@ -2984,7 +3061,7 @@
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -3019,8 +3096,8 @@
 /* ./tinfo/lib_baudrate.c */
 
 struct speed {
-    short s; 
-    int sp; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -3059,7 +3136,7 @@
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -3070,7 +3147,7 @@
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -3186,7 +3263,7 @@
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -3210,7 +3287,7 @@
 
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -3223,19 +3300,19 @@
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -3246,37 +3323,37 @@
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -3287,7 +3364,7 @@
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -3298,7 +3375,7 @@
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -3309,14 +3386,14 @@
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -3378,17 +3455,53 @@
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
 /* ./tinfo/lib_setup.c */
 
 #undef _nc_ttytype
@@ -3424,7 +3537,7 @@
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -3440,13 +3553,13 @@
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -3462,8 +3575,8 @@
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -3474,13 +3587,13 @@
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
+		const char *const tn,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -3499,20 +3612,28 @@
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
+#undef _nc_find_prescr
+SCREEN	*_nc_find_prescr(void)
+		{ return(*(SCREEN **)0); }
+
+#undef _nc_forget_prescr
+void	_nc_forget_prescr(void)
+		{ /* void */ }
+
 #undef new_prescr
 SCREEN	*new_prescr(void)
 		{ return(*(SCREEN **)0); }
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -3525,20 +3646,20 @@
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -3549,7 +3670,7 @@
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -3560,14 +3681,14 @@
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -3586,8 +3707,8 @@
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -3595,7 +3716,7 @@
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -3606,7 +3727,7 @@
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -3617,7 +3738,7 @@
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -3631,25 +3752,58 @@
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
+#undef _nc_tiparm
+char	*_nc_tiparm(
+		int	expected,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -3666,7 +3820,7 @@
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -3686,7 +3840,7 @@
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -3697,7 +3851,7 @@
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -3708,7 +3862,7 @@
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -3719,35 +3873,35 @@
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -3775,6 +3929,11 @@
 		long	increment)
 		{ /* void */ }
 
+#undef curses_trace
+unsigned curses_trace(
+		unsigned tracelevel)
+		{ return(*(unsigned *)0); }
+
 #undef trace
 void	trace(
 		const unsigned int tracelevel)
@@ -3782,7 +3941,7 @@
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -3836,6 +3995,13 @@
 		WINDOW	*code)
 		{ return(*(WINDOW **)0); }
 
+#undef _nc_fmt_funcptr
+char	*_nc_fmt_funcptr(
+		char	*target,
+		const char *source,
+		size_t	size)
+		{ return(*(char **)0); }
+
 #undef _nc_use_tracef
 int	_nc_use_tracef(
 		unsigned mask)
@@ -3843,7 +4009,7 @@
 
 #undef _nc_locked_tracef
 void	_nc_locked_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -3851,7 +4017,7 @@
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -3872,13 +4038,13 @@
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -3894,14 +4060,9 @@
 
 /* ./trace/lib_tracebits.c */
 
-typedef struct {
-    unsigned int val;
-    const char name[8];
-} BITNAMES;
-
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -3912,7 +4073,7 @@
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -3925,7 +4086,7 @@
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -3936,7 +4097,7 @@
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -4003,9 +4164,9 @@
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -4018,8 +4179,8 @@
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -4053,14 +4214,14 @@
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
@@ -4073,60 +4234,62 @@
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE *ptr, 
-		char	*buffer, 
+		TERMTYPE *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
+		const char *const filename,
 		TERMTYPE *ptr)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/read_termcap.c */
 
-#undef _nc_read_termcap
-void	_nc_read_termcap(void)
-		{ /* void */ }
+#undef _nc_read_termcap_entry
+int	_nc_read_termcap_entry(
+		const char *const tn,
+		TERMTYPE *const tp)
+		{ return(*(int *)0); }
 
 /* ./tinfo/strings.c */
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -4134,13 +4297,13 @@
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -4155,21 +4318,21 @@
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -4184,7 +4347,7 @@
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -4197,7 +4360,7 @@
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -4208,20 +4371,20 @@
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const chtype *buf, 
+		int	bufnum,
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const chtype *buf, 
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -4229,7 +4392,7 @@
 
 #undef _nc_init_entry
 void	_nc_init_entry(
-		TERMTYPE *const tp)
+		ENTRY	*const tp)
 		{ /* void */ }
 
 #undef _nc_copy_entry
@@ -4239,34 +4402,34 @@
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		TERMTYPE *const to, 
-		TERMTYPE *const from)
+		ENTRY	*const target,
+		ENTRY	*const source)
 		{ /* void */ }
 
 /* ./tinfo/captoinfo.c */
 
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -4274,8 +4437,8 @@
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -4283,39 +4446,31 @@
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE *p1, 
+		TERMTYPE *p1,
 		NCURSES_BOOL p2);
-#undef _nc_check_termtype
-void	(*_nc_check_termtype)(
-		TERMTYPE *p1);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
-#undef _nc_resolve_uses
-int	_nc_resolve_uses(
-		NCURSES_BOOL fullresolve)
-		{ return(*(int *)0); }
-
 /* ./tinfo/comp_scan.c */
 
 #undef _nc_syntax
@@ -4337,7 +4492,7 @@
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -4348,8 +4503,8 @@
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -4366,22 +4521,17 @@
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		struct entry *entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
-typedef struct {
-    const char from[3];
-    const char to[6];
-} assoc;
-
 /* ./tinfo/write_entry.c */
 
 #undef _nc_set_writedir
@@ -4394,6 +4544,14 @@
 		TERMTYPE *const tp)
 		{ /* void */ }
 
+#undef _nc_write_object
+int	_nc_write_object(
+		TERMTYPE *tp,
+		char	*buffer,
+		unsigned *offset,
+		unsigned limit)
+		{ return(*(int *)0); }
+
 #undef _nc_tic_written
 int	_nc_tic_written(void)
 		{ return(*(int *)0); }
@@ -4402,14 +4560,14 @@
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -4423,7 +4581,7 @@
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -4436,14 +4594,14 @@
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -4451,14 +4609,14 @@
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/ncurses/llib-lncursestw b/ncurses/llib-lncursestw
index 9871dcc..3aa57ee 100644
--- a/ncurses/llib-lncursestw
+++ b/ncurses/llib-lncursestw
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2009-2013,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2009-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -69,7 +70,7 @@
 
 #undef _nc_make_oldhash_sp
 void	_nc_make_oldhash_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	i)
 		{ /* void */ }
 
@@ -80,16 +81,16 @@
 
 #undef _nc_scroll_oldhash_sp
 void	_nc_scroll_oldhash_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
 #undef _nc_scroll_oldhash
 void	_nc_scroll_oldhash(
-		int	n, 
-		int	top, 
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
@@ -97,31 +98,31 @@
 
 #undef _nc_render
 cchar_t	_nc_render(
-		WINDOW	*win, 
+		WINDOW	*win,
 		cchar_t	ch)
 		{ return(*(cchar_t *)0); }
 
 #undef _nc_build_wch
 int	_nc_build_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		cchar_t	*ch)
 		{ return(*(int *)0); }
 
 #undef _nc_waddch_nosync
 int	_nc_waddch_nosync(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t c)
 		{ return(*(int *)0); }
 
 #undef waddch
 int	waddch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
 #undef wechochar
 int	wechochar(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -129,15 +130,15 @@
 
 #undef waddnstr
 int	waddnstr(
-		WINDOW	*win, 
-		const char *astr, 
+		WINDOW	*win,
+		const char *astr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef waddchnstr
 int	waddchnstr(
-		WINDOW	*win, 
-		const chtype *astr, 
+		WINDOW	*win,
+		const chtype *astr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -148,15 +149,15 @@
 
 #undef wadd_wchnstr
 int	wadd_wchnstr(
-		WINDOW	*win, 
-		const cchar_t *astr, 
+		WINDOW	*win,
+		const cchar_t *astr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef waddnwstr
 int	waddnwstr(
-		WINDOW	*win, 
-		const wchar_t *str, 
+		WINDOW	*win,
+		const wchar_t *str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -175,25 +176,25 @@
 
 #undef wbkgrndset
 void	wbkgrndset(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *ch)
 		{ /* void */ }
 
 #undef wbkgdset
 void	wbkgdset(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ /* void */ }
 
 #undef wbkgrnd
 int	wbkgrnd(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *ch)
 		{ return(*(int *)0); }
 
 #undef wbkgd
 int	wbkgd(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
@@ -201,14 +202,14 @@
 
 #undef wborder
 int	wborder(
-		WINDOW	*win, 
-		chtype	ls, 
-		chtype	rs, 
-		chtype	ts, 
-		chtype	bs, 
-		chtype	tl, 
-		chtype	tr, 
-		chtype	bl, 
+		WINDOW	*win,
+		chtype	ls,
+		chtype	rs,
+		chtype	ts,
+		chtype	bs,
+		chtype	tl,
+		chtype	tr,
+		chtype	bl,
 		chtype	br)
 		{ return(*(int *)0); }
 
@@ -216,10 +217,10 @@
 
 #undef wchgat
 int	wchgat(
-		WINDOW	*win, 
-		int	n, 
-		attr_t	attr, 
-		short	color, 
+		WINDOW	*win,
+		int	n,
+		attr_t	attr,
+		short	pair_arg,
 		const void *opts)
 		{ return(*(int *)0); }
 
@@ -234,7 +235,7 @@
 
 #undef clearok
 int	clearok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -280,35 +281,64 @@
 int	start_color(void)
 		{ return(*(int *)0); }
 
+#undef _nc_change_pair
+void	_nc_change_pair(
+		SCREEN	*sp,
+		int	pair)
+		{ /* void */ }
+
+#undef _nc_reserve_pairs
+void	_nc_reserve_pairs(
+		SCREEN	*sp,
+		int	want)
+		{ /* void */ }
+
+#undef _nc_init_pair
+int	_nc_init_pair(
+		SCREEN	*sp,
+		int	pair,
+		int	f,
+		int	b)
+		{ return(*(int *)0); }
+
 #undef init_pair_sp
 int	init_pair_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	f, 
+		SCREEN	*sp,
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_pair
 int	init_pair(
-		short	pair, 
-		short	f, 
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
+#undef _nc_init_color
+int	_nc_init_color(
+		SCREEN	*sp,
+		int	color,
+		int	r,
+		int	g,
+		int	b)
+		{ return(*(int *)0); }
+
 #undef init_color_sp
 int	init_color_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	r, 
-		short	g, 
+		SCREEN	*sp,
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_color
 int	init_color(
-		short	color, 
-		short	r, 
-		short	g, 
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
@@ -332,59 +362,140 @@
 
 #undef color_content_sp
 int	color_content_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	*r, 
-		short	*g, 
+		SCREEN	*sp,
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef color_content
 int	color_content(
-		short	color, 
-		short	*r, 
-		short	*g, 
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
+#undef _nc_pair_content
+int	_nc_pair_content(
+		SCREEN	*sp,
+		int	pair,
+		int	*f,
+		int	*b)
+		{ return(*(int *)0); }
+
 #undef pair_content_sp
 int	pair_content_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	*f, 
+		SCREEN	*sp,
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef pair_content
 int	pair_content(
-		short	pair, 
-		short	*f, 
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef _nc_do_color_sp
 void	_nc_do_color_sp(
-		SCREEN	*sp, 
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		SCREEN	*sp,
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC_sp outc)
 		{ /* void */ }
 
 #undef _nc_do_color
 void	_nc_do_color(
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC outc)
 		{ /* void */ }
 
+#undef init_extended_pair_sp
+int	init_extended_pair_sp(
+		SCREEN	*sp,
+		int	pair,
+		int	f,
+		int	b)
+		{ return(*(int *)0); }
+
+#undef init_extended_color_sp
+int	init_extended_color_sp(
+		SCREEN	*sp,
+		int	color,
+		int	r,
+		int	g,
+		int	b)
+		{ return(*(int *)0); }
+
+#undef extended_color_content_sp
+int	extended_color_content_sp(
+		SCREEN	*sp,
+		int	color,
+		int	*r,
+		int	*g,
+		int	*b)
+		{ return(*(int *)0); }
+
+#undef extended_pair_content_sp
+int	extended_pair_content_sp(
+		SCREEN	*sp,
+		int	pair,
+		int	*f,
+		int	*b)
+		{ return(*(int *)0); }
+
+#undef reset_color_pairs_sp
+void	reset_color_pairs_sp(
+		SCREEN	*sp)
+		{ /* void */ }
+
+#undef init_extended_pair
+int	init_extended_pair(
+		int	pair,
+		int	f,
+		int	b)
+		{ return(*(int *)0); }
+
+#undef init_extended_color
+int	init_extended_color(
+		int	color,
+		int	r,
+		int	g,
+		int	b)
+		{ return(*(int *)0); }
+
+#undef extended_color_content
+int	extended_color_content(
+		int	color,
+		int	*r,
+		int	*g,
+		int	*b)
+		{ return(*(int *)0); }
+
+#undef extended_pair_content
+int	extended_pair_content(
+		int	pair,
+		int	*f,
+		int	*b)
+		{ return(*(int *)0); }
+
+#undef reset_color_pairs
+void	reset_color_pairs(void)
+		{ /* void */ }
+
 /* ./base/lib_colorset.c */
 
 #undef wcolor_set
 int	wcolor_set(
-		WINDOW	*win, 
-		short	color_pair_number, 
+		WINDOW	*win,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -454,1316 +565,1302 @@
 /* ./lib_gen.c */
 
 #undef addch
-int	(addch)(
+int	addch(
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef addchnstr
-int	(addchnstr)(
-		const chtype *a1, 
+int	addchnstr(
+		const chtype *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef addchstr
-int	(addchstr)(
+int	addchstr(
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef addnstr
-int	(addnstr)(
-		const char *a1, 
+int	addnstr(
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef addstr
-int	(addstr)(
+int	addstr(
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef attroff
-int	(attroff)(
+int	attroff(
 		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attron
-int	(attron)(
+int	attron(
 		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attrset
-int	(attrset)(
+int	attrset(
 		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attr_get
-int	(attr_get)(
-		attr_t	*a1, 
-		short	*a2, 
+int	attr_get(
+		attr_t	*a1,
+		short	*a2,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_off
-int	(attr_off)(
-		attr_t	a1, 
+int	attr_off(
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_on
-int	(attr_on)(
-		attr_t	a1, 
+int	attr_on(
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_set
-int	(attr_set)(
-		attr_t	a1, 
-		short	a2, 
+int	attr_set(
+		attr_t	a1,
+		short	a2,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef bkgd
-int	(bkgd)(
+int	bkgd(
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef bkgdset
-void	(bkgdset)(
+void	bkgdset(
 		chtype	z)
 		{ /* void */ }
 
 #undef border
-int	(border)(
-		chtype	a1, 
-		chtype	a2, 
-		chtype	a3, 
-		chtype	a4, 
-		chtype	a5, 
-		chtype	a6, 
-		chtype	a7, 
+int	border(
+		chtype	a1,
+		chtype	a2,
+		chtype	a3,
+		chtype	a4,
+		chtype	a5,
+		chtype	a6,
+		chtype	a7,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef box
-int	(box)(
-		WINDOW	*a1, 
-		chtype	a2, 
+int	box(
+		WINDOW	*a1,
+		chtype	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef chgat
-int	(chgat)(
-		int	a1, 
-		attr_t	a2, 
-		short	a3, 
+int	chgat(
+		int	a1,
+		attr_t	a2,
+		short	a3,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef clear
-int	(clear)(void)
+int	clear(void)
 		{ return(*(int *)0); }
 
 #undef clrtobot
-int	(clrtobot)(void)
+int	clrtobot(void)
 		{ return(*(int *)0); }
 
 #undef clrtoeol
-int	(clrtoeol)(void)
+int	clrtoeol(void)
 		{ return(*(int *)0); }
 
 #undef color_set
-int	(color_set)(
-		short	a1, 
+int	color_set(
+		short	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef COLOR_PAIR
-int	(COLOR_PAIR)(
+int	COLOR_PAIR(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef delch
-int	(delch)(void)
+int	delch(void)
 		{ return(*(int *)0); }
 
 #undef deleteln
-int	(deleteln)(void)
+int	deleteln(void)
 		{ return(*(int *)0); }
 
 #undef echochar
-int	(echochar)(
+int	echochar(
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef erase
-int	(erase)(void)
+int	erase(void)
 		{ return(*(int *)0); }
 
 #undef getbkgd
-chtype	(getbkgd)(
+chtype	getbkgd(
 		WINDOW	*z)
 		{ return(*(chtype *)0); }
 
 #undef getch
-int	(getch)(void)
+int	getch(void)
 		{ return(*(int *)0); }
 
 #undef getnstr
-int	(getnstr)(
-		char	*a1, 
+int	getnstr(
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef getstr
-int	(getstr)(
+int	getstr(
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef hline
-int	(hline)(
-		chtype	a1, 
+int	hline(
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef inch
-chtype	(inch)(void)
+chtype	inch(void)
 		{ return(*(chtype *)0); }
 
 #undef inchnstr
-int	(inchnstr)(
-		chtype	*a1, 
+int	inchnstr(
+		chtype	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef inchstr
-int	(inchstr)(
+int	inchstr(
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef innstr
-int	(innstr)(
-		char	*a1, 
+int	innstr(
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef insch
-int	(insch)(
+int	insch(
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef insdelln
-int	(insdelln)(
+int	insdelln(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef insertln
-int	(insertln)(void)
+int	insertln(void)
 		{ return(*(int *)0); }
 
 #undef insnstr
-int	(insnstr)(
-		const char *a1, 
+int	insnstr(
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef insstr
-int	(insstr)(
+int	insstr(
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef instr
-int	(instr)(
+int	instr(
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef move
-int	(move)(
-		int	a1, 
+int	move(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddch
-int	(mvaddch)(
-		int	a1, 
-		int	a2, 
+int	mvaddch(
+		int	a1,
+		int	a2,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvaddchnstr
-int	(mvaddchnstr)(
-		int	a1, 
-		int	a2, 
-		const chtype *a3, 
+int	mvaddchnstr(
+		int	a1,
+		int	a2,
+		const chtype *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddchstr
-int	(mvaddchstr)(
-		int	a1, 
-		int	a2, 
+int	mvaddchstr(
+		int	a1,
+		int	a2,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvaddnstr
-int	(mvaddnstr)(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+int	mvaddnstr(
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddstr
-int	(mvaddstr)(
-		int	a1, 
-		int	a2, 
+int	mvaddstr(
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvchgat
-int	(mvchgat)(
-		int	a1, 
-		int	a2, 
-		int	a3, 
-		attr_t	a4, 
-		short	a5, 
+int	mvchgat(
+		int	a1,
+		int	a2,
+		int	a3,
+		attr_t	a4,
+		short	a5,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvdelch
-int	(mvdelch)(
-		int	a1, 
+int	mvdelch(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetch
-int	(mvgetch)(
-		int	a1, 
+int	mvgetch(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetnstr
-int	(mvgetnstr)(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+int	mvgetnstr(
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetstr
-int	(mvgetstr)(
-		int	a1, 
-		int	a2, 
+int	mvgetstr(
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvhline
-int	(mvhline)(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+int	mvhline(
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinch
-chtype	(mvinch)(
-		int	a1, 
+chtype	mvinch(
+		int	a1,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvinchnstr
-int	(mvinchnstr)(
-		int	a1, 
-		int	a2, 
-		chtype	*a3, 
+int	mvinchnstr(
+		int	a1,
+		int	a2,
+		chtype	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinchstr
-int	(mvinchstr)(
-		int	a1, 
-		int	a2, 
+int	mvinchstr(
+		int	a1,
+		int	a2,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvinnstr
-int	(mvinnstr)(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+int	mvinnstr(
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsch
-int	(mvinsch)(
-		int	a1, 
-		int	a2, 
+int	mvinsch(
+		int	a1,
+		int	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvinsnstr
-int	(mvinsnstr)(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+int	mvinsnstr(
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsstr
-int	(mvinsstr)(
-		int	a1, 
-		int	a2, 
+int	mvinsstr(
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvinstr
-int	(mvinstr)(
-		int	a1, 
-		int	a2, 
+int	mvinstr(
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvvline
-int	(mvvline)(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+int	mvvline(
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddch
-int	(mvwaddch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwaddch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchnstr
-int	(mvwaddchnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const chtype *a4, 
+int	mvwaddchnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const chtype *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchstr
-int	(mvwaddchstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwaddchstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvwaddnstr
-int	(mvwaddnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+int	mvwaddnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddstr
-int	(mvwaddstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwaddstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwchgat
-int	(mvwchgat)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		int	a4, 
-		attr_t	a5, 
-		short	a6, 
+int	mvwchgat(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		int	a4,
+		attr_t	a5,
+		short	a6,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvwdelch
-int	(mvwdelch)(
-		WINDOW	*a1, 
-		int	a2, 
+int	mvwdelch(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetch
-int	(mvwgetch)(
-		WINDOW	*a1, 
-		int	a2, 
+int	mvwgetch(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetnstr
-int	(mvwgetnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+int	mvwgetnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetstr
-int	(mvwgetstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwgetstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwhline
-int	(mvwhline)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+int	mvwhline(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinch
-chtype	(mvwinch)(
-		WINDOW	*a1, 
-		int	a2, 
+chtype	mvwinch(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvwinchnstr
-int	(mvwinchnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	*a4, 
+int	mvwinchnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinchstr
-int	(mvwinchstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinchstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvwinnstr
-int	(mvwinnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+int	mvwinnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsch
-int	(mvwinsch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinsch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsnstr
-int	(mvwinsnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+int	mvwinsnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsstr
-int	(mvwinsstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinsstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwinstr
-int	(mvwinstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwvline
-int	(mvwvline)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+int	mvwvline(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef PAIR_NUMBER
-int	(PAIR_NUMBER)(
+int	PAIR_NUMBER(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef redrawwin
-int	(redrawwin)(
+int	redrawwin(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef refresh
-int	(refresh)(void)
+int	refresh(void)
 		{ return(*(int *)0); }
 
 #undef scrl
-int	(scrl)(
+int	scrl(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef scroll
-int	(scroll)(
+int	scroll(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef setscrreg
-int	(setscrreg)(
-		int	a1, 
+int	setscrreg(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef slk_attr_off
-int	(slk_attr_off)(
-		const attr_t a1, 
+int	slk_attr_off(
+		const attr_t a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef slk_attr_on
-int	(slk_attr_on)(
-		attr_t	a1, 
+int	slk_attr_on(
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef standout
-int	(standout)(void)
+int	standout(void)
 		{ return(*(int *)0); }
 
 #undef standend
-int	(standend)(void)
+int	standend(void)
 		{ return(*(int *)0); }
 
 #undef timeout
-void	(timeout)(
+void	timeout(
 		int	z)
 		{ /* void */ }
 
 #undef touchline
-int	(touchline)(
-		WINDOW	*a1, 
-		int	a2, 
+int	touchline(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef touchwin
-int	(touchwin)(
+int	touchwin(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef untouchwin
-int	(untouchwin)(
+int	untouchwin(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef vline
-int	(vline)(
-		chtype	a1, 
+int	vline(
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
-#undef vw_printw
-int	(vw_printw)(
-		WINDOW	*a1, 
-		const char *a2, 
-		va_list	z)
-		{ return(*(int *)0); }
-
-#undef vw_scanw
-int	(vw_scanw)(
-		WINDOW	*a1, 
-		const char *a2, 
-		va_list	z)
-		{ return(*(int *)0); }
-
 #undef waddchstr
-int	(waddchstr)(
-		WINDOW	*a1, 
+int	waddchstr(
+		WINDOW	*a1,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef waddstr
-int	(waddstr)(
-		WINDOW	*a1, 
+int	waddstr(
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef wattron
-int	(wattron)(
-		WINDOW	*a1, 
+int	wattron(
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattroff
-int	(wattroff)(
-		WINDOW	*a1, 
+int	wattroff(
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattrset
-int	(wattrset)(
-		WINDOW	*a1, 
+int	wattrset(
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattr_get
-int	(wattr_get)(
-		WINDOW	*a1, 
-		attr_t	*a2, 
-		short	*a3, 
+int	wattr_get(
+		WINDOW	*a1,
+		attr_t	*a2,
+		short	*a3,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef wattr_set
-int	(wattr_set)(
-		WINDOW	*a1, 
-		attr_t	a2, 
-		short	a3, 
+int	wattr_set(
+		WINDOW	*a1,
+		attr_t	a2,
+		short	a3,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef wdeleteln
-int	(wdeleteln)(
+int	wdeleteln(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef wgetstr
-int	(wgetstr)(
-		WINDOW	*a1, 
+int	wgetstr(
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef winchstr
-int	(winchstr)(
-		WINDOW	*a1, 
+int	winchstr(
+		WINDOW	*a1,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef winsertln
-int	(winsertln)(
+int	winsertln(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef winsstr
-int	(winsstr)(
-		WINDOW	*a1, 
+int	winsstr(
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef winstr
-int	(winstr)(
-		WINDOW	*a1, 
+int	winstr(
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef wstandout
-int	(wstandout)(
+int	wstandout(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef wstandend
-int	(wstandend)(
+int	wstandend(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef getattrs
-int	(getattrs)(
+int	getattrs(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getcurx
-int	(getcurx)(
+int	getcurx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getcury
-int	(getcury)(
+int	getcury(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getbegx
-int	(getbegx)(
+int	getbegx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getbegy
-int	(getbegy)(
+int	getbegy(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getmaxx
-int	(getmaxx)(
+int	getmaxx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getmaxy
-int	(getmaxy)(
+int	getmaxy(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getparx
-int	(getparx)(
+int	getparx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getpary
-int	(getpary)(
+int	getpary(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef wgetparent
-WINDOW	*(wgetparent)(
+WINDOW	*wgetparent(
 		const WINDOW *z)
 		{ return(*(WINDOW **)0); }
 
 #undef is_cleared
-NCURSES_BOOL (is_cleared)(
+NCURSES_BOOL is_cleared(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_idcok
-NCURSES_BOOL (is_idcok)(
+NCURSES_BOOL is_idcok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_idlok
-NCURSES_BOOL (is_idlok)(
+NCURSES_BOOL is_idlok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_immedok
-NCURSES_BOOL (is_immedok)(
+NCURSES_BOOL is_immedok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_keypad
-NCURSES_BOOL (is_keypad)(
+NCURSES_BOOL is_keypad(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_leaveok
-NCURSES_BOOL (is_leaveok)(
+NCURSES_BOOL is_leaveok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_nodelay
-NCURSES_BOOL (is_nodelay)(
+NCURSES_BOOL is_nodelay(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_notimeout
-NCURSES_BOOL (is_notimeout)(
+NCURSES_BOOL is_notimeout(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_pad
-NCURSES_BOOL (is_pad)(
+NCURSES_BOOL is_pad(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_scrollok
-NCURSES_BOOL (is_scrollok)(
+NCURSES_BOOL is_scrollok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_subwin
-NCURSES_BOOL (is_subwin)(
+NCURSES_BOOL is_subwin(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_syncok
-NCURSES_BOOL (is_syncok)(
+NCURSES_BOOL is_syncok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef wgetdelay
-int	(wgetdelay)(
+int	wgetdelay(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef wgetscrreg
-int	(wgetscrreg)(
-		const WINDOW *a1, 
-		int	*a2, 
+int	wgetscrreg(
+		const WINDOW *a1,
+		int	*a2,
 		int	*z)
 		{ return(*(int *)0); }
 
 #undef add_wch
-int	(add_wch)(
+int	add_wch(
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef add_wchnstr
-int	(add_wchnstr)(
-		const cchar_t *a1, 
+int	add_wchnstr(
+		const cchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef add_wchstr
-int	(add_wchstr)(
+int	add_wchstr(
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef addnwstr
-int	(addnwstr)(
-		const wchar_t *a1, 
+int	addnwstr(
+		const wchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef addwstr
-int	(addwstr)(
+int	addwstr(
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef bkgrnd
-int	(bkgrnd)(
+int	bkgrnd(
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef bkgrndset
-void	(bkgrndset)(
+void	bkgrndset(
 		const cchar_t *z)
 		{ /* void */ }
 
 #undef border_set
-int	(border_set)(
-		const cchar_t *a1, 
-		const cchar_t *a2, 
-		const cchar_t *a3, 
-		const cchar_t *a4, 
-		const cchar_t *a5, 
-		const cchar_t *a6, 
-		const cchar_t *a7, 
+int	border_set(
+		const cchar_t *a1,
+		const cchar_t *a2,
+		const cchar_t *a3,
+		const cchar_t *a4,
+		const cchar_t *a5,
+		const cchar_t *a6,
+		const cchar_t *a7,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef box_set
-int	(box_set)(
-		WINDOW	*a1, 
-		const cchar_t *a2, 
+int	box_set(
+		WINDOW	*a1,
+		const cchar_t *a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef echo_wchar
-int	(echo_wchar)(
+int	echo_wchar(
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef get_wch
-int	(get_wch)(
+int	get_wch(
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef get_wstr
-int	(get_wstr)(
+int	get_wstr(
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef getbkgrnd
-int	(getbkgrnd)(
+int	getbkgrnd(
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef getn_wstr
-int	(getn_wstr)(
-		wint_t	*a1, 
+int	getn_wstr(
+		wint_t	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef hline_set
-int	(hline_set)(
-		const cchar_t *a1, 
+int	hline_set(
+		const cchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef in_wch
-int	(in_wch)(
+int	in_wch(
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef in_wchnstr
-int	(in_wchnstr)(
-		cchar_t	*a1, 
+int	in_wchnstr(
+		cchar_t	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef in_wchstr
-int	(in_wchstr)(
+int	in_wchstr(
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef innwstr
-int	(innwstr)(
-		wchar_t	*a1, 
+int	innwstr(
+		wchar_t	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef ins_nwstr
-int	(ins_nwstr)(
-		const wchar_t *a1, 
+int	ins_nwstr(
+		const wchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef ins_wch
-int	(ins_wch)(
+int	ins_wch(
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef ins_wstr
-int	(ins_wstr)(
+int	ins_wstr(
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef inwstr
-int	(inwstr)(
+int	inwstr(
 		wchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvadd_wch
-int	(mvadd_wch)(
-		int	a1, 
-		int	a2, 
+int	mvadd_wch(
+		int	a1,
+		int	a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvadd_wchnstr
-int	(mvadd_wchnstr)(
-		int	a1, 
-		int	a2, 
-		const cchar_t *a3, 
+int	mvadd_wchnstr(
+		int	a1,
+		int	a2,
+		const cchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvadd_wchstr
-int	(mvadd_wchstr)(
-		int	a1, 
-		int	a2, 
+int	mvadd_wchstr(
+		int	a1,
+		int	a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvaddnwstr
-int	(mvaddnwstr)(
-		int	a1, 
-		int	a2, 
-		const wchar_t *a3, 
+int	mvaddnwstr(
+		int	a1,
+		int	a2,
+		const wchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddwstr
-int	(mvaddwstr)(
-		int	a1, 
-		int	a2, 
+int	mvaddwstr(
+		int	a1,
+		int	a2,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvget_wch
-int	(mvget_wch)(
-		int	a1, 
-		int	a2, 
+int	mvget_wch(
+		int	a1,
+		int	a2,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvget_wstr
-int	(mvget_wstr)(
-		int	a1, 
-		int	a2, 
+int	mvget_wstr(
+		int	a1,
+		int	a2,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvgetn_wstr
-int	(mvgetn_wstr)(
-		int	a1, 
-		int	a2, 
-		wint_t	*a3, 
+int	mvgetn_wstr(
+		int	a1,
+		int	a2,
+		wint_t	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvhline_set
-int	(mvhline_set)(
-		int	a1, 
-		int	a2, 
-		const cchar_t *a3, 
+int	mvhline_set(
+		int	a1,
+		int	a2,
+		const cchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvin_wch
-int	(mvin_wch)(
-		int	a1, 
-		int	a2, 
+int	mvin_wch(
+		int	a1,
+		int	a2,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvin_wchnstr
-int	(mvin_wchnstr)(
-		int	a1, 
-		int	a2, 
-		cchar_t	*a3, 
+int	mvin_wchnstr(
+		int	a1,
+		int	a2,
+		cchar_t	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvin_wchstr
-int	(mvin_wchstr)(
-		int	a1, 
-		int	a2, 
+int	mvin_wchstr(
+		int	a1,
+		int	a2,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvinnwstr
-int	(mvinnwstr)(
-		int	a1, 
-		int	a2, 
-		wchar_t	*a3, 
+int	mvinnwstr(
+		int	a1,
+		int	a2,
+		wchar_t	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvins_nwstr
-int	(mvins_nwstr)(
-		int	a1, 
-		int	a2, 
-		const wchar_t *a3, 
+int	mvins_nwstr(
+		int	a1,
+		int	a2,
+		const wchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvins_wch
-int	(mvins_wch)(
-		int	a1, 
-		int	a2, 
+int	mvins_wch(
+		int	a1,
+		int	a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvins_wstr
-int	(mvins_wstr)(
-		int	a1, 
-		int	a2, 
+int	mvins_wstr(
+		int	a1,
+		int	a2,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvinwstr
-int	(mvinwstr)(
-		int	a1, 
-		int	a2, 
+int	mvinwstr(
+		int	a1,
+		int	a2,
 		wchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvvline_set
-int	(mvvline_set)(
-		int	a1, 
-		int	a2, 
-		const cchar_t *a3, 
+int	mvvline_set(
+		int	a1,
+		int	a2,
+		const cchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwadd_wch
-int	(mvwadd_wch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwadd_wch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwadd_wchnstr
-int	(mvwadd_wchnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const cchar_t *a4, 
+int	mvwadd_wchnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const cchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwadd_wchstr
-int	(mvwadd_wchstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwadd_wchstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwaddnwstr
-int	(mvwaddnwstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const wchar_t *a4, 
+int	mvwaddnwstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const wchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddwstr
-int	(mvwaddwstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwaddwstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwget_wch
-int	(mvwget_wch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwget_wch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwget_wstr
-int	(mvwget_wstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwget_wstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwgetn_wstr
-int	(mvwgetn_wstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		wint_t	*a4, 
+int	mvwgetn_wstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		wint_t	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwhline_set
-int	(mvwhline_set)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const cchar_t *a4, 
+int	mvwhline_set(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const cchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwin_wch
-int	(mvwin_wch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwin_wch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwin_wchnstr
-int	(mvwin_wchnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		cchar_t	*a4, 
+int	mvwin_wchnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		cchar_t	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwin_wchstr
-int	(mvwin_wchstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwin_wchstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwinnwstr
-int	(mvwinnwstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		wchar_t	*a4, 
+int	mvwinnwstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		wchar_t	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwins_nwstr
-int	(mvwins_nwstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const wchar_t *a4, 
+int	mvwins_nwstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const wchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwins_wch
-int	(mvwins_wch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwins_wch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwins_wstr
-int	(mvwins_wstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwins_wstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwinwstr
-int	(mvwinwstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinwstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		wchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwvline_set
-int	(mvwvline_set)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const cchar_t *a4, 
+int	mvwvline_set(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const cchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef vline_set
-int	(vline_set)(
-		const cchar_t *a1, 
+int	vline_set(
+		const cchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wadd_wchstr
-int	(wadd_wchstr)(
-		WINDOW	*a1, 
+int	wadd_wchstr(
+		WINDOW	*a1,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef waddwstr
-int	(waddwstr)(
-		WINDOW	*a1, 
+int	waddwstr(
+		WINDOW	*a1,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef wget_wstr
-int	(wget_wstr)(
-		WINDOW	*a1, 
+int	wget_wstr(
+		WINDOW	*a1,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef wgetbkgrnd
-int	(wgetbkgrnd)(
-		WINDOW	*a1, 
+int	wgetbkgrnd(
+		WINDOW	*a1,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef win_wchstr
-int	(win_wchstr)(
-		WINDOW	*a1, 
+int	win_wchstr(
+		WINDOW	*a1,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef wins_wstr
-int	(wins_wstr)(
-		WINDOW	*a1, 
+int	wins_wstr(
+		WINDOW	*a1,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mouse_trafo
-NCURSES_BOOL (mouse_trafo)(
-		int	*a1, 
-		int	*a2, 
+NCURSES_BOOL mouse_trafo(
+		int	*a1,
+		int	*a2,
 		NCURSES_BOOL z)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1780,7 +1877,7 @@
 
 #undef set_escdelay_sp
 int	set_escdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -1800,8 +1897,8 @@
 
 #undef _nc_wgetch
 int	_nc_wgetch(
-		WINDOW	*win, 
-		int	*result, 
+		WINDOW	*win,
+		int	*result,
 		int	use_meta)
 		{ return(*(int *)0); }
 
@@ -1814,8 +1911,8 @@
 
 #undef wgetnstr
 int	wgetnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	maxlen)
 		{ return(*(int *)0); }
 
@@ -1823,8 +1920,8 @@
 
 #undef whline
 int	whline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1832,7 +1929,7 @@
 
 #undef immedok
 void	immedok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
@@ -1840,8 +1937,8 @@
 
 #undef winchnstr
 int	winchnstr(
-		WINDOW	*win, 
-		chtype	*str, 
+		WINDOW	*win,
+		chtype	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1855,14 +1952,14 @@
 
 #undef _nc_insert_ch
 int	_nc_insert_ch(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
 #undef winsch
 int	winsch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	c)
 		{ return(*(int *)0); }
 
@@ -1870,7 +1967,7 @@
 
 #undef winsdelln
 int	winsdelln(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1878,8 +1975,8 @@
 
 #undef winsnstr
 int	winsnstr(
-		WINDOW	*win, 
-		const char *s, 
+		WINDOW	*win,
+		const char *s,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1887,8 +1984,8 @@
 
 #undef winnstr
 int	winnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1907,7 +2004,7 @@
 
 #undef leaveok
 int	leaveok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -1915,7 +2012,7 @@
 
 #undef getmouse_sp
 int	getmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -1926,7 +2023,7 @@
 
 #undef ungetmouse_sp
 int	ungetmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -1937,27 +2034,27 @@
 
 #undef mousemask_sp
 mmask_t	mousemask_sp(
-		SCREEN	*sp, 
-		mmask_t	newmask, 
+		SCREEN	*sp,
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef mousemask
 mmask_t	mousemask(
-		mmask_t	newmask, 
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef wenclose
 NCURSES_BOOL wenclose(
-		const WINDOW *win, 
-		int	y, 
+		const WINDOW *win,
+		int	y,
 		int	x)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef mouseinterval_sp
 int	mouseinterval_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	maxclick)
 		{ return(*(int *)0); }
 
@@ -1982,9 +2079,9 @@
 
 #undef wmouse_trafo
 NCURSES_BOOL wmouse_trafo(
-		const WINDOW *win, 
-		int	*pY, 
-		int	*pX, 
+		const WINDOW *win,
+		int	*pY,
+		int	*pX,
 		NCURSES_BOOL to_screen)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1992,8 +2089,8 @@
 
 #undef wmove
 int	wmove(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
@@ -2001,14 +2098,14 @@
 
 #undef _nc_msec_cost_sp
 int	_nc_msec_cost_sp(
-		SCREEN	*sp, 
-		const char *const cap, 
+		SCREEN	*sp,
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
 #undef _nc_msec_cost
 int	_nc_msec_cost(
-		const char *const cap, 
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
@@ -2041,35 +2138,35 @@
 
 #undef _nc_mvcur_sp
 int	_nc_mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef _nc_mvcur
 int	_nc_mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur_sp
 int	mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur
 int	mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
@@ -2080,8 +2177,8 @@
 
 #undef mvwin
 int	mvwin(
-		WINDOW	*win, 
-		int	by, 
+		WINDOW	*win,
+		int	by,
 		int	bx)
 		{ return(*(int *)0); }
 
@@ -2107,16 +2204,16 @@
 
 #undef newterm_sp
 SCREEN	*newterm_sp(
-		SCREEN	*sp, 
-		const char *name, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
 #undef newterm
 SCREEN	*newterm(
-		const char *name, 
-		FILE	*ofp, 
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
@@ -2129,46 +2226,46 @@
 
 #undef newwin_sp
 WINDOW	*newwin_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef newwin
 WINDOW	*newwin(
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef derwin
 WINDOW	*derwin(
-		WINDOW	*orig, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		WINDOW	*orig,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef subwin
 WINDOW	*subwin(
-		WINDOW	*w, 
-		int	l, 
-		int	c, 
-		int	y, 
+		WINDOW	*w,
+		int	l,
+		int	c,
+		int	y,
 		int	x)
 		{ return(*(WINDOW **)0); }
 
 #undef _nc_makenew_sp
 WINDOW	*_nc_makenew_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
-		int	begx, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
+		int	begx,
 		int	flags)
 		{ return(*(WINDOW **)0); }
 
@@ -2211,26 +2308,26 @@
 
 #undef overlay
 int	overlay(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef overwrite
 int	overwrite(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef copywin
 int	copywin(
-		const WINDOW *src, 
-		WINDOW	*dst, 
-		int	sminrow, 
-		int	smincol, 
-		int	dminrow, 
-		int	dmincol, 
-		int	dmaxrow, 
-		int	dmaxcol, 
+		const WINDOW *src,
+		WINDOW	*dst,
+		int	sminrow,
+		int	smincol,
+		int	dminrow,
+		int	dmincol,
+		int	dmaxrow,
+		int	dmaxcol,
 		int	over)
 		{ return(*(int *)0); }
 
@@ -2238,51 +2335,51 @@
 
 #undef newpad_sp
 WINDOW	*newpad_sp(
-		SCREEN	*sp, 
-		int	l, 
+		SCREEN	*sp,
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef newpad
 WINDOW	*newpad(
-		int	l, 
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef subpad
 WINDOW	*subpad(
-		WINDOW	*orig, 
-		int	l, 
-		int	c, 
-		int	begy, 
+		WINDOW	*orig,
+		int	l,
+		int	c,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef prefresh
 int	prefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pnoutrefresh
 int	pnoutrefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pechochar
 int	pechochar(
-		WINDOW	*pad, 
+		WINDOW	*pad,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -2290,38 +2387,45 @@
 
 #undef printw
 int	printw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wprintw
 int	wprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvprintw
 int	mvprintw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwprintw
 int	mvwprintw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef vwprintw
 int	vwprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
+		va_list	argp)
+		{ return(*(int *)0); }
+
+#undef vw_printw
+int	vw_printw(
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
@@ -2329,8 +2433,8 @@
 
 #undef wredrawln
 int	wredrawln(
-		WINDOW	*win, 
-		int	beg, 
+		WINDOW	*win,
+		int	beg,
 		int	num)
 		{ return(*(int *)0); }
 
@@ -2350,16 +2454,16 @@
 
 #undef restartterm_sp
 int	restartterm_sp(
-		SCREEN	*sp, 
-		const char *termp, 
-		int	filenum, 
+		SCREEN	*sp,
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
 #undef restartterm
 int	restartterm(
-		const char *termp, 
-		int	filenum, 
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -2367,38 +2471,45 @@
 
 #undef vwscanw
 int	vwscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
+		va_list	argp)
+		{ return(*(int *)0); }
+
+#undef vw_scanw
+int	vw_scanw(
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef scanw
 int	scanw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wscanw
 int	wscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvscanw
 int	mvscanw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwscanw
 int	mvwscanw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
@@ -2406,7 +2517,7 @@
 
 #undef getwin_sp
 WINDOW	*getwin_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		FILE	*filep)
 		{ return(*(WINDOW **)0); }
 
@@ -2417,13 +2528,13 @@
 
 #undef putwin
 int	putwin(
-		WINDOW	*win, 
+		WINDOW	*win,
 		FILE	*filep)
 		{ return(*(int *)0); }
 
 #undef scr_restore_sp
 int	scr_restore_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -2439,7 +2550,7 @@
 
 #undef scr_init_sp
 int	scr_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -2450,7 +2561,7 @@
 
 #undef scr_set_sp
 int	scr_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -2463,16 +2574,16 @@
 
 #undef _nc_scroll_window
 void	_nc_scroll_window(
-		WINDOW	*win, 
-		int const n, 
-		int const top, 
-		int const bottom, 
+		WINDOW	*win,
+		int const n,
+		int const top,
+		int const bottom,
 		cchar_t	blank)
 		{ /* void */ }
 
 #undef wscrl
 int	wscrl(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2480,7 +2591,7 @@
 
 #undef scrollok
 int	scrollok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -2488,8 +2599,8 @@
 
 #undef wsetscrreg
 int	wsetscrreg(
-		WINDOW	*win, 
-		int	top, 
+		WINDOW	*win,
+		int	top,
 		int	bottom)
 		{ return(*(int *)0); }
 
@@ -2507,54 +2618,54 @@
 
 #undef _nc_setupscreen_sp
 int	_nc_setupscreen_sp(
-		SCREEN	**spp, 
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		SCREEN	**spp,
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_setupscreen
 int	_nc_setupscreen(
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline_sp
 int	_nc_ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline
 int	_nc_ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline_sp
 int	ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline
 int	ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
@@ -2562,13 +2673,13 @@
 
 #undef _nc_format_slks
 int	_nc_format_slks(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	cols)
 		{ return(*(int *)0); }
 
 #undef _nc_slk_initialize
 int	_nc_slk_initialize(
-		WINDOW	*stwin, 
+		WINDOW	*stwin,
 		int	cols)
 		{ return(*(int *)0); }
 
@@ -2585,16 +2696,16 @@
 
 #undef slk_attr_set_sp
 int	slk_attr_set_sp(
-		SCREEN	*sp, 
-		const attr_t attr, 
-		short	color_pair_number, 
+		SCREEN	*sp,
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 #undef slk_attr_set
 int	slk_attr_set(
-		const attr_t attr, 
-		short	color_pair_number, 
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2602,7 +2713,7 @@
 
 #undef slk_attroff_sp
 int	slk_attroff_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2615,7 +2726,7 @@
 
 #undef slk_attron_sp
 int	slk_attron_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2628,7 +2739,7 @@
 
 #undef slk_attrset_sp
 int	slk_attrset_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2663,20 +2774,31 @@
 
 #undef slk_color_sp
 int	slk_color_sp(
-		SCREEN	*sp, 
-		short	color_pair_number)
+		SCREEN	*sp,
+		short	pair_arg)
 		{ return(*(int *)0); }
 
 #undef slk_color
 int	slk_color(
-		short	color_pair_number)
+		short	pair_arg)
+		{ return(*(int *)0); }
+
+#undef extended_slk_color_sp
+int	extended_slk_color_sp(
+		SCREEN	*sp,
+		int	pair_arg)
+		{ return(*(int *)0); }
+
+#undef extended_slk_color
+int	extended_slk_color(
+		int	pair_arg)
 		{ return(*(int *)0); }
 
 /* ./base/lib_slkinit.c */
 
 #undef slk_init_sp
 int	slk_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2689,7 +2811,7 @@
 
 #undef slk_label_sp
 char	*slk_label_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	n)
 		{ return(*(char **)0); }
 
@@ -2722,16 +2844,16 @@
 
 #undef slk_set_sp
 int	slk_set_sp(
-		SCREEN	*sp, 
-		int	i, 
-		const char *astr, 
+		SCREEN	*sp,
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
 #undef slk_set
 int	slk_set(
-		int	i, 
-		const char *astr, 
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2750,7 +2872,7 @@
 
 #undef is_linetouched
 NCURSES_BOOL is_linetouched(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	line)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -2761,9 +2883,9 @@
 
 #undef wtouchln
 int	wtouchln(
-		WINDOW	*win, 
-		int	y, 
-		int	n, 
+		WINDOW	*win,
+		int	y,
+		int	n,
 		int	changed)
 		{ return(*(int *)0); }
 
@@ -2771,7 +2893,7 @@
 
 #undef _tracedump
 void	_tracedump(
-		const char *name, 
+		const char *name,
 		WINDOW	*win)
 		{ /* void */ }
 
@@ -2779,19 +2901,19 @@
 
 #undef _nc_trace_mmask_t
 char	*_nc_trace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(char **)0); }
 
 #undef _nc_tracemouse
 char	*_nc_tracemouse(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT const *ep)
 		{ return(*(char **)0); }
 
 #undef _nc_retrace_mmask_t
 mmask_t	_nc_retrace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(mmask_t *)0); }
 
@@ -2816,7 +2938,7 @@
 
 #undef ungetch_sp
 int	ungetch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -2829,20 +2951,20 @@
 
 #undef vidputs_sp
 int	vidputs_sp(
-		SCREEN	*sp, 
-		chtype	newmode, 
+		SCREEN	*sp,
+		chtype	newmode,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef vidputs
 int	vidputs(
-		chtype	newmode, 
+		chtype	newmode,
 		NCURSES_OUTC outc)
 		{ return(*(int *)0); }
 
 #undef vidattr_sp
 int	vidattr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	newmode)
 		{ return(*(int *)0); }
 
@@ -2864,8 +2986,8 @@
 
 #undef wvline
 int	wvline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2873,8 +2995,8 @@
 
 #undef wattr_off
 int	wattr_off(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2882,8 +3004,8 @@
 
 #undef wattr_on
 int	wattr_on(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2903,14 +3025,14 @@
 
 #undef mvderwin
 int	mvderwin(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
 #undef syncok
 int	syncok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL bf)
 		{ return(*(int *)0); }
 
@@ -2949,14 +3071,14 @@
 
 #undef _nc_printf_string_sp
 char	*_nc_printf_string_sp(
-		SCREEN	*sp, 
-		const char *fmt, 
+		SCREEN	*sp,
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
 #undef _nc_printf_string
 char	*_nc_printf_string(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -2973,18 +3095,18 @@
 
 #undef _nc_scrolln_sp
 int	_nc_scrolln_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
-		int	bot, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
 #undef _nc_scrolln
 int	_nc_scrolln(
-		int	n, 
-		int	top, 
-		int	bot, 
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
@@ -3017,7 +3139,7 @@
 
 #undef _nc_do_xmc_glitch_sp
 void	_nc_do_xmc_glitch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		attr_t	previous)
 		{ /* void */ }
 
@@ -3028,13 +3150,9 @@
 
 /* ./trace/varargs.c */
 
-typedef enum {
-    atUnknown = 0, atInteger, atFloat, atPoint, atString
-} ARGTYPE;
-
 #undef _nc_varargs
 char	*_nc_varargs(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -3052,7 +3170,7 @@
 
 #undef _nc_free_and_exit_sp
 void	_nc_free_and_exit_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	code)
 		{ /* void */ }
 
@@ -3061,6 +3179,11 @@
 		int	code)
 		{ /* void */ }
 
+#undef exit_curses
+void	exit_curses(
+		int	code)
+		{ /* void */ }
+
 /* ./widechar/charable.c */
 
 #undef _nc_is_charable
@@ -3082,13 +3205,13 @@
 
 #undef wadd_wch
 int	wadd_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
 #undef wecho_wchar
 int	wecho_wchar(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
@@ -3096,14 +3219,14 @@
 
 #undef wborder_set
 int	wborder_set(
-		WINDOW	*win, 
-		const cchar_t *ls, 
-		const cchar_t *rs, 
-		const cchar_t *ts, 
-		const cchar_t *bs, 
-		const cchar_t *tl, 
-		const cchar_t *tr, 
-		const cchar_t *bl, 
+		WINDOW	*win,
+		const cchar_t *ls,
+		const cchar_t *rs,
+		const cchar_t *ts,
+		const cchar_t *bs,
+		const cchar_t *tl,
+		const cchar_t *tr,
+		const cchar_t *bl,
 		const cchar_t *br)
 		{ return(*(int *)0); }
 
@@ -3111,29 +3234,41 @@
 
 #undef setcchar
 int	setcchar(
-		cchar_t	*wcval, 
-		const wchar_t *wch, 
-		const attr_t attrs, 
-		short	color_pair, 
+		cchar_t	*wcval,
+		const wchar_t *wch,
+		const attr_t attrs,
+		short	pair_arg,
 		const void *opts)
 		{ return(*(int *)0); }
 
 #undef getcchar
 int	getcchar(
-		const cchar_t *wcval, 
-		wchar_t	*wch, 
-		attr_t	*attrs, 
-		short	*color_pair, 
+		const cchar_t *wcval,
+		wchar_t	*wch,
+		attr_t	*attrs,
+		short	*pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 /* ./widechar/lib_erasewchar.c */
 
+#undef erasewchar_sp
+int	erasewchar_sp(
+		SCREEN	*sp,
+		wchar_t	*wch)
+		{ return(*(int *)0); }
+
 #undef erasewchar
 int	erasewchar(
 		wchar_t	*wch)
 		{ return(*(int *)0); }
 
+#undef killwchar_sp
+int	killwchar_sp(
+		SCREEN	*sp,
+		wchar_t	*wch)
+		{ return(*(int *)0); }
+
 #undef killwchar
 int	killwchar(
 		wchar_t	*wch)
@@ -3143,7 +3278,7 @@
 
 #undef wget_wch
 int	wget_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		wint_t	*result)
 		{ return(*(int *)0); }
 
@@ -3151,8 +3286,8 @@
 
 #undef wgetn_wstr
 int	wgetn_wstr(
-		WINDOW	*win, 
-		wint_t	*str, 
+		WINDOW	*win,
+		wint_t	*str,
 		int	maxlen)
 		{ return(*(int *)0); }
 
@@ -3160,8 +3295,8 @@
 
 #undef whline_set
 int	whline_set(
-		WINDOW	*win, 
-		const cchar_t *ch, 
+		WINDOW	*win,
+		const cchar_t *ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3169,7 +3304,7 @@
 
 #undef win_wch
 int	win_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		cchar_t	*wcval)
 		{ return(*(int *)0); }
 
@@ -3177,8 +3312,8 @@
 
 #undef win_wchnstr
 int	win_wchnstr(
-		WINDOW	*win, 
-		cchar_t	*wchstr, 
+		WINDOW	*win,
+		cchar_t	*wchstr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3186,20 +3321,20 @@
 
 #undef _nc_insert_wch
 int	_nc_insert_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
 #undef wins_wch
 int	wins_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
 #undef wins_nwstr
 int	wins_nwstr(
-		WINDOW	*win, 
-		const wchar_t *wstr, 
+		WINDOW	*win,
+		const wchar_t *wstr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3207,14 +3342,14 @@
 
 #undef winnwstr
 int	winnwstr(
-		WINDOW	*win, 
-		wchar_t	*wstr, 
+		WINDOW	*win,
+		wchar_t	*wstr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef winwstr
 int	winwstr(
-		WINDOW	*win, 
+		WINDOW	*win,
 		wchar_t	*wstr)
 		{ return(*(int *)0); }
 
@@ -3229,7 +3364,7 @@
 
 #undef pecho_wchar
 int	pecho_wchar(
-		WINDOW	*pad, 
+		WINDOW	*pad,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
@@ -3237,8 +3372,8 @@
 
 #undef slk_wset
 int	slk_wset(
-		int	i, 
-		const wchar_t *astr, 
+		int	i,
+		const wchar_t *astr,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -3246,14 +3381,14 @@
 
 #undef _nc_wcrtomb
 size_t	_nc_wcrtomb(
-		char	*target, 
-		wchar_t	source, 
+		char	*target,
+		wchar_t	source,
 		mbstate_t *state)
 		{ return(*(size_t *)0); }
 
 #undef unget_wch_sp
 int	unget_wch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const wchar_t wch)
 		{ return(*(int *)0); }
 
@@ -3266,33 +3401,33 @@
 
 #undef vid_puts_sp
 int	vid_puts_sp(
-		SCREEN	*sp, 
-		attr_t	newmode, 
-		short	pair, 
-		void	*opts, 
+		SCREEN	*sp,
+		attr_t	newmode,
+		short	pair_arg,
+		void	*opts,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef vid_puts
 int	vid_puts(
-		attr_t	newmode, 
-		short	pair, 
-		void	*opts, 
+		attr_t	newmode,
+		short	pair_arg,
+		void	*opts,
 		NCURSES_OUTC outc)
 		{ return(*(int *)0); }
 
 #undef vid_attr_sp
 int	vid_attr_sp(
-		SCREEN	*sp, 
-		attr_t	newmode, 
-		short	pair, 
+		SCREEN	*sp,
+		attr_t	newmode,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 #undef vid_attr
 int	vid_attr(
-		attr_t	newmode, 
-		short	pair, 
+		attr_t	newmode,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -3309,8 +3444,8 @@
 
 #undef wvline_set
 int	wvline_set(
-		WINDOW	*win, 
-		const cchar_t *ch, 
+		WINDOW	*win,
+		const cchar_t *ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3327,7 +3462,7 @@
 
 #undef wunctrl_sp
 wchar_t	*wunctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		cchar_t	*wc)
 		{ return(*(wchar_t **)0); }
 
@@ -3340,31 +3475,31 @@
 
 #undef _nc_toggle_attr_on
 void	_nc_toggle_attr_on(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_toggle_attr_off
 void	_nc_toggle_attr_off(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_DelCharCost_sp
 int	_nc_DelCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_InsCharCost_sp
 int	_nc_InsCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_UpdateAttrs_sp
 void	_nc_UpdateAttrs_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const cchar_t *c)
 		{ /* void */ }
 
@@ -3387,7 +3522,7 @@
 
 #undef use_legacy_coding_sp
 int	use_legacy_coding_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	level)
 		{ return(*(int *)0); }
 
@@ -3409,14 +3544,14 @@
 
 #undef assume_default_colors_sp
 int	assume_default_colors_sp(
-		SCREEN	*sp, 
-		int	fg, 
+		SCREEN	*sp,
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
 #undef assume_default_colors
 int	assume_default_colors(
-		int	fg, 
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
@@ -3424,55 +3559,121 @@
 
 #undef mcprint_sp
 int	mcprint_sp(
-		SCREEN	*sp, 
-		char	*data, 
+		SCREEN	*sp,
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
 #undef mcprint
 int	mcprint(
-		char	*data, 
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
+/* ./base/new_pair.c */
+
+#undef _nc_free_ordered_pairs
+void	_nc_free_ordered_pairs(
+		SCREEN	*sp)
+		{ /* void */ }
+
+#undef _nc_reset_color_pair
+void	_nc_reset_color_pair(
+		SCREEN	*sp,
+		int	pair,
+		colorpair_t *next)
+		{ /* void */ }
+
+#undef _nc_set_color_pair
+void	_nc_set_color_pair(
+		SCREEN	*sp,
+		int	pair,
+		int	mode)
+		{ /* void */ }
+
+#undef _nc_copy_pairs
+void	_nc_copy_pairs(
+		SCREEN	*sp,
+		colorpair_t *target,
+		colorpair_t *source,
+		int	length)
+		{ /* void */ }
+
+#undef alloc_pair_sp
+int	alloc_pair_sp(
+		SCREEN	*sp,
+		int	fg,
+		int	bg)
+		{ return(*(int *)0); }
+
+#undef find_pair_sp
+int	find_pair_sp(
+		SCREEN	*sp,
+		int	fg,
+		int	bg)
+		{ return(*(int *)0); }
+
+#undef free_pair_sp
+int	free_pair_sp(
+		SCREEN	*sp,
+		int	pair)
+		{ return(*(int *)0); }
+
+#undef alloc_pair
+int	alloc_pair(
+		int	f,
+		int	b)
+		{ return(*(int *)0); }
+
+#undef find_pair
+int	find_pair(
+		int	f,
+		int	b)
+		{ return(*(int *)0); }
+
+#undef free_pair
+int	free_pair(
+		int	pair)
+		{ return(*(int *)0); }
+
 /* ./base/resizeterm.c */
 
 #undef is_term_resized_sp
 NCURSES_BOOL is_term_resized_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_term_resized
 NCURSES_BOOL is_term_resized(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef resize_term_sp
 int	resize_term_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resize_term
 int	resize_term(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm_sp
 int	resizeterm_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm
 int	resizeterm(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -3487,8 +3688,8 @@
 
 #undef use_screen
 int	use_screen(
-		SCREEN	*screen, 
-		NCURSES_SCREEN_CB func, 
+		SCREEN	*screen,
+		NCURSES_SCREEN_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -3496,8 +3697,8 @@
 
 #undef use_window
 int	use_window(
-		WINDOW	*win, 
-		NCURSES_WINDOW_CB func, 
+		WINDOW	*win,
+		NCURSES_WINDOW_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -3505,8 +3706,8 @@
 
 #undef wresize
 int	wresize(
-		WINDOW	*win, 
-		int	ToLines, 
+		WINDOW	*win,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -3534,7 +3735,7 @@
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -3552,12 +3753,25 @@
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -3565,16 +3779,28 @@
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE *to, 
-		TERMTYPE *from)
+		TERMTYPE2 *to,
+		TERMTYPE2 *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
+#undef _nc_copy_termtype2
+void	_nc_copy_termtype2(
+		TERMTYPE2 *dst,
+		const TERMTYPE2 *src)
+		{ /* void */ }
+
+#undef _nc_export_termtype2
+void	_nc_export_termtype2(
+		TERMTYPE *dst,
+		const TERMTYPE2 *src)
+		{ /* void */ }
+
 /* ./codes.c */
 
 #undef _nc_boolcodes
@@ -3641,19 +3867,19 @@
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -3661,17 +3887,32 @@
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
+#undef _nc_find_user_entry
+struct user_table_entry const *_nc_find_user_entry(
+		const char *string)
+		{ return(*(struct user_table_entry const **)0); }
+
+/* ./comp_userdefs.c */
+
+#undef _nc_get_userdefs_table
+const struct user_table_entry *_nc_get_userdefs_table(void)
+		{ return(*(const struct user_table_entry **)0); }
+
+#undef _nc_get_hash_user
+const HashData *_nc_get_hash_user(void)
+		{ return(*(const HashData **)0); }
+
 /* ./tinfo/db_iterator.c */
 
 #undef _nc_tic_dir
@@ -3690,13 +3931,13 @@
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -3704,7 +3945,7 @@
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -3717,8 +3958,8 @@
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
-		TERMTYPE *tterm)
+		ENTRY	*headp,
+		TERMTYPE2 *tterm)
 		{ /* void */ }
 
 #undef _nc_free_entries
@@ -3726,18 +3967,22 @@
 		ENTRY	*headp)
 		{ /* void */ }
 
-#undef _nc_delink_entry
-ENTRY	*_nc_delink_entry(
-		ENTRY	*headp, 
-		TERMTYPE *tterm)
-		{ return(*(ENTRY **)0); }
-
 #undef _nc_leaks_tinfo
 void	_nc_leaks_tinfo(void)
 		{ /* void */ }
 
+#undef exit_terminfo
+void	exit_terminfo(
+		int	code)
+		{ /* void */ }
+
 /* ./fallback.c */
 
+#undef _nc_fallback2
+const TERMTYPE2 *_nc_fallback2(
+		const char *name)
+		{ return(*(const TERMTYPE2 **)0); }
+
 #undef _nc_fallback
 const TERMTYPE *_nc_fallback(
 		const char *name)
@@ -3750,6 +3995,16 @@
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
+#undef _nc_free_termtype2
+void	_nc_free_termtype2(
+		TERMTYPE2 *ptr)
+		{ /* void */ }
+
 #undef _nc_user_definable
 NCURSES_BOOL _nc_user_definable;
 
@@ -3767,7 +4022,7 @@
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -3802,8 +4057,8 @@
 /* ./tinfo/lib_baudrate.c */
 
 struct speed {
-    short s; 
-    int sp; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -3842,7 +4097,7 @@
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -3853,7 +4108,7 @@
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -3969,7 +4224,7 @@
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -3993,7 +4248,7 @@
 
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -4006,19 +4261,19 @@
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -4029,37 +4284,37 @@
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -4070,7 +4325,7 @@
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -4081,7 +4336,7 @@
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -4092,14 +4347,14 @@
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -4161,17 +4416,53 @@
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
 /* ./tinfo/lib_setup.c */
 
 #undef _nc_ttytype
@@ -4207,7 +4498,7 @@
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -4223,13 +4514,13 @@
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -4245,8 +4536,8 @@
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -4257,13 +4548,13 @@
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
-		TERMTYPE *const tp)
+		const char *const tn,
+		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -4282,20 +4573,28 @@
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
+#undef _nc_find_prescr
+SCREEN	*_nc_find_prescr(void)
+		{ return(*(SCREEN **)0); }
+
+#undef _nc_forget_prescr
+void	_nc_forget_prescr(void)
+		{ /* void */ }
+
 #undef new_prescr
 SCREEN	*new_prescr(void)
 		{ return(*(SCREEN **)0); }
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -4308,20 +4607,20 @@
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -4332,7 +4631,7 @@
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -4343,14 +4642,14 @@
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -4369,8 +4668,8 @@
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -4378,7 +4677,7 @@
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -4389,7 +4688,7 @@
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -4400,7 +4699,7 @@
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -4414,25 +4713,58 @@
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
+#undef _nc_tiparm
+char	*_nc_tiparm(
+		int	expected,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -4449,7 +4781,7 @@
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -4469,7 +4801,7 @@
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -4480,7 +4812,7 @@
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -4491,7 +4823,7 @@
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -4502,35 +4834,35 @@
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -4558,6 +4890,11 @@
 		long	increment)
 		{ /* void */ }
 
+#undef curses_trace
+unsigned curses_trace(
+		unsigned tracelevel)
+		{ return(*(unsigned *)0); }
+
 #undef trace
 void	trace(
 		const unsigned int tracelevel)
@@ -4565,7 +4902,7 @@
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -4619,6 +4956,13 @@
 		WINDOW	*code)
 		{ return(*(WINDOW **)0); }
 
+#undef _nc_fmt_funcptr
+char	*_nc_fmt_funcptr(
+		char	*target,
+		const char *source,
+		size_t	size)
+		{ return(*(char **)0); }
+
 #undef _nc_use_tracef
 int	_nc_use_tracef(
 		unsigned mask)
@@ -4626,7 +4970,7 @@
 
 #undef _nc_locked_tracef
 void	_nc_locked_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -4634,7 +4978,7 @@
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -4655,13 +4999,13 @@
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -4677,7 +5021,7 @@
 
 #undef _tracecchar_t2
 char	*_tracecchar_t2(
-		int	bufnum, 
+		int	bufnum,
 		const cchar_t *ch)
 		{ return(*(char **)0); }
 
@@ -4688,14 +5032,9 @@
 
 /* ./trace/lib_tracebits.c */
 
-typedef struct {
-    unsigned int val;
-    const char name[8];
-} BITNAMES;
-
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -4706,7 +5045,7 @@
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -4719,7 +5058,7 @@
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -4730,7 +5069,7 @@
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -4797,9 +5136,9 @@
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -4812,8 +5151,8 @@
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -4847,14 +5186,14 @@
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
@@ -4862,65 +5201,74 @@
 
 #undef _nc_init_termtype
 void	_nc_init_termtype(
-		TERMTYPE *const tp)
+		TERMTYPE2 *const tp)
 		{ /* void */ }
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE *ptr, 
-		char	*buffer, 
+		TERMTYPE2 *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
-		TERMTYPE *ptr)
+		const char *const filename,
+		TERMTYPE2 *ptr)
+		{ return(*(int *)0); }
+
+#undef _nc_read_entry2
+int	_nc_read_entry2(
+		const char *const name,
+		char	*const filename,
+		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/read_termcap.c */
 
-#undef _nc_read_termcap
-void	_nc_read_termcap(void)
-		{ /* void */ }
+#undef _nc_read_termcap_entry
+int	_nc_read_termcap_entry(
+		const char *const tn,
+		TERMTYPE2 *const tp)
+		{ return(*(int *)0); }
 
 /* ./tinfo/strings.c */
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -4928,13 +5276,13 @@
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -4949,21 +5297,21 @@
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -4971,14 +5319,14 @@
 
 #undef _nc_trim_sgr0
 char	*_nc_trim_sgr0(
-		TERMTYPE *tp)
+		TERMTYPE2 *tp)
 		{ return(*(char **)0); }
 
 /* ./unctrl.c */
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -4991,7 +5339,7 @@
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -5002,13 +5350,13 @@
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viswbuf2
 const char *_nc_viswbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const wchar_t *buf)
 		{ return(*(const char **)0); }
 
@@ -5019,7 +5367,7 @@
 
 #undef _nc_viswbufn
 const char *_nc_viswbufn(
-		const wchar_t *buf, 
+		const wchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -5030,14 +5378,14 @@
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const cchar_t *buf, 
+		int	bufnum,
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const cchar_t *buf, 
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -5045,7 +5393,7 @@
 
 #undef _nc_init_entry
 void	_nc_init_entry(
-		TERMTYPE *const tp)
+		ENTRY	*const tp)
 		{ /* void */ }
 
 #undef _nc_copy_entry
@@ -5055,34 +5403,34 @@
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		TERMTYPE *const to, 
-		TERMTYPE *const from)
+		ENTRY	*const target,
+		ENTRY	*const source)
 		{ /* void */ }
 
 /* ./tinfo/captoinfo.c */
 
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -5090,8 +5438,8 @@
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -5099,39 +5447,31 @@
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE *p1, 
+		TERMTYPE2 *p1,
 		NCURSES_BOOL p2);
-#undef _nc_check_termtype
-void	(*_nc_check_termtype)(
-		TERMTYPE *p1);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
-#undef _nc_resolve_uses
-int	_nc_resolve_uses(
-		NCURSES_BOOL fullresolve)
-		{ return(*(int *)0); }
-
 /* ./tinfo/comp_scan.c */
 
 #undef _nc_syntax
@@ -5153,7 +5493,7 @@
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -5164,8 +5504,8 @@
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -5182,22 +5522,17 @@
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		struct entry *entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
-typedef struct {
-    const char from[3];
-    const char to[6];
-} assoc;
-
 /* ./tinfo/write_entry.c */
 
 #undef _nc_set_writedir
@@ -5207,9 +5542,17 @@
 
 #undef _nc_write_entry
 void	_nc_write_entry(
-		TERMTYPE *const tp)
+		TERMTYPE2 *const tp)
 		{ /* void */ }
 
+#undef _nc_write_object
+int	_nc_write_object(
+		TERMTYPE2 *tp,
+		char	*buffer,
+		unsigned *offset,
+		unsigned limit)
+		{ return(*(int *)0); }
+
 #undef _nc_tic_written
 int	_nc_tic_written(void)
 		{ return(*(int *)0); }
@@ -5218,14 +5561,14 @@
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -5239,7 +5582,7 @@
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -5252,14 +5595,14 @@
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -5267,14 +5610,14 @@
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/ncurses/llib-lncursesw b/ncurses/llib-lncursesw
index 217ae1b..dbf535d 100644
--- a/ncurses/llib-lncursesw
+++ b/ncurses/llib-lncursesw
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2001-2013,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2001-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -69,7 +70,7 @@
 
 #undef _nc_make_oldhash_sp
 void	_nc_make_oldhash_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	i)
 		{ /* void */ }
 
@@ -80,16 +81,16 @@
 
 #undef _nc_scroll_oldhash_sp
 void	_nc_scroll_oldhash_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
 #undef _nc_scroll_oldhash
 void	_nc_scroll_oldhash(
-		int	n, 
-		int	top, 
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
@@ -97,31 +98,31 @@
 
 #undef _nc_render
 cchar_t	_nc_render(
-		WINDOW	*win, 
+		WINDOW	*win,
 		cchar_t	ch)
 		{ return(*(cchar_t *)0); }
 
 #undef _nc_build_wch
 int	_nc_build_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		cchar_t	*ch)
 		{ return(*(int *)0); }
 
 #undef _nc_waddch_nosync
 int	_nc_waddch_nosync(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t c)
 		{ return(*(int *)0); }
 
 #undef waddch
 int	waddch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
 #undef wechochar
 int	wechochar(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -129,15 +130,15 @@
 
 #undef waddnstr
 int	waddnstr(
-		WINDOW	*win, 
-		const char *astr, 
+		WINDOW	*win,
+		const char *astr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef waddchnstr
 int	waddchnstr(
-		WINDOW	*win, 
-		const chtype *astr, 
+		WINDOW	*win,
+		const chtype *astr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -148,15 +149,15 @@
 
 #undef wadd_wchnstr
 int	wadd_wchnstr(
-		WINDOW	*win, 
-		const cchar_t *astr, 
+		WINDOW	*win,
+		const cchar_t *astr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef waddnwstr
 int	waddnwstr(
-		WINDOW	*win, 
-		const wchar_t *str, 
+		WINDOW	*win,
+		const wchar_t *str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -175,25 +176,25 @@
 
 #undef wbkgrndset
 void	wbkgrndset(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *ch)
 		{ /* void */ }
 
 #undef wbkgdset
 void	wbkgdset(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ /* void */ }
 
 #undef wbkgrnd
 int	wbkgrnd(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *ch)
 		{ return(*(int *)0); }
 
 #undef wbkgd
 int	wbkgd(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
@@ -201,14 +202,14 @@
 
 #undef wborder
 int	wborder(
-		WINDOW	*win, 
-		chtype	ls, 
-		chtype	rs, 
-		chtype	ts, 
-		chtype	bs, 
-		chtype	tl, 
-		chtype	tr, 
-		chtype	bl, 
+		WINDOW	*win,
+		chtype	ls,
+		chtype	rs,
+		chtype	ts,
+		chtype	bs,
+		chtype	tl,
+		chtype	tr,
+		chtype	bl,
 		chtype	br)
 		{ return(*(int *)0); }
 
@@ -216,10 +217,10 @@
 
 #undef wchgat
 int	wchgat(
-		WINDOW	*win, 
-		int	n, 
-		attr_t	attr, 
-		short	color, 
+		WINDOW	*win,
+		int	n,
+		attr_t	attr,
+		short	pair_arg,
 		const void *opts)
 		{ return(*(int *)0); }
 
@@ -234,7 +235,7 @@
 
 #undef clearok
 int	clearok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -277,35 +278,64 @@
 int	start_color(void)
 		{ return(*(int *)0); }
 
+#undef _nc_change_pair
+void	_nc_change_pair(
+		SCREEN	*sp,
+		int	pair)
+		{ /* void */ }
+
+#undef _nc_reserve_pairs
+void	_nc_reserve_pairs(
+		SCREEN	*sp,
+		int	want)
+		{ /* void */ }
+
+#undef _nc_init_pair
+int	_nc_init_pair(
+		SCREEN	*sp,
+		int	pair,
+		int	f,
+		int	b)
+		{ return(*(int *)0); }
+
 #undef init_pair_sp
 int	init_pair_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	f, 
+		SCREEN	*sp,
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_pair
 int	init_pair(
-		short	pair, 
-		short	f, 
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
+#undef _nc_init_color
+int	_nc_init_color(
+		SCREEN	*sp,
+		int	color,
+		int	r,
+		int	g,
+		int	b)
+		{ return(*(int *)0); }
+
 #undef init_color_sp
 int	init_color_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	r, 
-		short	g, 
+		SCREEN	*sp,
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_color
 int	init_color(
-		short	color, 
-		short	r, 
-		short	g, 
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
@@ -329,59 +359,140 @@
 
 #undef color_content_sp
 int	color_content_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	*r, 
-		short	*g, 
+		SCREEN	*sp,
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef color_content
 int	color_content(
-		short	color, 
-		short	*r, 
-		short	*g, 
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
+#undef _nc_pair_content
+int	_nc_pair_content(
+		SCREEN	*sp,
+		int	pair,
+		int	*f,
+		int	*b)
+		{ return(*(int *)0); }
+
 #undef pair_content_sp
 int	pair_content_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	*f, 
+		SCREEN	*sp,
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef pair_content
 int	pair_content(
-		short	pair, 
-		short	*f, 
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef _nc_do_color_sp
 void	_nc_do_color_sp(
-		SCREEN	*sp, 
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		SCREEN	*sp,
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC_sp outc)
 		{ /* void */ }
 
 #undef _nc_do_color
 void	_nc_do_color(
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC outc)
 		{ /* void */ }
 
+#undef init_extended_pair_sp
+int	init_extended_pair_sp(
+		SCREEN	*sp,
+		int	pair,
+		int	f,
+		int	b)
+		{ return(*(int *)0); }
+
+#undef init_extended_color_sp
+int	init_extended_color_sp(
+		SCREEN	*sp,
+		int	color,
+		int	r,
+		int	g,
+		int	b)
+		{ return(*(int *)0); }
+
+#undef extended_color_content_sp
+int	extended_color_content_sp(
+		SCREEN	*sp,
+		int	color,
+		int	*r,
+		int	*g,
+		int	*b)
+		{ return(*(int *)0); }
+
+#undef extended_pair_content_sp
+int	extended_pair_content_sp(
+		SCREEN	*sp,
+		int	pair,
+		int	*f,
+		int	*b)
+		{ return(*(int *)0); }
+
+#undef reset_color_pairs_sp
+void	reset_color_pairs_sp(
+		SCREEN	*sp)
+		{ /* void */ }
+
+#undef init_extended_pair
+int	init_extended_pair(
+		int	pair,
+		int	f,
+		int	b)
+		{ return(*(int *)0); }
+
+#undef init_extended_color
+int	init_extended_color(
+		int	color,
+		int	r,
+		int	g,
+		int	b)
+		{ return(*(int *)0); }
+
+#undef extended_color_content
+int	extended_color_content(
+		int	color,
+		int	*r,
+		int	*g,
+		int	*b)
+		{ return(*(int *)0); }
+
+#undef extended_pair_content
+int	extended_pair_content(
+		int	pair,
+		int	*f,
+		int	*b)
+		{ return(*(int *)0); }
+
+#undef reset_color_pairs
+void	reset_color_pairs(void)
+		{ /* void */ }
+
 /* ./base/lib_colorset.c */
 
 #undef wcolor_set
 int	wcolor_set(
-		WINDOW	*win, 
-		short	color_pair_number, 
+		WINDOW	*win,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -451,1316 +562,1302 @@
 /* ./lib_gen.c */
 
 #undef addch
-int	(addch)(
+int	addch(
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef addchnstr
-int	(addchnstr)(
-		const chtype *a1, 
+int	addchnstr(
+		const chtype *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef addchstr
-int	(addchstr)(
+int	addchstr(
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef addnstr
-int	(addnstr)(
-		const char *a1, 
+int	addnstr(
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef addstr
-int	(addstr)(
+int	addstr(
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef attroff
-int	(attroff)(
+int	attroff(
 		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attron
-int	(attron)(
+int	attron(
 		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attrset
-int	(attrset)(
+int	attrset(
 		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attr_get
-int	(attr_get)(
-		attr_t	*a1, 
-		short	*a2, 
+int	attr_get(
+		attr_t	*a1,
+		short	*a2,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_off
-int	(attr_off)(
-		attr_t	a1, 
+int	attr_off(
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_on
-int	(attr_on)(
-		attr_t	a1, 
+int	attr_on(
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_set
-int	(attr_set)(
-		attr_t	a1, 
-		short	a2, 
+int	attr_set(
+		attr_t	a1,
+		short	a2,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef bkgd
-int	(bkgd)(
+int	bkgd(
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef bkgdset
-void	(bkgdset)(
+void	bkgdset(
 		chtype	z)
 		{ /* void */ }
 
 #undef border
-int	(border)(
-		chtype	a1, 
-		chtype	a2, 
-		chtype	a3, 
-		chtype	a4, 
-		chtype	a5, 
-		chtype	a6, 
-		chtype	a7, 
+int	border(
+		chtype	a1,
+		chtype	a2,
+		chtype	a3,
+		chtype	a4,
+		chtype	a5,
+		chtype	a6,
+		chtype	a7,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef box
-int	(box)(
-		WINDOW	*a1, 
-		chtype	a2, 
+int	box(
+		WINDOW	*a1,
+		chtype	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef chgat
-int	(chgat)(
-		int	a1, 
-		attr_t	a2, 
-		short	a3, 
+int	chgat(
+		int	a1,
+		attr_t	a2,
+		short	a3,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef clear
-int	(clear)(void)
+int	clear(void)
 		{ return(*(int *)0); }
 
 #undef clrtobot
-int	(clrtobot)(void)
+int	clrtobot(void)
 		{ return(*(int *)0); }
 
 #undef clrtoeol
-int	(clrtoeol)(void)
+int	clrtoeol(void)
 		{ return(*(int *)0); }
 
 #undef color_set
-int	(color_set)(
-		short	a1, 
+int	color_set(
+		short	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef COLOR_PAIR
-int	(COLOR_PAIR)(
+int	COLOR_PAIR(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef delch
-int	(delch)(void)
+int	delch(void)
 		{ return(*(int *)0); }
 
 #undef deleteln
-int	(deleteln)(void)
+int	deleteln(void)
 		{ return(*(int *)0); }
 
 #undef echochar
-int	(echochar)(
+int	echochar(
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef erase
-int	(erase)(void)
+int	erase(void)
 		{ return(*(int *)0); }
 
 #undef getbkgd
-chtype	(getbkgd)(
+chtype	getbkgd(
 		WINDOW	*z)
 		{ return(*(chtype *)0); }
 
 #undef getch
-int	(getch)(void)
+int	getch(void)
 		{ return(*(int *)0); }
 
 #undef getnstr
-int	(getnstr)(
-		char	*a1, 
+int	getnstr(
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef getstr
-int	(getstr)(
+int	getstr(
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef hline
-int	(hline)(
-		chtype	a1, 
+int	hline(
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef inch
-chtype	(inch)(void)
+chtype	inch(void)
 		{ return(*(chtype *)0); }
 
 #undef inchnstr
-int	(inchnstr)(
-		chtype	*a1, 
+int	inchnstr(
+		chtype	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef inchstr
-int	(inchstr)(
+int	inchstr(
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef innstr
-int	(innstr)(
-		char	*a1, 
+int	innstr(
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef insch
-int	(insch)(
+int	insch(
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef insdelln
-int	(insdelln)(
+int	insdelln(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef insertln
-int	(insertln)(void)
+int	insertln(void)
 		{ return(*(int *)0); }
 
 #undef insnstr
-int	(insnstr)(
-		const char *a1, 
+int	insnstr(
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef insstr
-int	(insstr)(
+int	insstr(
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef instr
-int	(instr)(
+int	instr(
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef move
-int	(move)(
-		int	a1, 
+int	move(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddch
-int	(mvaddch)(
-		int	a1, 
-		int	a2, 
+int	mvaddch(
+		int	a1,
+		int	a2,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvaddchnstr
-int	(mvaddchnstr)(
-		int	a1, 
-		int	a2, 
-		const chtype *a3, 
+int	mvaddchnstr(
+		int	a1,
+		int	a2,
+		const chtype *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddchstr
-int	(mvaddchstr)(
-		int	a1, 
-		int	a2, 
+int	mvaddchstr(
+		int	a1,
+		int	a2,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvaddnstr
-int	(mvaddnstr)(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+int	mvaddnstr(
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddstr
-int	(mvaddstr)(
-		int	a1, 
-		int	a2, 
+int	mvaddstr(
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvchgat
-int	(mvchgat)(
-		int	a1, 
-		int	a2, 
-		int	a3, 
-		attr_t	a4, 
-		short	a5, 
+int	mvchgat(
+		int	a1,
+		int	a2,
+		int	a3,
+		attr_t	a4,
+		short	a5,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvdelch
-int	(mvdelch)(
-		int	a1, 
+int	mvdelch(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetch
-int	(mvgetch)(
-		int	a1, 
+int	mvgetch(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetnstr
-int	(mvgetnstr)(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+int	mvgetnstr(
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetstr
-int	(mvgetstr)(
-		int	a1, 
-		int	a2, 
+int	mvgetstr(
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvhline
-int	(mvhline)(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+int	mvhline(
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinch
-chtype	(mvinch)(
-		int	a1, 
+chtype	mvinch(
+		int	a1,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvinchnstr
-int	(mvinchnstr)(
-		int	a1, 
-		int	a2, 
-		chtype	*a3, 
+int	mvinchnstr(
+		int	a1,
+		int	a2,
+		chtype	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinchstr
-int	(mvinchstr)(
-		int	a1, 
-		int	a2, 
+int	mvinchstr(
+		int	a1,
+		int	a2,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvinnstr
-int	(mvinnstr)(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+int	mvinnstr(
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsch
-int	(mvinsch)(
-		int	a1, 
-		int	a2, 
+int	mvinsch(
+		int	a1,
+		int	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvinsnstr
-int	(mvinsnstr)(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+int	mvinsnstr(
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsstr
-int	(mvinsstr)(
-		int	a1, 
-		int	a2, 
+int	mvinsstr(
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvinstr
-int	(mvinstr)(
-		int	a1, 
-		int	a2, 
+int	mvinstr(
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvvline
-int	(mvvline)(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+int	mvvline(
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddch
-int	(mvwaddch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwaddch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchnstr
-int	(mvwaddchnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const chtype *a4, 
+int	mvwaddchnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const chtype *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchstr
-int	(mvwaddchstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwaddchstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvwaddnstr
-int	(mvwaddnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+int	mvwaddnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddstr
-int	(mvwaddstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwaddstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwchgat
-int	(mvwchgat)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		int	a4, 
-		attr_t	a5, 
-		short	a6, 
+int	mvwchgat(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		int	a4,
+		attr_t	a5,
+		short	a6,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvwdelch
-int	(mvwdelch)(
-		WINDOW	*a1, 
-		int	a2, 
+int	mvwdelch(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetch
-int	(mvwgetch)(
-		WINDOW	*a1, 
-		int	a2, 
+int	mvwgetch(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetnstr
-int	(mvwgetnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+int	mvwgetnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetstr
-int	(mvwgetstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwgetstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwhline
-int	(mvwhline)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+int	mvwhline(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinch
-chtype	(mvwinch)(
-		WINDOW	*a1, 
-		int	a2, 
+chtype	mvwinch(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvwinchnstr
-int	(mvwinchnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	*a4, 
+int	mvwinchnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinchstr
-int	(mvwinchstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinchstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvwinnstr
-int	(mvwinnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+int	mvwinnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsch
-int	(mvwinsch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinsch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsnstr
-int	(mvwinsnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+int	mvwinsnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsstr
-int	(mvwinsstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinsstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwinstr
-int	(mvwinstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwvline
-int	(mvwvline)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+int	mvwvline(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef PAIR_NUMBER
-int	(PAIR_NUMBER)(
+int	PAIR_NUMBER(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef redrawwin
-int	(redrawwin)(
+int	redrawwin(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef refresh
-int	(refresh)(void)
+int	refresh(void)
 		{ return(*(int *)0); }
 
 #undef scrl
-int	(scrl)(
+int	scrl(
 		int	z)
 		{ return(*(int *)0); }
 
 #undef scroll
-int	(scroll)(
+int	scroll(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef setscrreg
-int	(setscrreg)(
-		int	a1, 
+int	setscrreg(
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef slk_attr_off
-int	(slk_attr_off)(
-		const attr_t a1, 
+int	slk_attr_off(
+		const attr_t a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef slk_attr_on
-int	(slk_attr_on)(
-		attr_t	a1, 
+int	slk_attr_on(
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef standout
-int	(standout)(void)
+int	standout(void)
 		{ return(*(int *)0); }
 
 #undef standend
-int	(standend)(void)
+int	standend(void)
 		{ return(*(int *)0); }
 
 #undef timeout
-void	(timeout)(
+void	timeout(
 		int	z)
 		{ /* void */ }
 
 #undef touchline
-int	(touchline)(
-		WINDOW	*a1, 
-		int	a2, 
+int	touchline(
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef touchwin
-int	(touchwin)(
+int	touchwin(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef untouchwin
-int	(untouchwin)(
+int	untouchwin(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef vline
-int	(vline)(
-		chtype	a1, 
+int	vline(
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
-#undef vw_printw
-int	(vw_printw)(
-		WINDOW	*a1, 
-		const char *a2, 
-		va_list	z)
-		{ return(*(int *)0); }
-
-#undef vw_scanw
-int	(vw_scanw)(
-		WINDOW	*a1, 
-		const char *a2, 
-		va_list	z)
-		{ return(*(int *)0); }
-
 #undef waddchstr
-int	(waddchstr)(
-		WINDOW	*a1, 
+int	waddchstr(
+		WINDOW	*a1,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef waddstr
-int	(waddstr)(
-		WINDOW	*a1, 
+int	waddstr(
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef wattron
-int	(wattron)(
-		WINDOW	*a1, 
+int	wattron(
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattroff
-int	(wattroff)(
-		WINDOW	*a1, 
+int	wattroff(
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattrset
-int	(wattrset)(
-		WINDOW	*a1, 
+int	wattrset(
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattr_get
-int	(wattr_get)(
-		WINDOW	*a1, 
-		attr_t	*a2, 
-		short	*a3, 
+int	wattr_get(
+		WINDOW	*a1,
+		attr_t	*a2,
+		short	*a3,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef wattr_set
-int	(wattr_set)(
-		WINDOW	*a1, 
-		attr_t	a2, 
-		short	a3, 
+int	wattr_set(
+		WINDOW	*a1,
+		attr_t	a2,
+		short	a3,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef wdeleteln
-int	(wdeleteln)(
+int	wdeleteln(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef wgetstr
-int	(wgetstr)(
-		WINDOW	*a1, 
+int	wgetstr(
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef winchstr
-int	(winchstr)(
-		WINDOW	*a1, 
+int	winchstr(
+		WINDOW	*a1,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef winsertln
-int	(winsertln)(
+int	winsertln(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef winsstr
-int	(winsstr)(
-		WINDOW	*a1, 
+int	winsstr(
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef winstr
-int	(winstr)(
-		WINDOW	*a1, 
+int	winstr(
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef wstandout
-int	(wstandout)(
+int	wstandout(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef wstandend
-int	(wstandend)(
+int	wstandend(
 		WINDOW	*z)
 		{ return(*(int *)0); }
 
 #undef getattrs
-int	(getattrs)(
+int	getattrs(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getcurx
-int	(getcurx)(
+int	getcurx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getcury
-int	(getcury)(
+int	getcury(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getbegx
-int	(getbegx)(
+int	getbegx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getbegy
-int	(getbegy)(
+int	getbegy(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getmaxx
-int	(getmaxx)(
+int	getmaxx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getmaxy
-int	(getmaxy)(
+int	getmaxy(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getparx
-int	(getparx)(
+int	getparx(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef getpary
-int	(getpary)(
+int	getpary(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef wgetparent
-WINDOW	*(wgetparent)(
+WINDOW	*wgetparent(
 		const WINDOW *z)
 		{ return(*(WINDOW **)0); }
 
 #undef is_cleared
-NCURSES_BOOL (is_cleared)(
+NCURSES_BOOL is_cleared(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_idcok
-NCURSES_BOOL (is_idcok)(
+NCURSES_BOOL is_idcok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_idlok
-NCURSES_BOOL (is_idlok)(
+NCURSES_BOOL is_idlok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_immedok
-NCURSES_BOOL (is_immedok)(
+NCURSES_BOOL is_immedok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_keypad
-NCURSES_BOOL (is_keypad)(
+NCURSES_BOOL is_keypad(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_leaveok
-NCURSES_BOOL (is_leaveok)(
+NCURSES_BOOL is_leaveok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_nodelay
-NCURSES_BOOL (is_nodelay)(
+NCURSES_BOOL is_nodelay(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_notimeout
-NCURSES_BOOL (is_notimeout)(
+NCURSES_BOOL is_notimeout(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_pad
-NCURSES_BOOL (is_pad)(
+NCURSES_BOOL is_pad(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_scrollok
-NCURSES_BOOL (is_scrollok)(
+NCURSES_BOOL is_scrollok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_subwin
-NCURSES_BOOL (is_subwin)(
+NCURSES_BOOL is_subwin(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_syncok
-NCURSES_BOOL (is_syncok)(
+NCURSES_BOOL is_syncok(
 		const WINDOW *z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef wgetdelay
-int	(wgetdelay)(
+int	wgetdelay(
 		const WINDOW *z)
 		{ return(*(int *)0); }
 
 #undef wgetscrreg
-int	(wgetscrreg)(
-		const WINDOW *a1, 
-		int	*a2, 
+int	wgetscrreg(
+		const WINDOW *a1,
+		int	*a2,
 		int	*z)
 		{ return(*(int *)0); }
 
 #undef add_wch
-int	(add_wch)(
+int	add_wch(
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef add_wchnstr
-int	(add_wchnstr)(
-		const cchar_t *a1, 
+int	add_wchnstr(
+		const cchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef add_wchstr
-int	(add_wchstr)(
+int	add_wchstr(
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef addnwstr
-int	(addnwstr)(
-		const wchar_t *a1, 
+int	addnwstr(
+		const wchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef addwstr
-int	(addwstr)(
+int	addwstr(
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef bkgrnd
-int	(bkgrnd)(
+int	bkgrnd(
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef bkgrndset
-void	(bkgrndset)(
+void	bkgrndset(
 		const cchar_t *z)
 		{ /* void */ }
 
 #undef border_set
-int	(border_set)(
-		const cchar_t *a1, 
-		const cchar_t *a2, 
-		const cchar_t *a3, 
-		const cchar_t *a4, 
-		const cchar_t *a5, 
-		const cchar_t *a6, 
-		const cchar_t *a7, 
+int	border_set(
+		const cchar_t *a1,
+		const cchar_t *a2,
+		const cchar_t *a3,
+		const cchar_t *a4,
+		const cchar_t *a5,
+		const cchar_t *a6,
+		const cchar_t *a7,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef box_set
-int	(box_set)(
-		WINDOW	*a1, 
-		const cchar_t *a2, 
+int	box_set(
+		WINDOW	*a1,
+		const cchar_t *a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef echo_wchar
-int	(echo_wchar)(
+int	echo_wchar(
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef get_wch
-int	(get_wch)(
+int	get_wch(
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef get_wstr
-int	(get_wstr)(
+int	get_wstr(
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef getbkgrnd
-int	(getbkgrnd)(
+int	getbkgrnd(
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef getn_wstr
-int	(getn_wstr)(
-		wint_t	*a1, 
+int	getn_wstr(
+		wint_t	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef hline_set
-int	(hline_set)(
-		const cchar_t *a1, 
+int	hline_set(
+		const cchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef in_wch
-int	(in_wch)(
+int	in_wch(
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef in_wchnstr
-int	(in_wchnstr)(
-		cchar_t	*a1, 
+int	in_wchnstr(
+		cchar_t	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef in_wchstr
-int	(in_wchstr)(
+int	in_wchstr(
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef innwstr
-int	(innwstr)(
-		wchar_t	*a1, 
+int	innwstr(
+		wchar_t	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef ins_nwstr
-int	(ins_nwstr)(
-		const wchar_t *a1, 
+int	ins_nwstr(
+		const wchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef ins_wch
-int	(ins_wch)(
+int	ins_wch(
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef ins_wstr
-int	(ins_wstr)(
+int	ins_wstr(
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef inwstr
-int	(inwstr)(
+int	inwstr(
 		wchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvadd_wch
-int	(mvadd_wch)(
-		int	a1, 
-		int	a2, 
+int	mvadd_wch(
+		int	a1,
+		int	a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvadd_wchnstr
-int	(mvadd_wchnstr)(
-		int	a1, 
-		int	a2, 
-		const cchar_t *a3, 
+int	mvadd_wchnstr(
+		int	a1,
+		int	a2,
+		const cchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvadd_wchstr
-int	(mvadd_wchstr)(
-		int	a1, 
-		int	a2, 
+int	mvadd_wchstr(
+		int	a1,
+		int	a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvaddnwstr
-int	(mvaddnwstr)(
-		int	a1, 
-		int	a2, 
-		const wchar_t *a3, 
+int	mvaddnwstr(
+		int	a1,
+		int	a2,
+		const wchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddwstr
-int	(mvaddwstr)(
-		int	a1, 
-		int	a2, 
+int	mvaddwstr(
+		int	a1,
+		int	a2,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvget_wch
-int	(mvget_wch)(
-		int	a1, 
-		int	a2, 
+int	mvget_wch(
+		int	a1,
+		int	a2,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvget_wstr
-int	(mvget_wstr)(
-		int	a1, 
-		int	a2, 
+int	mvget_wstr(
+		int	a1,
+		int	a2,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvgetn_wstr
-int	(mvgetn_wstr)(
-		int	a1, 
-		int	a2, 
-		wint_t	*a3, 
+int	mvgetn_wstr(
+		int	a1,
+		int	a2,
+		wint_t	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvhline_set
-int	(mvhline_set)(
-		int	a1, 
-		int	a2, 
-		const cchar_t *a3, 
+int	mvhline_set(
+		int	a1,
+		int	a2,
+		const cchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvin_wch
-int	(mvin_wch)(
-		int	a1, 
-		int	a2, 
+int	mvin_wch(
+		int	a1,
+		int	a2,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvin_wchnstr
-int	(mvin_wchnstr)(
-		int	a1, 
-		int	a2, 
-		cchar_t	*a3, 
+int	mvin_wchnstr(
+		int	a1,
+		int	a2,
+		cchar_t	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvin_wchstr
-int	(mvin_wchstr)(
-		int	a1, 
-		int	a2, 
+int	mvin_wchstr(
+		int	a1,
+		int	a2,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvinnwstr
-int	(mvinnwstr)(
-		int	a1, 
-		int	a2, 
-		wchar_t	*a3, 
+int	mvinnwstr(
+		int	a1,
+		int	a2,
+		wchar_t	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvins_nwstr
-int	(mvins_nwstr)(
-		int	a1, 
-		int	a2, 
-		const wchar_t *a3, 
+int	mvins_nwstr(
+		int	a1,
+		int	a2,
+		const wchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvins_wch
-int	(mvins_wch)(
-		int	a1, 
-		int	a2, 
+int	mvins_wch(
+		int	a1,
+		int	a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvins_wstr
-int	(mvins_wstr)(
-		int	a1, 
-		int	a2, 
+int	mvins_wstr(
+		int	a1,
+		int	a2,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvinwstr
-int	(mvinwstr)(
-		int	a1, 
-		int	a2, 
+int	mvinwstr(
+		int	a1,
+		int	a2,
 		wchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvvline_set
-int	(mvvline_set)(
-		int	a1, 
-		int	a2, 
-		const cchar_t *a3, 
+int	mvvline_set(
+		int	a1,
+		int	a2,
+		const cchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwadd_wch
-int	(mvwadd_wch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwadd_wch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwadd_wchnstr
-int	(mvwadd_wchnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const cchar_t *a4, 
+int	mvwadd_wchnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const cchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwadd_wchstr
-int	(mvwadd_wchstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwadd_wchstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwaddnwstr
-int	(mvwaddnwstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const wchar_t *a4, 
+int	mvwaddnwstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const wchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddwstr
-int	(mvwaddwstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwaddwstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwget_wch
-int	(mvwget_wch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwget_wch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwget_wstr
-int	(mvwget_wstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwget_wstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwgetn_wstr
-int	(mvwgetn_wstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		wint_t	*a4, 
+int	mvwgetn_wstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		wint_t	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwhline_set
-int	(mvwhline_set)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const cchar_t *a4, 
+int	mvwhline_set(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const cchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwin_wch
-int	(mvwin_wch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwin_wch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwin_wchnstr
-int	(mvwin_wchnstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		cchar_t	*a4, 
+int	mvwin_wchnstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		cchar_t	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwin_wchstr
-int	(mvwin_wchstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwin_wchstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwinnwstr
-int	(mvwinnwstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		wchar_t	*a4, 
+int	mvwinnwstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		wchar_t	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwins_nwstr
-int	(mvwins_nwstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const wchar_t *a4, 
+int	mvwins_nwstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const wchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwins_wch
-int	(mvwins_wch)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwins_wch(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwins_wstr
-int	(mvwins_wstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwins_wstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwinwstr
-int	(mvwinwstr)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+int	mvwinwstr(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		wchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwvline_set
-int	(mvwvline_set)(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const cchar_t *a4, 
+int	mvwvline_set(
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const cchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef vline_set
-int	(vline_set)(
-		const cchar_t *a1, 
+int	vline_set(
+		const cchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wadd_wchstr
-int	(wadd_wchstr)(
-		WINDOW	*a1, 
+int	wadd_wchstr(
+		WINDOW	*a1,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef waddwstr
-int	(waddwstr)(
-		WINDOW	*a1, 
+int	waddwstr(
+		WINDOW	*a1,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef wget_wstr
-int	(wget_wstr)(
-		WINDOW	*a1, 
+int	wget_wstr(
+		WINDOW	*a1,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef wgetbkgrnd
-int	(wgetbkgrnd)(
-		WINDOW	*a1, 
+int	wgetbkgrnd(
+		WINDOW	*a1,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef win_wchstr
-int	(win_wchstr)(
-		WINDOW	*a1, 
+int	win_wchstr(
+		WINDOW	*a1,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef wins_wstr
-int	(wins_wstr)(
-		WINDOW	*a1, 
+int	wins_wstr(
+		WINDOW	*a1,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mouse_trafo
-NCURSES_BOOL (mouse_trafo)(
-		int	*a1, 
-		int	*a2, 
+NCURSES_BOOL mouse_trafo(
+		int	*a1,
+		int	*a2,
 		NCURSES_BOOL z)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1771,7 +1868,7 @@
 
 #undef set_escdelay_sp
 int	set_escdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -1791,8 +1888,8 @@
 
 #undef _nc_wgetch
 int	_nc_wgetch(
-		WINDOW	*win, 
-		int	*result, 
+		WINDOW	*win,
+		int	*result,
 		int	use_meta)
 		{ return(*(int *)0); }
 
@@ -1805,8 +1902,8 @@
 
 #undef wgetnstr
 int	wgetnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	maxlen)
 		{ return(*(int *)0); }
 
@@ -1814,8 +1911,8 @@
 
 #undef whline
 int	whline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1823,7 +1920,7 @@
 
 #undef immedok
 void	immedok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
@@ -1831,8 +1928,8 @@
 
 #undef winchnstr
 int	winchnstr(
-		WINDOW	*win, 
-		chtype	*str, 
+		WINDOW	*win,
+		chtype	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1846,14 +1943,14 @@
 
 #undef _nc_insert_ch
 int	_nc_insert_ch(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
 #undef winsch
 int	winsch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	c)
 		{ return(*(int *)0); }
 
@@ -1861,7 +1958,7 @@
 
 #undef winsdelln
 int	winsdelln(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1869,8 +1966,8 @@
 
 #undef winsnstr
 int	winsnstr(
-		WINDOW	*win, 
-		const char *s, 
+		WINDOW	*win,
+		const char *s,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1878,8 +1975,8 @@
 
 #undef winnstr
 int	winnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1898,22 +1995,15 @@
 
 #undef leaveok
 int	leaveok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 /* ./base/lib_mouse.c */
 
-typedef struct {
-    int nerror; 
-    int nparam; 
-    int params[9];
-    int final; 
-} SGR_DATA;
-
 #undef getmouse_sp
 int	getmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -1924,7 +2014,7 @@
 
 #undef ungetmouse_sp
 int	ungetmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -1935,27 +2025,27 @@
 
 #undef mousemask_sp
 mmask_t	mousemask_sp(
-		SCREEN	*sp, 
-		mmask_t	newmask, 
+		SCREEN	*sp,
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef mousemask
 mmask_t	mousemask(
-		mmask_t	newmask, 
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef wenclose
 NCURSES_BOOL wenclose(
-		const WINDOW *win, 
-		int	y, 
+		const WINDOW *win,
+		int	y,
 		int	x)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef mouseinterval_sp
 int	mouseinterval_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	maxclick)
 		{ return(*(int *)0); }
 
@@ -1980,9 +2070,9 @@
 
 #undef wmouse_trafo
 NCURSES_BOOL wmouse_trafo(
-		const WINDOW *win, 
-		int	*pY, 
-		int	*pX, 
+		const WINDOW *win,
+		int	*pY,
+		int	*pX,
 		NCURSES_BOOL to_screen)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1990,8 +2080,8 @@
 
 #undef wmove
 int	wmove(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
@@ -1999,14 +2089,14 @@
 
 #undef _nc_msec_cost_sp
 int	_nc_msec_cost_sp(
-		SCREEN	*sp, 
-		const char *const cap, 
+		SCREEN	*sp,
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
 #undef _nc_msec_cost
 int	_nc_msec_cost(
-		const char *const cap, 
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
@@ -2039,35 +2129,35 @@
 
 #undef _nc_mvcur_sp
 int	_nc_mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef _nc_mvcur
 int	_nc_mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur_sp
 int	mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur
 int	mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
@@ -2078,8 +2168,8 @@
 
 #undef mvwin
 int	mvwin(
-		WINDOW	*win, 
-		int	by, 
+		WINDOW	*win,
+		int	by,
 		int	bx)
 		{ return(*(int *)0); }
 
@@ -2105,16 +2195,16 @@
 
 #undef newterm_sp
 SCREEN	*newterm_sp(
-		SCREEN	*sp, 
-		const char *name, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
 #undef newterm
 SCREEN	*newterm(
-		const char *name, 
-		FILE	*ofp, 
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
@@ -2127,46 +2217,46 @@
 
 #undef newwin_sp
 WINDOW	*newwin_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef newwin
 WINDOW	*newwin(
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef derwin
 WINDOW	*derwin(
-		WINDOW	*orig, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		WINDOW	*orig,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef subwin
 WINDOW	*subwin(
-		WINDOW	*w, 
-		int	l, 
-		int	c, 
-		int	y, 
+		WINDOW	*w,
+		int	l,
+		int	c,
+		int	y,
 		int	x)
 		{ return(*(WINDOW **)0); }
 
 #undef _nc_makenew_sp
 WINDOW	*_nc_makenew_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
-		int	begx, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
+		int	begx,
 		int	flags)
 		{ return(*(WINDOW **)0); }
 
@@ -2209,26 +2299,26 @@
 
 #undef overlay
 int	overlay(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef overwrite
 int	overwrite(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef copywin
 int	copywin(
-		const WINDOW *src, 
-		WINDOW	*dst, 
-		int	sminrow, 
-		int	smincol, 
-		int	dminrow, 
-		int	dmincol, 
-		int	dmaxrow, 
-		int	dmaxcol, 
+		const WINDOW *src,
+		WINDOW	*dst,
+		int	sminrow,
+		int	smincol,
+		int	dminrow,
+		int	dmincol,
+		int	dmaxrow,
+		int	dmaxcol,
 		int	over)
 		{ return(*(int *)0); }
 
@@ -2236,51 +2326,51 @@
 
 #undef newpad_sp
 WINDOW	*newpad_sp(
-		SCREEN	*sp, 
-		int	l, 
+		SCREEN	*sp,
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef newpad
 WINDOW	*newpad(
-		int	l, 
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef subpad
 WINDOW	*subpad(
-		WINDOW	*orig, 
-		int	l, 
-		int	c, 
-		int	begy, 
+		WINDOW	*orig,
+		int	l,
+		int	c,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef prefresh
 int	prefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pnoutrefresh
 int	pnoutrefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pechochar
 int	pechochar(
-		WINDOW	*pad, 
+		WINDOW	*pad,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -2288,38 +2378,45 @@
 
 #undef printw
 int	printw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wprintw
 int	wprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvprintw
 int	mvprintw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwprintw
 int	mvwprintw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef vwprintw
 int	vwprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
+		va_list	argp)
+		{ return(*(int *)0); }
+
+#undef vw_printw
+int	vw_printw(
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
@@ -2327,8 +2424,8 @@
 
 #undef wredrawln
 int	wredrawln(
-		WINDOW	*win, 
-		int	beg, 
+		WINDOW	*win,
+		int	beg,
 		int	num)
 		{ return(*(int *)0); }
 
@@ -2348,16 +2445,16 @@
 
 #undef restartterm_sp
 int	restartterm_sp(
-		SCREEN	*sp, 
-		const char *termp, 
-		int	filenum, 
+		SCREEN	*sp,
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
 #undef restartterm
 int	restartterm(
-		const char *termp, 
-		int	filenum, 
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -2365,68 +2462,53 @@
 
 #undef vwscanw
 int	vwscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
+		va_list	argp)
+		{ return(*(int *)0); }
+
+#undef vw_scanw
+int	vw_scanw(
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef scanw
 int	scanw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wscanw
 int	wscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvscanw
 int	mvscanw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwscanw
 int	mvwscanw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 /* ./base/lib_screen.c */
 
-typedef enum {
-    pINT 
-    ,pSHORT 
-    ,pBOOL 
-    ,pATTR 
-    ,pCHAR 
-    ,pSIZE 
-    ,pCCHAR 
-} PARAM_TYPE;
-
-typedef struct {
-    const char name[11];
-    attr_t attr;
-} SCR_ATTRS;
-
-typedef struct {
-    const char name[17];
-    PARAM_TYPE type;
-    size_t size;
-    size_t offset;
-} SCR_PARAMS;
-
 #undef getwin_sp
 WINDOW	*getwin_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		FILE	*filep)
 		{ return(*(WINDOW **)0); }
 
@@ -2437,13 +2519,13 @@
 
 #undef putwin
 int	putwin(
-		WINDOW	*win, 
+		WINDOW	*win,
 		FILE	*filep)
 		{ return(*(int *)0); }
 
 #undef scr_restore_sp
 int	scr_restore_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -2459,7 +2541,7 @@
 
 #undef scr_init_sp
 int	scr_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -2470,7 +2552,7 @@
 
 #undef scr_set_sp
 int	scr_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -2483,16 +2565,16 @@
 
 #undef _nc_scroll_window
 void	_nc_scroll_window(
-		WINDOW	*win, 
-		int const n, 
-		int const top, 
-		int const bottom, 
+		WINDOW	*win,
+		int const n,
+		int const top,
+		int const bottom,
 		cchar_t	blank)
 		{ /* void */ }
 
 #undef wscrl
 int	wscrl(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2500,7 +2582,7 @@
 
 #undef scrollok
 int	scrollok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -2508,8 +2590,8 @@
 
 #undef wsetscrreg
 int	wsetscrreg(
-		WINDOW	*win, 
-		int	top, 
+		WINDOW	*win,
+		int	top,
 		int	bottom)
 		{ return(*(int *)0); }
 
@@ -2527,54 +2609,54 @@
 
 #undef _nc_setupscreen_sp
 int	_nc_setupscreen_sp(
-		SCREEN	**spp, 
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		SCREEN	**spp,
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_setupscreen
 int	_nc_setupscreen(
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline_sp
 int	_nc_ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline
 int	_nc_ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline_sp
 int	ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline
 int	ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
@@ -2582,13 +2664,13 @@
 
 #undef _nc_format_slks
 int	_nc_format_slks(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	cols)
 		{ return(*(int *)0); }
 
 #undef _nc_slk_initialize
 int	_nc_slk_initialize(
-		WINDOW	*stwin, 
+		WINDOW	*stwin,
 		int	cols)
 		{ return(*(int *)0); }
 
@@ -2605,16 +2687,16 @@
 
 #undef slk_attr_set_sp
 int	slk_attr_set_sp(
-		SCREEN	*sp, 
-		const attr_t attr, 
-		short	color_pair_number, 
+		SCREEN	*sp,
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 #undef slk_attr_set
 int	slk_attr_set(
-		const attr_t attr, 
-		short	color_pair_number, 
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2622,7 +2704,7 @@
 
 #undef slk_attroff_sp
 int	slk_attroff_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2635,7 +2717,7 @@
 
 #undef slk_attron_sp
 int	slk_attron_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2648,7 +2730,7 @@
 
 #undef slk_attrset_sp
 int	slk_attrset_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2683,20 +2765,31 @@
 
 #undef slk_color_sp
 int	slk_color_sp(
-		SCREEN	*sp, 
-		short	color_pair_number)
+		SCREEN	*sp,
+		short	pair_arg)
 		{ return(*(int *)0); }
 
 #undef slk_color
 int	slk_color(
-		short	color_pair_number)
+		short	pair_arg)
+		{ return(*(int *)0); }
+
+#undef extended_slk_color_sp
+int	extended_slk_color_sp(
+		SCREEN	*sp,
+		int	pair_arg)
+		{ return(*(int *)0); }
+
+#undef extended_slk_color
+int	extended_slk_color(
+		int	pair_arg)
 		{ return(*(int *)0); }
 
 /* ./base/lib_slkinit.c */
 
 #undef slk_init_sp
 int	slk_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2709,7 +2802,7 @@
 
 #undef slk_label_sp
 char	*slk_label_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	n)
 		{ return(*(char **)0); }
 
@@ -2742,16 +2835,16 @@
 
 #undef slk_set_sp
 int	slk_set_sp(
-		SCREEN	*sp, 
-		int	i, 
-		const char *astr, 
+		SCREEN	*sp,
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
 #undef slk_set
 int	slk_set(
-		int	i, 
-		const char *astr, 
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2770,7 +2863,7 @@
 
 #undef is_linetouched
 NCURSES_BOOL is_linetouched(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	line)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -2781,9 +2874,9 @@
 
 #undef wtouchln
 int	wtouchln(
-		WINDOW	*win, 
-		int	y, 
-		int	n, 
+		WINDOW	*win,
+		int	y,
+		int	n,
 		int	changed)
 		{ return(*(int *)0); }
 
@@ -2791,7 +2884,7 @@
 
 #undef _tracedump
 void	_tracedump(
-		const char *name, 
+		const char *name,
 		WINDOW	*win)
 		{ /* void */ }
 
@@ -2799,19 +2892,19 @@
 
 #undef _nc_trace_mmask_t
 char	*_nc_trace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(char **)0); }
 
 #undef _nc_tracemouse
 char	*_nc_tracemouse(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT const *ep)
 		{ return(*(char **)0); }
 
 #undef _nc_retrace_mmask_t
 mmask_t	_nc_retrace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(mmask_t *)0); }
 
@@ -2836,7 +2929,7 @@
 
 #undef ungetch_sp
 int	ungetch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -2849,20 +2942,20 @@
 
 #undef vidputs_sp
 int	vidputs_sp(
-		SCREEN	*sp, 
-		chtype	newmode, 
+		SCREEN	*sp,
+		chtype	newmode,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef vidputs
 int	vidputs(
-		chtype	newmode, 
+		chtype	newmode,
 		NCURSES_OUTC outc)
 		{ return(*(int *)0); }
 
 #undef vidattr_sp
 int	vidattr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	newmode)
 		{ return(*(int *)0); }
 
@@ -2884,8 +2977,8 @@
 
 #undef wvline
 int	wvline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2893,8 +2986,8 @@
 
 #undef wattr_off
 int	wattr_off(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2902,8 +2995,8 @@
 
 #undef wattr_on
 int	wattr_on(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2923,14 +3016,14 @@
 
 #undef mvderwin
 int	mvderwin(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
 #undef syncok
 int	syncok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL bf)
 		{ return(*(int *)0); }
 
@@ -2969,14 +3062,14 @@
 
 #undef _nc_printf_string_sp
 char	*_nc_printf_string_sp(
-		SCREEN	*sp, 
-		const char *fmt, 
+		SCREEN	*sp,
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
 #undef _nc_printf_string
 char	*_nc_printf_string(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -2993,18 +3086,18 @@
 
 #undef _nc_scrolln_sp
 int	_nc_scrolln_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
-		int	bot, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
 #undef _nc_scrolln
 int	_nc_scrolln(
-		int	n, 
-		int	top, 
-		int	bot, 
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
@@ -3037,7 +3130,7 @@
 
 #undef _nc_do_xmc_glitch_sp
 void	_nc_do_xmc_glitch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		attr_t	previous)
 		{ /* void */ }
 
@@ -3048,13 +3141,9 @@
 
 /* ./trace/varargs.c */
 
-typedef enum {
-    atUnknown = 0, atInteger, atFloat, atPoint, atString
-} ARGTYPE;
-
 #undef _nc_varargs
 char	*_nc_varargs(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -3072,7 +3161,7 @@
 
 #undef _nc_free_and_exit_sp
 void	_nc_free_and_exit_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	code)
 		{ /* void */ }
 
@@ -3081,6 +3170,11 @@
 		int	code)
 		{ /* void */ }
 
+#undef exit_curses
+void	exit_curses(
+		int	code)
+		{ /* void */ }
+
 /* ./widechar/charable.c */
 
 #undef _nc_is_charable
@@ -3102,13 +3196,13 @@
 
 #undef wadd_wch
 int	wadd_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
 #undef wecho_wchar
 int	wecho_wchar(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
@@ -3116,14 +3210,14 @@
 
 #undef wborder_set
 int	wborder_set(
-		WINDOW	*win, 
-		const cchar_t *ls, 
-		const cchar_t *rs, 
-		const cchar_t *ts, 
-		const cchar_t *bs, 
-		const cchar_t *tl, 
-		const cchar_t *tr, 
-		const cchar_t *bl, 
+		WINDOW	*win,
+		const cchar_t *ls,
+		const cchar_t *rs,
+		const cchar_t *ts,
+		const cchar_t *bs,
+		const cchar_t *tl,
+		const cchar_t *tr,
+		const cchar_t *bl,
 		const cchar_t *br)
 		{ return(*(int *)0); }
 
@@ -3131,29 +3225,41 @@
 
 #undef setcchar
 int	setcchar(
-		cchar_t	*wcval, 
-		const wchar_t *wch, 
-		const attr_t attrs, 
-		short	color_pair, 
+		cchar_t	*wcval,
+		const wchar_t *wch,
+		const attr_t attrs,
+		short	pair_arg,
 		const void *opts)
 		{ return(*(int *)0); }
 
 #undef getcchar
 int	getcchar(
-		const cchar_t *wcval, 
-		wchar_t	*wch, 
-		attr_t	*attrs, 
-		short	*color_pair, 
+		const cchar_t *wcval,
+		wchar_t	*wch,
+		attr_t	*attrs,
+		short	*pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 /* ./widechar/lib_erasewchar.c */
 
+#undef erasewchar_sp
+int	erasewchar_sp(
+		SCREEN	*sp,
+		wchar_t	*wch)
+		{ return(*(int *)0); }
+
 #undef erasewchar
 int	erasewchar(
 		wchar_t	*wch)
 		{ return(*(int *)0); }
 
+#undef killwchar_sp
+int	killwchar_sp(
+		SCREEN	*sp,
+		wchar_t	*wch)
+		{ return(*(int *)0); }
+
 #undef killwchar
 int	killwchar(
 		wchar_t	*wch)
@@ -3163,7 +3269,7 @@
 
 #undef wget_wch
 int	wget_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		wint_t	*result)
 		{ return(*(int *)0); }
 
@@ -3171,8 +3277,8 @@
 
 #undef wgetn_wstr
 int	wgetn_wstr(
-		WINDOW	*win, 
-		wint_t	*str, 
+		WINDOW	*win,
+		wint_t	*str,
 		int	maxlen)
 		{ return(*(int *)0); }
 
@@ -3180,8 +3286,8 @@
 
 #undef whline_set
 int	whline_set(
-		WINDOW	*win, 
-		const cchar_t *ch, 
+		WINDOW	*win,
+		const cchar_t *ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3189,7 +3295,7 @@
 
 #undef win_wch
 int	win_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		cchar_t	*wcval)
 		{ return(*(int *)0); }
 
@@ -3197,8 +3303,8 @@
 
 #undef win_wchnstr
 int	win_wchnstr(
-		WINDOW	*win, 
-		cchar_t	*wchstr, 
+		WINDOW	*win,
+		cchar_t	*wchstr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3206,20 +3312,20 @@
 
 #undef _nc_insert_wch
 int	_nc_insert_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
 #undef wins_wch
 int	wins_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
 #undef wins_nwstr
 int	wins_nwstr(
-		WINDOW	*win, 
-		const wchar_t *wstr, 
+		WINDOW	*win,
+		const wchar_t *wstr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3227,14 +3333,14 @@
 
 #undef winnwstr
 int	winnwstr(
-		WINDOW	*win, 
-		wchar_t	*wstr, 
+		WINDOW	*win,
+		wchar_t	*wstr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef winwstr
 int	winwstr(
-		WINDOW	*win, 
+		WINDOW	*win,
 		wchar_t	*wstr)
 		{ return(*(int *)0); }
 
@@ -3249,7 +3355,7 @@
 
 #undef pecho_wchar
 int	pecho_wchar(
-		WINDOW	*pad, 
+		WINDOW	*pad,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
@@ -3257,8 +3363,8 @@
 
 #undef slk_wset
 int	slk_wset(
-		int	i, 
-		const wchar_t *astr, 
+		int	i,
+		const wchar_t *astr,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -3266,14 +3372,14 @@
 
 #undef _nc_wcrtomb
 size_t	_nc_wcrtomb(
-		char	*target, 
-		wchar_t	source, 
+		char	*target,
+		wchar_t	source,
 		mbstate_t *state)
 		{ return(*(size_t *)0); }
 
 #undef unget_wch_sp
 int	unget_wch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const wchar_t wch)
 		{ return(*(int *)0); }
 
@@ -3286,33 +3392,33 @@
 
 #undef vid_puts_sp
 int	vid_puts_sp(
-		SCREEN	*sp, 
-		attr_t	newmode, 
-		short	pair, 
-		void	*opts, 
+		SCREEN	*sp,
+		attr_t	newmode,
+		short	pair_arg,
+		void	*opts,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef vid_puts
 int	vid_puts(
-		attr_t	newmode, 
-		short	pair, 
-		void	*opts, 
+		attr_t	newmode,
+		short	pair_arg,
+		void	*opts,
 		NCURSES_OUTC outc)
 		{ return(*(int *)0); }
 
 #undef vid_attr_sp
 int	vid_attr_sp(
-		SCREEN	*sp, 
-		attr_t	newmode, 
-		short	pair, 
+		SCREEN	*sp,
+		attr_t	newmode,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 #undef vid_attr
 int	vid_attr(
-		attr_t	newmode, 
-		short	pair, 
+		attr_t	newmode,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -3329,8 +3435,8 @@
 
 #undef wvline_set
 int	wvline_set(
-		WINDOW	*win, 
-		const cchar_t *ch, 
+		WINDOW	*win,
+		const cchar_t *ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3347,7 +3453,7 @@
 
 #undef wunctrl_sp
 wchar_t	*wunctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		cchar_t	*wc)
 		{ return(*(wchar_t **)0); }
 
@@ -3360,31 +3466,31 @@
 
 #undef _nc_toggle_attr_on
 void	_nc_toggle_attr_on(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_toggle_attr_off
 void	_nc_toggle_attr_off(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_DelCharCost_sp
 int	_nc_DelCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_InsCharCost_sp
 int	_nc_InsCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_UpdateAttrs_sp
 void	_nc_UpdateAttrs_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const cchar_t *c)
 		{ /* void */ }
 
@@ -3407,7 +3513,7 @@
 
 #undef use_legacy_coding_sp
 int	use_legacy_coding_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	level)
 		{ return(*(int *)0); }
 
@@ -3429,14 +3535,14 @@
 
 #undef assume_default_colors_sp
 int	assume_default_colors_sp(
-		SCREEN	*sp, 
-		int	fg, 
+		SCREEN	*sp,
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
 #undef assume_default_colors
 int	assume_default_colors(
-		int	fg, 
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
@@ -3444,55 +3550,121 @@
 
 #undef mcprint_sp
 int	mcprint_sp(
-		SCREEN	*sp, 
-		char	*data, 
+		SCREEN	*sp,
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
 #undef mcprint
 int	mcprint(
-		char	*data, 
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
+/* ./base/new_pair.c */
+
+#undef _nc_free_ordered_pairs
+void	_nc_free_ordered_pairs(
+		SCREEN	*sp)
+		{ /* void */ }
+
+#undef _nc_reset_color_pair
+void	_nc_reset_color_pair(
+		SCREEN	*sp,
+		int	pair,
+		colorpair_t *next)
+		{ /* void */ }
+
+#undef _nc_set_color_pair
+void	_nc_set_color_pair(
+		SCREEN	*sp,
+		int	pair,
+		int	mode)
+		{ /* void */ }
+
+#undef _nc_copy_pairs
+void	_nc_copy_pairs(
+		SCREEN	*sp,
+		colorpair_t *target,
+		colorpair_t *source,
+		int	length)
+		{ /* void */ }
+
+#undef alloc_pair_sp
+int	alloc_pair_sp(
+		SCREEN	*sp,
+		int	fg,
+		int	bg)
+		{ return(*(int *)0); }
+
+#undef find_pair_sp
+int	find_pair_sp(
+		SCREEN	*sp,
+		int	fg,
+		int	bg)
+		{ return(*(int *)0); }
+
+#undef free_pair_sp
+int	free_pair_sp(
+		SCREEN	*sp,
+		int	pair)
+		{ return(*(int *)0); }
+
+#undef alloc_pair
+int	alloc_pair(
+		int	f,
+		int	b)
+		{ return(*(int *)0); }
+
+#undef find_pair
+int	find_pair(
+		int	f,
+		int	b)
+		{ return(*(int *)0); }
+
+#undef free_pair
+int	free_pair(
+		int	pair)
+		{ return(*(int *)0); }
+
 /* ./base/resizeterm.c */
 
 #undef is_term_resized_sp
 NCURSES_BOOL is_term_resized_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_term_resized
 NCURSES_BOOL is_term_resized(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef resize_term_sp
 int	resize_term_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resize_term
 int	resize_term(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm_sp
 int	resizeterm_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm
 int	resizeterm(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -3507,8 +3679,8 @@
 
 #undef use_screen
 int	use_screen(
-		SCREEN	*screen, 
-		NCURSES_SCREEN_CB func, 
+		SCREEN	*screen,
+		NCURSES_SCREEN_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -3516,8 +3688,8 @@
 
 #undef use_window
 int	use_window(
-		WINDOW	*win, 
-		NCURSES_WINDOW_CB func, 
+		WINDOW	*win,
+		NCURSES_WINDOW_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -3525,8 +3697,8 @@
 
 #undef wresize
 int	wresize(
-		WINDOW	*win, 
-		int	ToLines, 
+		WINDOW	*win,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -3554,7 +3726,7 @@
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -3572,12 +3744,25 @@
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -3585,16 +3770,28 @@
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE *to, 
-		TERMTYPE *from)
+		TERMTYPE2 *to,
+		TERMTYPE2 *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
+#undef _nc_copy_termtype2
+void	_nc_copy_termtype2(
+		TERMTYPE2 *dst,
+		const TERMTYPE2 *src)
+		{ /* void */ }
+
+#undef _nc_export_termtype2
+void	_nc_export_termtype2(
+		TERMTYPE *dst,
+		const TERMTYPE2 *src)
+		{ /* void */ }
+
 /* ./codes.c */
 
 #undef boolcodes
@@ -3656,19 +3853,19 @@
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -3676,17 +3873,32 @@
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
+#undef _nc_find_user_entry
+struct user_table_entry const *_nc_find_user_entry(
+		const char *string)
+		{ return(*(struct user_table_entry const **)0); }
+
+/* ./comp_userdefs.c */
+
+#undef _nc_get_userdefs_table
+const struct user_table_entry *_nc_get_userdefs_table(void)
+		{ return(*(const struct user_table_entry **)0); }
+
+#undef _nc_get_hash_user
+const HashData *_nc_get_hash_user(void)
+		{ return(*(const HashData **)0); }
+
 /* ./tinfo/db_iterator.c */
 
 #undef _nc_tic_dir
@@ -3705,13 +3917,13 @@
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -3719,7 +3931,7 @@
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -3732,8 +3944,8 @@
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
-		TERMTYPE *tterm)
+		ENTRY	*headp,
+		TERMTYPE2 *tterm)
 		{ /* void */ }
 
 #undef _nc_free_entries
@@ -3741,18 +3953,22 @@
 		ENTRY	*headp)
 		{ /* void */ }
 
-#undef _nc_delink_entry
-ENTRY	*_nc_delink_entry(
-		ENTRY	*headp, 
-		TERMTYPE *tterm)
-		{ return(*(ENTRY **)0); }
-
 #undef _nc_leaks_tinfo
 void	_nc_leaks_tinfo(void)
 		{ /* void */ }
 
+#undef exit_terminfo
+void	exit_terminfo(
+		int	code)
+		{ /* void */ }
+
 /* ./fallback.c */
 
+#undef _nc_fallback2
+const TERMTYPE2 *_nc_fallback2(
+		const char *name)
+		{ return(*(const TERMTYPE2 **)0); }
+
 #undef _nc_fallback
 const TERMTYPE *_nc_fallback(
 		const char *name)
@@ -3765,6 +3981,16 @@
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
+#undef _nc_free_termtype2
+void	_nc_free_termtype2(
+		TERMTYPE2 *ptr)
+		{ /* void */ }
+
 #undef _nc_user_definable
 NCURSES_BOOL _nc_user_definable;
 
@@ -3782,7 +4008,7 @@
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -3816,8 +4042,8 @@
 /* ./tinfo/lib_baudrate.c */
 
 struct speed {
-    short s; 
-    int sp; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -3846,7 +4072,7 @@
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -3857,7 +4083,7 @@
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -3943,7 +4169,7 @@
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -3967,7 +4193,7 @@
 
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -3980,19 +4206,19 @@
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -4003,37 +4229,37 @@
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -4044,7 +4270,7 @@
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -4055,7 +4281,7 @@
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -4066,14 +4292,14 @@
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -4135,17 +4361,53 @@
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
 /* ./tinfo/lib_setup.c */
 
 #undef ttytype
@@ -4159,7 +4421,7 @@
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -4175,13 +4437,13 @@
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -4197,8 +4459,8 @@
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -4209,13 +4471,13 @@
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
-		TERMTYPE *const tp)
+		const char *const tn,
+		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -4234,9 +4496,9 @@
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
@@ -4246,8 +4508,8 @@
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -4260,20 +4522,20 @@
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -4284,7 +4546,7 @@
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -4295,14 +4557,14 @@
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -4321,8 +4583,8 @@
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -4330,7 +4592,7 @@
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -4341,7 +4603,7 @@
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -4352,7 +4614,7 @@
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -4366,25 +4628,58 @@
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
+#undef _nc_tiparm
+char	*_nc_tiparm(
+		int	expected,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -4401,7 +4696,7 @@
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -4421,7 +4716,7 @@
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -4432,7 +4727,7 @@
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -4443,7 +4738,7 @@
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -4454,35 +4749,35 @@
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -4496,6 +4791,11 @@
 #undef _nc_outchars
 long	_nc_outchars;
 
+#undef curses_trace
+unsigned curses_trace(
+		unsigned tracelevel)
+		{ return(*(unsigned *)0); }
+
 #undef trace
 void	trace(
 		const unsigned int tracelevel)
@@ -4503,7 +4803,7 @@
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -4557,11 +4857,18 @@
 		WINDOW	*code)
 		{ return(*(WINDOW **)0); }
 
+#undef _nc_fmt_funcptr
+char	*_nc_fmt_funcptr(
+		char	*target,
+		const char *source,
+		size_t	size)
+		{ return(*(char **)0); }
+
 /* ./trace/lib_traceatr.c */
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -4582,13 +4889,13 @@
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -4604,7 +4911,7 @@
 
 #undef _tracecchar_t2
 char	*_tracecchar_t2(
-		int	bufnum, 
+		int	bufnum,
 		const cchar_t *ch)
 		{ return(*(char **)0); }
 
@@ -4615,14 +4922,9 @@
 
 /* ./trace/lib_tracebits.c */
 
-typedef struct {
-    unsigned int val;
-    const char name[8];
-} BITNAMES;
-
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -4633,7 +4935,7 @@
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -4646,7 +4948,7 @@
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -4657,7 +4959,7 @@
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -4724,9 +5026,9 @@
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -4739,8 +5041,8 @@
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -4763,14 +5065,14 @@
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
@@ -4778,65 +5080,74 @@
 
 #undef _nc_init_termtype
 void	_nc_init_termtype(
-		TERMTYPE *const tp)
+		TERMTYPE2 *const tp)
 		{ /* void */ }
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE *ptr, 
-		char	*buffer, 
+		TERMTYPE2 *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
-		TERMTYPE *ptr)
+		const char *const filename,
+		TERMTYPE2 *ptr)
+		{ return(*(int *)0); }
+
+#undef _nc_read_entry2
+int	_nc_read_entry2(
+		const char *const name,
+		char	*const filename,
+		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/read_termcap.c */
 
-#undef _nc_read_termcap
-void	_nc_read_termcap(void)
-		{ /* void */ }
+#undef _nc_read_termcap_entry
+int	_nc_read_termcap_entry(
+		const char *const tn,
+		TERMTYPE2 *const tp)
+		{ return(*(int *)0); }
 
 /* ./tinfo/strings.c */
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -4844,13 +5155,13 @@
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -4865,21 +5176,21 @@
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -4887,14 +5198,14 @@
 
 #undef _nc_trim_sgr0
 char	*_nc_trim_sgr0(
-		TERMTYPE *tp)
+		TERMTYPE2 *tp)
 		{ return(*(char **)0); }
 
 /* ./unctrl.c */
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -4907,7 +5218,7 @@
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -4918,13 +5229,13 @@
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viswbuf2
 const char *_nc_viswbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const wchar_t *buf)
 		{ return(*(const char **)0); }
 
@@ -4935,7 +5246,7 @@
 
 #undef _nc_viswbufn
 const char *_nc_viswbufn(
-		const wchar_t *buf, 
+		const wchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -4946,14 +5257,14 @@
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const cchar_t *buf, 
+		int	bufnum,
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const cchar_t *buf, 
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -4961,7 +5272,7 @@
 
 #undef _nc_init_entry
 void	_nc_init_entry(
-		TERMTYPE *const tp)
+		ENTRY	*const tp)
 		{ /* void */ }
 
 #undef _nc_copy_entry
@@ -4971,34 +5282,34 @@
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		TERMTYPE *const to, 
-		TERMTYPE *const from)
+		ENTRY	*const target,
+		ENTRY	*const source)
 		{ /* void */ }
 
 /* ./tinfo/captoinfo.c */
 
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -5006,8 +5317,8 @@
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -5015,39 +5326,31 @@
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE *p1, 
+		TERMTYPE2 *p1,
 		NCURSES_BOOL p2);
-#undef _nc_check_termtype
-void	(*_nc_check_termtype)(
-		TERMTYPE *p1);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
-#undef _nc_resolve_uses
-int	_nc_resolve_uses(
-		NCURSES_BOOL fullresolve)
-		{ return(*(int *)0); }
-
 /* ./tinfo/comp_scan.c */
 
 #undef _nc_syntax
@@ -5069,7 +5372,7 @@
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -5080,8 +5383,8 @@
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -5098,22 +5401,17 @@
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		struct entry *entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
-typedef struct {
-    const char from[3];
-    const char to[6];
-} assoc;
-
 /* ./tinfo/write_entry.c */
 
 #undef _nc_set_writedir
@@ -5123,9 +5421,17 @@
 
 #undef _nc_write_entry
 void	_nc_write_entry(
-		TERMTYPE *const tp)
+		TERMTYPE2 *const tp)
 		{ /* void */ }
 
+#undef _nc_write_object
+int	_nc_write_object(
+		TERMTYPE2 *tp,
+		char	*buffer,
+		unsigned *offset,
+		unsigned limit)
+		{ return(*(int *)0); }
+
 #undef _nc_tic_written
 int	_nc_tic_written(void)
 		{ return(*(int *)0); }
@@ -5134,14 +5440,14 @@
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -5155,7 +5461,7 @@
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -5168,14 +5474,14 @@
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -5183,14 +5489,14 @@
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/ncurses/llib-ltic b/ncurses/llib-ltic
index 8230981..9e87aae 100644
--- a/ncurses/llib-ltic
+++ b/ncurses/llib-ltic
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2012,2015 Free Software Foundation, Inc.                   *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
+ * Copyright 2012-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,11 +35,10 @@
 /* ./tinfo/alloc_entry.c */
 
 #include <curses.priv.h>
-#include <tic.h>
 
 #undef _nc_init_entry
 void	_nc_init_entry(
-		TERMTYPE *const tp)
+		ENTRY	*const tp)
 		{ /* void */ }
 
 #undef _nc_copy_entry
@@ -48,36 +48,34 @@
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		TERMTYPE *const to, 
-		TERMTYPE *const from)
+		ENTRY	*const target,
+		ENTRY	*const source)
 		{ /* void */ }
 
 /* ./tinfo/captoinfo.c */
 
-#include <ctype.h>
-
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -85,8 +83,8 @@
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -94,39 +92,31 @@
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE *p1, 
+		TERMTYPE *p1,
 		NCURSES_BOOL p2);
-#undef _nc_check_termtype
-void	(*_nc_check_termtype)(
-		TERMTYPE *p1);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
-#undef _nc_resolve_uses
-int	_nc_resolve_uses(
-		NCURSES_BOOL fullresolve)
-		{ return(*(int *)0); }
-
 /* ./tinfo/comp_scan.c */
 
 #undef _nc_syntax
@@ -148,7 +138,7 @@
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -159,8 +149,8 @@
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -177,26 +167,19 @@
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		struct entry *entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
-typedef struct {
-    const char from[3];
-    const char to[6];
-} assoc;
-
 /* ./tinfo/write_entry.c */
 
-#include <hashed_db.h>
-
 #undef _nc_set_writedir
 void	_nc_set_writedir(
 		const char *dir)
@@ -207,6 +190,14 @@
 		TERMTYPE *const tp)
 		{ /* void */ }
 
+#undef _nc_write_object
+int	_nc_write_object(
+		TERMTYPE *tp,
+		char	*buffer,
+		unsigned *offset,
+		unsigned limit)
+		{ return(*(int *)0); }
+
 #undef _nc_tic_written
 int	_nc_tic_written(void)
 		{ return(*(int *)0); }
diff --git a/ncurses/llib-ltict b/ncurses/llib-ltict
index e7d175c..db9090b 100644
--- a/ncurses/llib-ltict
+++ b/ncurses/llib-ltict
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2013,2015 Free Software Foundation, Inc.                   *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
+ * Copyright 2013-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,11 +35,10 @@
 /* ./tinfo/alloc_entry.c */
 
 #include <curses.priv.h>
-#include <tic.h>
 
 #undef _nc_init_entry
 void	_nc_init_entry(
-		TERMTYPE *const tp)
+		ENTRY	*const tp)
 		{ /* void */ }
 
 #undef _nc_copy_entry
@@ -48,36 +48,34 @@
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		TERMTYPE *const to, 
-		TERMTYPE *const from)
+		ENTRY	*const target,
+		ENTRY	*const source)
 		{ /* void */ }
 
 /* ./tinfo/captoinfo.c */
 
-#include <ctype.h>
-
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -85,8 +83,8 @@
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -94,39 +92,31 @@
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE *p1, 
+		TERMTYPE *p1,
 		NCURSES_BOOL p2);
-#undef _nc_check_termtype
-void	(*_nc_check_termtype)(
-		TERMTYPE *p1);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
-#undef _nc_resolve_uses
-int	_nc_resolve_uses(
-		NCURSES_BOOL fullresolve)
-		{ return(*(int *)0); }
-
 /* ./tinfo/comp_scan.c */
 
 #undef _nc_syntax
@@ -148,7 +138,7 @@
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -159,8 +149,8 @@
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -177,26 +167,19 @@
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		struct entry *entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
-typedef struct {
-    const char from[3];
-    const char to[6];
-} assoc;
-
 /* ./tinfo/write_entry.c */
 
-#include <hashed_db.h>
-
 #undef _nc_set_writedir
 void	_nc_set_writedir(
 		const char *dir)
@@ -207,6 +190,14 @@
 		TERMTYPE *const tp)
 		{ /* void */ }
 
+#undef _nc_write_object
+int	_nc_write_object(
+		TERMTYPE *tp,
+		char	*buffer,
+		unsigned *offset,
+		unsigned limit)
+		{ return(*(int *)0); }
+
 #undef _nc_tic_written
 int	_nc_tic_written(void)
 		{ return(*(int *)0); }
diff --git a/ncurses/llib-ltictw b/ncurses/llib-ltictw
index 8230981..85db89b 100644
--- a/ncurses/llib-ltictw
+++ b/ncurses/llib-ltictw
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2012,2015 Free Software Foundation, Inc.                   *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
+ * Copyright 2012-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,11 +35,10 @@
 /* ./tinfo/alloc_entry.c */
 
 #include <curses.priv.h>
-#include <tic.h>
 
 #undef _nc_init_entry
 void	_nc_init_entry(
-		TERMTYPE *const tp)
+		ENTRY	*const tp)
 		{ /* void */ }
 
 #undef _nc_copy_entry
@@ -48,36 +48,34 @@
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		TERMTYPE *const to, 
-		TERMTYPE *const from)
+		ENTRY	*const target,
+		ENTRY	*const source)
 		{ /* void */ }
 
 /* ./tinfo/captoinfo.c */
 
-#include <ctype.h>
-
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -85,8 +83,8 @@
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -94,39 +92,31 @@
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE *p1, 
+		TERMTYPE2 *p1,
 		NCURSES_BOOL p2);
-#undef _nc_check_termtype
-void	(*_nc_check_termtype)(
-		TERMTYPE *p1);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
-#undef _nc_resolve_uses
-int	_nc_resolve_uses(
-		NCURSES_BOOL fullresolve)
-		{ return(*(int *)0); }
-
 /* ./tinfo/comp_scan.c */
 
 #undef _nc_syntax
@@ -148,7 +138,7 @@
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -159,8 +149,8 @@
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -177,26 +167,19 @@
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		struct entry *entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
-typedef struct {
-    const char from[3];
-    const char to[6];
-} assoc;
-
 /* ./tinfo/write_entry.c */
 
-#include <hashed_db.h>
-
 #undef _nc_set_writedir
 void	_nc_set_writedir(
 		const char *dir)
@@ -204,9 +187,17 @@
 
 #undef _nc_write_entry
 void	_nc_write_entry(
-		TERMTYPE *const tp)
+		TERMTYPE2 *const tp)
 		{ /* void */ }
 
+#undef _nc_write_object
+int	_nc_write_object(
+		TERMTYPE2 *tp,
+		char	*buffer,
+		unsigned *offset,
+		unsigned limit)
+		{ return(*(int *)0); }
+
 #undef _nc_tic_written
 int	_nc_tic_written(void)
 		{ return(*(int *)0); }
diff --git a/ncurses/llib-lticw b/ncurses/llib-lticw
index 8230981..85db89b 100644
--- a/ncurses/llib-lticw
+++ b/ncurses/llib-lticw
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2012,2015 Free Software Foundation, Inc.                   *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
+ * Copyright 2012-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,11 +35,10 @@
 /* ./tinfo/alloc_entry.c */
 
 #include <curses.priv.h>
-#include <tic.h>
 
 #undef _nc_init_entry
 void	_nc_init_entry(
-		TERMTYPE *const tp)
+		ENTRY	*const tp)
 		{ /* void */ }
 
 #undef _nc_copy_entry
@@ -48,36 +48,34 @@
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		TERMTYPE *const to, 
-		TERMTYPE *const from)
+		ENTRY	*const target,
+		ENTRY	*const source)
 		{ /* void */ }
 
 /* ./tinfo/captoinfo.c */
 
-#include <ctype.h>
-
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -85,8 +83,8 @@
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -94,39 +92,31 @@
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE *p1, 
+		TERMTYPE2 *p1,
 		NCURSES_BOOL p2);
-#undef _nc_check_termtype
-void	(*_nc_check_termtype)(
-		TERMTYPE *p1);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
-#undef _nc_resolve_uses
-int	_nc_resolve_uses(
-		NCURSES_BOOL fullresolve)
-		{ return(*(int *)0); }
-
 /* ./tinfo/comp_scan.c */
 
 #undef _nc_syntax
@@ -148,7 +138,7 @@
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -159,8 +149,8 @@
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -177,26 +167,19 @@
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		struct entry *entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
-typedef struct {
-    const char from[3];
-    const char to[6];
-} assoc;
-
 /* ./tinfo/write_entry.c */
 
-#include <hashed_db.h>
-
 #undef _nc_set_writedir
 void	_nc_set_writedir(
 		const char *dir)
@@ -204,9 +187,17 @@
 
 #undef _nc_write_entry
 void	_nc_write_entry(
-		TERMTYPE *const tp)
+		TERMTYPE2 *const tp)
 		{ /* void */ }
 
+#undef _nc_write_object
+int	_nc_write_object(
+		TERMTYPE2 *tp,
+		char	*buffer,
+		unsigned *offset,
+		unsigned limit)
+		{ return(*(int *)0); }
+
 #undef _nc_tic_written
 int	_nc_tic_written(void)
 		{ return(*(int *)0); }
diff --git a/ncurses/llib-ltinfo b/ncurses/llib-ltinfo
index fd3036b..5cfa111 100644
--- a/ncurses/llib-ltinfo
+++ b/ncurses/llib-ltinfo
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2012-2013,2015 Free Software Foundation, Inc.              *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2012-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,8 +35,6 @@
 /* ./tinfo/access.c */
 
 #include <curses.priv.h>
-#include <ctype.h>
-#include <tic.h>
 
 #undef _nc_rootname
 char	*_nc_rootname(
@@ -59,7 +58,7 @@
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -77,12 +76,25 @@
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -90,13 +102,13 @@
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE *to, 
+		TERMTYPE *to,
 		TERMTYPE *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
@@ -111,8 +123,6 @@
 
 /* ./comp_captab.c */
 
-#include <hashsize.h>
-
 #undef _nc_get_table
 const struct name_table_entry *_nc_get_table(
 		NCURSES_BOOL termcap)
@@ -163,19 +173,19 @@
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -183,20 +193,33 @@
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
-/* ./tinfo/db_iterator.c */
+#undef _nc_find_user_entry
+struct user_table_entry const *_nc_find_user_entry(
+		const char *string)
+		{ return(*(struct user_table_entry const **)0); }
 
-#include <time.h>
+/* ./comp_userdefs.c */
+
+#undef _nc_get_userdefs_table
+const struct user_table_entry *_nc_get_userdefs_table(void)
+		{ return(*(const struct user_table_entry **)0); }
+
+#undef _nc_get_hash_user
+const HashData *_nc_get_hash_user(void)
+		{ return(*(const HashData **)0); }
+
+/* ./tinfo/db_iterator.c */
 
 #undef _nc_tic_dir
 const char *_nc_tic_dir(
@@ -214,13 +237,13 @@
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -228,7 +251,7 @@
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -241,7 +264,7 @@
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
+		ENTRY	*headp,
 		TERMTYPE *tterm)
 		{ /* void */ }
 
@@ -250,16 +273,15 @@
 		ENTRY	*headp)
 		{ /* void */ }
 
-#undef _nc_delink_entry
-ENTRY	*_nc_delink_entry(
-		ENTRY	*headp, 
-		TERMTYPE *tterm)
-		{ return(*(ENTRY **)0); }
-
 #undef _nc_leaks_tinfo
 void	_nc_leaks_tinfo(void)
 		{ /* void */ }
 
+#undef exit_terminfo
+void	exit_terminfo(
+		int	code)
+		{ /* void */ }
+
 /* ./fallback.c */
 
 #undef _nc_fallback
@@ -274,6 +296,11 @@
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
 #undef _nc_user_definable
 NCURSES_BOOL _nc_user_definable;
 
@@ -291,7 +318,7 @@
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -303,15 +330,6 @@
 
 /* ./tinfo/init_keytry.c */
 
-#if 0
-
-#include <init_keytry.h>
-
-#undef _nc_tinfo_fkeys
-const struct tinfo_fkeys _nc_tinfo_fkeys[] = {0};
-
-#endif
-
 #undef _nc_init_keytry
 void	_nc_init_keytry(
 		SCREEN	*sp)
@@ -333,11 +351,9 @@
 
 /* ./tinfo/lib_baudrate.c */
 
-#include <termcap.h>
-
 struct speed {
-    short s; 
-    int sp; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -366,7 +382,7 @@
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -377,7 +393,7 @@
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -463,7 +479,7 @@
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -485,11 +501,9 @@
 
 /* ./tinfo/lib_napms.c */
 
-#include <sys/time.h>
-
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -502,19 +516,19 @@
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -525,37 +539,37 @@
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -566,7 +580,7 @@
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -577,7 +591,7 @@
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -588,14 +602,14 @@
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -657,22 +671,54 @@
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
-/* ./tinfo/lib_setup.c */
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
 
-#include <locale.h>
-#include <sys/ioctl.h>
-#include <langinfo.h>
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
+/* ./tinfo/lib_setup.c */
 
 #undef ttytype
 char	ttytype[256];
@@ -685,7 +731,7 @@
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -701,13 +747,13 @@
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -723,8 +769,8 @@
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -735,13 +781,13 @@
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
+		const char *const tn,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -760,9 +806,9 @@
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
@@ -772,8 +818,8 @@
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -786,26 +832,20 @@
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
-#if 0
-
-#include <capdefaults.c>
-
-#endif
-
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -816,7 +856,7 @@
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -827,14 +867,14 @@
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -853,8 +893,8 @@
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -862,7 +902,7 @@
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -873,7 +913,7 @@
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -884,7 +924,7 @@
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -898,25 +938,58 @@
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
+#undef _nc_tiparm
+char	*_nc_tiparm(
+		int	expected,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -933,7 +1006,7 @@
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -953,7 +1026,7 @@
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -964,7 +1037,7 @@
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -975,7 +1048,7 @@
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -986,35 +1059,35 @@
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -1028,6 +1101,11 @@
 #undef _nc_outchars
 long	_nc_outchars;
 
+#undef curses_trace
+unsigned curses_trace(
+		unsigned tracelevel)
+		{ return(*(unsigned *)0); }
+
 #undef trace
 void	trace(
 		const unsigned int tracelevel)
@@ -1035,7 +1113,7 @@
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -1089,11 +1167,18 @@
 		WINDOW	*code)
 		{ return(*(WINDOW **)0); }
 
+#undef _nc_fmt_funcptr
+char	*_nc_fmt_funcptr(
+		char	*target,
+		const char *source,
+		size_t	size)
+		{ return(*(char **)0); }
+
 /* ./trace/lib_traceatr.c */
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -1114,13 +1199,13 @@
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -1136,14 +1221,9 @@
 
 /* ./trace/lib_tracebits.c */
 
-typedef struct {
-    unsigned int val;
-    const char name[8];
-} BITNAMES;
-
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -1154,7 +1234,7 @@
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -1167,7 +1247,7 @@
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1178,7 +1258,7 @@
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1245,9 +1325,9 @@
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -1260,8 +1340,8 @@
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -1284,21 +1364,19 @@
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 /* ./tinfo/read_entry.c */
 
-#include <hashed_db.h>
-
 #undef _nc_init_termtype
 void	_nc_init_termtype(
 		TERMTYPE *const tp)
@@ -1306,28 +1384,26 @@
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE *ptr, 
-		char	*buffer, 
+		TERMTYPE *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
+		const char *const filename,
 		TERMTYPE *ptr)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/read_termcap.c */
 
-#include <sys/types.h>
-
 #undef _nc_read_termcap
 void	_nc_read_termcap(void)
 		{ /* void */ }
@@ -1336,32 +1412,32 @@
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1369,13 +1445,13 @@
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -1390,21 +1466,21 @@
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -1419,7 +1495,7 @@
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -1432,7 +1508,7 @@
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -1443,20 +1519,20 @@
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const chtype *buf, 
+		int	bufnum,
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const chtype *buf, 
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -1464,14 +1540,14 @@
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -1485,7 +1561,7 @@
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -1498,14 +1574,14 @@
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -1513,14 +1589,14 @@
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/ncurses/llib-ltinfot b/ncurses/llib-ltinfot
index 11f0d95..94ca9a7 100644
--- a/ncurses/llib-ltinfot
+++ b/ncurses/llib-ltinfot
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2013-2013,2015 Free Software Foundation, Inc.              *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2013-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,8 +35,6 @@
 /* ./tinfo/access.c */
 
 #include <curses.priv.h>
-#include <ctype.h>
-#include <tic.h>
 
 #undef _nc_rootname
 char	*_nc_rootname(
@@ -59,7 +58,7 @@
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -77,12 +76,25 @@
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -90,13 +102,13 @@
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE *to, 
+		TERMTYPE *to,
 		TERMTYPE *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
@@ -116,8 +128,6 @@
 
 /* ./comp_captab.c */
 
-#include <hashsize.h>
-
 #undef _nc_get_table
 const struct name_table_entry *_nc_get_table(
 		NCURSES_BOOL termcap)
@@ -168,19 +178,19 @@
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -188,20 +198,33 @@
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
-/* ./tinfo/db_iterator.c */
+#undef _nc_find_user_entry
+struct user_table_entry const *_nc_find_user_entry(
+		const char *string)
+		{ return(*(struct user_table_entry const **)0); }
 
-#include <time.h>
+/* ./comp_userdefs.c */
+
+#undef _nc_get_userdefs_table
+const struct user_table_entry *_nc_get_userdefs_table(void)
+		{ return(*(const struct user_table_entry **)0); }
+
+#undef _nc_get_hash_user
+const HashData *_nc_get_hash_user(void)
+		{ return(*(const HashData **)0); }
+
+/* ./tinfo/db_iterator.c */
 
 #undef _nc_tic_dir
 const char *_nc_tic_dir(
@@ -219,13 +242,13 @@
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -233,7 +256,7 @@
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -246,7 +269,7 @@
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
+		ENTRY	*headp,
 		TERMTYPE *tterm)
 		{ /* void */ }
 
@@ -255,16 +278,15 @@
 		ENTRY	*headp)
 		{ /* void */ }
 
-#undef _nc_delink_entry
-ENTRY	*_nc_delink_entry(
-		ENTRY	*headp, 
-		TERMTYPE *tterm)
-		{ return(*(ENTRY **)0); }
-
 #undef _nc_leaks_tinfo
 void	_nc_leaks_tinfo(void)
 		{ /* void */ }
 
+#undef exit_terminfo
+void	exit_terminfo(
+		int	code)
+		{ /* void */ }
+
 /* ./fallback.c */
 
 #undef _nc_fallback
@@ -279,6 +301,11 @@
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
 #undef _nc_user_definable
 NCURSES_BOOL _nc_user_definable;
 
@@ -296,7 +323,7 @@
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -308,15 +335,6 @@
 
 /* ./tinfo/init_keytry.c */
 
-#if 0
-
-#include <init_keytry.h>
-
-#undef _nc_tinfo_fkeys
-const struct tinfo_fkeys _nc_tinfo_fkeys[] = {0};
-
-#endif
-
 #undef _nc_init_keytry
 void	_nc_init_keytry(
 		SCREEN	*sp)
@@ -339,11 +357,9 @@
 
 /* ./tinfo/lib_baudrate.c */
 
-#include <termcap.h>
-
 struct speed {
-    short s; 
-    int sp; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -382,7 +398,7 @@
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -393,7 +409,7 @@
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -509,7 +525,7 @@
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -533,7 +549,7 @@
 
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -546,19 +562,19 @@
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -569,37 +585,37 @@
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -610,7 +626,7 @@
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -621,7 +637,7 @@
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -632,14 +648,14 @@
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -701,22 +717,54 @@
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
-/* ./tinfo/lib_setup.c */
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
 
-#include <locale.h>
-#include <sys/ioctl.h>
-#include <langinfo.h>
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
+/* ./tinfo/lib_setup.c */
 
 #undef _nc_ttytype
 char	*_nc_ttytype(void)
@@ -751,7 +799,7 @@
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -767,13 +815,13 @@
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -789,8 +837,8 @@
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -801,13 +849,13 @@
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
+		const char *const tn,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -826,20 +874,28 @@
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
+#undef _nc_find_prescr
+SCREEN	*_nc_find_prescr(void)
+		{ return(*(SCREEN **)0); }
+
+#undef _nc_forget_prescr
+void	_nc_forget_prescr(void)
+		{ /* void */ }
+
 #undef new_prescr
 SCREEN	*new_prescr(void)
 		{ return(*(SCREEN **)0); }
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -852,26 +908,20 @@
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
-#if 0
-
-#include <capdefaults.c>
-
-#endif
-
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -882,7 +932,7 @@
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -893,14 +943,14 @@
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -919,8 +969,8 @@
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -928,7 +978,7 @@
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -939,7 +989,7 @@
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -950,7 +1000,7 @@
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -964,25 +1014,58 @@
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
+#undef _nc_tiparm
+char	*_nc_tiparm(
+		int	expected,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -999,7 +1082,7 @@
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -1019,7 +1102,7 @@
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -1030,7 +1113,7 @@
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -1041,7 +1124,7 @@
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -1052,35 +1135,35 @@
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -1108,6 +1191,11 @@
 		long	increment)
 		{ /* void */ }
 
+#undef curses_trace
+unsigned curses_trace(
+		unsigned tracelevel)
+		{ return(*(unsigned *)0); }
+
 #undef trace
 void	trace(
 		const unsigned int tracelevel)
@@ -1115,7 +1203,7 @@
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -1169,6 +1257,13 @@
 		WINDOW	*code)
 		{ return(*(WINDOW **)0); }
 
+#undef _nc_fmt_funcptr
+char	*_nc_fmt_funcptr(
+		char	*target,
+		const char *source,
+		size_t	size)
+		{ return(*(char **)0); }
+
 #undef _nc_use_tracef
 int	_nc_use_tracef(
 		unsigned mask)
@@ -1176,7 +1271,7 @@
 
 #undef _nc_locked_tracef
 void	_nc_locked_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -1184,7 +1279,7 @@
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -1205,13 +1300,13 @@
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -1227,14 +1322,9 @@
 
 /* ./trace/lib_tracebits.c */
 
-typedef struct {
-    unsigned int val;
-    const char name[8];
-} BITNAMES;
-
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -1245,7 +1335,7 @@
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -1258,7 +1348,7 @@
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1269,7 +1359,7 @@
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1334,13 +1424,11 @@
 
 /* ./tty/lib_twait.c */
 
-#include <sys/time.h>
-
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -1353,8 +1441,8 @@
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -1388,21 +1476,19 @@
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 /* ./tinfo/read_entry.c */
 
-#include <hashed_db.h>
-
 #undef _nc_init_termtype
 void	_nc_init_termtype(
 		TERMTYPE *const tp)
@@ -1410,28 +1496,26 @@
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE *ptr, 
-		char	*buffer, 
+		TERMTYPE *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
+		const char *const filename,
 		TERMTYPE *ptr)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/read_termcap.c */
 
-#include <sys/types.h>
-
 #undef _nc_read_termcap
 void	_nc_read_termcap(void)
 		{ /* void */ }
@@ -1440,32 +1524,32 @@
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1473,13 +1557,13 @@
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -1494,21 +1578,21 @@
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -1523,7 +1607,7 @@
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -1536,7 +1620,7 @@
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -1547,20 +1631,20 @@
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const chtype *buf, 
+		int	bufnum,
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const chtype *buf, 
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -1568,14 +1652,14 @@
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -1589,7 +1673,7 @@
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -1602,14 +1686,14 @@
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -1617,14 +1701,14 @@
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/ncurses/llib-ltinfotw b/ncurses/llib-ltinfotw
index 3e6ada3..3b21b87 100644
--- a/ncurses/llib-ltinfotw
+++ b/ncurses/llib-ltinfotw
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2012-2013,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2012-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,8 +35,6 @@
 /* ./tinfo/access.c */
 
 #include <curses.priv.h>
-#include <ctype.h>
-#include <tic.h>
 
 #undef _nc_rootname
 char	*_nc_rootname(
@@ -59,7 +58,7 @@
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -77,12 +76,25 @@
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -90,16 +102,28 @@
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE *to, 
-		TERMTYPE *from)
+		TERMTYPE2 *to,
+		TERMTYPE2 *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
+#undef _nc_copy_termtype2
+void	_nc_copy_termtype2(
+		TERMTYPE2 *dst,
+		const TERMTYPE2 *src)
+		{ /* void */ }
+
+#undef _nc_export_termtype2
+void	_nc_export_termtype2(
+		TERMTYPE *dst,
+		const TERMTYPE2 *src)
+		{ /* void */ }
+
 /* ./codes.c */
 
 #undef _nc_boolcodes
@@ -116,8 +140,6 @@
 
 /* ./comp_captab.c */
 
-#include <hashsize.h>
-
 #undef _nc_get_table
 const struct name_table_entry *_nc_get_table(
 		NCURSES_BOOL termcap)
@@ -168,19 +190,19 @@
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -188,20 +210,33 @@
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
-/* ./tinfo/db_iterator.c */
+#undef _nc_find_user_entry
+struct user_table_entry const *_nc_find_user_entry(
+		const char *string)
+		{ return(*(struct user_table_entry const **)0); }
 
-#include <time.h>
+/* ./comp_userdefs.c */
+
+#undef _nc_get_userdefs_table
+const struct user_table_entry *_nc_get_userdefs_table(void)
+		{ return(*(const struct user_table_entry **)0); }
+
+#undef _nc_get_hash_user
+const HashData *_nc_get_hash_user(void)
+		{ return(*(const HashData **)0); }
+
+/* ./tinfo/db_iterator.c */
 
 #undef _nc_tic_dir
 const char *_nc_tic_dir(
@@ -219,13 +254,13 @@
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -233,7 +268,7 @@
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -246,8 +281,8 @@
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
-		TERMTYPE *tterm)
+		ENTRY	*headp,
+		TERMTYPE2 *tterm)
 		{ /* void */ }
 
 #undef _nc_free_entries
@@ -255,18 +290,22 @@
 		ENTRY	*headp)
 		{ /* void */ }
 
-#undef _nc_delink_entry
-ENTRY	*_nc_delink_entry(
-		ENTRY	*headp, 
-		TERMTYPE *tterm)
-		{ return(*(ENTRY **)0); }
-
 #undef _nc_leaks_tinfo
 void	_nc_leaks_tinfo(void)
 		{ /* void */ }
 
+#undef exit_terminfo
+void	exit_terminfo(
+		int	code)
+		{ /* void */ }
+
 /* ./fallback.c */
 
+#undef _nc_fallback2
+const TERMTYPE2 *_nc_fallback2(
+		const char *name)
+		{ return(*(const TERMTYPE2 **)0); }
+
 #undef _nc_fallback
 const TERMTYPE *_nc_fallback(
 		const char *name)
@@ -279,6 +318,16 @@
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
+#undef _nc_free_termtype2
+void	_nc_free_termtype2(
+		TERMTYPE2 *ptr)
+		{ /* void */ }
+
 #undef _nc_user_definable
 NCURSES_BOOL _nc_user_definable;
 
@@ -296,7 +345,7 @@
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -308,15 +357,6 @@
 
 /* ./tinfo/init_keytry.c */
 
-#if 0
-
-#include <init_keytry.h>
-
-#undef _nc_tinfo_fkeys
-const struct tinfo_fkeys _nc_tinfo_fkeys[] = {0};
-
-#endif
-
 #undef _nc_init_keytry
 void	_nc_init_keytry(
 		SCREEN	*sp)
@@ -339,11 +379,9 @@
 
 /* ./tinfo/lib_baudrate.c */
 
-#include <termcap.h>
-
 struct speed {
-    short s; 
-    int sp; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -382,7 +420,7 @@
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -393,7 +431,7 @@
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -509,7 +547,7 @@
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -533,7 +571,7 @@
 
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -546,19 +584,19 @@
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -569,37 +607,37 @@
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -610,7 +648,7 @@
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -621,7 +659,7 @@
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -632,14 +670,14 @@
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -701,22 +739,54 @@
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
-/* ./tinfo/lib_setup.c */
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
 
-#include <locale.h>
-#include <sys/ioctl.h>
-#include <langinfo.h>
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
+/* ./tinfo/lib_setup.c */
 
 #undef _nc_ttytype
 char	*_nc_ttytype(void)
@@ -751,7 +821,7 @@
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -767,13 +837,13 @@
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -789,8 +859,8 @@
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -801,13 +871,13 @@
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
-		TERMTYPE *const tp)
+		const char *const tn,
+		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -826,20 +896,28 @@
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
+#undef _nc_find_prescr
+SCREEN	*_nc_find_prescr(void)
+		{ return(*(SCREEN **)0); }
+
+#undef _nc_forget_prescr
+void	_nc_forget_prescr(void)
+		{ /* void */ }
+
 #undef new_prescr
 SCREEN	*new_prescr(void)
 		{ return(*(SCREEN **)0); }
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -852,26 +930,20 @@
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
-#if 0
-
-#include <capdefaults.c>
-
-#endif
-
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -882,7 +954,7 @@
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -893,14 +965,14 @@
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -919,8 +991,8 @@
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -928,7 +1000,7 @@
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -939,7 +1011,7 @@
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -950,7 +1022,7 @@
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -964,25 +1036,58 @@
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
+#undef _nc_tiparm
+char	*_nc_tiparm(
+		int	expected,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -999,7 +1104,7 @@
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -1019,7 +1124,7 @@
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -1030,7 +1135,7 @@
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -1041,7 +1146,7 @@
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -1052,35 +1157,35 @@
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -1108,6 +1213,11 @@
 		long	increment)
 		{ /* void */ }
 
+#undef curses_trace
+unsigned curses_trace(
+		unsigned tracelevel)
+		{ return(*(unsigned *)0); }
+
 #undef trace
 void	trace(
 		const unsigned int tracelevel)
@@ -1115,7 +1225,7 @@
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -1169,6 +1279,13 @@
 		WINDOW	*code)
 		{ return(*(WINDOW **)0); }
 
+#undef _nc_fmt_funcptr
+char	*_nc_fmt_funcptr(
+		char	*target,
+		const char *source,
+		size_t	size)
+		{ return(*(char **)0); }
+
 #undef _nc_use_tracef
 int	_nc_use_tracef(
 		unsigned mask)
@@ -1176,7 +1293,7 @@
 
 #undef _nc_locked_tracef
 void	_nc_locked_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -1184,7 +1301,7 @@
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -1205,13 +1322,13 @@
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -1227,7 +1344,7 @@
 
 #undef _tracecchar_t2
 char	*_tracecchar_t2(
-		int	bufnum, 
+		int	bufnum,
 		const cchar_t *ch)
 		{ return(*(char **)0); }
 
@@ -1238,14 +1355,9 @@
 
 /* ./trace/lib_tracebits.c */
 
-typedef struct {
-    unsigned int val;
-    const char name[8];
-} BITNAMES;
-
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -1256,7 +1368,7 @@
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -1269,7 +1381,7 @@
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1280,7 +1392,7 @@
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1345,13 +1457,11 @@
 
 /* ./tty/lib_twait.c */
 
-#include <sys/time.h>
-
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -1364,8 +1474,8 @@
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -1399,50 +1509,53 @@
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 /* ./tinfo/read_entry.c */
 
-#include <hashed_db.h>
-
 #undef _nc_init_termtype
 void	_nc_init_termtype(
-		TERMTYPE *const tp)
+		TERMTYPE2 *const tp)
 		{ /* void */ }
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE *ptr, 
-		char	*buffer, 
+		TERMTYPE2 *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
-		TERMTYPE *ptr)
+		const char *const filename,
+		TERMTYPE2 *ptr)
+		{ return(*(int *)0); }
+
+#undef _nc_read_entry2
+int	_nc_read_entry2(
+		const char *const name,
+		char	*const filename,
+		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/read_termcap.c */
 
-#include <sys/types.h>
-
 #undef _nc_read_termcap
 void	_nc_read_termcap(void)
 		{ /* void */ }
@@ -1451,32 +1564,32 @@
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1484,13 +1597,13 @@
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -1505,21 +1618,21 @@
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -1527,14 +1640,14 @@
 
 #undef _nc_trim_sgr0
 char	*_nc_trim_sgr0(
-		TERMTYPE *tp)
+		TERMTYPE2 *tp)
 		{ return(*(char **)0); }
 
 /* ./unctrl.c */
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -1547,7 +1660,7 @@
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -1558,13 +1671,13 @@
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viswbuf2
 const char *_nc_viswbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const wchar_t *buf)
 		{ return(*(const char **)0); }
 
@@ -1575,7 +1688,7 @@
 
 #undef _nc_viswbufn
 const char *_nc_viswbufn(
-		const wchar_t *buf, 
+		const wchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -1586,14 +1699,14 @@
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const cchar_t *buf, 
+		int	bufnum,
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const cchar_t *buf, 
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -1601,14 +1714,14 @@
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -1622,7 +1735,7 @@
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -1635,14 +1748,14 @@
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -1650,14 +1763,14 @@
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/ncurses/llib-ltinfow b/ncurses/llib-ltinfow
index 6df3296..fd30818 100644
--- a/ncurses/llib-ltinfow
+++ b/ncurses/llib-ltinfow
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2012-2013,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2012-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,8 +35,6 @@
 /* ./tinfo/access.c */
 
 #include <curses.priv.h>
-#include <ctype.h>
-#include <tic.h>
 
 #undef _nc_rootname
 char	*_nc_rootname(
@@ -59,7 +58,7 @@
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -77,12 +76,25 @@
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -90,16 +102,28 @@
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE *to, 
-		TERMTYPE *from)
+		TERMTYPE2 *to,
+		TERMTYPE2 *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
+#undef _nc_copy_termtype2
+void	_nc_copy_termtype2(
+		TERMTYPE2 *dst,
+		const TERMTYPE2 *src)
+		{ /* void */ }
+
+#undef _nc_export_termtype2
+void	_nc_export_termtype2(
+		TERMTYPE *dst,
+		const TERMTYPE2 *src)
+		{ /* void */ }
+
 /* ./codes.c */
 
 #undef boolcodes
@@ -111,8 +135,6 @@
 
 /* ./comp_captab.c */
 
-#include <hashsize.h>
-
 #undef _nc_get_table
 const struct name_table_entry *_nc_get_table(
 		NCURSES_BOOL termcap)
@@ -163,19 +185,19 @@
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -183,20 +205,33 @@
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
-/* ./tinfo/db_iterator.c */
+#undef _nc_find_user_entry
+struct user_table_entry const *_nc_find_user_entry(
+		const char *string)
+		{ return(*(struct user_table_entry const **)0); }
 
-#include <time.h>
+/* ./comp_userdefs.c */
+
+#undef _nc_get_userdefs_table
+const struct user_table_entry *_nc_get_userdefs_table(void)
+		{ return(*(const struct user_table_entry **)0); }
+
+#undef _nc_get_hash_user
+const HashData *_nc_get_hash_user(void)
+		{ return(*(const HashData **)0); }
+
+/* ./tinfo/db_iterator.c */
 
 #undef _nc_tic_dir
 const char *_nc_tic_dir(
@@ -214,13 +249,13 @@
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -228,7 +263,7 @@
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -241,8 +276,8 @@
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
-		TERMTYPE *tterm)
+		ENTRY	*headp,
+		TERMTYPE2 *tterm)
 		{ /* void */ }
 
 #undef _nc_free_entries
@@ -250,18 +285,22 @@
 		ENTRY	*headp)
 		{ /* void */ }
 
-#undef _nc_delink_entry
-ENTRY	*_nc_delink_entry(
-		ENTRY	*headp, 
-		TERMTYPE *tterm)
-		{ return(*(ENTRY **)0); }
-
 #undef _nc_leaks_tinfo
 void	_nc_leaks_tinfo(void)
 		{ /* void */ }
 
+#undef exit_terminfo
+void	exit_terminfo(
+		int	code)
+		{ /* void */ }
+
 /* ./fallback.c */
 
+#undef _nc_fallback2
+const TERMTYPE2 *_nc_fallback2(
+		const char *name)
+		{ return(*(const TERMTYPE2 **)0); }
+
 #undef _nc_fallback
 const TERMTYPE *_nc_fallback(
 		const char *name)
@@ -274,6 +313,16 @@
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
+#undef _nc_free_termtype2
+void	_nc_free_termtype2(
+		TERMTYPE2 *ptr)
+		{ /* void */ }
+
 #undef _nc_user_definable
 NCURSES_BOOL _nc_user_definable;
 
@@ -291,7 +340,7 @@
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -303,15 +352,6 @@
 
 /* ./tinfo/init_keytry.c */
 
-#if 0
-
-#include <init_keytry.h>
-
-#undef _nc_tinfo_fkeys
-const struct tinfo_fkeys _nc_tinfo_fkeys[] = {0};
-
-#endif
-
 #undef _nc_init_keytry
 void	_nc_init_keytry(
 		SCREEN	*sp)
@@ -333,11 +373,9 @@
 
 /* ./tinfo/lib_baudrate.c */
 
-#include <termcap.h>
-
 struct speed {
-    short s; 
-    int sp; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -366,7 +404,7 @@
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -377,7 +415,7 @@
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -463,7 +501,7 @@
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -485,11 +523,9 @@
 
 /* ./tinfo/lib_napms.c */
 
-#include <sys/time.h>
-
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -502,19 +538,19 @@
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -525,37 +561,37 @@
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -566,7 +602,7 @@
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -577,7 +613,7 @@
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -588,14 +624,14 @@
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -657,22 +693,54 @@
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
-/* ./tinfo/lib_setup.c */
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
 
-#include <locale.h>
-#include <sys/ioctl.h>
-#include <langinfo.h>
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
+/* ./tinfo/lib_setup.c */
 
 #undef ttytype
 char	ttytype[256];
@@ -685,7 +753,7 @@
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -701,13 +769,13 @@
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -723,8 +791,8 @@
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -735,13 +803,13 @@
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
-		TERMTYPE *const tp)
+		const char *const tn,
+		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -760,9 +828,9 @@
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
@@ -772,8 +840,8 @@
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -786,26 +854,20 @@
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
-#if 0
-
-#include <capdefaults.c>
-
-#endif
-
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -816,7 +878,7 @@
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -827,14 +889,14 @@
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -853,8 +915,8 @@
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -862,7 +924,7 @@
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -873,7 +935,7 @@
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -884,7 +946,7 @@
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -898,25 +960,58 @@
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
+#undef _nc_tiparm
+char	*_nc_tiparm(
+		int	expected,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -933,7 +1028,7 @@
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -953,7 +1048,7 @@
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -964,7 +1059,7 @@
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -975,7 +1070,7 @@
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -986,35 +1081,35 @@
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -1028,6 +1123,11 @@
 #undef _nc_outchars
 long	_nc_outchars;
 
+#undef curses_trace
+unsigned curses_trace(
+		unsigned tracelevel)
+		{ return(*(unsigned *)0); }
+
 #undef trace
 void	trace(
 		const unsigned int tracelevel)
@@ -1035,7 +1135,7 @@
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -1089,11 +1189,18 @@
 		WINDOW	*code)
 		{ return(*(WINDOW **)0); }
 
+#undef _nc_fmt_funcptr
+char	*_nc_fmt_funcptr(
+		char	*target,
+		const char *source,
+		size_t	size)
+		{ return(*(char **)0); }
+
 /* ./trace/lib_traceatr.c */
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -1114,13 +1221,13 @@
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -1136,7 +1243,7 @@
 
 #undef _tracecchar_t2
 char	*_tracecchar_t2(
-		int	bufnum, 
+		int	bufnum,
 		const cchar_t *ch)
 		{ return(*(char **)0); }
 
@@ -1147,14 +1254,9 @@
 
 /* ./trace/lib_tracebits.c */
 
-typedef struct {
-    unsigned int val;
-    const char name[8];
-} BITNAMES;
-
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -1165,7 +1267,7 @@
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -1178,7 +1280,7 @@
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1189,7 +1291,7 @@
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1256,9 +1358,9 @@
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -1271,8 +1373,8 @@
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -1295,50 +1397,53 @@
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 /* ./tinfo/read_entry.c */
 
-#include <hashed_db.h>
-
 #undef _nc_init_termtype
 void	_nc_init_termtype(
-		TERMTYPE *const tp)
+		TERMTYPE2 *const tp)
 		{ /* void */ }
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE *ptr, 
-		char	*buffer, 
+		TERMTYPE2 *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
-		TERMTYPE *ptr)
+		const char *const filename,
+		TERMTYPE2 *ptr)
+		{ return(*(int *)0); }
+
+#undef _nc_read_entry2
+int	_nc_read_entry2(
+		const char *const name,
+		char	*const filename,
+		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/read_termcap.c */
 
-#include <sys/types.h>
-
 #undef _nc_read_termcap
 void	_nc_read_termcap(void)
 		{ /* void */ }
@@ -1347,32 +1452,32 @@
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1380,13 +1485,13 @@
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -1401,21 +1506,21 @@
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -1423,14 +1528,14 @@
 
 #undef _nc_trim_sgr0
 char	*_nc_trim_sgr0(
-		TERMTYPE *tp)
+		TERMTYPE2 *tp)
 		{ return(*(char **)0); }
 
 /* ./unctrl.c */
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -1443,7 +1548,7 @@
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -1454,13 +1559,13 @@
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viswbuf2
 const char *_nc_viswbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const wchar_t *buf)
 		{ return(*(const char **)0); }
 
@@ -1471,7 +1576,7 @@
 
 #undef _nc_viswbufn
 const char *_nc_viswbufn(
-		const wchar_t *buf, 
+		const wchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -1482,14 +1587,14 @@
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const cchar_t *buf, 
+		int	bufnum,
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const cchar_t *buf, 
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -1497,14 +1602,14 @@
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -1518,7 +1623,7 @@
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -1531,14 +1636,14 @@
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -1546,14 +1651,14 @@
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/ncurses/make_hash b/ncurses/make_hash
deleted file mode 100755
index a6afa13..0000000
--- a/ncurses/make_hash
+++ /dev/null
Binary files differ
diff --git a/ncurses/make_keys b/ncurses/make_keys
deleted file mode 100755
index bd25688..0000000
--- a/ncurses/make_keys
+++ /dev/null
Binary files differ
diff --git a/ncurses/modules b/ncurses/modules
index b3b9732..e111712 100644
--- a/ncurses/modules
+++ b/ncurses/modules
@@ -1,6 +1,7 @@
-# $Id: modules,v 1.120 2013/01/26 22:17:55 tom Exp $
+# $Id: modules,v 1.127 2020/09/12 17:58:12 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.                #
+# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 1998-2013,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -44,7 +45,7 @@
 lib_clearok	lib		$(base)		$(HEADER_DEPS)
 lib_clrbot	lib		$(base)		$(HEADER_DEPS)
 lib_clreol	lib		$(base)		$(HEADER_DEPS)
-lib_color	lib		$(base)		$(HEADER_DEPS)	$(INCDIR)/tic.h
+lib_color	lib		$(base)		$(HEADER_DEPS)	$(INCDIR)/tic.h	$(srcdir)/new_pair.h
 lib_colorset	lib		$(base)		$(HEADER_DEPS)
 lib_delch	lib		$(base)		$(HEADER_DEPS)
 lib_delwin	lib		$(base)		$(HEADER_DEPS)
@@ -125,7 +126,7 @@
 charable	lib		$(wide)		$(HEADER_DEPS)
 lib_add_wch	lib		$(wide)		$(HEADER_DEPS)
 lib_box_set	lib		$(wide)		$(HEADER_DEPS)
-lib_cchar	lib		$(wide)		$(HEADER_DEPS)
+lib_cchar	lib		$(wide)		$(HEADER_DEPS)	$(srcdir)/new_pair.h
 lib_erasewchar	lib		$(wide)		$(HEADER_DEPS)
 lib_get_wch	lib		$(wide)		$(HEADER_DEPS)
 lib_get_wstr	lib		$(wide)		$(HEADER_DEPS)
@@ -149,6 +150,7 @@
 legacy_coding	lib		$(base)		$(HEADER_DEPS)
 lib_dft_fgbg	lib		$(base)		$(HEADER_DEPS)
 lib_print	lib		$(tinfo)	$(HEADER_DEPS)
+new_pair	lib		$(base)		$(HEADER_DEPS)	$(srcdir)/new_pair.h
 resizeterm	lib		$(base)		$(HEADER_DEPS)
 trace_xnames	lib		$(trace)	$(HEADER_DEPS)
 use_screen	lib		$(tinfo)	$(HEADER_DEPS)
@@ -164,6 +166,7 @@
 comp_captab	lib		.		$(HEADER_DEPS)	$(INCDIR)/tic.h ../include/hashsize.h
 comp_error	lib		$(tinfo)	$(HEADER_DEPS)	$(INCDIR)/tic.h
 comp_hash	lib		$(tinfo)	$(HEADER_DEPS)	$(INCDIR)/tic.h ../include/hashsize.h
+comp_userdefs	lib		.		$(HEADER_DEPS)	$(INCDIR)/tic.h ../include/hashsize.h
 db_iterator	lib		$(tinfo)	$(HEADER_DEPS)	$(INCDIR)/tic.h
 doalloc		lib		$(tinfo)	$(HEADER_DEPS)
 entries		lib		$(tinfo)	$(HEADER_DEPS)	$(INCDIR)/tic.h
@@ -238,6 +241,12 @@
 widechars	lib             $(wide)		$(HEADER_DEPS)
 win_driver	lib             $(win32con)	$(HEADER_DEPS)
 
+@ port_win32
+lib_win32con	lib		$(tinfo)	$(HEADER_DEPS)
+lib_win32util	lib		$(tinfo)	$(HEADER_DEPS)
+wcwidth		lib             $(win32con)	$(HEADER_DEPS)
+win32_driver	lib             $(win32con)	$(HEADER_DEPS)
+
 @ port_tinfo
 tinfo_driver	lib		$(tinfo)	$(HEADER_DEPS)	$(INCDIR)/tic.h
 
diff --git a/ncurses/names.c b/ncurses/names.c
deleted file mode 100644
index db93378..0000000
--- a/ncurses/names.c
+++ /dev/null
@@ -1,1379 +0,0 @@
-/* This file was generated by MKnames.awk */
-
-#include <curses.priv.h>
-
-#define IT NCURSES_CONST char * const
-
-
-#if BROKEN_LINKER || USE_REENTRANT
-
-static const char _nc_name_blob[] = 
-"bw\0" "auto_left_margin\0" "am\0" "auto_right_margin\0" "xsb\0" "no_esc_ctlc\0" \
-"xhp\0" "ceol_standout_glitch\0" "xenl\0" "eat_newline_glitch\0" "eo\0" \
-"erase_overstrike\0" "gn\0" "generic_type\0" "hc\0" "hard_copy\0" "km\0" \
-"has_meta_key\0" "hs\0" "has_status_line\0" "in\0" "insert_null_glitch\0" \
-"da\0" "memory_above\0" "db\0" "memory_below\0" "mir\0" "move_insert_mode\0" \
-"msgr\0" "move_standout_mode\0" "os\0" "over_strike\0" "eslok\0" "status_line_esc_ok\0" \
-"xt\0" "dest_tabs_magic_smso\0" "hz\0" "tilde_glitch\0" "ul\0" "transparent_underline\0" \
-"xon\0" "xon_xoff\0" "nxon\0" "needs_xon_xoff\0" "mc5i\0" "prtr_silent\0" \
-"chts\0" "hard_cursor\0" "nrrmc\0" "non_rev_rmcup\0" "npc\0" "no_pad_char\0" \
-"ndscr\0" "non_dest_scroll_region\0" "ccc\0" "can_change\0" "bce\0" "back_color_erase\0" \
-"hls\0" "hue_lightness_saturation\0" "xhpa\0" "col_addr_glitch\0" "crxm\0" \
-"cr_cancels_micro_mode\0" "daisy\0" "has_print_wheel\0" "xvpa\0" "row_addr_glitch\0" \
-"sam\0" "semi_auto_right_margin\0" "cpix\0" "cpi_changes_res\0" "lpix\0" \
-"lpi_changes_res\0" "cols\0" "columns\0" "it\0" "init_tabs\0" "lines\0" \
-"lines\0" "lm\0" "lines_of_memory\0" "xmc\0" "magic_cookie_glitch\0" "pb\0" \
-"padding_baud_rate\0" "vt\0" "virtual_terminal\0" "wsl\0" "width_status_line\0" \
-"nlab\0" "num_labels\0" "lh\0" "label_height\0" "lw\0" "label_width\0" \
-"ma\0" "max_attributes\0" "wnum\0" "maximum_windows\0" "colors\0" "max_colors\0" \
-"pairs\0" "max_pairs\0" "ncv\0" "no_color_video\0" "bufsz\0" "buffer_capacity\0" \
-"spinv\0" "dot_vert_spacing\0" "spinh\0" "dot_horz_spacing\0" "maddr\0" \
-"max_micro_address\0" "mjump\0" "max_micro_jump\0" "mcs\0" "micro_col_size\0" \
-"mls\0" "micro_line_size\0" "npins\0" "number_of_pins\0" "orc\0" "output_res_char\0" \
-"orl\0" "output_res_line\0" "orhi\0" "output_res_horz_inch\0" "orvi\0" \
-"output_res_vert_inch\0" "cps\0" "print_rate\0" "widcs\0" "wide_char_size\0" \
-"btns\0" "buttons\0" "bitwin\0" "bit_image_entwining\0" "bitype\0" "bit_image_type\0" \
-"cbt\0" "back_tab\0" "bel\0" "bell\0" "cr\0" "carriage_return\0" "csr\0" \
-"change_scroll_region\0" "tbc\0" "clear_all_tabs\0" "clear\0" "clear_screen\0" \
-"el\0" "clr_eol\0" "ed\0" "clr_eos\0" "hpa\0" "column_address\0" "cmdch\0" \
-"command_character\0" "cup\0" "cursor_address\0" "cud1\0" "cursor_down\0" \
-"home\0" "cursor_home\0" "civis\0" "cursor_invisible\0" "cub1\0" "cursor_left\0" \
-"mrcup\0" "cursor_mem_address\0" "cnorm\0" "cursor_normal\0" "cuf1\0" "cursor_right\0" \
-"ll\0" "cursor_to_ll\0" "cuu1\0" "cursor_up\0" "cvvis\0" "cursor_visible\0" \
-"dch1\0" "delete_character\0" "dl1\0" "delete_line\0" "dsl\0" "dis_status_line\0" \
-"hd\0" "down_half_line\0" "smacs\0" "enter_alt_charset_mode\0" "blink\0" \
-"enter_blink_mode\0" "bold\0" "enter_bold_mode\0" "smcup\0" "enter_ca_mode\0" \
-"smdc\0" "enter_delete_mode\0" "dim\0" "enter_dim_mode\0" "smir\0" "enter_insert_mode\0" \
-"invis\0" "enter_secure_mode\0" "prot\0" "enter_protected_mode\0" "rev\0" \
-"enter_reverse_mode\0" "smso\0" "enter_standout_mode\0" "smul\0" "enter_underline_mode\0" \
-"ech\0" "erase_chars\0" "rmacs\0" "exit_alt_charset_mode\0" "sgr0\0" "exit_attribute_mode\0" \
-"rmcup\0" "exit_ca_mode\0" "rmdc\0" "exit_delete_mode\0" "rmir\0" "exit_insert_mode\0" \
-"rmso\0" "exit_standout_mode\0" "rmul\0" "exit_underline_mode\0" "flash\0" \
-"flash_screen\0" "ff\0" "form_feed\0" "fsl\0" "from_status_line\0" "is1\0" \
-"init_1string\0" "is2\0" "init_2string\0" "is3\0" "init_3string\0" "if\0" \
-"init_file\0" "ich1\0" "insert_character\0" "il1\0" "insert_line\0" "ip\0" \
-"insert_padding\0" "kbs\0" "key_backspace\0" "ktbc\0" "key_catab\0" "kclr\0" \
-"key_clear\0" "kctab\0" "key_ctab\0" "kdch1\0" "key_dc\0" "kdl1\0" "key_dl\0" \
-"kcud1\0" "key_down\0" "krmir\0" "key_eic\0" "kel\0" "key_eol\0" "ked\0" \
-"key_eos\0" "kf0\0" "key_f0\0" "kf1\0" "key_f1\0" "kf10\0" "key_f10\0" \
-"kf2\0" "key_f2\0" "kf3\0" "key_f3\0" "kf4\0" "key_f4\0" "kf5\0" "key_f5\0" \
-"kf6\0" "key_f6\0" "kf7\0" "key_f7\0" "kf8\0" "key_f8\0" "kf9\0" "key_f9\0" \
-"khome\0" "key_home\0" "kich1\0" "key_ic\0" "kil1\0" "key_il\0" "kcub1\0" \
-"key_left\0" "kll\0" "key_ll\0" "knp\0" "key_npage\0" "kpp\0" "key_ppage\0" \
-"kcuf1\0" "key_right\0" "kind\0" "key_sf\0" "kri\0" "key_sr\0" "khts\0" \
-"key_stab\0" "kcuu1\0" "key_up\0" "rmkx\0" "keypad_local\0" "smkx\0" "keypad_xmit\0" \
-"lf0\0" "lab_f0\0" "lf1\0" "lab_f1\0" "lf10\0" "lab_f10\0" "lf2\0" "lab_f2\0" \
-"lf3\0" "lab_f3\0" "lf4\0" "lab_f4\0" "lf5\0" "lab_f5\0" "lf6\0" "lab_f6\0" \
-"lf7\0" "lab_f7\0" "lf8\0" "lab_f8\0" "lf9\0" "lab_f9\0" "rmm\0" "meta_off\0" \
-"smm\0" "meta_on\0" "nel\0" "newline\0" "pad\0" "pad_char\0" "dch\0" "parm_dch\0" \
-"dl\0" "parm_delete_line\0" "cud\0" "parm_down_cursor\0" "ich\0" "parm_ich\0" \
-"indn\0" "parm_index\0" "il\0" "parm_insert_line\0" "cub\0" "parm_left_cursor\0" \
-"cuf\0" "parm_right_cursor\0" "rin\0" "parm_rindex\0" "cuu\0" "parm_up_cursor\0" \
-"pfkey\0" "pkey_key\0" "pfloc\0" "pkey_local\0" "pfx\0" "pkey_xmit\0" "mc0\0" \
-"print_screen\0" "mc4\0" "prtr_off\0" "mc5\0" "prtr_on\0" "rep\0" "repeat_char\0" \
-"rs1\0" "reset_1string\0" "rs2\0" "reset_2string\0" "rs3\0" "reset_3string\0" \
-"rf\0" "reset_file\0" "rc\0" "restore_cursor\0" "vpa\0" "row_address\0" \
-"sc\0" "save_cursor\0" "ind\0" "scroll_forward\0" "ri\0" "scroll_reverse\0" \
-"sgr\0" "set_attributes\0" "hts\0" "set_tab\0" "wind\0" "set_window\0" \
-"ht\0" "tab\0" "tsl\0" "to_status_line\0" "uc\0" "underline_char\0" "hu\0" \
-"up_half_line\0" "iprog\0" "init_prog\0" "ka1\0" "key_a1\0" "ka3\0" "key_a3\0" \
-"kb2\0" "key_b2\0" "kc1\0" "key_c1\0" "kc3\0" "key_c3\0" "mc5p\0" "prtr_non\0" \
-"rmp\0" "char_padding\0" "acsc\0" "acs_chars\0" "pln\0" "plab_norm\0" "kcbt\0" \
-"key_btab\0" "smxon\0" "enter_xon_mode\0" "rmxon\0" "exit_xon_mode\0" "smam\0" \
-"enter_am_mode\0" "rmam\0" "exit_am_mode\0" "xonc\0" "xon_character\0" \
-"xoffc\0" "xoff_character\0" "enacs\0" "ena_acs\0" "smln\0" "label_on\0" \
-"rmln\0" "label_off\0" "kbeg\0" "key_beg\0" "kcan\0" "key_cancel\0" "kclo\0" \
-"key_close\0" "kcmd\0" "key_command\0" "kcpy\0" "key_copy\0" "kcrt\0" "key_create\0" \
-"kend\0" "key_end\0" "kent\0" "key_enter\0" "kext\0" "key_exit\0" "kfnd\0" \
-"key_find\0" "khlp\0" "key_help\0" "kmrk\0" "key_mark\0" "kmsg\0" "key_message\0" \
-"kmov\0" "key_move\0" "knxt\0" "key_next\0" "kopn\0" "key_open\0" "kopt\0" \
-"key_options\0" "kprv\0" "key_previous\0" "kprt\0" "key_print\0" "krdo\0" \
-"key_redo\0" "kref\0" "key_reference\0" "krfr\0" "key_refresh\0" "krpl\0" \
-"key_replace\0" "krst\0" "key_restart\0" "kres\0" "key_resume\0" "ksav\0" \
-"key_save\0" "kspd\0" "key_suspend\0" "kund\0" "key_undo\0" "kBEG\0" "key_sbeg\0" \
-"kCAN\0" "key_scancel\0" "kCMD\0" "key_scommand\0" "kCPY\0" "key_scopy\0" \
-"kCRT\0" "key_screate\0" "kDC\0" "key_sdc\0" "kDL\0" "key_sdl\0" "kslt\0" \
-"key_select\0" "kEND\0" "key_send\0" "kEOL\0" "key_seol\0" "kEXT\0" "key_sexit\0" \
-"kFND\0" "key_sfind\0" "kHLP\0" "key_shelp\0" "kHOM\0" "key_shome\0" "kIC\0" \
-"key_sic\0" "kLFT\0" "key_sleft\0" "kMSG\0" "key_smessage\0" "kMOV\0" "key_smove\0" \
-"kNXT\0" "key_snext\0" "kOPT\0" "key_soptions\0" "kPRV\0" "key_sprevious\0" \
-"kPRT\0" "key_sprint\0" "kRDO\0" "key_sredo\0" "kRPL\0" "key_sreplace\0" \
-"kRIT\0" "key_sright\0" "kRES\0" "key_srsume\0" "kSAV\0" "key_ssave\0" \
-"kSPD\0" "key_ssuspend\0" "kUND\0" "key_sundo\0" "rfi\0" "req_for_input\0" \
-"kf11\0" "key_f11\0" "kf12\0" "key_f12\0" "kf13\0" "key_f13\0" "kf14\0" \
-"key_f14\0" "kf15\0" "key_f15\0" "kf16\0" "key_f16\0" "kf17\0" "key_f17\0" \
-"kf18\0" "key_f18\0" "kf19\0" "key_f19\0" "kf20\0" "key_f20\0" "kf21\0" \
-"key_f21\0" "kf22\0" "key_f22\0" "kf23\0" "key_f23\0" "kf24\0" "key_f24\0" \
-"kf25\0" "key_f25\0" "kf26\0" "key_f26\0" "kf27\0" "key_f27\0" "kf28\0" \
-"key_f28\0" "kf29\0" "key_f29\0" "kf30\0" "key_f30\0" "kf31\0" "key_f31\0" \
-"kf32\0" "key_f32\0" "kf33\0" "key_f33\0" "kf34\0" "key_f34\0" "kf35\0" \
-"key_f35\0" "kf36\0" "key_f36\0" "kf37\0" "key_f37\0" "kf38\0" "key_f38\0" \
-"kf39\0" "key_f39\0" "kf40\0" "key_f40\0" "kf41\0" "key_f41\0" "kf42\0" \
-"key_f42\0" "kf43\0" "key_f43\0" "kf44\0" "key_f44\0" "kf45\0" "key_f45\0" \
-"kf46\0" "key_f46\0" "kf47\0" "key_f47\0" "kf48\0" "key_f48\0" "kf49\0" \
-"key_f49\0" "kf50\0" "key_f50\0" "kf51\0" "key_f51\0" "kf52\0" "key_f52\0" \
-"kf53\0" "key_f53\0" "kf54\0" "key_f54\0" "kf55\0" "key_f55\0" "kf56\0" \
-"key_f56\0" "kf57\0" "key_f57\0" "kf58\0" "key_f58\0" "kf59\0" "key_f59\0" \
-"kf60\0" "key_f60\0" "kf61\0" "key_f61\0" "kf62\0" "key_f62\0" "kf63\0" \
-"key_f63\0" "el1\0" "clr_bol\0" "mgc\0" "clear_margins\0" "smgl\0" "set_left_margin\0" \
-"smgr\0" "set_right_margin\0" "fln\0" "label_format\0" "sclk\0" "set_clock\0" \
-"dclk\0" "display_clock\0" "rmclk\0" "remove_clock\0" "cwin\0" "create_window\0" \
-"wingo\0" "goto_window\0" "hup\0" "hangup\0" "dial\0" "dial_phone\0" "qdial\0" \
-"quick_dial\0" "tone\0" "tone\0" "pulse\0" "pulse\0" "hook\0" "flash_hook\0" \
-"pause\0" "fixed_pause\0" "wait\0" "wait_tone\0" "u0\0" "user0\0" "u1\0" \
-"user1\0" "u2\0" "user2\0" "u3\0" "user3\0" "u4\0" "user4\0" "u5\0" "user5\0" \
-"u6\0" "user6\0" "u7\0" "user7\0" "u8\0" "user8\0" "u9\0" "user9\0" "op\0" \
-"orig_pair\0" "oc\0" "orig_colors\0" "initc\0" "initialize_color\0" "initp\0" \
-"initialize_pair\0" "scp\0" "set_color_pair\0" "setf\0" "set_foreground\0" \
-"setb\0" "set_background\0" "cpi\0" "change_char_pitch\0" "lpi\0" "change_line_pitch\0" \
-"chr\0" "change_res_horz\0" "cvr\0" "change_res_vert\0" "defc\0" "define_char\0" \
-"swidm\0" "enter_doublewide_mode\0" "sdrfq\0" "enter_draft_quality\0" "sitm\0" \
-"enter_italics_mode\0" "slm\0" "enter_leftward_mode\0" "smicm\0" "enter_micro_mode\0" \
-"snlq\0" "enter_near_letter_quality\0" "snrmq\0" "enter_normal_quality\0" \
-"sshm\0" "enter_shadow_mode\0" "ssubm\0" "enter_subscript_mode\0" "ssupm\0" \
-"enter_superscript_mode\0" "sum\0" "enter_upward_mode\0" "rwidm\0" "exit_doublewide_mode\0" \
-"ritm\0" "exit_italics_mode\0" "rlm\0" "exit_leftward_mode\0" "rmicm\0" \
-"exit_micro_mode\0" "rshm\0" "exit_shadow_mode\0" "rsubm\0" "exit_subscript_mode\0" \
-"rsupm\0" "exit_superscript_mode\0" "rum\0" "exit_upward_mode\0" "mhpa\0" \
-"micro_column_address\0" "mcud1\0" "micro_down\0" "mcub1\0" "micro_left\0" \
-"mcuf1\0" "micro_right\0" "mvpa\0" "micro_row_address\0" "mcuu1\0" "micro_up\0" \
-"porder\0" "order_of_pins\0" "mcud\0" "parm_down_micro\0" "mcub\0" "parm_left_micro\0" \
-"mcuf\0" "parm_right_micro\0" "mcuu\0" "parm_up_micro\0" "scs\0" "select_char_set\0" \
-"smgb\0" "set_bottom_margin\0" "smgbp\0" "set_bottom_margin_parm\0" "smglp\0" \
-"set_left_margin_parm\0" "smgrp\0" "set_right_margin_parm\0" "smgt\0" "set_top_margin\0" \
-"smgtp\0" "set_top_margin_parm\0" "sbim\0" "start_bit_image\0" "scsd\0" \
-"start_char_set_def\0" "rbim\0" "stop_bit_image\0" "rcsd\0" "stop_char_set_def\0" \
-"subcs\0" "subscript_characters\0" "supcs\0" "superscript_characters\0" \
-"docr\0" "these_cause_cr\0" "zerom\0" "zero_motion\0" "csnm\0" "char_set_names\0" \
-"kmous\0" "key_mouse\0" "minfo\0" "mouse_info\0" "reqmp\0" "req_mouse_pos\0" \
-"getm\0" "get_mouse\0" "setaf\0" "set_a_foreground\0" "setab\0" "set_a_background\0" \
-"pfxl\0" "pkey_plab\0" "devt\0" "device_type\0" "csin\0" "code_set_init\0" \
-"s0ds\0" "set0_des_seq\0" "s1ds\0" "set1_des_seq\0" "s2ds\0" "set2_des_seq\0" \
-"s3ds\0" "set3_des_seq\0" "smglr\0" "set_lr_margin\0" "smgtb\0" "set_tb_margin\0" \
-"birep\0" "bit_image_repeat\0" "binel\0" "bit_image_newline\0" "bicr\0" \
-"bit_image_carriage_return\0" "colornm\0" "color_names\0" "defbi\0" "define_bit_image_region\0" \
-"endbi\0" "end_bit_image_region\0" "setcolor\0" "set_color_band\0" "slines\0" \
-"set_page_length\0" "dispc\0" "display_pc_char\0" "smpch\0" "enter_pc_charset_mode\0" \
-"rmpch\0" "exit_pc_charset_mode\0" "smsc\0" "enter_scancode_mode\0" "rmsc\0" \
-"exit_scancode_mode\0" "pctrm\0" "pc_term_options\0" "scesc\0" "scancode_escape\0" \
-"scesa\0" "alt_scancode_esc\0" "ehhlm\0" "enter_horizontal_hl_mode\0" "elhlm\0" \
-"enter_left_hl_mode\0" "elohlm\0" "enter_low_hl_mode\0" "erhlm\0" "enter_right_hl_mode\0" \
-"ethlm\0" "enter_top_hl_mode\0" "evhlm\0" "enter_vertical_hl_mode\0" "sgr1\0" \
-"set_a_attributes\0" "slength\0" "set_pglen_inch\0" "OTi2\0" "termcap_init2\0" \
-"OTrs\0" "termcap_reset\0" "OTug\0" "magic_cookie_glitch_ul\0" "OTbs\0" \
-"backspaces_with_bs\0" "OTns\0" "crt_no_scrolling\0" "OTnc\0" "no_correctly_working_cr\0" \
-"OTdC\0" "carriage_return_delay\0" "OTdN\0" "new_line_delay\0" "OTnl\0" \
-"linefeed_if_not_lf\0" "OTbc\0" "backspace_if_not_bs\0" "OTMT\0" "gnu_has_meta_key\0" \
-"OTNL\0" "linefeed_is_newline\0" "OTdB\0" "backspace_delay\0" "OTdT\0" \
-"horizontal_tab_delay\0" "OTkn\0" "number_of_function_keys\0" "OTko\0" \
-"other_non_function_keys\0" "OTma\0" "arrow_key_map\0" "OTpt\0" "has_hardware_tabs\0" \
-"OTxr\0" "return_does_clr_eol\0" "OTG2\0" "acs_ulcorner\0" "OTG3\0" "acs_llcorner\0" \
-"OTG1\0" "acs_urcorner\0" "OTG4\0" "acs_lrcorner\0" "OTGR\0" "acs_ltee\0" \
-"OTGL\0" "acs_rtee\0" "OTGU\0" "acs_btee\0" "OTGD\0" "acs_ttee\0" "OTGH\0" \
-"acs_hline\0" "OTGV\0" "acs_vline\0" "OTGC\0" "acs_plus\0" "meml\0" "memory_lock\0" \
-"memu\0" "memory_unlock\0" "box1\0" "box_chars_1\0" ;
-static const short _nc_offset_boolfnames[] = {
-3, 23, 45, 61, 87, 109, 129,
-145, 158, 174, 193, 215, 231,
-248, 270, 292, 310, 332, 356,
-372, 398, 412, 432, 449, 467,
-485, 503, 530, 545, 566, 596,
-617, 645, 666, 686, 714, 735,
-8193, 8217, 8239, 8364, 8386, 8535, 8558, };
-
-static NCURSES_CONST char ** ptr_boolfnames = 0;
-
-static const short _nc_offset_boolnames[] = {
-0, 20, 41, 57, 82, 106, 126, 142, 155, 171, 190, 212, 228, 244, 265, 289, 304, 329, 353, 369, 394, 407, 427, 444, 461, 481, 497, 526, 541, 562, 591, 612, 639, 661, 682, 709, 730, 8188, 8212, 8234, 8359, 8381, 8530, 8553, };
-
-static NCURSES_CONST char ** ptr_boolnames = 0;
-
-static const short _nc_offset_numfnames[] = {
-756, 767, 783, 792, 812, 835,
-856, 877, 900, 914, 930, 945,
-965, 988, 1005, 1019, 1040, 1062, 1085, 1108, 1132, 1151, 1170,
-1192, 1211, 1231, 1252, 1278, 1303, 1320, 1340, 1355, 1382, 8165,
-8268, 8295, 8411, 8432,
-8458, };
-
-static NCURSES_CONST char ** ptr_numfnames = 0;
-
-static const short _nc_offset_numnames[] = {
-751, 764, 777, 789, 808, 832, 853, 873, 895, 911, 927, 942, 960, 981, 999, 1015, 1034, 1056,
-1079, 1102, 1126, 1147, 1166, 1186, 1207, 1227, 1247, 1273, 1299,
-1314, 1335, 1348, 1375, 8160, 8263, 8290, 8406, 8427, 8453, };
-
-static NCURSES_CONST char ** ptr_numnames = 0;
-
-static const short _nc_offset_strfnames[] = {
-1401,
-1414, 1422, 1442, 1467, 1488, 1504, 1515, 1527, 1548, 1570, 1590,
-1607, 1625, 1647, 1665, 1690, 1709, 1725, 1743, 1759, 1779, 1800,
-1816, 1835, 1856, 1885, 1907, 1929, 1948, 1970, 1990, 2014, 2037,
-2062, 2086, 2111, 2136, 2154, 2181, 2207, 2225, 2247, 2269, 2293,
-2319, 2335, 2349, 2370, 2387, 2404, 2420, 2435, 2456, 2471, 2490,
-2509, 2524, 2540, 2555, 2567, 2580, 2595, 2607, 2619, 2631, 2642,
-2654, 2666, 2677, 2688, 2699, 2710, 2721, 2732, 2743, 2756, 2771,
-2783, 2796, 2809, 2820, 2834, 2850, 2865, 2876, 2888, 2903, 2915,
-2933, 2949, 2960, 2972, 2984, 2995, 3006, 3017, 3028, 3039, 3050,
-3061, 3072, 3085, 3097, 3109, 3122, 3134, 3155, 3176, 3190, 3204,
-3225, 3246, 3268, 3284, 3305, 3320, 3335, 3349, 3366, 3379, 3391,
-3407, 3425, 3443, 3460, 3474, 3493, 3508, 3524, 3542, 3561, 3580,
-3593, 3607, 3615, 3633, 3651, 3670, 3684, 3695, 3706, 3717, 3728,
-3740, 3753, 3771, 3785, 3800, 3815, 3836, 3855, 3874, 3892, 3912,
-3933, 3946, 3960, 3975, 3988, 4004, 4019, 4036, 4050, 4066, 4079,
-4094, 4108, 4122, 4136, 4150, 4167, 4181, 4195, 4209, 4226, 4244,
-4259, 4273, 4292, 4309, 4326, 4343, 4359, 4373, 4390, 4404, 4418,
-4435, 4453, 4468, 4484, 4496, 4509, 4525, 4539, 4553, 4568, 4583,
-4598, 4612, 4625, 4640, 4658, 4673, 4688, 4706, 4725, 4741, 4756,
-4774, 4790, 4806, 4821, 4839, 4853, 4872, 4885, 4898, 4911, 4924,
-4937, 4950, 4963, 4976, 4989, 5002, 5015, 5028, 5041, 5054, 5067,
-5080, 5093, 5106, 5119, 5132, 5145, 5158, 5171, 5184, 5197, 5210,
-5223, 5236, 5249, 5262, 5275, 5288, 5301, 5314, 5327, 5340, 5353,
-5366, 5379, 5392, 5405, 5418, 5431, 5444, 5457, 5470, 5483, 5496,
-5509, 5522, 5535, 5548, 5560, 5572, 5591, 5612, 5633, 5651, 5666,
-5686, 5704, 5724, 5740, 5752, 5769, 5785, 5796, 5807, 5824, 5841,
-5854, 5863, 5872, 5881, 5890, 5899, 5908, 5917, 5926, 5935, 5944,
-5957, 5975, 5998, 6018, 6038, 6058, 6077, 6099, 6121, 6141, 6162,
-6180, 6208, 6233, 6256, 6282, 6304, 6336, 6362, 6386, 6413, 6440,
-6464, 6490, 6512, 6537, 6558, 6581, 6607, 6633, 6655, 6682, 6699,
-6716, 6733, 6757, 6773, 6792, 6813, 6834, 6856, 6874, 6895, 6919,
-6948, 6975, 7002, 7023, 7048, 7069, 7093, 7113, 7137, 7164, 7192,
-7213, 7230, 7251, 7267, 7284, 7303, 7319, 7342, 7364, 7379, 7396,
-7415, 7433, 7451, 7469, 7488, 7508, 7528, 7551, 7574, 7608, 7626,
-7656, 7686, 7708, 7730, 7752, 7780, 7806, 7831, 7856, 7878, 7900,
-7923, 7954, 7980, 8004, 8030, 8054, 8082, 8107, 8127, 8146, 8315, 8339, 8487, 8516, 8583, 8601, 8619, 8637, 8655, 8669,
-8683, 8697, 8711, 8726, 8741, 8755, 8772, 8791, };
-
-static NCURSES_CONST char ** ptr_strfnames = 0;
-
-static const short _nc_offset_strnames[] = {
-1397, 1410, 1419, 1438, 1463, 1482, 1501,
-1512, 1523, 1542, 1566, 1585, 1602, 1619, 1642, 1659, 1684, 1704,
-1722, 1738, 1753, 1774, 1796, 1812, 1832, 1850, 1879, 1902, 1923,
-1943, 1966, 1985, 2008, 2032, 2058, 2081, 2106, 2132, 2148, 2176,
-2201, 2220, 2242, 2264, 2288, 2313, 2332, 2345, 2366, 2383, 2400,
-2417, 2430, 2452, 2468, 2486, 2504, 2519, 2534, 2549, 2562, 2574,
-2589, 2603, 2615, 2627, 2638, 2649, 2662, 2673, 2684, 2695, 2706,
-2717, 2728, 2739, 2750, 2765, 2778, 2790, 2805, 2816, 2830, 2844,
-2860, 2872, 2883, 2897, 2910, 2928, 2945, 2956, 2967, 2980, 2991,
-3002, 3013, 3024, 3035, 3046, 3057, 3068, 3081, 3093, 3105, 3118,
-3131, 3151, 3172, 3185, 3201, 3221, 3242, 3264, 3280, 3299, 3314,
-3331, 3345, 3362, 3375, 3387, 3403, 3421, 3439, 3457, 3471, 3489,
-3505, 3520, 3539, 3557, 3576, 3588, 3604, 3611, 3630, 3648, 3664,
-3680, 3691, 3702, 3713, 3724, 3735, 3749, 3766, 3781, 3795, 3809,
-3830, 3850, 3869, 3887, 3906, 3927, 3941, 3955, 3970, 3983, 3999,
-4014, 4031, 4045, 4061, 4074, 4089, 4103, 4117, 4131, 4145, 4162,
-4176, 4190, 4204, 4221, 4239, 4254, 4268, 4287, 4304, 4321, 4338,
-4354, 4368, 4385, 4399, 4413, 4430, 4448, 4463, 4480, 4492, 4504,
-4520, 4534, 4548, 4563, 4578, 4593, 4608, 4620, 4635, 4653, 4668,
-4683, 4701, 4720, 4736, 4751, 4769, 4785, 4801, 4816, 4834, 4849,
-4867, 4880, 4893, 4906, 4919, 4932, 4945, 4958, 4971, 4984, 4997,
-5010, 5023, 5036, 5049, 5062, 5075, 5088, 5101, 5114, 5127, 5140,
-5153, 5166, 5179, 5192, 5205, 5218, 5231, 5244, 5257, 5270, 5283,
-5296, 5309, 5322, 5335, 5348, 5361, 5374, 5387, 5400, 5413, 5426,
-5439, 5452, 5465, 5478, 5491, 5504, 5517, 5530, 5543, 5556, 5568,
-5586, 5607, 5629, 5646, 5661, 5680, 5699, 5718, 5736, 5747, 5763,
-5780, 5790, 5802, 5818, 5836, 5851, 5860, 5869, 5878, 5887, 5896,
-5905, 5914, 5923, 5932, 5941, 5954, 5969, 5992, 6014, 6033, 6053,
-6073, 6095, 6117, 6137, 6157, 6174, 6202, 6228, 6252, 6276, 6299,
-6330, 6357, 6380, 6407, 6436, 6458, 6485, 6508, 6531, 6553, 6575,
-6601, 6629, 6650, 6676, 6693, 6710, 6728, 6751, 6766, 6787, 6808,
-6829, 6851, 6870, 6890, 6913, 6942, 6969, 6997, 7017, 7043, 7064,
-7088, 7108, 7131, 7158, 7187, 7207, 7225, 7245, 7261, 7278, 7298,
-7313, 7336, 7359, 7374, 7391, 7410, 7428, 7446, 7464, 7482, 7502,
-7522, 7545, 7569, 7600, 7620, 7650, 7677, 7701, 7724, 7746, 7774,
-7801, 7826, 7850, 7872, 7894, 7917, 7948, 7973, 7998, 8024, 8048,
-8077, 8099, 8122, 8141, 8310,
-8334, 8482, 8511, 8578,
-8596, 8614, 8632, 8650, 8664, 8678, 8692, 8706, 8721, 8736, 8750,
-8767, 8786, };
-
-static NCURSES_CONST char ** ptr_strnames = 0;
-
-
-static IT *
-alloc_array(NCURSES_CONST char ***value, const short *offsets, unsigned size)
-{
-	if (*value == 0) {
-		if ((*value = typeCalloc(NCURSES_CONST char *, size + 1)) != 0) {
-			unsigned n;
-			for (n = 0; n < size; ++n) {
-				(*value)[n] = (NCURSES_CONST char *) _nc_name_blob + offsets[n];
-			}
-		}
-	}
-	return *value;
-}
-
-#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API NCURSES_PUBLIC_VAR(it)(void) { return alloc_array(&ptr_##it, _nc_offset_##it, SIZEOF(_nc_offset_##it)); }
-
-/* remove public definition which conflicts with FIX() */
-#undef boolnames
-#undef boolfnames
-#undef numnames
-#undef numfnames
-#undef strnames
-#undef strfnames
-
-/* add local definition */
-FIX(boolnames)
-FIX(boolfnames)
-FIX(numnames)
-FIX(numfnames)
-FIX(strnames)
-FIX(strfnames)
-
-/* restore the public definition */
-#define boolnames  NCURSES_PUBLIC_VAR(boolnames())
-#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())
-#define numnames   NCURSES_PUBLIC_VAR(numnames())
-#define numfnames  NCURSES_PUBLIC_VAR(numfnames())
-#define strnames   NCURSES_PUBLIC_VAR(strnames())
-#define strfnames  NCURSES_PUBLIC_VAR(strfnames())
-
-#define FREE_FIX(it) if (ptr_##it) { FreeAndNull(ptr_##it); }
-
-#if NO_LEAKS
-NCURSES_EXPORT(void)
-_nc_names_leaks(void)
-{
-FREE_FIX(boolnames)
-FREE_FIX(boolfnames)
-FREE_FIX(numnames)
-FREE_FIX(numfnames)
-FREE_FIX(strnames)
-FREE_FIX(strfnames)
-}
-#endif
-
-#else
-
-#define DCL(it) NCURSES_EXPORT_VAR(IT) it[]
-
-DCL(boolnames) = {
-		"bw",
-		"am",
-		"xsb",
-		"xhp",
-		"xenl",
-		"eo",
-		"gn",
-		"hc",
-		"km",
-		"hs",
-		"in",
-		"da",
-		"db",
-		"mir",
-		"msgr",
-		"os",
-		"eslok",
-		"xt",
-		"hz",
-		"ul",
-		"xon",
-		"nxon",
-		"mc5i",
-		"chts",
-		"nrrmc",
-		"npc",
-		"ndscr",
-		"ccc",
-		"bce",
-		"hls",
-		"xhpa",
-		"crxm",
-		"daisy",
-		"xvpa",
-		"sam",
-		"cpix",
-		"lpix",
-		"OTbs",
-		"OTns",
-		"OTnc",
-		"OTMT",
-		"OTNL",
-		"OTpt",
-		"OTxr",
-
-		(NCURSES_CONST char *)0,
-};
-
-DCL(boolfnames) = {
-		"auto_left_margin",
-		"auto_right_margin",
-		"no_esc_ctlc",
-		"ceol_standout_glitch",
-		"eat_newline_glitch",
-		"erase_overstrike",
-		"generic_type",
-		"hard_copy",
-		"has_meta_key",
-		"has_status_line",
-		"insert_null_glitch",
-		"memory_above",
-		"memory_below",
-		"move_insert_mode",
-		"move_standout_mode",
-		"over_strike",
-		"status_line_esc_ok",
-		"dest_tabs_magic_smso",
-		"tilde_glitch",
-		"transparent_underline",
-		"xon_xoff",
-		"needs_xon_xoff",
-		"prtr_silent",
-		"hard_cursor",
-		"non_rev_rmcup",
-		"no_pad_char",
-		"non_dest_scroll_region",
-		"can_change",
-		"back_color_erase",
-		"hue_lightness_saturation",
-		"col_addr_glitch",
-		"cr_cancels_micro_mode",
-		"has_print_wheel",
-		"row_addr_glitch",
-		"semi_auto_right_margin",
-		"cpi_changes_res",
-		"lpi_changes_res",
-		"backspaces_with_bs",
-		"crt_no_scrolling",
-		"no_correctly_working_cr",
-		"gnu_has_meta_key",
-		"linefeed_is_newline",
-		"has_hardware_tabs",
-		"return_does_clr_eol",
-
-		(NCURSES_CONST char *)0,
-};
-
-DCL(numnames) = {
-		"cols",
-		"it",
-		"lines",
-		"lm",
-		"xmc",
-		"pb",
-		"vt",
-		"wsl",
-		"nlab",
-		"lh",
-		"lw",
-		"ma",
-		"wnum",
-		"colors",
-		"pairs",
-		"ncv",
-		"bufsz",
-		"spinv",
-		"spinh",
-		"maddr",
-		"mjump",
-		"mcs",
-		"mls",
-		"npins",
-		"orc",
-		"orl",
-		"orhi",
-		"orvi",
-		"cps",
-		"widcs",
-		"btns",
-		"bitwin",
-		"bitype",
-		"OTug",
-		"OTdC",
-		"OTdN",
-		"OTdB",
-		"OTdT",
-		"OTkn",
-
-		(NCURSES_CONST char *)0,
-};
-
-DCL(numfnames) = {
-		"columns",
-		"init_tabs",
-		"lines",
-		"lines_of_memory",
-		"magic_cookie_glitch",
-		"padding_baud_rate",
-		"virtual_terminal",
-		"width_status_line",
-		"num_labels",
-		"label_height",
-		"label_width",
-		"max_attributes",
-		"maximum_windows",
-		"max_colors",
-		"max_pairs",
-		"no_color_video",
-		"buffer_capacity",
-		"dot_vert_spacing",
-		"dot_horz_spacing",
-		"max_micro_address",
-		"max_micro_jump",
-		"micro_col_size",
-		"micro_line_size",
-		"number_of_pins",
-		"output_res_char",
-		"output_res_line",
-		"output_res_horz_inch",
-		"output_res_vert_inch",
-		"print_rate",
-		"wide_char_size",
-		"buttons",
-		"bit_image_entwining",
-		"bit_image_type",
-		"magic_cookie_glitch_ul",
-		"carriage_return_delay",
-		"new_line_delay",
-		"backspace_delay",
-		"horizontal_tab_delay",
-		"number_of_function_keys",
-
-		(NCURSES_CONST char *)0,
-};
-
-DCL(strnames) = {
-		"cbt",
-		"bel",
-		"cr",
-		"csr",
-		"tbc",
-		"clear",
-		"el",
-		"ed",
-		"hpa",
-		"cmdch",
-		"cup",
-		"cud1",
-		"home",
-		"civis",
-		"cub1",
-		"mrcup",
-		"cnorm",
-		"cuf1",
-		"ll",
-		"cuu1",
-		"cvvis",
-		"dch1",
-		"dl1",
-		"dsl",
-		"hd",
-		"smacs",
-		"blink",
-		"bold",
-		"smcup",
-		"smdc",
-		"dim",
-		"smir",
-		"invis",
-		"prot",
-		"rev",
-		"smso",
-		"smul",
-		"ech",
-		"rmacs",
-		"sgr0",
-		"rmcup",
-		"rmdc",
-		"rmir",
-		"rmso",
-		"rmul",
-		"flash",
-		"ff",
-		"fsl",
-		"is1",
-		"is2",
-		"is3",
-		"if",
-		"ich1",
-		"il1",
-		"ip",
-		"kbs",
-		"ktbc",
-		"kclr",
-		"kctab",
-		"kdch1",
-		"kdl1",
-		"kcud1",
-		"krmir",
-		"kel",
-		"ked",
-		"kf0",
-		"kf1",
-		"kf10",
-		"kf2",
-		"kf3",
-		"kf4",
-		"kf5",
-		"kf6",
-		"kf7",
-		"kf8",
-		"kf9",
-		"khome",
-		"kich1",
-		"kil1",
-		"kcub1",
-		"kll",
-		"knp",
-		"kpp",
-		"kcuf1",
-		"kind",
-		"kri",
-		"khts",
-		"kcuu1",
-		"rmkx",
-		"smkx",
-		"lf0",
-		"lf1",
-		"lf10",
-		"lf2",
-		"lf3",
-		"lf4",
-		"lf5",
-		"lf6",
-		"lf7",
-		"lf8",
-		"lf9",
-		"rmm",
-		"smm",
-		"nel",
-		"pad",
-		"dch",
-		"dl",
-		"cud",
-		"ich",
-		"indn",
-		"il",
-		"cub",
-		"cuf",
-		"rin",
-		"cuu",
-		"pfkey",
-		"pfloc",
-		"pfx",
-		"mc0",
-		"mc4",
-		"mc5",
-		"rep",
-		"rs1",
-		"rs2",
-		"rs3",
-		"rf",
-		"rc",
-		"vpa",
-		"sc",
-		"ind",
-		"ri",
-		"sgr",
-		"hts",
-		"wind",
-		"ht",
-		"tsl",
-		"uc",
-		"hu",
-		"iprog",
-		"ka1",
-		"ka3",
-		"kb2",
-		"kc1",
-		"kc3",
-		"mc5p",
-		"rmp",
-		"acsc",
-		"pln",
-		"kcbt",
-		"smxon",
-		"rmxon",
-		"smam",
-		"rmam",
-		"xonc",
-		"xoffc",
-		"enacs",
-		"smln",
-		"rmln",
-		"kbeg",
-		"kcan",
-		"kclo",
-		"kcmd",
-		"kcpy",
-		"kcrt",
-		"kend",
-		"kent",
-		"kext",
-		"kfnd",
-		"khlp",
-		"kmrk",
-		"kmsg",
-		"kmov",
-		"knxt",
-		"kopn",
-		"kopt",
-		"kprv",
-		"kprt",
-		"krdo",
-		"kref",
-		"krfr",
-		"krpl",
-		"krst",
-		"kres",
-		"ksav",
-		"kspd",
-		"kund",
-		"kBEG",
-		"kCAN",
-		"kCMD",
-		"kCPY",
-		"kCRT",
-		"kDC",
-		"kDL",
-		"kslt",
-		"kEND",
-		"kEOL",
-		"kEXT",
-		"kFND",
-		"kHLP",
-		"kHOM",
-		"kIC",
-		"kLFT",
-		"kMSG",
-		"kMOV",
-		"kNXT",
-		"kOPT",
-		"kPRV",
-		"kPRT",
-		"kRDO",
-		"kRPL",
-		"kRIT",
-		"kRES",
-		"kSAV",
-		"kSPD",
-		"kUND",
-		"rfi",
-		"kf11",
-		"kf12",
-		"kf13",
-		"kf14",
-		"kf15",
-		"kf16",
-		"kf17",
-		"kf18",
-		"kf19",
-		"kf20",
-		"kf21",
-		"kf22",
-		"kf23",
-		"kf24",
-		"kf25",
-		"kf26",
-		"kf27",
-		"kf28",
-		"kf29",
-		"kf30",
-		"kf31",
-		"kf32",
-		"kf33",
-		"kf34",
-		"kf35",
-		"kf36",
-		"kf37",
-		"kf38",
-		"kf39",
-		"kf40",
-		"kf41",
-		"kf42",
-		"kf43",
-		"kf44",
-		"kf45",
-		"kf46",
-		"kf47",
-		"kf48",
-		"kf49",
-		"kf50",
-		"kf51",
-		"kf52",
-		"kf53",
-		"kf54",
-		"kf55",
-		"kf56",
-		"kf57",
-		"kf58",
-		"kf59",
-		"kf60",
-		"kf61",
-		"kf62",
-		"kf63",
-		"el1",
-		"mgc",
-		"smgl",
-		"smgr",
-		"fln",
-		"sclk",
-		"dclk",
-		"rmclk",
-		"cwin",
-		"wingo",
-		"hup",
-		"dial",
-		"qdial",
-		"tone",
-		"pulse",
-		"hook",
-		"pause",
-		"wait",
-		"u0",
-		"u1",
-		"u2",
-		"u3",
-		"u4",
-		"u5",
-		"u6",
-		"u7",
-		"u8",
-		"u9",
-		"op",
-		"oc",
-		"initc",
-		"initp",
-		"scp",
-		"setf",
-		"setb",
-		"cpi",
-		"lpi",
-		"chr",
-		"cvr",
-		"defc",
-		"swidm",
-		"sdrfq",
-		"sitm",
-		"slm",
-		"smicm",
-		"snlq",
-		"snrmq",
-		"sshm",
-		"ssubm",
-		"ssupm",
-		"sum",
-		"rwidm",
-		"ritm",
-		"rlm",
-		"rmicm",
-		"rshm",
-		"rsubm",
-		"rsupm",
-		"rum",
-		"mhpa",
-		"mcud1",
-		"mcub1",
-		"mcuf1",
-		"mvpa",
-		"mcuu1",
-		"porder",
-		"mcud",
-		"mcub",
-		"mcuf",
-		"mcuu",
-		"scs",
-		"smgb",
-		"smgbp",
-		"smglp",
-		"smgrp",
-		"smgt",
-		"smgtp",
-		"sbim",
-		"scsd",
-		"rbim",
-		"rcsd",
-		"subcs",
-		"supcs",
-		"docr",
-		"zerom",
-		"csnm",
-		"kmous",
-		"minfo",
-		"reqmp",
-		"getm",
-		"setaf",
-		"setab",
-		"pfxl",
-		"devt",
-		"csin",
-		"s0ds",
-		"s1ds",
-		"s2ds",
-		"s3ds",
-		"smglr",
-		"smgtb",
-		"birep",
-		"binel",
-		"bicr",
-		"colornm",
-		"defbi",
-		"endbi",
-		"setcolor",
-		"slines",
-		"dispc",
-		"smpch",
-		"rmpch",
-		"smsc",
-		"rmsc",
-		"pctrm",
-		"scesc",
-		"scesa",
-		"ehhlm",
-		"elhlm",
-		"elohlm",
-		"erhlm",
-		"ethlm",
-		"evhlm",
-		"sgr1",
-		"slength",
-		"OTi2",
-		"OTrs",
-		"OTnl",
-		"OTbc",
-		"OTko",
-		"OTma",
-		"OTG2",
-		"OTG3",
-		"OTG1",
-		"OTG4",
-		"OTGR",
-		"OTGL",
-		"OTGU",
-		"OTGD",
-		"OTGH",
-		"OTGV",
-		"OTGC",
-		"meml",
-		"memu",
-		"box1",
-
-		(NCURSES_CONST char *)0,
-};
-
-DCL(strfnames) = {
-		"back_tab",
-		"bell",
-		"carriage_return",
-		"change_scroll_region",
-		"clear_all_tabs",
-		"clear_screen",
-		"clr_eol",
-		"clr_eos",
-		"column_address",
-		"command_character",
-		"cursor_address",
-		"cursor_down",
-		"cursor_home",
-		"cursor_invisible",
-		"cursor_left",
-		"cursor_mem_address",
-		"cursor_normal",
-		"cursor_right",
-		"cursor_to_ll",
-		"cursor_up",
-		"cursor_visible",
-		"delete_character",
-		"delete_line",
-		"dis_status_line",
-		"down_half_line",
-		"enter_alt_charset_mode",
-		"enter_blink_mode",
-		"enter_bold_mode",
-		"enter_ca_mode",
-		"enter_delete_mode",
-		"enter_dim_mode",
-		"enter_insert_mode",
-		"enter_secure_mode",
-		"enter_protected_mode",
-		"enter_reverse_mode",
-		"enter_standout_mode",
-		"enter_underline_mode",
-		"erase_chars",
-		"exit_alt_charset_mode",
-		"exit_attribute_mode",
-		"exit_ca_mode",
-		"exit_delete_mode",
-		"exit_insert_mode",
-		"exit_standout_mode",
-		"exit_underline_mode",
-		"flash_screen",
-		"form_feed",
-		"from_status_line",
-		"init_1string",
-		"init_2string",
-		"init_3string",
-		"init_file",
-		"insert_character",
-		"insert_line",
-		"insert_padding",
-		"key_backspace",
-		"key_catab",
-		"key_clear",
-		"key_ctab",
-		"key_dc",
-		"key_dl",
-		"key_down",
-		"key_eic",
-		"key_eol",
-		"key_eos",
-		"key_f0",
-		"key_f1",
-		"key_f10",
-		"key_f2",
-		"key_f3",
-		"key_f4",
-		"key_f5",
-		"key_f6",
-		"key_f7",
-		"key_f8",
-		"key_f9",
-		"key_home",
-		"key_ic",
-		"key_il",
-		"key_left",
-		"key_ll",
-		"key_npage",
-		"key_ppage",
-		"key_right",
-		"key_sf",
-		"key_sr",
-		"key_stab",
-		"key_up",
-		"keypad_local",
-		"keypad_xmit",
-		"lab_f0",
-		"lab_f1",
-		"lab_f10",
-		"lab_f2",
-		"lab_f3",
-		"lab_f4",
-		"lab_f5",
-		"lab_f6",
-		"lab_f7",
-		"lab_f8",
-		"lab_f9",
-		"meta_off",
-		"meta_on",
-		"newline",
-		"pad_char",
-		"parm_dch",
-		"parm_delete_line",
-		"parm_down_cursor",
-		"parm_ich",
-		"parm_index",
-		"parm_insert_line",
-		"parm_left_cursor",
-		"parm_right_cursor",
-		"parm_rindex",
-		"parm_up_cursor",
-		"pkey_key",
-		"pkey_local",
-		"pkey_xmit",
-		"print_screen",
-		"prtr_off",
-		"prtr_on",
-		"repeat_char",
-		"reset_1string",
-		"reset_2string",
-		"reset_3string",
-		"reset_file",
-		"restore_cursor",
-		"row_address",
-		"save_cursor",
-		"scroll_forward",
-		"scroll_reverse",
-		"set_attributes",
-		"set_tab",
-		"set_window",
-		"tab",
-		"to_status_line",
-		"underline_char",
-		"up_half_line",
-		"init_prog",
-		"key_a1",
-		"key_a3",
-		"key_b2",
-		"key_c1",
-		"key_c3",
-		"prtr_non",
-		"char_padding",
-		"acs_chars",
-		"plab_norm",
-		"key_btab",
-		"enter_xon_mode",
-		"exit_xon_mode",
-		"enter_am_mode",
-		"exit_am_mode",
-		"xon_character",
-		"xoff_character",
-		"ena_acs",
-		"label_on",
-		"label_off",
-		"key_beg",
-		"key_cancel",
-		"key_close",
-		"key_command",
-		"key_copy",
-		"key_create",
-		"key_end",
-		"key_enter",
-		"key_exit",
-		"key_find",
-		"key_help",
-		"key_mark",
-		"key_message",
-		"key_move",
-		"key_next",
-		"key_open",
-		"key_options",
-		"key_previous",
-		"key_print",
-		"key_redo",
-		"key_reference",
-		"key_refresh",
-		"key_replace",
-		"key_restart",
-		"key_resume",
-		"key_save",
-		"key_suspend",
-		"key_undo",
-		"key_sbeg",
-		"key_scancel",
-		"key_scommand",
-		"key_scopy",
-		"key_screate",
-		"key_sdc",
-		"key_sdl",
-		"key_select",
-		"key_send",
-		"key_seol",
-		"key_sexit",
-		"key_sfind",
-		"key_shelp",
-		"key_shome",
-		"key_sic",
-		"key_sleft",
-		"key_smessage",
-		"key_smove",
-		"key_snext",
-		"key_soptions",
-		"key_sprevious",
-		"key_sprint",
-		"key_sredo",
-		"key_sreplace",
-		"key_sright",
-		"key_srsume",
-		"key_ssave",
-		"key_ssuspend",
-		"key_sundo",
-		"req_for_input",
-		"key_f11",
-		"key_f12",
-		"key_f13",
-		"key_f14",
-		"key_f15",
-		"key_f16",
-		"key_f17",
-		"key_f18",
-		"key_f19",
-		"key_f20",
-		"key_f21",
-		"key_f22",
-		"key_f23",
-		"key_f24",
-		"key_f25",
-		"key_f26",
-		"key_f27",
-		"key_f28",
-		"key_f29",
-		"key_f30",
-		"key_f31",
-		"key_f32",
-		"key_f33",
-		"key_f34",
-		"key_f35",
-		"key_f36",
-		"key_f37",
-		"key_f38",
-		"key_f39",
-		"key_f40",
-		"key_f41",
-		"key_f42",
-		"key_f43",
-		"key_f44",
-		"key_f45",
-		"key_f46",
-		"key_f47",
-		"key_f48",
-		"key_f49",
-		"key_f50",
-		"key_f51",
-		"key_f52",
-		"key_f53",
-		"key_f54",
-		"key_f55",
-		"key_f56",
-		"key_f57",
-		"key_f58",
-		"key_f59",
-		"key_f60",
-		"key_f61",
-		"key_f62",
-		"key_f63",
-		"clr_bol",
-		"clear_margins",
-		"set_left_margin",
-		"set_right_margin",
-		"label_format",
-		"set_clock",
-		"display_clock",
-		"remove_clock",
-		"create_window",
-		"goto_window",
-		"hangup",
-		"dial_phone",
-		"quick_dial",
-		"tone",
-		"pulse",
-		"flash_hook",
-		"fixed_pause",
-		"wait_tone",
-		"user0",
-		"user1",
-		"user2",
-		"user3",
-		"user4",
-		"user5",
-		"user6",
-		"user7",
-		"user8",
-		"user9",
-		"orig_pair",
-		"orig_colors",
-		"initialize_color",
-		"initialize_pair",
-		"set_color_pair",
-		"set_foreground",
-		"set_background",
-		"change_char_pitch",
-		"change_line_pitch",
-		"change_res_horz",
-		"change_res_vert",
-		"define_char",
-		"enter_doublewide_mode",
-		"enter_draft_quality",
-		"enter_italics_mode",
-		"enter_leftward_mode",
-		"enter_micro_mode",
-		"enter_near_letter_quality",
-		"enter_normal_quality",
-		"enter_shadow_mode",
-		"enter_subscript_mode",
-		"enter_superscript_mode",
-		"enter_upward_mode",
-		"exit_doublewide_mode",
-		"exit_italics_mode",
-		"exit_leftward_mode",
-		"exit_micro_mode",
-		"exit_shadow_mode",
-		"exit_subscript_mode",
-		"exit_superscript_mode",
-		"exit_upward_mode",
-		"micro_column_address",
-		"micro_down",
-		"micro_left",
-		"micro_right",
-		"micro_row_address",
-		"micro_up",
-		"order_of_pins",
-		"parm_down_micro",
-		"parm_left_micro",
-		"parm_right_micro",
-		"parm_up_micro",
-		"select_char_set",
-		"set_bottom_margin",
-		"set_bottom_margin_parm",
-		"set_left_margin_parm",
-		"set_right_margin_parm",
-		"set_top_margin",
-		"set_top_margin_parm",
-		"start_bit_image",
-		"start_char_set_def",
-		"stop_bit_image",
-		"stop_char_set_def",
-		"subscript_characters",
-		"superscript_characters",
-		"these_cause_cr",
-		"zero_motion",
-		"char_set_names",
-		"key_mouse",
-		"mouse_info",
-		"req_mouse_pos",
-		"get_mouse",
-		"set_a_foreground",
-		"set_a_background",
-		"pkey_plab",
-		"device_type",
-		"code_set_init",
-		"set0_des_seq",
-		"set1_des_seq",
-		"set2_des_seq",
-		"set3_des_seq",
-		"set_lr_margin",
-		"set_tb_margin",
-		"bit_image_repeat",
-		"bit_image_newline",
-		"bit_image_carriage_return",
-		"color_names",
-		"define_bit_image_region",
-		"end_bit_image_region",
-		"set_color_band",
-		"set_page_length",
-		"display_pc_char",
-		"enter_pc_charset_mode",
-		"exit_pc_charset_mode",
-		"enter_scancode_mode",
-		"exit_scancode_mode",
-		"pc_term_options",
-		"scancode_escape",
-		"alt_scancode_esc",
-		"enter_horizontal_hl_mode",
-		"enter_left_hl_mode",
-		"enter_low_hl_mode",
-		"enter_right_hl_mode",
-		"enter_top_hl_mode",
-		"enter_vertical_hl_mode",
-		"set_a_attributes",
-		"set_pglen_inch",
-		"termcap_init2",
-		"termcap_reset",
-		"linefeed_if_not_lf",
-		"backspace_if_not_bs",
-		"other_non_function_keys",
-		"arrow_key_map",
-		"acs_ulcorner",
-		"acs_llcorner",
-		"acs_urcorner",
-		"acs_lrcorner",
-		"acs_ltee",
-		"acs_rtee",
-		"acs_btee",
-		"acs_ttee",
-		"acs_hline",
-		"acs_vline",
-		"acs_plus",
-		"memory_lock",
-		"memory_unlock",
-		"box_chars_1",
-
-		(NCURSES_CONST char *)0,
-};
-
-
-#endif /* BROKEN_LINKER */
diff --git a/ncurses/new_pair.h b/ncurses/new_pair.h
new file mode 100644
index 0000000..49d7e8b
--- /dev/null
+++ b/ncurses/new_pair.h
@@ -0,0 +1,139 @@
+/****************************************************************************
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2017 Free Software Foundation, Inc.                            *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "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.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *  Author: Thomas E. Dickey                                                *
+ ****************************************************************************/
+
+/*
+ * Common type definitions and macros for new_pair.c, lib_color.c
+ *
+ * $Id: new_pair.h,v 1.13 2021/09/24 17:52:01 tom Exp $
+ */
+
+#ifndef NEW_PAIR_H
+#define NEW_PAIR_H 1
+/* *INDENT-OFF* */
+
+#include <ncurses_cfg.h>
+#include <ncurses_dll.h>
+
+#include <sys/types.h>
+
+#undef SCREEN
+#define SCREEN struct screen
+SCREEN;
+
+#define LIMIT_TYPED(n,t) \
+	(t)(((n) > MAX_OF_TYPE(t)) \
+	    ? MAX_OF_TYPE(t) \
+	    : ((n) < -MAX_OF_TYPE(t)) \
+	       ? -MAX_OF_TYPE(t) \
+	       : (n))
+
+#define limit_COLOR(n) LIMIT_TYPED(n,NCURSES_COLOR_T)
+#define limit_PAIRS(n) LIMIT_TYPED(n,NCURSES_PAIRS_T)
+
+#define MAX_XCURSES_PAIR MAX_OF_TYPE(NCURSES_PAIRS_T)
+
+#if NCURSES_EXT_COLORS
+#define OPTIONAL_PAIR	GCC_UNUSED
+#define get_extended_pair(opts, color_pair) \
+	if ((opts) != NULL) { \
+	    *(int*)(opts) = color_pair; \
+	}
+#define set_extended_pair(opts, color_pair) \
+	if ((opts) != NULL) { \
+	    color_pair = *(const int*)(opts); \
+	}
+#else
+#define OPTIONAL_PAIR	/* nothing */
+#define get_extended_pair(opts, color_pair) /* nothing */
+#define set_extended_pair(opts, color_pair) \
+	if ((opts) != NULL) { \
+	    color_pair = -1; \
+	}
+#endif
+
+#ifdef NEW_PAIR_INTERNAL
+
+typedef enum {
+    cpKEEP = -1,		/* color pair 0 */
+    cpFREE = 0,			/* free for use */
+    cpINIT = 1			/* initialized */
+} CPMODE;
+
+typedef struct _color_pairs
+{
+    int fg;
+    int bg;
+#if NCURSES_EXT_COLORS
+    int mode;			/* tells if the entry is allocated or free */
+    int prev;			/* index of previous item */
+    int next;			/* index of next item */
+#endif
+}
+colorpair_t;
+
+#define MakeColorPair(target,f,b) target.fg = f, target.bg = b
+#define isSamePair(a,b)		((a).fg == (b).fg && (a).bg == (b).bg)
+#define FORE_OF(c)		(c).fg
+#define BACK_OF(c)		(c).bg
+
+/*
+ * Ensure that we use color pairs only when colors have been started, and also
+ * that the index is within the limits of the table which we allocated.
+ */
+#define ValidPair(sp,pair) \
+    ((sp != 0) && (pair >= 0) && (pair < sp->_pair_limit) && sp->_coloron)
+
+#if NCURSES_EXT_COLORS
+extern NCURSES_EXPORT(void)     _nc_copy_pairs(SCREEN*, colorpair_t*, colorpair_t*, int);
+extern NCURSES_EXPORT(void)     _nc_free_ordered_pairs(SCREEN*);
+extern NCURSES_EXPORT(void)     _nc_reset_color_pair(SCREEN*, int, colorpair_t*);
+extern NCURSES_EXPORT(void)     _nc_set_color_pair(SCREEN*, int, int);
+#else
+#define _nc_free_ordered_pairs(sp) /* nothing */
+#define _nc_reset_color_pair(sp, pair, data) /* nothing */
+#define _nc_set_color_pair(sp, pair, mode) /* nothing */
+#endif
+
+#else
+
+typedef struct _color_pairs colorpair_t;
+
+#endif /* NEW_PAIR_INTERNAL */
+
+#if NO_LEAKS
+extern NCURSES_EXPORT(void)     _nc_new_pair_leaks(SCREEN*);
+#endif
+
+/* *INDENT-ON* */
+
+#endif /* NEW_PAIR_H */
diff --git a/ncurses/report_hashing.c b/ncurses/report_hashing.c
new file mode 100644
index 0000000..bed96ef
--- /dev/null
+++ b/ncurses/report_hashing.c
@@ -0,0 +1,73 @@
+/****************************************************************************
+ * Copyright 2020 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.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *  Author: Thomas E. Dickey                                                *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+#include <tic.h>
+
+MODULE_ID("$Id: report_hashing.c,v 1.3 2020/02/02 23:34:34 tom Exp $")
+
+static void
+check_names(const char *name, NCURSES_CONST char *const *table, int termcap)
+{
+    int errs = 0;
+    int n;
+    struct name_table_entry const *entry_ptr;
+    const HashValue *hash_table = _nc_get_hash_table(termcap);
+
+    printf("%s:\n", name);
+    for (n = 0; table[n] != NULL; ++n) {
+	entry_ptr = _nc_find_entry(table[n], hash_table);
+	if (entry_ptr == 0) {
+	    printf("  %s\n", table[n]);
+	    errs++;
+	}
+    }
+    if (errs)
+	printf("%d errors\n", errs);
+}
+
+int
+main(void)
+{
+#define CHECK_TI(name) check_names(#name, name, 0)
+#define CHECK_TC(name) check_names(#name, name, 1)
+
+    CHECK_TI(boolnames);
+    CHECK_TI(numnames);
+    CHECK_TI(strnames);
+
+    CHECK_TC(boolcodes);
+    CHECK_TC(numcodes);
+    CHECK_TC(strcodes);
+
+    return EXIT_SUCCESS;
+}
diff --git a/ncurses/report_offsets.c b/ncurses/report_offsets.c
new file mode 100644
index 0000000..0f82dcf
--- /dev/null
+++ b/ncurses/report_offsets.c
@@ -0,0 +1,272 @@
+/****************************************************************************
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
+ * Copyright 2017 Free Software Foundation, Inc.                            *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "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.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *  Author: Thomas E. Dickey                                                *
+ ****************************************************************************/
+
+#define NEW_PAIR_INTERNAL 1
+#include <curses.priv.h>
+
+MODULE_ID("$Id: report_offsets.c,v 1.28 2024/02/24 15:59:09 tom Exp $")
+
+#define show_size(type) \
+	flag = 0; \
+	last = 0; \
+	printf("%5lu   " #type "\n", (unsigned long)sizeof(type))
+#define show_name(name) \
+	printf("%5lu   " #name "\n", (unsigned long)(name))
+#define show_offset(type,member) \
+	next = (unsigned long)offsetof(type,member); \
+	if (last > next) \
+		printf("?? incorrect order for " #type "." #member "\n"); \
+	printf("%5lu %c " #type "." #member "\n", next, flag ? *flag : ' '); \
+	last = next; \
+	flag = 0
+
+#if NCURSES_WIDECHAR && NCURSES_EXT_COLORS
+#define show_COLORS(type,member) { flag = "c"; show_offset(type,member); }
+#else
+#define show_COLORS(type,member)	/* nothing */
+#endif
+
+#ifdef USE_TERM_DRIVER
+#define show_DRIVER(type,member) { flag = "d"; show_offset(type,member); }
+#else
+#define show_DRIVER(type,member)	/* nothing */
+#endif
+
+#if NO_LEAKS
+#define show_MLEAKS(type,member) { flag = "L"; show_offset(type,member); }
+#else
+#define show_MLEAKS(type,member)	/* nothing */
+#endif
+
+#define show_NORMAL(type,member) { flag = "n"; show_offset(type,member); }
+#define show_OPTION(type,member) { flag = "+"; show_offset(type,member); }
+
+#if USE_REENTRANT
+#define show_REENTR(type,member) { flag = "r"; show_offset(type,member); }
+#else
+#define show_REENTR(type,member)	/* nothing */
+#endif
+
+#if NCURSES_SP_FUNCS
+#define show_SPFUNC(type,member) { flag = "s"; show_offset(type,member); }
+#else
+#define show_SPFUNC(type,member)	/* nothing */
+#endif
+
+#ifdef USE_PTHREADS
+#define show_THREAD(type,member) { flag = "t"; show_offset(type,member); }
+#else
+#define show_THREAD(type,member)	/* nothing */
+#endif
+
+#ifdef TRACE
+#define show_TRACES(type,member) { flag = "T"; show_offset(type,member); }
+#else
+#define show_TRACES(type,member)	/* nothing */
+#endif
+
+#if USE_WIDEC_SUPPORT
+#define show_WIDECH(type,member) { flag = "w"; show_offset(type,member); }
+#else
+#define show_WIDECH(type,member)	/* nothing */
+#endif
+
+int
+main(void)
+{
+    const char *flag = 0;
+    unsigned long last, next;
+
+    printf("Size/offsets of data structures:\n");
+
+    show_size(attr_t);
+    show_size(chtype);
+#if USE_WIDEC_SUPPORT
+    show_size(cchar_t);
+#endif
+    show_size(color_t);
+    show_size(colorpair_t);
+    show_size(mmask_t);
+    show_size(rgb_bits_t);
+    show_size(MEVENT);
+    show_size(NCURSES_BOOL);
+    show_size(TRIES);
+
+    printf("\n");
+    printf("Sizes of buffers/arrays:\n");
+#if USE_WIDEC_SUPPORT
+    show_name(CCHARW_MAX);
+#endif
+    show_name(EV_MAX);
+    show_name(FIFO_SIZE);
+    show_name(NAMESIZE);
+    show_name(MB_LEN_MAX);
+    show_name(PATH_MAX);
+#ifdef TRACE
+    show_name(TRACECHR_BUF);
+    show_name(TRACEMSE_MAX);
+#endif
+
+    printf("\n");
+    show_size(SCREEN);
+    show_offset(SCREEN, _ifd);
+    show_offset(SCREEN, _fifo);
+    show_offset(SCREEN, _fifohead);
+    show_offset(SCREEN, _direct_color);
+    show_offset(SCREEN, _panelHook);
+    show_offset(SCREEN, jump);
+    show_offset(SCREEN, rsp);
+#if NCURSES_NO_PADDING
+    show_OPTION(SCREEN, _no_padding);
+#endif
+#if USE_HARD_TABS
+    show_OPTION(SCREEN, _ht_cost);
+#endif
+#if USE_ITALIC
+    show_OPTION(SCREEN, _use_ritm);
+#endif
+#if USE_KLIBC_KBD
+    show_OPTION(SCREEN, _extended_key);
+#endif
+#if NCURSES_EXT_FUNCS
+    show_OPTION(SCREEN, _assumed_color);
+#endif
+#if USE_GPM_SUPPORT
+    show_OPTION(SCREEN, _mouse_gpm_loaded);
+#ifdef HAVE_LIBDL
+    show_OPTION(SCREEN, _dlopen_gpm);
+#endif
+#endif
+#if USE_EMX_MOUSE
+    show_OPTION(SCREEN, _emxmouse_wfd);
+#endif
+#if USE_SYSMOUSE
+    show_OPTION(SCREEN, _sysmouse_fifo);
+#endif
+    show_DRIVER(SCREEN, _drv_mouse_fifo);
+#if USE_SIZECHANGE
+    show_OPTION(SCREEN, _resize);
+#endif
+#ifdef USE_SP_WINDOWLIST
+    show_NORMAL(SCREEN, _windowlist);
+#endif
+    show_REENTR(SCREEN, _ttytype);
+    show_SPFUNC(SCREEN, use_tioctl);
+    show_WIDECH(SCREEN, _screen_acs_fix);
+    show_COLORS(SCREEN, _ordered_pairs);
+    show_TRACES(SCREEN, tracechr_buf);
+
+    printf("\n");
+    show_size(TERMINAL);
+    show_offset(TERMINAL, type);
+    show_offset(TERMINAL, Filedes);
+    show_offset(TERMINAL, Ottyb);
+    show_offset(TERMINAL, Nttyb);
+    show_offset(TERMINAL, _baudrate);
+    show_offset(TERMINAL, _termname);
+    show_offset(TERMINAL, tparm_state);
+#if HAVE_INIT_EXTENDED_COLOR
+    show_COLORS(TERMINAL, type2);
+#endif
+
+    printf("\n");
+    show_size(TERMTYPE);
+#if NCURSES_XNAMES
+    show_OPTION(TERMTYPE, ext_str_table);
+    show_OPTION(TERMTYPE, ext_Strings);
+#endif
+
+    printf("\n");
+    show_size(TPARM_STATE);
+    show_offset(TPARM_STATE, stack);
+    show_offset(TPARM_STATE, stack_ptr);
+    show_offset(TPARM_STATE, out_buff);
+    show_offset(TPARM_STATE, fmt_buff);
+    show_offset(TPARM_STATE, static_vars);
+    show_TRACES(TPARM_STATE, tname);
+
+    printf("\n");
+    show_size(WINDOW);
+    show_WIDECH(WINDOW, _bkgrnd);
+    show_COLORS(WINDOW, _color);
+
+    printf("\n");
+    show_size(NCURSES_GLOBALS);
+    show_offset(NCURSES_GLOBALS, init_signals);
+    show_offset(NCURSES_GLOBALS, tgetent_cache);
+    show_offset(NCURSES_GLOBALS, dbd_vars);
+#if HAVE_TSEARCH
+    show_offset(NCURSES_GLOBALS, cached_tparm);
+#endif
+    show_DRIVER(NCURSES_GLOBALS, term_driver);
+#ifndef USE_SP_WINDOWLIST
+    show_NORMAL(NCURSES_GLOBALS, _nc_windowlist);
+#endif
+#if USE_HOME_TERMINFO
+    show_OPTION(NCURSES_GLOBALS, home_terminfo);
+#endif
+#if !USE_SAFE_SPRINTF
+    show_OPTION(NCURSES_GLOBALS, safeprint_rows);
+#endif
+    show_THREAD(NCURSES_GLOBALS, mutex_curses);
+#if USE_PTHREADS_EINTR
+    show_THREAD(NCURSES_GLOBALS, read_thread);
+#endif
+    show_WIDECH(NCURSES_GLOBALS, key_name);
+    show_TRACES(NCURSES_GLOBALS, trace_opened);
+    show_TRACES(NCURSES_GLOBALS, trace_level);
+    show_MLEAKS(NCURSES_GLOBALS, leak_checking);
+
+    printf("\n");
+    show_size(NCURSES_PRESCREEN);
+    show_offset(NCURSES_PRESCREEN, tparm_state);
+    show_offset(NCURSES_PRESCREEN, saved_tty);
+    show_offset(NCURSES_PRESCREEN, use_tioctl);
+    show_offset(NCURSES_PRESCREEN, _outch);
+#ifndef USE_SP_RIPOFF
+    show_NORMAL(NCURSES_PRESCREEN, rippedoff);
+#endif
+#if NCURSES_NO_PADDING
+    show_OPTION(NCURSES_PRESCREEN, _no_padding);
+#endif
+#if BROKEN_LINKER
+    show_offset(NCURSES_PRESCREEN, real_acs_map);
+#else
+    show_REENTR(NCURSES_PRESCREEN, real_acs_map);
+#endif
+#if BROKEN_LINKER || USE_REENTRANT
+    show_TRACES(NCURSES_PRESCREEN, _outchars);
+#endif
+
+    return EXIT_SUCCESS;
+}
diff --git a/ncurses/term.priv.h b/ncurses/term.priv.h
new file mode 100644
index 0000000..1f436b5
--- /dev/null
+++ b/ncurses/term.priv.h
@@ -0,0 +1,364 @@
+/****************************************************************************
+ * Copyright 2021-2023,2024 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: term.priv.h,v 1.13 2024/03/02 20:43:06 tom Exp $
+ *
+ *	term.priv.h
+ *
+ *	Header file for terminfo library objects which are private to
+ *	the library.
+ */
+
+#ifndef _TERM_PRIV_H
+#define _TERM_PRIV_H 1
+/* *INDENT-OFF* */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ncurses_cfg.h>
+
+#ifndef __NCURSES_H
+#include <curses.h>
+#endif
+
+#undef NCURSES_OPAQUE
+#define NCURSES_INTERNALS 1
+#define NCURSES_OPAQUE 0
+
+#if HAVE_LIMITS_H
+# include <limits.h>		/* PATH_MAX, MB_LEN_MAX, etc */
+#elif HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+
+#include <signal.h>		/* sig_atomic_t */
+#include <time.h>		/* time_t */
+#include <term.h>		/* time_t */
+
+#ifdef USE_PTHREADS
+#if USE_REENTRANT
+#include <pthread.h>
+#endif
+#endif
+
+/*
+ * If not properly configured to use the system's limits.h, we get gcc's
+ * fallback for limits.h which sets MB_LEN_MAX to 1, which is never correct.
+ */
+#if !HAVE_CONSISTENT_MB_LEN_MAX
+#undef MB_LEN_MAX
+#endif
+
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 16	/* should be >= MB_CUR_MAX, but that may be a function */
+#endif
+
+#ifndef PATH_MAX
+# if defined(_POSIX_PATH_MAX)
+#  define PATH_MAX _POSIX_PATH_MAX
+# elif defined(MAXPATHLEN)
+#  define PATH_MAX MAXPATHLEN
+# else
+#  define PATH_MAX 255	/* the Posix minimum path-size */
+# endif
+#endif
+
+/*
+ * State of tparm().
+ */
+#define STACKSIZE 20
+
+typedef struct {
+	union {
+		int	num;
+		char *	str;
+	} data;
+	bool num_type;
+} STACK_FRAME;
+
+#define NUM_VARS 26
+
+typedef struct {
+	const char *	tparam_base;
+
+	STACK_FRAME	stack[STACKSIZE];
+	int		stack_ptr;
+
+	char *		out_buff;
+	size_t		out_size;
+	size_t		out_used;
+
+	char *		fmt_buff;
+	size_t		fmt_size;
+
+	int		static_vars[NUM_VARS];
+#ifdef TRACE
+	const char *	tname;
+#endif
+} TPARM_STATE;
+
+typedef struct {
+	char *		text;
+	size_t		size;
+} TRACEBUF;
+
+typedef struct {
+	const char *	name;
+	char *		value;
+} ITERATOR_VARS;
+
+/*
+ * Internals for term.h
+ */
+typedef struct term {			/* describe an actual terminal */
+	TERMTYPE	type;		/* terminal type description */
+	short		Filedes;	/* file description being written to */
+	TTY		Ottyb;		/* original state of the terminal */
+	TTY		Nttyb;		/* current state of the terminal */
+	int		_baudrate;	/* used to compute padding */
+	char *		_termname;	/* used for termname() */
+	TPARM_STATE	tparm_state;
+#if NCURSES_EXT_COLORS
+	TERMTYPE2	type2;		/* extended terminal type description */
+#endif
+#undef TERMINAL
+} TERMINAL;
+
+/*
+ * Internals for soft-keys
+ */
+typedef	struct {
+	WINDOW *	win;		/* the window used in the hook      */
+	int		line;		/* lines to take, < 0 => from bottom*/
+	int		(*hook)(WINDOW *, int); /* callback for user	    */
+} ripoff_t;
+
+/*
+ * Internals for tgetent
+ */
+typedef struct {
+	long		sequence;
+	bool		last_used;
+	char *		fix_sgr0;	/* this holds the filtered sgr0 string */
+	char *		last_bufp;	/* help with fix_sgr0 leak */
+	TERMINAL *	last_term;
+} TGETENT_CACHE;
+
+#define TGETENT_MAX 4
+
+#include <term_entry.h>		/* dbdLAST */
+
+#ifdef USE_TERM_DRIVER
+struct DriverTCB; /* Terminal Control Block forward declaration */
+#endif
+
+/*
+ * Global data which is not specific to a screen.
+ */
+typedef struct {
+	SIG_ATOMIC_T	have_sigtstp;
+	SIG_ATOMIC_T	have_sigwinch;
+	SIG_ATOMIC_T	cleanup_nested;
+
+	bool		init_signals;
+	bool		init_screen;
+
+	char *		comp_sourcename;
+	char *		comp_termtype;
+
+	bool		have_tic_directory;
+	bool		keep_tic_directory;
+	const char *	tic_directory;
+
+	char *		dbi_list;
+	int		dbi_size;
+
+	char *		first_name;
+	char **		keyname_table;
+	int		init_keyname;
+
+	int		slk_format;
+
+	int		getstr_limit;	/* getstr_limit based on POSIX LINE_MAX */
+
+	char *		safeprint_buf;
+	size_t		safeprint_used;
+
+	TGETENT_CACHE	tgetent_cache[TGETENT_MAX];
+	int		tgetent_index;
+	long		tgetent_sequence;
+	int		terminal_count;
+
+	char *		dbd_blob;	/* string-heap for dbd_list[] */
+	char **		dbd_list;	/* distinct places to look for data */
+	int		dbd_size;	/* length of dbd_list[] */
+	time_t		dbd_time;	/* cache last updated */
+	ITERATOR_VARS	dbd_vars[dbdLAST];
+
+#if HAVE_TSEARCH
+	void *		cached_tparm;
+	int		count_tparm;
+#endif /* HAVE_TSEARCH */
+
+#ifdef USE_TERM_DRIVER
+	int		(*term_driver)(struct DriverTCB*, const char*, int*);
+#endif
+
+#define WINDOWLIST struct _win_list
+
+#ifndef USE_SP_WINDOWLIST
+	WINDOWLIST *	_nc_windowlist;
+#define WindowList(sp)	_nc_globals._nc_windowlist
+#endif
+
+#if USE_HOME_TERMINFO
+	char *		home_terminfo;
+#endif
+
+#if !USE_SAFE_SPRINTF
+	int		safeprint_cols;
+	int		safeprint_rows;
+#endif
+
+#ifdef USE_PTHREADS
+	pthread_mutex_t	mutex_curses;
+	pthread_mutex_t	mutex_prescreen;
+	pthread_mutex_t	mutex_screen;
+	pthread_mutex_t	mutex_update;
+	pthread_mutex_t	mutex_tst_tracef;
+	pthread_mutex_t	mutex_tracef;
+	int		nested_tracef;
+	int		use_pthreads;
+#define _nc_use_pthreads	_nc_globals.use_pthreads
+#if USE_PTHREADS_EINTR
+	pthread_t	read_thread;	/* The reading thread */
+#endif
+#endif
+#if USE_WIDEC_SUPPORT
+	char		key_name[MB_LEN_MAX + 1];
+#endif
+
+#ifdef TRACE
+	bool		trace_opened;
+	int		trace_level;
+	FILE *		trace_fp;
+	int		trace_fd;
+
+	char *		tracearg_buf;
+	size_t		tracearg_used;
+
+	TRACEBUF *	tracebuf_ptr;
+	size_t		tracebuf_used;
+
+	char		tracechr_buf[40];
+
+	char *		tracedmp_buf;
+	size_t		tracedmp_used;
+
+	unsigned char *	tracetry_buf;
+	size_t		tracetry_used;
+
+	char		traceatr_color_buf[2][80];
+	int		traceatr_color_sel;
+	int		traceatr_color_last;
+#if !defined(USE_PTHREADS) && USE_REENTRANT
+	int		nested_tracef;
+#endif
+#endif	/* TRACE */
+
+#if NO_LEAKS
+	bool		leak_checking;
+#endif
+} NCURSES_GLOBALS;
+
+extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals;
+
+#define N_RIPS 5
+
+#ifdef USE_PTHREADS
+typedef struct _prescreen_list {
+	struct _prescreen_list *next;
+	pthread_t	id;
+	struct screen *	sp;
+} PRESCREEN_LIST;
+#endif
+
+/*
+ * Global data which can be swept up into a SCREEN when one is created.
+ * It may be modified before the next SCREEN is created.
+ */
+typedef struct {
+#ifdef USE_PTHREADS
+	PRESCREEN_LIST *allocated;
+#else
+	struct screen * allocated;
+#endif
+	bool		use_env;
+	bool		filter_mode;
+	attr_t		previous_attr;
+	TPARM_STATE	tparm_state;
+	TTY *		saved_tty;	/* savetty/resetty information	  */
+	bool		use_tioctl;
+	NCURSES_SP_OUTC	_outch;		/* output handler if not putc */
+#ifndef USE_SP_RIPOFF
+	ripoff_t	rippedoff[N_RIPS];
+	ripoff_t *	rsp;
+#endif
+#if NCURSES_NO_PADDING
+	bool		_no_padding;	/* flag to set if padding disabled */
+#endif
+#if BROKEN_LINKER || USE_REENTRANT
+	chtype *	real_acs_map;
+	int		_LINES;
+	int		_COLS;
+	int		_TABSIZE;
+	int		_ESCDELAY;
+	TERMINAL *	_cur_term;
+#endif
+#ifdef TRACE
+#if BROKEN_LINKER || USE_REENTRANT
+	long		_outchars;
+	const char *	_tputs_trace;
+#endif
+#endif
+} NCURSES_PRESCREEN;
+
+extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen;
+
+extern NCURSES_EXPORT(void) _nc_free_tparm(TERMINAL*);
+
+#ifdef __cplusplus
+}
+#endif
+
+/* *INDENT-ON* */
+
+#endif /* _TERM_PRIV_H */
diff --git a/ncurses/tinfo/MKcaptab.awk b/ncurses/tinfo/MKcaptab.awk
index 56d3d17..ee4e2e9 100644
--- a/ncurses/tinfo/MKcaptab.awk
+++ b/ncurses/tinfo/MKcaptab.awk
@@ -1,5 +1,6 @@
 ##############################################################################
-# Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.                #
+# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 1998-2006,2007 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -25,7 +26,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: MKcaptab.awk,v 1.20 2007/08/12 00:26:15 tom Exp $
+# $Id: MKcaptab.awk,v 1.21 2020/02/02 23:34:34 tom Exp $
 function add_string(text) {
     if (text != "IGNORE") {
 	offsets[num_strings] = offset;
diff --git a/ncurses/tinfo/MKcaptab.sh b/ncurses/tinfo/MKcaptab.sh
index 20c94a6..5f41350 100755
--- a/ncurses/tinfo/MKcaptab.sh
+++ b/ncurses/tinfo/MKcaptab.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 ##############################################################################
-# Copyright (c) 2007-2010,2011 Free Software Foundation, Inc.                #
+# Copyright 2019-2020,2023 Thomas E. Dickey                                  #
+# Copyright 2007-2010,2011 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -26,11 +27,28 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: MKcaptab.sh,v 1.14 2011/10/22 16:34:50 tom Exp $
-AWK=${1-awk}
-OPT1=${2-0}
-OPT2=${3-tinfo/MKcaptab.awk}
-DATA=${4-../include/Caps}
+# $Id: MKcaptab.sh,v 1.20 2023/04/22 15:12:57 tom Exp $
+
+if test $# != 0
+then
+	AWK="$1"; shift 1
+else
+	AWK=awk
+fi
+
+if test $# != 0
+then
+	OPT1="$1"; shift 1
+else
+	OPT1="-0"
+fi
+
+if test $# != 0
+then
+	OPT2="$1"; shift 1
+else
+	OPT2="tinfo/MKcaptab.awk"
+fi
 
 cat <<EOF
 /*
@@ -50,16 +68,18 @@
 #include <tic.h>
 #include <hashsize.h>
 
+/* *INDENT-OFF* */
 EOF
 
-./make_hash 1 info $OPT1 <$DATA
-./make_hash 3 cap  $OPT1 <$DATA
+cat "$@" |./make_hash 1 info $OPT1
+cat "$@" |./make_hash 3 cap  $OPT1
 
-$AWK -f $OPT2 bigstrings=$OPT1 tablename=capalias <$DATA
+cat "$@" |$AWK -f $OPT2 bigstrings=$OPT1 tablename=capalias
 
-$AWK -f $OPT2 bigstrings=$OPT1 tablename=infoalias <$DATA
+cat "$@" |$AWK -f $OPT2 bigstrings=$OPT1 tablename=infoalias
 
 cat <<EOF
+/* *INDENT-ON* */
 
 #if $OPT1
 static void
@@ -70,7 +90,7 @@
 
 static const struct name_table_entry *
 _nc_build_names(struct name_table_entry **actual,
-		const name_table_data *source,
+		const name_table_data * source,
 		const char *strings)
 {
     if (*actual == 0) {
@@ -97,7 +117,7 @@
 
 static const struct alias *
 _nc_build_alias(struct alias **actual,
-		const alias_table_data *source,
+		const alias_table_data * source,
 		const char *strings,
 		size_t tablesize)
 {
@@ -127,20 +147,22 @@
 #define build_alias(root) _nc_ ## root ## alias_table
 #endif
 
-NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool termcap)
+NCURSES_EXPORT(const struct name_table_entry *)
+_nc_get_table(bool termcap)
 {
-    return termcap ? build_names(cap) : build_names(info) ;
+    return termcap ? build_names(cap) : build_names(info);
 }
 
-/* entrypoint used by tack (do not alter) */
-NCURSES_EXPORT(const HashValue *) _nc_get_hash_table (bool termcap)
+NCURSES_EXPORT(const HashValue *)
+_nc_get_hash_table(bool termcap)
 {
-    return termcap ? _nc_cap_hash_table: _nc_info_hash_table ;
+    return termcap ? _nc_cap_hash_table : _nc_info_hash_table;
 }
 
-NCURSES_EXPORT(const struct alias *) _nc_get_alias_table (bool termcap)
+NCURSES_EXPORT(const struct alias *)
+_nc_get_alias_table(bool termcap)
 {
-    return termcap ? build_alias(cap) : build_alias(info) ;
+    return termcap ? build_alias(cap) : build_alias(info);
 }
 
 static HashValue
@@ -150,7 +172,7 @@
 
     DEBUG(9, ("hashing %s", string));
     while (*string) {
-	sum += (long) (*string + (*(string + 1) << 8));
+	sum += (long) (UChar(*string) + (UChar(*(string + 1)) << 8));
 	string++;
     }
 
@@ -187,18 +209,21 @@
     return !strcmp(a, b);
 }
 
-static const HashData hash_data[2] = {
-    { HASHTABSIZE, _nc_info_hash_table, info_hash, compare_info_names },
-    { HASHTABSIZE, _nc_cap_hash_table, tcap_hash, compare_tcap_names }
+static const HashData hash_data[2] =
+{
+    {HASHTABSIZE, _nc_info_hash_table, info_hash, compare_info_names},
+    {HASHTABSIZE, _nc_cap_hash_table, tcap_hash, compare_tcap_names}
 };
 
-NCURSES_EXPORT(const HashData *) _nc_get_hash_info (bool termcap)
+NCURSES_EXPORT(const HashData *)
+_nc_get_hash_info(bool termcap)
 {
     return &hash_data[(termcap != FALSE)];
 }
 
 #if NO_LEAKS
-NCURSES_EXPORT(void) _nc_comp_captab_leaks(void)
+NCURSES_EXPORT(void)
+_nc_comp_captab_leaks(void)
 {
 #if $OPT1
     FreeIfNeeded(_nc_cap_table);
diff --git a/ncurses/tinfo/MKcodes.awk b/ncurses/tinfo/MKcodes.awk
index 97e5131..48f4800 100644
--- a/ncurses/tinfo/MKcodes.awk
+++ b/ncurses/tinfo/MKcodes.awk
@@ -1,5 +1,6 @@
 ##############################################################################
-# Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.                #
+# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2007-2009,2010 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -25,7 +26,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: MKcodes.awk,v 1.9 2010/01/23 17:57:43 tom Exp $
+# $Id: MKcodes.awk,v 1.11 2020/02/02 23:34:34 tom Exp $
 function large_item(value) {
 	result = sprintf("%d,", offset);
 	offset = offset + length(value) + 1;
@@ -79,7 +80,9 @@
 	}
 
 $1 ~ /^#/		{next;}
+$1 ~ /^(cap|info)alias/	{next;}
 
+$1 == "userdef"		{next;}
 $1 == "SKIPWARN"	{next;}
 
 $3 == "bool"	{
diff --git a/ncurses/tinfo/MKfallback.sh b/ncurses/tinfo/MKfallback.sh
index 11f1d2e..02b36ed 100755
--- a/ncurses/tinfo/MKfallback.sh
+++ b/ncurses/tinfo/MKfallback.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 ##############################################################################
-# Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.                #
+# Copyright 2020,2023 Thomas E. Dickey                                       #
+# Copyright 1998-2019,2020 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -26,7 +27,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: MKfallback.sh,v 1.15 2010/08/07 20:32:34 tom Exp $
+# $Id: MKfallback.sh,v 1.26 2023/04/22 15:12:57 tom Exp $
 #
 # MKfallback.sh -- create fallback table for entry reads
 #
@@ -43,9 +44,14 @@
 shift
 
 tic_path=$1
+test -z "$tic_path" && tic_path=tic
 shift
 
-case $tic_path in #(vi
+infocmp_path=$1
+test -z "$infocmp_path" && infocmp_path=infocmp
+shift
+
+case "$tic_path" in #(vi
 /*)
 	tic_head=`echo "$tic_path" | sed -e 's,/[^/]*$,,'`
 	PATH=$tic_head:$PATH
@@ -63,14 +69,16 @@
 	TERMINFO_DIRS=$TERMINFO:$terminfo_dir
 	export TERMINFO_DIRS
 
-	$tic_path -x $terminfo_src >&2
+	"$tic_path" -x "$terminfo_src" >&2
 else
 	tmp_info=
 fi
 
 cat <<EOF
+/* This file was generated by $0 */
+
 /*
- * DO NOT EDIT THIS FILE BY HAND!  It is generated by MKfallback.sh.
+ * DO NOT EDIT THIS FILE BY HAND!
  */
 
 #include <curses.priv.h>
@@ -84,21 +92,21 @@
 
 /* fallback entries for: $* */
 EOF
-	for x in $*
+	for x in "$@"
 	do
 		echo "/* $x */"
-		infocmp -E $x
+		"$infocmp_path" -E "$x" | sed -e 's/\<short\>/NCURSES_INT2/g'
 	done
 
 	cat <<EOF
-static const TERMTYPE fallbacks[$#] =
+static const TERMTYPE2 fallbacks[$#] =
 {
 EOF
 	comma=""
-	for x in $*
+	for x in "$@"
 	do
 		echo "$comma /* $x */"
-		infocmp -e $x
+		"$infocmp_path" -e "$x"
 		comma=","
 	done
 
@@ -109,28 +117,48 @@
 fi
 
 cat <<EOF
-NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *name GCC_UNUSED)
+NCURSES_EXPORT(const TERMTYPE2 *)
+_nc_fallback2 (const char *name GCC_UNUSED)
 {
 EOF
 
 if [ "$*" ]
 then
 	cat <<EOF
-    const TERMTYPE	*tp;
+    const TERMTYPE2	*tp;
 
     for (tp = fallbacks;
-	 	tp < fallbacks + sizeof(fallbacks)/sizeof(TERMTYPE);
-	 	tp++)
-	if (_nc_name_match(tp->term_names, name, "|"))
+	 tp < fallbacks + sizeof(fallbacks)/sizeof(TERMTYPE2);
+	 tp++) {
+	if (_nc_name_match(tp->term_names, name, "|")) {
 	    return(tp);
+	}
+    }
 EOF
 else
 	echo "	/* the fallback list is empty */";
 fi
 
 cat <<EOF
-	return((TERMTYPE *)0);
+    return((const TERMTYPE2 *)0);
 }
+
+#if NCURSES_EXT_NUMBERS
+#undef _nc_fallback
+
+NCURSES_EXPORT(const TERMTYPE *)
+_nc_fallback (const char *name)
+{
+    const TERMTYPE2 *tp = _nc_fallback2(name);
+    const TERMTYPE *result = 0;
+    if (tp != 0) {
+	static TERMTYPE temp;
+	_nc_export_termtype2(&temp, tp);
+	result = &temp;
+    }
+    return result;
+}
+#endif
 EOF
 
 if test -n "$tmp_info" ; then
diff --git a/ncurses/tinfo/MKkeys_list.sh b/ncurses/tinfo/MKkeys_list.sh
index 14017b0..05ac8cf 100755
--- a/ncurses/tinfo/MKkeys_list.sh
+++ b/ncurses/tinfo/MKkeys_list.sh
@@ -1,7 +1,8 @@
 #! /bin/sh
-# $Id: MKkeys_list.sh,v 1.4 2003/10/25 16:19:54 tom Exp $
+# $Id: MKkeys_list.sh,v 1.9 2024/01/19 12:26:30 tom Exp $
 ##############################################################################
-# Copyright (c) 2001,2003 Free Software Foundation, Inc.                     #
+# Copyright 2019-2022,2024 Thomas E. Dickey                                  #
+# Copyright 2001-2003,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -35,24 +36,32 @@
 # Extract function-key names from the Caps file
 #
 : ${AWK-awk}
-DATA=${1-../../include/Caps}
+: ${USE_SIGWINCH-0}
+if test $# != 0
+then
+	DATA="$*"
+else
+	DATA=../../include/Caps
+fi
 
 data=data$$
-trap 'rm -f $data' 0 1 2 5 15
-sed -e 's/[	][	]*/	/g' < $DATA >$data
+trap 'rm -f $data; exit 1' 1 2 3 15
+trap 'rm -f $data' 0
+cat $DATA | sed -e 's/[	][	]*/	/g' >$data
 
 cat <<EOF
 # These definitions were generated by $0 $DATA
 KEY_BREAK
 KEY_SRESET
 KEY_RESET
-KEY_RESIZE
 EOF
+test "$USE_SIGWINCH" = 1 && echo KEY_RESIZE
 
 ${AWK-awk} <$data '
 /^#/		{next;}
 /^capalias/	{next;}
 /^infoalias/	{next;}
+/^userdef/	{next;}
 
 $5 != "-" {
 		if (substr($5, 1, 4) == "KEY_" ) {
diff --git a/ncurses/tinfo/MKnames.awk b/ncurses/tinfo/MKnames.awk
index 7685d18..4594c72 100644
--- a/ncurses/tinfo/MKnames.awk
+++ b/ncurses/tinfo/MKnames.awk
@@ -1,5 +1,6 @@
 ##############################################################################
-# Copyright (c) 2007-2008,2009 Free Software Foundation, Inc.                #
+# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 1998-2008,2009 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -25,7 +26,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: MKnames.awk,v 1.22 2009/03/21 21:03:39 tom Exp $
+# $Id: MKnames.awk,v 1.24 2020/02/02 23:34:34 tom Exp $
 function large_item(value) {
 	result = sprintf("%d,", offset);
 	offset = offset + length(value) + 1;
@@ -79,7 +80,9 @@
 	}
 
 $1 ~ /^#/		{next;}
+$1 ~ /^(cap|info)alias/	{next;}
 
+$1 == "userdef"		{next;}
 $1 == "SKIPWARN"	{next;}
 
 $3 == "bool"	{
diff --git a/ncurses/tinfo/MKuserdefs.sh b/ncurses/tinfo/MKuserdefs.sh
new file mode 100755
index 0000000..109dd64
--- /dev/null
+++ b/ncurses/tinfo/MKuserdefs.sh
@@ -0,0 +1,146 @@
+#!/bin/sh
+##############################################################################
+# Copyright 2019,2020 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: MKuserdefs.sh,v 1.10 2020/02/02 23:34:34 tom Exp $
+AWK=${1-awk}; shift 1
+OPT1=${1-0}; shift 1
+
+cat <<EOF
+/*
+ * generated by $0
+ */
+
+EOF
+
+cat <<'EOF'
+/*
+ *    comp_userdefs.c -- The names of widely used user-defined capabilities
+ *                       indexed via a hash table for the compiler.
+ *
+ */
+
+#include <curses.priv.h>
+#include <tic.h>
+#include <hashsize.h>
+
+#if NCURSES_XNAMES
+EOF
+
+cat "$@" | ./make_hash 1 user $OPT1
+
+cat <<EOF
+
+#define USERTABSIZE SIZEOF(user_names_data)
+
+#if $OPT1
+static void
+next_string(const char *strings, unsigned *offset)
+{
+    *offset += (unsigned) strlen(strings + *offset) + 1;
+}
+
+static const struct user_table_entry *
+_nc_build_names(struct user_table_entry **actual,
+		const user_table_data *source,
+		const char *strings)
+{
+    if (*actual == 0) {
+	*actual = typeCalloc(struct user_table_entry, USERTABSIZE);
+	if (*actual != 0) {
+	    unsigned n;
+	    unsigned len = 0;
+	    for (n = 0; n < USERTABSIZE; ++n) {
+		(*actual)[n].ute_name = strings + len;
+		(*actual)[n].ute_type = (int) source[n].ute_type;
+		(*actual)[n].ute_argc = source[n].ute_argc;
+		(*actual)[n].ute_args = source[n].ute_args;
+		(*actual)[n].ute_index = source[n].ute_index;
+		(*actual)[n].ute_link = source[n].ute_link;
+		next_string(strings, &len);
+	    }
+	}
+    }
+    return *actual;
+}
+
+#define build_names(root) _nc_build_names(&_nc_##root##_table, \\
+					  root##_names_data, \\
+					  root##_names_text)
+#else
+#define build_names(root) _nc_ ## root ## _table
+#endif
+
+NCURSES_EXPORT(const struct user_table_entry *) _nc_get_userdefs_table (void)
+{
+    return build_names(user) ;
+}
+
+static HashValue
+info_hash(const char *string)
+{
+    long sum = 0;
+
+    DEBUG(9, ("hashing %s", string));
+    while (*string) {
+	sum += (long) (*string + (*(string + 1) << 8));
+	string++;
+    }
+
+    DEBUG(9, ("sum is %ld", sum));
+    return (HashValue) (sum % HASHTABSIZE);
+}
+
+static int
+compare_info_names(const char *a, const char *b)
+{
+    return !strcmp(a, b);
+}
+
+static const HashData hash_data[] = {
+    { HASHTABSIZE, _nc_user_hash_table, info_hash, compare_info_names }
+};
+
+NCURSES_EXPORT(const HashData *) _nc_get_hash_user (void)
+{
+    return hash_data;
+}
+
+#if NO_LEAKS
+NCURSES_EXPORT(void) _nc_comp_userdefs_leaks(void)
+{
+#if $OPT1
+    FreeIfNeeded(_nc_user_table);
+#endif
+}
+#endif /* NO_LEAKS */
+
+#else /*! NCURSES_XNAMES */
+NCURSES_EXPORT(void) _nc_comp_userdefs(void);
+NCURSES_EXPORT(void) _nc_comp_userdefs(void) { }
+#endif /* NCURSES_XNAMES */
+EOF
diff --git a/ncurses/tinfo/README b/ncurses/tinfo/README
index 14c4220..6157ba1 100644
--- a/ncurses/tinfo/README
+++ b/ncurses/tinfo/README
@@ -1,5 +1,6 @@
 -------------------------------------------------------------------------------
--- Copyright (c) 1998,2006 Free Software Foundation, Inc.                    --
+-- Copyright 2020 Thomas E. Dickey                                           --
+-- Copyright 1998,2006 Free Software Foundation, Inc.                        --
 --                                                                           --
 -- Permission is hereby granted, free of charge, to any person obtaining a   --
 -- copy of this software and associated documentation files (the             --
@@ -25,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: README,v 1.2 2006/04/22 22:19:37 tom Exp $
+-- $Id: README,v 1.3 2020/02/02 23:34:34 tom Exp $
 -------------------------------------------------------------------------------
 
 The files in this directory (tinfo) are those that support the terminfo
diff --git a/ncurses/tinfo/access.c b/ncurses/tinfo/access.c
index d987687..50a5769 100644
--- a/ncurses/tinfo/access.c
+++ b/ncurses/tinfo/access.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2019-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2011,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,20 +35,33 @@
 
 #include <ctype.h>
 
+#ifndef USE_ROOT_ACCESS
+#if HAVE_SETFSUID
+#include <sys/fsuid.h>
+#else
+#include <sys/stat.h>
+#endif
+#endif
+
+#if HAVE_GETAUXVAL && HAVE_SYS_AUXV_H && defined(__GLIBC__) && (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19)
+#include <sys/auxv.h>
+#define USE_GETAUXVAL 1
+#else
+#define USE_GETAUXVAL 0
+#endif
+
 #include <tic.h>
 
-MODULE_ID("$Id: access.c,v 1.23 2012/09/01 19:21:29 tom Exp $")
-
-#ifdef __TANDEM
-#define ROOT_UID 65535
-#endif
-
-#ifndef ROOT_UID
-#define ROOT_UID 0
-#endif
+MODULE_ID("$Id: access.c,v 1.37 2023/06/24 21:55:09 tom Exp $")
 
 #define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c))
 
+#ifdef _NC_MSC
+# define ACCESS(FN, MODE) access((FN), (MODE)&(R_OK|W_OK))
+#else
+# define ACCESS access
+#endif
+
 NCURSES_EXPORT(char *)
 _nc_rootname(char *path)
 {
@@ -56,8 +70,8 @@
     static char *temp;
     char *s;
 
-    temp = strdup(result);
-    result = temp;
+    if ((temp = strdup(result)) != 0)
+	result = temp;
 #if !MIXEDCASE_FILENAMES
     for (s = result; *s != '\0'; ++s) {
 	*s = (char) LOWERCASE(*s);
@@ -119,7 +133,7 @@
 
     if (path == 0) {
 	result = -1;
-    } else if (access(path, mode) < 0) {
+    } else if (ACCESS(path, mode) < 0) {
 	if ((mode & W_OK) != 0
 	    && errno == ENOENT
 	    && strlen(path) < PATH_MAX) {
@@ -134,7 +148,7 @@
 	    if (head == leaf)
 		_nc_STRCPY(head, ".", sizeof(head));
 
-	    result = access(head, R_OK | W_OK | X_OK);
+	    result = ACCESS(head, R_OK | W_OK | X_OK);
 	} else {
 	    result = -1;
 	}
@@ -170,23 +184,101 @@
     return result;
 }
 
-#ifndef USE_ROOT_ENVIRON
+#if HAVE_GETEUID && HAVE_GETEGID
+#define is_posix_elevated() \
+	(getuid() != geteuid() \
+	 || getgid() != getegid())
+#else
+#define is_posix_elevated() FALSE
+#endif
+
+#if HAVE_ISSETUGID
+#define is_elevated() issetugid()
+#elif USE_GETAUXVAL && defined(AT_SECURE)
+#define is_elevated() \
+	(getauxval(AT_SECURE) \
+	 ? TRUE \
+	 : (errno != ENOENT \
+	    ? FALSE \
+	    : is_posix_elevated()))
+#else
+#define is_elevated() is_posix_elevated()
+#endif
+
+#if HAVE_SETFSUID
+#define lower_privileges() \
+	    int save_err = errno; \
+	    setfsuid(getuid()); \
+	    setfsgid(getgid()); \
+	    errno = save_err
+#define resume_elevation() \
+	    save_err = errno; \
+	    setfsuid(geteuid()); \
+	    setfsgid(getegid()); \
+	    errno = save_err
+#else
+#define lower_privileges()	/* nothing */
+#define resume_elevation()	/* nothing */
+#endif
+
 /*
- * Returns true if we allow application to use environment variables that are
- * used for searching lists of directories, etc.
+ * Returns true if not running as root or setuid.  We use this check to allow
+ * applications to use environment variables that are used for searching lists
+ * of directories, etc.
  */
 NCURSES_EXPORT(int)
 _nc_env_access(void)
 {
-#if HAVE_ISSETUGID
-    if (issetugid())
-	return FALSE;
-#elif HAVE_GETEUID && HAVE_GETEGID
-    if (getuid() != geteuid()
-	|| getgid() != getegid())
-	return FALSE;
+    int result = TRUE;
+
+#if HAVE_GETUID && HAVE_GETEUID
+#if !defined(USE_SETUID_ENVIRON)
+    if (is_elevated()) {
+	result = FALSE;
+    }
 #endif
-    /* ...finally, disallow root */
-    return (getuid() != ROOT_UID) && (geteuid() != ROOT_UID);
+#if !defined(USE_ROOT_ENVIRON)
+    if ((getuid() == ROOT_UID) || (geteuid() == ROOT_UID)) {
+	result = FALSE;
+    }
+#endif
+#endif /* HAVE_GETUID && HAVE_GETEUID */
+    return result;
 }
+
+#ifndef USE_ROOT_ACCESS
+/*
+ * Limit privileges if possible; otherwise disallow access for updating files.
+ */
+NCURSES_EXPORT(FILE *)
+_nc_safe_fopen(const char *path, const char *mode)
+{
+    FILE *result = NULL;
+#if HAVE_SETFSUID
+    lower_privileges();
+    result = fopen(path, mode);
+    resume_elevation();
+#else
+    if (!is_elevated() || *mode == 'r') {
+	result = fopen(path, mode);
+    }
 #endif
+    return result;
+}
+
+NCURSES_EXPORT(int)
+_nc_safe_open3(const char *path, int flags, mode_t mode)
+{
+    int result = -1;
+#if HAVE_SETFSUID
+    lower_privileges();
+    result = open(path, flags, mode);
+    resume_elevation();
+#else
+    if (!is_elevated() || (flags & O_RDONLY)) {
+	result = open(path, flags, mode);
+    }
+#endif
+    return result;
+}
+#endif /* USE_ROOT_ACCESS */
diff --git a/ncurses/tinfo/add_tries.c b/ncurses/tinfo/add_tries.c
index 29a1a60..9d21557 100644
--- a/ncurses/tinfo/add_tries.c
+++ b/ncurses/tinfo/add_tries.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -38,8 +39,9 @@
 */
 
 #include <curses.priv.h>
+#include <tic.h>
 
-MODULE_ID("$Id: add_tries.c,v 1.10 2010/12/19 01:31:14 tom Exp $")
+MODULE_ID("$Id: add_tries.c,v 1.13 2023/06/24 15:36:13 tom Exp $")
 
 #define SET_TRY(dst,src) if ((dst->ch = *src++) == 128) dst->ch = '\0'
 #define CMP_TRY(a,b) ((a)? (a == b) : (b == 128))
@@ -52,7 +54,7 @@
 
     T((T_CALLED("_nc_add_to_try(%p, %s, %u)"),
        (void *) *tree, _nc_visbuf(str), code));
-    if (txt == 0 || *txt == '\0' || code == 0)
+    if (!VALID_STRING(str) || *txt == '\0' || code == 0)
 	returnCode(ERR);
 
     if ((*tree) != 0) {
@@ -109,6 +111,7 @@
 		savedptr = ptr->child;
 		free(ptr);
 	    }
+	    *tree = NULL;
 	    returnCode(ERR);
 	}
 
diff --git a/ncurses/tinfo/alloc_entry.c b/ncurses/tinfo/alloc_entry.c
index 14ea391..6280ad4 100644
--- a/ncurses/tinfo/alloc_entry.c
+++ b/ncurses/tinfo/alloc_entry.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2013,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -47,73 +48,89 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: alloc_entry.c,v 1.58 2013/08/17 19:20:38 tom Exp $")
+MODULE_ID("$Id: alloc_entry.c,v 1.79 2023/09/15 08:16:12 tom Exp $")
 
 #define ABSENT_OFFSET    -1
 #define CANCELLED_OFFSET -2
 
-#define MAX_STRTAB	4096	/* documented maximum entry size */
-
 static char *stringbuf;		/* buffer for string capabilities */
 static size_t next_free;	/* next free character in stringbuf */
 
 NCURSES_EXPORT(void)
-_nc_init_entry(TERMTYPE *const tp)
+_nc_init_entry(ENTRY * const tp)
 /* initialize a terminal type data block */
 {
+    DEBUG(2, (T_CALLED("_nc_init_entry(tp=%p)"), (void *) tp));
+
+    if (tp == NULL) {
 #if NO_LEAKS
-    if (tp == 0) {
-	if (stringbuf != 0) {
+	if (stringbuf != NULL) {
 	    FreeAndNull(stringbuf);
 	}
 	return;
-    }
+#else
+	_nc_err_abort("_nc_init_entry called without initialization");
 #endif
+    }
 
-    if (stringbuf == 0)
-	TYPE_MALLOC(char, (size_t) MAX_STRTAB, stringbuf);
+    if (stringbuf == NULL)
+	TYPE_CALLOC(char, (size_t) MAX_ENTRY_SIZE, stringbuf);
 
     next_free = 0;
 
-    _nc_init_termtype(tp);
+    _nc_init_termtype(&(tp->tterm));
+
+    DEBUG(2, (T_RETURN("")));
 }
 
 NCURSES_EXPORT(ENTRY *)
 _nc_copy_entry(ENTRY * oldp)
 {
-    ENTRY *newp = typeCalloc(ENTRY, 1);
+    ENTRY *newp;
 
-    if (newp != 0) {
+    DEBUG(2, (T_CALLED("_nc_copy_entry(oldp=%p)"), (void *) oldp));
+
+    newp = typeCalloc(ENTRY, 1);
+    if (newp != NULL) {
 	*newp = *oldp;
-	_nc_copy_termtype(&(newp->tterm), &(oldp->tterm));
+	_nc_copy_termtype2(&(newp->tterm), &(oldp->tterm));
     }
-    return newp;
+
+    DEBUG(2, (T_RETURN("%p"), (void *) newp));
+    return (newp);
 }
 
 /* save a copy of string in the string buffer */
 NCURSES_EXPORT(char *)
-_nc_save_str(const char *const string)
+_nc_save_str(const char *string)
 {
     char *result = 0;
     size_t old_next_free = next_free;
-    size_t len = strlen(string) + 1;
 
-    if (len == 1 && next_free != 0) {
-	/*
-	 * Cheat a little by making an empty string point to the end of the
-	 * previous string.
-	 */
-	if (next_free < MAX_STRTAB) {
-	    result = (stringbuf + next_free - 1);
+    if (stringbuf != NULL) {
+	size_t len;
+
+	if (!VALID_STRING(string))
+	    string = "";
+	len = strlen(string) + 1;
+
+	if (len == 1 && next_free != 0) {
+	    /*
+	     * Cheat a little by making an empty string point to the end of the
+	     * previous string.
+	     */
+	    if (next_free < MAX_ENTRY_SIZE) {
+		result = (stringbuf + next_free - 1);
+	    }
+	} else if (next_free + len < MAX_ENTRY_SIZE) {
+	    _nc_STRCPY(&stringbuf[next_free], string, MAX_ENTRY_SIZE);
+	    DEBUG(7, ("Saved string %s", _nc_visbuf(string)));
+	    DEBUG(7, ("at location %d", (int) next_free));
+	    next_free += len;
+	    result = (stringbuf + old_next_free);
+	} else {
+	    _nc_warning("Too much data, some is lost: %s", string);
 	}
-    } else if (next_free + len < MAX_STRTAB) {
-	_nc_STRCPY(&stringbuf[next_free], string, MAX_STRTAB);
-	DEBUG(7, ("Saved string %s", _nc_visbuf(string)));
-	DEBUG(7, ("at location %d", (int) next_free));
-	next_free += len;
-	result = (stringbuf + old_next_free);
-    } else {
-	_nc_warning("Too much data, some is lost: %s", string);
     }
     return result;
 }
@@ -125,17 +142,23 @@
     int offsets[MAX_ENTRY_SIZE / sizeof(short)];
     int useoffsets[MAX_USES];
     unsigned i, n;
-    unsigned nuses = ep->nuses;
-    TERMTYPE *tp = &(ep->tterm);
+    unsigned nuses;
+    TERMTYPE2 *tp;
 
+    DEBUG(2, (T_CALLED("_nc_wrap_entry(ep=%p, copy_strings=%d)"), (void *)
+	      ep, copy_strings));
+    if (ep == NULL || stringbuf == NULL)
+	_nc_err_abort("_nc_wrap_entry called without initialization");
+
+    nuses = ep->nuses;
+    tp = &(ep->tterm);
     if (copy_strings) {
 	next_free = 0;		/* clear static storage */
 
 	/* copy term_names, Strings, uses */
 	tp->term_names = _nc_save_str(tp->term_names);
 	for_each_string(i, tp) {
-	    if (tp->Strings[i] != ABSENT_STRING &&
-		tp->Strings[i] != CANCELLED_STRING) {
+	    if (VALID_STRING(tp->Strings[i])) {
 		tp->Strings[i] = _nc_save_str(tp->Strings[i]);
 	    }
 	}
@@ -210,41 +233,148 @@
 #endif
 
     for (i = 0; i < nuses; i++) {
-	if (useoffsets[i] == ABSENT_OFFSET)
+	if (useoffsets[i] == ABSENT_OFFSET) {
 	    ep->uses[i].name = 0;
-	else
-	    ep->uses[i].name = (tp->str_table + useoffsets[i]);
+	} else {
+	    ep->uses[i].name = strdup(tp->str_table + useoffsets[i]);
+	}
     }
+    DEBUG(2, (T_RETURN("")));
 }
 
 NCURSES_EXPORT(void)
-_nc_merge_entry(TERMTYPE *const to, TERMTYPE *const from)
+_nc_merge_entry(ENTRY * const target, ENTRY * const source)
 /* merge capabilities from `from' entry into `to' entry */
 {
+    TERMTYPE2 *to = &(target->tterm);
+    TERMTYPE2 *from = &(source->tterm);
+#if NCURSES_XNAMES
+    TERMTYPE2 copy;
+    size_t str_size, copy_size;
+    char *str_table;
+#endif
     unsigned i;
 
+    if (source == 0 || from == 0 || target == 0 || to == 0)
+	return;
+
 #if NCURSES_XNAMES
+    _nc_copy_termtype2(&copy, from);
+    from = &copy;
     _nc_align_termtype(to, from);
+    /*
+     * compute the maximum size of the string-table.
+     */
+    str_size = strlen(to->term_names) + 1;
+    for_each_string(i, from) {
+	if (VALID_STRING(from->Strings[i]))
+	    str_size += strlen(from->Strings[i]) + 1;
+    }
+    for_each_string(i, to) {
+	if (VALID_STRING(to->Strings[i]))
+	    str_size += strlen(to->Strings[i]) + 1;
+    }
+    /* allocate a string-table large enough for both source/target, and
+     * copy all of the strings into that table.  In the merge, we will
+     * select from the original source/target lists to construct a new
+     * target list.
+     */
+    if (str_size != 0) {
+	char *str_copied;
+	if ((str_table = malloc(str_size)) == NULL)
+	    _nc_err_abort(MSG_NO_MEMORY);
+	str_copied = str_table;
+	_nc_STRCPY(str_copied, to->term_names, str_size);
+	to->term_names = str_copied;
+	copy_size = strlen(str_copied) + 1;
+	str_copied += copy_size;
+	str_size -= copy_size;
+	for_each_string(i, from) {
+	    if (VALID_STRING(from->Strings[i])) {
+		_nc_STRCPY(str_copied, from->Strings[i], str_size);
+		from->Strings[i] = str_copied;
+		copy_size = strlen(str_copied) + 1;
+		str_copied += copy_size;
+		str_size -= copy_size;
+	    }
+	}
+	for_each_string(i, to) {
+	    if (VALID_STRING(to->Strings[i])) {
+		_nc_STRCPY(str_copied, to->Strings[i], str_size);
+		to->Strings[i] = str_copied;
+		copy_size = strlen(str_copied) + 1;
+		str_copied += copy_size;
+		str_size -= copy_size;
+	    }
+	}
+	free(to->str_table);
+	to->str_table = str_table;
+	free(from->str_table);
+    }
+    /*
+     * Do the same for the extended-strings (i.e., lists of capabilities).
+     */
+    str_size = 0;
+    for (i = 0; i < NUM_EXT_NAMES(from); ++i) {
+	if (VALID_STRING(from->ext_Names[i]))
+	    str_size += strlen(from->ext_Names[i]) + 1;
+    }
+    for (i = 0; i < NUM_EXT_NAMES(to); ++i) {
+	if (VALID_STRING(to->ext_Names[i]))
+	    str_size += strlen(to->ext_Names[i]) + 1;
+    }
+    /* allocate a string-table large enough for both source/target, and
+     * copy all of the strings into that table.  In the merge, we will
+     * select from the original source/target lists to construct a new
+     * target list.
+     */
+    if (str_size != 0) {
+	char *str_copied;
+	if ((str_table = malloc(str_size)) == NULL)
+	    _nc_err_abort(MSG_NO_MEMORY);
+	str_copied = str_table;
+	for (i = 0; i < NUM_EXT_NAMES(from); ++i) {
+	    if (VALID_STRING(from->ext_Names[i])) {
+		_nc_STRCPY(str_copied, from->ext_Names[i], str_size);
+		from->ext_Names[i] = str_copied;
+		copy_size = strlen(str_copied) + 1;
+		str_copied += copy_size;
+		str_size -= copy_size;
+	    }
+	}
+	for (i = 0; i < NUM_EXT_NAMES(to); ++i) {
+	    if (VALID_STRING(to->ext_Names[i])) {
+		_nc_STRCPY(str_copied, to->ext_Names[i], str_size);
+		to->ext_Names[i] = str_copied;
+		copy_size = strlen(str_copied) + 1;
+		str_copied += copy_size;
+		str_size -= copy_size;
+	    }
+	}
+	free(to->ext_str_table);
+	to->ext_str_table = str_table;
+	free(from->ext_str_table);
+    }
 #endif
     for_each_boolean(i, from) {
-	if (to->Booleans[i] != (char) CANCELLED_BOOLEAN) {
+	if (to->Booleans[i] != (NCURSES_SBOOL) CANCELLED_BOOLEAN) {
 	    int mergebool = from->Booleans[i];
 
 	    if (mergebool == CANCELLED_BOOLEAN)
 		to->Booleans[i] = FALSE;
 	    else if (mergebool == TRUE)
-		to->Booleans[i] = (char) mergebool;
+		to->Booleans[i] = (NCURSES_SBOOL) mergebool;
 	}
     }
 
     for_each_number(i, from) {
 	if (to->Numbers[i] != CANCELLED_NUMERIC) {
-	    short mergenum = from->Numbers[i];
+	    int mergenum = from->Numbers[i];
 
 	    if (mergenum == CANCELLED_NUMERIC)
 		to->Numbers[i] = ABSENT_NUMERIC;
 	    else if (mergenum != ABSENT_NUMERIC)
-		to->Numbers[i] = mergenum;
+		to->Numbers[i] = (NCURSES_INT2) mergenum;
 	}
     }
 
@@ -263,13 +393,20 @@
 		to->Strings[i] = mergestring;
 	}
     }
+#if NCURSES_XNAMES
+    /* cleanup */
+    free(copy.Booleans);
+    free(copy.Numbers);
+    free(copy.Strings);
+    free(copy.ext_Names);
+#endif
 }
 
 #if NO_LEAKS
 NCURSES_EXPORT(void)
 _nc_alloc_entry_leaks(void)
 {
-    if (stringbuf != 0) {
+    if (stringbuf != NULL) {
 	FreeAndNull(stringbuf);
     }
     next_free = 0;
diff --git a/ncurses/tinfo/alloc_ttype.c b/ncurses/tinfo/alloc_ttype.c
index 35c92dd..304c1b6 100644
--- a/ncurses/tinfo/alloc_ttype.c
+++ b/ncurses/tinfo/alloc_ttype.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1999-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1999-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +43,7 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: alloc_ttype.c,v 1.27 2013/06/08 16:54:50 tom Exp $")
+MODULE_ID("$Id: alloc_ttype.c,v 1.51 2023/09/09 23:15:53 tom Exp $")
 
 #if NCURSES_XNAMES
 /*
@@ -61,7 +62,7 @@
 	} else if (cmp > 0) {
 	    dst[n++] = *b++;
 	    nb--;
-	} else if (cmp == 0) {
+	} else {
 	    dst[n++] = *a;
 	    a++, b++;
 	    na--, nb--;
@@ -78,37 +79,59 @@
 }
 
 static bool
-find_name(char **table, int length, char *name)
+find_name(char **table, int item, int length, const char *name)
 {
-    while (length-- > 0) {
-	if (!strcmp(*table++, name)) {
-	    DEBUG(4, ("found name '%s'", name));
-	    return TRUE;
+    int n;
+    int result = -1;
+
+    for (n = item; n < length; ++n) {
+	if (!strcmp(table[n], name)) {
+	    DEBUG(4, ("found name '%s' @%d", name, n));
+	    result = n;
+	    break;
 	}
     }
-    DEBUG(4, ("did not find name '%s'", name));
-    return FALSE;
+    if (result < 0) {
+	DEBUG(4, ("did not find name '%s'", name));
+    }
+    return (result >= 0);
 }
 
 #define EXTEND_NUM(num, ext) \
+	DEBUG(4, ("extending " #num " from %d to %d", \
+	 to->num, (unsigned short) (to->num + (ext - to->ext)))); \
 	to->num = (unsigned short) (to->num + (ext - to->ext))
 
 static void
-realign_data(TERMTYPE *to, char **ext_Names,
+realign_data(TERMTYPE2 *to, char **ext_Names,
 	     int ext_Booleans,
 	     int ext_Numbers,
 	     int ext_Strings)
 {
     int n, m, base;
-    int limit = (to->ext_Booleans + to->ext_Numbers + to->ext_Strings);
+    int to_Booleans = to->ext_Booleans;
+    int to_Numbers = to->ext_Numbers;
+    int to_Strings = to->ext_Strings;
+    int to1, to2, from;
+
+    DEBUG(4, ("realign_data %d/%d/%d vs %d/%d/%d",
+	      ext_Booleans,
+	      ext_Numbers,
+	      ext_Strings,
+	      to->ext_Booleans,
+	      to->ext_Numbers,
+	      to->ext_Strings));
 
     if (to->ext_Booleans != ext_Booleans) {
+	to1 = 0;
+	to2 = to_Booleans + to1;
+	from = 0;
 	EXTEND_NUM(num_Booleans, ext_Booleans);
 	TYPE_REALLOC(NCURSES_SBOOL, to->num_Booleans, to->Booleans);
 	for (n = to->ext_Booleans - 1,
 	     m = ext_Booleans - 1,
 	     base = to->num_Booleans - (m + 1); m >= 0; m--) {
-	    if (find_name(to->ext_Names, limit, ext_Names[m])) {
+	    if (find_name(to->ext_Names, to1, to2, ext_Names[m + from])) {
 		to->Booleans[base + m] = to->Booleans[base + n--];
 	    } else {
 		to->Booleans[base + m] = FALSE;
@@ -118,12 +141,15 @@
     }
 
     if (to->ext_Numbers != ext_Numbers) {
+	to1 = to_Booleans;
+	to2 = to_Numbers + to1;
+	from = ext_Booleans;
 	EXTEND_NUM(num_Numbers, ext_Numbers);
-	TYPE_REALLOC(short, to->num_Numbers, to->Numbers);
+	TYPE_REALLOC(NCURSES_INT2, to->num_Numbers, to->Numbers);
 	for (n = to->ext_Numbers - 1,
 	     m = ext_Numbers - 1,
 	     base = to->num_Numbers - (m + 1); m >= 0; m--) {
-	    if (find_name(to->ext_Names, limit, ext_Names[m + ext_Booleans])) {
+	    if (find_name(to->ext_Names, to1, to2, ext_Names[m + from])) {
 		to->Numbers[base + m] = to->Numbers[base + n--];
 	    } else {
 		to->Numbers[base + m] = ABSENT_NUMERIC;
@@ -131,13 +157,17 @@
 	}
 	to->ext_Numbers = UShort(ext_Numbers);
     }
+
     if (to->ext_Strings != ext_Strings) {
+	to1 = to_Booleans + to_Numbers;
+	to2 = to_Strings + to1;
+	from = ext_Booleans + ext_Numbers;
 	EXTEND_NUM(num_Strings, ext_Strings);
 	TYPE_REALLOC(char *, to->num_Strings, to->Strings);
 	for (n = to->ext_Strings - 1,
 	     m = ext_Strings - 1,
 	     base = to->num_Strings - (m + 1); m >= 0; m--) {
-	    if (find_name(to->ext_Names, limit, ext_Names[m + ext_Booleans + ext_Numbers])) {
+	    if (find_name(to->ext_Names, to1, to2, ext_Names[m + from])) {
 		to->Strings[base + m] = to->Strings[base + n--];
 	    } else {
 		to->Strings[base + m] = ABSENT_STRING;
@@ -151,7 +181,7 @@
  * Returns the first index in ext_Names[] for the given token-type
  */
 static unsigned
-_nc_first_ext_name(TERMTYPE *tp, int token_type)
+_nc_first_ext_name(TERMTYPE2 *tp, int token_type)
 {
     unsigned first;
 
@@ -176,7 +206,7 @@
  * Returns the last index in ext_Names[] for the given token-type
  */
 static unsigned
-_nc_last_ext_name(TERMTYPE *tp, int token_type)
+_nc_last_ext_name(TERMTYPE2 *tp, int token_type)
 {
     unsigned last;
 
@@ -199,7 +229,7 @@
  * Lookup an entry from extended-names, returning -1 if not found
  */
 static int
-_nc_find_ext_name(TERMTYPE *tp, char *name, int token_type)
+_nc_find_ext_name(TERMTYPE2 *tp, char *name, int token_type)
 {
     unsigned j;
     unsigned first = _nc_first_ext_name(tp, token_type);
@@ -218,7 +248,7 @@
  * (e.g., Booleans[]).
  */
 static int
-_nc_ext_data_index(TERMTYPE *tp, int n, int token_type)
+_nc_ext_data_index(TERMTYPE2 *tp, int n, int token_type)
 {
     switch (token_type) {
     case BOOLEAN:
@@ -241,13 +271,14 @@
  * data.
  */
 static bool
-_nc_del_ext_name(TERMTYPE *tp, char *name, int token_type)
+_nc_del_ext_name(TERMTYPE2 *tp, char *name, int token_type)
 {
-    int j;
-    int first, last;
+    int first;
 
     if ((first = _nc_find_ext_name(tp, name, token_type)) >= 0) {
-	last = (int) NUM_EXT_NAMES(tp) - 1;
+	int j;
+	int last = (int) NUM_EXT_NAMES(tp) - 1;
+
 	for (j = first; j < last; j++) {
 	    tp->ext_Names[j] = tp->ext_Names[j + 1];
 	}
@@ -285,7 +316,7 @@
  * index into the corresponding data array is returned.
  */
 static int
-_nc_ins_ext_name(TERMTYPE *tp, char *name, int token_type)
+_nc_ins_ext_name(TERMTYPE2 *tp, char *name, int token_type)
 {
     unsigned first = _nc_first_ext_name(tp, token_type);
     unsigned last = _nc_last_ext_name(tp, token_type);
@@ -319,7 +350,7 @@
     case NUMBER:
 	tp->ext_Numbers++;
 	tp->num_Numbers++;
-	TYPE_REALLOC(short, tp->num_Numbers, tp->Numbers);
+	TYPE_REALLOC(NCURSES_INT2, tp->num_Numbers, tp->Numbers);
 	for (k = (unsigned) (tp->num_Numbers - 1); k > j; k--)
 	    tp->Numbers[k] = tp->Numbers[k - 1];
 	break;
@@ -340,12 +371,15 @@
  * cancellation of a name that is inherited from another entry.
  */
 static void
-adjust_cancels(TERMTYPE *to, TERMTYPE *from)
+adjust_cancels(TERMTYPE2 *to, TERMTYPE2 *from)
 {
     int first = to->ext_Booleans + to->ext_Numbers;
     int last = first + to->ext_Strings;
     int j, k;
 
+    DEBUG(3, (T_CALLED("adjust_cancels(%s), from(%s)"),
+	      NonNull(to->term_names),
+	      NonNull(from->term_names)));
     for (j = first; j < last;) {
 	char *name = to->ext_Names[j];
 	int j_str = to->num_Strings - first - to->ext_Strings;
@@ -382,38 +416,47 @@
 	    j++;
 	}
     }
+    DEBUG(3, (T_RETURN("")));
 }
 
 NCURSES_EXPORT(void)
-_nc_align_termtype(TERMTYPE *to, TERMTYPE *from)
+_nc_align_termtype(TERMTYPE2 *to, TERMTYPE2 *from)
 {
-    int na = (int) NUM_EXT_NAMES(to);
-    int nb = (int) NUM_EXT_NAMES(from);
-    int n;
-    bool same;
+    int na;
+    int nb;
     char **ext_Names;
-    int ext_Booleans, ext_Numbers, ext_Strings;
-    bool used_ext_Names = FALSE;
 
-    DEBUG(2, ("align_termtype to(%d:%s), from(%d:%s)", na, to->term_names,
-	      nb, from->term_names));
+    na = to ? ((int) NUM_EXT_NAMES(to)) : 0;
+    nb = from ? ((int) NUM_EXT_NAMES(from)) : 0;
 
-    if (na != 0 || nb != 0) {
+    DEBUG(2, (T_CALLED("_nc_align_termtype to(%d:%s), from(%d:%s)"),
+	      na, to ? NonNull(to->term_names) : "?",
+	      nb, from ? NonNull(from->term_names) : "?"));
+
+    if (to != NULL && from != NULL && (na != 0 || nb != 0)) {
+	int ext_Booleans, ext_Numbers, ext_Strings;
+	bool used_ext_Names = FALSE;
+
 	if ((na == nb)		/* check if the arrays are equivalent */
 	    &&(to->ext_Booleans == from->ext_Booleans)
 	    && (to->ext_Numbers == from->ext_Numbers)
 	    && (to->ext_Strings == from->ext_Strings)) {
+	    int n;
+	    bool same;
+
 	    for (n = 0, same = TRUE; n < na; n++) {
 		if (strcmp(to->ext_Names[n], from->ext_Names[n])) {
 		    same = FALSE;
 		    break;
 		}
 	    }
-	    if (same)
+	    if (same) {
+		DEBUG(2, (T_RETURN("")));
 		return;
+	    }
 	}
 	/*
-	 * This is where we pay for having a simple extension representation. 
+	 * This is where we pay for having a simple extension representation.
 	 * Allocate a new ext_Names array and merge the two ext_Names arrays
 	 * into it, updating to's counts for booleans, etc.  Fortunately we do
 	 * this only for the terminfo compiler (tic) and comparer (infocmp).
@@ -470,42 +513,201 @@
 	if (!used_ext_Names)
 	    free(ext_Names);
     }
+    DEBUG(2, (T_RETURN("")));
 }
 #endif
 
-NCURSES_EXPORT(void)
-_nc_copy_termtype(TERMTYPE *dst, const TERMTYPE *src)
+#define srcINT 1
+#define dstINT 2
+
+/*
+ * TERMTYPE and TERMTYPE2 differ only with regard to the values in Numbers.
+ * Use 'mode' to decide which to use.
+ */
+static void
+copy_termtype(TERMTYPE2 *dst, const TERMTYPE2 *src, int mode)
 {
-#if NCURSES_XNAMES
     unsigned i;
+    int pass;
+    char *new_table;
+    size_t new_table_size;
+#if NCURSES_EXT_NUMBERS
+    short *oldptr = 0;
+    int *newptr = 0;
 #endif
 
+    DEBUG(2, (T_CALLED("copy_termtype(dst=%p, src=%p, mode=%d)"), (void *)
+	      dst, (const void *) src, mode));
     *dst = *src;		/* ...to copy the sizes and string-tables */
 
     TYPE_MALLOC(NCURSES_SBOOL, NUM_BOOLEANS(dst), dst->Booleans);
-    TYPE_MALLOC(short, NUM_NUMBERS(dst), dst->Numbers);
     TYPE_MALLOC(char *, NUM_STRINGS(dst), dst->Strings);
 
     memcpy(dst->Booleans,
 	   src->Booleans,
 	   NUM_BOOLEANS(dst) * sizeof(dst->Booleans[0]));
-    memcpy(dst->Numbers,
-	   src->Numbers,
-	   NUM_NUMBERS(dst) * sizeof(dst->Numbers[0]));
     memcpy(dst->Strings,
 	   src->Strings,
 	   NUM_STRINGS(dst) * sizeof(dst->Strings[0]));
 
-    /* FIXME: we probably should also copy str_table and ext_str_table,
-     * but tic and infocmp are not written to exploit that (yet).
-     */
+    new_table = NULL;
+    new_table_size = 0;
+    for (pass = 0; pass < 2; ++pass) {
+	size_t str_size = 0;
+	if (src->term_names != NULL) {
+	    if (pass) {
+		dst->term_names = new_table + str_size;
+		_nc_STRCPY(dst->term_names + str_size,
+			   src->term_names,
+			   new_table_size - str_size);
+	    }
+	    str_size += strlen(src->term_names) + 1;
+	}
+	for_each_string(i, src) {
+	    if (VALID_STRING(src->Strings[i])) {
+		if (pass) {
+		    _nc_STRCPY(new_table + str_size,
+			       src->Strings[i],
+			       new_table_size - str_size);
+		    dst->Strings[i] = new_table + str_size;
+		}
+		str_size += strlen(src->Strings[i]) + 1;
+	    }
+	}
+	if (pass) {
+	    dst->str_table = new_table;
+	} else {
+	    ++str_size;
+	    if ((new_table = malloc(str_size)) == NULL)
+		_nc_err_abort(MSG_NO_MEMORY);
+	    new_table_size = str_size;
+	}
+    }
+
+#if NCURSES_EXT_NUMBERS
+    if ((mode & dstINT) == 0) {
+	DEBUG(2, ("...convert int ->short"));
+	TYPE_MALLOC(short, NUM_NUMBERS(dst), oldptr);
+	((TERMTYPE *) dst)->Numbers = oldptr;
+    } else {
+	DEBUG(2, ("...copy without changing size"));
+	TYPE_MALLOC(int, NUM_NUMBERS(dst), newptr);
+	dst->Numbers = newptr;
+    }
+    if ((mode == srcINT) && (oldptr != 0)) {
+	DEBUG(2, ("...copy int ->short"));
+	for (i = 0; i < NUM_NUMBERS(dst); ++i) {
+	    if (src->Numbers[i] > MAX_OF_TYPE(short)) {
+		oldptr[i] = MAX_OF_TYPE(short);
+	    } else {
+		oldptr[i] = (short) src->Numbers[i];
+	    }
+	}
+    } else if ((mode == dstINT) && (newptr != 0)) {
+	DEBUG(2, ("...copy short ->int"));
+	for (i = 0; i < NUM_NUMBERS(dst); ++i) {
+	    newptr[i] = ((const short *) (src->Numbers))[i];
+	}
+    } else {
+	DEBUG(2, ("...copy %s without change",
+		  (mode & dstINT)
+		  ? "int"
+		  : "short"));
+	memcpy(dst->Numbers,
+	       src->Numbers,
+	       NUM_NUMBERS(dst) * ((mode & dstINT)
+				   ? sizeof(int)
+				   : sizeof(short)));
+    }
+#else
+    (void) mode;
+    TYPE_MALLOC(short, NUM_NUMBERS(dst), dst->Numbers);
+    memcpy(dst->Numbers,
+	   src->Numbers,
+	   NUM_NUMBERS(dst) * sizeof(dst->Numbers[0]));
+#endif
 
 #if NCURSES_XNAMES
     if ((i = NUM_EXT_NAMES(src)) != 0) {
 	TYPE_MALLOC(char *, i, dst->ext_Names);
 	memcpy(dst->ext_Names, src->ext_Names, i * sizeof(char *));
+
+	new_table = NULL;
+	new_table_size = 0;
+	for (pass = 0; pass < 2; ++pass) {
+	    size_t str_size = 0;
+	    char *raw_data = src->ext_str_table;
+	    if (raw_data != NULL) {
+		for (i = 0; i < src->ext_Strings; ++i) {
+		    size_t skip = strlen(raw_data) + 1;
+		    if (skip != 1) {
+			if (pass) {
+			    _nc_STRCPY(new_table + str_size,
+				       raw_data,
+				       new_table_size - str_size);
+			}
+			str_size += skip;
+			raw_data += skip;
+		    }
+		}
+	    }
+	    for (i = 0; i < NUM_EXT_NAMES(dst); ++i) {
+		if (VALID_STRING(src->ext_Names[i])) {
+		    if (pass) {
+			_nc_STRCPY(new_table + str_size,
+				   src->ext_Names[i],
+				   new_table_size - str_size);
+			dst->ext_Names[i] = new_table + str_size;
+		    }
+		    str_size += strlen(src->ext_Names[i]) + 1;
+		}
+	    }
+	    if (pass) {
+		dst->ext_str_table = new_table;
+	    } else {
+		++str_size;
+		if ((new_table = calloc(str_size, 1)) == NULL)
+		    _nc_err_abort(MSG_NO_MEMORY);
+		new_table_size = str_size;
+	    }
+	}
     } else {
 	dst->ext_Names = 0;
     }
 #endif
+    (void) new_table_size;
+    DEBUG(2, (T_RETURN("")));
 }
+
+NCURSES_EXPORT(void)
+_nc_copy_termtype(TERMTYPE *dst, const TERMTYPE *src)
+{
+    DEBUG(2, (T_CALLED("_nc_copy_termtype(dst=%p, src=%p)"), (void *) dst,
+	      (const void *) src));
+    copy_termtype((TERMTYPE2 *) dst, (const TERMTYPE2 *) src, 0);
+    DEBUG(2, (T_RETURN("")));
+}
+
+#if NCURSES_EXT_NUMBERS
+NCURSES_EXPORT(void)
+_nc_copy_termtype2(TERMTYPE2 *dst, const TERMTYPE2 *src)
+{
+    DEBUG(2, (T_CALLED("_nc_copy_termtype2(dst=%p, src=%p)"), (void *) dst,
+	      (const void *) src));
+    copy_termtype(dst, src, srcINT | dstINT);
+    DEBUG(2, (T_RETURN("")));
+}
+
+/*
+ * Use this for exporting the internal TERMTYPE2 to the legacy format used via
+ * the CUR macro by applications.
+ */
+NCURSES_EXPORT(void)
+_nc_export_termtype2(TERMTYPE *dst, const TERMTYPE2 *src)
+{
+    DEBUG(2, (T_CALLED("_nc_export_termtype2(dst=%p, src=%p)"), (void *)
+	      dst, (const void *) src));
+    copy_termtype((TERMTYPE2 *) dst, src, srcINT);
+    DEBUG(2, (T_RETURN("")));
+}
+#endif /* NCURSES_EXT_NUMBERS */
diff --git a/ncurses/tinfo/captoinfo.c b/ncurses/tinfo/captoinfo.c
index e02e622..7e14731 100644
--- a/ncurses/tinfo/captoinfo.c
+++ b/ncurses/tinfo/captoinfo.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2018-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  *
  * copy of this software and associated documentation files (the            *
@@ -33,12 +34,16 @@
  ****************************************************************************/
 
 /*
- *	captoinfo.c --- conversion between termcap and terminfo formats
+ *	captoinfo.c
+ *
+ *	Provide conversion in both directions between termcap and terminfo.
+ *
+ * cap-to-info --- conversion between termcap and terminfo formats
  *
  *	The captoinfo() code was swiped from Ross Ridge's mytinfo package,
  *	adapted to fit ncurses by Eric S. Raymond <esr@snark.thyrsus.com>.
  *
- *	There is just one entry point:
+ *	It has just one entry point:
  *
  *	char *_nc_captoinfo(n, s, parameterized)
  *
@@ -93,7 +98,13 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: captoinfo.c,v 1.77 2012/12/30 00:50:40 tom Exp $")
+MODULE_ID("$Id: captoinfo.c,v 1.102 2021/09/04 10:29:15 tom Exp $")
+
+#if 0
+#define DEBUG_THIS(p) DEBUG(9, p)
+#else
+#define DEBUG_THIS(p)		/* nothing */
+#endif
 
 #define MAX_PUSHED	16	/* max # args we can push onto the stack */
 
@@ -181,7 +192,7 @@
 	case '$':
 	case '\\':
 	case '%':
-	    c = (unsigned char) (*sp);
+	    c = UChar(*sp);
 	    len = 2;
 	    break;
 	case '\0':
@@ -194,29 +205,36 @@
 	case '3':
 	    len = 1;
 	    while (isdigit(UChar(*sp))) {
-		c = (unsigned char) (8 * c + (*sp++ - '0'));
+		c = UChar(8 * c + (*sp++ - '0'));
 		len++;
 	    }
 	    break;
 	default:
-	    c = (unsigned char) (*sp);
-	    len = 2;
+	    c = UChar(*sp);
+	    len = (c != '\0') ? 2 : 1;
 	    break;
 	}
 	break;
     case '^':
-	c = (unsigned char) (*++sp & 0x1f);
 	len = 2;
+	c = UChar(*++sp);
+	if (c == '?') {
+	    c = 127;
+	} else if (c == '\0') {
+	    len = 1;
+	} else {
+	    c &= 0x1f;
+	}
 	break;
     default:
-	c = (unsigned char) (*sp);
-	len = 1;
+	c = UChar(*sp);
+	len = (c != '\0') ? 1 : 0;
     }
     if (isgraph(c) && c != ',' && c != '\'' && c != '\\' && c != ':') {
 	dp = save_string(dp, "%\'");
 	dp = save_char(dp, c);
 	dp = save_char(dp, '\'');
-    } else {
+    } else if (c != '\0') {
 	dp = save_string(dp, "%{");
 	if (c > 99)
 	    dp = save_char(dp, c / 100 + '0');
@@ -232,6 +250,8 @@
 getparm(int parm, int n)
 /* push n copies of param on the terminfo stack if not already there */
 {
+    int nn;
+
     if (seenr) {
 	if (parm == 1)
 	    parm = 2;
@@ -239,7 +259,7 @@
 	    parm = 1;
     }
 
-    while (n--) {
+    for (nn = 0; nn < n; ++nn) {
 	dp = save_string(dp, "%p");
 	dp = save_char(dp, '0' + parm);
     }
@@ -248,7 +268,7 @@
 	if (n > 1) {
 	    _nc_warning("string may not be optimal");
 	    dp = save_string(dp, "%Pa");
-	    while (n--) {
+	    while (n-- > 0) {
 		dp = save_string(dp, "%ga");
 	    }
 	}
@@ -288,6 +308,8 @@
     seenr = 0;
     param = 1;
 
+    DEBUG_THIS(("_nc_captoinfo params %d, %s", parameterized, s));
+
     dp = init_string();
 
     /* skip the initial padding (if we haven't been told not to) */
@@ -295,7 +317,7 @@
     if (s == 0)
 	s = "";
     if (parameterized >= 0 && isdigit(UChar(*s)))
-	for (capstart = s;; s++)
+	for (capstart = s; *s != '\0'; s++)
 	    if (!(isdigit(UChar(*s)) || *s == '*' || *s == '.'))
 		break;
 
@@ -309,7 +331,7 @@
 	    }
 	    switch (*s++) {
 	    case '%':
-		dp = save_char(dp, '%');
+		dp = save_string(dp, "%%");
 		break;
 	    case 'r':
 		if (seenr++ == 1) {
@@ -342,13 +364,18 @@
 		dp = save_string(dp, "%{2}%*%-");
 		break;
 	    case '>':
-		getparm(param, 2);
 		/* %?%{x}%>%t%{y}%+%; */
-		dp = save_string(dp, "%?");
-		s += cvtchar(s);
-		dp = save_string(dp, "%>%t");
-		s += cvtchar(s);
-		dp = save_string(dp, "%+%;");
+		if (s[0] && s[1]) {
+		    getparm(param, 2);
+		    dp = save_string(dp, "%?");
+		    s += cvtchar(s);
+		    dp = save_string(dp, "%>%t");
+		    s += cvtchar(s);
+		    dp = save_string(dp, "%+%;");
+		} else {
+		    _nc_warning("expected two characters after %%>");
+		    dp = save_string(dp, "%>");
+		}
 		break;
 	    case 'a':
 		if ((*s == '=' || *s == '+' || *s == '-'
@@ -429,12 +456,17 @@
 		pop();
 		break;
 	    case '0':		/* not clear any of the historical termcaps did this */
-		if (*s == '3')
+		if (*s == '3') {
+		    ++s;
 		    goto see03;
-		else if (*s != '2')
-		    goto invalid;
-		/* FALLTHRU */
+		}
+		if (*s == '2') {
+		    ++s;
+		    goto see02;
+		}
+		goto invalid;
 	    case '2':
+	      see02:
 		getparm(param, 1);
 		dp = save_string(dp, "%2d");
 		pop();
@@ -469,7 +501,8 @@
 	    }
 	    break;
 	default:
-	    dp = save_char(dp, *s++);
+	    if (*s != '\0')
+		dp = save_char(dp, *s++);
 	    break;
 	}
     }
@@ -480,7 +513,7 @@
      */
     if (capstart) {
 	dp = save_string(dp, "$<");
-	for (s = capstart;; s++)
+	for (s = capstart; *s != '\0'; s++)
 	    if (isdigit(UChar(*s)) || *s == '*' || *s == '.')
 		dp = save_char(dp, *s);
 	    else
@@ -489,6 +522,9 @@
     }
 
     (void) save_char(dp, '\0');
+
+    DEBUG_THIS(("... _nc_captoinfo %s", NonNull(my_string)));
+
     return (my_string);
 }
 
@@ -525,13 +561,13 @@
 static char *
 save_tc_char(char *bufptr, int c1)
 {
-    char temp[80];
-
     if (is7bits(c1) && isprint(c1)) {
 	if (c1 == ':' || c1 == '\\')
 	    bufptr = save_char(bufptr, '\\');
 	bufptr = save_char(bufptr, c1);
     } else {
+	char temp[80];
+
 	if (c1 == (c1 & 0x1f)) {	/* iscntrl() returns T on 255 */
 	    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
 			"%.20s", unctrl((chtype) c1));
@@ -554,6 +590,8 @@
 }
 
 /*
+ * info-to-cap --- conversion between terminfo and termcap formats
+ *
  * Here are the capabilities infotocap assumes it can translate to:
  *
  *     %%       output `%'
@@ -571,6 +609,8 @@
  *     %m       exclusive-or all parameters with 0177 (not in 4.4BSD)
  */
 
+#define octal_fixup(n, c) fixups[n].ch = ((fixups[n].ch << 3) | ((c) - '0'))
+
 /*
  * Convert a terminfo string to termcap format.  Parameters are as in
  * _nc_captoinfo().
@@ -586,12 +626,23 @@
     char *bufptr = init_string();
     char octal[4];
     int len;
+    int digits;
     bool syntax_error = FALSE;
+    int myfix = 0;
+    struct {
+	int ch;
+	int offset;
+    } fixups[MAX_TC_FIXUPS];
+
+    DEBUG_THIS(("_nc_infotocap %s params %d, %s",
+		_nc_strict_bsd ? "strict" : "loose",
+		parameterized,
+		_nc_visbuf(str)));
 
     /* we may have to move some trailing mandatory padding up front */
     padding = str + strlen(str) - 1;
     if (padding > str && *padding == '>') {
-	if (*--padding == '/')
+	if (padding > (str + 1) && *--padding == '/')
 	    --padding;
 	while (isdigit(UChar(*padding)) || *padding == '.' || *padding == '*')
 	    padding--;
@@ -603,7 +654,9 @@
 	    bufptr = save_char(bufptr, *padding++);
     }
 
-    for (; *str && ((trimmed == 0) || (str < trimmed)); str++) {
+    for (; !syntax_error &&
+	 *str &&
+	 ((trimmed == 0) || (str < trimmed)); str++) {
 	int c1, c2;
 	char *cp = 0;
 
@@ -611,10 +664,23 @@
 	    if (str[1] == '\0' || (str + 1) == trimmed) {
 		bufptr = save_string(bufptr, "\\136");
 		++str;
+	    } else if (str[1] == '?') {
+		/*
+		 * Although the 4.3BSD termcap file has an instance of "kb=^?",
+		 * that appears to be just cut/paste since neither 4.3BSD nor
+		 * 4.4BSD termcap interprets "^?" as DEL.
+		 */
+		bufptr = save_string(bufptr, "\\177");
+		++str;
 	    } else {
 		bufptr = save_char(bufptr, *str++);
 		bufptr = save_char(bufptr, *str);
 	    }
+	} else if (str[0] == ':') {
+	    bufptr = save_char(bufptr, '\\');
+	    bufptr = save_char(bufptr, '0');
+	    bufptr = save_char(bufptr, '7');
+	    bufptr = save_char(bufptr, '2');
 	} else if (str[0] == '\\') {
 	    if (str[1] == '\0' || (str + 1) == trimmed) {
 		bufptr = save_string(bufptr, "\\134");
@@ -625,17 +691,20 @@
 	    } else if (str[1] == ',') {
 		bufptr = save_char(bufptr, *++str);
 	    } else {
-		int xx1, xx2;
+		int xx1;
 
 		bufptr = save_char(bufptr, *str++);
 		xx1 = *str;
 		if (_nc_strict_bsd) {
-		    if (isdigit(UChar(xx1))) {
-			int pad = 0;
 
-			if (!isdigit(UChar(str[1])))
+		    if (isoctal(UChar(xx1))) {
+			int pad = 0;
+			int xx2;
+			int fix = 0;
+
+			if (!isoctal(UChar(str[1])))
 			    pad = 2;
-			else if (str[1] && !isdigit(UChar(str[2])))
+			else if (str[1] && !isoctal(UChar(str[2])))
 			    pad = 1;
 
 			/*
@@ -650,10 +719,31 @@
 			    xx2 = '0';
 			    pad = 0;	/* FIXME - optionally pad to 3 digits */
 			}
+			if (myfix < MAX_TC_FIXUPS) {
+			    fix = 3 - pad;
+			    fixups[myfix].ch = 0;
+			    fixups[myfix].offset = (int) (bufptr
+							  - my_string
+							  - 1);
+			}
 			while (pad-- > 0) {
 			    bufptr = save_char(bufptr, xx2);
+			    if (myfix < MAX_TC_FIXUPS) {
+				fixups[myfix].ch <<= 3;
+				fixups[myfix].ch |= (xx2 - '0');
+			    }
 			    xx2 = '0';
 			}
+			if (myfix < MAX_TC_FIXUPS) {
+			    int n;
+			    for (n = 0; n < fix; ++n) {
+				fixups[myfix].ch <<= 3;
+				fixups[myfix].ch |= (str[n] - '0');
+			    }
+			    if (fixups[myfix].ch < 32) {
+				++myfix;
+			    }
+			}
 		    } else if (strchr("E\\nrtbf", xx1) == 0) {
 			switch (xx1) {
 			case 'e':
@@ -689,6 +779,24 @@
 			    break;
 			}
 		    }
+		} else {
+		    if (myfix < MAX_TC_FIXUPS && isoctal(UChar(xx1))) {
+			bool will_fix = TRUE;
+			int n;
+
+			fixups[myfix].ch = 0;
+			fixups[myfix].offset = (int) (bufptr - my_string - 1);
+			for (n = 0; n < 3; ++n) {
+			    if (isoctal(str[n])) {
+				octal_fixup(myfix, str[n]);
+			    } else {
+				will_fix = FALSE;
+				break;
+			    }
+			}
+			if (will_fix && (fixups[myfix].ch < 32))
+			    ++myfix;
+		    }
 		}
 		bufptr = save_char(bufptr, xx1);
 	    }
@@ -735,8 +843,9 @@
 	} else if ((len = bcd_expression(str)) != 0) {
 	    str += len;
 	    bufptr = save_string(bufptr, "%B");
-	} else if ((sscanf(str, "%%{%d}%%+%%c", &c1) == 1
-		    || sscanf(str, "%%'%c'%%+%%c", &ch1) == 1)
+	} else if ((sscanf(str, "%%{%d}%%+%%%c", &c1, &ch2) == 2
+		    || sscanf(str, "%%'%c'%%+%%%c", &ch1, &ch2) == 2)
+		   && ch2 == 'c'
 		   && (cp = strchr(str, '+'))) {
 	    str = cp + 2;
 	    bufptr = save_string(bufptr, "%+");
@@ -779,26 +888,46 @@
 		bufptr = save_char(bufptr, '%');
 		ch1 = 0;
 		ch2 = 0;
+		digits = 0;
 		while (isdigit(UChar(*str))) {
+		    if (++digits > 2) {
+			syntax_error = TRUE;
+			break;
+		    }
 		    ch2 = ch1;
 		    ch1 = *str++;
-		    if (_nc_strict_bsd) {
-			if (ch1 > '3')
-			    return 0;
+		    if (digits == 2 && ch2 != '0') {
+			syntax_error = TRUE;
+			break;
+		    } else if (_nc_strict_bsd) {
+			if (ch1 > '3') {
+			    syntax_error = TRUE;
+			    break;
+			}
 		    } else {
 			bufptr = save_char(bufptr, ch1);
 		    }
 		}
+		if (syntax_error)
+		    break;
+		/*
+		 * Convert %02 to %2 and %03 to %3
+		 */
+		if (ch2 == '0' && !_nc_strict_bsd) {
+		    ch2 = 0;
+		    bufptr[-2] = bufptr[-1];
+		    *--bufptr = 0;
+		}
 		if (_nc_strict_bsd) {
-		    if (ch2 != 0 && ch2 != '0')
-			return 0;
-		    if (ch1 < '2')
+		    if (ch2 != 0 && ch2 != '0') {
+			syntax_error = TRUE;
+		    } else if (ch1 < '2') {
 			ch1 = 'd';
+		    }
 		    bufptr = save_char(bufptr, ch1);
 		}
-		if (strchr("doxX.", *str)) {
-		    if (*str != 'd')	/* termcap doesn't have octal, hex */
-			return 0;
+		if (strchr("oxX.", *str)) {
+		    syntax_error = TRUE;	/* termcap doesn't have octal, hex */
 		}
 		break;
 
@@ -811,14 +940,16 @@
 		break;
 
 		/*
-		 * %s isn't in termcap, but it's convenient to pass it through
+		 * %s isn't in termcap, but it is convenient to pass it through
 		 * so we can represent things like terminfo pfkey strings in
 		 * termcap notation.
 		 */
 	    case 's':
-		if (_nc_strict_bsd)
-		    return 0;
-		bufptr = save_string(bufptr, "%s");
+		if (_nc_strict_bsd) {
+		    syntax_error = TRUE;
+		} else {
+		    bufptr = save_string(bufptr, "%s");
+		}
 		break;
 
 	    case 'p':
@@ -830,8 +961,9 @@
 			bufptr = save_string(bufptr, "%r");
 			seentwo++;
 		    }
-		} else if (*str >= '3')
-		    return (0);
+		} else if (*str >= '3') {
+		    syntax_error = TRUE;
+		}
 		break;
 
 	    case 'i':
@@ -855,6 +987,24 @@
 
     }				/* endwhile (*str) */
 
+    if (!syntax_error &&
+	myfix > 0 &&
+	((int) strlen(my_string) - (4 * myfix)) < MIN_TC_FIXUPS) {
+	while (--myfix >= 0) {
+	    char *p = fixups[myfix].offset + my_string;
+	    *p++ = '^';
+	    *p++ = (char) (fixups[myfix].ch | '@');
+	    while ((p[0] = p[2]) != '\0') {
+		++p;
+	    }
+	}
+    }
+
+    DEBUG_THIS(("... _nc_infotocap %s",
+		syntax_error
+		? "<ERR>"
+		: _nc_visbuf(my_string)));
+
     return (syntax_error ? NULL : my_string);
 }
 
diff --git a/ncurses/tinfo/comp_error.c b/ncurses/tinfo/comp_error.c
index ff0acc7..3e6b402 100644
--- a/ncurses/tinfo/comp_error.c
+++ b/ncurses/tinfo/comp_error.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2012,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -41,7 +42,7 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: comp_error.c,v 1.36 2012/02/22 22:34:31 tom Exp $")
+MODULE_ID("$Id: comp_error.c,v 1.44 2023/06/15 20:27:02 tom Exp $")
 
 NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings = FALSE;
 NCURSES_EXPORT_VAR(int) _nc_curr_line = 0; /* current line # in input */
@@ -59,19 +60,28 @@
 NCURSES_EXPORT(void)
 _nc_set_source(const char *const name)
 {
-    FreeIfNeeded(SourceName);
-    SourceName = strdup(name);
+    if (name == NULL) {
+	free(SourceName);
+	SourceName = NULL;
+    } else if (SourceName == NULL) {
+	SourceName = strdup(name);
+    } else if (strcmp(name, SourceName)) {
+	free(SourceName);
+	SourceName = strdup(name);
+    }
 }
 
 NCURSES_EXPORT(void)
 _nc_set_type(const char *const name)
 {
+#define MY_SIZE (size_t) MAX_NAME_SIZE
     if (TermType == 0)
-	TermType = typeMalloc(char, MAX_NAME_SIZE + 1);
+	TermType = typeMalloc(char, MY_SIZE + 1);
     if (TermType != 0) {
 	TermType[0] = '\0';
-	if (name)
-	    strncat(TermType, name, (size_t) MAX_NAME_SIZE);
+	if (name) {
+	    _nc_STRNCAT(TermType, name, MY_SIZE, MY_SIZE);
+	}
     }
 }
 
@@ -92,9 +102,9 @@
 where_is_problem(void)
 {
     fprintf(stderr, "\"%s\"", SourceName ? SourceName : "?");
-    if (_nc_curr_line >= 0)
+    if (_nc_curr_line > 0)
 	fprintf(stderr, ", line %d", _nc_curr_line);
-    if (_nc_curr_col >= 0)
+    if (_nc_curr_col > 0)
 	fprintf(stderr, ", col %d", _nc_curr_col);
     if (TermType != 0 && TermType[0] != '\0')
 	fprintf(stderr, ", terminal '%s'", TermType);
@@ -103,7 +113,7 @@
 }
 
 NCURSES_EXPORT(void)
-_nc_warning(const char *const fmt,...)
+_nc_warning(const char *const fmt, ...)
 {
     va_list argp;
 
@@ -118,7 +128,7 @@
 }
 
 NCURSES_EXPORT(void)
-_nc_err_abort(const char *const fmt,...)
+_nc_err_abort(const char *const fmt, ...)
 {
     va_list argp;
 
@@ -131,7 +141,7 @@
 }
 
 NCURSES_EXPORT(void)
-_nc_syserr_abort(const char *const fmt,...)
+_nc_syserr_abort(const char *const fmt, ...)
 {
     va_list argp;
 
@@ -141,16 +151,16 @@
     fprintf(stderr, "\n");
     va_end(argp);
 
+#if defined(TRACE) || !defined(NDEBUG)
     /* If we're debugging, try to show where the problem occurred - this
      * will dump core.
      */
-#if defined(TRACE) || !defined(NDEBUG)
-    abort();
-#else
+    if (_nc_env_access())
+	abort();
+#endif
     /* Dumping core in production code is not a good idea.
      */
     exit(EXIT_FAILURE);
-#endif
 }
 
 #if NO_LEAKS
diff --git a/ncurses/tinfo/comp_expand.c b/ncurses/tinfo/comp_expand.c
index 2ab06eb..e971384 100644
--- a/ncurses/tinfo/comp_expand.c
+++ b/ncurses/tinfo/comp_expand.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -27,7 +28,7 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey <dickey@clark.net> 1998                        *
+ *  Author: Thomas E. Dickey                    1998                        *
  ****************************************************************************/
 
 #include <curses.priv.h>
@@ -35,7 +36,13 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: comp_expand.c,v 1.25 2012/03/24 18:37:17 tom Exp $")
+MODULE_ID("$Id: comp_expand.c,v 1.35 2023/04/28 20:59:06 tom Exp $")
+
+#if 0
+#define DEBUG_THIS(p) DEBUG(9, p)
+#else
+#define DEBUG_THIS(p)		/* nothing */
+#endif
 
 static int
 trailing_spaces(const char *src)
@@ -46,10 +53,9 @@
 }
 
 /* this deals with differences over whether 0x7f and 0x80..0x9f are controls */
-#define REALCTL(s) (UChar(*(s)) < 127 && iscntrl(UChar(*(s))))
 #define REALPRINT(s) (UChar(*(s)) < 127 && isprint(UChar(*(s))))
 
-#define P_LIMIT(p) (length - (size_t)(p))
+#define P_LIMIT(p)   (length - (size_t)(p))
 
 NCURSES_EXPORT(char *)
 _nc_tic_expand(const char *srcp, bool tic_format, int numbers)
@@ -59,9 +65,13 @@
 
     int bufp;
     const char *str = VALID_STRING(srcp) ? srcp : "\0\0";
-    bool islong = (strlen(str) > 3);
     size_t need = (2 + strlen(str)) * 4;
     int ch;
+    int octals = 0;
+    struct {
+	int ch;
+	int offset;
+    } fixups[MAX_TC_FIXUPS];
 
     if (srcp == 0) {
 #if NO_LEAKS
@@ -77,6 +87,10 @@
 	      return 0;
     }
 
+    DEBUG_THIS(("_nc_tic_expand %s:%s:%s",
+		tic_format ? "ti" : "tc",
+		numbers ? "#" : "",
+		_nc_visbuf(srcp)));
     bufp = 0;
     while ((ch = UChar(*str)) != 0) {
 	if (ch == '%' && REALPRINT(str + 1)) {
@@ -115,7 +129,6 @@
 		    if (dst != 0
 			&& *dst == R_BRACE
 			&& value < 127
-			&& value != '\\'	/* FIXME */
 			&& isprint((int) value)) {
 			ch = (int) value;
 			buffer[bufp++] = S_QUOTE;
@@ -133,6 +146,8 @@
 		}
 		break;
 	    default:
+		if (*str == ',')	/* minitel1 uses this */
+		    buffer[bufp++] = '\\';
 		buffer[bufp++] = *str;
 		break;
 	    }
@@ -149,43 +164,37 @@
 					       trailing_spaces(str))) {
 	    buffer[bufp++] = '\\';
 	    buffer[bufp++] = 's';
-	} else if ((ch == ',' || ch == ':' || ch == '^') && tic_format) {
+	} else if ((ch == ',' || ch == '^') && tic_format) {
 	    buffer[bufp++] = '\\';
 	    buffer[bufp++] = (char) ch;
 	} else if (REALPRINT(str)
 		   && (ch != ','
-		       && ch != ':'
+		       && !(ch == ':' && !tic_format)
 		       && !(ch == '!' && !tic_format)
 		       && ch != '^'))
 	    buffer[bufp++] = (char) ch;
-#if 0				/* FIXME: this would be more readable (in fact the whole 'islong' logic should be removed) */
-	else if (ch == '\b') {
-	    buffer[bufp++] = '\\';
-	    buffer[bufp++] = 'b';
-	} else if (ch == '\f') {
-	    buffer[bufp++] = '\\';
-	    buffer[bufp++] = 'f';
-	} else if (ch == '\t' && islong) {
-	    buffer[bufp++] = '\\';
-	    buffer[bufp++] = 't';
-	}
-#endif
-	else if (ch == '\r' && (islong || (strlen(srcp) > 2 && str[1] == '\0'))) {
+	else if (ch == '\r') {
 	    buffer[bufp++] = '\\';
 	    buffer[bufp++] = 'r';
-	} else if (ch == '\n' && islong) {
+	} else if (ch == '\n') {
 	    buffer[bufp++] = '\\';
 	    buffer[bufp++] = 'n';
 	}
 #define UnCtl(c) ((c) + '@')
-	else if (REALCTL(str) && ch != '\\'
-		 && (!islong || isdigit(UChar(str[1])))) {
+	else if (UChar(ch) < 32
+		 && isdigit(UChar(str[1]))) {
 	    _nc_SPRINTF(&buffer[bufp], _nc_SLIMIT(P_LIMIT(bufp))
 			"^%c", UnCtl(ch));
 	    bufp += 2;
 	} else {
 	    _nc_SPRINTF(&buffer[bufp], _nc_SLIMIT(P_LIMIT(bufp))
 			"\\%03o", ch);
+	    if ((octals < MAX_TC_FIXUPS) &&
+		((tic_format && (ch == 127)) || ch < 32)) {
+		fixups[octals].ch = UChar(ch);
+		fixups[octals].offset = bufp;
+		++octals;
+	    }
 	    bufp += 4;
 	}
 
@@ -193,5 +202,26 @@
     }
 
     buffer[bufp] = '\0';
+
+    /*
+     * If most of a short string is ASCII control characters, reformat the
+     * string to show those in up-arrow format.  For longer strings, it is
+     * more likely that the characters are just binary coding.
+     *
+     * If we're formatting termcap, just use the shorter format (up-arrows).
+     */
+    if (octals != 0 && (!tic_format || (bufp - (4 * octals)) < MIN_TC_FIXUPS)) {
+	while (--octals >= 0) {
+	    char *p = buffer + fixups[octals].offset;
+	    *p++ = '^';
+	    *p++ = (char) ((fixups[octals].ch == 127)
+			   ? '?'
+			   : (fixups[octals].ch + (int) '@'));
+	    while ((p[0] = p[2]) != 0) {
+		++p;
+	    }
+	}
+    }
+    DEBUG_THIS(("... %s", _nc_visbuf(buffer)));
     return (buffer);
 }
diff --git a/ncurses/tinfo/comp_hash.c b/ncurses/tinfo/comp_hash.c
index 959c6e1..4b081af 100644
--- a/ncurses/tinfo/comp_hash.c
+++ b/ncurses/tinfo/comp_hash.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2008,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -44,13 +45,12 @@
 #include <tic.h>
 #include <hashsize.h>
 
-MODULE_ID("$Id: comp_hash.c,v 1.48 2009/08/08 17:36:21 tom Exp $")
+MODULE_ID("$Id: comp_hash.c,v 1.55 2023/06/24 13:29:43 tom Exp $")
 
 /*
  * Finds the entry for the given string in the hash table if present.
  * Returns a pointer to the entry in the table or 0 if not found.
  */
-/* entrypoint used by tack (do not alter) */
 NCURSES_EXPORT(struct name_table_entry const *)
 _nc_find_entry(const char *string,
 	       const HashValue * hash_table)
@@ -63,7 +63,9 @@
 
     hashvalue = data->hash_of(string);
 
-    if (data->table_data[hashvalue] >= 0) {
+    if (hashvalue >= 0
+	&& (unsigned) hashvalue < data->table_size
+	&& data->table_data[hashvalue] >= 0) {
 
 	real_table = _nc_get_table(termcap);
 	ptr = real_table + data->table_data[hashvalue];
@@ -96,19 +98,54 @@
     const HashData *data = _nc_get_hash_info(termcap);
     int hashvalue = data->hash_of(string);
 
-    if (data->table_data[hashvalue] >= 0) {
+    if (hashvalue >= 0
+	&& (unsigned) hashvalue < data->table_size
+	&& data->table_data[hashvalue] >= 0) {
 	const struct name_table_entry *const table = _nc_get_table(termcap);
 
-	ptr = table + data->table_data[hashvalue];
-	while (ptr->nte_type != type
-	       || !data->compare_names(ptr->nte_name, string)) {
-	    if (ptr->nte_link < 0) {
-		ptr = 0;
-		break;
+	if (table != NULL) {
+	    ptr = table + data->table_data[hashvalue];
+	    while (ptr->nte_type != type
+		   || !data->compare_names(ptr->nte_name, string)) {
+		if (ptr->nte_link < 0) {
+		    ptr = 0;
+		    break;
+		}
+		ptr = table + (ptr->nte_link + data->table_data[data->table_size]);
 	    }
-	    ptr = table + (ptr->nte_link + data->table_data[data->table_size]);
 	}
     }
 
     return ptr;
 }
+
+#if NCURSES_XNAMES
+NCURSES_EXPORT(struct user_table_entry const *)
+_nc_find_user_entry(const char *string)
+{
+    const HashData *data = _nc_get_hash_user();
+    int hashvalue;
+    struct user_table_entry const *ptr = 0;
+    struct user_table_entry const *real_table;
+
+    hashvalue = data->hash_of(string);
+
+    if (hashvalue >= 0
+	&& (unsigned) hashvalue < data->table_size
+	&& data->table_data[hashvalue] >= 0) {
+
+	real_table = _nc_get_userdefs_table();
+	ptr = real_table + data->table_data[hashvalue];
+	while (!data->compare_names(ptr->ute_name, string)) {
+	    if (ptr->ute_link < 0) {
+		ptr = 0;
+		break;
+	    }
+	    ptr = real_table + (ptr->ute_link
+				+ data->table_data[data->table_size]);
+	}
+    }
+
+    return (ptr);
+}
+#endif /* NCURSES_XNAMES */
diff --git a/ncurses/tinfo/comp_parse.c b/ncurses/tinfo/comp_parse.c
index 82a61a5..dec4b92 100644
--- a/ncurses/tinfo/comp_parse.c
+++ b/ncurses/tinfo/comp_parse.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -47,23 +48,22 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: comp_parse.c,v 1.90 2013/08/31 15:22:31 tom Exp $")
+MODULE_ID("$Id: comp_parse.c,v 1.134 2024/02/10 15:52:11 tom Exp $")
 
-static void sanity_check2(TERMTYPE *, bool);
-NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype2) (TERMTYPE *, bool) = sanity_check2;
+static void sanity_check2(TERMTYPE2 *, bool);
+NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2) (TERMTYPE2 *, bool) = sanity_check2;
 
-/* obsolete: 20040705 */
-static void sanity_check(TERMTYPE *);
-NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype) (TERMTYPE *) = sanity_check;
-
-static void fixup_acsc(TERMTYPE *, int);
+static void fixup_acsc(TERMTYPE2 *, int);
 
 static void
 enqueue(ENTRY * ep)
 /* add an entry to the in-core list */
 {
-    ENTRY *newp = _nc_copy_entry(ep);
+    ENTRY *newp;
 
+    DEBUG(2, (T_CALLED("enqueue(ep=%p)"), (void *) ep));
+
+    newp = _nc_copy_entry(ep);
     if (newp == 0)
 	_nc_err_abort(MSG_NO_MEMORY);
 
@@ -73,8 +73,11 @@
     newp->next = 0;
     if (newp->last)
 	newp->last->next = newp;
+    DEBUG(2, (T_RETURN("")));
 }
 
+#define NAMEBUFFER_SIZE (MAX_NAME_SIZE + 2)
+
 static char *
 force_bar(char *dst, char *src)
 {
@@ -82,8 +85,8 @@
 	size_t len = strlen(src);
 	if (len > MAX_NAME_SIZE)
 	    len = MAX_NAME_SIZE;
-	(void) strncpy(dst, src, len);
-	_nc_STRCPY(dst + len, "|", MAX_NAME_SIZE);
+	_nc_STRNCPY(dst, src, MAX_NAME_SIZE);
+	_nc_STRCPY(dst + len, "|", NAMEBUFFER_SIZE - len);
 	src = dst;
     }
     return src;
@@ -107,8 +110,8 @@
 check_collisions(char *n1, char *n2, int counter)
 {
     char *pstart, *qstart, *pend, *qend;
-    char nc1[MAX_NAME_SIZE + 2];
-    char nc2[MAX_NAME_SIZE + 2];
+    char nc1[NAMEBUFFER_SIZE];
+    char nc2[NAMEBUFFER_SIZE];
 
     n1 = ForceBar(nc1, n1);
     n2 = ForceBar(nc2, n2);
@@ -182,11 +185,11 @@
 			++qend;
 		    while ((*qstart++ = *qend++) != '\0') ;
 		    fprintf(stderr, "...now\t%s\n", p2);
+		    removed = TRUE;
 		} else {
 		    fprintf(stderr, "Cannot remove alias '%.*s'\n",
 			    (int) (qend - qstart), qstart);
 		}
-		removed = TRUE;
 		break;
 	    }
 	}
@@ -218,6 +221,12 @@
     bool oldsuppress = _nc_suppress_warnings;
     int immediate = 0;
 
+    DEBUG(2,
+	  (T_CALLED("_nc_read_entry_source("
+		    "file=%p, buf=%p, literal=%d, silent=%d, hook=%#"
+		    PRIxPTR ")"),
+	   (void *) fp, buf, literal, silent, CASTxPTR(hook)));
+
     if (silent)
 	_nc_suppress_warnings = TRUE;	/* shut the lexer up, too */
 
@@ -245,38 +254,159 @@
 	    FreeIfNeeded(thisentry.tterm.Booleans);
 	    FreeIfNeeded(thisentry.tterm.Numbers);
 	    FreeIfNeeded(thisentry.tterm.Strings);
+	    FreeIfNeeded(thisentry.tterm.str_table);
 #if NCURSES_XNAMES
 	    FreeIfNeeded(thisentry.tterm.ext_Names);
+	    FreeIfNeeded(thisentry.tterm.ext_str_table);
 #endif
 	}
     }
 
     if (_nc_tail) {
 	/* set up the head pointer */
-	for (_nc_head = _nc_tail; _nc_head->last; _nc_head = _nc_head->last)
-	    continue;
+	for (_nc_head = _nc_tail; _nc_head->last; _nc_head = _nc_head->last) {
+	    /* EMPTY */ ;
+	}
 
-	DEBUG(1, ("head = %s", _nc_head->tterm.term_names));
-	DEBUG(1, ("tail = %s", _nc_tail->tterm.term_names));
+	DEBUG(2, ("head = %s", _nc_head->tterm.term_names));
+	DEBUG(2, ("tail = %s", _nc_tail->tterm.term_names));
     }
 #ifdef TRACE
     else if (!immediate)
-	DEBUG(1, ("no entries parsed"));
+	DEBUG(2, ("no entries parsed"));
 #endif
 
     _nc_suppress_warnings = oldsuppress;
+    DEBUG(2, (T_RETURN("")));
 }
 
+#if 0 && NCURSES_XNAMES
+static unsigned
+find_capname(TERMTYPE2 *p, const char *name)
+{
+    unsigned num_names = NUM_EXT_NAMES(p);
+    unsigned n;
+    if (name != 0) {
+	for (n = 0; n < num_names; ++n) {
+	    if (!strcmp(p->ext_Names[n], name))
+		break;
+	}
+    } else {
+	n = num_names + 1;
+    }
+    return n;
+}
+
+static int
+extended_captype(TERMTYPE2 *p, unsigned which)
+{
+    int result = UNDEF;
+    unsigned limit = 0;
+    limit += p->ext_Booleans;
+    if (limit != 0 && which < limit) {
+	result = BOOLEAN;
+    } else {
+	limit += p->ext_Numbers;
+	if (limit != 0 && which < limit) {
+	    result = NUMBER;
+	} else {
+	    limit += p->ext_Strings;
+	    if (limit != 0 && which < limit) {
+		result = ((p->Strings[STRCOUNT + which] != CANCELLED_STRING)
+			  ? STRING
+			  : CANCEL);
+	    } else if (which >= limit) {
+		result = CANCEL;
+	    }
+	}
+    }
+    return result;
+}
+
+static const char *
+name_of_captype(int which)
+{
+    const char *result = "?";
+    switch (which) {
+    case BOOLEAN:
+	result = "boolean";
+	break;
+    case NUMBER:
+	result = "number";
+	break;
+    case STRING:
+	result = "string";
+	break;
+    }
+    return result;
+}
+
+#define valid_TERMTYPE2(p) \
+	((p) != 0 && \
+	 (p)->term_names != 0 && \
+	 (p)->ext_Names != 0)
+
+/*
+ * Disallow changing the type of an extended capability when doing a "use"
+ * if one or the other is a string.
+ */
+static int
+invalid_merge(TERMTYPE2 *to, TERMTYPE2 *from)
+{
+    int rc = FALSE;
+    if (valid_TERMTYPE2(to)
+	&& valid_TERMTYPE2(from)) {
+	char *to_name = _nc_first_name(to->term_names);
+	char *from_name = strdup(_nc_first_name(from->term_names));
+	unsigned num_names = NUM_EXT_NAMES(from);
+	unsigned n;
+
+	for (n = 0; n < num_names; ++n) {
+	    const char *capname = from->ext_Names[n];
+	    int tt = extended_captype(to, find_capname(to, capname));
+	    int tf = extended_captype(from, n);
+
+	    if (tt <= STRING
+		&& tf <= STRING
+		&& (tt == STRING) != (tf == STRING)) {
+		if (from_name != 0 && strcmp(to_name, from_name)) {
+		    _nc_warning("merge of %s to %s changes type of %s from %s to %s",
+				from_name,
+				to_name,
+				from->ext_Names[n],
+				name_of_captype(tf),
+				name_of_captype(tt));
+		} else {
+		    _nc_warning("merge of %s changes type of %s from %s to %s",
+				to_name,
+				from->ext_Names[n],
+				name_of_captype(tf),
+				name_of_captype(tt));
+		}
+		rc = TRUE;
+	    }
+	}
+	free(from_name);
+    }
+    return rc;
+}
+#define validate_merge(p, q) \
+	if (invalid_merge(&((p)->tterm), &((q)->tterm))) \
+		return FALSE
+#else
+#define validate_merge(p, q)	/* nothing */
+#endif
+
 NCURSES_EXPORT(int)
 _nc_resolve_uses2(bool fullresolve, bool literal)
 /* try to resolve all use capabilities */
 {
     ENTRY *qp, *rp, *lastread = 0;
     bool keepgoing;
-    unsigned i;
-    int unresolved, total_unresolved, multiples;
+    unsigned i, j;
+    int total_unresolved, multiples;
 
-    DEBUG(2, ("RESOLUTION BEGINNING"));
+    DEBUG(2, (T_CALLED("_nc_resolve_uses2")));
 
     /*
      * Check for multiple occurrences of the same name.
@@ -285,7 +415,7 @@
     for_entry_list(qp) {
 	int matchcount = 0;
 
-	for_entry_list(rp) {
+	for_entry_list2(rp, qp->next) {
 	    if (qp > rp
 		&& check_collisions(qp->tterm.term_names,
 				    rp->tterm.term_names,
@@ -301,8 +431,10 @@
 	    }
 	}
     }
-    if (multiples > 0)
+    if (multiples > 0) {
+	DEBUG(2, (T_RETURN("false")));
 	return (FALSE);
+    }
 
     DEBUG(2, ("NO MULTIPLE NAME OCCURRENCES"));
 
@@ -312,13 +444,15 @@
     total_unresolved = 0;
     _nc_curr_col = -1;
     for_entry_list(qp) {
-	unresolved = 0;
 	for (i = 0; i < qp->nuses; i++) {
 	    bool foundit;
 	    char *child = _nc_first_name(qp->tterm.term_names);
 	    char *lookfor = qp->uses[i].name;
 	    long lookline = qp->uses[i].line;
 
+	    if (lookfor == 0)
+		continue;
+
 	    foundit = FALSE;
 
 	    _nc_set_type(child);
@@ -327,21 +461,31 @@
 	    for_entry_list(rp) {
 		if (rp != qp
 		    && _nc_name_match(rp->tterm.term_names, lookfor, "|")) {
-		    DEBUG(2, ("%s: resolving use=%s (in core)",
-			      child, lookfor));
+		    DEBUG(2, ("%s: resolving use=%s %p (in core)",
+			      child, lookfor, lookfor));
 
 		    qp->uses[i].link = rp;
 		    foundit = TRUE;
+
+		    /* verify that there are no earlier uses */
+		    for (j = 0; j < i; ++j) {
+			if (qp->uses[j].link != NULL
+			    && !strcmp(qp->uses[j].link->tterm.term_names,
+				       rp->tterm.term_names)) {
+			    _nc_warning("duplicate use=%s", lookfor);
+			    break;
+			}
+		    }
 		}
 	    }
 
 	    /* if that didn't work, try to merge in a compiled entry */
 	    if (!foundit) {
-		TERMTYPE thisterm;
+		TERMTYPE2 thisterm;
 		char filename[PATH_MAX];
 
 		memset(&thisterm, 0, sizeof(thisterm));
-		if (_nc_read_entry(lookfor, filename, &thisterm) == 1) {
+		if (_nc_read_entry2(lookfor, filename, &thisterm) == 1) {
 		    DEBUG(2, ("%s: resolving use=%s (compiled)",
 			      child, lookfor));
 
@@ -353,12 +497,21 @@
 
 		    qp->uses[i].link = rp;
 		    foundit = TRUE;
+
+		    /* verify that there are no earlier uses */
+		    for (j = 0; j < i; ++j) {
+			if (qp->uses[j].link != NULL
+			    && !strcmp(qp->uses[j].link->tterm.term_names,
+				       rp->tterm.term_names)) {
+			    _nc_warning("duplicate use=%s", lookfor);
+			    break;
+			}
+		    }
 		}
 	    }
 
 	    /* no good, mark this one unresolvable and complain */
 	    if (!foundit) {
-		unresolved++;
 		total_unresolved++;
 
 		_nc_curr_line = (int) lookline;
@@ -370,6 +523,7 @@
     if (total_unresolved) {
 	/* free entries read in off disk */
 	_nc_free_entries(lastread);
+	DEBUG(2, (T_RETURN("false")));
 	return (FALSE);
     }
 
@@ -382,25 +536,28 @@
      */
     if (fullresolve) {
 	do {
-	    TERMTYPE merged;
+	    ENTRY merged;
 
 	    keepgoing = FALSE;
 
 	    for_entry_list(qp) {
 		if (qp->nuses > 0) {
-		    DEBUG(2, ("%s: attempting merge",
-			      _nc_first_name(qp->tterm.term_names)));
+		    DEBUG(2, ("%s: attempting merge of %d entries",
+			      _nc_first_name(qp->tterm.term_names),
+			      qp->nuses));
 		    /*
 		     * If any of the use entries we're looking for is
 		     * incomplete, punt.  We'll catch this entry on a
 		     * subsequent pass.
 		     */
-		    for (i = 0; i < qp->nuses; i++)
-			if (qp->uses[i].link->nuses) {
+		    for (i = 0; i < qp->nuses; i++) {
+			if (qp->uses[i].link
+			    && qp->uses[i].link->nuses) {
 			    DEBUG(2, ("%s: use entry %d unresolved",
 				      _nc_first_name(qp->tterm.term_names), i));
 			    goto incomplete;
 			}
+		    }
 
 		    /*
 		     * First, make sure there is no garbage in the
@@ -408,20 +565,24 @@
 		     * the merged entry the name field and string
 		     * table pointer.
 		     */
-		    _nc_copy_termtype(&merged, &(qp->tterm));
+		    _nc_copy_termtype2(&(merged.tterm), &(qp->tterm));
 
 		    /*
 		     * Now merge in each use entry in the proper
 		     * (reverse) order.
 		     */
-		    for (; qp->nuses; qp->nuses--)
-			_nc_merge_entry(&merged,
-					&qp->uses[qp->nuses - 1].link->tterm);
+		    for (; qp->nuses; qp->nuses--) {
+			int n = (int) (qp->nuses - 1);
+			validate_merge(&merged, qp->uses[n].link);
+			_nc_merge_entry(&merged, qp->uses[n].link);
+			free(qp->uses[n].name);
+		    }
 
 		    /*
 		     * Now merge in the original entry.
 		     */
-		    _nc_merge_entry(&merged, &qp->tterm);
+		    validate_merge(&merged, qp);
+		    _nc_merge_entry(&merged, qp);
 
 		    /*
 		     * Replace the original entry with the merged one.
@@ -429,10 +590,12 @@
 		    FreeIfNeeded(qp->tterm.Booleans);
 		    FreeIfNeeded(qp->tterm.Numbers);
 		    FreeIfNeeded(qp->tterm.Strings);
+		    FreeIfNeeded(qp->tterm.str_table);
 #if NCURSES_XNAMES
 		    FreeIfNeeded(qp->tterm.ext_Names);
+		    FreeIfNeeded(qp->tterm.ext_str_table);
 #endif
-		    qp->tterm = merged;
+		    qp->tterm = merged.tterm;
 		    _nc_wrap_entry(qp, TRUE);
 
 		    /*
@@ -450,63 +613,57 @@
 	DEBUG(2, ("MERGES COMPLETED OK"));
     }
 
-    /*
-     * We'd like to free entries read in off disk at this point, but can't.
-     * The merge_entry() code doesn't copy the strings in the use entries,
-     * it just aliases them.  If this ever changes, do a
-     * free_entries(lastread) here.
-     */
-
     DEBUG(2, ("RESOLUTION FINISHED"));
 
-    if (fullresolve)
-	if (_nc_check_termtype != 0) {
-	    _nc_curr_col = -1;
-	    for_entry_list(qp) {
-		_nc_curr_line = (int) qp->startline;
-		_nc_set_type(_nc_first_name(qp->tterm.term_names));
+    if (fullresolve) {
+	_nc_curr_col = -1;
+	for_entry_list(qp) {
+	    _nc_curr_line = (int) qp->startline;
+	    _nc_set_type(_nc_first_name(qp->tterm.term_names));
+	    /*
+	     * tic overrides this function pointer to provide more verbose
+	     * checking.
+	     */
+	    if (_nc_check_termtype2 != sanity_check2) {
+		SCREEN *save_SP = SP;
+		SCREEN fake_sp;
+		TERMINAL fake_tm;
+		TERMINAL *save_tm = cur_term;
+
 		/*
-		 * tic overrides this function pointer to provide more verbose
-		 * checking.
+		 * Setup so that tic can use ordinary terminfo interface to
+		 * obtain capability information.
 		 */
-		if (_nc_check_termtype2 != sanity_check2) {
-		    SCREEN *save_SP = SP;
-		    SCREEN fake_sp;
-		    TERMINAL fake_tm;
-		    TERMINAL *save_tm = cur_term;
+		memset(&fake_sp, 0, sizeof(fake_sp));
+		memset(&fake_tm, 0, sizeof(fake_tm));
+		fake_sp._term = &fake_tm;
+		TerminalType(&fake_tm) = qp->tterm;
+		_nc_set_screen(&fake_sp);
+		set_curterm(&fake_tm);
 
-		    /*
-		     * Setup so that tic can use ordinary terminfo interface
-		     * to obtain capability information.
-		     */
-		    memset(&fake_sp, 0, sizeof(fake_sp));
-		    memset(&fake_tm, 0, sizeof(fake_tm));
-		    fake_sp._term = &fake_tm;
-		    fake_tm.type = qp->tterm;
-		    _nc_set_screen(&fake_sp);
-		    set_curterm(&fake_tm);
+		_nc_check_termtype2(&qp->tterm, literal);
 
-		    _nc_check_termtype2(&qp->tterm, literal);
+		/*
+		 * Checking calls tparm, which can allocate memory.  Fix leaks.
+		 */
+#define TPS(name) fake_tm.tparm_state.name
+		FreeAndNull(TPS(out_buff));
+		FreeAndNull(TPS(fmt_buff));
+#undef TPS
 
-		    _nc_set_screen(save_SP);
-		    set_curterm(save_tm);
-		} else {
-		    fixup_acsc(&qp->tterm, literal);
-		}
+		_nc_set_screen(save_SP);
+		set_curterm(save_tm);
+	    } else {
+		fixup_acsc(&qp->tterm, literal);
 	    }
-	    DEBUG(2, ("SANITY CHECK FINISHED"));
 	}
+	DEBUG(2, ("SANITY CHECK FINISHED"));
+    }
 
+    DEBUG(2, (T_RETURN("true")));
     return (TRUE);
 }
 
-/* obsolete: 20040705 */
-NCURSES_EXPORT(int)
-_nc_resolve_uses(bool fullresolve)
-{
-    return _nc_resolve_uses2(fullresolve, FALSE);
-}
-
 /*
  * This bit of legerdemain turns all the terminfo variable names into
  * references to locations in the arrays Booleans, Numbers, and Strings ---
@@ -517,18 +674,18 @@
 #define CUR tp->
 
 static void
-fixup_acsc(TERMTYPE *tp, int literal)
+fixup_acsc(TERMTYPE2 *tp, int literal)
 {
     if (!literal) {
-	if (acs_chars == 0
-	    && enter_alt_charset_mode != 0
-	    && exit_alt_charset_mode != 0)
+	if (acs_chars == ABSENT_STRING
+	    && PRESENT(enter_alt_charset_mode)
+	    && PRESENT(exit_alt_charset_mode))
 	    acs_chars = strdup(VT_ACSC);
     }
 }
 
 static void
-sanity_check2(TERMTYPE *tp, bool literal)
+sanity_check2(TERMTYPE2 *tp, bool literal)
 {
     if (!PRESENT(exit_attribute_mode)) {
 #ifdef __UNUSED__		/* this casts too wide a net */
@@ -547,7 +704,9 @@
 #endif /* __UNUSED__ */
 	PAIRED(enter_standout_mode, exit_standout_mode);
 	PAIRED(enter_underline_mode, exit_underline_mode);
+#if defined(enter_italics_mode) && defined(exit_italics_mode)
 	PAIRED(enter_italics_mode, exit_italics_mode);
+#endif
     }
 
     /* we do this check/fix in postprocess_termcap(), but some packagers
@@ -578,23 +737,18 @@
     PAIRED(enter_xon_mode, exit_xon_mode);
     PAIRED(enter_am_mode, exit_am_mode);
     ANDMISSING(label_off, label_on);
-#ifdef remove_clock
+#if defined(display_clock) && defined(remove_clock)
     PAIRED(display_clock, remove_clock);
 #endif
     ANDMISSING(set_color_pair, initialize_pair);
 }
 
-/* obsolete: 20040705 */
-static void
-sanity_check(TERMTYPE *tp)
-{
-    sanity_check2(tp, FALSE);
-}
-
 #if NO_LEAKS
 NCURSES_EXPORT(void)
 _nc_leaks_tic(void)
 {
+    T((T_CALLED("_nc_leaks_tic()")));
+    _nc_globals.leak_checking = TRUE;
     _nc_alloc_entry_leaks();
     _nc_captoinfo_leaks();
     _nc_comp_scan_leaks();
@@ -603,12 +757,14 @@
     _nc_codes_leaks();
 #endif
     _nc_tic_expand(0, FALSE, 0);
+    T((T_RETURN("")));
 }
 
 NCURSES_EXPORT(void)
 _nc_free_tic(int code)
 {
+    T((T_CALLED("_nc_free_tic(%d)"), code));
     _nc_leaks_tic();
-    _nc_free_tinfo(code);
+    exit_terminfo(code);
 }
 #endif
diff --git a/ncurses/tinfo/comp_scan.c b/ncurses/tinfo/comp_scan.c
index fe6e8e7..3ba0835 100644
--- a/ncurses/tinfo/comp_scan.c
+++ b/ncurses/tinfo/comp_scan.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+,* Copyright 2020-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -50,7 +51,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: comp_scan.c,v 1.102 2013/11/16 19:57:50 tom Exp $")
+MODULE_ID("$Id: comp_scan.c,v 1.122 2023/05/27 20:13:10 tom Exp $")
 
 /*
  * Maximum length of string capability we'll accept before raising an error.
@@ -111,6 +112,9 @@
 NCURSES_EXPORT(void)
 _nc_reset_input(FILE *fp, char *buf)
 {
+    TR(TRACE_DATABASE,
+       (T_CALLED("_nc_reset_input(fp=%p, buf=%p)"), (void *) fp, buf));
+
     pushtype = NO_PUSHBACK;
     if (pushname != 0)
 	pushname[0] = '\0';
@@ -120,6 +124,8 @@
     if (fp != 0)
 	_nc_curr_line = 0;
     _nc_curr_col = 0;
+
+    returnVoidDB;
 }
 
 /*
@@ -135,7 +141,7 @@
 
     while (len--) {
 	if (!isspace(UChar(bufptr[len]))) {
-	    if (from_end < (int) len)
+	    if (from_end <= (int) len)
 		result = bufptr[(int) len - from_end];
 	    break;
 	}
@@ -144,6 +150,32 @@
 }
 
 /*
+ * Read, like fgets(), but error-out if the input contains nulls.
+ */
+static int
+get_text(char *buffer, int length)
+{
+    int count = 0;
+    int limit = length - 1;
+
+    while (limit-- > 0) {
+	int ch = fgetc(yyin);
+
+	if (ch == '\0') {
+	    _nc_err_abort("This is not a text-file");
+	} else if (ch == EOF) {
+	    break;
+	}
+	++count;
+	*buffer++ = (char) ch;
+	if (ch == '\n')
+	    break;
+    }
+    *buffer = '\0';
+    return count;
+}
+
+/*
  *	int next_char()
  *
  *	Returns the next character in the input stream.  Comments and leading
@@ -168,6 +200,8 @@
 	if (result != 0) {
 	    FreeAndNull(result);
 	    FreeAndNull(pushname);
+	    bufptr = 0;
+	    bufstart = 0;
 	    allocated = 0;
 	}
 	/*
@@ -189,12 +223,11 @@
 	 * quite hard to get completely right.  Try it and see.  If you
 	 * succeed, don't forget to hack push_back() correspondingly.
 	 */
-	size_t used;
 	size_t len;
 
 	do {
+	    size_t used = 0;
 	    bufstart = 0;
-	    used = 0;
 	    do {
 		if (used + (LEXBUFSIZ / 4) >= allocated) {
 		    allocated += (allocated + LEXBUFSIZ);
@@ -207,7 +240,7 @@
 		if (used == 0)
 		    _nc_curr_file_pos = ftell(yyin);
 
-		if (fgets(result + used, (int) (allocated - used), yyin) != 0) {
+		if (get_text(result + used, (int) (allocated - used))) {
 		    bufstart = result;
 		    if (used == 0) {
 			if (_nc_curr_line == 0
@@ -223,6 +256,8 @@
 		}
 		if ((bufptr = bufstart) != 0) {
 		    used = strlen(bufptr);
+		    if (used == 0)
+			return (EOF);
 		    while (iswhite(*bufptr)) {
 			if (*bufptr == '\t') {
 			    _nc_curr_col = (_nc_curr_col | 7) + 1;
@@ -267,7 +302,7 @@
 /* push a character back onto the input stream */
 {
     if (bufptr == bufstart)
-	_nc_syserr_abort("Can't backspace off beginning of line");
+	_nc_syserr_abort("cannot backspace off beginning of line");
     *--bufptr = (char) c;
     _nc_curr_col--;
 }
@@ -276,14 +311,16 @@
 stream_pos(void)
 /* return our current character position in the input stream */
 {
-    return (yyin ? ftell(yyin) : (bufptr ? bufptr - bufstart : 0));
+    return (yyin ? ftell(yyin) : (bufptr ? (long) (bufptr - bufstart) : 0));
 }
 
 static bool
 end_of_stream(void)
 /* are we at end of input? */
 {
-    return ((yyin ? feof(yyin) : (bufptr && *bufptr == '\0'))
+    return ((yyin
+	     ? (feof(yyin) && (bufptr == NULL || *bufptr == '\0'))
+	     : (bufptr && *bufptr == '\0'))
 	    ? TRUE : FALSE);
 }
 
@@ -291,9 +328,11 @@
 static NCURSES_INLINE int
 eat_escaped_newline(int ch)
 {
-    if (ch == '\\')
-	while ((ch = next_char()) == '\n' || iswhite(ch))
-	    continue;
+    if (ch == '\\') {
+	while ((ch = next_char()) == '\n' || iswhite(ch)) {
+	    /* EMPTY */ ;
+	}
+    }
     return ch;
 }
 
@@ -363,6 +402,8 @@
     int old_col;
 #endif
 
+    DEBUG(3, (T_CALLED("_nc_get_token(silent=%d)"), silent));
+
     if (pushtype != NO_PUSHBACK) {
 	int retval = pushtype;
 
@@ -375,6 +416,7 @@
 	    pushname[0] = '\0';
 
 	/* currtok wasn't altered by _nc_push_token() */
+	DEBUG(3, (T_RETURN("%d"), retval));
 	return (retval);
     }
 
@@ -385,6 +427,7 @@
 	    if (_nc_curr_token.tk_name == tok_buf)
 		_nc_curr_token.tk_name = 0;
 	}
+	DEBUG(3, (T_RETURN("%d"), EOF));
 	return (EOF);
     }
 
@@ -393,7 +436,6 @@
     while ((ch = next_char()) == '\n' || iswhite(ch)) {
 	if (ch == '\n')
 	    had_newline = TRUE;
-	continue;
     }
 
     ch = eat_escaped_newline(ch);
@@ -418,8 +460,9 @@
 	    dot_flag = TRUE;
 	    DEBUG(8, ("dot-flag set"));
 
-	    while ((ch = next_char()) == '.' || iswhite(ch))
-		continue;
+	    while ((ch = next_char()) == '.' || iswhite(ch)) {
+		/* EMPTY */ ;
+	    }
 	}
 
 	if (ch == EOF) {
@@ -552,7 +595,7 @@
 		 * Grrr...what we ought to do here is barf, complaining that
 		 * the entry is malformed.  But because a couple of name fields
 		 * in the 8.2 termcap file end with |\, we just have to assume
-		 * it's termcap syntax.
+		 * it is termcap syntax.
 		 */
 		_nc_syntax = SYN_TERMCAP;
 		separator = ':';
@@ -560,8 +603,9 @@
 		/* throw away trailing /, *$/ */
 		for (--tok_ptr;
 		     iswhite(*tok_ptr) || *tok_ptr == ',';
-		     tok_ptr--)
-		    continue;
+		     tok_ptr--) {
+		    /* EMPTY */ ;
+		}
 		tok_ptr[1] = '\0';
 	    }
 
@@ -583,14 +627,15 @@
 	     */
 	    if (after_list != 0) {
 		if (!silent) {
-		    if (*after_list == '\0')
+		    if (*after_list == '\0' || strchr("|", after_list[1]) != NULL) {
 			_nc_warning("empty longname field");
-		    else if (strchr(after_list, ' ') == 0)
+		    } else if (strchr(after_list, ' ') == 0) {
 			_nc_warning("older tic versions may treat the description field as an alias");
+		    }
 		}
 	    } else {
 		after_list = tok_buf + strlen(tok_buf);
-		DEBUG(1, ("missing description"));
+		DEBUG(2, ("missing description"));
 	    }
 
 	    /*
@@ -669,7 +714,15 @@
 		    if (numchk == numbuf)
 			_nc_warning("no value given for `%s'", tok_buf);
 		    if ((*numchk != '\0') || (ch != separator))
-			_nc_warning("Missing separator");
+			_nc_warning("Missing separator for `%s'", tok_buf);
+		    if (number < 0)
+			_nc_warning("value of `%s' cannot be negative", tok_buf);
+		    if (number > MAX_OF_TYPE(NCURSES_INT2)) {
+			_nc_warning("limiting value of `%s' from %#lx to %#x",
+				    tok_buf,
+				    number, MAX_OF_TYPE(NCURSES_INT2));
+			number = MAX_OF_TYPE(NCURSES_INT2);
+		    }
 		}
 		_nc_curr_token.tk_name = tok_buf;
 		_nc_curr_token.tk_valnumber = (int) number;
@@ -757,6 +810,7 @@
 	       : "<null>"),
 	      type));
 
+    DEBUG(3, (T_RETURN("%d"), type));
     return (type);
 }
 
@@ -780,7 +834,7 @@
  */
 
 NCURSES_EXPORT(int)
-_nc_trans_string(char *ptr, char *last)
+_nc_trans_string(char *ptr, const char *const last)
 {
     int count = 0;
     int number = 0;
@@ -810,8 +864,6 @@
 	    }
 	    if (c == '?' && (_nc_syntax != SYN_TERMCAP)) {
 		*(ptr++) = '\177';
-		if (_nc_tracing)
-		    _nc_warning("Allow ^? as synonym for \\177");
 	    } else {
 		if ((c &= 037) == 0)
 		    c = 128;
@@ -824,8 +876,6 @@
 	    if (c == EOF)
 		_nc_err_abort(MSG_NO_INPUTS);
 
-#define isoctal(c) ((c) >= '0' && (c) <= '7')
-
 	    if (isoctal(c) || (strict_bsd && isdigit(c))) {
 		number = c - '0';
 		for (i = 0; i < 2; i++) {
@@ -990,10 +1040,8 @@
 NCURSES_EXPORT(void)
 _nc_panic_mode(char ch)
 {
-    int c;
-
     for (;;) {
-	c = next_char();
+	int c = next_char();
 	if (c == ch)
 	    return;
 	if (c == EOF)
diff --git a/ncurses/tinfo/db_iterator.c b/ncurses/tinfo/db_iterator.c
index 94a4082..db3872e 100644
--- a/ncurses/tinfo/db_iterator.c
+++ b/ncurses/tinfo/db_iterator.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2006-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2006-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -43,7 +44,7 @@
 #include <hashed_db.h>
 #endif
 
-MODULE_ID("$Id: db_iterator.c,v 1.39 2014/11/01 14:47:00 tom Exp $")
+MODULE_ID("$Id: db_iterator.c,v 1.50 2023/06/24 21:52:32 tom Exp $")
 
 #define HaveTicDirectory _nc_globals.have_tic_directory
 #define KeepTicDirectory _nc_globals.keep_tic_directory
@@ -72,15 +73,18 @@
 {
     bool result = FALSE;
 
-    if (stat(name, sb) == 0
-	&& (S_ISDIR(sb->st_mode) || S_ISREG(sb->st_mode))) {
+    if (quick_prefix(name)) {
+	result = TRUE;
+    } else if (stat(name, sb) == 0
+	       && (S_ISDIR(sb->st_mode)
+		   || (S_ISREG(sb->st_mode) && sb->st_size))) {
 	result = TRUE;
     }
 #if USE_HASHED_DB
     else if (strlen(name) < PATH_MAX - sizeof(DBM_SUFFIX)) {
 	char temp[PATH_MAX];
 	_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "%s%s", name, DBM_SUFFIX);
-	if (stat(temp, sb) == 0 && S_ISREG(sb->st_mode)) {
+	if (stat(temp, sb) == 0 && S_ISREG(sb->st_mode) && sb->st_size) {
 	    result = TRUE;
 	}
     }
@@ -89,6 +93,27 @@
 }
 
 /*
+ * Trim newlines (and backslashes preceding those) and tab characters to
+ * help simplify scripting of the quick-dump feature.  Leave spaces and
+ * other backslashes alone.
+ */
+static void
+trim_formatting(char *source)
+{
+    char *target = source;
+    char ch;
+
+    while ((ch = *source++) != '\0') {
+	if (ch == '\\' && *source == '\n')
+	    continue;
+	if (ch == '\n' || ch == '\t')
+	    continue;
+	*target++ = ch;
+    }
+    *target = '\0';
+}
+
+/*
  * Store the latest value of an environment variable in my_vars[] so we can
  * detect if one changes, invalidating the cached search-list.
  */
@@ -99,19 +124,21 @@
 
     if (which < dbdLAST) {
 	char *value;
+	char *cached_value = my_vars[which].value;
+	bool same_value;
 
-	if ((value = getenv(name)) == 0 || (value = strdup(value)) == 0) {
-	    ;
-	} else if (my_vars[which].name == 0 || strcmp(my_vars[which].name, name)) {
-	    FreeIfNeeded(my_vars[which].value);
-	    my_vars[which].name = name;
-	    my_vars[which].value = value;
-	    result = TRUE;
-	} else if ((my_vars[which].value != 0) ^ (value != 0)) {
-	    FreeIfNeeded(my_vars[which].value);
-	    my_vars[which].value = value;
-	    result = TRUE;
-	} else if (value != 0 && strcmp(value, my_vars[which].value)) {
+	if ((value = getenv(name)) != 0) {
+	    value = strdup(value);
+	}
+	same_value = ((value == 0 && cached_value == 0) ||
+		      (value != 0 &&
+		       cached_value != 0 &&
+		       strcmp(value, cached_value) == 0));
+
+	/* Set variable name to enable checks in cache_expired(). */
+	my_vars[which].name = name;
+
+	if (!same_value) {
 	    FreeIfNeeded(my_vars[which].value);
 	    my_vars[which].value = value;
 	    result = TRUE;
@@ -122,6 +149,7 @@
     return result;
 }
 
+#if NCURSES_USE_DATABASE || NCURSES_USE_TERMCAP
 static char *
 cache_getenv(const char *name, DBDIRS which)
 {
@@ -133,6 +161,7 @@
     }
     return result;
 }
+#endif
 
 /*
  * The cache expires if at least a second has passed since the initial lookup,
@@ -173,6 +202,13 @@
     FreeAndNull(my_list);
 }
 
+static void
+update_tic_dir(const char *update)
+{
+    free((char *) TicDirectory);
+    TicDirectory = update;
+}
+
 /*
  * Record the "official" location of the terminfo directory, according to
  * the place where we're writing to, or the normal default, if not.
@@ -182,8 +218,9 @@
 {
     T(("_nc_tic_dir %s", NonNull(path)));
     if (!KeepTicDirectory) {
-	if (path != 0) {
-	    TicDirectory = path;
+	if (path != NULL) {
+	    if (path != TicDirectory)
+		update_tic_dir(strdup(path));
 	    HaveTicDirectory = TRUE;
 	} else if (HaveTicDirectory == 0) {
 	    if (use_terminfo_vars()) {
@@ -251,7 +288,7 @@
     *state = dbdTIC;
     *offset = 0;
 
-    T(("_nc_first_db"));
+    T((T_CALLED("_nc_first_db")));
 
     /* build a blob containing all of the strings we will use for a lookup
      * table.
@@ -260,7 +297,7 @@
 	size_t blobsize = 0;
 	const char *values[dbdLAST];
 	struct stat *my_stat;
-	int j, k;
+	int j;
 
 	if (cache_has_expired)
 	    free_cache();
@@ -330,10 +367,12 @@
 	    my_list = typeCalloc(char *, blobsize);
 	    my_stat = typeCalloc(struct stat, blobsize);
 	    if (my_list != 0 && my_stat != 0) {
-		k = 0;
+		int k = 0;
 		my_list[k++] = my_blob;
 		for (j = 0; my_blob[j] != '\0'; ++j) {
-		    if (my_blob[j] == NCURSES_PATHSEP) {
+		    if (my_blob[j] == NCURSES_PATHSEP
+			&& ((&my_blob[j] - my_list[k - 1]) != 3
+			    || !quick_prefix(my_list[k - 1]))) {
 			my_blob[j] = '\0';
 			my_list[k++] = &my_blob[j + 1];
 		    }
@@ -344,11 +383,16 @@
 		 */
 		for (j = 0; my_list[j] != 0; ++j) {
 #ifdef TERMINFO
-		    if (*my_list[j] == '\0')
-			my_list[j] = strdup(TERMINFO);
+		    if (*my_list[j] == '\0') {
+			char *my_copy = strdup(TERMINFO);
+			if (my_copy != 0)
+			    my_list[j] = my_copy;
+		    }
 #endif
+		    trim_formatting(my_list[j]);
 		    for (k = 0; k < j; ++k) {
 			if (!strcmp(my_list[j], my_list[k])) {
+			    T(("duplicate %s", my_list[j]));
 			    k = j - 1;
 			    while ((my_list[j] = my_list[j + 1]) != 0) {
 				++j;
@@ -377,6 +421,7 @@
 		    }
 #endif
 		    if (!found) {
+			T(("not found %s", my_list[j]));
 			k = j;
 			while ((my_list[k] = my_list[k + 1]) != 0) {
 			    ++k;
@@ -392,6 +437,7 @@
 	    free(my_stat);
 	}
     }
+    returnVoid;
 }
 
 #if NO_LEAKS
@@ -409,5 +455,6 @@
 	FreeIfNeeded(my_vars[which].value);
 	my_vars[which].value = 0;
     }
+    update_tic_dir(NULL);
 }
 #endif
diff --git a/ncurses/tinfo/doalloc.c b/ncurses/tinfo/doalloc.c
index 7c502b0..e3b1a2e 100644
--- a/ncurses/tinfo/doalloc.c
+++ b/ncurses/tinfo/doalloc.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 1998-2002,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,15 +40,18 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: doalloc.c,v 1.11 2012/11/03 19:27:41 tom Exp $")
+MODULE_ID("$Id: doalloc.c,v 1.14 2021/04/24 23:43:39 tom Exp $")
 
-NCURSES_EXPORT(void *)
+void *
 _nc_doalloc(void *oldp, size_t amount)
 {
     void *newp;
 
-    if (oldp != 0) {
-	if ((newp = realloc(oldp, amount)) == 0) {
+    if (oldp != NULL) {
+	if (amount == 0) {
+	    free(oldp);
+	    newp = NULL;
+	} else if ((newp = realloc(oldp, amount)) == 0) {
 	    free(oldp);
 	    errno = ENOMEM;	/* just in case 'free' reset */
 	}
diff --git a/ncurses/tinfo/entries.c b/ncurses/tinfo/entries.c
index e84033d..f47fd3f 100644
--- a/ncurses/tinfo/entries.c
+++ b/ncurses/tinfo/entries.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2006-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2006-2012,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -37,7 +38,7 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: entries.c,v 1.21 2012/05/05 20:33:44 tom Exp $")
+MODULE_ID("$Id: entries.c,v 1.35 2023/05/27 20:13:10 tom Exp $")
 
 /****************************************************************************
  *
@@ -63,30 +64,8 @@
 NCURSES_EXPORT_VAR(ENTRY *) _nc_head = 0;
 NCURSES_EXPORT_VAR(ENTRY *) _nc_tail = 0;
 
-NCURSES_EXPORT(void)
-_nc_free_entry(ENTRY * headp, TERMTYPE *tterm)
-/* free the allocated storage consumed by the given list entry */
-{
-    ENTRY *ep;
-
-    if ((ep = _nc_delink_entry(headp, tterm)) != 0) {
-	free(ep);
-    }
-}
-
-NCURSES_EXPORT(void)
-_nc_free_entries(ENTRY * headp)
-/* free the allocated storage consumed by list entries */
-{
-    (void) headp;		/* unused - _nc_head is altered here! */
-
-    while (_nc_head != 0) {
-	_nc_free_termtype(&(_nc_head->tterm));
-    }
-}
-
-NCURSES_EXPORT(ENTRY *)
-_nc_delink_entry(ENTRY * headp, TERMTYPE *tterm)
+static ENTRY *
+_nc_delink_entry(ENTRY * headp, const TERMTYPE2 *const tterm)
 /* delink the allocated storage for the given list entry */
 {
     ENTRY *ep, *last;
@@ -112,22 +91,63 @@
 }
 
 NCURSES_EXPORT(void)
+_nc_free_entry(ENTRY * headp, TERMTYPE2 *tterm)
+/* free the allocated storage consumed by the given list entry */
+{
+    ENTRY *ep;
+
+    if ((ep = _nc_delink_entry(headp, tterm)) != 0) {
+	free(ep);
+    }
+}
+
+NCURSES_EXPORT(void)
+_nc_free_entries(ENTRY * headp)
+/* free the allocated storage consumed by list entries */
+{
+    (void) headp;		/* unused - _nc_head is altered here! */
+
+    while (_nc_head != 0) {
+	_nc_free_termtype2(&(_nc_head->tterm));
+    }
+}
+
+NCURSES_EXPORT(void)
 _nc_leaks_tinfo(void)
 {
 #if NO_LEAKS
     char *s;
 #endif
 
-    T((T_CALLED("_nc_free_tinfo()")));
+    T((T_CALLED("_nc_leaks_tinfo()")));
 #if NO_LEAKS
-    _nc_free_tparm();
+    _nc_globals.leak_checking = TRUE;
+    _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));
     }
+    _nc_forget_prescr();
 
     _nc_comp_captab_leaks();
+    _nc_comp_userdefs_leaks();
     _nc_free_entries(_nc_head);
     _nc_get_type(0);
     _nc_first_name(0);
@@ -144,7 +164,8 @@
 	free(s);
 
 #ifdef TRACE
-    trace(0);
+    T((T_RETURN("")));
+    curses_trace(0);
     _nc_trace_buf(-1, (size_t) 0);
 #endif
 
@@ -156,7 +177,18 @@
 NCURSES_EXPORT(void)
 _nc_free_tinfo(int code)
 {
+    T((T_CALLED("_nc_free_tinfo(%d)"), code));
     _nc_leaks_tinfo();
     exit(code);
 }
 #endif
+
+NCURSES_EXPORT(void)
+exit_terminfo(int code)
+{
+    T((T_CALLED("exit_terminfo(%d)"), code));
+#if NO_LEAKS
+    _nc_leaks_tinfo();
+#endif
+    exit(code);
+}
diff --git a/ncurses/tinfo/free_ttype.c b/ncurses/tinfo/free_ttype.c
index ad056ba..7935152 100644
--- a/ncurses/tinfo/free_ttype.c
+++ b/ncurses/tinfo/free_ttype.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1999-2010,2011 Free Software Foundation, Inc.              *
+ * Copyright 2020-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1999-2011,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,25 +43,52 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: free_ttype.c,v 1.15 2011/02/06 01:08:31 tom Exp $")
+MODULE_ID("$Id: free_ttype.c,v 1.22 2023/04/22 15:12:57 tom Exp $")
 
-NCURSES_EXPORT(void)
-_nc_free_termtype(TERMTYPE *ptr)
+static void
+really_free_termtype(TERMTYPE2 *ptr, bool freeStrings)
 {
-    T(("_nc_free_termtype(%s)", ptr->term_names));
+    T(("really_free_termtype(%s) %d", ptr->term_names, freeStrings));
 
-    FreeIfNeeded(ptr->str_table);
+    if (freeStrings) {
+	FreeIfNeeded(ptr->str_table);
+    }
     FreeIfNeeded(ptr->Booleans);
     FreeIfNeeded(ptr->Numbers);
     FreeIfNeeded(ptr->Strings);
 #if NCURSES_XNAMES
-    FreeIfNeeded(ptr->ext_str_table);
+    if (freeStrings) {
+	FreeIfNeeded(ptr->ext_str_table);
+    }
     FreeIfNeeded(ptr->ext_Names);
 #endif
     memset(ptr, 0, sizeof(TERMTYPE));
     _nc_free_entry(_nc_head, ptr);
 }
 
+NCURSES_EXPORT(void)
+_nc_free_termtype(TERMTYPE *ptr)
+{
+    really_free_termtype((TERMTYPE2 *) ptr, !NCURSES_EXT_NUMBERS);
+}
+
+/*
+ * These similar entrypoints are not used outside of ncurses.
+ */
+NCURSES_EXPORT(void)
+_nc_free_termtype1(TERMTYPE *ptr)
+{
+    really_free_termtype((TERMTYPE2 *) ptr, TRUE);
+}
+
+#if NCURSES_EXT_NUMBERS
+NCURSES_EXPORT(void)
+_nc_free_termtype2(TERMTYPE2 *ptr)
+{
+    really_free_termtype(ptr, TRUE);
+}
+#endif
+
 #if NCURSES_XNAMES
 NCURSES_EXPORT_VAR(bool) _nc_user_definable = TRUE;
 
diff --git a/ncurses/tinfo/getenv_num.c b/ncurses/tinfo/getenv_num.c
index d5e35cb..ca179d3 100644
--- a/ncurses/tinfo/getenv_num.c
+++ b/ncurses/tinfo/getenv_num.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2012,2013 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -36,7 +37,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: getenv_num.c,v 1.6 2013/09/28 20:25:08 tom Exp $")
+MODULE_ID("$Id: getenv_num.c,v 1.8 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 _nc_getenv_num(const char *name)
@@ -68,6 +69,8 @@
 	_nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) "%s=%d", name, value);
 	if ((s = strdup(buffer)) != 0)
 	    putenv(s);
+#else
+#error expected setenv/putenv functions
 #endif
     }
 }
diff --git a/ncurses/tinfo/hashed_db.c b/ncurses/tinfo/hashed_db.c
index b594205..b78d98f 100644
--- a/ncurses/tinfo/hashed_db.c
+++ b/ncurses/tinfo/hashed_db.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2006-2011,2013 Free Software Foundation, Inc.              *
+ * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2006-2011,2013 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -36,7 +37,7 @@
 
 #if USE_HASHED_DB
 
-MODULE_ID("$Id: hashed_db.c,v 1.17 2013/12/15 00:33:01 tom Exp $")
+MODULE_ID("$Id: hashed_db.c,v 1.19 2020/02/02 23:34:34 tom Exp $")
 
 #if HASHED_DB_API >= 2
 static DBC *cursor;
@@ -273,7 +274,7 @@
 	result = -1;
     }
 #else
-    result = db->seq(db, key, data, 0);
+    result = db->seq(db, key, data, R_NEXT);
 #endif
     return result;
 }
diff --git a/ncurses/tinfo/home_terminfo.c b/ncurses/tinfo/home_terminfo.c
index e77f71c..7e626df 100644
--- a/ncurses/tinfo/home_terminfo.c
+++ b/ncurses/tinfo/home_terminfo.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2012,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -37,7 +38,7 @@
 #include <curses.priv.h>
 #include <tic.h>
 
-MODULE_ID("$Id: home_terminfo.c,v 1.15 2012/10/27 21:49:14 tom Exp $")
+MODULE_ID("$Id: home_terminfo.c,v 1.17 2020/02/02 23:34:34 tom Exp $")
 
 /* ncurses extension...fall back on user's private directory */
 
@@ -48,10 +49,11 @@
 {
     char *result = 0;
 #if USE_HOME_TERMINFO
-    char *home;
-
     if (use_terminfo_vars()) {
+
 	if (MyBuffer == 0) {
+	    char *home;
+
 	    if ((home = getenv("HOME")) != 0) {
 		size_t want = (strlen(home) + sizeof(PRIVATE_INFO));
 		TYPE_MALLOC(char, want, MyBuffer);
diff --git a/ncurses/tinfo/init_keytry.c b/ncurses/tinfo/init_keytry.c
index ea47b38..ef20dfb 100644
--- a/ncurses/tinfo/init_keytry.c
+++ b/ncurses/tinfo/init_keytry.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1999-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 1999-2010,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -29,7 +30,7 @@
 #include <curses.priv.h>
 #include <tic.h>		/* struct tinfo_fkeys */
 
-MODULE_ID("$Id: init_keytry.c,v 1.17 2010/04/24 22:29:56 tom Exp $")
+MODULE_ID("$Id: init_keytry.c,v 1.20 2023/09/16 12:55:01 tom Exp $")
 
 /*
 **      _nc_init_keytry()
@@ -66,7 +67,7 @@
 NCURSES_EXPORT(void)
 _nc_init_keytry(SCREEN *sp)
 {
-    unsigned n;
+    T(("_nc_init_keytry(%p)", (void *) sp));
 
     /* The sp->_keytry value is initialized in newterm(), where the sp
      * structure is created, because we can not tell where keypad() or
@@ -74,6 +75,8 @@
      */
 
     if (sp != 0) {
+	unsigned n;
+
 	for (n = 0; _nc_tinfo_fkeys[n].code; n++) {
 	    if (_nc_tinfo_fkeys[n].offset < STRCOUNT) {
 		(void) _nc_add_to_try(&(sp->_keytry),
@@ -94,7 +97,7 @@
 		char *value = tp->Strings[n];
 		if (name != 0
 		    && *name == 'k'
-		    && value != 0
+		    && VALID_STRING(value)
 		    && NCURSES_SP_NAME(key_defined) (NCURSES_SP_ARGx
 						     value) == 0) {
 		    (void) _nc_add_to_try(&(sp->_keytry),
diff --git a/ncurses/tinfo/lib_acs.c b/ncurses/tinfo/lib_acs.c
index 69a1851..4ede53f 100644
--- a/ncurses/tinfo/lib_acs.c
+++ b/ncurses/tinfo/lib_acs.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_acs.c,v 1.45 2014/03/08 20:32:59 tom Exp $")
+MODULE_ID("$Id: lib_acs.c,v 1.50 2020/02/02 23:34:34 tom Exp $")
 
 #if BROKEN_LINKER || USE_REENTRANT
 #define MyBuffer _nc_prescreen.real_acs_map
@@ -171,7 +172,7 @@
     if (ena_acs != NULL) {
 	NCURSES_PUTP2("ena_acs", ena_acs);
     }
-#if NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS && defined(enter_pc_charset_mode) && defined(exit_pc_charset_mode)
     /*
      * Linux console "supports" the "PC ROM" character set by the coincidence
      * that smpch/rmpch and smacs/rmacs have the same values.  ncurses has
@@ -205,8 +206,13 @@
 	while (i + 1 < length) {
 	    if (acs_chars[i] != 0 && UChar(acs_chars[i]) < ACS_LEN) {
 		real_map[UChar(acs_chars[i])] = UChar(acs_chars[i + 1]) | A_ALTCHARSET;
-		if (SP != 0)
+		T(("#%d real_map[%s] = %s",
+		   (int) i,
+		   _tracechar(UChar(acs_chars[i])),
+		   _tracechtype(real_map[UChar(acs_chars[i])])));
+		if (SP != 0) {
 		    SP->_screen_acs_map[UChar(acs_chars[i])] = TRUE;
+		}
 	    }
 	    i += 2;
 	}
@@ -249,3 +255,72 @@
     NCURSES_SP_NAME(_nc_init_acs) (CURRENT_SCREEN);
 }
 #endif
+
+#if !NCURSES_WCWIDTH_GRAPHICS
+NCURSES_EXPORT(int)
+_nc_wacs_width(unsigned ch)
+{
+    int result;
+    switch (ch) {
+    case 0x00a3:		/* FALLTHRU - ncurses pound-sterling symbol */
+    case 0x00b0:		/* FALLTHRU - VT100 degree symbol */
+    case 0x00b1:		/* FALLTHRU - VT100 plus/minus */
+    case 0x00b7:		/* FALLTHRU - VT100 bullet */
+    case 0x03c0:		/* FALLTHRU - ncurses greek pi */
+    case 0x2190:		/* FALLTHRU - Teletype arrow pointing left */
+    case 0x2191:		/* FALLTHRU - Teletype arrow pointing up */
+    case 0x2192:		/* FALLTHRU - Teletype arrow pointing right */
+    case 0x2193:		/* FALLTHRU - Teletype arrow pointing down */
+    case 0x2260:		/* FALLTHRU - ncurses not-equal */
+    case 0x2264:		/* FALLTHRU - ncurses less-than-or-equal-to */
+    case 0x2265:		/* FALLTHRU - ncurses greater-than-or-equal-to */
+    case 0x23ba:		/* FALLTHRU - VT100 scan line 1 */
+    case 0x23bb:		/* FALLTHRU - ncurses scan line 3 */
+    case 0x23bc:		/* FALLTHRU - ncurses scan line 7 */
+    case 0x23bd:		/* FALLTHRU - VT100 scan line 9 */
+    case 0x2500:		/* FALLTHRU - VT100 horizontal line */
+    case 0x2501:		/* FALLTHRU - thick horizontal line */
+    case 0x2502:		/* FALLTHRU - VT100 vertical line */
+    case 0x2503:		/* FALLTHRU - thick vertical line */
+    case 0x250c:		/* FALLTHRU - VT100 upper left corner */
+    case 0x250f:		/* FALLTHRU - thick upper left corner */
+    case 0x2510:		/* FALLTHRU - VT100 upper right corner */
+    case 0x2513:		/* FALLTHRU - thick upper right corner */
+    case 0x2514:		/* FALLTHRU - VT100 lower left corner */
+    case 0x2517:		/* FALLTHRU - thick lower left corner */
+    case 0x2518:		/* FALLTHRU - VT100 lower right corner */
+    case 0x251b:		/* FALLTHRU - thick lower right corner */
+    case 0x251c:		/* FALLTHRU - VT100 tee pointing left */
+    case 0x2523:		/* FALLTHRU - thick tee pointing left */
+    case 0x2524:		/* FALLTHRU - VT100 tee pointing right */
+    case 0x252b:		/* FALLTHRU - thick tee pointing right */
+    case 0x252c:		/* FALLTHRU - VT100 tee pointing down */
+    case 0x2533:		/* FALLTHRU - thick tee pointing down */
+    case 0x2534:		/* FALLTHRU - VT100 tee pointing up */
+    case 0x253b:		/* FALLTHRU - thick tee pointing up */
+    case 0x253c:		/* FALLTHRU - VT100 large plus or crossover */
+    case 0x254b:		/* FALLTHRU - thick large plus or crossover */
+    case 0x2550:		/* FALLTHRU - double horizontal line */
+    case 0x2551:		/* FALLTHRU - double vertical line */
+    case 0x2554:		/* FALLTHRU - double upper left corner */
+    case 0x2557:		/* FALLTHRU - double upper right corner */
+    case 0x255a:		/* FALLTHRU - double lower left corner */
+    case 0x255d:		/* FALLTHRU - double lower right corner */
+    case 0x2560:		/* FALLTHRU - double tee pointing right */
+    case 0x2563:		/* FALLTHRU - double tee pointing left */
+    case 0x2566:		/* FALLTHRU - double tee pointing down */
+    case 0x2569:		/* FALLTHRU - double tee pointing up */
+    case 0x256c:		/* FALLTHRU - double large plus or crossover */
+    case 0x2592:		/* FALLTHRU - VT100 checker board (stipple) */
+    case 0x25ae:		/* FALLTHRU - Teletype solid square block */
+    case 0x25c6:		/* FALLTHRU - VT100 diamond */
+    case 0x2603:		/* FALLTHRU - Teletype lantern symbol */
+	result = 1;
+	break;
+    default:
+	result = wcwidth(ch);
+	break;
+    }
+    return result;
+}
+#endif /* !NCURSES_WCWIDTH_GRAPHICS */
diff --git a/ncurses/tinfo/lib_baudrate.c b/ncurses/tinfo/lib_baudrate.c
index 1cf5505..311c41a 100644
--- a/ncurses/tinfo/lib_baudrate.c
+++ b/ncurses/tinfo/lib_baudrate.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
 
 #include <curses.priv.h>
 #include <termcap.h>		/* ospeed */
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
 #include <sys/param.h>
 #endif
 
@@ -49,7 +50,11 @@
  * of the indices up to B115200 fit nicely in a 'short', allowing us to retain
  * ospeed's type for compatibility.
  */
-#if NCURSES_OSPEED_COMPAT && ((defined(__FreeBSD__) && (__FreeBSD_version < 700000)) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__))
+#if NCURSES_OSPEED_COMPAT && \
+ 	((defined(__FreeBSD__) && (__FreeBSD_version < 700000)) || \
+	defined(__NetBSD__) || \
+	((defined(__OpenBSD__) && OpenBSD < 201510)) || \
+	defined(__APPLE__))
 #undef B0
 #undef B50
 #undef B75
@@ -79,7 +84,7 @@
 #undef USE_OLD_TTY
 #endif /* USE_OLD_TTY */
 
-MODULE_ID("$Id: lib_baudrate.c,v 1.37 2015/06/14 00:34:12 tom Exp $")
+MODULE_ID("$Id: lib_baudrate.c,v 1.45 2020/09/05 21:15:32 tom Exp $")
 
 /*
  *	int
@@ -90,10 +95,11 @@
  */
 
 struct speed {
-    NCURSES_OSPEED s;		/* values for 'ospeed' */
-    int sp;			/* the actual speed */
+    int given_speed;		/* values for 'ospeed' */
+    int actual_speed;		/* the actual speed */
 };
 
+#if !defined(EXP_WIN32_DRIVER)
 #define DATA(number) { B##number, number }
 
 static struct speed const speeds[] =
@@ -117,6 +123,9 @@
 #elif defined(EXTA)
     {EXTA, 19200},
 #endif
+#ifdef B28800
+    DATA(28800),
+#endif
 #ifdef B38400
     DATA(38400),
 #elif defined(EXTB)
@@ -127,32 +136,80 @@
 #endif
     /* ifdef to prevent overflow when OLD_TTY is not available */
 #if !(NCURSES_OSPEED_COMPAT && defined(__FreeBSD__) && (__FreeBSD_version > 700000))
+#ifdef B76800
+    DATA(76800),
+#endif
 #ifdef B115200
     DATA(115200),
 #endif
+#ifdef B153600
+    DATA(153600),
+#endif
 #ifdef B230400
     DATA(230400),
 #endif
+#ifdef B307200
+    DATA(307200),
+#endif
 #ifdef B460800
     DATA(460800),
 #endif
+#ifdef B500000
+    DATA(500000),
+#endif
+#ifdef B576000
+    DATA(576000),
+#endif
 #ifdef B921600
     DATA(921600),
 #endif
+#ifdef B1000000
+    DATA(1000000),
+#endif
+#ifdef B1152000
+    DATA(1152000),
+#endif
+#ifdef B1500000
+    DATA(1500000),
+#endif
+#ifdef B2000000
+    DATA(2000000),
+#endif
+#ifdef B2500000
+    DATA(2500000),
+#endif
+#ifdef B3000000
+    DATA(3000000),
+#endif
+#ifdef B3500000
+    DATA(3500000),
+#endif
+#ifdef B4000000
+    DATA(4000000),
+#endif
 #endif
 };
+#endif /* !EXP_WIN32_DRIVER */
 
 NCURSES_EXPORT(int)
 _nc_baudrate(int OSpeed)
 {
+#if defined(EXP_WIN32_DRIVER)
+    /* On Windows this is a noop */
+    (void) OSpeed;
+    return (OK);
+#else
 #if !USE_REENTRANT
     static int last_OSpeed;
     static int last_baudrate;
 #endif
 
     int result = ERR;
-    unsigned i;
 
+    if (OSpeed < 0)
+	OSpeed = (NCURSES_OSPEED) OSpeed;
+    if (OSpeed < 0)
+	OSpeed = (unsigned short) OSpeed;
 #if !USE_REENTRANT
     if (OSpeed == last_OSpeed) {
 	result = last_baudrate;
@@ -160,9 +217,14 @@
 #endif
     if (result == ERR) {
 	if (OSpeed >= 0) {
+	    unsigned i;
+
 	    for (i = 0; i < SIZEOF(speeds); i++) {
-		if ((int) speeds[i].s == OSpeed) {
-		    result = speeds[i].sp;
+		if (speeds[i].given_speed > OSpeed) {
+		    break;
+		}
+		if (speeds[i].given_speed == OSpeed) {
+		    result = speeds[i].actual_speed;
 		    break;
 		}
 	    }
@@ -175,22 +237,27 @@
 #endif
     }
     return (result);
+#endif /* !EXP_WIN32_DRIVER */
 }
 
 NCURSES_EXPORT(int)
 _nc_ospeed(int BaudRate)
 {
     int result = 1;
-    unsigned i;
-
+#if defined(EXP_WIN32_DRIVER)
+    (void) BaudRate;
+#else
     if (BaudRate >= 0) {
+	unsigned i;
+
 	for (i = 0; i < SIZEOF(speeds); i++) {
-	    if (speeds[i].sp == BaudRate) {
-		result = speeds[i].s;
+	    if (speeds[i].actual_speed == BaudRate) {
+		result = speeds[i].given_speed;
 		break;
 	    }
 	}
     }
+#endif
     return (result);
 }
 
@@ -201,6 +268,9 @@
 
     T((T_CALLED("baudrate(%p)"), (void *) SP_PARM));
 
+#if defined(EXP_WIN32_DRIVER)
+    result = OK;
+#else
     /*
      * In debugging, allow the environment symbol to override when we're
      * redirecting to a file, so we can construct repeatable test-cases
@@ -208,7 +278,7 @@
      */
 #ifdef TRACE
     if (IsValidTIScreen(SP_PARM)
-	&& !NC_ISATTY(fileno(SP_PARM ? SP_PARM->_ofp : stdout))
+	&& !NC_ISATTY(fileno((SP_PARM && SP_PARM->_ofp) ? SP_PARM->_ofp : stdout))
 	&& getenv("BAUDRATE") != 0) {
 	int ret;
 	if ((ret = _nc_getenv_num("BAUDRATE")) <= 0)
@@ -234,7 +304,7 @@
     } else {
 	result = ERR;
     }
-
+#endif /* !EXP_WIN32_DRIVER */
     returnCode(result);
 }
 
diff --git a/ncurses/tinfo/lib_cur_term.c b/ncurses/tinfo/lib_cur_term.c
index 9941d13..1f8db2c 100644
--- a/ncurses/tinfo/lib_cur_term.c
+++ b/ncurses/tinfo/lib_cur_term.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+,* Copyright 2020-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  *
  * copy of this software and associated documentation files (the            *
@@ -38,11 +39,12 @@
 
 #include <curses.priv.h>
 #include <termcap.h>		/* ospeed */
+#include <tic.h>		/* VALID_STRING */
 
-MODULE_ID("$Id: lib_cur_term.c,v 1.33 2014/03/08 20:32:59 tom Exp $")
+MODULE_ID("$Id: lib_cur_term.c,v 1.49 2022/05/28 17:56:55 tom Exp $")
 
 #undef CUR
-#define CUR termp->type.
+#define CUR TerminalType(termp).
 
 #if USE_REENTRANT
 
@@ -76,7 +78,7 @@
 #endif
 
 NCURSES_EXPORT(TERMINAL *)
-NCURSES_SP_NAME(set_curterm) (NCURSES_SP_DCLx TERMINAL * termp)
+NCURSES_SP_NAME(set_curterm) (NCURSES_SP_DCLx TERMINAL *termp)
 {
     TERMINAL *oldterm;
 
@@ -95,16 +97,21 @@
 #ifdef USE_TERM_DRIVER
 	TERMINAL_CONTROL_BLOCK *TCB = (TERMINAL_CONTROL_BLOCK *) termp;
 	ospeed = (NCURSES_OSPEED) _nc_ospeed(termp->_baudrate);
-	if (TCB->drv->isTerminfo && termp->type.Strings) {
-	    PC = (char) ((pad_char != NULL) ? pad_char[0] : 0);
+	if (TCB->drv &&
+	    TCB->drv->isTerminfo &&
+	    TerminalType(termp).Strings) {
+	    PC = (char) (VALID_STRING(pad_char) ? pad_char[0] : 0);
 	}
 	TCB->csp = SP_PARM;
 #else
 	ospeed = (NCURSES_OSPEED) _nc_ospeed(termp->_baudrate);
-	if (termp->type.Strings) {
-	    PC = (char) ((pad_char != NULL) ? pad_char[0] : 0);
+	if (TerminalType(termp).Strings) {
+	    PC = (char) (VALID_STRING(pad_char) ? pad_char[0] : 0);
 	}
 #endif
+#if !USE_REENTRANT
+	save_ttytype(termp);
+#endif
     }
     _nc_unlock_global(curses);
 
@@ -114,14 +121,14 @@
 
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(TERMINAL *)
-set_curterm(TERMINAL * termp)
+set_curterm(TERMINAL *termp)
 {
     return NCURSES_SP_NAME(set_curterm) (CURRENT_SCREEN, termp);
 }
 #endif
 
 NCURSES_EXPORT(int)
-NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL * termp)
+NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL *termp)
 {
     int rc = ERR;
 
@@ -139,7 +146,14 @@
 #endif
 	);
 
-	_nc_free_termtype(&(termp->type));
+#if NCURSES_EXT_NUMBERS
+#if NCURSES_EXT_COLORS
+	_nc_free_termtype1(&termp->type);
+#else
+	_nc_free_termtype2(&termp->type);
+#endif
+#endif
+	_nc_free_termtype2(&TerminalType(termp));
 	if (termp == cur)
 	    NCURSES_SP_NAME(set_curterm) (NCURSES_SP_ARGx 0);
 
@@ -153,18 +167,29 @@
 	if (TCB->drv)
 	    TCB->drv->td_release(TCB);
 #endif
+#if NO_LEAKS
+	/* discard memory used in tgetent's cache for this terminal */
+	_nc_tgetent_leak(termp);
+#endif
+	if (--_nc_globals.terminal_count == 0) {
+	    _nc_free_tparm(termp);
+	}
+
+	free(termp->tparm_state.fmt_buff);
+	free(termp->tparm_state.out_buff);
 	free(termp);
 
 	rc = OK;
     }
+
     returnCode(rc);
 }
 
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(int)
-del_curterm(TERMINAL * termp)
+del_curterm(TERMINAL *termp)
 {
-    int rc = ERR;
+    int rc;
 
     _nc_lock_global(curses);
     rc = NCURSES_SP_NAME(del_curterm) (CURRENT_SCREEN, termp);
diff --git a/ncurses/tinfo/lib_data.c b/ncurses/tinfo/lib_data.c
index 06b6f88..b817f49 100644
--- a/ncurses/tinfo/lib_data.c
+++ b/ncurses/tinfo/lib_data.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2024 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_data.c,v 1.66 2013/08/24 17:28:24 tom Exp $")
+MODULE_ID("$Id: lib_data.c,v 1.89 2024/02/24 18:11:38 tom Exp $")
 
 /*
  * OS/2's native linker complains if we don't initialize public data when
@@ -94,7 +95,9 @@
 NCURSES_EXPORT(int)
 _nc_alloc_screen(void)
 {
-    return ((my_screen = _nc_alloc_screen_sp()) != 0);
+    my_screen = _nc_alloc_screen_sp();
+    T(("_nc_alloc_screen_sp %p", my_screen));
+    return (my_screen != 0);
 }
 
 NCURSES_EXPORT(void)
@@ -137,12 +140,15 @@
 
     0,				/* slk_format */
 
+    2048,			/* getstr_limit */
+
     NULL,			/* safeprint_buf */
     0,				/* safeprint_used */
 
     TGETENT_0s,			/* tgetent_cache */
     0,				/* tgetent_index */
     0,				/* tgetent_sequence */
+    0,				/* terminal_count */
 
     0,				/* dbd_blob */
     0,				/* dbd_list */
@@ -150,6 +156,15 @@
     0,				/* dbd_time */
     { { 0, 0 } },		/* dbd_vars */
 
+#if HAVE_TSEARCH
+    NULL,			/* cached_tparm */
+    0,				/* count_tparm */
+#endif /* HAVE_TSEARCH */
+
+#ifdef USE_TERM_DRIVER
+    0,				/* term_driver */
+#endif
+
 #ifndef USE_SP_WINDOWLIST
     0,				/* _nc_windowlist */
 #endif
@@ -163,15 +178,27 @@
     0,				/* safeprint_rows */
 #endif
 
-#ifdef USE_TERM_DRIVER
-    0,				/* term_driver */
+#ifdef USE_PTHREADS
+    PTHREAD_MUTEX_INITIALIZER,	/* mutex_curses */
+    PTHREAD_MUTEX_INITIALIZER,	/* mutex_prescreen */
+    PTHREAD_MUTEX_INITIALIZER,	/* mutex_screen */
+    PTHREAD_MUTEX_INITIALIZER,	/* mutex_update */
+    PTHREAD_MUTEX_INITIALIZER,	/* mutex_tst_tracef */
+    PTHREAD_MUTEX_INITIALIZER,	/* mutex_tracef */
+    0,				/* nested_tracef */
+    0,				/* use_pthreads */
+#if USE_PTHREADS_EINTR
+    0,				/* read_thread */
 #endif
-
+#endif
+#if USE_WIDEC_SUPPORT
+    CHARS_0s,			/* key_name */
+#endif
 #ifdef TRACE
-    FALSE,			/* init_trace */
-    CHARS_0s,			/* trace_fname */
+    FALSE,			/* trace_opened */
     0,				/* trace_level */
     NULL,			/* trace_fp */
+    -1,				/* trace_fd */
 
     NULL,			/* tracearg_buf */
     0,				/* tracearg_used */
@@ -194,15 +221,8 @@
     0,				/* nested_tracef */
 #endif
 #endif /* TRACE */
-#ifdef USE_PTHREADS
-    PTHREAD_MUTEX_INITIALIZER,	/* mutex_curses */
-    PTHREAD_MUTEX_INITIALIZER,	/* mutex_tst_tracef */
-    PTHREAD_MUTEX_INITIALIZER,	/* mutex_tracef */
-    0,				/* nested_tracef */
-    0,				/* use_pthreads */
-#endif
-#if USE_PTHREADS_EINTR
-    0,				/* read_thread */
+#if NO_LEAKS
+    FALSE,			/* leak_checking */
 #endif
 };
 
@@ -214,17 +234,11 @@
 #define RIPOFF_0s	{ RIPOFF_0 }
 
 NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
+    NULL,			/* allocated */
     TRUE,			/* use_env */
     FALSE,			/* filter_mode */
     A_NORMAL,			/* previous_attr */
-#ifndef USE_SP_RIPOFF
-    RIPOFF_0s,			/* ripoff */
-    NULL,			/* rsp */
-#endif
     {				/* tparm_state */
-#ifdef TRACE
-	NULL,			/* tname */
-#endif
 	NULL,			/* tparam_base */
 
 	STACK_FRAME_0s,		/* stack */
@@ -237,14 +251,21 @@
 	NULL,			/* fmt_buff */
 	0,			/* fmt_size */
 
-	NUM_VARS_0s,		/* dynamic_var */
 	NUM_VARS_0s,		/* static_vars */
+#ifdef TRACE
+	NULL,			/* tname */
+#endif
     },
     NULL,			/* saved_tty */
+    FALSE,			/* use_tioctl */
+    0,				/* _outch */
+#ifndef USE_SP_RIPOFF
+    RIPOFF_0s,			/* ripoff */
+    NULL,			/* rsp */
+#endif
 #if NCURSES_NO_PADDING
     FALSE,			/* flag to set if padding disabled  */
 #endif
-    0,				/* _outch */
 #if BROKEN_LINKER || USE_REENTRANT
     NULL,			/* real_acs_map */
     0,				/* LINES */
@@ -252,12 +273,13 @@
     8,				/* TABSIZE */
     1000,			/* ESCDELAY */
     0,				/* cur_term */
+#endif
 #ifdef TRACE
+#if BROKEN_LINKER || USE_REENTRANT
     0L,				/* _outchars */
     NULL,			/* _tputs_trace */
 #endif
 #endif
-    FALSE,			/* use_tioctl */
 };
 /* *INDENT-ON* */
 
@@ -287,6 +309,9 @@
     if (!initialized) {
 	initialized = TRUE;
 	_nc_mutex_init(&_nc_globals.mutex_curses);
+	_nc_mutex_init(&_nc_globals.mutex_prescreen);
+	_nc_mutex_init(&_nc_globals.mutex_screen);
+	_nc_mutex_init(&_nc_globals.mutex_update);
 	_nc_mutex_init(&_nc_globals.mutex_tst_tracef);
 	_nc_mutex_init(&_nc_globals.mutex_tracef);
     }
@@ -337,25 +362,28 @@
 NCURSES_EXPORT(int)
 _nc_mutex_lock(pthread_mutex_t * obj)
 {
-    if (_nc_use_pthreads == 0)
-	return 0;
-    return pthread_mutex_lock(obj);
+    int rc = 0;
+    if (_nc_use_pthreads != 0)
+	rc = pthread_mutex_lock(obj);
+    return rc;
 }
 
 NCURSES_EXPORT(int)
 _nc_mutex_trylock(pthread_mutex_t * obj)
 {
-    if (_nc_use_pthreads == 0)
-	return 0;
-    return pthread_mutex_trylock(obj);
+    int rc = 0;
+    if (_nc_use_pthreads != 0)
+	rc = pthread_mutex_trylock(obj);
+    return rc;
 }
 
 NCURSES_EXPORT(int)
 _nc_mutex_unlock(pthread_mutex_t * obj)
 {
-    if (_nc_use_pthreads == 0)
-	return 0;
-    return pthread_mutex_unlock(obj);
+    int rc = 0;
+    if (_nc_use_pthreads != 0)
+	rc = pthread_mutex_unlock(obj);
+    return rc;
 }
 #endif /* USE_PTHREADS */
 
@@ -371,7 +399,7 @@
     if ((pthread_sigmask))
 	return pthread_sigmask(how, newmask, oldmask);
     else
-	return sigprocmask(how, newmask, oldmask);
+	return (sigprocmask) (how, newmask, oldmask);
 }
 #endif
 #endif /* USE_PTHREADS */
diff --git a/ncurses/tinfo/lib_has_cap.c b/ncurses/tinfo/lib_has_cap.c
index 17e59d5..cbf68b3 100644
--- a/ncurses/tinfo/lib_has_cap.c
+++ b/ncurses/tinfo/lib_has_cap.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2013 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2009,2013 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -46,7 +47,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_has_cap.c,v 1.10 2013/11/16 19:57:22 tom Exp $")
+MODULE_ID("$Id: lib_has_cap.c,v 1.11 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(bool)
 NCURSES_SP_NAME(has_ic) (NCURSES_SP_DCL0)
diff --git a/ncurses/tinfo/lib_kernel.c b/ncurses/tinfo/lib_kernel.c
index 37f7084..46f652b 100644
--- a/ncurses/tinfo/lib_kernel.c
+++ b/ncurses/tinfo/lib_kernel.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -48,8 +49,9 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_kernel.c,v 1.31 2010/12/19 01:21:19 tom Exp $")
+MODULE_ID("$Id: lib_kernel.c,v 1.36 2023/06/10 13:29:06 tom Exp $")
 
+#ifdef TERMIOS
 static int
 _nc_vdisable(void)
 {
@@ -57,7 +59,7 @@
 #if defined(_POSIX_VDISABLE) && HAVE_UNISTD_H
     value = _POSIX_VDISABLE;
 #endif
-#if defined(_PC_VDISABLE)
+#if defined(_PC_VDISABLE) && HAVE_FPATHCONF
     if (value == -1) {
 	value = (int) fpathconf(0, _PC_VDISABLE);
 	if (value == -1) {
@@ -70,6 +72,7 @@
 #endif
     return value;
 }
+#endif /* TERMIOS */
 
 /*
  *	erasechar()
@@ -91,6 +94,8 @@
 	result = termp->Ottyb.c_cc[VERASE];
 	if (result == _nc_vdisable())
 	    result = ERR;
+#elif defined(EXP_WIN32_DRIVER)
+	result = ERR;
 #else
 	result = termp->Ottyb.sg_erase;
 #endif
@@ -126,6 +131,8 @@
 	result = termp->Ottyb.c_cc[VKILL];
 	if (result == _nc_vdisable())
 	    result = ERR;
+#elif defined(EXP_WIN32_DRIVER)
+	result = ERR;
 #else
 	result = termp->Ottyb.sg_kill;
 #endif
@@ -141,30 +148,40 @@
 }
 #endif
 
+static void
+flush_input(int fd)
+{
+#ifdef TERMIOS
+    tcflush(fd, TCIFLUSH);
+#else /* !TERMIOS */
+    errno = 0;
+    do {
+#if defined(EXP_WIN32_DRIVER)
+	_nc_console_flush(_nc_console_fd2handle(fd));
+#else
+	ioctl(fd, TIOCFLUSH, 0);
+#endif
+    } while
+	(errno == EINTR);
+#endif
+}
+
 /*
  *	flushinp()
  *
- *	Flush any input on cur_term->Filedes
- *
+ *	Flush any input on tty
  */
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(flushinp) (NCURSES_SP_DCL0)
 {
-    TERMINAL *termp = TerminalOf(SP_PARM);
-
     T((T_CALLED("flushinp(%p)"), (void *) SP_PARM));
 
-    if (termp != 0) {
-#ifdef TERMIOS
-	tcflush(termp->Filedes, TCIFLUSH);
-#else
-	errno = 0;
-	do {
-	    ioctl(termp->Filedes, TIOCFLUSH, 0);
-	} while
-	    (errno == EINTR);
-#endif
+    if (SP_PARM != 0) {
+	if (NC_ISATTY(SP_PARM->_ifd))
+	    flush_input(SP_PARM->_ifd);
+	else if (NC_ISATTY(SP_PARM->_ofd))
+	    flush_input(SP_PARM->_ofd);
 	if (SP_PARM) {
 	    SP_PARM->_fifohead = -1;
 	    SP_PARM->_fifotail = 0;
diff --git a/ncurses/tinfo/lib_longname.c b/ncurses/tinfo/lib_longname.c
index fa231b8..9dc6d71 100644
--- a/ncurses/tinfo/lib_longname.c
+++ b/ncurses/tinfo/lib_longname.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2015 Free Software Foundation, Inc.              *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_longname.c,v 1.13 2015/07/25 20:08:14 tom Exp $")
+MODULE_ID("$Id: lib_longname.c,v 1.15 2021/04/03 22:36:21 tom Exp $")
 
 #if USE_REENTRANT
 NCURSES_EXPORT(char *)
@@ -50,11 +51,12 @@
 {
     static char empty[] =
     {'\0'};
-    char *ptr;
 
     T((T_CALLED("longname(%p)"), (void *) SP_PARM));
 
     if (SP_PARM) {
+	char *ptr;
+
 	for (ptr = SP_PARM->_ttytype + strlen(SP_PARM->_ttytype);
 	     ptr > SP_PARM->_ttytype;
 	     ptr--)
diff --git a/ncurses/tinfo/lib_napms.c b/ncurses/tinfo/lib_napms.c
index df17363..1b89a54 100644
--- a/ncurses/tinfo/lib_napms.c
+++ b/ncurses/tinfo/lib_napms.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -51,17 +52,18 @@
 #endif
 #endif
 
-MODULE_ID("$Id: lib_napms.c,v 1.24 2014/03/08 20:32:59 tom Exp $")
+MODULE_ID("$Id: lib_napms.c,v 1.28 2023/09/16 16:09:33 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(napms) (NCURSES_SP_DCLx int ms)
 {
     T((T_CALLED("napms(%d)"), ms));
 
+    if (ms > MAX_DELAY_MSECS)
+	ms = MAX_DELAY_MSECS;
+
 #ifdef USE_TERM_DRIVER
-    if (HasTerminal(SP_PARM)) {
-	CallDriver_1(SP_PARM, td_nap, ms);
-    }
+    CallDriver_1(SP_PARM, td_nap, ms);
 #else /* !USE_TERM_DRIVER */
 #if NCURSES_SP_FUNCS
     (void) sp;
@@ -76,6 +78,8 @@
 	    request = remaining;
 	}
     }
+#elif defined(_NC_WINDOWS)
+    Sleep((DWORD) ms);
 #else
     _nc_timed_wait(0, 0, ms, (int *) 0 EVENTLIST_2nd(0));
 #endif
diff --git a/ncurses/tinfo/lib_options.c b/ncurses/tinfo/lib_options.c
index b736d5f..6a8bb39 100644
--- a/ncurses/tinfo/lib_options.c
+++ b/ncurses/tinfo/lib_options.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -46,7 +47,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_options.c,v 1.78 2014/09/27 21:55:24 tom Exp $")
+MODULE_ID("$Id: lib_options.c,v 1.83 2023/04/29 18:56:12 tom Exp $")
 
 NCURSES_EXPORT(int)
 idlok(WINDOW *win, bool flag)
@@ -87,11 +88,11 @@
 {
     T((T_CALLED("halfdelay(%p,%d)"), (void *) SP_PARM, t));
 
-    if (t < 1 || t > 255 || !IsValidTIScreen(SP_PARM))
+    if (t < 1 || t > 255 || !SP_PARM || !IsValidTIScreen(SP_PARM))
 	returnCode(ERR);
 
     NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG);
-    SP_PARM->_cbreak = t + 1;
+    IsCbreak(SP_PARM) = t + 1;
     returnCode(OK);
 }
 
@@ -202,7 +203,7 @@
 #ifdef USE_TERM_DRIVER
 	    code = CallDriver_1(SP_PARM, td_cursorSet, vis);
 #else
-	    if (IsTermInfo(SP_PARM)) {
+	    if (IsValidTIScreen(SP_PARM)) {
 		switch (vis) {
 		case 2:
 		    code = NCURSES_PUTP2_FLUSH("cursor_visible",
@@ -241,7 +242,7 @@
 NCURSES_SP_NAME(typeahead) (NCURSES_SP_DCLx int fd)
 {
     T((T_CALLED("typeahead(%p, %d)"), (void *) SP_PARM, fd));
-    if (IsValidTIScreen(SP_PARM)) {
+    if (SP_PARM && IsValidTIScreen(SP_PARM)) {
 	SP_PARM->_checkfd = fd;
 	returnCode(OK);
     } else {
@@ -360,7 +361,7 @@
 #else
 	    if (flag) {
 		(void) NCURSES_PUTP2_FLUSH("keypad_xmit", keypad_xmit);
-	    } else if (!flag && keypad_local) {
+	    } else if (keypad_local) {
 		(void) NCURSES_PUTP2_FLUSH("keypad_local", keypad_local);
 	    }
 
diff --git a/ncurses/tinfo/lib_print.c b/ncurses/tinfo/lib_print.c
index 0dab4d4..e7d8535 100644
--- a/ncurses/tinfo/lib_print.c
+++ b/ncurses/tinfo/lib_print.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2018-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2011,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,14 +40,14 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_print.c,v 1.23 2012/02/22 22:34:31 tom Exp $")
+MODULE_ID("$Id: lib_print.c,v 1.31 2023/06/10 12:44:41 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len)
 /* ship binary character data to the printer via mc4/mc5/mc5p */
 {
     int result;
-    char *mybuf, *switchon;
+    char *mybuf = NULL, *switchon;
     size_t onsize, offsize;
     size_t need;
 
@@ -59,7 +60,7 @@
     }
 
     if (prtr_non) {
-	switchon = TPARM_1(prtr_non, len);
+	switchon = TIPARM_1(prtr_non, len);
 	onsize = strlen(switchon);
 	offsize = 0;
     } else {
@@ -72,6 +73,7 @@
 
     if (switchon == 0
 	|| (mybuf = typeMalloc(char, need + 1)) == 0) {
+	free(mybuf);
 	errno = ENOMEM;
 	return (ERR);
     }
@@ -88,14 +90,14 @@
      * data has actually been shipped to the terminal.  If the write(2)
      * operation is truly atomic we're protected from this.
      */
-    result = (int) write(TerminalOf(SP_PARM)->Filedes, mybuf, need);
+    result = (int) write(SP_PARM->_ofd, mybuf, need);
 
     /*
      * By giving up our scheduler slot here we increase the odds that the
      * kernel will ship the contiguous clist items from the last write
      * immediately.
      */
-#ifndef __MINGW32__
+#ifndef _NC_WINDOWS
     (void) sleep(0);
 #endif
     free(mybuf);
diff --git a/ncurses/tinfo/lib_raw.c b/ncurses/tinfo/lib_raw.c
index 928692b..fda6dea 100644
--- a/ncurses/tinfo/lib_raw.c
+++ b/ncurses/tinfo/lib_raw.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020-2023,2024 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -49,7 +50,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_raw.c,v 1.21 2012/01/21 19:21:29 KO.Myung-Hun Exp $")
+MODULE_ID("$Id: lib_raw.c,v 1.30 2024/03/30 15:54:17 tom Exp $")
 
 #if HAVE_SYS_TERMIO_H
 #include <sys/termio.h>		/* needed for ISC */
@@ -96,6 +97,8 @@
 	buf.c_iflag &= (unsigned) ~(COOKED_INPUT);
 	buf.c_cc[VMIN] = 1;
 	buf.c_cc[VTIME] = 0;
+#elif defined(EXP_WIN32_DRIVER)
+	buf.dwFlagIn &= (unsigned long) ~CONMODE_NORAW;
 #else
 	buf.sg_flags |= RAW;
 #endif
@@ -112,8 +115,10 @@
 	    kbdinfo.fsMask |= KEYBOARD_BINARY_MODE;
 	    KbdSetStatus(&kbdinfo, 0);
 #endif
-	    SP_PARM->_raw = TRUE;
-	    SP_PARM->_cbreak = 1;
+	    if (SP_PARM) {
+		IsRaw(SP_PARM) = TRUE;
+		IsCbreak(SP_PARM) = 1;
+	    }
 	    termp->Nttyb = buf;
 	}
 	AFTER("raw");
@@ -146,15 +151,19 @@
 #ifdef TERMIOS
 	buf.c_lflag &= (unsigned) ~ICANON;
 	buf.c_iflag &= (unsigned) ~ICRNL;
-	buf.c_lflag |= ISIG;
 	buf.c_cc[VMIN] = 1;
 	buf.c_cc[VTIME] = 0;
+#elif defined(EXP_WIN32_DRIVER)
+	buf.dwFlagIn |= CONMODE_NORAW;
+	buf.dwFlagIn &= (unsigned long) ~CONMODE_NOCBREAK;
 #else
 	buf.sg_flags |= CBREAK;
 #endif
 	result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
 	if (result == OK) {
-	    SP_PARM->_cbreak = 1;
+	    if (SP_PARM) {
+		IsCbreak(SP_PARM) = 1;
+	    }
 	    termp->Nttyb = buf;
 	}
 	AFTER("cbreak");
@@ -177,12 +186,12 @@
 NCURSES_EXPORT(void)
 NCURSES_SP_NAME(qiflush) (NCURSES_SP_DCL0)
 {
-    int result = ERR;
     TERMINAL *termp;
 
     T((T_CALLED("qiflush(%p)"), (void *) SP_PARM));
     if ((termp = TerminalOf(SP_PARM)) != 0) {
 	TTY buf;
+	int result;
 
 	BEFORE("qiflush");
 	buf = termp->Nttyb;
@@ -190,6 +199,7 @@
 	buf.c_lflag &= (unsigned) ~(NOFLSH);
 	result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
 #else
+	result = ERR;
 	/* FIXME */
 #endif
 	if (result == OK)
@@ -225,6 +235,8 @@
 	buf.c_lflag |= ISIG | ICANON |
 	    (termp->Ottyb.c_lflag & IEXTEN);
 	buf.c_iflag |= COOKED_INPUT;
+#elif defined(EXP_WIN32_DRIVER)
+	buf.dwFlagIn |= CONMODE_NORAW;
 #else
 	buf.sg_flags &= ~(RAW | CBREAK);
 #endif
@@ -241,8 +253,10 @@
 	    kbdinfo.fsMask |= KEYBOARD_ASCII_MODE;
 	    KbdSetStatus(&kbdinfo, 0);
 #endif
-	    SP_PARM->_raw = FALSE;
-	    SP_PARM->_cbreak = 0;
+	    if (SP_PARM) {
+		IsRaw(SP_PARM) = FALSE;
+		IsCbreak(SP_PARM) = 0;
+	    }
 	    termp->Nttyb = buf;
 	}
 	AFTER("noraw");
@@ -275,12 +289,16 @@
 #ifdef TERMIOS
 	buf.c_lflag |= ICANON;
 	buf.c_iflag |= ICRNL;
+#elif defined(EXP_WIN32_DRIVER)
+	buf.dwFlagIn |= (CONMODE_NOCBREAK | CONMODE_NORAW);
 #else
 	buf.sg_flags &= ~CBREAK;
 #endif
 	result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
 	if (result == OK) {
-	    SP_PARM->_cbreak = 0;
+	    if (SP_PARM) {
+		IsCbreak(SP_PARM) = 0;
+	    }
 	    termp->Nttyb = buf;
 	}
 	AFTER("nocbreak");
@@ -299,12 +317,12 @@
 NCURSES_EXPORT(void)
 NCURSES_SP_NAME(noqiflush) (NCURSES_SP_DCL0)
 {
-    int result = ERR;
     TERMINAL *termp;
 
     T((T_CALLED("noqiflush(%p)"), (void *) SP_PARM));
     if ((termp = TerminalOf(SP_PARM)) != 0) {
 	TTY buf;
+	int result;
 
 	BEFORE("noqiflush");
 	buf = termp->Nttyb;
@@ -313,6 +331,7 @@
 	result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
 #else
 	/* FIXME */
+	result = ERR;
 #endif
 	if (result == OK)
 	    termp->Nttyb = buf;
@@ -375,3 +394,46 @@
     return NCURSES_SP_NAME(intrflush) (CURRENT_SCREEN, win, flag);
 }
 #endif
+
+#if NCURSES_EXT_FUNCS
+/* *INDENT-OFF* */
+
+/*
+ * SCREEN is always opaque, but nl/raw/cbreak/echo set properties in it.
+ * As an extension, provide a way to query the properties.
+ *
+ * There are other properties which could be queried, e.g., filter, keypad,
+ * use_env, use_meta, but these particular properties are saved/restored within
+ * the wgetnstr() and wgetn_wstr() functions, which requires that the higher
+ * level curses library knows about the internal state of the lower level
+ * terminfo library.
+ */
+
+#define is_TEST(show,what) \
+    NCURSES_EXPORT(int) \
+    NCURSES_SP_NAME(show) (NCURSES_SP_DCL0) \
+    { \
+	return ((SP_PARM != NULL) ? (what(SP_PARM) ? 1 : 0) : -1); \
+    }
+
+is_TEST(is_nl, IsNl)
+is_TEST(is_raw, IsRaw)
+is_TEST(is_cbreak, IsCbreak)
+is_TEST(is_echo, IsEcho)
+
+#if NCURSES_SP_FUNCS
+#undef is_TEST
+#define is_TEST(show) \
+    NCURSES_EXPORT(int) \
+    show(void) \
+    { \
+	return NCURSES_SP_NAME(show) (CURRENT_SCREEN); \
+    }
+is_TEST(is_nl)
+is_TEST(is_raw)
+is_TEST(is_cbreak)
+is_TEST(is_echo)
+#endif
+
+/* *INDENT-ON* */
+#endif /* extensions */
diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c
index 0a0a1f5..99097f0 100644
--- a/ncurses/tinfo/lib_setup.c
+++ b/ncurses/tinfo/lib_setup.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -48,7 +49,7 @@
 #include <locale.h>
 #endif
 
-MODULE_ID("$Id: lib_setup.c,v 1.164 2015/06/27 18:10:55 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.240 2024/04/20 17:04:05 tom Exp $")
 
 /****************************************************************************
  *
@@ -65,7 +66,7 @@
 #endif
 
 #if NEED_PTEM_H
- /* On SCO, they neglected to define struct winsize in termios.h -- it's only
+ /* On SCO, they neglected to define struct winsize in termios.h -- it is only
   * in termio.h and ptem.h (the former conflicts with other definitions).
   */
 # include <sys/stream.h>
@@ -98,7 +99,7 @@
  * Reduce explicit use of "cur_term" global variable.
  */
 #undef CUR
-#define CUR termp->type.
+#define CUR TerminalType(termp).
 
 /*
  * Wrap global variables in this module.
@@ -115,12 +116,12 @@
     if (CURRENT_SCREEN) {
 	TERMINAL *termp = TerminalOf(CURRENT_SCREEN);
 	if (termp != 0) {
-	    result = termp->type.term_names;
+	    result = TerminalType(termp).term_names;
 	}
     }
 #else
     if (cur_term != 0) {
-	result = cur_term->type.term_names;
+	result = TerminalType(cur_term).term_names;
     }
 #endif
     return result;
@@ -173,16 +174,20 @@
 NCURSES_SP_NAME(set_tabsize) (NCURSES_SP_DCLx int value)
 {
     int code = OK;
-#if USE_REENTRANT
-    if (SP_PARM) {
-	SP_PARM->_TABSIZE = value;
-    } else {
+    if (value <= 0) {
 	code = ERR;
-    }
+    } else {
+#if USE_REENTRANT
+	if (SP_PARM) {
+	    SP_PARM->_TABSIZE = value;
+	} else {
+	    code = ERR;
+	}
 #else
-    (void) SP_PARM;
-    TABSIZE = value;
+	(void) SP_PARM;
+	TABSIZE = value;
 #endif
+    }
     return code;
 }
 
@@ -220,9 +225,9 @@
 NCURSES_EXPORT(void)
 NCURSES_SP_NAME(use_env) (NCURSES_SP_DCLx bool f)
 {
+    START_TRACE();
     T((T_CALLED("use_env(%p,%d)"), (void *) SP_PARM, (int) f));
 #if NCURSES_SP_FUNCS
-    START_TRACE();
     if (IsPreScreen(SP_PARM)) {
 	SP_PARM->_use_env = f;
     }
@@ -235,11 +240,11 @@
 NCURSES_EXPORT(void)
 NCURSES_SP_NAME(use_tioctl) (NCURSES_SP_DCLx bool f)
 {
+    START_TRACE();
     T((T_CALLED("use_tioctl(%p,%d)"), (void *) SP_PARM, (int) f));
 #if NCURSES_SP_FUNCS
-    START_TRACE();
     if (IsPreScreen(SP_PARM)) {
-	SP_PARM->_use_tioctl = f;
+	SP_PARM->use_tioctl = f;
     }
 #else
     _nc_prescreen.use_tioctl = f;
@@ -251,8 +256,8 @@
 NCURSES_EXPORT(void)
 use_env(bool f)
 {
-    T((T_CALLED("use_env(%d)"), (int) f));
     START_TRACE();
+    T((T_CALLED("use_env(%d)"), (int) f));
     _nc_prescreen.use_env = f;
     returnVoid;
 }
@@ -260,17 +265,202 @@
 NCURSES_EXPORT(void)
 use_tioctl(bool f)
 {
-    T((T_CALLED("use_tioctl(%d)"), (int) f));
     START_TRACE();
+    T((T_CALLED("use_tioctl(%d)"), (int) f));
     _nc_prescreen.use_tioctl = f;
     returnVoid;
 }
 #endif
 
+#if !(defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER))
+static void
+_nc_default_screensize(TERMINAL *termp, int *linep, int *colp)
+{
+    /* if we can't get dynamic info about the size, use static */
+    if (*linep <= 0) {
+	*linep = (int) lines;
+    }
+    if (*colp <= 0) {
+	*colp = (int) columns;
+    }
+
+    /* the ultimate fallback, assume fixed 24x80 size */
+    if (*linep <= 0) {
+	*linep = 24;
+    }
+    if (*colp <= 0) {
+	*colp = 80;
+    }
+}
+
+#if defined(USE_CHECK_SIZE) && defined(user6) && defined(user7)
+static const char *
+skip_csi(const char *value)
+{
+    if (UChar(*value) == CSI_CHR) {
+	++value;
+    } else if (*value == ESC_CHR && value[1] == L_BLOCK) {
+	value += 2;
+    }
+    return value;
+}
+
+static bool
+is_expected(const char *value, const char *expected)
+{
+    bool result = FALSE;
+    if (VALID_STRING(value)) {
+	const char *skipped = skip_csi(value);
+	if (skipped != value) {
+	    if (!strcmp(skipped, expected))
+		result = TRUE;
+	}
+    }
+    return result;
+}
+
+static bool
+get_position(TERMINAL *termp, int fd, int *row, int *col)
+{
+    bool result = FALSE;
+    size_t need = strlen(user7);
+    int have;
+
+    have = (int) write(fd, user7, need);
+
+    if (have == (int) need) {
+	int y, x;
+	char buf[20];
+	char *s;
+	char cc;
+	const char *skipped;
+	int scanned;
+
+	s = memset(buf, '\0', sizeof(buf));
+	do {
+	    size_t ask = (sizeof(buf) - 1 - (size_t) (s - buf));
+	    int got = (int) read(fd, s, ask);
+	    if (got == 0)
+		break;
+	    s += got;
+	    *s = '\0';
+	} while (strchr(buf, 'R') == NULL && (size_t) (s + 1 - buf) < sizeof(buf));
+	T(("CPR response %s", _nc_visbuf(buf)));
+	skipped = skip_csi(buf);
+	cc = '\0';
+	if (skipped != buf
+	    && *skipped != '\0'
+	    && (scanned = sscanf(skip_csi(buf), "%d;%d%c", &y, &x, &cc)) == 3
+	    && (cc == 'R')) {
+	    *row = y;
+	    *col = x;
+	    result = TRUE;
+	}
+    }
+    T(("get_position %s %d,%d", result ? "OK" : "ERR", *row, *col));
+    return result;
+}
+
+static bool
+set_position(NCURSES_SP_DCLx TERMINAL *termp, int row, int col)
+{
+    bool result;
+    char *actual = TIPARM_2(cursor_address, row, col);
+    T((T_CALLED("set_position %d,%d)"), row, col));
+#if NCURSES_SP_FUNCS
+    result = (NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "set_position",
+					 actual) == OK);
+    NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
+#else
+    /* This does not support padding because without sp-funcs, we have only
+     * the interface using stdio, but we are not guaranteed that Filedes
+     * is the same as fileno(stdout).
+     */
+    result = FALSE;
+    if (actual != NULL) {
+	size_t want = strlen(actual);
+	int have = (int) write(termp->Filedes, actual, want);
+	result = ((int) want == have);
+    }
+#endif
+    returnBool(result);
+}
+
+/*
+ * This is a little more complicated than one might expect, because we do this
+ * before setting up the terminal modes, etc., and cannot use the timeout or
+ * buffering functions.
+ *
+ * We check if the terminal description has the ECMA-48 CPR (cursor position
+ * report) in u7 and the response in u6.  The two variations of is_expected()
+ * cover the termcap style and terminfo style, and are equivalent as far as we
+ * are concerned.  For analyzing the response, we wait (a short time) for 'R'
+ * to be echoed, and then check if we received two integers in the response.
+ *
+ * In principle, this could run on "any" ECMA-48 terminal, but in practice,
+ * there is a scenario using GNU screen where it uses ncurses with a partially
+ * configured pseudo-terminal, and the CPR response goes to the wrong place.
+ * So we do a simple check to exclude pseudo-terminals.
+ */
+static void
+_nc_check_screensize(SCREEN *sp, TERMINAL *termp, int *linep, int *colp)
+{
+    int fd = termp->Filedes;
+    TTY saved;
+    const char *name = NULL;
+
+    if (IsRealTty(fd, name)
+	&& VALID_STRING(cursor_address)
+	&& is_expected(user7, "6n")
+	&& (is_expected(user6, "%i%d;%dR") ||
+	    is_expected(user6, "%i%p1%d;%p2%dR"))
+	&& GET_TTY(fd, &saved) == OK) {
+	int current_y = -1, current_x = -1;
+	int updated_y = -1, updated_x = -1;
+	TTY alter = saved;
+
+#if NCURSES_SP_FUNCS
+	if (sp == NULL) {
+	    sp = new_prescr();
+	    sp->_term = termp;
+	    NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG);
+	}
+#else
+	(void) sp;
+#endif
+
+	T(("trying CPR (u7/u6) with %s", name));
+	alter.c_lflag &= (unsigned) ~(ECHO | ICANON | ISIG | IEXTEN);
+	alter.c_iflag &= (unsigned) ~(IXON | BRKINT | PARMRK);
+	alter.c_cc[VMIN] = 0;
+	alter.c_cc[VTIME] = 1;
+	SET_TTY(fd, &alter);
+
+	if (get_position(termp, fd, &current_y, &current_x)
+	    && set_position(NCURSES_SP_ARGx termp, 9999, 9999)
+	    && get_position(termp, fd, &updated_y, &updated_x)) {
+	    *linep = updated_y;
+	    *colp = updated_x;
+	    set_position(NCURSES_SP_ARGx termp, current_y, current_x);
+	}
+	/* restore tty modes */
+	SET_TTY(fd, &saved);
+    } else {
+	T(("NOT trying CPR with fd %d (%s): %s",
+	   fd, NonNull(name), NC_ISATTY(fd) ? "tty" : "not a tty"));
+    }
+
+    _nc_default_screensize(termp, linep, colp);
+}
+#else /* !USE_CHECK_SIZE */
+#define _nc_check_screensize(sp, termp, linep, colp)	/* nothing */
+#endif
+#endif /* !(defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER)) */
+
 NCURSES_EXPORT(void)
 _nc_get_screensize(SCREEN *sp,
 #ifdef USE_TERM_DRIVER
-		   TERMINAL * termp,
+		   TERMINAL *termp,
 #endif
 		   int *linep, int *colp)
 /* Obtain lines/columns values from the environment and/or terminfo entry */
@@ -297,16 +487,33 @@
 #else /* !USE_TERM_DRIVER */
     TERMINAL *termp = cur_term;
     int my_tabsize;
+    bool useEnv = _nc_prescreen.use_env;
+    bool useTioctl = _nc_prescreen.use_tioctl;
 
+    T((T_CALLED("_nc_get_screensize (%p)"), (void *) sp));
+#ifdef EXP_WIN32_DRIVER
+    /* If we are here, then Windows console is used in terminfo mode.
+       We need to figure out the size using the console API
+     */
+    _nc_console_size(linep, colp);
+    T(("screen size: winconsole lines = %d columns = %d", *linep, *colp));
+#else
     /* figure out the size of the screen */
     T(("screen size: terminfo lines = %d columns = %d", lines, columns));
 
     *linep = (int) lines;
     *colp = (int) columns;
+#endif
 
-    if (_nc_prescreen.use_env || _nc_prescreen.use_tioctl) {
-	int value;
+#if NCURSES_SP_FUNCS
+    if (sp) {
+	useEnv = sp->_use_env;
+	useTioctl = sp->use_tioctl;
+    }
+#endif
 
+    T(("useEnv:%d useTioctl:%d", useEnv, useTioctl));
+    if (useEnv || useTioctl) {
 #ifdef __EMX__
 	{
 	    int screendata[2];
@@ -340,8 +547,10 @@
 	}
 #endif /* HAVE_SIZECHANGE */
 
-	if (_nc_prescreen.use_env) {
-	    if (_nc_prescreen.use_tioctl) {
+	if (useEnv) {
+	    int value;
+
+	    if (useTioctl) {
 		/*
 		 * If environment variables are used, update them.
 		 */
@@ -367,30 +576,26 @@
 		*colp = value;
 		T(("screen size: environment COLUMNS = %d", *colp));
 	    }
-	}
 
-	/* if we can't get dynamic info about the size, use static */
-	if (*linep <= 0) {
-	    *linep = (int) lines;
-	}
-	if (*colp <= 0) {
-	    *colp = (int) columns;
-	}
-
-	/* the ultimate fallback, assume fixed 24x80 size */
-	if (*linep <= 0) {
-	    *linep = 24;
-	}
-	if (*colp <= 0) {
-	    *colp = 80;
+	    _nc_default_screensize(termp, linep, colp);
+	} else {
+	    _nc_check_screensize(sp, termp, linep, colp);
 	}
 
 	/*
 	 * Put the derived values back in the screen-size caps, so
 	 * tigetnum() and tgetnum() will do the right thing.
 	 */
-	lines = (short) (*linep);
-	columns = (short) (*colp);
+	lines = (NCURSES_INT2) (*linep);
+	columns = (NCURSES_INT2) (*colp);
+#if NCURSES_EXT_NUMBERS
+#define OldNumber(termp,name) \
+	(termp)->type.Numbers[(&name - (termp)->type2.Numbers)]
+	OldNumber(termp, lines) = (short) (*linep);
+	OldNumber(termp, columns) = (short) (*colp);
+#endif
+    } else {
+	_nc_check_screensize(sp, termp, linep, colp);
     }
 
     T(("screen size is %dx%d", *linep, *colp));
@@ -407,6 +612,7 @@
     TABSIZE = my_tabsize;
 #endif
     T(("TABSIZE = %d", TABSIZE));
+    returnVoid;
 #endif /* USE_TERM_DRIVER */
 }
 
@@ -431,23 +637,24 @@
     int old_cols = columns;
 #endif
 
-    TINFO_GET_SIZE(sp, sp->_term, &new_lines, &new_cols);
-
-    /*
-     * See is_term_resized() and resizeterm().
-     * We're doing it this way because those functions belong to the upper
-     * ncurses library, while this resides in the lower terminfo library.
-     */
-    if (sp != 0 && sp->_resize != 0) {
-	if ((new_lines != old_lines) || (new_cols != old_cols)) {
-	    sp->_resize(NCURSES_SP_ARGx new_lines, new_cols);
-	} else if (sp->_sig_winch && (sp->_ungetch != 0)) {
-	    sp->_ungetch(SP_PARM, KEY_RESIZE);	/* so application can know this */
+    if (sp != 0) {
+	TINFO_GET_SIZE(sp, sp->_term, &new_lines, &new_cols);
+	/*
+	 * See is_term_resized() and resizeterm().
+	 * We're doing it this way because those functions belong to the upper
+	 * ncurses library, while this resides in the lower terminfo library.
+	 */
+	if (sp->_resize != 0) {
+	    if ((new_lines != old_lines) || (new_cols != old_cols)) {
+		sp->_resize(NCURSES_SP_ARGx new_lines, new_cols);
+	    } else if (sp->_sig_winch && (sp->_ungetch != 0)) {
+		sp->_ungetch(SP_PARM, KEY_RESIZE);	/* so application can know this */
+	    }
+	    sp->_sig_winch = FALSE;
 	}
-	sp->_sig_winch = FALSE;
     }
 }
-#endif
+#endif /* USE_SIZECHANGE */
 
 /****************************************************************************
  *
@@ -461,10 +668,10 @@
  * just like tgetent().
  */
 int
-_nc_setup_tinfo(const char *const tn, TERMTYPE *const tp)
+_nc_setup_tinfo(const char *const tn, TERMTYPE2 *const tp)
 {
     char filename[PATH_MAX];
-    int status = _nc_read_entry(tn, filename, tp);
+    int status = _nc_read_entry2(tn, filename, tp);
 
     /*
      * If we have an entry, force all of the cancelled strings to null
@@ -474,6 +681,7 @@
      */
     if (status == TGETENT_YES) {
 	unsigned n;
+	T(("_nc_setup_tinfo - resetting invalid booleans/strings"));
 	for_each_boolean(n, tp) {
 	    if (!VALID_BOOLEAN(tp->Booleans[n]))
 		tp->Booleans[n] = FALSE;
@@ -488,14 +696,12 @@
 #endif
 
 /*
-**	Take the real command character out of the CC environment variable
-**	and substitute it in for the prototype given in 'command_character'.
-*/
+ * Take the real command character out of the CC environment variable
+ * and substitute it in for the prototype given in 'command_character'.
+ */
 void
-_nc_tinfo_cmdch(TERMINAL * termp, int proto)
+_nc_tinfo_cmdch(TERMINAL *termp, int proto)
 {
-    unsigned i;
-    char CC;
     char *tmp;
 
     /*
@@ -504,11 +710,16 @@
      * name as an environment variable - using the same symbol.
      */
     if ((tmp = getenv("CC")) != 0 && strlen(tmp) == 1) {
-	CC = *tmp;
+	unsigned i;
+	char CC = *tmp;
+
 	for_each_string(i, &(termp->type)) {
-	    for (tmp = termp->type.Strings[i]; tmp && *tmp; tmp++) {
-		if (UChar(*tmp) == proto)
-		    *tmp = CC;
+	    tmp = termp->type.Strings[i];
+	    if (VALID_STRING(tmp)) {
+		for (; *tmp; ++tmp) {
+		    if (UChar(*tmp) == proto)
+			*tmp = CC;
+		}
 	    }
 	}
     }
@@ -528,9 +739,9 @@
      */
     env = setlocale(LC_CTYPE, 0);
 #else
-    if (((env = getenv("LC_ALL")) != 0 && *env != '\0')
+    if (((env = getenv("LANG")) != 0 && *env != '\0')
 	|| ((env = getenv("LC_CTYPE")) != 0 && *env != '\0')
-	|| ((env = getenv("LANG")) != 0 && *env != '\0')) {
+	|| ((env = getenv("LC_ALL")) != 0 && *env != '\0')) {
 	;
     }
 #endif
@@ -544,22 +755,27 @@
 NCURSES_EXPORT(int)
 _nc_unicode_locale(void)
 {
-    int result = 0;
-#if defined(__MINGW32__) && USE_WIDEC_SUPPORT
-    result = 1;
+    static bool initialized = FALSE;
+    static int result = 0;
+
+    if (!initialized) {
+#if defined(_NC_WINDOWS) && USE_WIDEC_SUPPORT
+	result = 1;
 #elif HAVE_LANGINFO_CODESET
-    char *env = nl_langinfo(CODESET);
-    result = !strcmp(env, "UTF-8");
-    T(("_nc_unicode_locale(%s) ->%d", env, result));
+	char *env = nl_langinfo(CODESET);
+	result = !strcmp(env, "UTF-8");
+	T(("_nc_unicode_locale(%s) ->%d", env, result));
 #else
-    char *env = _nc_get_locale();
-    if (env != 0) {
-	if (strstr(env, ".UTF-8") != 0) {
-	    result = 1;
-	    T(("_nc_unicode_locale(%s) ->%d", env, result));
+	char *env = _nc_get_locale();
+	if (env != 0) {
+	    if (strstr(env, ".UTF-8") != 0) {
+		result = 1;
+		T(("_nc_unicode_locale(%s) ->%d", env, result));
+	    }
 	}
-    }
 #endif
+	initialized = TRUE;
+    }
     return result;
 }
 
@@ -571,7 +787,7 @@
  * character set.
  */
 NCURSES_EXPORT(int)
-_nc_locale_breaks_acs(TERMINAL * termp)
+_nc_locale_breaks_acs(TERMINAL *termp)
 {
     const char *env_name = "NCURSES_NO_UTF8_ACS";
     const char *env;
@@ -602,19 +818,18 @@
 }
 
 NCURSES_EXPORT(int)
-TINFO_SETUP_TERM(TERMINAL ** tp,
-		 NCURSES_CONST char *tname,
+TINFO_SETUP_TERM(TERMINAL **tp,
+		 const char *tname,
 		 int Filedes,
 		 int *errret,
 		 int reuse)
 {
 #ifdef USE_TERM_DRIVER
     TERMINAL_CONTROL_BLOCK *TCB = 0;
-#else
-    int status;
 #endif
     TERMINAL *termp;
     SCREEN *sp = 0;
+    char *myname;
     int code = ERR;
 
     START_TRACE();
@@ -635,22 +850,30 @@
 
     if (tname == 0) {
 	tname = getenv("TERM");
-	if (tname == 0 || *tname == '\0') {
-#ifdef USE_TERM_DRIVER
+#if defined(EXP_WIN32_DRIVER)
+	if (!VALID_TERM_ENV(tname, NO_TERMINAL)) {
+	    T(("Failure with TERM=%s", NonNull(tname)));
+	    ret_error0(TGETENT_ERR, "TERM environment variable not set.\n");
+	}
+#elif defined(USE_TERM_DRIVER)
+	if (!NonEmpty(tname))
 	    tname = "unknown";
 #else
+	if (!NonEmpty(tname)) {
+	    T(("Failure with TERM=%s", NonNull(tname)));
 	    ret_error0(TGETENT_ERR, "TERM environment variable not set.\n");
-#endif
 	}
+#endif
     }
-
-    if (strlen(tname) > MAX_NAME_SIZE) {
+    myname = strdup(tname);
+    if (myname == NULL || strlen(myname) > MAX_NAME_SIZE) {
 	ret_error(TGETENT_ERR,
-		  "TERM environment must be <= %d characters.\n",
-		  MAX_NAME_SIZE);
+		  "TERM environment must be 1..%d characters.\n",
+		  MAX_NAME_SIZE,
+		  free(myname));
     }
 
-    T(("your terminal name is %s", tname));
+    T(("your terminal name is %s", myname));
 
     /*
      * Allow output redirection.  This is what SVr3 does.  If stdout is
@@ -658,6 +881,10 @@
      */
     if (Filedes == STDOUT_FILENO && !NC_ISATTY(Filedes))
 	Filedes = STDERR_FILENO;
+#if defined(EXP_WIN32_DRIVER)
+    if (Filedes != STDERR_FILENO && NC_ISATTY(Filedes))
+	_setmode(Filedes, _O_BINARY);
+#endif
 
     /*
      * Check if we have already initialized to use this terminal.  If so, we
@@ -679,8 +906,8 @@
 	&& (termp != 0)
 	&& termp->Filedes == Filedes
 	&& termp->_termname != 0
-	&& !strcmp(termp->_termname, tname)
-	&& _nc_name_match(termp->type.term_names, tname, "|")) {
+	&& !strcmp(termp->_termname, myname)
+	&& _nc_name_match(TerminalType(termp).term_names, myname, "|")) {
 	T(("reusing existing terminal information and mode-settings"));
 	code = OK;
 #ifdef USE_TERM_DRIVER
@@ -689,39 +916,70 @@
     } else {
 #ifdef USE_TERM_DRIVER
 	TERMINAL_CONTROL_BLOCK *my_tcb;
-	my_tcb = typeCalloc(TERMINAL_CONTROL_BLOCK, 1);
-	termp = &(my_tcb->term);
+	termp = 0;
+	if ((my_tcb = typeCalloc(TERMINAL_CONTROL_BLOCK, 1)) != 0)
+	    termp = &(my_tcb->term);
 #else
+	int status;
+
 	termp = typeCalloc(TERMINAL, 1);
 #endif
 	if (termp == 0) {
-	    ret_error0(TGETENT_ERR,
-		       "Not enough memory to create terminal structure.\n");
+	    ret_error1(TGETENT_ERR,
+		       "Not enough memory to create terminal structure.\n",
+		       myname, free(myname));
 	}
+	++_nc_globals.terminal_count;
+#if HAVE_SYSCONF
+	{
+	    long limit;
+#ifdef LINE_MAX
+	    limit = LINE_MAX;
+#else
+	    limit = _nc_globals.getstr_limit;
+#endif
+#ifdef _SC_LINE_MAX
+	    if (limit < sysconf(_SC_LINE_MAX))
+		limit = sysconf(_SC_LINE_MAX);
+#endif
+	    if (_nc_globals.getstr_limit < (int) limit)
+		_nc_globals.getstr_limit = (int) limit;
+	}
+#endif /* HAVE_SYSCONF */
+	T(("using %d for getstr limit", _nc_globals.getstr_limit));
+
 #ifdef USE_TERM_DRIVER
 	INIT_TERM_DRIVER();
+	/*
+	 * _nc_get_driver() will call td_CanHandle() for each driver, and win_driver
+	 * needs file descriptor to do the test, so set it before calling.
+	 */
+	termp->Filedes = (short) Filedes;
 	TCB = (TERMINAL_CONTROL_BLOCK *) termp;
-	code = _nc_globals.term_driver(TCB, tname, errret);
+	code = _nc_globals.term_driver(TCB, myname, errret);
 	if (code == OK) {
-	    termp->Filedes = (short) Filedes;
-	    termp->_termname = strdup(tname);
+	    termp->_termname = strdup(myname);
 	} else {
-	    ret_error0(errret ? *errret : TGETENT_ERR,
-		       "Could not find any driver to handle this terminal.\n");
+	    ret_error1(errret ? *errret : TGETENT_ERR,
+		       "Could not find any driver to handle terminal.\n",
+		       myname, free(myname));
 	}
 #else
 #if NCURSES_USE_DATABASE || NCURSES_USE_TERMCAP
-	status = _nc_setup_tinfo(tname, &termp->type);
+	status = _nc_setup_tinfo(myname, &TerminalType(termp));
+	T(("_nc_setup_tinfo returns %d", status));
 #else
+	T(("no database available"));
 	status = TGETENT_NO;
 #endif
 
 	/* try fallback list if entry on disk */
 	if (status != TGETENT_YES) {
-	    const TERMTYPE *fallback = _nc_fallback(tname);
+	    const TERMTYPE2 *fallback = _nc_fallback2(myname);
 
 	    if (fallback) {
-		_nc_copy_termtype(&(termp->type), fallback);
+		T(("found fallback entry"));
+		_nc_copy_termtype2(&(TerminalType(termp)), fallback);
 		status = TGETENT_YES;
 	    }
 	}
@@ -729,33 +987,41 @@
 	if (status != TGETENT_YES) {
 	    del_curterm(termp);
 	    if (status == TGETENT_ERR) {
+		free(myname);
 		ret_error0(status, "terminals database is inaccessible\n");
 	    } else if (status == TGETENT_NO) {
-		ret_error1(status, "unknown terminal type.\n", tname);
+		ret_error1(status, "unknown terminal type.\n",
+			   myname, free(myname));
+	    } else {
+		free(myname);
+		ret_error0(status, "unexpected return-code\n");
 	    }
 	}
+#if NCURSES_EXT_NUMBERS
+	_nc_export_termtype2(&termp->type, &TerminalType(termp));
+#endif
 #if !USE_REENTRANT
-	strncpy(ttytype, termp->type.term_names, (size_t) (NAMESIZE - 1));
-	ttytype[NAMESIZE - 1] = '\0';
+	save_ttytype(termp);
 #endif
 
 	termp->Filedes = (short) Filedes;
-	termp->_termname = strdup(tname);
+	termp->_termname = strdup(myname);
 
 	set_curterm(termp);
 
-	if (command_character)
+	if (VALID_STRING(command_character))
 	    _nc_tinfo_cmdch(termp, UChar(*command_character));
 
 	/*
 	 * If an application calls setupterm() rather than initscr() or
 	 * newterm(), we will not have the def_prog_mode() call in
 	 * _nc_setupscreen().  Do it now anyway, so we can initialize the
-	 * baudrate.
+	 * baudrate.  Also get the shell-mode so that erasechar() works.
 	 */
 	if (NC_ISATTY(Filedes)) {
-	    def_prog_mode();
-	    baudrate();
+	    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);
 	}
 	code = OK;
 #endif
@@ -786,36 +1052,99 @@
 	if ((VALID_STRING(cursor_address)
 	     || (VALID_STRING(cursor_down) && VALID_STRING(cursor_home)))
 	    && VALID_STRING(clear_screen)) {
-	    ret_error1(TGETENT_YES, "terminal is not really generic.\n", tname);
+	    ret_error1(TGETENT_YES, "terminal is not really generic.\n",
+		       myname, free(myname));
 	} else {
 	    del_curterm(termp);
-	    ret_error1(TGETENT_NO, "I need something more specific.\n", tname);
+	    ret_error1(TGETENT_NO, "I need something more specific.\n",
+		       myname, free(myname));
 	}
     } else if (hard_copy) {
-	ret_error1(TGETENT_YES, "I can't handle hardcopy terminals.\n", tname);
+	ret_error1(TGETENT_YES, "I can't handle hardcopy terminals.\n",
+		   myname, free(myname));
     }
 #endif
+    free(myname);
     returnCode(code);
 }
 
+#ifdef USE_PTHREADS
+/*
+ * Returns a non-null pointer unless a new screen should be allocated because
+ * no match was found in the pre-screen cache.
+ */
+NCURSES_EXPORT(SCREEN *)
+_nc_find_prescr(void)
+{
+    SCREEN *result = 0;
+    PRESCREEN_LIST *p;
+    pthread_t id = GetThreadID();
+    for (p = _nc_prescreen.allocated; p != 0; p = p->next) {
+	if (p->id == id) {
+	    result = p->sp;
+	    break;
+	}
+    }
+    return result;
+}
+
+/*
+ * Tells ncurses to forget that this thread was associated with the pre-screen
+ * cache.  It does not modify the pre-screen cache itself, since that is used
+ * for creating new screens.
+ */
+NCURSES_EXPORT(void)
+_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) {
+		q->next = p->next;
+	    } else {
+		_nc_prescreen.allocated = p->next;
+	    }
+	    free(p);
+	    break;
+	}
+    }
+    _nc_unlock_global(screen);
+}
+#endif /* USE_PTHREADS */
+
 #if NCURSES_SP_FUNCS
 /*
  * In case of handling multiple screens, we need to have a screen before
- * initialization in setupscreen takes place.  This is to extend the substitute
- * for some of the stuff in _nc_prescreen, especially for slk and ripoff
- * handling which should be done per screen.
+ * initialization in _nc_setupscreen takes place.  This is to extend the
+ * substitute for some of the stuff in _nc_prescreen, especially for slk and
+ * ripoff handling which should be done per screen.
  */
 NCURSES_EXPORT(SCREEN *)
 new_prescr(void)
 {
-    static SCREEN *sp;
+    SCREEN *sp;
 
     START_TRACE();
     T((T_CALLED("new_prescr()")));
 
-    if (sp == 0) {
+    _nc_lock_global(screen);
+    if ((sp = _nc_find_prescr()) == 0) {
 	sp = _nc_alloc_screen_sp();
+	T(("_nc_alloc_screen_sp %p", (void *) sp));
 	if (sp != 0) {
+#ifdef USE_PTHREADS
+	    PRESCREEN_LIST *p = typeCalloc(PRESCREEN_LIST, 1);
+	    if (p != 0) {
+		p->id = GetThreadID();
+		p->sp = sp;
+		p->next = _nc_prescreen.allocated;
+		_nc_prescreen.allocated = p;
+	    }
+#else
+	    _nc_prescreen.allocated = sp;
+#endif
 	    sp->rsp = sp->rippedoff;
 	    sp->_filtered = _nc_prescreen.filter_mode;
 	    sp->_use_env = _nc_prescreen.use_env;
@@ -831,7 +1160,10 @@
 	    sp->_ESCDELAY = _nc_prescreen._ESCDELAY;
 #endif
 	}
+    } else {
+	T(("_nc_alloc_screen_sp %p (reuse)", (void *) sp));
     }
+    _nc_unlock_global(screen);
     returnSP(sp);
 }
 #endif
@@ -842,17 +1174,26 @@
  * the same TERMINAL data (see comment).
  */
 NCURSES_EXPORT(int)
-_nc_setupterm(NCURSES_CONST char *tname,
+_nc_setupterm(const char *tname,
 	      int Filedes,
 	      int *errret,
 	      int reuse)
 {
-    int res;
+    int rc = ERR;
     TERMINAL *termp = 0;
-    res = TINFO_SETUP_TERM(&termp, tname, Filedes, errret, reuse);
-    if (ERR != res)
-	NCURSES_SP_NAME(set_curterm) (CURRENT_SCREEN_PRE, termp);
-    return res;
+
+    _nc_init_pthreads();
+    _nc_lock_global(prescreen);
+    START_TRACE();
+    if (TINFO_SETUP_TERM(&termp, tname, Filedes, errret, reuse) == OK) {
+	_nc_forget_prescr();
+	if (NCURSES_SP_NAME(set_curterm) (CURRENT_SCREEN_PRE, termp) != 0) {
+	    rc = OK;
+	}
+    }
+    _nc_unlock_global(prescreen);
+
+    return rc;
 }
 #endif
 
@@ -863,7 +1204,7 @@
  *	Make cur_term point to the structure.
  */
 NCURSES_EXPORT(int)
-setupterm(NCURSES_CONST char *tname, int Filedes, int *errret)
+setupterm(const char *tname, int Filedes, int *errret)
 {
     START_TRACE();
     return _nc_setupterm(tname, Filedes, errret, FALSE);
diff --git a/ncurses/tinfo/lib_termcap.c b/ncurses/tinfo/lib_termcap.c
index fdfc494..2ece985 100644
--- a/ncurses/tinfo/lib_termcap.c
+++ b/ncurses/tinfo/lib_termcap.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -48,7 +49,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_termcap.c,v 1.80 2013/06/08 16:48:47 tom Exp $")
+MODULE_ID("$Id: lib_termcap.c,v 1.89 2023/05/27 20:13:10 tom Exp $")
 
 NCURSES_EXPORT_VAR(char *) UP = 0;
 NCURSES_EXPORT_VAR(char *) BC = 0;
@@ -100,8 +101,7 @@
     START_TRACE();
     T((T_CALLED("tgetent()")));
 
-    TINFO_SETUP_TERM(&termp, (NCURSES_CONST char *) name,
-		     STDOUT_FILENO, &rc, TRUE);
+    TINFO_SETUP_TERM(&termp, name, STDOUT_FILENO, &rc, TRUE);
 
 #ifdef USE_TERM_DRIVER
     if (termp == 0 ||
@@ -153,8 +153,12 @@
 	}
 	CacheInx = best;
     }
-    LAST_TRM = TerminalOf(SP_PARM);
-    LAST_SEQ = ++CacheSeq;
+    if (rc == 1) {
+	LAST_TRM = TerminalOf(SP_PARM);
+	LAST_SEQ = ++CacheSeq;
+    } else {
+	LAST_TRM = 0;
+    }
 
     PC = 0;
     UP = 0;
@@ -175,7 +179,8 @@
 	if (backspace_if_not_bs != NULL)
 	    BC = backspace_if_not_bs;
 
-	if ((FIX_SGR0 = _nc_trim_sgr0(&(TerminalOf(SP_PARM)->type))) != 0) {
+	if ((FIX_SGR0 = _nc_trim_sgr0(&TerminalType(TerminalOf(SP_PARM))))
+	    != 0) {
 	    if (!strcmp(FIX_SGR0, exit_attribute_mode)) {
 		if (FIX_SGR0 != exit_attribute_mode) {
 		    free(FIX_SGR0);
@@ -230,15 +235,15 @@
  ***************************************************************************/
 
 NCURSES_EXPORT(int)
-NCURSES_SP_NAME(tgetflag) (NCURSES_SP_DCLx NCURSES_CONST char *id)
+NCURSES_SP_NAME(tgetflag) (NCURSES_SP_DCLx const char *id)
 {
     int result = 0;		/* Solaris returns zero for missing flag */
-    int j = -1;
 
     T((T_CALLED("tgetflag(%p, %s)"), (void *) SP_PARM, id));
     if (HasTInfoTerminal(SP_PARM) && ValidCap(id)) {
-	TERMTYPE *tp = &(TerminalOf(SP_PARM)->type);
+	TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM));
 	struct name_table_entry const *entry_ptr;
+	int j = -1;
 
 	entry_ptr = _nc_find_type_entry(id, BOOLEAN, TRUE);
 	if (entry_ptr != 0) {
@@ -266,7 +271,7 @@
 
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(int)
-tgetflag(NCURSES_CONST char *id)
+tgetflag(const char *id)
 {
     return NCURSES_SP_NAME(tgetflag) (CURRENT_SCREEN, id);
 }
@@ -282,15 +287,15 @@
  ***************************************************************************/
 
 NCURSES_EXPORT(int)
-NCURSES_SP_NAME(tgetnum) (NCURSES_SP_DCLx NCURSES_CONST char *id)
+NCURSES_SP_NAME(tgetnum) (NCURSES_SP_DCLx const char *id)
 {
     int result = ABSENT_NUMERIC;
-    int j = -1;
 
     T((T_CALLED("tgetnum(%p, %s)"), (void *) SP_PARM, id));
     if (HasTInfoTerminal(SP_PARM) && ValidCap(id)) {
-	TERMTYPE *tp = &(TerminalOf(SP_PARM)->type);
+	TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM));
 	struct name_table_entry const *entry_ptr;
+	int j = -1;
 
 	entry_ptr = _nc_find_type_entry(id, NUMBER, TRUE);
 	if (entry_ptr != 0) {
@@ -318,7 +323,7 @@
 
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(int)
-tgetnum(NCURSES_CONST char *id)
+tgetnum(const char *id)
 {
     return NCURSES_SP_NAME(tgetnum) (CURRENT_SCREEN, id);
 }
@@ -334,15 +339,15 @@
  ***************************************************************************/
 
 NCURSES_EXPORT(char *)
-NCURSES_SP_NAME(tgetstr) (NCURSES_SP_DCLx NCURSES_CONST char *id, char **area)
+NCURSES_SP_NAME(tgetstr) (NCURSES_SP_DCLx const char *id, char **area)
 {
     char *result = NULL;
-    int j = -1;
 
     T((T_CALLED("tgetstr(%s,%p)"), id, (void *) area));
     if (HasTInfoTerminal(SP_PARM) && ValidCap(id)) {
-	TERMTYPE *tp = &(TerminalOf(SP_PARM)->type);
+	TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM));
 	struct name_table_entry const *entry_ptr;
+	int j = -1;
 
 	entry_ptr = _nc_find_type_entry(id, STRING, TRUE);
 	if (entry_ptr != 0) {
@@ -384,20 +389,41 @@
 
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(char *)
-tgetstr(NCURSES_CONST char *id, char **area)
+tgetstr(const char *id, char **area)
 {
     return NCURSES_SP_NAME(tgetstr) (CURRENT_SCREEN, id, area);
 }
 #endif
 
 #if NO_LEAKS
+#undef CacheInx
+#define CacheInx num
+NCURSES_EXPORT(void)
+_nc_tgetent_leak(const TERMINAL *const termp)
+{
+    if (termp != 0) {
+	int num;
+	for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) {
+	    if (LAST_TRM == termp) {
+		FreeAndNull(FIX_SGR0);
+		if (LAST_TRM != 0) {
+		    LAST_TRM = 0;
+		}
+		break;
+	    }
+	}
+    }
+}
+
 NCURSES_EXPORT(void)
 _nc_tgetent_leaks(void)
 {
+    int num;
     for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) {
-	FreeIfNeeded(FIX_SGR0);
-	if (LAST_TRM != 0)
+	if (LAST_TRM != 0) {
 	    del_curterm(LAST_TRM);
+	    _nc_tgetent_leak(LAST_TRM);
+	}
     }
 }
 #endif
diff --git a/ncurses/tinfo/lib_termname.c b/ncurses/tinfo/lib_termname.c
index e3f6827..2d80bb3 100644
--- a/ncurses/tinfo/lib_termname.c
+++ b/ncurses/tinfo/lib_termname.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2003,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2003,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -28,7 +29,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_termname.c,v 1.12 2009/10/24 21:56:58 tom Exp $")
+MODULE_ID("$Id: lib_termname.c,v 1.13 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(char *)
 NCURSES_SP_NAME(termname) (NCURSES_SP_DCL0)
diff --git a/ncurses/tinfo/lib_tgoto.c b/ncurses/tinfo/lib_tgoto.c
index 31daf44..58b561f 100644
--- a/ncurses/tinfo/lib_tgoto.c
+++ b/ncurses/tinfo/lib_tgoto.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2000-2008,2012 Free Software Foundation, Inc.              *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
+ * Copyright 2000-2008,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -35,7 +36,7 @@
 #include <ctype.h>
 #include <termcap.h>
 
-MODULE_ID("$Id: lib_tgoto.c,v 1.16 2012/02/24 02:08:08 tom Exp $")
+MODULE_ID("$Id: lib_tgoto.c,v 1.23 2023/04/16 17:19:40 tom Exp $")
 
 #if !PURE_TERMINFO
 static bool
@@ -125,7 +126,14 @@
 			*value += 1;
 			need_BC = TRUE;
 		    } else {
-			*value = 0200;	/* tputs will treat this as \0 */
+			/* tputs will pretend this is \0, which will almost
+			 * always work since ANSI-compatible terminals ignore
+			 * the character.  ECMA-48 does not document a C1
+			 * control for this value.  A few (obsolete) terminals
+			 * can use this value in special cases, such as cursor
+			 * addressing using single-byte coordinates.
+			 */
+			*value = 0200;
 		    }
 		}
 		result[used++] = (char) *value++;
@@ -199,6 +207,16 @@
 	result = tgoto_internal(string, x, y);
     else
 #endif
-	result = TPARM_2((NCURSES_CONST char *) string, y, x);
+    if ((result = TIPARM_2(string, y, x)) == NULL) {
+	/*
+	 * Because termcap did not provide a more general solution such as
+	 * tparm(), it was necessary to handle single-parameter capabilities
+	 * using tgoto().  The internal _nc_tiparm() function returns a NULL
+	 * for that case; retry for the single-parameter case.
+	 */
+	if ((result = TIPARM_1(string, y)) == NULL) {
+	    result = TIPARM_0(string);
+	}
+    }
     returnPtr(result);
 }
diff --git a/ncurses/tinfo/lib_ti.c b/ncurses/tinfo/lib_ti.c
index e9ae746..5cb77b8 100644
--- a/ncurses/tinfo/lib_ti.c
+++ b/ncurses/tinfo/lib_ti.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -36,7 +37,7 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: lib_ti.c,v 1.30 2013/06/08 16:55:05 tom Exp $")
+MODULE_ID("$Id: lib_ti.c,v 1.34 2020/02/02 23:34:34 tom Exp $")
 
 #if 0
 static bool
@@ -50,16 +51,16 @@
 #endif
 
 NCURSES_EXPORT(int)
-NCURSES_SP_NAME(tigetflag) (NCURSES_SP_DCLx NCURSES_CONST char *str)
+NCURSES_SP_NAME(tigetflag) (NCURSES_SP_DCLx const char *str)
 {
     int result = ABSENT_BOOLEAN;
-    int j = -1;
 
     T((T_CALLED("tigetflag(%p, %s)"), (void *) SP_PARM, str));
 
     if (HasTInfoTerminal(SP_PARM)) {
-	TERMTYPE *tp = &(TerminalOf(SP_PARM)->type);
+	TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM));
 	struct name_table_entry const *entry_ptr;
+	int j = -1;
 
 	entry_ptr = _nc_find_type_entry(str, BOOLEAN, FALSE);
 	if (entry_ptr != 0) {
@@ -88,23 +89,23 @@
 
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(int)
-tigetflag(NCURSES_CONST char *str)
+tigetflag(const char *str)
 {
     return NCURSES_SP_NAME(tigetflag) (CURRENT_SCREEN, str);
 }
 #endif
 
 NCURSES_EXPORT(int)
-NCURSES_SP_NAME(tigetnum) (NCURSES_SP_DCLx NCURSES_CONST char *str)
+NCURSES_SP_NAME(tigetnum) (NCURSES_SP_DCLx const char *str)
 {
-    int j = -1;
     int result = CANCELLED_NUMERIC;	/* Solaris returns a -1 on error */
 
     T((T_CALLED("tigetnum(%p, %s)"), (void *) SP_PARM, str));
 
     if (HasTInfoTerminal(SP_PARM)) {
-	TERMTYPE *tp = &(TerminalOf(SP_PARM)->type);
+	TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM));
 	struct name_table_entry const *entry_ptr;
+	int j = -1;
 
 	entry_ptr = _nc_find_type_entry(str, NUMBER, FALSE);
 	if (entry_ptr != 0) {
@@ -135,23 +136,23 @@
 
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(int)
-tigetnum(NCURSES_CONST char *str)
+tigetnum(const char *str)
 {
     return NCURSES_SP_NAME(tigetnum) (CURRENT_SCREEN, str);
 }
 #endif
 
 NCURSES_EXPORT(char *)
-NCURSES_SP_NAME(tigetstr) (NCURSES_SP_DCLx NCURSES_CONST char *str)
+NCURSES_SP_NAME(tigetstr) (NCURSES_SP_DCLx const char *str)
 {
     char *result = CANCELLED_STRING;
-    int j = -1;
 
     T((T_CALLED("tigetstr(%p, %s)"), (void *) SP_PARM, str));
 
     if (HasTInfoTerminal(SP_PARM)) {
-	TERMTYPE *tp = &(TerminalOf(SP_PARM)->type);
+	TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM));
 	struct name_table_entry const *entry_ptr;
+	int j = -1;
 
 	entry_ptr = _nc_find_type_entry(str, STRING, FALSE);
 	if (entry_ptr != 0) {
@@ -180,7 +181,7 @@
 
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(char *)
-tigetstr(NCURSES_CONST char *str)
+tigetstr(const char *str)
 {
     return NCURSES_SP_NAME(tigetstr) (CURRENT_SCREEN, str);
 }
diff --git a/ncurses/tinfo/lib_tparm.c b/ncurses/tinfo/lib_tparm.c
index 4f18859..5666b27 100644
--- a/ncurses/tinfo/lib_tparm.c
+++ b/ncurses/tinfo/lib_tparm.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -37,12 +38,22 @@
  *
  */
 
+#define entry _ncu_entry
+#define ENTRY _ncu_ENTRY
+
 #include <curses.priv.h>
 
+#undef entry
+#undef ENTRY
+
+#if HAVE_TSEARCH
+#include <search.h>
+#endif
+
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: lib_tparm.c,v 1.94 2015/07/17 01:03:35 tom Exp $")
+MODULE_ID("$Id: lib_tparm.c,v 1.153 2023/11/04 19:28:41 tom Exp $")
 
 /*
  *	char *
@@ -106,128 +117,245 @@
 
 NCURSES_EXPORT_VAR(int) _nc_tparm_err = 0;
 
-#define TPS(var) _nc_prescreen.tparm_state.var
+#define TPS(var) tps->var
 #define popcount _nc_popcount	/* workaround for NetBSD 6.0 defect */
 
-#if NO_LEAKS
-NCURSES_EXPORT(void)
-_nc_free_tparm(void)
+#define get_tparm_state(term) \
+	    (term != NULL \
+	      ? &(term->tparm_state) \
+	      : &(_nc_prescreen.tparm_state))
+
+#define isUPPER(c) ((c) >= 'A' && (c) <= 'Z')
+#define isLOWER(c) ((c) >= 'a' && (c) <= 'z')
+#define tc_BUMP()  if (level < 0 && number < 2) number++
+
+typedef struct {
+    const char *format;		/* format-string can be used as cache-key */
+    int tparm_type;		/* bit-set for each string-parameter */
+    int num_actual;
+    int num_parsed;
+    int num_popped;
+    TPARM_ARG param[NUM_PARM];
+    char *p_is_s[NUM_PARM];
+} TPARM_DATA;
+
+#if HAVE_TSEARCH
+#define MyCache _nc_globals.cached_tparm
+#define MyCount _nc_globals.count_tparm
+static int which_tparm;
+static TPARM_DATA **delete_tparm;
+#endif /* HAVE_TSEARCH */
+
+static char dummy[] = "";	/* avoid const-cast */
+
+#if HAVE_TSEARCH
+static int
+cmp_format(const void *p, const void *q)
 {
-    if (TPS(out_buff) != 0) {
-	FreeAndNull(TPS(out_buff));
-	TPS(out_size) = 0;
-	TPS(out_used) = 0;
-	FreeAndNull(TPS(fmt_buff));
-	TPS(fmt_size) = 0;
+    const char *a = *(char *const *) p;
+    const char *b = *(char *const *) q;
+    return strcmp(a, b);
+}
+#endif
+
+#if HAVE_TSEARCH
+static void
+visit_nodes(const void *nodep, VISIT which, int depth)
+{
+    (void) depth;
+    if (which == preorder || which == leaf) {
+	delete_tparm[which_tparm] = *(TPARM_DATA **) nodep;
+	which_tparm++;
     }
 }
 #endif
 
-static NCURSES_INLINE void
-get_space(size_t need)
+NCURSES_EXPORT(void)
+_nc_free_tparm(TERMINAL *termp)
 {
-    need += TPS(out_used);
-    if (need > TPS(out_size)) {
-	TPS(out_size) = need * 2;
-	TYPE_REALLOC(char, TPS(out_size), TPS(out_buff));
+    TPARM_STATE *tps = get_tparm_state(termp);
+#if HAVE_TSEARCH
+    if (MyCount != 0) {
+	delete_tparm = typeCalloc(TPARM_DATA *, MyCount);
+	if (delete_tparm != NULL) {
+	    which_tparm = 0;
+	    twalk(MyCache, visit_nodes);
+	    for (which_tparm = 0; which_tparm < MyCount; ++which_tparm) {
+		TPARM_DATA *ptr = delete_tparm[which_tparm];
+		if (ptr != NULL) {
+		    tdelete(ptr, &MyCache, cmp_format);
+		    free((char *) ptr->format);
+		    free(ptr);
+		}
+	    }
+	    which_tparm = 0;
+	    twalk(MyCache, visit_nodes);
+	    FreeAndNull(delete_tparm);
+	}
+	MyCount = 0;
+	which_tparm = 0;
     }
+#endif
+    FreeAndNull(TPS(out_buff));
+    TPS(out_size) = 0;
+    TPS(out_used) = 0;
+
+    FreeAndNull(TPS(fmt_buff));
+    TPS(fmt_size) = 0;
 }
 
-static NCURSES_INLINE void
-save_text(const char *fmt, const char *s, int len)
+static int
+tparm_error(TPARM_STATE *tps, const char *message)
 {
-    size_t s_len = strlen(s);
-    if (len > (int) s_len)
-	s_len = (size_t) len;
-
-    get_space(s_len + 1);
-
-    _nc_SPRINTF(TPS(out_buff) + TPS(out_used),
-		_nc_SLIMIT(TPS(out_size) - TPS(out_used))
-		fmt, s);
-    TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used));
+    (void) tps;
+    (void) message;
+    DEBUG(2, ("%s: %s", message, _nc_visbuf(TPS(tparam_base))));
+    return ++_nc_tparm_err;
 }
 
+#define get_space(tps, need) \
+{ \
+    size_t need2get = need + TPS(out_used); \
+    if (need2get > TPS(out_size)) { \
+	TPS(out_size) = need2get * 2; \
+	TYPE_REALLOC(char, TPS(out_size), TPS(out_buff)); \
+    } \
+}
+
+#if NCURSES_EXPANDED
 static NCURSES_INLINE void
-save_number(const char *fmt, int number, int len)
-{
-    if (len < 30)
-	len = 30;		/* actually log10(MAX_INT)+1 */
-
-    get_space((size_t) len + 1);
-
-    _nc_SPRINTF(TPS(out_buff) + TPS(out_used),
-		_nc_SLIMIT(TPS(out_size) - TPS(out_used))
-		fmt, number);
-    TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used));
+  (get_space) (TPARM_STATE *tps, size_t need) {
+    get_space(tps, need);
 }
 
+#undef get_space
+#endif
+
+#define save_text(tps, fmt, s, len) \
+{ \
+    size_t s_len = (size_t) len + strlen(s) + strlen(fmt); \
+    get_space(tps, s_len + 1); \
+    _nc_SPRINTF(TPS(out_buff) + TPS(out_used), \
+		_nc_SLIMIT(TPS(out_size) - TPS(out_used)) \
+		fmt, s); \
+    TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used)); \
+}
+
+#if NCURSES_EXPANDED
 static NCURSES_INLINE void
-save_char(int c)
-{
-    if (c == 0)
-	c = 0200;
-    get_space((size_t) 1);
-    TPS(out_buff)[TPS(out_used)++] = (char) c;
+  (save_text) (TPARM_STATE *tps, const char *fmt, const char *s, int len) {
+    save_text(tps, fmt, s, len);
 }
 
+#undef save_text
+#endif
+
+#define save_number(tps, fmt, number, len) \
+{ \
+    size_t s_len = (size_t) len + 30 + strlen(fmt); \
+    get_space(tps, s_len + 1); \
+    _nc_SPRINTF(TPS(out_buff) + TPS(out_used), \
+		_nc_SLIMIT(TPS(out_size) - TPS(out_used)) \
+		fmt, number); \
+    TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used)); \
+}
+
+#if NCURSES_EXPANDED
 static NCURSES_INLINE void
-npush(int x)
-{
-    if (TPS(stack_ptr) < STACKSIZE) {
-	TPS(stack)[TPS(stack_ptr)].num_type = TRUE;
-	TPS(stack)[TPS(stack_ptr)].data.num = x;
-	TPS(stack_ptr)++;
-    } else {
-	DEBUG(2, ("npush: stack overflow: %s", _nc_visbuf(TPS(tparam_base))));
-	_nc_tparm_err++;
-    }
+  (save_number) (TPARM_STATE *tps, const char *fmt, int number, int len) {
+    save_number(tps, fmt, number, len);
 }
 
+#undef save_number
+#endif
+
+#define save_char(tps, c) \
+{ \
+    get_space(tps, (size_t) 1); \
+    TPS(out_buff)[TPS(out_used)++] = (char) ((c == 0) ? 0200 : c); \
+}
+
+#if NCURSES_EXPANDED
+static NCURSES_INLINE void
+  (save_char) (TPARM_STATE *tps, int c) {
+    save_char(tps, c);
+}
+
+#undef save_char
+#endif
+
+#define npush(tps, x) \
+{ \
+    if (TPS(stack_ptr) < STACKSIZE) { \
+	TPS(stack)[TPS(stack_ptr)].num_type = TRUE; \
+	TPS(stack)[TPS(stack_ptr)].data.num = x; \
+	TPS(stack_ptr)++; \
+    } else { \
+	(void) tparm_error(tps, "npush: stack overflow"); \
+    } \
+}
+
+#if NCURSES_EXPANDED
+static NCURSES_INLINE void
+  (npush) (TPARM_STATE *tps, int x) {
+    npush(tps, x);
+}
+
+#undef npush
+#endif
+
+#define spush(tps, x) \
+{ \
+    if (TPS(stack_ptr) < STACKSIZE) { \
+	TPS(stack)[TPS(stack_ptr)].num_type = FALSE; \
+	TPS(stack)[TPS(stack_ptr)].data.str = x; \
+	TPS(stack_ptr)++; \
+    } else { \
+	(void) tparm_error(tps, "spush: stack overflow"); \
+    } \
+}
+
+#if NCURSES_EXPANDED
+static NCURSES_INLINE void
+  (spush) (TPARM_STATE *tps, char *x) {
+    spush(tps, x);
+}
+
+#undef spush
+#endif
+
+#define npop(tps) \
+    ((TPS(stack_ptr)-- > 0) \
+     ? ((TPS(stack)[TPS(stack_ptr)].num_type) \
+	 ? TPS(stack)[TPS(stack_ptr)].data.num \
+	 : 0) \
+     : (tparm_error(tps, "npop: stack underflow"), \
+        TPS(stack_ptr) = 0))
+
+#if NCURSES_EXPANDED
 static NCURSES_INLINE int
-npop(void)
-{
-    int result = 0;
-    if (TPS(stack_ptr) > 0) {
-	TPS(stack_ptr)--;
-	if (TPS(stack)[TPS(stack_ptr)].num_type)
-	    result = TPS(stack)[TPS(stack_ptr)].data.num;
-    } else {
-	DEBUG(2, ("npop: stack underflow: %s", _nc_visbuf(TPS(tparam_base))));
-	_nc_tparm_err++;
-    }
-    return result;
+  (npop) (TPARM_STATE *tps) {
+    return npop(tps);
 }
+#undef npop
+#endif
 
-static NCURSES_INLINE void
-spush(char *x)
-{
-    if (TPS(stack_ptr) < STACKSIZE) {
-	TPS(stack)[TPS(stack_ptr)].num_type = FALSE;
-	TPS(stack)[TPS(stack_ptr)].data.str = x;
-	TPS(stack_ptr)++;
-    } else {
-	DEBUG(2, ("spush: stack overflow: %s", _nc_visbuf(TPS(tparam_base))));
-	_nc_tparm_err++;
-    }
-}
+#define spop(tps) \
+    ((TPS(stack_ptr)-- > 0) \
+     ? ((!TPS(stack)[TPS(stack_ptr)].num_type \
+        && TPS(stack)[TPS(stack_ptr)].data.str != 0) \
+         ? TPS(stack)[TPS(stack_ptr)].data.str \
+         : dummy) \
+     : (tparm_error(tps, "spop: stack underflow"), \
+        dummy))
 
+#if NCURSES_EXPANDED
 static NCURSES_INLINE char *
-spop(void)
-{
-    static char dummy[] = "";	/* avoid const-cast */
-    char *result = dummy;
-    if (TPS(stack_ptr) > 0) {
-	TPS(stack_ptr)--;
-	if (!TPS(stack)[TPS(stack_ptr)].num_type
-	    && TPS(stack)[TPS(stack_ptr)].data.str != 0)
-	    result = TPS(stack)[TPS(stack_ptr)].data.str;
-    } else {
-	DEBUG(2, ("spop: stack underflow: %s", _nc_visbuf(TPS(tparam_base))));
-	_nc_tparm_err++;
-    }
-    return result;
+  (spop) (TPARM_STATE *tps) {
+    return spop(tps);
 }
+#undef spop
+#endif
 
 static NCURSES_INLINE const char *
 parse_format(const char *s, char *format, int *len)
@@ -324,9 +452,6 @@
     return s;
 }
 
-#define isUPPER(c) ((c) >= 'A' && (c) <= 'Z')
-#define isLOWER(c) ((c) >= 'a' && (c) <= 'z')
-
 /*
  * Analyze the string to see how many parameters we need from the varargs list,
  * and what their types are.  We will only accept string parameters if they
@@ -339,21 +464,22 @@
  * may be cases that we cannot see the explicit parameter numbers.
  */
 NCURSES_EXPORT(int)
-_nc_tparm_analyze(const char *string, char *p_is_s[NUM_PARM], int *popcount)
+_nc_tparm_analyze(TERMINAL *term, const char *string, char **p_is_s, int *popcount)
 {
+    TPARM_STATE *tps = get_tparm_state(term);
     size_t len2;
     int i;
     int lastpop = -1;
     int len;
     int number = 0;
+    int level = -1;
     const char *cp = string;
-    static char dummy[] = "";
 
     if (cp == 0)
 	return 0;
 
-    if ((len2 = strlen(cp)) > TPS(fmt_size)) {
-	TPS(fmt_size) = len2 + TPS(fmt_size) + 2;
+    if ((len2 = strlen(cp)) + 2 > TPS(fmt_size)) {
+	TPS(fmt_size) += len2 + 2;
 	TPS(fmt_buff) = typeRealloc(char, TPS(fmt_size), TPS(fmt_buff));
 	if (TPS(fmt_buff) == 0)
 	    return 0;
@@ -378,22 +504,27 @@
 #ifdef EXP_XTERM_1005
 	    case 'u':
 #endif
-		if (lastpop <= 0)
-		    number++;
+		if (lastpop <= 0) {
+		    tc_BUMP();
+		}
+		level -= 1;
 		lastpop = -1;
 		break;
 
 	    case 'l':
 	    case 's':
-		if (lastpop > 0)
+		if (lastpop > 0) {
+		    level -= 1;
 		    p_is_s[lastpop - 1] = dummy;
-		++number;
+		}
+		tc_BUMP();
 		break;
 
 	    case 'p':
 		cp++;
 		i = (UChar(*cp) - '0');
 		if (i >= 0 && i <= NUM_PARM) {
+		    ++level;
 		    lastpop = i;
 		    if (lastpop > *popcount)
 			*popcount = lastpop;
@@ -401,20 +532,22 @@
 		break;
 
 	    case 'P':
-		++number;
 		++cp;
 		break;
 
 	    case 'g':
+		++level;
 		cp++;
 		break;
 
 	    case S_QUOTE:
+		++level;
 		cp += 2;
 		lastpop = -1;
 		break;
 
 	    case L_BRACE:
+		++level;
 		cp++;
 		while (isdigit(UChar(*cp))) {
 		    cp++;
@@ -434,14 +567,15 @@
 	    case '=':
 	    case '<':
 	    case '>':
+		tc_BUMP();
+		level -= 1;	/* pop 2, operate, push 1 */
 		lastpop = -1;
-		number += 2;
 		break;
 
 	    case '!':
 	    case '~':
+		tc_BUMP();
 		lastpop = -1;
-		++number;
 		break;
 
 	    case 'i':
@@ -458,100 +592,220 @@
     return number;
 }
 
-static NCURSES_INLINE char *
-tparam_internal(int use_TPARM_ARG, const char *string, va_list ap)
+/*
+ * Analyze the capability string, finding the number of parameters and their
+ * types.
+ *
+ * TODO: cache the result so that this is done once per capability per term.
+ */
+static int
+tparm_setup(TERMINAL *term, const char *string, TPARM_DATA *result)
 {
-    char *p_is_s[NUM_PARM];
-    TPARM_ARG param[NUM_PARM];
-    int popcount = 0;
+    TPARM_STATE *tps = get_tparm_state(term);
+    int rc = OK;
+
+    TPS(out_used) = 0;
+    memset(result, 0, sizeof(*result));
+
+    if (!VALID_STRING(string)) {
+	TR(TRACE_CALLS, ("%s: format is invalid", TPS(tname)));
+	rc = ERR;
+    } else {
+#if HAVE_TSEARCH
+	TPARM_DATA *fs;
+	void *ft;
+
+	result->format = string;
+	if ((ft = tfind(result, &MyCache, cmp_format)) != 0) {
+	    size_t len2;
+	    fs = *(TPARM_DATA **) ft;
+	    *result = *fs;
+	    if ((len2 = strlen(string)) + 2 > TPS(fmt_size)) {
+		TPS(fmt_size) += len2 + 2;
+		TPS(fmt_buff) = typeRealloc(char, TPS(fmt_size), TPS(fmt_buff));
+		if (TPS(fmt_buff) == 0)
+		    return ERR;
+	    }
+	} else
+#endif
+	{
+	    /*
+	     * Find the highest parameter-number referred to in the format
+	     * string.  Use this value to limit the number of arguments copied
+	     * from the variable-length argument list.
+	     */
+	    result->num_parsed = _nc_tparm_analyze(term, string,
+						   result->p_is_s,
+						   &(result->num_popped));
+	    if (TPS(fmt_buff) == 0) {
+		TR(TRACE_CALLS, ("%s: error in analysis", TPS(tname)));
+		rc = ERR;
+	    } else {
+		int n;
+
+		if (result->num_parsed > NUM_PARM)
+		    result->num_parsed = NUM_PARM;
+		if (result->num_popped > NUM_PARM)
+		    result->num_popped = NUM_PARM;
+		result->num_actual = Max(result->num_popped, result->num_parsed);
+
+		for (n = 0; n < result->num_actual; ++n) {
+		    if (result->p_is_s[n])
+			result->tparm_type |= (1 << n);
+		}
+#if HAVE_TSEARCH
+		if ((fs = typeCalloc(TPARM_DATA, 1)) != 0) {
+		    *fs = *result;
+		    if ((fs->format = strdup(string)) != 0) {
+			if (tsearch(fs, &MyCache, cmp_format) != 0) {
+			    ++MyCount;
+			} else {
+			    free(fs);
+			    rc = ERR;
+			}
+		    } else {
+			free(fs);
+			rc = ERR;
+		    }
+		} else {
+		    rc = ERR;
+		}
+#endif
+	    }
+	}
+    }
+
+    return rc;
+}
+
+/*
+ * A few caps (such as plab_norm) have string-valued parms.  We'll have to
+ * assume that the caller knows the difference, since a char* and an int may
+ * not be the same size on the stack.  The normal prototype for tparm uses 9
+ * long's, which is consistent with our va_arg() usage.
+ */
+static void
+tparm_copy_valist(TPARM_DATA *data, int use_TPARM_ARG, va_list ap)
+{
+    int i;
+
+    for (i = 0; i < data->num_actual; i++) {
+	if (data->p_is_s[i] != 0) {
+	    char *value = va_arg(ap, char *);
+	    if (value == 0)
+		value = dummy;
+	    data->p_is_s[i] = value;
+	    data->param[i] = 0;
+	} else if (use_TPARM_ARG) {
+	    data->param[i] = va_arg(ap, TPARM_ARG);
+	} else {
+	    data->param[i] = (TPARM_ARG) va_arg(ap, int);
+	}
+    }
+}
+
+/*
+ * This is a termcap compatibility hack.  If there are no explicit pop
+ * operations in the string, load the stack in such a way that successive pops
+ * will grab successive parameters.  That will make the expansion of (for
+ * example) \E[%d;%dH work correctly in termcap style, which means tparam()
+ * will expand termcap strings OK.
+ */
+static bool
+tparm_tc_compat(TPARM_STATE *tps, TPARM_DATA *data)
+{
+    bool termcap_hack = FALSE;
+
+    TPS(stack_ptr) = 0;
+
+    if (data->num_popped == 0) {
+	int i;
+
+	termcap_hack = TRUE;
+	for (i = data->num_parsed - 1; i >= 0; i--) {
+	    if (data->p_is_s[i]) {
+		spush(tps, data->p_is_s[i]);
+	    } else {
+		npush(tps, (int) data->param[i]);
+	    }
+	}
+    }
+    return termcap_hack;
+}
+
+#ifdef TRACE
+static void
+tparm_trace_call(TPARM_STATE *tps, const char *string, TPARM_DATA *data)
+{
+    if (USE_TRACEF(TRACE_CALLS)) {
+	int i;
+	for (i = 0; i < data->num_actual; i++) {
+	    if (data->p_is_s[i] != 0) {
+		save_text(tps, ", %s", _nc_visbuf(data->p_is_s[i]), 0);
+	    } else if ((long) data->param[i] > MAX_OF_TYPE(NCURSES_INT2) ||
+		       (long) data->param[i] < 0) {
+		_tracef("BUG: problem with tparm parameter #%d of %d",
+			i + 1, data->num_actual);
+		break;
+	    } else {
+		save_number(tps, ", %d", (int) data->param[i], 0);
+	    }
+	}
+	_tracef(T_CALLED("%s(%s%s)"), TPS(tname), _nc_visbuf(string), TPS(out_buff));
+	TPS(out_used) = 0;
+	_nc_unlock_global(tracef);
+    }
+}
+
+#else
+#define tparm_trace_call(tps, string, data)	/* nothing */
+#endif /* TRACE */
+
+#define init_vars(name) \
+	if (!name##_used) { \
+	    name##_used = TRUE; \
+	    memset(name##_vars, 0, sizeof(name##_vars)); \
+	}
+
+static NCURSES_INLINE char *
+tparam_internal(TPARM_STATE *tps, const char *string, TPARM_DATA *data)
+{
     int number;
-    int num_args;
     int len;
     int level;
     int x, y;
     int i;
+    const char *s;
     const char *cp = string;
-    size_t len2;
-    bool termcap_hack;
-    bool incremented_two;
-
-    if (cp == NULL)
-	return NULL;
-
-    TPS(out_used) = 0;
-    len2 = strlen(cp);
-
+    size_t len2 = strlen(cp);
+    bool incremented_two = FALSE;
+    bool termcap_hack = tparm_tc_compat(tps, data);
     /*
-     * Find the highest parameter-number referred to in the format string.
-     * Use this value to limit the number of arguments copied from the
-     * variable-length argument list.
+     * SVr4 curses stores variables 'A' to 'Z' in the TERMINAL structure (so
+     * they are initialized once to zero), and variables 'a' to 'z' on the
+     * stack in tparm, referring to the former as "static" and the latter as
+     * "dynamic".  However, it makes no check to ensure that the "dynamic"
+     * variables are initialized.
+     *
+     * Solaris xpg4 curses makes no distinction between the upper/lower, and
+     * stores the common set of 26 variables on the stack, without initializing
+     * them.
+     *
+     * In ncurses, both sets of variables are initialized on the first use.
      */
-    number = _nc_tparm_analyze(cp, p_is_s, &popcount);
-    if (TPS(fmt_buff) == 0)
+    bool dynamic_used = FALSE;
+    int dynamic_vars[NUM_VARS];
+
+    tparm_trace_call(tps, string, data);
+
+    if (TPS(fmt_buff) == NULL) {
+	T((T_RETURN("<null>")));
 	return NULL;
-
-    incremented_two = FALSE;
-
-    if (number > NUM_PARM)
-	number = NUM_PARM;
-    if (popcount > NUM_PARM)
-	popcount = NUM_PARM;
-    num_args = max(popcount, number);
-
-    for (i = 0; i < num_args; i++) {
-	/*
-	 * A few caps (such as plab_norm) have string-valued parms.
-	 * We'll have to assume that the caller knows the difference, since
-	 * a char* and an int may not be the same size on the stack.  The
-	 * normal prototype for this uses 9 long's, which is consistent with
-	 * our va_arg() usage.
-	 */
-	if (p_is_s[i] != 0) {
-	    p_is_s[i] = va_arg(ap, char *);
-	    param[i] = 0;
-	} else if (use_TPARM_ARG) {
-	    param[i] = va_arg(ap, TPARM_ARG);
-	} else {
-	    param[i] = (TPARM_ARG) va_arg(ap, int);
-	}
     }
 
-    /*
-     * This is a termcap compatibility hack.  If there are no explicit pop
-     * operations in the string, load the stack in such a way that
-     * successive pops will grab successive parameters.  That will make
-     * the expansion of (for example) \E[%d;%dH work correctly in termcap
-     * style, which means tparam() will expand termcap strings OK.
-     */
-    TPS(stack_ptr) = 0;
-    termcap_hack = FALSE;
-    if (popcount == 0) {
-	termcap_hack = TRUE;
-	popcount = number;
-	for (i = number - 1; i >= 0; i--) {
-	    if (p_is_s[i])
-		spush(p_is_s[i]);
-	    else
-		npush((int) param[i]);
-	}
-    }
-#ifdef TRACE
-    if (USE_TRACEF(TRACE_CALLS)) {
-	for (i = 0; i < num_args; i++) {
-	    if (p_is_s[i] != 0)
-		save_text(", %s", _nc_visbuf(p_is_s[i]), 0);
-	    else
-		save_number(", %d", (int) param[i], 0);
-	}
-	_tracef(T_CALLED("%s(%s%s)"), TPS(tname), _nc_visbuf(cp), TPS(out_buff));
-	TPS(out_used) = 0;
-	_nc_unlock_global(tracef);
-    }
-#endif /* TRACE */
-
     while ((cp - string) < (int) len2) {
 	if (*cp != '%') {
-	    save_char(UChar(*cp));
+	    save_char(tps, UChar(*cp));
 	} else {
 	    TPS(tparam_base) = cp++;
 	    cp = parse_format(cp, TPS(fmt_buff), &len);
@@ -559,50 +813,54 @@
 	    default:
 		break;
 	    case '%':
-		save_char('%');
+		save_char(tps, '%');
 		break;
 
 	    case 'd':		/* FALLTHRU */
 	    case 'o':		/* FALLTHRU */
 	    case 'x':		/* FALLTHRU */
 	    case 'X':		/* FALLTHRU */
-		save_number(TPS(fmt_buff), npop(), len);
+		x = npop(tps);
+		save_number(tps, TPS(fmt_buff), x, len);
 		break;
 
 	    case 'c':		/* FALLTHRU */
-		save_char(npop());
+		x = npop(tps);
+		save_char(tps, x);
 		break;
 
 #ifdef EXP_XTERM_1005
 	    case 'u':
 		{
 		    unsigned char target[10];
-		    unsigned source = (unsigned) npop();
+		    unsigned source = (unsigned) npop(tps);
 		    int rc = _nc_conv_to_utf8(target, source, (unsigned)
 					      sizeof(target));
 		    int n;
 		    for (n = 0; n < rc; ++n) {
-			save_char(target[n]);
+			save_char(tps, target[n]);
 		    }
 		}
 		break;
 #endif
 	    case 'l':
-		npush((int) strlen(spop()));
+		s = spop(tps);
+		npush(tps, (int) strlen(s));
 		break;
 
 	    case 's':
-		save_text(TPS(fmt_buff), spop(), len);
+		s = spop(tps);
+		save_text(tps, TPS(fmt_buff), s, len);
 		break;
 
 	    case 'p':
 		cp++;
 		i = (UChar(*cp) - '1');
 		if (i >= 0 && i < NUM_PARM) {
-		    if (p_is_s[i]) {
-			spush(p_is_s[i]);
+		    if (data->p_is_s[i]) {
+			spush(tps, data->p_is_s[i]);
 		    } else {
-			npush((int) param[i]);
+			npush(tps, (int) data->param[i]);
 		    }
 		}
 		break;
@@ -611,10 +869,11 @@
 		cp++;
 		if (isUPPER(*cp)) {
 		    i = (UChar(*cp) - 'A');
-		    TPS(static_vars)[i] = npop();
+		    TPS(static_vars)[i] = npop(tps);
 		} else if (isLOWER(*cp)) {
 		    i = (UChar(*cp) - 'a');
-		    TPS(dynamic_var)[i] = npop();
+		    init_vars(dynamic);
+		    dynamic_vars[i] = npop(tps);
 		}
 		break;
 
@@ -622,16 +881,17 @@
 		cp++;
 		if (isUPPER(*cp)) {
 		    i = (UChar(*cp) - 'A');
-		    npush(TPS(static_vars)[i]);
+		    npush(tps, TPS(static_vars)[i]);
 		} else if (isLOWER(*cp)) {
 		    i = (UChar(*cp) - 'a');
-		    npush(TPS(dynamic_var)[i]);
+		    init_vars(dynamic);
+		    npush(tps, dynamic_vars[i]);
 		}
 		break;
 
 	    case S_QUOTE:
 		cp++;
-		npush(UChar(*cp));
+		npush(tps, UChar(*cp));
 		cp++;
 		break;
 
@@ -642,83 +902,95 @@
 		    number = (number * 10) + (UChar(*cp) - '0');
 		    cp++;
 		}
-		npush(number);
+		npush(tps, number);
 		break;
 
 	    case '+':
-		npush(npop() + npop());
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x + y);
 		break;
 
 	    case '-':
-		y = npop();
-		x = npop();
-		npush(x - y);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x - y);
 		break;
 
 	    case '*':
-		npush(npop() * npop());
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x * y);
 		break;
 
 	    case '/':
-		y = npop();
-		x = npop();
-		npush(y ? (x / y) : 0);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, y ? (x / y) : 0);
 		break;
 
 	    case 'm':
-		y = npop();
-		x = npop();
-		npush(y ? (x % y) : 0);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, y ? (x % y) : 0);
 		break;
 
 	    case 'A':
-		y = npop();
-		x = npop();
-		npush(y && x);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, y && x);
 		break;
 
 	    case 'O':
-		y = npop();
-		x = npop();
-		npush(y || x);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, y || x);
 		break;
 
 	    case '&':
-		npush(npop() & npop());
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x & y);
 		break;
 
 	    case '|':
-		npush(npop() | npop());
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x | y);
 		break;
 
 	    case '^':
-		npush(npop() ^ npop());
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x ^ y);
 		break;
 
 	    case '=':
-		y = npop();
-		x = npop();
-		npush(x == y);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x == y);
 		break;
 
 	    case '<':
-		y = npop();
-		x = npop();
-		npush(x < y);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x < y);
 		break;
 
 	    case '>':
-		y = npop();
-		x = npop();
-		npush(x > y);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x > y);
 		break;
 
 	    case '!':
-		npush(!npop());
+		x = npop(tps);
+		npush(tps, !x);
 		break;
 
 	    case '~':
-		npush(~npop());
+		x = npop(tps);
+		npush(tps, ~x);
 		break;
 
 	    case 'i':
@@ -731,15 +1003,15 @@
 		 */
 		if (!incremented_two) {
 		    incremented_two = TRUE;
-		    if (p_is_s[0] == 0) {
-			param[0]++;
+		    if (data->p_is_s[0] == 0) {
+			data->param[0]++;
 			if (termcap_hack)
-			    TPS(stack)[0].data.num = (int) param[0];
+			    TPS(stack)[0].data.num = (int) data->param[0];
 		    }
-		    if (p_is_s[1] == 0) {
-			param[1]++;
+		    if (data->p_is_s[1] == 0) {
+			data->param[1]++;
 			if (termcap_hack)
-			    TPS(stack)[1].data.num = (int) param[1];
+			    TPS(stack)[1].data.num = (int) data->param[1];
 		    }
 		}
 		break;
@@ -748,7 +1020,7 @@
 		break;
 
 	    case 't':
-		x = npop();
+		x = npop(tps);
 		if (!x) {
 		    /* scan forward for %e or %; at level zero */
 		    cp++;
@@ -807,64 +1079,330 @@
 	cp++;
     }				/* endwhile (*cp) */
 
-    get_space((size_t) 1);
+    get_space(tps, (size_t) 1);
     TPS(out_buff)[TPS(out_used)] = '\0';
 
+    if (TPS(stack_ptr) && !_nc_tparm_err) {
+	DEBUG(2, ("tparm: stack has %d item%s on return",
+		  TPS(stack_ptr),
+		  TPS(stack_ptr) == 1 ? "" : "s"));
+	_nc_tparm_err++;
+    }
+
     T((T_RETURN("%s"), _nc_visbuf(TPS(out_buff))));
     return (TPS(out_buff));
 }
 
-#if NCURSES_TPARM_VARARGS
-#define tparm_varargs tparm
-#else
-#define tparm_proto tparm
+#ifdef CUR
+/*
+ * Only a few standard capabilities accept string parameters.  The others that
+ * are parameterized accept only numeric parameters.
+ */
+static bool
+check_string_caps(TPARM_DATA *data, const char *string)
+{
+    bool result = FALSE;
+
+#define CHECK_CAP(name) (VALID_STRING(name) && !strcmp(name, string))
+
+    /*
+     * Disallow string parameters unless we can check them against a terminal
+     * description.
+     */
+    if (cur_term != NULL) {
+	int want_type = 0;
+
+	if (CHECK_CAP(pkey_key))
+	    want_type = 2;	/* function key #1, type string #2 */
+	else if (CHECK_CAP(pkey_local))
+	    want_type = 2;	/* function key #1, execute string #2 */
+	else if (CHECK_CAP(pkey_xmit))
+	    want_type = 2;	/* function key #1, transmit string #2 */
+	else if (CHECK_CAP(plab_norm))
+	    want_type = 2;	/* label #1, show string #2 */
+#ifdef pkey_plab
+	else if (CHECK_CAP(pkey_plab))
+	    want_type = 6;	/* function key #1, type string #2, show string #3 */
+#endif
+#if NCURSES_XNAMES
+	else {
+	    char *check;
+
+	    check = tigetstr("Cs");
+	    if (CHECK_CAP(check))
+		want_type = 1;	/* style #1 */
+
+	    check = tigetstr("Ms");
+	    if (CHECK_CAP(check))
+		want_type = 3;	/* storage unit #1, content #2 */
+	}
 #endif
 
-NCURSES_EXPORT(char *)
-tparm_varargs(NCURSES_CONST char *string,...)
-{
-    va_list ap;
-    char *result;
-
-    _nc_tparm_err = 0;
-    va_start(ap, string);
-#ifdef TRACE
-    TPS(tname) = "tparm";
-#endif /* TRACE */
-    result = tparam_internal(TRUE, string, ap);
-    va_end(ap);
+	if (want_type == data->tparm_type) {
+	    result = TRUE;
+	} else {
+	    T(("unexpected string-parameter"));
+	}
+    }
     return result;
 }
 
-#if !NCURSES_TPARM_VARARGS
+#define ValidCap(allow_strings) (myData.tparm_type == 0 || \
+				 (allow_strings && \
+				  check_string_caps(&myData, string)))
+#else
+#define ValidCap(allow_strings) 1
+#endif
+
+#if NCURSES_TPARM_VARARGS
+
 NCURSES_EXPORT(char *)
-tparm_proto(NCURSES_CONST char *string,
-	    TPARM_ARG a1,
-	    TPARM_ARG a2,
-	    TPARM_ARG a3,
-	    TPARM_ARG a4,
-	    TPARM_ARG a5,
-	    TPARM_ARG a6,
-	    TPARM_ARG a7,
-	    TPARM_ARG a8,
-	    TPARM_ARG a9)
+tparm(const char *string, ...)
 {
-    return tparm_varargs(string, a1, a2, a3, a4, a5, a6, a7, a8, a9);
+    TPARM_STATE *tps = get_tparm_state(cur_term);
+    TPARM_DATA myData;
+    char *result = NULL;
+
+    _nc_tparm_err = 0;
+#ifdef TRACE
+    tps->tname = "tparm";
+#endif /* TRACE */
+
+    if (tparm_setup(cur_term, string, &myData) == OK && ValidCap(TRUE)) {
+	va_list ap;
+
+	va_start(ap, string);
+	tparm_copy_valist(&myData, TRUE, ap);
+	va_end(ap);
+
+	result = tparam_internal(tps, string, &myData);
+    }
+    return result;
 }
+
+#else /* !NCURSES_TPARM_VARARGS */
+
+NCURSES_EXPORT(char *)
+tparm(const char *string,
+      TPARM_ARG a1,
+      TPARM_ARG a2,
+      TPARM_ARG a3,
+      TPARM_ARG a4,
+      TPARM_ARG a5,
+      TPARM_ARG a6,
+      TPARM_ARG a7,
+      TPARM_ARG a8,
+      TPARM_ARG a9)
+{
+    TPARM_STATE *tps = get_tparm_state(cur_term);
+    TPARM_DATA myData;
+    char *result = NULL;
+
+    _nc_tparm_err = 0;
+#ifdef TRACE
+    tps->tname = "tparm";
+#endif /* TRACE */
+
+#define string_ok (sizeof(char*) <= sizeof(TPARM_ARG))
+
+    if (tparm_setup(cur_term, string, &myData) == OK && ValidCap(string_ok)) {
+
+	myData.param[0] = a1;
+	myData.param[1] = a2;
+	myData.param[2] = a3;
+	myData.param[3] = a4;
+	myData.param[4] = a5;
+	myData.param[5] = a6;
+	myData.param[6] = a7;
+	myData.param[7] = a8;
+	myData.param[8] = a9;
+
+	result = tparam_internal(tps, string, &myData);
+    }
+    return result;
+}
+
 #endif /* NCURSES_TPARM_VARARGS */
 
 NCURSES_EXPORT(char *)
-tiparm(const char *string,...)
+tiparm(const char *string, ...)
 {
-    va_list ap;
-    char *result;
+    TPARM_STATE *tps = get_tparm_state(cur_term);
+    TPARM_DATA myData;
+    char *result = NULL;
 
     _nc_tparm_err = 0;
-    va_start(ap, string);
 #ifdef TRACE
-    TPS(tname) = "tiparm";
+    tps->tname = "tiparm";
 #endif /* TRACE */
-    result = tparam_internal(FALSE, string, ap);
-    va_end(ap);
+
+    if (tparm_setup(cur_term, string, &myData) == OK && ValidCap(TRUE)) {
+	va_list ap;
+
+	va_start(ap, string);
+	tparm_copy_valist(&myData, FALSE, ap);
+	va_end(ap);
+
+	result = tparam_internal(tps, string, &myData);
+    }
     return result;
 }
+
+/*
+ * Use tparm if the formatting string matches the expected number of parameters
+ * counting string-parameters.
+ */
+NCURSES_EXPORT(char *)
+tiparm_s(int num_expected, int tparm_type, const char *string, ...)
+{
+    TPARM_STATE *tps = get_tparm_state(cur_term);
+    TPARM_DATA myData;
+    char *result = NULL;
+
+    _nc_tparm_err = 0;
+#ifdef TRACE
+    tps->tname = "tiparm_s";
+#endif /* TRACE */
+    if (num_expected >= 0 &&
+	num_expected <= 9 &&
+	tparm_type >= 0 &&
+	tparm_type < 7 &&	/* limit to 2 string parameters */
+	tparm_setup(cur_term, string, &myData) == OK &&
+	myData.tparm_type == tparm_type &&
+	myData.num_actual == num_expected) {
+	va_list ap;
+
+	va_start(ap, string);
+	tparm_copy_valist(&myData, FALSE, ap);
+	va_end(ap);
+
+	result = tparam_internal(tps, string, &myData);
+    }
+    return result;
+}
+
+/*
+ * Analyze the formatting string, return the analysis.
+ */
+NCURSES_EXPORT(int)
+tiscan_s(int *num_expected, int *tparm_type, const char *string)
+{
+    TPARM_DATA myData;
+    int result = ERR;
+
+#ifdef TRACE
+    TPARM_STATE *tps = get_tparm_state(cur_term);
+    tps->tname = "tiscan_s";
+#endif /* TRACE */
+
+    if (tparm_setup(cur_term, string, &myData) == OK) {
+	*num_expected = myData.num_actual;
+	*tparm_type = myData.tparm_type;
+	result = OK;
+    }
+    return result;
+}
+
+/*
+ * The internal-use flavor ensures that parameters are numbers, not strings.
+ * In addition to ensuring that they are numbers, it ensures that the parameter
+ * count is consistent with intended usage.
+ *
+ * Unlike the general-purpose tparm/tiparm, these internal calls are fairly
+ * well defined:
+ *
+ * expected == 0 - not applicable
+ * expected == 1 - set color, or vertical/horizontal addressing
+ * expected == 2 - cursor addressing
+ * expected == 4 - initialize color or color pair
+ * expected == 9 - set attributes
+ *
+ * Only for the last case (set attributes) should a parameter be optional.
+ * Also, a capability which calls for more parameters than expected should be
+ * ignored.
+ *
+ * Return a null if the parameter-checks fail.  Otherwise, return a pointer to
+ * the formatted capability string.
+ */
+NCURSES_EXPORT(char *)
+_nc_tiparm(int expected, const char *string, ...)
+{
+    TPARM_STATE *tps = get_tparm_state(cur_term);
+    TPARM_DATA myData;
+    char *result = NULL;
+
+    _nc_tparm_err = 0;
+    T((T_CALLED("_nc_tiparm(%d, %s, ...)"), expected, _nc_visbuf(string)));
+#ifdef TRACE
+    tps->tname = "_nc_tiparm";
+#endif /* TRACE */
+
+    if (tparm_setup(cur_term, string, &myData) == OK && ValidCap(FALSE)) {
+#ifdef CUR
+	if (myData.num_actual != expected && cur_term != NULL) {
+	    int needed = expected;
+	    if (CHECK_CAP(to_status_line)) {
+		needed = 0;	/* allow for xterm's status line */
+	    } else if (CHECK_CAP(set_a_background)) {
+		needed = 0;	/* allow for monochrome fakers */
+	    } else if (CHECK_CAP(set_a_foreground)) {
+		needed = 0;
+	    } else if (CHECK_CAP(set_background)) {
+		needed = 0;
+	    } else if (CHECK_CAP(set_foreground)) {
+		needed = 0;
+	    }
+#if NCURSES_XNAMES
+	    else {
+		char *check;
+
+		check = tigetstr("xm");
+		if (CHECK_CAP(check)) {
+		    needed = 3;
+		}
+		check = tigetstr("S0");
+		if (CHECK_CAP(check)) {
+		    needed = 0;	/* used in screen-base */
+		}
+	    }
+#endif
+	    if (myData.num_actual >= needed && myData.num_actual <= expected)
+		expected = myData.num_actual;
+	}
+#endif
+	if (myData.num_actual == 0 && expected) {
+	    T(("missing parameter%s, expected %s%d",
+	       expected > 1 ? "s" : "",
+	       expected == 9 ? "up to " : "",
+	       expected));
+	} else if (myData.num_actual > expected) {
+	    T(("too many parameters, have %d, expected %d",
+	       myData.num_actual,
+	       expected));
+	} else if (expected != 9 && myData.num_actual != expected) {
+	    T(("expected %d parameters, have %d",
+	       myData.num_actual,
+	       expected));
+	} else {
+	    va_list ap;
+
+	    va_start(ap, string);
+	    tparm_copy_valist(&myData, FALSE, ap);
+	    va_end(ap);
+
+	    result = tparam_internal(tps, string, &myData);
+	}
+    }
+    returnPtr(result);
+}
+
+/*
+ * Improve tic's checks by resetting the terminfo "static variables" before
+ * calling functions which may update them.
+ */
+NCURSES_EXPORT(void)
+_nc_reset_tparm(TERMINAL *term)
+{
+    TPARM_STATE *tps = get_tparm_state(term);
+    memset(TPS(static_vars), 0, sizeof(TPS(static_vars)));
+}
diff --git a/ncurses/tinfo/lib_tputs.c b/ncurses/tinfo/lib_tputs.c
index 09cbbc2..f834532 100644
--- a/ncurses/tinfo/lib_tputs.c
+++ b/ncurses/tinfo/lib_tputs.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -51,12 +52,12 @@
 #include <termcap.h>		/* ospeed */
 #include <tic.h>
 
-MODULE_ID("$Id: lib_tputs.c,v 1.96 2015/01/03 23:51:23 tom Exp $")
+MODULE_ID("$Id: lib_tputs.c,v 1.111 2023/09/16 16:05:15 tom Exp $")
 
 NCURSES_EXPORT_VAR(char) PC = 0;              /* used by termcap library */
 NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0;        /* used by termcap library */
 
-NCURSES_EXPORT_VAR(int) _nc_nulls_sent = 0;   /* used by 'tack' program */
+NCURSES_EXPORT_VAR(int) _nc_nulls_sent = 0;
 
 #if NCURSES_NO_PADDING
 NCURSES_EXPORT(void)
@@ -88,6 +89,9 @@
 {
     T((T_CALLED("delay_output(%p,%d)"), (void *) SP_PARM, ms));
 
+    if (ms > MAX_DELAY_MSECS)
+	ms = MAX_DELAY_MSECS;
+
     if (!HasTInfoTerminal(SP_PARM))
 	returnCode(ERR);
 
@@ -119,16 +123,20 @@
 NCURSES_EXPORT(void)
 NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_DCL0)
 {
+    T((T_CALLED("_nc_flush(%p)"), (void *) SP_PARM));
     if (SP_PARM != 0 && SP_PARM->_ofd >= 0) {
+	TR(TRACE_CHARPUT, ("ofd:%d inuse:%lu buffer:%p",
+			   SP_PARM->_ofd,
+			   (unsigned long) SP_PARM->out_inuse,
+			   SP_PARM->out_buffer));
 	if (SP_PARM->out_inuse) {
 	    char *buf = SP_PARM->out_buffer;
-	    size_t amount = SP->out_inuse;
-	    ssize_t res;
+	    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) {
-		res = write(SP_PARM->_ofd, buf, amount);
-
+		ssize_t res = write(SP_PARM->_ofd, buf, amount);
 		if (res > 0) {
 		    /* if the write was incomplete, try again */
 		    amount -= (size_t) res;
@@ -141,8 +149,17 @@
 		    break;	/* an error we can not recover from */
 		}
 	    }
+	} else if (SP_PARM->out_buffer == 0) {
+	    TR(TRACE_CHARPUT, ("flushing stdout"));
+	    fflush(stdout);
 	}
+    } else {
+	TR(TRACE_CHARPUT, ("flushing stdout"));
+	fflush(stdout);
     }
+    if (SP_PARM != 0)
+	SP_PARM->out_inuse = 0;
+    returnVoid;
 }
 
 #if NCURSES_SP_FUNCS
@@ -263,21 +280,24 @@
 			NCURSES_SP_OUTC outc)
 {
     NCURSES_SP_OUTC my_outch = GetOutCh();
-    bool always_delay;
-    bool normal_delay;
+    bool always_delay = FALSE;
+    bool normal_delay = FALSE;
     int number;
 #if BSD_TPUTS
     int trailpad;
 #endif /* BSD_TPUTS */
 
 #ifdef TRACE
-    char addrbuf[32];
-
     if (USE_TRACEF(TRACE_TPUTS)) {
-	if (outc == NCURSES_SP_NAME(_nc_outch))
+	char addrbuf[32];
+	TR_FUNC_BFR(1);
+
+	if (outc == NCURSES_SP_NAME(_nc_outch)) {
 	    _nc_STRCPY(addrbuf, "_nc_outch", sizeof(addrbuf));
-	else
-	    _nc_SPRINTF(addrbuf, _nc_SLIMIT(sizeof(addrbuf)) "%p", outc);
+	} else {
+	    _nc_SPRINTF(addrbuf, _nc_SLIMIT(sizeof(addrbuf)) "%s",
+			TR_FUNC_ARG(0, outc));
+	}
 	if (_nc_tputs_trace) {
 	    _tracef("tputs(%s = %s, %d, %s) called", _nc_tputs_trace,
 		    _nc_visbuf(string), affcnt, addrbuf);
@@ -289,32 +309,30 @@
     }
 #endif /* TRACE */
 
-    if (SP_PARM != 0 && !HasTInfoTerminal(SP_PARM))
-	return ERR;
-
     if (!VALID_STRING(string))
 	return ERR;
 
-    if (
+    if (SP_PARM != 0 && HasTInfoTerminal(SP_PARM)) {
+	if (
 #if NCURSES_SP_FUNCS
-	   (SP_PARM != 0 && SP_PARM->_term == 0)
+	       (SP_PARM != 0 && SP_PARM->_term == 0)
 #else
-	   cur_term == 0
+	       cur_term == 0
 #endif
-	) {
-	always_delay = FALSE;
-	normal_delay = TRUE;
-    } else {
-	always_delay = (string == bell) || (string == flash_screen);
-	normal_delay =
-	    !xon_xoff
-	    && padding_baud_rate
+	    ) {
+	    always_delay = FALSE;
+	    normal_delay = TRUE;
+	} else {
+	    always_delay = (string == bell) || (string == flash_screen);
+	    normal_delay =
+		!xon_xoff
+		&& padding_baud_rate
 #if NCURSES_NO_PADDING
-	    && !GetNoPadding(SP_PARM)
+		&& !GetNoPadding(SP_PARM)
 #endif
-	    && (_nc_baudrate(ospeed) >= padding_baud_rate);
+		&& (_nc_baudrate(ospeed) >= padding_baud_rate);
+	}
     }
-
 #if BSD_TPUTS
     /*
      * This ugly kluge deals with the fact that some ancient BSD programs
@@ -413,7 +431,7 @@
      */
     if (trailpad > 0
 	&& (always_delay || normal_delay))
-	delay_output(trailpad / 10);
+	NCURSES_SP_NAME(delay_output) (NCURSES_SP_ARGx trailpad / 10);
 #endif /* BSD_TPUTS */
 
     SetOutCh(my_outch);
@@ -425,7 +443,7 @@
 _nc_outc_wrapper(SCREEN *sp, int c)
 {
     if (0 == sp) {
-	return (ERR);
+	return fputc(c, stdout);
     } else {
 	return sp->jump(c);
     }
diff --git a/ncurses/tinfo/lib_ttyflags.c b/ncurses/tinfo/lib_ttyflags.c
index 43bed35..6363a80 100644
--- a/ncurses/tinfo/lib_ttyflags.c
+++ b/ncurses/tinfo/lib_ttyflags.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -41,42 +42,42 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_ttyflags.c,v 1.30 2014/04/26 18:47:20 juergen Exp $")
+MODULE_ID("$Id: lib_ttyflags.c,v 1.36 2020/09/05 22:54:47 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_DCLx TTY * buf)
 {
+    TERMINAL *termp = TerminalOf(SP_PARM);
     int result = OK;
 
-    if (buf == 0 || SP_PARM == 0) {
+    if (buf == 0 || termp == 0) {
 	result = ERR;
     } else {
-	TERMINAL *termp = TerminalOf(SP_PARM);
 
-	if (0 == termp) {
-	    result = ERR;
-	} else {
 #ifdef USE_TERM_DRIVER
+	if (SP_PARM != 0) {
 	    result = CallDriver_2(SP_PARM, td_sgmode, FALSE, buf);
-#else
-	    for (;;) {
-		if (GET_TTY(termp->Filedes, buf) != 0) {
-		    if (errno == EINTR)
-			continue;
-		    result = ERR;
-		}
-		break;
-	    }
-#endif
+	} else {
+	    result = ERR;
 	}
-
-	if (result == ERR)
-	    memset(buf, 0, sizeof(*buf));
+#else
+	for (;;) {
+	    if (GET_TTY(termp->Filedes, buf) != 0) {
+		if (errno == EINTR)
+		    continue;
+		result = ERR;
+	    }
+	    break;
+	}
+#endif
 
 	TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s",
 			termp ? termp->Filedes : -1,
 			_nc_trace_ttymode(buf)));
     }
+    if (result == ERR && buf != 0)
+	memset(buf, 0, sizeof(*buf));
+
     return (result);
 }
 
@@ -141,7 +142,8 @@
     int rc = ERR;
     TERMINAL *termp = TerminalOf(SP_PARM);
 
-    T((T_CALLED("def_shell_mode(%p)"), (void *) SP_PARM));
+    T((T_CALLED("def_shell_mode(%p) ->term %p"),
+       (void *) SP_PARM, (void *) termp));
 
     if (termp != 0) {
 #ifdef USE_TERM_DRIVER
@@ -154,6 +156,8 @@
 #ifdef TERMIOS
 	    if (termp->Ottyb.c_oflag & OFLAGS_TABS)
 		tab = back_tab = NULL;
+#elif defined(EXP_WIN32_DRIVER)
+	    /* noop */
 #else
 	    if (termp->Ottyb.sg_flags & XTABS)
 		tab = back_tab = NULL;
@@ -179,7 +183,7 @@
     int rc = ERR;
     TERMINAL *termp = TerminalOf(SP_PARM);
 
-    T((T_CALLED("def_prog_mode(%p)"), (void *) SP_PARM));
+    T((T_CALLED("def_prog_mode(%p) ->term %p"), (void *) SP_PARM, (void *) termp));
 
     if (termp != 0) {
 #ifdef USE_TERM_DRIVER
@@ -191,6 +195,8 @@
 	if (_nc_get_tty_mode(&termp->Nttyb) == OK) {
 #ifdef TERMIOS
 	    termp->Nttyb.c_oflag &= (unsigned) (~OFLAGS_TABS);
+#elif defined(EXP_WIN32_DRIVER)
+	    /* noop */
 #else
 	    termp->Nttyb.sg_flags &= (unsigned) (~XTABS);
 #endif
@@ -215,7 +221,7 @@
     int rc = ERR;
     TERMINAL *termp = TerminalOf(SP_PARM);
 
-    T((T_CALLED("reset_prog_mode(%p)"), (void *) SP_PARM));
+    T((T_CALLED("reset_prog_mode(%p) ->term %p"), (void *) SP_PARM, (void *) termp));
 
     if (termp != 0) {
 #ifdef USE_TERM_DRIVER
@@ -247,7 +253,8 @@
     int rc = ERR;
     TERMINAL *termp = TerminalOf(SP_PARM);
 
-    T((T_CALLED("reset_shell_mode(%p)"), (void *) SP_PARM));
+    T((T_CALLED("reset_shell_mode(%p) ->term %p"),
+       (void *) SP_PARM, (void *) termp));
 
     if (termp != 0) {
 #ifdef USE_TERM_DRIVER
diff --git a/ncurses/tinfo/lib_win32con.c b/ncurses/tinfo/lib_win32con.c
new file mode 100644
index 0000000..2d6857a
--- /dev/null
+++ b/ncurses/tinfo/lib_win32con.c
@@ -0,0 +1,1252 @@
+/****************************************************************************
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "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.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *  Author: Juergen Pfeifer                                                 *
+ *     and: Thomas E. Dickey                                                *
+ ****************************************************************************/
+
+/*
+ * TODO - GetMousePos(POINT * result) from ntconio.c
+ */
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_win32con.c,v 1.14 2023/08/05 20:44:38 tom Exp $")
+
+#ifdef _NC_WINDOWS
+
+#ifdef _NC_MINGW
+#include <wchar.h>
+#else
+#include <tchar.h>
+#endif
+
+#include <io.h>
+
+#if USE_WIDEC_SUPPORT
+#define write_screen WriteConsoleOutputW
+#define read_screen  ReadConsoleOutputW
+#else
+#define write_screen WriteConsoleOutput
+#define read_screen  ReadConsoleOutput
+#endif
+
+static bool read_screen_data(void);
+
+#define GenMap(vKey,key) MAKELONG(key, vKey)
+static const LONG keylist[] =
+{
+    GenMap(VK_PRIOR, KEY_PPAGE),
+    GenMap(VK_NEXT, KEY_NPAGE),
+    GenMap(VK_END, KEY_END),
+    GenMap(VK_HOME, KEY_HOME),
+    GenMap(VK_LEFT, KEY_LEFT),
+    GenMap(VK_UP, KEY_UP),
+    GenMap(VK_RIGHT, KEY_RIGHT),
+    GenMap(VK_DOWN, KEY_DOWN),
+    GenMap(VK_DELETE, KEY_DC),
+    GenMap(VK_INSERT, KEY_IC)
+};
+static const LONG ansi_keys[] =
+{
+    GenMap(VK_PRIOR, 'I'),
+    GenMap(VK_NEXT, 'Q'),
+    GenMap(VK_END, 'O'),
+    GenMap(VK_HOME, 'H'),
+    GenMap(VK_LEFT, 'K'),
+    GenMap(VK_UP, 'H'),
+    GenMap(VK_RIGHT, 'M'),
+    GenMap(VK_DOWN, 'P'),
+    GenMap(VK_DELETE, 'S'),
+    GenMap(VK_INSERT, 'R')
+};
+#define array_length(a) (sizeof(a)/sizeof(a[0]))
+#define N_INI ((int)array_length(keylist))
+#define FKEYS 24
+#define MAPSIZE (FKEYS + N_INI)
+
+/*   A process can only have a single console, so it is safe
+     to maintain all the information about it in a single
+     static structure.
+ */
+NCURSES_EXPORT_VAR(ConsoleInfo) _nc_CONSOLE;
+static bool console_initialized = FALSE;
+
+#define EnsureInit() (void)(console_initialized ? TRUE : _nc_console_checkinit(TRUE, TRUE))
+
+#define REQUIRED_MAX_V (DWORD)10
+#define REQUIRED_MIN_V (DWORD)0
+#define REQUIRED_BUILD (DWORD)17763
+/*
+  This function returns 0 if the Windows version has no support for
+  the modern Console interface, otherwise it returns 1
+ */
+NCURSES_EXPORT(int)
+_nc_console_vt_supported(void)
+{
+    OSVERSIONINFO osvi;
+    int res = 0;
+
+    T((T_CALLED("lib_win32con::_nc_console_vt_supported")));
+    ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
+    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+    GetVersionEx(&osvi);
+    T(("GetVersionEx returnedMajor=%ld, Minor=%ld, Build=%ld",
+       osvi.dwMajorVersion,
+       osvi.dwMinorVersion,
+       osvi.dwBuildNumber));
+    if (osvi.dwMajorVersion >= REQUIRED_MAX_V) {
+	if (osvi.dwMajorVersion == REQUIRED_MAX_V) {
+	    if (((osvi.dwMinorVersion == REQUIRED_MIN_V) &&
+		 (osvi.dwBuildNumber >= REQUIRED_BUILD)) ||
+		((osvi.dwMinorVersion > REQUIRED_MIN_V)))
+		res = 1;
+	} else
+	    res = 1;
+    }
+    returnCode(res);
+}
+
+NCURSES_EXPORT(void)
+_nc_console_size(int *Lines, int *Cols)
+{
+    EnsureInit();
+    if (Lines != NULL && Cols != NULL) {
+	if (WINCONSOLE.buffered) {
+	    *Lines = (int) (WINCONSOLE.SBI.dwSize.Y);
+	    *Cols = (int) (WINCONSOLE.SBI.dwSize.X);
+	} else {
+	    *Lines = (int) (WINCONSOLE.SBI.srWindow.Bottom + 1 -
+			    WINCONSOLE.SBI.srWindow.Top);
+	    *Cols = (int) (WINCONSOLE.SBI.srWindow.Right + 1 -
+			   WINCONSOLE.SBI.srWindow.Left);
+	}
+    }
+}
+
+/* Convert a file descriptor into a HANDLE
+   That's not necessarily a console HANDLE
+*/
+NCURSES_EXPORT(HANDLE)
+_nc_console_handle(int fd)
+{
+    intptr_t value = _get_osfhandle(fd);
+    return (HANDLE) value;
+}
+
+/* Validate that a HANDLE is actually a
+   console HANDLE
+*/
+static BOOL
+IsConsoleHandle(HANDLE hdl)
+{
+    DWORD dwFlag = 0;
+    BOOL result = FALSE;
+
+    T((T_CALLED("lib_win32con::IsConsoleHandle(HANDLE=%p"), hdl));
+
+    EnsureInit();
+
+    if (!GetConsoleMode(hdl, &dwFlag)) {
+	T(("GetConsoleMode failed"));
+    } else {
+	result = TRUE;
+    }
+
+    returnBool(result);
+}
+
+/*   This is used when running in terminfo mode to discover,
+     whether or not the "terminal" is actually a Windows
+     Console. It is the responsibility of the console to deal
+     with the terminal escape sequences that are sent by
+     terminfo.
+ */
+NCURSES_EXPORT(int)
+_nc_console_test(int fd)
+{
+    int code = 0;
+    HANDLE hdl = INVALID_HANDLE_VALUE;
+    T((T_CALLED("lib_win32con::_nc_console_test(%d)"), fd));
+    hdl = _nc_console_handle(fd);
+    code = (int) IsConsoleHandle(hdl);
+    returnCode(code);
+}
+
+#define OutHandle() ((WINCONSOLE.isTermInfoConsole || WINCONSOLE.progMode) ? WINCONSOLE.hdl : WINCONSOLE.out)
+
+NCURSES_EXPORT(void)
+_nc_console_selectActiveHandle(void)
+{
+    if (WINCONSOLE.lastOut != WINCONSOLE.hdl) {
+	WINCONSOLE.lastOut = WINCONSOLE.hdl;
+	SetConsoleActiveScreenBuffer(WINCONSOLE.lastOut);
+    }
+}
+
+NCURSES_EXPORT(HANDLE)
+_nc_console_fd2handle(int fd)
+{
+    HANDLE hdl = _nc_console_handle(fd);
+    if (hdl == WINCONSOLE.inp) {
+	T(("lib_win32con:validateHandle %d -> WINCONSOLE.inp", fd));
+    } else if (hdl == WINCONSOLE.hdl) {
+	T(("lib_win32con:validateHandle %d -> WINCONSOLE.hdl", fd));
+    } else if (hdl == WINCONSOLE.out) {
+	T(("lib_win32con:validateHandle %d -> WINCONSOLE.out", fd));
+    } else {
+	T(("lib_win32con:validateHandle %d maps to unknown HANDLE", fd));
+	hdl = INVALID_HANDLE_VALUE;
+    }
+#if 1
+    assert(hdl != INVALID_HANDLE_VALUE);
+#endif
+    if (hdl != INVALID_HANDLE_VALUE) {
+	if (hdl != WINCONSOLE.inp && (!WINCONSOLE.isTermInfoConsole && WINCONSOLE.progMode)) {
+	    if (hdl == WINCONSOLE.out && hdl != WINCONSOLE.hdl) {
+		T(("lib_win32con:validateHandle forcing WINCONSOLE.out -> WINCONSOLE.hdl"));
+		hdl = WINCONSOLE.hdl;
+	    }
+	}
+    }
+    return hdl;
+}
+
+NCURSES_EXPORT(int)
+_nc_console_setmode(HANDLE hdl, const TTY * arg)
+{
+    DWORD dwFlag = 0;
+    int code = ERR;
+    HANDLE alt;
+
+    if (arg) {
+#ifdef TRACE
+	TTY TRCTTY;
+#define TRCTTYOUT(flag) TRCTTY.dwFlagOut = flag
+#define TRCTTYIN(flag)  TRCTTY.dwFlagIn = flag
+#else
+#define TRCTTYOUT(flag)
+#define TRCTTYIN(flag)
+#endif
+	T(("lib_win32con:_nc_console_setmode %s", _nc_trace_ttymode(arg)));
+	if (hdl == WINCONSOLE.inp) {
+	    dwFlag = arg->dwFlagIn | ENABLE_MOUSE_INPUT | VT_FLAG_IN;
+	    if (WINCONSOLE.isTermInfoConsole)
+		dwFlag |= (VT_FLAG_IN);
+	    else
+		dwFlag &= (DWORD) ~ (VT_FLAG_IN);
+	    TRCTTYIN(dwFlag);
+	    SetConsoleMode(hdl, dwFlag);
+
+	    alt = OutHandle();
+	    dwFlag = arg->dwFlagOut;
+	    if (WINCONSOLE.isTermInfoConsole)
+		dwFlag |= (VT_FLAG_OUT);
+	    else
+		dwFlag |= (VT_FLAG_OUT);
+	    TRCTTYOUT(dwFlag);
+	    SetConsoleMode(alt, dwFlag);
+	} else {
+	    dwFlag = arg->dwFlagOut;
+	    if (WINCONSOLE.isTermInfoConsole)
+		dwFlag |= (VT_FLAG_OUT);
+	    else
+		dwFlag |= (VT_FLAG_OUT);
+	    TRCTTYOUT(dwFlag);
+	    SetConsoleMode(hdl, dwFlag);
+
+	    alt = WINCONSOLE.inp;
+	    dwFlag = arg->dwFlagIn | ENABLE_MOUSE_INPUT;
+	    if (WINCONSOLE.isTermInfoConsole)
+		dwFlag |= (VT_FLAG_IN);
+	    else
+		dwFlag &= (DWORD) ~ (VT_FLAG_IN);
+	    TRCTTYIN(dwFlag);
+	    SetConsoleMode(alt, dwFlag);
+	    T(("effective mode set %s", _nc_trace_ttymode(&TRCTTY)));
+	}
+	code = OK;
+    }
+    return (code);
+}
+
+NCURSES_EXPORT(int)
+_nc_console_getmode(HANDLE hdl, TTY * arg)
+{
+    int code = ERR;
+
+    if (arg) {
+	DWORD dwFlag = 0;
+	HANDLE alt;
+
+	if (hdl == WINCONSOLE.inp) {
+	    if (GetConsoleMode(hdl, &dwFlag)) {
+		arg->dwFlagIn = dwFlag;
+		alt = OutHandle();
+		if (GetConsoleMode(alt, &dwFlag)) {
+		    arg->dwFlagOut = dwFlag;
+		    code = OK;
+		}
+	    }
+	} else {
+	    if (GetConsoleMode(hdl, &dwFlag)) {
+		arg->dwFlagOut = dwFlag;
+		alt = WINCONSOLE.inp;
+		if (GetConsoleMode(alt, &dwFlag)) {
+		    arg->dwFlagIn = dwFlag;
+		    code = OK;
+		}
+	    }
+	}
+    }
+    T(("lib_win32con:_nc_console_getmode %s", _nc_trace_ttymode(arg)));
+    return (code);
+}
+
+NCURSES_EXPORT(int)
+_nc_console_flush(HANDLE hdl)
+{
+    int code = OK;
+
+    T((T_CALLED("lib_win32con::_nc_console_flush(hdl=%p"), hdl));
+
+    if (hdl != INVALID_HANDLE_VALUE) {
+	if (hdl == WINCONSOLE.hdl ||
+	    hdl == WINCONSOLE.inp ||
+	    hdl == WINCONSOLE.out) {
+	    if (!FlushConsoleInputBuffer(WINCONSOLE.inp))
+		code = ERR;
+	} else {
+	    code = ERR;
+	    T(("_nc_console_flush not requesting a handle owned by console."));
+	}
+    }
+    returnCode(code);
+}
+
+NCURSES_EXPORT(WORD)
+_nc_console_MapColor(bool fore, int color)
+{
+    static const int _cmap[] =
+    {0, 4, 2, 6, 1, 5, 3, 7};
+    int a;
+    if (color < 0 || color > 7)
+	a = fore ? 7 : 0;
+    else
+	a = _cmap[color];
+    if (!fore)
+	a = a << 4;
+    return (WORD) a;
+}
+
+/*
+ * Attempt to save the screen contents.  PDCurses does this if
+ * PDC_RESTORE_SCREEN is set, giving the same visual appearance on
+ * restoration as if the library had allocated a console buffer.  MSDN
+ * says that the data which can be read is limited to 64Kb (and may be
+ * less).
+ */
+static bool
+save_original_screen(void)
+{
+    bool result = FALSE;
+
+    WINCONSOLE.save_region.Top = 0;
+    WINCONSOLE.save_region.Left = 0;
+    WINCONSOLE.save_region.Bottom = (SHORT) (WINCONSOLE.SBI.dwSize.Y - 1);
+    WINCONSOLE.save_region.Right = (SHORT) (WINCONSOLE.SBI.dwSize.X - 1);
+
+    if (read_screen_data()) {
+	result = TRUE;
+    } else {
+
+	WINCONSOLE.save_region.Top = WINCONSOLE.SBI.srWindow.Top;
+	WINCONSOLE.save_region.Left = WINCONSOLE.SBI.srWindow.Left;
+	WINCONSOLE.save_region.Bottom = WINCONSOLE.SBI.srWindow.Bottom;
+	WINCONSOLE.save_region.Right = WINCONSOLE.SBI.srWindow.Right;
+
+	WINCONSOLE.window_only = TRUE;
+
+	if (read_screen_data()) {
+	    result = TRUE;
+	}
+    }
+
+    T(("... save original screen contents %s", result ? "ok" : "err"));
+    return result;
+}
+
+#if 0
+static bool
+restore_original_screen(void)
+{
+    COORD bufferCoord;
+    bool result = FALSE;
+    SMALL_RECT save_region = WINCONSOLE.save_region;
+
+    T(("... restoring %s",
+       WINCONSOLE.window_only ? "window" : "entire buffer"));
+
+    bufferCoord.X = (SHORT) (WINCONSOLE.window_only ?
+			     WINCONSOLE.SBI.srWindow.Left : 0);
+    bufferCoord.Y = (SHORT) (WINCONSOLE.window_only ?
+			     WINCONSOLE.SBI.srWindow.Top : 0);
+
+    if (write_screen(WINCONSOLE.hdl,
+		     WINCONSOLE.save_screen,
+		     WINCONSOLE.save_size,
+		     bufferCoord,
+		     &save_region)) {
+	result = TRUE;
+	mvcur(-1, -1, LINES - 2, 0);
+	T(("... restore original screen contents ok %dx%d (%d,%d - %d,%d)",
+	   WINCONSOLE.save_size.Y,
+	   WINCONSOLE.save_size.X,
+	   save_region.Top,
+	   save_region.Left,
+	   save_region.Bottom,
+	   save_region.Right));
+    } else {
+	T(("... restore original screen contents err"));
+    }
+    return result;
+}
+#endif
+
+static bool
+read_screen_data(void)
+{
+    bool result = FALSE;
+    COORD bufferCoord;
+    size_t want;
+
+    WINCONSOLE.save_size.X = (SHORT) (WINCONSOLE.save_region.Right
+				      - WINCONSOLE.save_region.Left + 1);
+    WINCONSOLE.save_size.Y = (SHORT) (WINCONSOLE.save_region.Bottom
+				      - WINCONSOLE.save_region.Top + 1);
+
+    want = (size_t) (WINCONSOLE.save_size.X * WINCONSOLE.save_size.Y);
+
+    if ((WINCONSOLE.save_screen = malloc(want * sizeof(CHAR_INFO))) != 0) {
+	bufferCoord.X = (SHORT) (WINCONSOLE.window_only ?
+				 WINCONSOLE.SBI.srWindow.Left : 0);
+	bufferCoord.Y = (SHORT) (WINCONSOLE.window_only ?
+				 WINCONSOLE.SBI.srWindow.Top : 0);
+
+	T(("... reading console %s %dx%d into %d,%d - %d,%d at %d,%d",
+	   WINCONSOLE.window_only ? "window" : "buffer",
+	   WINCONSOLE.save_size.Y, WINCONSOLE.save_size.X,
+	   WINCONSOLE.save_region.Top,
+	   WINCONSOLE.save_region.Left,
+	   WINCONSOLE.save_region.Bottom,
+	   WINCONSOLE.save_region.Right,
+	   bufferCoord.Y,
+	   bufferCoord.X));
+
+	if (read_screen(WINCONSOLE.hdl,
+			WINCONSOLE.save_screen,
+			WINCONSOLE.save_size,
+			bufferCoord,
+			&WINCONSOLE.save_region)) {
+	    result = TRUE;
+	} else {
+	    T((" error %#lx", (unsigned long) GetLastError()));
+	    FreeAndNull(WINCONSOLE.save_screen);
+	}
+    }
+
+    return result;
+}
+
+NCURSES_EXPORT(bool)
+_nc_console_get_SBI(void)
+{
+    bool rc = FALSE;
+    if (GetConsoleScreenBufferInfo(WINCONSOLE.hdl, &(WINCONSOLE.SBI))) {
+	T(("GetConsoleScreenBufferInfo"));
+	T(("... buffer(X:%d Y:%d)",
+	   WINCONSOLE.SBI.dwSize.X,
+	   WINCONSOLE.SBI.dwSize.Y));
+	T(("... window(X:%d Y:%d)",
+	   WINCONSOLE.SBI.dwMaximumWindowSize.X,
+	   WINCONSOLE.SBI.dwMaximumWindowSize.Y));
+	T(("... cursor(X:%d Y:%d)",
+	   WINCONSOLE.SBI.dwCursorPosition.X,
+	   WINCONSOLE.SBI.dwCursorPosition.Y));
+	T(("... display(Top:%d Bottom:%d Left:%d Right:%d)",
+	   WINCONSOLE.SBI.srWindow.Top,
+	   WINCONSOLE.SBI.srWindow.Bottom,
+	   WINCONSOLE.SBI.srWindow.Left,
+	   WINCONSOLE.SBI.srWindow.Right));
+	if (WINCONSOLE.buffered) {
+	    WINCONSOLE.origin.X = 0;
+	    WINCONSOLE.origin.Y = 0;
+	} else {
+	    WINCONSOLE.origin.X = WINCONSOLE.SBI.srWindow.Left;
+	    WINCONSOLE.origin.Y = WINCONSOLE.SBI.srWindow.Top;
+	}
+	rc = TRUE;
+    } else {
+	T(("GetConsoleScreenBufferInfo ERR"));
+    }
+    return rc;
+}
+
+#define MIN_WIDE 80
+#define MIN_HIGH 24
+
+/*
+ * In "normal" mode, reset the buffer- and window-sizes back to their original values.
+ */
+NCURSES_EXPORT(void)
+_nc_console_set_scrollback(bool normal, CONSOLE_SCREEN_BUFFER_INFO * info)
+{
+    SMALL_RECT rect;
+    COORD coord;
+    bool changed = FALSE;
+
+    T((T_CALLED("lib_win32con::_nc_console_set_scrollback(%s)"),
+       (normal
+	? "normal"
+	: "application")));
+
+    T(("... SBI.srWindow %d,%d .. %d,%d",
+       info->srWindow.Top,
+       info->srWindow.Left,
+       info->srWindow.Bottom,
+       info->srWindow.Right));
+    T(("... SBI.dwSize %dx%d",
+       info->dwSize.Y,
+       info->dwSize.X));
+
+    if (normal) {
+	rect = info->srWindow;
+	coord = info->dwSize;
+	if (memcmp(info, &WINCONSOLE.SBI, sizeof(*info)) != 0) {
+	    changed = TRUE;
+	    WINCONSOLE.SBI = *info;
+	}
+    } else {
+	int high = info->srWindow.Bottom - info->srWindow.Top + 1;
+	int wide = info->srWindow.Right - info->srWindow.Left + 1;
+
+	if (high < MIN_HIGH) {
+	    T(("... height %d < %d", high, MIN_HIGH));
+	    high = MIN_HIGH;
+	    changed = TRUE;
+	}
+	if (wide < MIN_WIDE) {
+	    T(("... width %d < %d", wide, MIN_WIDE));
+	    wide = MIN_WIDE;
+	    changed = TRUE;
+	}
+
+	rect.Left =
+	    rect.Top = 0;
+	rect.Right = (SHORT) (wide - 1);
+	rect.Bottom = (SHORT) (high - 1);
+
+	coord.X = (SHORT) wide;
+	coord.Y = (SHORT) high;
+
+	if (info->dwSize.Y != high ||
+	    info->dwSize.X != wide ||
+	    info->srWindow.Top != 0 ||
+	    info->srWindow.Left != 0) {
+	    changed = TRUE;
+	}
+
+    }
+
+    if (changed) {
+	T(("... coord %d,%d", coord.Y, coord.X));
+	T(("... rect %d,%d - %d,%d",
+	   rect.Top, rect.Left,
+	   rect.Bottom, rect.Right));
+	SetConsoleScreenBufferSize(WINCONSOLE.hdl, coord);	/* dwSize */
+	SetConsoleWindowInfo(WINCONSOLE.hdl, TRUE, &rect);	/* srWindow */
+	_nc_console_get_SBI();
+    }
+    returnVoid;
+}
+
+static ULONGLONG
+tdiff(FILETIME fstart, FILETIME fend)
+{
+    ULARGE_INTEGER ustart;
+    ULARGE_INTEGER uend;
+    ULONGLONG diff;
+
+    ustart.LowPart = fstart.dwLowDateTime;
+    ustart.HighPart = fstart.dwHighDateTime;
+    uend.LowPart = fend.dwLowDateTime;
+    uend.HighPart = fend.dwHighDateTime;
+
+    diff = (uend.QuadPart - ustart.QuadPart) / 10000;
+    return diff;
+}
+
+static int
+Adjust(int milliseconds, int diff)
+{
+    if (milliseconds != INFINITY) {
+	milliseconds -= diff;
+	if (milliseconds < 0)
+	    milliseconds = 0;
+    }
+    return milliseconds;
+}
+
+#define BUTTON_MASK (FROM_LEFT_1ST_BUTTON_PRESSED | \
+                     FROM_LEFT_2ND_BUTTON_PRESSED | \
+                     FROM_LEFT_3RD_BUTTON_PRESSED | \
+                     FROM_LEFT_4TH_BUTTON_PRESSED | \
+                     RIGHTMOST_BUTTON_PRESSED)
+
+static mmask_t
+decode_mouse(SCREEN *sp, int mask)
+{
+    mmask_t result = 0;
+
+    (void) sp;
+    assert(sp && console_initialized);
+
+    if (mask & FROM_LEFT_1ST_BUTTON_PRESSED)
+	result |= BUTTON1_PRESSED;
+    if (mask & FROM_LEFT_2ND_BUTTON_PRESSED)
+	result |= BUTTON2_PRESSED;
+    if (mask & FROM_LEFT_3RD_BUTTON_PRESSED)
+	result |= BUTTON3_PRESSED;
+    if (mask & FROM_LEFT_4TH_BUTTON_PRESSED)
+	result |= BUTTON4_PRESSED;
+
+    if (mask & RIGHTMOST_BUTTON_PRESSED) {
+	switch (WINCONSOLE.numButtons) {
+	case 1:
+	    result |= BUTTON1_PRESSED;
+	    break;
+	case 2:
+	    result |= BUTTON2_PRESSED;
+	    break;
+	case 3:
+	    result |= BUTTON3_PRESSED;
+	    break;
+	case 4:
+	    result |= BUTTON4_PRESSED;
+	    break;
+	}
+    }
+
+    return result;
+}
+
+#define AdjustY() (WINCONSOLE.buffered ? 0 : (int) WINCONSOLE.SBI.srWindow.Top)
+
+static bool
+handle_mouse(SCREEN *sp, MOUSE_EVENT_RECORD mer)
+{
+    MEVENT work;
+    bool result = FALSE;
+
+    assert(sp);
+
+    sp->_drv_mouse_old_buttons = sp->_drv_mouse_new_buttons;
+    sp->_drv_mouse_new_buttons = mer.dwButtonState & BUTTON_MASK;
+
+    /*
+     * We're only interested if the button is pressed or released.
+     * FIXME: implement continuous event-tracking.
+     */
+    if (sp->_drv_mouse_new_buttons != sp->_drv_mouse_old_buttons) {
+	memset(&work, 0, sizeof(work));
+
+	if (sp->_drv_mouse_new_buttons) {
+	    work.bstate |= decode_mouse(sp, sp->_drv_mouse_new_buttons);
+	} else {
+	    /* cf: BUTTON_PRESSED, BUTTON_RELEASED */
+	    work.bstate |= (decode_mouse(sp, sp->_drv_mouse_old_buttons)
+			    >> 1);
+	    result = TRUE;
+	}
+
+	work.x = mer.dwMousePosition.X;
+	work.y = mer.dwMousePosition.Y - AdjustY();
+
+	sp->_drv_mouse_fifo[sp->_drv_mouse_tail] = work;
+	sp->_drv_mouse_tail += 1;
+    }
+    return result;
+}
+
+static int
+rkeycompare(const void *el1, const void *el2)
+{
+    WORD key1 = (LOWORD((*((const LONG *) el1)))) & 0x7fff;
+    WORD key2 = (LOWORD((*((const LONG *) el2)))) & 0x7fff;
+
+    return ((key1 < key2) ? -1 : ((key1 == key2) ? 0 : 1));
+}
+
+static int
+keycompare(const void *el1, const void *el2)
+{
+    WORD key1 = HIWORD((*((const LONG *) el1)));
+    WORD key2 = HIWORD((*((const LONG *) el2)));
+
+    return ((key1 < key2) ? -1 : ((key1 == key2) ? 0 : 1));
+}
+
+static int
+MapKey(WORD vKey)
+{
+    int code = -1;
+
+    if (!WINCONSOLE.isTermInfoConsole) {
+	WORD nKey = 0;
+	void *res;
+	LONG key = GenMap(vKey, 0);
+
+	res = bsearch(&key,
+		      WINCONSOLE.map,
+		      (size_t) (N_INI + FKEYS),
+		      sizeof(keylist[0]),
+		      keycompare);
+	if (res) {
+	    key = *((LONG *) res);
+	    nKey = LOWORD(key);
+	    code = (int) (nKey & 0x7fff);
+	    if (nKey & 0x8000)
+		code = -code;
+	}
+    }
+    return code;
+}
+
+static int
+AnsiKey(WORD vKey)
+{
+    int code = -1;
+
+    if (!WINCONSOLE.isTermInfoConsole) {
+	WORD nKey = 0;
+	void *res;
+	LONG key = GenMap(vKey, 0);
+
+	res = bsearch(&key,
+		      WINCONSOLE.ansi_map,
+		      (size_t) (N_INI + FKEYS),
+		      sizeof(keylist[0]),
+		      keycompare);
+	if (res) {
+	    key = *((LONG *) res);
+	    nKey = LOWORD(key);
+	    code = (int) (nKey & 0x7fff);
+	    if (nKey & 0x8000)
+		code = -code;
+	}
+    }
+    return code;
+}
+
+NCURSES_EXPORT(int)
+_nc_console_keyok(int keycode, int flag)
+{
+    int code = ERR;
+    WORD nKey;
+    WORD vKey;
+    void *res;
+    LONG key = GenMap(0, (WORD) keycode);
+
+    T((T_CALLED("lib_win32con::_nc_console_keyok(%d, %d)"), keycode, flag));
+
+    res = bsearch(&key,
+		  WINCONSOLE.rmap,
+		  (size_t) (N_INI + FKEYS),
+		  sizeof(keylist[0]),
+		  rkeycompare);
+    if (res) {
+	key = *((LONG *) res);
+	vKey = HIWORD(key);
+	nKey = (LOWORD(key)) & 0x7fff;
+	if (!flag)
+	    nKey |= 0x8000;
+	*(LONG *) res = GenMap(vKey, nKey);
+    }
+    returnCode(code);
+}
+
+NCURSES_EXPORT(bool)
+_nc_console_keyExist(int keycode)
+{
+    WORD nKey;
+    void *res;
+    bool found = FALSE;
+    LONG key = GenMap(0, (WORD) keycode);
+
+    T((T_CALLED("lib_win32con::_nc_console_keyExist(%d)"), keycode));
+    res = bsearch(&key,
+		  WINCONSOLE.rmap,
+		  (size_t) (N_INI + FKEYS),
+		  sizeof(keylist[0]),
+		  rkeycompare);
+    if (res) {
+	key = *((LONG *) res);
+	nKey = LOWORD(key);
+	if (!(nKey & 0x8000))
+	    found = TRUE;
+    }
+    returnCode(found);
+}
+
+NCURSES_EXPORT(int)
+_nc_console_twait(
+		     SCREEN *sp,
+		     HANDLE hdl,
+		     int mode,
+		     int milliseconds,
+		     int *timeleft
+		     EVENTLIST_2nd(_nc_eventlist * evl))
+{
+    INPUT_RECORD inp_rec;
+    BOOL b;
+    DWORD nRead = 0, rc = (DWORD) (-1);
+    int code = 0;
+    FILETIME fstart;
+    FILETIME fend;
+    int diff;
+    bool isNoDelay = (milliseconds == 0);
+
+#ifdef NCURSES_WGETCH_EVENTS
+    (void) evl;			/* TODO: implement wgetch-events */
+#endif
+
+#define IGNORE_CTRL_KEYS (SHIFT_PRESSED|LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED| \
+                          LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED)
+#define CONSUME() ReadConsoleInput(hdl, &inp_rec, 1, &nRead)
+
+    assert(sp);
+
+    TR(TRACE_IEVENT, ("start twait: hdl=%p, %d milliseconds, mode: %d",
+		      hdl, milliseconds, mode));
+
+    if (milliseconds < 0)
+	milliseconds = INFINITY;
+
+    memset(&inp_rec, 0, sizeof(inp_rec));
+
+    while (true) {
+	if (!isNoDelay) {
+	    GetSystemTimeAsFileTime(&fstart);
+	    rc = WaitForSingleObject(hdl, (DWORD) milliseconds);
+	    GetSystemTimeAsFileTime(&fend);
+	    diff = (int) tdiff(fstart, fend);
+	    milliseconds = Adjust(milliseconds, diff);
+	    if (milliseconds < 0)
+		break;
+	}
+
+	if (isNoDelay || (rc == WAIT_OBJECT_0)) {
+	    if (mode) {
+		nRead = 0;
+		b = GetNumberOfConsoleInputEvents(hdl, &nRead);
+		if (!b) {
+		    T(("twait:err GetNumberOfConsoleInputEvents"));
+		}
+		if (isNoDelay && b) {
+		    T(("twait: Events Available: %ld", nRead));
+		    if (nRead == 0) {
+			code = 0;
+			goto end;
+		    } else {
+			DWORD n = 0;
+			INPUT_RECORD *pInpRec =
+			TypeAlloca(INPUT_RECORD, nRead);
+			if (pInpRec != NULL) {
+			    DWORD i;
+			    BOOL f;
+			    memset(pInpRec, 0, sizeof(INPUT_RECORD) * nRead);
+			    f = PeekConsoleInput(hdl, pInpRec, nRead, &n);
+			    if (f) {
+				for (i = 0; i < n; i++) {
+				    if (pInpRec[i].EventType == KEY_EVENT) {
+					if (pInpRec[i].Event.KeyEvent.bKeyDown) {
+					    DWORD ctrlMask =
+					    (pInpRec[i].Event.KeyEvent.dwControlKeyState &
+					     IGNORE_CTRL_KEYS);
+					    if (!ctrlMask) {
+						code = TW_INPUT;
+						goto end;
+					    }
+					}
+				    }
+				}
+			    } else {
+				T(("twait:err PeekConsoleInput"));
+			    }
+			    code = 0;
+			    goto end;
+			} else {
+			    T(("twait:err could not alloca input records"));
+			}
+		    }
+		}
+		if (b && nRead > 0) {
+		    b = PeekConsoleInput(hdl, &inp_rec, 1, &nRead);
+		    if (!b) {
+			T(("twait:err PeekConsoleInput"));
+		    }
+		    if (b && nRead > 0) {
+			switch (inp_rec.EventType) {
+			case KEY_EVENT:
+			    if (mode & TW_INPUT) {
+				WORD vk =
+				inp_rec.Event.KeyEvent.wVirtualKeyCode;
+				char ch =
+				inp_rec.Event.KeyEvent.uChar.AsciiChar;
+				T(("twait:event KEY_EVENT"));
+				T(("twait vk=%d, ch=%d, keydown=%d",
+				   vk, ch, inp_rec.Event.KeyEvent.bKeyDown));
+				if (inp_rec.Event.KeyEvent.bKeyDown) {
+				    T(("twait:event KeyDown"));
+				    if (!WINCONSOLE.isTermInfoConsole &&
+					(0 == ch)) {
+					int nKey = MapKey(vk);
+					if (nKey < 0) {
+					    CONSUME();
+					    continue;
+					}
+				    }
+				    code = TW_INPUT;
+				    goto end;
+				} else {
+				    CONSUME();
+				}
+			    }
+			    continue;
+			case MOUSE_EVENT:
+			    T(("twait:event MOUSE_EVENT"));
+			    if (decode_mouse(sp,
+					     (inp_rec.Event.MouseEvent.dwButtonState
+					      & BUTTON_MASK)) == 0) {
+				CONSUME();
+			    } else if (mode & TW_MOUSE) {
+				code = TW_MOUSE;
+				goto end;
+			    }
+			    continue;
+			    /* e.g., FOCUS_EVENT */
+			default:
+			    T(("twait:event Tyoe %d", inp_rec.EventType));
+			    CONSUME();
+			    _nc_console_selectActiveHandle();
+			    continue;
+			}
+		    }
+		}
+	    }
+	    continue;
+	} else {
+	    if (rc != WAIT_TIMEOUT) {
+		code = -1;
+		break;
+	    } else {
+		code = 0;
+		break;
+	    }
+	}
+    }
+  end:
+
+    TR(TRACE_IEVENT, ("end twait: returned %d (%lu), remaining time %d msec",
+		      code, GetLastError(), milliseconds));
+
+    if (timeleft)
+	*timeleft = milliseconds;
+
+    return code;
+}
+
+NCURSES_EXPORT(int)
+_nc_console_testmouse(
+			 SCREEN *sp,
+			 HANDLE hdl,
+			 int delay
+			 EVENTLIST_2nd(_nc_eventlist * evl))
+{
+    int rc = 0;
+
+    assert(sp);
+
+    if (sp->_drv_mouse_head < sp->_drv_mouse_tail) {
+	rc = TW_MOUSE;
+    } else {
+	rc = _nc_console_twait(sp,
+			       hdl,
+			       TWAIT_MASK,
+			       delay,
+			       (int *) 0
+			       EVENTLIST_2nd(evl));
+    }
+    return rc;
+}
+
+NCURSES_EXPORT(int)
+_nc_console_read(
+		    SCREEN *sp,
+		    HANDLE hdl,
+		    int *buf)
+{
+    int rc = -1;
+    INPUT_RECORD inp_rec;
+    BOOL b;
+    DWORD nRead;
+    WORD vk;
+
+    assert(sp);
+    assert(buf);
+
+    memset(&inp_rec, 0, sizeof(inp_rec));
+
+    T((T_CALLED("lib_win32con::_nc_console_read(%p)"), sp));
+
+    while ((b = ReadConsoleInput(hdl, &inp_rec, 1, &nRead))) {
+	if (b && nRead > 0) {
+	    if (rc < 0)
+		rc = 0;
+	    rc = rc + (int) nRead;
+	    if (inp_rec.EventType == KEY_EVENT) {
+		if (!inp_rec.Event.KeyEvent.bKeyDown)
+		    continue;
+		*buf = (int) inp_rec.Event.KeyEvent.uChar.AsciiChar;
+		vk = inp_rec.Event.KeyEvent.wVirtualKeyCode;
+		/*
+		 * There are 24 virtual function-keys, and typically
+		 * 12 function-keys on a keyboard.  Use the shift-modifier
+		 * to provide the remaining 12 keys.
+		 */
+		if (vk >= VK_F1 && vk <= VK_F12) {
+		    if (inp_rec.Event.KeyEvent.dwControlKeyState &
+			SHIFT_PRESSED) {
+			vk = (WORD) (vk + 12);
+		    }
+		}
+		if (*buf == 0) {
+		    int key = MapKey(vk);
+		    if (key < 0)
+			continue;
+		    if (sp->_keypad_on) {
+			*buf = key;
+		    } else {
+			ungetch('\0');
+			*buf = AnsiKey(vk);
+		    }
+		}
+		break;
+	    } else if (inp_rec.EventType == MOUSE_EVENT) {
+		if (handle_mouse(sp,
+				 inp_rec.Event.MouseEvent)) {
+		    *buf = KEY_MOUSE;
+		    break;
+		}
+	    }
+	    continue;
+	}
+    }
+    returnCode(rc);
+}
+
+/*   Our replacement for the systems _isatty to include also
+     a test for mintty. This is called from the NC_ISATTY macro
+     defined in curses.priv.h
+
+     Return codes:
+     - 0 : Not a TTY
+     - 1 : A Windows character device detected by _isatty
+     - 2 : A future implementation may return 2 for mintty
+ */
+NCURSES_EXPORT(int)
+_nc_console_isatty(int fd)
+{
+    int result = 0;
+    T((T_CALLED("lib_win32con::_nc_console_isatty(%d"), fd));
+
+    if (_isatty(fd))
+	result = 1;
+#ifdef _NC_CHECK_MINTTY
+    else {
+	if (_nc_console_checkmintty(fd, NULL)) {
+	    result = 2;
+	    fprintf(stderr,
+		    "ncurses on Windows must run in a Windows console.\n"
+		    "On newer versions of Windows, the calling program should create a PTY-like.\n"
+		    "device using the CreatePseudoConsole Windows API call.\n");
+	    exit(EXIT_FAILURE);
+	}
+    }
+#endif
+    returnCode(result);
+}
+
+NCURSES_EXPORT(bool)
+_nc_console_checkinit(bool initFlag, bool assumeTermInfo)
+{
+    bool res = FALSE;
+
+    T((T_CALLED("lib_win32con::_nc_console_checkinit(initFlag=%d, assumeTermInfo=%d)"),
+       initFlag, assumeTermInfo));
+
+    if (!initFlag) {
+	res = console_initialized;
+    } else {
+	/* initialize once, or not at all */
+	if (!console_initialized) {
+	    int i;
+	    DWORD num_buttons;
+	    WORD a;
+	    BOOL buffered = FALSE;
+	    BOOL b;
+
+	    START_TRACE();
+	    WINCONSOLE.isTermInfoConsole = assumeTermInfo;
+
+	    WINCONSOLE.map = (LPDWORD) malloc(sizeof(DWORD) * MAPSIZE);
+	    WINCONSOLE.rmap = (LPDWORD) malloc(sizeof(DWORD) * MAPSIZE);
+	    WINCONSOLE.ansi_map = (LPDWORD) malloc(sizeof(DWORD) * MAPSIZE);
+
+	    for (i = 0; i < (N_INI + FKEYS); i++) {
+		if (i < N_INI) {
+		    WINCONSOLE.rmap[i] = WINCONSOLE.map[i] =
+			(DWORD) keylist[i];
+		    WINCONSOLE.ansi_map[i] = (DWORD) ansi_keys[i];
+		} else {
+		    WINCONSOLE.rmap[i] = WINCONSOLE.map[i] =
+			(DWORD) GenMap((VK_F1 + (i - N_INI)),
+				       (KEY_F(1) + (i - N_INI)));
+		    WINCONSOLE.ansi_map[i] =
+			(DWORD) GenMap((VK_F1 + (i - N_INI)),
+				       (';' + (i - N_INI)));
+		}
+	    }
+	    qsort(WINCONSOLE.ansi_map,
+		  (size_t) (MAPSIZE),
+		  sizeof(keylist[0]),
+		  keycompare);
+	    qsort(WINCONSOLE.map,
+		  (size_t) (MAPSIZE),
+		  sizeof(keylist[0]),
+		  keycompare);
+	    qsort(WINCONSOLE.rmap,
+		  (size_t) (MAPSIZE),
+		  sizeof(keylist[0]),
+		  rkeycompare);
+
+	    if (GetNumberOfConsoleMouseButtons(&num_buttons)) {
+		WINCONSOLE.numButtons = (int) num_buttons;
+	    } else {
+		WINCONSOLE.numButtons = 1;
+	    }
+
+	    a = _nc_console_MapColor(true, COLOR_WHITE) |
+		_nc_console_MapColor(false, COLOR_BLACK);
+	    for (i = 0; i < CON_NUMPAIRS; i++)
+		WINCONSOLE.pairs[i] = a;
+
+#define SaveConsoleMode(handle, value) \
+            GetConsoleMode(WINCONSOLE.handle, &WINCONSOLE.originalMode.value)
+
+	    if (WINCONSOLE.isTermInfoConsole) {
+		WINCONSOLE.inp = GetStdHandle(STD_INPUT_HANDLE);
+		WINCONSOLE.out = GetStdHandle(STD_OUTPUT_HANDLE);
+		WINCONSOLE.hdl = WINCONSOLE.out;
+
+		SaveConsoleMode(inp, dwFlagIn);
+		SaveConsoleMode(out, dwFlagOut);
+
+	    } else {
+		b = AllocConsole();
+
+		if (!b)
+		    b = AttachConsole(ATTACH_PARENT_PROCESS);
+
+		WINCONSOLE.inp = GetDirectHandle("CONIN$", FILE_SHARE_READ);
+		WINCONSOLE.out = GetDirectHandle("CONOUT$", FILE_SHARE_WRITE);
+
+		SaveConsoleMode(inp, dwFlagIn);
+		SaveConsoleMode(out, dwFlagOut);
+
+		if (getenv("NCGDB") || getenv("NCURSES_CONSOLE2")) {
+		    WINCONSOLE.hdl = WINCONSOLE.out;
+		    T(("... will not buffer console"));
+		} else {
+		    T(("... creating console buffer"));
+		    WINCONSOLE.hdl =
+			CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE,
+						  FILE_SHARE_READ | FILE_SHARE_WRITE,
+						  NULL,
+						  CONSOLE_TEXTMODE_BUFFER,
+						  NULL);
+		    buffered = TRUE;
+		}
+	    }
+
+	    /* We set binary I/O even when using the console
+	       driver to cover the situation, that the
+	       TERM variable is set to #win32con, but actually
+	       Windows supports virtual terminal processing.
+	       So if terminfo functions are used in this setup,
+	       they actually may work.
+	     */
+	    _setmode(fileno(stdin), _O_BINARY);
+	    _setmode(fileno(stdout), _O_BINARY);
+
+	    if (WINCONSOLE.hdl != INVALID_HANDLE_VALUE) {
+		WINCONSOLE.buffered = buffered;
+		_nc_console_get_SBI();
+		WINCONSOLE.save_SBI = WINCONSOLE.SBI;
+		if (!buffered) {
+		    save_original_screen();
+		    _nc_console_set_scrollback(FALSE, &WINCONSOLE.SBI);
+		}
+		GetConsoleCursorInfo(WINCONSOLE.hdl, &WINCONSOLE.save_CI);
+		T(("... initial cursor is %svisible, %d%%",
+		   (WINCONSOLE.save_CI.bVisible ? "" : "not-"),
+		   (int) WINCONSOLE.save_CI.dwSize));
+	    }
+
+	    WINCONSOLE.initialized = TRUE;
+	    console_initialized = TRUE;
+	}
+	res = (WINCONSOLE.hdl != INVALID_HANDLE_VALUE);
+    }
+    returnBool(res);
+}
+
+#endif // _NC_WINDOWS
diff --git a/ncurses/tinfo/lib_win32util.c b/ncurses/tinfo/lib_win32util.c
new file mode 100644
index 0000000..c67c8ce
--- /dev/null
+++ b/ncurses/tinfo/lib_win32util.c
@@ -0,0 +1,134 @@
+/****************************************************************************
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "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.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *  Author: Juergen Pfeifer                                                 *
+ *     and: Thomas E. Dickey                                                *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_win32util.c,v 1.4 2023/06/17 17:19:06 tom Exp $")
+
+#ifdef _NC_WINDOWS
+#include <io.h>
+
+#ifdef _NC_CHECK_MINTTY
+#define PSAPI_VERSION 2
+#include <psapi.h>
+#include <tchar.h>
+
+#define array_length(a) (sizeof(a)/sizeof(a[0]))
+
+/*   This function tests, whether or not the ncurses application
+     is running as a descendant of MSYS2/cygwin mintty terminal
+     application. mintty doesn't use Windows Console for its screen
+     I/O, so the native Windows _isatty doesn't recognize it as
+     character device. But we can discover we are at the end of an
+     Pipe and can query the server side of the pipe, looking whether
+     or not this is mintty.
+     For now we terminate the program if we discover that situation.
+     Although in theory it would be possible, to remotely manipulate
+     the terminal state of mintty, this is out of scope for now and
+     not worth the significant effort.
+ */
+NCURSES_EXPORT(int)
+_nc_console_checkmintty(int fd, LPHANDLE pMinTTY)
+{
+    HANDLE handle = _nc_console_handle(fd);
+    DWORD dw;
+    int code = 0;
+
+    T((T_CALLED("lib_winhelper::_nc_console_checkmintty(%d, %p)"), fd, pMinTTY));
+
+    if (handle != INVALID_HANDLE_VALUE) {
+	dw = GetFileType(handle);
+	if (dw == FILE_TYPE_PIPE) {
+	    if (GetNamedPipeInfo(handle, 0, 0, 0, 0)) {
+		ULONG pPid;
+		/* Requires NT6 */
+		if (GetNamedPipeServerProcessId(handle, &pPid)) {
+		    TCHAR buf[MAX_PATH];
+		    DWORD len = 0;
+		    /* These security attributes may allow us to
+		       create a remote thread in mintty to manipulate
+		       the terminal state remotely */
+		    HANDLE pHandle = OpenProcess(PROCESS_CREATE_THREAD
+						 | PROCESS_QUERY_INFORMATION
+						 | PROCESS_VM_OPERATION
+						 | PROCESS_VM_WRITE
+						 | PROCESS_VM_READ,
+						 FALSE,
+						 pPid);
+		    if (pMinTTY)
+			*pMinTTY = INVALID_HANDLE_VALUE;
+		    if (pHandle != INVALID_HANDLE_VALUE) {
+			if ((len = GetProcessImageFileName(pHandle,
+							   buf,
+							   (DWORD)
+							   array_length(buf)))) {
+			    TCHAR *pos = _tcsrchr(buf, _T('\\'));
+			    if (pos) {
+				pos++;
+				if (_tcsnicmp(pos, _TEXT("mintty.exe"), 10)
+				    == 0) {
+				    if (pMinTTY)
+					*pMinTTY = pHandle;
+				    code = 1;
+				}
+			    }
+			}
+		    }
+		}
+	    }
+	}
+    }
+    returnCode(code);
+}
+#endif /* _NC_CHECK_MINTTY */
+
+#if HAVE_GETTIMEOFDAY == 2
+#define JAN1970 116444736000000000LL	/* the value for 01/01/1970 00:00 */
+
+NCURSES_EXPORT(int)
+_nc_gettimeofday(struct timeval *tv, void *tz GCC_UNUSED)
+{
+    union {
+	FILETIME ft;
+	long long since1601;	/* time since 1 Jan 1601 in 100ns units */
+    } data;
+
+    GetSystemTimeAsFileTime(&data.ft);
+    tv->tv_usec = (long) ((data.since1601 / 10LL) % 1000000LL);
+    tv->tv_sec = (long) ((data.since1601 - JAN1970) / 10000000LL);
+    return (0);
+}
+#endif // HAVE_GETTIMEOFDAY == 2
+
+#endif // _NC_WINDOWS
diff --git a/ncurses/tinfo/make_hash.c b/ncurses/tinfo/make_hash.c
index 37ac765..78a684c 100644
--- a/ncurses/tinfo/make_hash.c
+++ b/ncurses/tinfo/make_hash.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018-2020,2024 Thomas E. Dickey                                *
+ * Copyright 2009-2013,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,7 +35,6 @@
 
 /*
  *	make_hash.c --- build-time program for constructing comp_captab.c
- *
  */
 
 #include <build.priv.h>
@@ -44,14 +44,14 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: make_hash.c,v 1.13 2013/09/28 20:55:47 tom Exp $")
+MODULE_ID("$Id: make_hash.c,v 1.34 2024/03/02 19:35:40 tom Exp $")
 
 /*
  *	_nc_make_hash_table()
  *
  *	Takes the entries in table[] and hashes them into hash_table[]
- *	by name.  There are CAPTABSIZE entries in table[] and HASHTABSIZE
- *	slots in hash_table[].
+ *	by name.  There are CAPTABSIZE entries in the predefined table[]
+ *	and HASHTABSIZE slots in hash_table[].
  *
  */
 
@@ -59,6 +59,14 @@
 #define MODULE_ID(id)		/*nothing */
 #include <tinfo/doalloc.c>
 
+#define L_PAREN "("
+#define R_PAREN ")"
+#define L_BRACE "{"
+#define R_BRACE "}"
+
+static const char *typenames[] =
+{"BOOLEAN", "NUMBER", "STRING"};
+
 static void
 failed(const char *s)
 {
@@ -82,7 +90,7 @@
  *
  *	Computes the hashing function on the given string.
  *
- *	The current hash function is the sum of each consectutive pair
+ *	The current hash function is the sum of each consecutive pair
  *	of characters, taken as two-byte integers, mod HASHTABSIZE.
  *
  */
@@ -93,36 +101,40 @@
     long sum = 0;
 
     while (*string) {
-	sum += (long) (*string + (*(string + 1) << 8));
+	sum += (long) (UChar(*string) + (UChar(*(string + 1)) << 8));
 	string++;
     }
 
     return (int) (sum % HASHTABSIZE);
 }
 
+#define UNUSED -1
+
 static void
-_nc_make_hash_table(struct name_table_entry *table,
-		    HashValue * hash_table)
+_nc_make_hash_table(struct user_table_entry *table,
+		    HashValue * hash_table,
+		    unsigned tablesize)
 {
-    short i;
+    unsigned i;
     int hashvalue;
     int collisions = 0;
 
     for (i = 0; i < HASHTABSIZE; i++) {
-	hash_table[i] = -1;
+	hash_table[i] = UNUSED;
     }
-    for (i = 0; i < CAPTABSIZE; i++) {
-	hashvalue = hash_function(table[i].nte_name);
+    for (i = 0; i < tablesize; i++) {
+	hashvalue = hash_function(table[i].ute_name);
 
 	if (hash_table[hashvalue] >= 0)
 	    collisions++;
 
-	if (hash_table[hashvalue] != 0)
-	    table[i].nte_link = hash_table[hashvalue];
-	hash_table[hashvalue] = i;
+	if (hash_table[hashvalue] != UNUSED) {
+	    table[i].ute_link = hash_table[hashvalue];
+	}
+	hash_table[hashvalue] = (HashValue) i;
     }
 
-    printf("/* %d collisions out of %d entries */\n", collisions, CAPTABSIZE);
+    printf("/* %d collisions out of %d entries */\n", collisions, tablesize);
 }
 
 /*
@@ -156,10 +168,18 @@
 
     int col = 0;
 
-    if (list == 0 && (list = typeCalloc(char *, (MAX_COLUMNS + 1))) == 0)
-	  return (0);
+    if (buffer == 0) {
+	free(list);
+	list = 0;
+	return 0;
+    }
 
     if (*buffer != '#') {
+	if (list == 0) {
+	    list = typeCalloc(char *, (MAX_COLUMNS + 1));
+	    if (list == 0)
+		return (0);
+	}
 	while (*buffer != '\0') {
 	    char *s;
 	    for (s = buffer; (*s != '\0') && !isspace(UChar(*s)); s++)
@@ -188,21 +208,58 @@
     return col ? list : 0;
 }
 
+#define SetType(n,t) \
+	if (is_user) \
+	    name_table[n].ute_type |= (int)(1 << (t)); \
+	else \
+	    name_table[n].ute_type = (t)
+
+#define GetType(n) \
+	(is_user \
+	 ? get_type(name_table[n].ute_type) \
+	 : typenames[name_table[n].ute_type])
+
+static char *
+get_type(int type_mask)
+{
+    static char result[80];
+    unsigned n;
+    _nc_STRCPY(result, L_PAREN, sizeof(result));
+    for (n = 0; n < 3; ++n) {
+	if ((1 << n) & type_mask) {
+	    size_t want = 5 + strlen(typenames[n]);
+	    if (want > sizeof(result)) {
+		fprintf(stderr, "Buffer is not large enough for %s + %s\n",
+			result, typenames[n]);
+		exit(EXIT_FAILURE);
+	    }
+	    if (result[1])
+		_nc_STRCAT(result, "|", sizeof(result));
+	    _nc_STRCAT(result, "1<<", sizeof(result));
+	    _nc_STRCAT(result, typenames[n], sizeof(result));
+	}
+    }
+    _nc_STRCAT(result, R_PAREN, sizeof(result));
+    return result;
+}
+
 int
 main(int argc, char **argv)
 {
-    struct name_table_entry *name_table = typeCalloc(struct
-						     name_table_entry, CAPTABSIZE);
+    unsigned tablesize = CAPTABSIZE;
+    struct user_table_entry *name_table = typeCalloc(struct
+						     user_table_entry, tablesize);
     HashValue *hash_table = typeCalloc(HashValue, HASHTABSIZE);
-    const char *root_name = "";
+    const char *root_name;
     int column = 0;
     int bigstring = 0;
-    int n;
+    unsigned n;
+    unsigned nn;
+    unsigned tableused = 0;
+    bool is_user;
+    const char *table_name;
     char buffer[BUFSIZ];
 
-    static const char *typenames[] =
-    {"BOOLEAN", "NUMBER", "STRING"};
-
     short BoolCount = 0;
     short NumCount = 0;
     short StrCount = 0;
@@ -220,42 +277,80 @@
 	fprintf(stderr, "usage: make_hash column root_name bigstring\n");
 	exit(EXIT_FAILURE);
     }
+    is_user = (*root_name == 'u');
+    table_name = (is_user ? "user" : "name");
 
     /*
      * Read the table into our arrays.
      */
-    for (n = 0; (n < CAPTABSIZE) && fgets(buffer, BUFSIZ, stdin);) {
-	char **list, *nlp = strchr(buffer, '\n');
+    for (n = 0; (n < tablesize) && fgets(buffer, BUFSIZ, stdin);) {
+	char **list;
+	char *nlp = strchr(buffer, '\n');
 	if (nlp)
 	    *nlp = '\0';
+	else
+	    buffer[sizeof(buffer) - 2] = '\0';
 	list = parse_columns(buffer);
 	if (list == 0)		/* blank or comment */
 	    continue;
-	if (column > count_columns(list)) {
+	if (is_user) {
+	    if (strcmp(list[0], "userdef"))
+		continue;
+	} else if (!strcmp(list[0], "userdef")) {
+	    continue;
+	}
+	if (column < 0 || column > count_columns(list)) {
 	    fprintf(stderr, "expected %d columns, have %d:\n%s\n",
 		    column,
 		    count_columns(list),
 		    buffer);
 	    exit(EXIT_FAILURE);
 	}
-	name_table[n].nte_link = -1;	/* end-of-hash */
-	name_table[n].nte_name = strmalloc(list[column]);
+	nn = tableused;
+	if (is_user) {
+	    unsigned j;
+	    for (j = 0; j < tableused; ++j) {
+		if (!strcmp(list[column], name_table[j].ute_name)) {
+		    nn = j;
+		    break;
+		}
+	    }
+	}
+	if (nn == tableused) {
+	    name_table[nn].ute_link = -1;	/* end-of-hash */
+	    name_table[nn].ute_name = strmalloc(list[column]);
+	    ++tableused;
+	}
+
 	if (!strcmp(list[2], "bool")) {
-	    name_table[n].nte_type = BOOLEAN;
-	    name_table[n].nte_index = BoolCount++;
+	    SetType(nn, BOOLEAN);
+	    name_table[nn].ute_index = BoolCount++;
 	} else if (!strcmp(list[2], "num")) {
-	    name_table[n].nte_type = NUMBER;
-	    name_table[n].nte_index = NumCount++;
+	    SetType(nn, NUMBER);
+	    name_table[nn].ute_index = NumCount++;
 	} else if (!strcmp(list[2], "str")) {
-	    name_table[n].nte_type = STRING;
-	    name_table[n].nte_index = StrCount++;
+	    SetType(nn, STRING);
+	    name_table[nn].ute_index = StrCount++;
+	    if (is_user) {
+		if (*list[3] != '-') {
+		    unsigned j;
+		    name_table[nn].ute_argc = (unsigned) strlen(list[3]);
+		    for (j = 0; j < name_table[nn].ute_argc; ++j) {
+			if (list[3][j] == 's') {
+			    name_table[nn].ute_args |= (1U << j);
+			}
+		    }
+		}
+	    }
 	} else {
 	    fprintf(stderr, "Unknown type: %s\n", list[2]);
 	    exit(EXIT_FAILURE);
 	}
 	n++;
     }
-    _nc_make_hash_table(name_table, hash_table);
+    if (tablesize > tableused)
+	tablesize = tableused;
+    _nc_make_hash_table(name_table, hash_table, tablesize);
 
     /*
      * Write the compiled tables to standard output
@@ -265,66 +360,86 @@
 	int nxt;
 
 	printf("static const char %s_names_text[] = \\\n", root_name);
-	for (n = 0; n < CAPTABSIZE; n++) {
-	    nxt = (int) strlen(name_table[n].nte_name) + 5;
+	for (n = 0; n < tablesize; n++) {
+	    nxt = (int) strlen(name_table[n].ute_name) + 5;
 	    if (nxt + len > 72) {
 		printf("\\\n");
 		len = 0;
 	    }
-	    printf("\"%s\\0\" ", name_table[n].nte_name);
+	    printf("\"%s\\0\" ", name_table[n].ute_name);
 	    len += nxt;
 	}
 	printf(";\n\n");
 
 	len = 0;
-	printf("static name_table_data const %s_names_data[] =\n",
+	printf("static %s_table_data const %s_names_data[] =\n",
+	       table_name,
 	       root_name);
-	printf("{\n");
-	for (n = 0; n < CAPTABSIZE; n++) {
-	    printf("\t{ %15d,\t%10s,\t%3d, %3d }%c\n",
-		   len,
-		   typenames[name_table[n].nte_type],
-		   name_table[n].nte_index,
-		   name_table[n].nte_link,
-		   n < CAPTABSIZE - 1 ? ',' : ' ');
-	    len += (int) strlen(name_table[n].nte_name) + 1;
+	printf("%s\n", L_BRACE);
+	for (n = 0; n < tablesize; n++) {
+	    printf("\t%s %15d,\t%10s,", L_BRACE, len, GetType(n));
+	    if (is_user)
+		printf("\t%d,%d,",
+		       name_table[n].ute_argc,
+		       name_table[n].ute_args);
+	    printf("\t%3d, %3d %s%c\n",
+		   name_table[n].ute_index,
+		   name_table[n].ute_link,
+		   R_BRACE,
+		   n < tablesize - 1 ? ',' : ' ');
+	    len += (int) strlen(name_table[n].ute_name) + 1;
 	}
-	printf("};\n\n");
-	printf("static struct name_table_entry *_nc_%s_table = 0;\n\n", root_name);
+	printf("%s;\n\n", R_BRACE);
+	printf("static struct %s_table_entry *_nc_%s_table = 0;\n\n",
+	       table_name,
+	       root_name);
     } else {
 
-	printf("static struct name_table_entry const _nc_%s_table[] =\n",
+	printf("static struct %s_table_entry const _nc_%s_table[] =\n",
+	       table_name,
 	       root_name);
-	printf("{\n");
-	for (n = 0; n < CAPTABSIZE; n++) {
+	printf("%s\n", L_BRACE);
+	for (n = 0; n < tablesize; n++) {
 	    _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) "\"%s\"",
-			name_table[n].nte_name);
-	    printf("\t{ %15s,\t%10s,\t%3d, %3d }%c\n",
-		   buffer,
-		   typenames[name_table[n].nte_type],
-		   name_table[n].nte_index,
-		   name_table[n].nte_link,
-		   n < CAPTABSIZE - 1 ? ',' : ' ');
+			name_table[n].ute_name);
+	    printf("\t%s %15s,\t%10s,", L_BRACE, buffer, GetType(n));
+	    if (is_user)
+		printf("\t%d,%d,",
+		       name_table[n].ute_argc,
+		       name_table[n].ute_args);
+	    printf("\t%3d, %3d %s%c\n",
+		   name_table[n].ute_index,
+		   name_table[n].ute_link,
+		   R_BRACE,
+		   n < tablesize - 1 ? ',' : ' ');
 	}
-	printf("};\n\n");
+	printf("%s;\n\n", R_BRACE);
     }
 
     printf("static const HashValue _nc_%s_hash_table[%d] =\n",
 	   root_name,
 	   HASHTABSIZE + 1);
-    printf("{\n");
+    printf("%s\n", L_BRACE);
     for (n = 0; n < HASHTABSIZE; n++) {
 	printf("\t%3d,\n", hash_table[n]);
     }
     printf("\t0\t/* base-of-table */\n");
-    printf("};\n\n");
+    printf("%s;\n\n", R_BRACE);
 
-    printf("#if (BOOLCOUNT!=%d)||(NUMCOUNT!=%d)||(STRCOUNT!=%d)\n",
-	   BoolCount, NumCount, StrCount);
-    printf("#error\t--> term.h and comp_captab.c disagree about the <--\n");
-    printf("#error\t--> numbers of booleans, numbers and/or strings <--\n");
-    printf("#endif\n\n");
+    if (!is_user) {
+	printf("#if (BOOLCOUNT!=%d)||(NUMCOUNT!=%d)||(STRCOUNT!=%d)\n",
+	       BoolCount, NumCount, StrCount);
+	printf("#error\t--> term.h and comp_captab.c disagree about the <--\n");
+	printf("#error\t--> numbers of booleans, numbers and/or strings <--\n");
+	printf("#endif\n\n");
+    }
 
     free(hash_table);
+    for (n = 0; (n < tablesize); ++n) {
+	free((void *) name_table[n].ute_name);
+    }
+    free(name_table);
+    parse_columns(0);
+
     return EXIT_SUCCESS;
 }
diff --git a/ncurses/tinfo/make_keys.c b/ncurses/tinfo/make_keys.c
index fa0c2f2..b8eb934 100644
--- a/ncurses/tinfo/make_keys.c
+++ b/ncurses/tinfo/make_keys.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2015 Free Software Foundation, Inc.              *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 1998-2011,2015 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
 #define USE_TERMLIB 1
 #include <build.priv.h>
 
-MODULE_ID("$Id: make_keys.c,v 1.21 2015/07/16 01:10:03 tom Exp $")
+MODULE_ID("$Id: make_keys.c,v 1.23 2021/08/18 20:55:25 tom Exp $")
 
 #include <names.c>
 
@@ -127,11 +128,13 @@
 {
     static const char *prefix[] =
     {
-	"#ifndef NCU_KEYS_H",
-	"#define NCU_KEYS_H 1",
+	"#ifndef _INIT_KEYTRY_H",
+	"#define _INIT_KEYTRY_H 1",
 	"",
 	"/* This file was generated by MAKE_KEYS */",
 	"",
+	"#include <tic.h>",
+	"",
 	"#if BROKEN_LINKER",
 	"static",
 	"#endif",
@@ -142,7 +145,7 @@
     {
 	"\t{ 0, 0} };",
 	"",
-	"#endif /* NCU_KEYS_H */",
+	"#endif /* _INIT_KEYTRY_H */",
 	0
     };
 
diff --git a/ncurses/tinfo/name_match.c b/ncurses/tinfo/name_match.c
index c648535..71e584d 100644
--- a/ncurses/tinfo/name_match.c
+++ b/ncurses/tinfo/name_match.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1999-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2013,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -33,7 +34,7 @@
 #include <curses.priv.h>
 #include <tic.h>
 
-MODULE_ID("$Id: name_match.c,v 1.23 2013/05/25 20:20:08 tom Exp $")
+MODULE_ID("$Id: name_match.c,v 1.25 2020/02/02 23:34:34 tom Exp $")
 
 #define FirstName _nc_globals.first_name
 
@@ -58,8 +59,6 @@
 NCURSES_EXPORT(char *)
 _nc_first_name(const char *const sp)
 {
-    unsigned n;
-
 #if NO_LEAKS
     if (sp == 0) {
 	if (FirstName != 0) {
@@ -72,6 +71,7 @@
 	    FirstName = typeMalloc(char, MAX_NAME_SIZE + 1);
 
 	if (FirstName != 0) {
+	    unsigned n;
 	    const char *src = sp;
 #if NCURSES_USE_TERMCAP && NCURSES_XNAMES
 	    src = skip_index(sp);
@@ -93,11 +93,13 @@
 NCURSES_EXPORT(int)
 _nc_name_match(const char *const namelst, const char *const name, const char *const delim)
 {
-    const char *s, *d, *t;
-    int code, found;
+    const char *s;
 
     if ((s = namelst) != 0) {
 	while (*s != '\0') {
+	    const char *d, *t;
+	    int code, found;
+
 	    for (d = name; *d != '\0'; d++) {
 		if (*s != *d)
 		    break;
diff --git a/ncurses/tinfo/obsolete.c b/ncurses/tinfo/obsolete.c
index 63476dc..cc62f18 100644
--- a/ncurses/tinfo/obsolete.c
+++ b/ncurses/tinfo/obsolete.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2013,2014 Free Software Foundation, Inc.                   *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 2013-2014,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -36,10 +37,10 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: obsolete.c,v 1.3 2014/10/11 02:39:35 tom Exp $")
+MODULE_ID("$Id: obsolete.c,v 1.11 2023/10/21 15:38:47 tom Exp $")
 
 /*
- * Obsolete entrypoint retained for binary compatbility.
+ * Obsolete entrypoint retained for binary compatibility.
  */
 NCURSES_EXPORT(void)
 NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_DCLx FILE *ofp, int buffered)
@@ -68,7 +69,7 @@
 	size_t need = strlen(s);
 	result = malloc(need + 1);
 	if (result != 0) {
-	    strcpy(result, s);
+	    _nc_STRCPY(result, s, need);
 	}
     }
     return result;
@@ -237,3 +238,98 @@
 #undef CH
 }
 #endif /* EXP_XTERM_1005 */
+
+#ifdef EXP_OOM_TESTING
+/*
+ * Out-of-memory testing, suitable for checking if initialization (and limited
+ * running) recovers from errors due to insufficient memory.  In practice, this
+ * is unlikely except with artificially constructed tests (or poorly behaved
+ * applications).
+ */
+#undef malloc
+#undef calloc
+#undef realloc
+#undef free
+#undef strdup
+
+#define TR_OOM(stmt) T(stmt)
+
+static long oom_limit = -1;
+static long oom_count = 0;
+
+static bool
+oom_check(void)
+{
+    static bool initialized = FALSE;
+    static bool triggered = FALSE;
+    bool result = FALSE;
+
+    if (!initialized) {
+	char *env = getenv("NCURSES_OOM_TESTING");
+	initialized = TRUE;
+	if (env != NULL) {
+	    char *check;
+	    oom_limit = strtol(env, &check, 0);
+	    if (check != NULL && *check != '\0')
+		oom_limit = 0;
+	}
+    }
+    ++oom_count;
+    if (oom_limit >= 0) {
+	result = (oom_count > oom_limit);
+	if (result && !triggered) {
+	    triggered = TRUE;
+	    TR_OOM(("out-of-memory"));
+	}
+    }
+    return result;
+}
+
+NCURSES_EXPORT(void *)
+_nc_oom_malloc(size_t size)
+{
+    char *result = (oom_check()
+		    ? NULL
+		    : malloc(size));
+    TR_OOM(("oom #%ld malloc(%ld) %p", oom_count, size, result));
+    return result;
+}
+
+NCURSES_EXPORT(void *)
+_nc_oom_calloc(size_t nmemb, size_t size)
+{
+    char *result = (oom_check()
+		    ? NULL
+		    : calloc(nmemb, size));
+    TR_OOM(("oom #%ld calloc(%ld, %ld) %p", oom_count, nmemb, size, result));
+    return result;
+}
+
+NCURSES_EXPORT(void *)
+_nc_oom_realloc(void *ptr, size_t size)
+{
+    char *result = (oom_check()
+		    ? NULL
+		    : realloc(ptr, size));
+    TR_OOM(("oom #%ld realloc(%p, %ld) %p", oom_count, ptr, size, result));
+    return result;
+}
+
+NCURSES_EXPORT(void)
+_nc_oom_free(void *ptr)
+{
+    ++oom_count;
+    TR_OOM(("oom #%ld free(%p)", oom_count, ptr));
+    free(ptr);
+}
+
+NCURSES_EXPORT(char *)
+_nc_oom_strdup(const char *ptr)
+{
+    char *result = (oom_check()
+		    ? NULL
+		    : strdup(ptr));
+    TR_OOM(("oom #%ld strdup(%p) %p", oom_count, ptr, result));
+    return result;
+}
+#endif /* EXP_OOM_TESTING */
diff --git a/ncurses/tinfo/parse_entry.c b/ncurses/tinfo/parse_entry.c
index 0dc1414..13fef49 100644
--- a/ncurses/tinfo/parse_entry.c
+++ b/ncurses/tinfo/parse_entry.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -47,7 +48,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: parse_entry.c,v 1.80 2015/04/04 14:18:38 tom Exp $")
+MODULE_ID("$Id: parse_entry.c,v 1.108 2023/04/24 22:32:33 tom Exp $")
 
 #ifdef LINT
 static short const parametrized[] =
@@ -56,17 +57,17 @@
 #include <parametrized.h>
 #endif
 
-static void postprocess_termcap(TERMTYPE *, bool);
-static void postprocess_terminfo(TERMTYPE *);
+static void postprocess_termcap(TERMTYPE2 *, bool);
+static void postprocess_terminfo(TERMTYPE2 *);
 static struct name_table_entry const *lookup_fullname(const char *name);
 
 #if NCURSES_XNAMES
 
 static struct name_table_entry const *
-_nc_extend_names(ENTRY * entryp, char *name, int token_type)
+_nc_extend_names(ENTRY * entryp, const char *name, int token_type)
 {
     static struct name_table_entry temp;
-    TERMTYPE *tp = &(entryp->tterm);
+    TERMTYPE2 *tp = &(entryp->tterm);
     unsigned offset = 0;
     unsigned actual;
     unsigned tindex;
@@ -109,7 +110,7 @@
 	/* Well, we are given a cancel for a name that we don't recognize */
 	return _nc_extend_names(entryp, name, STRING);
     default:
-	return 0;
+	return NULL;
     }
 
     /* Adjust the 'offset' (insertion-point) to keep the lists of extended
@@ -141,6 +142,11 @@
 	for (last = (unsigned) (max - 1); last > tindex; last--)
 
     if (!found) {
+	char *saved;
+
+	if ((saved = _nc_save_str(name)) == NULL)
+	    return NULL;
+
 	switch (token_type) {
 	case BOOLEAN:
 	    tp->ext_Booleans++;
@@ -152,7 +158,7 @@
 	case NUMBER:
 	    tp->ext_Numbers++;
 	    tp->num_Numbers++;
-	    TYPE_REALLOC(short, tp->num_Numbers, tp->Numbers);
+	    TYPE_REALLOC(NCURSES_INT2, tp->num_Numbers, tp->Numbers);
 	    for_each_value(tp->num_Numbers)
 		tp->Numbers[last] = tp->Numbers[last - 1];
 	    break;
@@ -168,7 +174,7 @@
 	TYPE_REALLOC(char *, actual, tp->ext_Names);
 	while (--actual > offset)
 	    tp->ext_Names[actual] = tp->ext_Names[actual - 1];
-	tp->ext_Names[offset] = _nc_save_str(name);
+	tp->ext_Names[offset] = saved;
     }
 
     temp.nte_name = tp->ext_Names[offset];
@@ -178,9 +184,79 @@
 
     return &temp;
 }
+
+static const char *
+usertype2s(int mask)
+{
+    const char *result = "unknown";
+    if (mask & (1 << BOOLEAN)) {
+	result = "boolean";
+    } else if (mask & (1 << NUMBER)) {
+	result = "number";
+    } else if (mask & (1 << STRING)) {
+	result = "string";
+    }
+    return result;
+}
+
+static bool
+expected_type(const char *name, int token_type, bool silent)
+{
+    struct user_table_entry const *entry = _nc_find_user_entry(name);
+    bool result = TRUE;
+    if ((entry != 0) && (token_type != CANCEL)) {
+	int have_type = (1 << token_type);
+	if (!(entry->ute_type & have_type)) {
+	    if (!silent)
+		_nc_warning("expected %s-type for %s, have %s",
+			    usertype2s(entry->ute_type),
+			    name,
+			    usertype2s(have_type));
+	    result = FALSE;
+	}
+    }
+    return result;
+}
 #endif /* NCURSES_XNAMES */
 
 /*
+ * A valid entry name uses characters from the "portable character set"
+ * (more commonly referred to as US-ASCII), and disallows some of the
+ * punctuation characters:
+ *
+ * '/' is a pathname separator
+ * '\' may be a pathname separator, but more important, is an escape
+ * '|' delimits names and description
+ * '#' denotes a numeric value
+ * '=' denotes a string value
+ * '@' denotes a cancelled symbol
+ * ',' separates terminfo capabilities
+ * ':' separates termcap capabilities
+ *
+ * Termcap capability names may begin with a '#' or '@' (since they have
+ * exactly two characters).
+ */
+static bool
+valid_entryname(const char *name)
+{
+    bool result = TRUE;
+    bool first = TRUE;
+    int ch;
+    while ((ch = UChar(*name++)) != '\0') {
+	if (ch <= ' ' || ch > '~' || strchr("/\\|=,:", ch) != NULL) {
+	    result = FALSE;
+	    break;
+	}
+	if (!first && strchr("#@", ch) != NULL) {
+	    result = FALSE;
+	    break;
+	}
+	first = FALSE;
+    }
+    return result;
+}
+
+/*
  *	int
  *	_nc_parse_entry(entry, literal, silent)
  *
@@ -203,24 +279,29 @@
  	{ bad_tc_usage = TRUE; \
 	 _nc_warning("Legacy termcap allows only a trailing tc= clause"); }
 
-#define MAX_NUMBER 0x7fff	/* positive shorts only */
+#define MAX_NUMBER MAX_OF_TYPE(NCURSES_INT2)
 
 NCURSES_EXPORT(int)
-_nc_parse_entry(struct entry *entryp, int literal, bool silent)
+_nc_parse_entry(ENTRY * entryp, int literal, bool silent)
 {
     int token_type;
     struct name_table_entry const *entry_ptr;
     char *ptr, *base;
+    const char *name;
     bool bad_tc_usage = FALSE;
 
+    TR(TRACE_DATABASE,
+       (T_CALLED("_nc_parse_entry(entry=%p, literal=%d, silent=%d)"),
+	(void *) entryp, literal, silent));
+
     token_type = _nc_get_token(silent);
 
     if (token_type == EOF)
-	return (EOF);
+	returnDB(EOF);
     if (token_type != NAMES)
 	_nc_err_abort("Entry does not start with terminal names in column one");
 
-    _nc_init_entry(&entryp->tterm);
+    _nc_init_entry(entryp);
 
     entryp->cstart = _nc_comment_start;
     entryp->cend = _nc_comment_end;
@@ -236,13 +317,14 @@
      * implemented it.  Note that the resulting terminal type was never the
      * 2-character name, but was instead the first alias after that.
      */
+#define ok_TC2(s) (isgraph(UChar(s)) && (s) != '|')
     ptr = _nc_curr_token.tk_name;
     if (_nc_syntax == SYN_TERMCAP
 #if NCURSES_XNAMES
 	&& !_nc_user_definable
 #endif
 	) {
-	if (ptr[2] == '|') {
+	if (ok_TC2(ptr[0]) && ok_TC2(ptr[1]) && (ptr[2] == '|')) {
 	    ptr += 3;
 	    _nc_curr_token.tk_name[2] = '\0';
 	}
@@ -251,16 +333,21 @@
     entryp->tterm.str_table = entryp->tterm.term_names = _nc_save_str(ptr);
 
     if (entryp->tterm.str_table == 0)
-	return (ERR);
+	returnDB(ERR);
 
-    DEBUG(1, ("Starting '%s'", ptr));
+    DEBUG(2, ("Starting '%s'", ptr));
 
     /*
      * We do this because the one-token lookahead in the parse loop
      * results in the terminal type getting prematurely set to correspond
      * to that of the next entry.
      */
-    _nc_set_type(_nc_first_name(entryp->tterm.term_names));
+    name = _nc_first_name(entryp->tterm.term_names);
+    if (!valid_entryname(name)) {
+	_nc_warning("invalid entry name \"%s\"", name);
+	name = "invalid";
+    }
+    _nc_set_type(name);
 
     /* check for overly-long names and aliases */
     for (base = entryp->tterm.term_names; (ptr = strchr(base, '|')) != 0;
@@ -282,11 +369,28 @@
 	bool is_use = (strcmp(_nc_curr_token.tk_name, "use") == 0);
 	bool is_tc = !is_use && (strcmp(_nc_curr_token.tk_name, "tc") == 0);
 	if (is_use || is_tc) {
-	    entryp->uses[entryp->nuses].name = _nc_save_str(_nc_curr_token.tk_valstring);
-	    entryp->uses[entryp->nuses].line = _nc_curr_line;
-	    entryp->nuses++;
-	    if (entryp->nuses > 1 && is_tc) {
-		BAD_TC_USAGE
+	    char *saved;
+
+	    if (!VALID_STRING(_nc_curr_token.tk_valstring)
+		|| _nc_curr_token.tk_valstring[0] == '\0') {
+		_nc_warning("missing name for use-clause");
+		continue;
+	    } else if (!valid_entryname(_nc_curr_token.tk_valstring)) {
+		_nc_warning("invalid name for use-clause \"%s\"",
+			    _nc_curr_token.tk_valstring);
+		continue;
+	    } else if (entryp->nuses >= MAX_USES) {
+		_nc_warning("too many use-clauses, ignored \"%s\"",
+			    _nc_curr_token.tk_valstring);
+		continue;
+	    }
+	    if ((saved = _nc_save_str(_nc_curr_token.tk_valstring)) != NULL) {
+		entryp->uses[entryp->nuses].name = saved;
+		entryp->uses[entryp->nuses].line = _nc_curr_line;
+		entryp->nuses++;
+		if (entryp->nuses > 1 && is_tc) {
+		    BAD_TC_USAGE
+		}
 	    }
 	} else {
 	    /* normal token lookup */
@@ -294,7 +398,7 @@
 				       _nc_get_hash_table(_nc_syntax));
 
 	    /*
-	     * Our kluge to handle aliasing.  The reason it's done
+	     * Our kluge to handle aliasing.  The reason it is done
 	     * this ugly way, with a linear search, is so the hashing
 	     * machinery doesn't have to be made really complicated
 	     * (also we get better warnings this way).  No point in
@@ -351,12 +455,20 @@
 	     * define a name based on its context.
 	     */
 	    if (entry_ptr == NOTFOUND
-		&& _nc_user_definable
-		&& (entry_ptr = _nc_extend_names(entryp,
-						 _nc_curr_token.tk_name,
-						 token_type)) != 0) {
-		if (_nc_tracing >= DEBUG_LEVEL(1))
-		    _nc_warning("extended capability '%s'", _nc_curr_token.tk_name);
+		&& _nc_user_definable) {
+		if (expected_type(_nc_curr_token.tk_name, token_type, silent)) {
+		    if ((entry_ptr = _nc_extend_names(entryp,
+						      _nc_curr_token.tk_name,
+						      token_type)) != 0) {
+			if (_nc_tracing >= DEBUG_LEVEL(1)) {
+			    _nc_warning("extended capability '%s'",
+					_nc_curr_token.tk_name);
+			}
+		    }
+		} else {
+		    /* ignore it: we have already printed error message */
+		    continue;
+		}
 	    }
 #endif /* NCURSES_XNAMES */
 
@@ -369,7 +481,16 @@
 	    }
 
 	    /* deal with bad type/value combinations. */
-	    if (token_type != CANCEL && entry_ptr->nte_type != token_type) {
+	    if (token_type == CANCEL) {
+		/*
+		 * Prefer terminfo in this (long-obsolete) ambiguity:
+		 */
+		if (!strcmp("ma", _nc_curr_token.tk_name)) {
+		    entry_ptr = _nc_find_type_entry("ma", NUMBER,
+						    _nc_syntax != 0);
+		    assert(entry_ptr != 0);
+		}
+	    } else if (entry_ptr->nte_type != token_type) {
 		/*
 		 * Nasty special cases here handle situations in which type
 		 * information can resolve name clashes.  Normal lookup
@@ -446,20 +567,27 @@
 		break;
 
 	    case NUMBER:
+#if !NCURSES_EXT_NUMBERS
 		if (_nc_curr_token.tk_valnumber > MAX_NUMBER) {
 		    entryp->tterm.Numbers[entry_ptr->nte_index] = MAX_NUMBER;
-		} else {
+		} else
+#endif
+		{
 		    entryp->tterm.Numbers[entry_ptr->nte_index] =
-			(short) _nc_curr_token.tk_valnumber;
+			(NCURSES_INT2) _nc_curr_token.tk_valnumber;
 		}
 		break;
 
 	    case STRING:
 		ptr = _nc_curr_token.tk_valstring;
-		if (_nc_syntax == SYN_TERMCAP)
+		if (_nc_syntax == SYN_TERMCAP) {
+		    int n = entry_ptr->nte_index;
 		    ptr = _nc_captoinfo(_nc_curr_token.tk_name,
 					ptr,
-					parametrized[entry_ptr->nte_index]);
+					(n < (int) SIZEOF(parametrized))
+					? parametrized[n]
+					: 0);
+		}
 		entryp->tterm.Strings[entry_ptr->nte_index] = _nc_save_str(ptr);
 		break;
 
@@ -486,23 +614,26 @@
     if (!literal) {
 	if (_nc_syntax == SYN_TERMCAP) {
 	    bool has_base_entry = FALSE;
-	    unsigned i;
 
 	    /*
 	     * Don't insert defaults if this is a `+' entry meant only
 	     * for inclusion in other entries (not sure termcap ever
 	     * had these, actually).
 	     */
-	    if (strchr(entryp->tterm.term_names, '+'))
+	    if (strchr(entryp->tterm.term_names, '+')) {
 		has_base_entry = TRUE;
-	    else
+	    } else {
+		unsigned i;
 		/*
 		 * Otherwise, look for a base entry that will already
 		 * have picked up defaults via translation.
 		 */
-		for (i = 0; i < entryp->nuses; i++)
-		    if (!strchr((char *) entryp->uses[i].name, '+'))
+		for (i = 0; i < entryp->nuses; i++) {
+		    if (entryp->uses[i].name != 0
+			&& !strchr(entryp->uses[i].name, '+'))
 			has_base_entry = TRUE;
+		}
+	    }
 
 	    postprocess_termcap(&entryp->tterm, has_base_entry);
 	} else
@@ -510,59 +641,66 @@
     }
     _nc_wrap_entry(entryp, FALSE);
 
-    return (OK);
+    returnDB(OK);
 }
 
 NCURSES_EXPORT(int)
 _nc_capcmp(const char *s, const char *t)
 /* compare two string capabilities, stripping out padding */
 {
-    if (!VALID_STRING(s) && !VALID_STRING(t))
-	return (0);
-    else if (!VALID_STRING(s) || !VALID_STRING(t))
-	return (1);
+    bool ok_s = VALID_STRING(s);
+    bool ok_t = VALID_STRING(t);
 
-    for (;;) {
-	if (s[0] == '$' && s[1] == '<') {
-	    for (s += 2;; s++)
-		if (!(isdigit(UChar(*s))
-		      || *s == '.'
-		      || *s == '*'
-		      || *s == '/'
-		      || *s == '>'))
-		    break;
+    if (ok_s && ok_t) {
+	for (;;) {
+	    if (s[0] == '$' && s[1] == '<') {
+		for (s += 2;; s++) {
+		    if (!(isdigit(UChar(*s))
+			  || *s == '.'
+			  || *s == '*'
+			  || *s == '/'
+			  || *s == '>')) {
+			break;
+		    }
+		}
+	    }
+
+	    if (t[0] == '$' && t[1] == '<') {
+		for (t += 2;; t++) {
+		    if (!(isdigit(UChar(*t))
+			  || *t == '.'
+			  || *t == '*'
+			  || *t == '/'
+			  || *t == '>')) {
+			break;
+		    }
+		}
+	    }
+
+	    /* we've now pushed s and t past any padding they pointed at */
+
+	    if (*s == '\0' && *t == '\0')
+		return (0);
+
+	    if (*s != *t)
+		return (*t - *s);
+
+	    /* else *s == *t but one is not NUL, so continue */
+	    s++, t++;
 	}
-
-	if (t[0] == '$' && t[1] == '<') {
-	    for (t += 2;; t++)
-		if (!(isdigit(UChar(*t))
-		      || *t == '.'
-		      || *t == '*'
-		      || *t == '/'
-		      || *t == '>'))
-		    break;
-	}
-
-	/* we've now pushed s and t past any padding they were pointing at */
-
-	if (*s == '\0' && *t == '\0')
-	    return (0);
-
-	if (*s != *t)
-	    return (*t - *s);
-
-	/* else *s == *t but one is not NUL, so continue */
-	s++, t++;
+    } else if (ok_s || ok_t) {
+	return 1;
     }
+    return 0;
 }
 
 static void
-append_acs0(string_desc * dst, int code, int src)
+append_acs0(string_desc * dst, int code, char *src, size_t off)
 {
-    if (src != 0) {
+    if (src != 0 && off < strlen(src)) {
 	char temp[3];
 	temp[0] = (char) code;
-	temp[1] = (char) src;
+	temp[1] = src[off];
 	temp[2] = 0;
 	_nc_safe_strcat(dst, temp);
     }
@@ -571,8 +709,8 @@
 static void
 append_acs(string_desc * dst, int code, char *src)
 {
-    if (src != 0 && strlen(src) == 1) {
-	append_acs0(dst, code, *src);
+    if (VALID_STRING(src) && strlen(src) == 1) {
+	append_acs0(dst, code, src, 0);
     }
 }
 
@@ -621,13 +759,6 @@
 static const char C_HT[] = "\t";
 
 /*
- * Note that WANTED and PRESENT are not simple inverses!  If a capability
- * has been explicitly cancelled, it's not considered WANTED.
- */
-#define WANTED(s)	((s) == ABSENT_STRING)
-#define PRESENT(s)	(((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
-
-/*
  * This bit of legerdemain turns all the terminfo variable names into
  * references to locations in the arrays Booleans, Numbers, and Strings ---
  * precisely what's needed.
@@ -637,11 +768,15 @@
 #define CUR tp->
 
 static void
-postprocess_termcap(TERMTYPE *tp, bool has_base)
+postprocess_termcap(TERMTYPE2 *tp, bool has_base)
 {
     char buf[MAX_LINE * 2 + 2];
     string_desc result;
 
+    TR(TRACE_DATABASE,
+       (T_CALLED("postprocess_termcap(tp=%p, has_base=%d)"),
+	(void *) tp, has_base));
+
     /*
      * TERMCAP DEFAULTS AND OBSOLETE-CAPABILITY TRANSLATIONS
      *
@@ -652,10 +787,10 @@
 
     /* if there was a tc entry, assume we picked up defaults via that */
     if (!has_base) {
-	if (WANTED(init_3string) && termcap_init2)
+	if (WANTED(init_3string) && PRESENT(termcap_init2))
 	    init_3string = _nc_save_str(termcap_init2);
 
-	if (WANTED(reset_2string) && termcap_reset)
+	if (WANTED(reset_2string) && PRESENT(termcap_reset))
 	    reset_2string = _nc_save_str(termcap_reset);
 
 	if (WANTED(carriage_return)) {
@@ -770,7 +905,7 @@
 	if (init_tabs != 8 && init_tabs != ABSENT_NUMERIC)
 	    _nc_warning("hardware tabs with a width other than 8: %d", init_tabs);
 	else {
-	    if (tab && _nc_capcmp(tab, C_HT))
+	    if (PRESENT(tab) && _nc_capcmp(tab, C_HT))
 		_nc_warning("hardware tabs with a non-^I tab string %s",
 			    _nc_visbuf(tab));
 	    else {
@@ -832,15 +967,14 @@
 	    }
 
 	    if (tp->Strings[to_ptr->nte_index]) {
-		/* There's no point in warning about it if it's the same
+		const char *s = tp->Strings[from_ptr->nte_index];
+		const char *t = tp->Strings[to_ptr->nte_index];
+		/* There's no point in warning about it if it is the same
 		 * string; that's just an inefficiency.
 		 */
-		if (strcmp(
-			      tp->Strings[from_ptr->nte_index],
-			      tp->Strings[to_ptr->nte_index]) != 0)
+		if (VALID_STRING(s) && VALID_STRING(t) && strcmp(s, t) != 0)
 		    _nc_warning("%s (%s) already has an explicit value %s, ignoring ko",
-				ap->to, ap->from,
-				_nc_visbuf(tp->Strings[to_ptr->nte_index]));
+				ap->to, ap->from, t);
 		continue;
 	    }
 
@@ -848,17 +982,22 @@
 	     * The magic moment -- copy the mapped key string over,
 	     * stripping out padding.
 	     */
-	    for (dp = buf2, bp = tp->Strings[from_ptr->nte_index]; *bp; bp++) {
-		if (bp[0] == '$' && bp[1] == '<') {
-		    while (*bp && *bp != '>') {
-			++bp;
-		    }
-		} else
-		    *dp++ = *bp;
-	    }
-	    *dp = '\0';
+	    bp = tp->Strings[from_ptr->nte_index];
+	    if (VALID_STRING(bp)) {
+		for (dp = buf2; *bp; bp++) {
+		    if (bp[0] == '$' && bp[1] == '<') {
+			while (*bp && *bp != '>') {
+			    ++bp;
+			}
+		    } else
+			*dp++ = *bp;
+		}
+		*dp = '\0';
 
-	    tp->Strings[to_ptr->nte_index] = _nc_save_str(buf2);
+		tp->Strings[to_ptr->nte_index] = _nc_save_str(buf2);
+	    } else {
+		tp->Strings[to_ptr->nte_index] = bp;
+	    }
 	}
 
 	/*
@@ -867,7 +1006,7 @@
 	 * got mapped to kich1 and im to kIC to avoid a collision.
 	 * If the description has im but not ic, hack kIC back to kich1.
 	 */
-	if (foundim && WANTED(key_ic) && key_sic) {
+	if (foundim && WANTED(key_ic) && PRESENT(key_sic)) {
 	    key_ic = key_sic;
 	    key_sic = ABSENT_STRING;
 	}
@@ -919,16 +1058,21 @@
 	    acs_chars = _nc_save_str(buf2);
 	    _nc_warning("acsc string synthesized from XENIX capabilities");
 	}
-    } else if (acs_chars == 0
-	       && enter_alt_charset_mode != 0
-	       && exit_alt_charset_mode != 0) {
+    } else if (acs_chars == ABSENT_STRING
+	       && PRESENT(enter_alt_charset_mode)
+	       && PRESENT(exit_alt_charset_mode)) {
 	acs_chars = _nc_save_str(VT_ACSC);
     }
+    returnVoidDB;
 }
 
 static void
-postprocess_terminfo(TERMTYPE *tp)
+postprocess_terminfo(TERMTYPE2 *tp)
 {
+    TR(TRACE_DATABASE,
+       (T_CALLED("postprocess_terminfo(tp=%p)"),
+	(void *) tp));
+
     /*
      * TERMINFO-TO-TERMINFO MAPPINGS FOR SOURCE TRANSLATION
      * ----------------------------------------------------------------------
@@ -944,17 +1088,17 @@
 	_nc_str_init(&result, buf2, sizeof(buf2));
 	_nc_safe_strcat(&result, acs_chars);
 
-	append_acs0(&result, 'l', box_chars_1[0]);	/* ACS_ULCORNER */
-	append_acs0(&result, 'q', box_chars_1[1]);	/* ACS_HLINE */
-	append_acs0(&result, 'k', box_chars_1[2]);	/* ACS_URCORNER */
-	append_acs0(&result, 'x', box_chars_1[3]);	/* ACS_VLINE */
-	append_acs0(&result, 'j', box_chars_1[4]);	/* ACS_LRCORNER */
-	append_acs0(&result, 'm', box_chars_1[5]);	/* ACS_LLCORNER */
-	append_acs0(&result, 'w', box_chars_1[6]);	/* ACS_TTEE */
-	append_acs0(&result, 'u', box_chars_1[7]);	/* ACS_RTEE */
-	append_acs0(&result, 'v', box_chars_1[8]);	/* ACS_BTEE */
-	append_acs0(&result, 't', box_chars_1[9]);	/* ACS_LTEE */
-	append_acs0(&result, 'n', box_chars_1[10]);	/* ACS_PLUS */
+	append_acs0(&result, 'l', box_chars_1, 0);	/* ACS_ULCORNER */
+	append_acs0(&result, 'q', box_chars_1, 1);	/* ACS_HLINE */
+	append_acs0(&result, 'k', box_chars_1, 2);	/* ACS_URCORNER */
+	append_acs0(&result, 'x', box_chars_1, 3);	/* ACS_VLINE */
+	append_acs0(&result, 'j', box_chars_1, 4);	/* ACS_LRCORNER */
+	append_acs0(&result, 'm', box_chars_1, 5);	/* ACS_LLCORNER */
+	append_acs0(&result, 'w', box_chars_1, 6);	/* ACS_TTEE */
+	append_acs0(&result, 'u', box_chars_1, 7);	/* ACS_RTEE */
+	append_acs0(&result, 'v', box_chars_1, 8);	/* ACS_BTEE */
+	append_acs0(&result, 't', box_chars_1, 9);	/* ACS_LTEE */
+	append_acs0(&result, 'n', box_chars_1, 10);	/* ACS_PLUS */
 
 	if (buf2[0]) {
 	    acs_chars = _nc_save_str(buf2);
@@ -965,6 +1109,7 @@
     /*
      * ----------------------------------------------------------------------
      */
+    returnVoidDB;
 }
 
 /*
diff --git a/ncurses/tinfo/read_entry.c b/ncurses/tinfo/read_entry.c
index 81fdc46..b0f360e 100644
--- a/ncurses/tinfo/read_entry.c
+++ b/ncurses/tinfo/read_entry.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -41,15 +42,87 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: read_entry.c,v 1.129 2015/06/27 16:16:40 tom Exp $")
-
-#define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
+MODULE_ID("$Id: read_entry.c,v 1.171 2023/09/16 16:30:34 tom Exp $")
 
 #define MyNumber(n) (short) LOW_MSB(n)
 
+#define SIZEOF_32BITS 4
+
 #if NCURSES_USE_DATABASE
-static void
-convert_shorts(char *buf, short *Numbers, int count)
+#if NCURSES_EXT_NUMBERS
+static size_t
+convert_16bits(char *buf, NCURSES_INT2 *Numbers, int count)
+{
+    int i;
+    size_t j;
+    size_t size = SIZEOF_SHORT;
+    for (i = 0; i < count; i++) {
+	unsigned mask = 0xff;
+	unsigned char ch = 0;
+	Numbers[i] = 0;
+	for (j = 0; j < size; ++j) {
+	    ch = UChar(*buf++);
+	    Numbers[i] |= (ch << (8 * j));
+	    mask <<= 8;
+	}
+	if (ch & 0x80) {
+	    while (mask != 0) {
+		Numbers[i] |= (int) mask;
+		mask <<= 8;
+	    }
+	}
+	TR(TRACE_DATABASE, ("get Numbers[%d]=%d", i, Numbers[i]));
+    }
+    return size;
+}
+
+static size_t
+convert_32bits(char *buf, NCURSES_INT2 *Numbers, int count)
+{
+    int i;
+    size_t j;
+    size_t size = SIZEOF_INT2;
+    unsigned char ch;
+
+    assert(sizeof(NCURSES_INT2) == size);
+    for (i = 0; i < count; i++) {
+	Numbers[i] = 0;
+	for (j = 0; j < size; ++j) {
+	    ch = UChar(*buf++);
+	    Numbers[i] |= (ch << (8 * j));
+	}
+	/* "unsigned" and NCURSES_INT2 are the same size - no sign-extension */
+	TR(TRACE_DATABASE, ("get Numbers[%d]=%d", i, Numbers[i]));
+    }
+    return size;
+}
+#else
+static size_t
+convert_32bits(char *buf, NCURSES_INT2 *Numbers, int count)
+{
+    int i, j;
+    unsigned char ch;
+    for (i = 0; i < count; i++) {
+	int value = 0;
+	for (j = 0; j < SIZEOF_32BITS; ++j) {
+	    ch = UChar(*buf++);
+	    value |= (ch << (8 * j));
+	}
+	if (value == -1)
+	    Numbers[i] = ABSENT_NUMERIC;
+	else if (value == -2)
+	    Numbers[i] = CANCELLED_NUMERIC;
+	else if (value > MAX_OF_TYPE(NCURSES_INT2))
+	    Numbers[i] = MAX_OF_TYPE(NCURSES_INT2);
+	else
+	    Numbers[i] = (short) value;
+	TR(TRACE_DATABASE, ("get Numbers[%d]=%d", i, Numbers[i]));
+    }
+    return SIZEOF_SHORT;
+}
+
+static size_t
+convert_16bits(char *buf, NCURSES_INT2 *Numbers, int count)
 {
     int i;
     for (i = 0; i < count; i++) {
@@ -61,13 +134,17 @@
 	    Numbers[i] = MyNumber(buf + 2 * i);
 	TR(TRACE_DATABASE, ("get Numbers[%d]=%d", i, Numbers[i]));
     }
+    return SIZEOF_SHORT;
 }
+#endif
 
-static void
-convert_strings(char *buf, char **Strings, int count, int size, char *table)
+static bool
+convert_strings(char *buf, char **Strings, int count, int size,
+		char *table, bool always)
 {
     int i;
     char *p;
+    bool success = TRUE;
 
     for (i = 0; i < count; i++) {
 	if (IS_NEG1(buf + 2 * i)) {
@@ -77,20 +154,44 @@
 	} else if (MyNumber(buf + 2 * i) > size) {
 	    Strings[i] = ABSENT_STRING;
 	} else {
-	    Strings[i] = (MyNumber(buf + 2 * i) + table);
-	    TR(TRACE_DATABASE, ("Strings[%d] = %s", i, _nc_visbuf(Strings[i])));
+	    int nn = MyNumber(buf + 2 * i);
+	    if (nn >= 0 && nn < size) {
+		Strings[i] = (nn + table);
+		TR(TRACE_DATABASE, ("Strings[%d] = %s", i,
+				    _nc_visbuf(Strings[i])));
+	    } else {
+		TR(TRACE_DATABASE,
+		   ("found out-of-range index %d to Strings[%d]", nn, i));
+		success = FALSE;
+		break;
+	    }
 	}
 
 	/* make sure all strings are NUL terminated */
 	if (VALID_STRING(Strings[i])) {
-	    for (p = Strings[i]; p <= table + size; p++)
+	    for (p = Strings[i]; p < table + size; p++)
 		if (*p == '\0')
 		    break;
 	    /* if there is no NUL, ignore the string */
-	    if (p > table + size)
+	    if (p >= table + size) {
 		Strings[i] = ABSENT_STRING;
+	    } else if (p == Strings[i] && always) {
+		TR(TRACE_DATABASE,
+		   ("found empty but required Strings[%d]", i));
+		success = FALSE;
+		break;
+	    }
+	} else if (always) {	/* names are always needed */
+	    TR(TRACE_DATABASE,
+	       ("found invalid but required Strings[%d]", i));
+	    success = FALSE;
+	    break;
 	}
     }
+    if (!success) {
+	_nc_warning("corrupt data found in convert_strings");
+    }
+    return success;
 }
 
 static int
@@ -112,17 +213,22 @@
 #define Read(buf, count) fake_read(buffer, &offset, limit, (char *) buf, (unsigned) count)
 
 #define read_shorts(buf, count) \
-	(Read(buf, (count)*2) == (int) (count)*2)
+	(Read(buf, (count)*SIZEOF_SHORT) == (int) (count)*SIZEOF_SHORT)
+
+#define read_numbers(buf, count) \
+	(Read(buf, (count)*(unsigned)size_of_numbers) == (int) (count)*size_of_numbers)
 
 #define even_boundary(value) \
     if ((value) % 2 != 0) Read(buf, 1)
 #endif
 
 NCURSES_EXPORT(void)
-_nc_init_termtype(TERMTYPE *const tp)
+_nc_init_termtype(TERMTYPE2 *const tp)
 {
     unsigned i;
 
+    DEBUG(2, (T_CALLED("_nc_init_termtype(tp=%p)"), (void *) tp));
+
 #if NCURSES_XNAMES
     tp->num_Booleans = BOOLCOUNT;
     tp->num_Numbers = NUMCOUNT;
@@ -134,7 +240,7 @@
     if (tp->Booleans == 0)
 	TYPE_MALLOC(NCURSES_SBOOL, BOOLCOUNT, tp->Booleans);
     if (tp->Numbers == 0)
-	TYPE_MALLOC(short, NUMCOUNT, tp->Numbers);
+	TYPE_MALLOC(NCURSES_INT2, NUMCOUNT, tp->Numbers);
     if (tp->Strings == 0)
 	TYPE_MALLOC(char *, STRCOUNT, tp->Strings);
 
@@ -146,6 +252,8 @@
 
     for_each_string(i, tp)
 	tp->Strings[i] = ABSENT_STRING;
+
+    DEBUG(2, (T_RETURN("")));
 }
 
 #if NCURSES_USE_DATABASE
@@ -169,7 +277,7 @@
  * Return TGETENT_YES if read, TGETENT_NO if not found or garbled.
  */
 NCURSES_EXPORT(int)
-_nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit)
+_nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit)
 {
     int offset = 0;
     int name_size, bool_count, num_count, str_count, str_size;
@@ -177,6 +285,13 @@
     char buf[MAX_ENTRY_SIZE + 2];
     char *string_table;
     unsigned want, have;
+    size_t (*convert_numbers) (char *, NCURSES_INT2 *, int);
+    int size_of_numbers;
+    int max_entry_size = MAX_ENTRY_SIZE;
+
+    TR(TRACE_DATABASE,
+       (T_CALLED("_nc_read_termtype(ptr=%p, buffer=%p, limit=%d)"),
+	(void *) ptr, buffer, limit));
 
     TR(TRACE_DATABASE, ("READ termtype header @%d", offset));
 
@@ -185,14 +300,33 @@
     /* grab the header */
     if (!read_shorts(buf, 6)
 	|| !IS_TIC_MAGIC(buf)) {
-	return (TGETENT_NO);
+	returnDB(TGETENT_NO);
     }
+#if NCURSES_EXT_NUMBERS
+    if (LOW_MSB(buf) == MAGIC2) {
+	convert_numbers = convert_32bits;
+	size_of_numbers = SIZEOF_INT2;
+    } else {
+	max_entry_size = MAX_ENTRY_SIZE1;
+	convert_numbers = convert_16bits;
+	size_of_numbers = SIZEOF_SHORT;
+    }
+#else
+    if (LOW_MSB(buf) == MAGIC2) {
+	convert_numbers = convert_32bits;
+	size_of_numbers = SIZEOF_32BITS;
+    } else {
+	convert_numbers = convert_16bits;
+	size_of_numbers = SIZEOF_INT2;
+    }
+#endif
 
-    name_size = MyNumber(buf + 2);
+    /* *INDENT-EQLS* */
+    name_size  = MyNumber(buf + 2);
     bool_count = MyNumber(buf + 4);
-    num_count = MyNumber(buf + 6);
-    str_count = MyNumber(buf + 8);
-    str_size = MyNumber(buf + 10);
+    num_count  = MyNumber(buf + 6);
+    str_count  = MyNumber(buf + 8);
+    str_size   = MyNumber(buf + 10);
 
     TR(TRACE_DATABASE,
        ("TERMTYPE name_size=%d, bool=%d/%d, num=%d/%d str=%d/%d(%d)",
@@ -202,26 +336,22 @@
 	|| bool_count < 0
 	|| num_count < 0
 	|| str_count < 0
+	|| bool_count > BOOLCOUNT
+	|| num_count > NUMCOUNT
+	|| str_count > STRCOUNT
 	|| str_size < 0) {
-	return (TGETENT_NO);
+	returnDB(TGETENT_NO);
     }
 
     want = (unsigned) (str_size + name_size + 1);
-    if (str_size) {
-	/* try to allocate space for the string table */
-	if (str_count * 2 >= MAX_ENTRY_SIZE
-	    || (string_table = typeMalloc(char, want)) == 0) {
-	    return (TGETENT_NO);
-	}
-    } else {
-	str_count = 0;
-	if ((string_table = typeMalloc(char, want)) == 0) {
-	    return (TGETENT_NO);
-	}
+    /* try to allocate space for the string table */
+    if (str_count * SIZEOF_SHORT >= max_entry_size
+	|| (string_table = typeMalloc(char, want)) == 0) {
+	returnDB(TGETENT_NO);
     }
 
     /* grab the name (a null-terminated string) */
-    want = min(MAX_NAME_SIZE, (unsigned) name_size);
+    want = Min(MAX_NAME_SIZE, (unsigned) name_size);
     ptr->str_table = string_table;
     ptr->term_names = string_table;
     if ((have = (unsigned) Read(ptr->term_names, want)) != want) {
@@ -234,10 +364,9 @@
 	offset = (int) (have - MAX_NAME_SIZE);
 
     /* grab the booleans */
-    if ((ptr->Booleans = TYPE_CALLOC(NCURSES_SBOOL,
-				     max(BOOLCOUNT, bool_count))) == 0
-	|| Read(ptr->Booleans, (unsigned) bool_count) < bool_count) {
-	return (TGETENT_NO);
+    TYPE_CALLOC(NCURSES_SBOOL, Max(BOOLCOUNT, bool_count), ptr->Booleans);
+    if (Read(ptr->Booleans, (unsigned) bool_count) < bool_count) {
+	returnDB(TGETENT_NO);
     }
 
     /*
@@ -249,26 +378,27 @@
     even_boundary(name_size + bool_count);
 
     /* grab the numbers */
-    if ((ptr->Numbers = TYPE_CALLOC(short, max(NUMCOUNT, num_count))) == 0
-	|| !read_shorts(buf, num_count)) {
-	return (TGETENT_NO);
+    TYPE_CALLOC(NCURSES_INT2, Max(NUMCOUNT, num_count), ptr->Numbers);
+    if (!read_numbers(buf, num_count)) {
+	returnDB(TGETENT_NO);
     }
-    convert_shorts(buf, ptr->Numbers, num_count);
+    convert_numbers(buf, ptr->Numbers, num_count);
 
-    if ((ptr->Strings = TYPE_CALLOC(char *, max(STRCOUNT, str_count))) == 0) {
-	return (TGETENT_NO);
-    }
+    TYPE_CALLOC(char *, Max(STRCOUNT, str_count), ptr->Strings);
 
     if (str_count) {
 	/* grab the string offsets */
 	if (!read_shorts(buf, str_count)) {
-	    return (TGETENT_NO);
+	    returnDB(TGETENT_NO);
 	}
 	/* finally, grab the string table itself */
 	if (Read(string_table, (unsigned) str_size) != str_size) {
-	    return (TGETENT_NO);
+	    returnDB(TGETENT_NO);
 	}
-	convert_strings(buf, ptr->Strings, str_count, str_size, string_table);
+	if (!convert_strings(buf, ptr->Strings, str_count, str_size,
+			     string_table, FALSE)) {
+	    returnDB(TGETENT_NO);
+	}
     }
 #if NCURSES_XNAMES
 
@@ -285,20 +415,20 @@
 	int ext_bool_count = MyNumber(buf + 0);
 	int ext_num_count = MyNumber(buf + 2);
 	int ext_str_count = MyNumber(buf + 4);
-	int ext_str_size = MyNumber(buf + 6);
+	int ext_str_usage = MyNumber(buf + 6);
 	int ext_str_limit = MyNumber(buf + 8);
 	unsigned need = (unsigned) (ext_bool_count + ext_num_count + ext_str_count);
 	int base = 0;
 
-	if (need >= (MAX_ENTRY_SIZE / 2)
-	    || ext_str_size >= MAX_ENTRY_SIZE
-	    || ext_str_limit >= MAX_ENTRY_SIZE
+	if ((int) need >= (max_entry_size / 2)
+	    || ext_str_usage >= max_entry_size
+	    || ext_str_limit >= max_entry_size
 	    || ext_bool_count < 0
 	    || ext_num_count < 0
 	    || ext_str_count < 0
-	    || ext_str_size < 0
+	    || ext_str_usage < 0
 	    || ext_str_limit < 0) {
-	    return (TGETENT_NO);
+	    returnDB(TGETENT_NO);
 	}
 
 	ptr->num_Booleans = UShort(BOOLCOUNT + ext_bool_count);
@@ -306,19 +436,25 @@
 	ptr->num_Strings = UShort(STRCOUNT + ext_str_count);
 
 	TYPE_REALLOC(NCURSES_SBOOL, ptr->num_Booleans, ptr->Booleans);
-	TYPE_REALLOC(short, ptr->num_Numbers, ptr->Numbers);
+	TYPE_REALLOC(NCURSES_INT2, ptr->num_Numbers, ptr->Numbers);
 	TYPE_REALLOC(char *, ptr->num_Strings, ptr->Strings);
 
-	TR(TRACE_DATABASE, ("extended header is %d/%d/%d(%d:%d)",
-			    ext_bool_count, ext_num_count, ext_str_count,
-			    ext_str_size, ext_str_limit));
+	TR(TRACE_DATABASE, ("extended header: "
+			    "bool %d, "
+			    "number %d, "
+			    "string %d(%d:%d)",
+			    ext_bool_count,
+			    ext_num_count,
+			    ext_str_count,
+			    ext_str_usage,
+			    ext_str_limit));
 
 	TR(TRACE_DATABASE, ("READ %d extended-booleans @%d",
 			    ext_bool_count, offset));
 	if ((ptr->ext_Booleans = UShort(ext_bool_count)) != 0) {
 	    if (Read(ptr->Booleans + BOOLCOUNT, (unsigned)
 		     ext_bool_count) != ext_bool_count) {
-		return (TGETENT_NO);
+		returnDB(TGETENT_NO);
 	    }
 	}
 	even_boundary(ext_bool_count);
@@ -326,20 +462,20 @@
 	TR(TRACE_DATABASE, ("READ %d extended-numbers @%d",
 			    ext_num_count, offset));
 	if ((ptr->ext_Numbers = UShort(ext_num_count)) != 0) {
-	    if (!read_shorts(buf, ext_num_count)) {
-		return (TGETENT_NO);
+	    if (!read_numbers(buf, ext_num_count)) {
+		returnDB(TGETENT_NO);
 	    }
 	    TR(TRACE_DATABASE, ("Before converting extended-numbers"));
-	    convert_shorts(buf, ptr->Numbers + NUMCOUNT, ext_num_count);
+	    convert_numbers(buf, ptr->Numbers + NUMCOUNT, ext_num_count);
 	}
 
 	TR(TRACE_DATABASE, ("READ extended-offsets @%d", offset));
-	if ((unsigned) (ext_str_count + (int) need) >= (MAX_ENTRY_SIZE / 2)) {
-	    return (TGETENT_NO);
+	if ((ext_str_count + (int) need) >= (max_entry_size / 2)) {
+	    returnDB(TGETENT_NO);
 	}
 	if ((ext_str_count || need)
 	    && !read_shorts(buf, ext_str_count + (int) need)) {
-	    return (TGETENT_NO);
+	    returnDB(TGETENT_NO);
 	}
 
 	TR(TRACE_DATABASE, ("READ %d bytes of extended-strings @%d",
@@ -348,47 +484,63 @@
 	if (ext_str_limit) {
 	    ptr->ext_str_table = typeMalloc(char, (size_t) ext_str_limit);
 	    if (ptr->ext_str_table == 0) {
-		return (TGETENT_NO);
+		returnDB(TGETENT_NO);
 	    }
 	    if (Read(ptr->ext_str_table, (unsigned) ext_str_limit) != ext_str_limit) {
-		return (TGETENT_NO);
+		returnDB(TGETENT_NO);
 	    }
 	    TR(TRACE_DATABASE, ("first extended-string is %s", _nc_visbuf(ptr->ext_str_table)));
 	}
 
 	if ((ptr->ext_Strings = UShort(ext_str_count)) != 0) {
+	    int check = (ext_bool_count + ext_num_count + ext_str_count);
+
 	    TR(TRACE_DATABASE,
-	       ("Before computing extended-string capabilities str_count=%d, ext_str_count=%d",
+	       ("Before computing extended-string capabilities "
+		"str_count=%d, ext_str_count=%d",
 		str_count, ext_str_count));
-	    convert_strings(buf, ptr->Strings + str_count, ext_str_count,
-			    ext_str_limit, ptr->ext_str_table);
+	    if (!convert_strings(buf, ptr->Strings + str_count, ext_str_count,
+				 ext_str_limit, ptr->ext_str_table, FALSE)) {
+		returnDB(TGETENT_NO);
+	    }
 	    for (i = ext_str_count - 1; i >= 0; i--) {
 		TR(TRACE_DATABASE, ("MOVE from [%d:%d] %s",
 				    i, i + str_count,
 				    _nc_visbuf(ptr->Strings[i + str_count])));
 		ptr->Strings[i + STRCOUNT] = ptr->Strings[i + str_count];
-		if (VALID_STRING(ptr->Strings[i + STRCOUNT]))
+		if (VALID_STRING(ptr->Strings[i + STRCOUNT])) {
 		    base += (int) (strlen(ptr->Strings[i + STRCOUNT]) + 1);
+		    ++check;
+		}
 		TR(TRACE_DATABASE, ("... to    [%d] %s",
 				    i + STRCOUNT,
 				    _nc_visbuf(ptr->Strings[i + STRCOUNT])));
 	    }
+	    TR(TRACE_DATABASE, ("Check table-size: %d/%d", check, ext_str_usage));
+#if 0
+	    /*
+	     * Phasing in a proper check will be done "later".
+	     */
+	    if (check != ext_str_usage)
+		returnDB(TGETENT_NO);
+#endif
 	}
 
 	if (need) {
-	    if (ext_str_count >= (MAX_ENTRY_SIZE / 2)) {
-		return (TGETENT_NO);
+	    if (ext_str_count >= (max_entry_size / 2)) {
+		returnDB(TGETENT_NO);
 	    }
-	    if ((ptr->ext_Names = TYPE_CALLOC(char *, need)) == 0) {
-		return (TGETENT_NO);
-	    }
+	    TYPE_CALLOC(char *, need, ptr->ext_Names);
 	    TR(TRACE_DATABASE,
 	       ("ext_NAMES starting @%d in extended_strings, first = %s",
 		base, _nc_visbuf(ptr->ext_str_table + base)));
-	    convert_strings(buf + (2 * ext_str_count),
-			    ptr->ext_Names,
-			    (int) need,
-			    ext_str_limit, ptr->ext_str_table + base);
+	    if (!convert_strings(buf + (2 * ext_str_count),
+				 ptr->ext_Names,
+				 (int) need,
+				 ext_str_limit, ptr->ext_str_table + base,
+				 TRUE)) {
+		returnDB(TGETENT_NO);
+	    }
 	}
 
 	TR(TRACE_DATABASE,
@@ -415,7 +567,7 @@
     for (i = str_count; i < STRCOUNT; i++)
 	ptr->Strings[i] = ABSENT_STRING;
 
-    return (TGETENT_YES);
+    returnDB(TGETENT_YES);
 }
 
 /*
@@ -427,26 +579,31 @@
  *	table.
  */
 NCURSES_EXPORT(int)
-_nc_read_file_entry(const char *const filename, TERMTYPE *ptr)
+_nc_read_file_entry(const char *const filename, TERMTYPE2 *ptr)
 /* return 1 if read, 0 if not found or garbled */
 {
     FILE *fp = 0;
     int code;
-    int limit;
-    char buffer[MAX_ENTRY_SIZE + 1];
 
     if (_nc_access(filename, R_OK) < 0
-	|| (fp = fopen(filename, "rb")) == 0) {
+	|| (fp = safe_fopen(filename, BIN_R)) == 0) {
 	TR(TRACE_DATABASE, ("cannot open terminfo %s (errno=%d)", filename, errno));
 	code = TGETENT_NO;
     } else {
-	if ((limit = (int) fread(buffer, sizeof(char), sizeof(buffer), fp))
-	    > 0) {
+	int limit;
+	char buffer[MAX_ENTRY_SIZE + 1];
+
+	limit = (int) fread(buffer, sizeof(char), sizeof(buffer), fp);
+	if (limit > 0) {
+	    const char *old_source = _nc_get_source();
 
 	    TR(TRACE_DATABASE, ("read terminfo %s", filename));
+	    if (old_source == NULL)
+		_nc_set_source(filename);
 	    if ((code = _nc_read_termtype(ptr, buffer, limit)) == TGETENT_NO) {
-		_nc_free_termtype(ptr);
+		_nc_free_termtype2(ptr);
 	    }
+	    _nc_set_source(old_source);
 	} else {
 	    code = TGETENT_NO;
 	}
@@ -508,6 +665,105 @@
     return result;
 }
 
+static int
+lookup_b64(int *target, const char **source)
+{
+    int result = 3;
+    int j;
+    /*
+     * ncurses' quickdump writes only RFC 4648 "url/filename-safe" encoding,
+     * but accepts RFC-3548
+     */
+    for (j = 0; j < 4; ++j) {
+	int ch = UChar(**source);
+	*source += 1;
+	if (ch >= 'A' && ch <= 'Z') {
+	    target[j] = (ch - 'A');
+	} else if (ch >= 'a' && ch <= 'z') {
+	    target[j] = 26 + (ch - 'a');
+	} else if (ch >= '0' && ch <= '9') {
+	    target[j] = 52 + (ch - '0');
+	} else if (ch == '-' || ch == '+') {
+	    target[j] = 62;
+	} else if (ch == '_' || ch == '/') {
+	    target[j] = 63;
+	} else if (ch == '=') {
+	    target[j] = 64;
+	    result--;
+	} else {
+	    result = -1;
+	    break;
+	}
+    }
+    return result;
+}
+
+static int
+decode_hex(const char **source)
+{
+    int result = 0;
+    int nibble;
+
+    for (nibble = 0; nibble < 2; ++nibble) {
+	int ch = UChar(**source);
+	result <<= 4;
+	*source += 1;
+	if (ch >= '0' && ch <= '9') {
+	    ch -= '0';
+	} else if (ch >= 'A' && ch <= 'F') {
+	    ch -= 'A';
+	    ch += 10;
+	} else if (ch >= 'a' && ch <= 'f') {
+	    ch -= 'a';
+	    ch += 10;
+	} else {
+	    result = -1;
+	    break;
+	}
+	result |= ch;
+    }
+    return result;
+}
+
+static int
+decode_quickdump(char *target, const char *source)
+{
+    char *base = target;
+    int result = 0;
+
+    if (!strncmp(source, "b64:", (size_t) 4)) {
+	source += 4;
+	while (*source != '\0') {
+	    int bits[4];
+	    int ch = lookup_b64(bits, &source);
+	    if (ch < 0 || (ch + target - base) >= MAX_ENTRY_SIZE) {
+		result = 0;
+		break;
+	    }
+	    result += ch;
+	    *target++ = (char) ((bits[0] << 2) | (bits[1] >> 4));
+	    if (bits[2] < 64) {
+		*target++ = (char) ((bits[1] << 4) | (bits[2] >> 2));
+		if (bits[3] < 64) {
+		    *target++ = (char) ((bits[2] << 6) | bits[3]);
+		}
+	    }
+	}
+    } else if (!strncmp(source, "hex:", (size_t) 4)) {
+	source += 4;
+	while (*source != '\0') {
+	    int ch = decode_hex(&source);
+	    if (ch < 0 || (target - base) >= MAX_ENTRY_SIZE) {
+		result = 0;
+		break;
+	    }
+	    *target++ = (char) ch;
+	    ++result;
+	}
+    }
+    return result;
+}
+
 /*
  * Build a terminfo pathname and try to read the data.  Returns TGETENT_YES on
  * success, TGETENT_NO on failure.
@@ -517,20 +773,39 @@
 		   unsigned limit,
 		   const char *const path,
 		   const char *name,
-		   TERMTYPE *const tp)
+		   TERMTYPE2 *const tp)
 {
     int code = TGETENT_NO;
-
 #if USE_HASHED_DB
     DB *capdbp;
+#endif
+    char buffer[MAX_ENTRY_SIZE + 1];
+    int used;
 
-    if (make_db_filename(filename, limit, path)
-	&& (capdbp = _nc_db_open(filename, FALSE)) != 0) {
+    TR(TRACE_DATABASE,
+       (T_CALLED("_nc_read_tic_entry(file=%p, path=%s, name=%s)"),
+	filename, path, name));
+
+    assert(TGETENT_YES == TRUE);	/* simplify call for _nc_name_match */
+
+    if ((used = decode_quickdump(buffer, path)) != 0
+	&& (code = _nc_read_termtype(tp, buffer, used)) == TGETENT_YES
+	&& (code = _nc_name_match(tp->term_names, name, "|")) == TGETENT_YES) {
+	TR(TRACE_DATABASE, ("loaded quick-dump for %s", name));
+	/* shorten name shown by infocmp */
+	_nc_STRCPY(filename, "$TERMINFO", limit);
+    } else
+#if USE_HASHED_DB
+	if (make_db_filename(filename, limit, path)
+	    && (capdbp = _nc_db_open(filename, FALSE)) != 0) {
 
 	DBT key, data;
 	int reccnt = 0;
 	char *save = strdup(name);
 
+	if (save == 0)
+	    returnDB(code);
+
 	memset(&key, 0, sizeof(key));
 	key.data = save;
 	key.size = strlen(save);
@@ -540,7 +815,7 @@
 	 * looking for compiled (binary) terminfo data.
 	 *
 	 * cgetent uses a two-level lookup.  On the first it uses the given
-	 * name to return a record containing only the aliases for an entry. 
+	 * name to return a record containing only the aliases for an entry.
 	 * On the second (using that list of aliases as a key), it returns the
 	 * content of the terminal description.  We expect second lookup to
 	 * return data beginning with the same set of aliases.
@@ -551,15 +826,15 @@
 	 * (source/binary) by checking the lengths.
 	 */
 	while (_nc_db_get(capdbp, &key, &data) == 0) {
-	    int used = (int) data.size - 1;
 	    char *have = (char *) data.data;
+	    used = (int) data.size - 1;
 
 	    if (*have++ == 0) {
 		if (data.size > key.size
 		    && IS_TIC_MAGIC(have)) {
 		    code = _nc_read_termtype(tp, have, used);
 		    if (code == TGETENT_NO) {
-			_nc_free_termtype(tp);
+			_nc_free_termtype2(tp);
 		    }
 		}
 		break;
@@ -586,30 +861,29 @@
 	code = _nc_read_file_entry(filename, tp);
     }
 #if NCURSES_USE_TERMCAP
-    else if (code != TGETENT_YES) {
+    if (code != TGETENT_YES) {
 	code = _nc_read_termcap_entry(name, tp);
 	_nc_SPRINTF(filename, _nc_SLIMIT(PATH_MAX)
 		    "%.*s", PATH_MAX - 1, _nc_get_source());
     }
 #endif
-    return code;
+    returnDB(code);
 }
 #endif /* NCURSES_USE_DATABASE */
 
 /*
- *	_nc_read_entry(char *name, char *filename, TERMTYPE *tp)
- *
- *	Find and read the compiled entry for a given terminal type,
- *	if it exists.  We take pains here to make sure no combination
- *	of environment variables and terminal type name can be used to
- *	overrun the file buffer.
+ * Find and read the compiled entry for a given terminal type, if it exists.
+ * We take pains here to make sure no combination of environment variables and
+ * terminal type name can be used to overrun the file buffer.
  */
-
 NCURSES_EXPORT(int)
-_nc_read_entry(const char *const name, char *const filename, TERMTYPE *const tp)
+_nc_read_entry2(const char *const name, char *const filename, TERMTYPE2 *const tp)
 {
     int code = TGETENT_NO;
 
+    if (name == 0)
+	return _nc_read_entry2("", filename, tp);
+
     _nc_SPRINTF(filename, _nc_SLIMIT(PATH_MAX)
 		"%.*s", PATH_MAX - 1, name);
 
@@ -628,7 +902,6 @@
 	_nc_first_db(&state, &offset);
 	code = TGETENT_ERR;
 	while ((path = _nc_next_db(&state, &offset)) != 0) {
-	    TR(TRACE_DATABASE, ("_nc_read_tic_entry path=%s, name=%s", path, name));
 	    code = _nc_read_tic_entry(filename, PATH_MAX, path, name, tp);
 	    if (code == TGETENT_YES) {
 		_nc_last_db();
@@ -645,3 +918,16 @@
     }
     return code;
 }
+
+#if NCURSES_EXT_NUMBERS
+NCURSES_EXPORT(int)
+_nc_read_entry(const char *const name, char *const filename, TERMTYPE *const tp)
+{
+    TERMTYPE2 dummy;
+    int rc;
+    rc = _nc_read_entry2(name, filename, &dummy);
+    if (rc == TGETENT_YES)
+	_nc_export_termtype2(tp, &dummy);
+    return rc;
+}
+#endif
diff --git a/ncurses/tinfo/read_termcap.c b/ncurses/tinfo/read_termcap.c
index 6bfb23c..1a29484 100644
--- a/ncurses/tinfo/read_termcap.c
+++ b/ncurses/tinfo/read_termcap.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -56,7 +57,7 @@
 #include <sys/types.h>
 #include <tic.h>
 
-MODULE_ID("$Id: read_termcap.c,v 1.89 2013/12/15 00:32:43 tom Exp $")
+MODULE_ID("$Id: read_termcap.c,v 1.104 2023/06/24 21:53:16 tom Exp $")
 
 #if !PURE_TERMINFO
 
@@ -66,10 +67,10 @@
 #define TC_REF_LOOP   -3
 #define TC_UNRESOLVED -4	/* this is not returned by BSD cgetent */
 
-static NCURSES_CONST char *
+static const char *
 get_termpath(void)
 {
-    NCURSES_CONST char *result;
+    const char *result;
 
     if (!use_terminfo_vars() || (result = getenv("TERMPATH")) == 0)
 	result = TERMPATH;
@@ -186,7 +187,7 @@
     bp = buf;
     for (;;) {
 	/*
-	 * Skip past the current capability field - it's either the
+	 * Skip past the current capability field - it is either the
 	 * name field if this is the first time through the loop, or
 	 * the remainder of a field whose name failed to match cap.
 	 */
@@ -323,7 +324,7 @@
 	    if (fd >= 0) {
 		(void) lseek(fd, (off_t) 0, SEEK_SET);
 	    } else if ((_nc_access(db_array[current], R_OK) < 0)
-		       || (fd = open(db_array[current], O_RDONLY, 0)) < 0) {
+		       || (fd = safe_open2(db_array[current], O_RDONLY)) < 0) {
 		/* No error on unfound file. */
 		if (errno == ENOENT)
 		    continue;
@@ -364,7 +365,7 @@
 			if (bp >= b_end) {
 			    int n;
 
-			    n = read(fd, buf, sizeof(buf));
+			    n = (int) read(fd, buf, sizeof(buf));
 			    if (n <= 0) {
 				if (myfd)
 				    (void) close(fd);
@@ -393,7 +394,7 @@
 				|| *(rp - 1) != '\\')
 				break;
 			}
-			*rp++ = c;
+			*rp++ = (char) c;
 
 			/*
 			 * Enforce loop invariant: if no room
@@ -404,8 +405,8 @@
 			    unsigned pos;
 			    size_t newsize;
 
-			    pos = rp - record;
-			    newsize = r_end - record + BFRAG;
+			    pos = (unsigned) (rp - record);
+			    newsize = (size_t) (r_end - record + BFRAG);
 			    record = DOALLOC(newsize);
 			    if (record == 0) {
 				if (myfd)
@@ -492,14 +493,14 @@
 		}
 	    }
 	    tcstart = tc - 3;
-	    tclen = s - tcstart;
+	    tclen = (int) (s - tcstart);
 	    tcend = s;
 
 	    icap = 0;
 	    iret = _nc_getent(&icap, &ilen, &oline, current, db_array, fd,
 			      tc, depth + 1, 0);
 	    newicap = icap;	/* Put into a register. */
-	    newilen = ilen;
+	    newilen = (int) ilen;
 	    if (iret != TC_SUCCESS) {
 		/* an error */
 		if (iret < TC_NOT_FOUND) {
@@ -523,7 +524,7 @@
 	    /* not interested in name field of tc'ed record */
 	    s = newicap;
 	    while (*s != '\0' && *s++ != ':') ;
-	    newilen -= s - newicap;
+	    newilen -= (int) (s - newicap);
 	    newicap = s;
 
 	    /* make sure interpolated record is `:'-terminated */
@@ -542,10 +543,10 @@
 		unsigned pos, tcpos, tcposend;
 		size_t newsize;
 
-		pos = rp - record;
-		newsize = r_end - record + diff + BFRAG;
-		tcpos = tcstart - record;
-		tcposend = tcend - record;
+		pos = (unsigned) (rp - record);
+		newsize = (size_t) (r_end - record + diff + BFRAG);
+		tcpos = (unsigned) (tcstart - record);
+		tcposend = (unsigned) (tcend - record);
 		record = DOALLOC(newsize);
 		if (record == 0) {
 		    if (myfd)
@@ -583,7 +584,7 @@
      */
     if (myfd)
 	(void) close(fd);
-    *len = rp - record - 1;	/* don't count NUL */
+    *len = (unsigned) (rp - record - 1);	/* don't count NUL */
     if (r_end > rp) {
 	if ((record = DOALLOC((size_t) (rp - record))) == 0) {
 	    errno = ENOMEM;
@@ -791,7 +792,7 @@
     int i;
     char pathbuf[PBUFSIZ];	/* holds raw path of filenames */
     CGETENT_CONST char *pathvec[PVECSIZ];	/* point to names in pathbuf */
-    NCURSES_CONST char *termpath;
+    const char *termpath;
     string_desc desc;
 
     *lineno = 1;
@@ -802,7 +803,7 @@
     /*
      * TERMCAP can have one of two things in it.  It can be the name of a file
      * to use instead of /etc/termcap.  In this case it better start with a
-     * "/".  Or it can be an entry to use so we don't have to read the file. 
+     * "/".  Or it can be an entry to use so we don't have to read the file.
      * In this case it has to already have the newlines crunched out.  If
      * TERMCAP does not hold a file name then a path of names is searched
      * instead.  The path is found in the TERMPATH variable, or becomes
@@ -956,7 +957,7 @@
 #endif /* !USE_GETCAP */
 
 NCURSES_EXPORT(int)
-_nc_read_termcap_entry(const char *const tn, TERMTYPE *const tp)
+_nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp)
 {
     int found = TGETENT_NO;
     ENTRY *ep;
@@ -965,6 +966,8 @@
 #endif
 #if USE_GETCAP
     char *p, tc[TBUFSIZ];
+    char *tc_buf = 0;
+#define MY_SIZE sizeof(tc) - 1
     int status;
     static char *source;
     static int lineno;
@@ -982,8 +985,7 @@
     if (use_terminfo_vars() && (p = getenv("TERMCAP")) != 0
 	&& !_nc_is_abs_path(p) && _nc_name_match(p, tn, "|:")) {
 	/* TERMCAP holds a termcap entry */
-	strncpy(tc, p, sizeof(tc) - 1);
-	tc[sizeof(tc) - 1] = '\0';
+	tc_buf = strdup(p);
 	_nc_set_source("TERMCAP");
     } else {
 	/* we're using getcap(3) */
@@ -992,8 +994,13 @@
 
 	_nc_curr_line = lineno;
 	_nc_set_source(source);
+	tc_buf = tc;
     }
-    _nc_read_entry_source((FILE *) 0, tc, FALSE, TRUE, NULLHOOK);
+    if (tc_buf == 0)
+	return (TGETENT_ERR);
+    _nc_read_entry_source((FILE *) 0, tc_buf, FALSE, TRUE, NULLHOOK);
+    if (tc_buf != tc)
+	free(tc_buf);
 #else
     /*
      * Here is what the 4.4BSD termcap(3) page prescribes:
@@ -1027,7 +1034,7 @@
     int j, k;
     bool use_buffer = FALSE;
     bool normal = TRUE;
-    char tc_buf[1024];
+    char *tc_buf = 0;
     char pathbuf[PATH_MAX];
     char *copied = 0;
     char *cp;
@@ -1039,10 +1046,8 @@
 	    ADD_TC(tc, 0);
 	    normal = FALSE;
 	} else if (_nc_name_match(tc, tn, "|:")) {	/* treat as a capability file */
-	    use_buffer = TRUE;
-	    _nc_SPRINTF(tc_buf,
-			_nc_SLIMIT(sizeof(tc_buf))
-			"%.*s\n", (int) sizeof(tc_buf) - 2, tc);
+	    tc_buf = strdup(tc);
+	    use_buffer = (tc_buf != 0);
 	    normal = FALSE;
 	}
     }
@@ -1050,23 +1055,25 @@
     if (normal) {		/* normal case */
 	char envhome[PATH_MAX], *h;
 
-	copied = strdup(get_termpath());
-	for (cp = copied; *cp; cp++) {
-	    if (*cp == NCURSES_PATHSEP)
-		*cp = '\0';
-	    else if (cp == copied || cp[-1] == '\0') {
-		ADD_TC(cp, filecount);
+	if ((copied = strdup(get_termpath())) != 0) {
+	    for (cp = copied; *cp; cp++) {
+		if (*cp == NCURSES_PATHSEP)
+		    *cp = '\0';
+		else if (cp == copied || cp[-1] == '\0') {
+		    ADD_TC(cp, filecount);
+		}
 	    }
 	}
-
-#define PRIVATE_CAP "%s/.termcap"
+#define PRIVATE_CAP "%.*s/.termcap"
 
 	if (use_terminfo_vars() && (h = getenv("HOME")) != NULL && *h != '\0'
 	    && (strlen(h) + sizeof(PRIVATE_CAP)) < PATH_MAX) {
 	    /* user's .termcap, if any, should override it */
 	    _nc_STRCPY(envhome, h, sizeof(envhome));
 	    _nc_SPRINTF(pathbuf, _nc_SLIMIT(sizeof(pathbuf))
-			PRIVATE_CAP, envhome);
+			PRIVATE_CAP,
+			(int) (sizeof(pathbuf) - sizeof(PRIVATE_CAP)),
+			envhome);
 	    ADD_TC(pathbuf, filecount);
 	}
     }
@@ -1108,9 +1115,10 @@
 
 	/*
 	 * We don't suppress warning messages here.  The presumption is
-	 * that since it's just a single entry, they won't be a pain.
+	 * that since it is just a single entry, they won't be a pain.
 	 */
 	_nc_read_entry_source((FILE *) 0, tc_buf, FALSE, FALSE, NULLHOOK);
+	free(tc_buf);
     } else {
 	int i;
 
@@ -1118,7 +1126,7 @@
 
 	    TR(TRACE_DATABASE, ("Looking for %s in %s", tn, termpaths[i]));
 	    if (_nc_access(termpaths[i], R_OK) == 0
-		&& (fp = fopen(termpaths[i], "r")) != (FILE *) 0) {
+		&& (fp = safe_fopen(termpaths[i], "r")) != (FILE *) 0) {
 		_nc_set_source(termpaths[i]);
 
 		/*
@@ -1140,7 +1148,8 @@
 	return (TGETENT_ERR);
 
     /* resolve all use references */
-    _nc_resolve_uses2(TRUE, FALSE);
+    if (_nc_resolve_uses2(TRUE, FALSE) != TRUE)
+	return (TGETENT_ERR);
 
     /* find a terminal matching tn, if we can */
 #if USE_GETCAP_CACHE
@@ -1157,7 +1166,7 @@
 		_nc_free_entry(_nc_head, &(ep->tterm));
 
 		/*
-		 * OK, now try to write the type to user's terminfo directory. 
+		 * OK, now try to write the type to user's terminfo directory.
 		 * Next time he loads this, it will come through terminfo.
 		 *
 		 * Advantage:  Second and subsequent fetches of this entry will
diff --git a/ncurses/tinfo/strings.c b/ncurses/tinfo/strings.c
index 393d8e7..03f59c2 100644
--- a/ncurses/tinfo/strings.c
+++ b/ncurses/tinfo/strings.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2000-2007,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 2000-2012,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -35,8 +36,9 @@
 **/
 
 #include <curses.priv.h>
+#include <tic.h>
 
-MODULE_ID("$Id: strings.c,v 1.8 2012/02/22 22:34:31 tom Exp $")
+MODULE_ID("$Id: strings.c,v 1.11 2023/05/27 20:13:10 tom Exp $")
 
 /****************************************************************************
  * Useful string functions (especially for mvcur)
@@ -93,7 +95,7 @@
  * Copy a descriptor
  */
 NCURSES_EXPORT(string_desc *)
-_nc_str_copy(string_desc * dst, string_desc * src)
+_nc_str_copy(string_desc * dst, const string_desc * const src)
 {
     *dst = *src;
     return dst;
@@ -105,7 +107,7 @@
 NCURSES_EXPORT(bool)
 _nc_safe_strcat(string_desc * dst, const char *src)
 {
-    if (src != 0) {
+    if (PRESENT(src)) {
 	size_t len = strlen(src);
 
 	if (len < dst->s_size) {
@@ -126,7 +128,7 @@
 NCURSES_EXPORT(bool)
 _nc_safe_strcpy(string_desc * dst, const char *src)
 {
-    if (src != 0) {
+    if (PRESENT(src)) {
 	size_t len = strlen(src);
 
 	if (len < dst->s_size) {
diff --git a/ncurses/tinfo/tinfo_driver.c b/ncurses/tinfo/tinfo_driver.c
index c6a1c22..fd993b8 100644
--- a/ncurses/tinfo/tinfo_driver.c
+++ b/ncurses/tinfo/tinfo_driver.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2008-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2008-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -28,12 +29,13 @@
 
 /****************************************************************************
  *  Author: Juergen Pfeifer                                                 *
- *                                                                          *
+ *     and: Thomas E. Dickey                                                *
  ****************************************************************************/
 
 #include <curses.priv.h>
-#define CUR ((TERMINAL*)TCB)->type.
+#define CUR TerminalType((TERMINAL*)TCB).
 #include <tic.h>
+#include <termcap.h>		/* ospeed */
 
 #if HAVE_NANOSLEEP
 #include <time.h>
@@ -50,7 +52,7 @@
 # endif
 #endif
 
-MODULE_ID("$Id: tinfo_driver.c,v 1.40 2015/06/27 01:20:41 tom Exp $")
+MODULE_ID("$Id: tinfo_driver.c,v 1.74 2023/09/16 10:44:33 tom Exp $")
 
 /*
  * SCO defines TIOCGSIZE and the corresponding struct.  Other systems (SunOS,
@@ -113,9 +115,43 @@
     return "tinfo";
 }
 
+static void
+get_baudrate(TERMINAL *termp)
+{
+    int my_ospeed;
+    int result;
+    if (GET_TTY(termp->Filedes, &termp->Nttyb) == OK) {
+#ifdef TERMIOS
+	termp->Nttyb.c_oflag &= (unsigned) (~OFLAGS_TABS);
+#elif defined(EXP_WIN32_DRIVER)
+	/* noop */
+#else
+	termp->Nttyb.sg_flags &= (unsigned) (~XTABS);
+#endif
+    }
+#ifdef USE_OLD_TTY
+    result = (int) cfgetospeed(&(termp->Nttyb));
+    my_ospeed = (NCURSES_OSPEED) _nc_ospeed(result);
+#else /* !USE_OLD_TTY */
+#ifdef TERMIOS
+    my_ospeed = (NCURSES_OSPEED) cfgetospeed(&(termp->Nttyb));
+#elif defined(EXP_WIN32_DRIVER)
+    /* noop */
+    my_ospeed = 0;
+#else
+    my_ospeed = (NCURSES_OSPEED) termp->Nttyb.sg_ospeed;
+#endif
+    result = _nc_baudrate(my_ospeed);
+#endif
+    termp->_baudrate = result;
+    ospeed = (NCURSES_OSPEED) my_ospeed;
+}
+
 #undef SETUP_FAIL
 #define SETUP_FAIL FALSE
 
+#define NO_COPY {}
+
 static bool
 drv_CanHandle(TERMINAL_CONTROL_BLOCK * TCB, const char *tname, int *errret)
 {
@@ -125,7 +161,7 @@
     SCREEN *sp;
 
     START_TRACE();
-    T((T_CALLED("tinfo::drv_CanHandle(%p)"), TCB));
+    T((T_CALLED("tinfo::drv_CanHandle(%p)"), (void *) TCB));
 
     assert(TCB != 0 && tname != 0);
     termp = (TERMINAL *) TCB;
@@ -133,17 +169,20 @@
     TCB->magic = TCBMAGIC;
 
 #if (NCURSES_USE_DATABASE || NCURSES_USE_TERMCAP)
-    status = _nc_setup_tinfo(tname, &termp->type);
+    status = _nc_setup_tinfo(tname, &TerminalType(termp));
+    T(("_nc_setup_tinfo returns %d", status));
 #else
+    T(("no database available"));
     status = TGETENT_NO;
 #endif
 
     /* try fallback list if entry on disk */
     if (status != TGETENT_YES) {
-	const TERMTYPE *fallback = _nc_fallback(tname);
+	const TERMTYPE2 *fallback = _nc_fallback2(tname);
 
 	if (fallback) {
-	    termp->type = *fallback;
+	    T(("found fallback entry"));
+	    TerminalType(termp) = *fallback;
 	    status = TGETENT_YES;
 	}
     }
@@ -153,17 +192,40 @@
 	if (status == TGETENT_ERR) {
 	    ret_error0(status, "terminals database is inaccessible\n");
 	} else if (status == TGETENT_NO) {
-	    ret_error1(status, "unknown terminal type.\n", tname);
+	    ret_error1(status, "unknown terminal type.\n",
+		       tname, NO_COPY);
+	} else {
+	    ret_error0(status, "unexpected return-code\n");
 	}
     }
     result = TRUE;
+#if NCURSES_EXT_NUMBERS
+    _nc_export_termtype2(&termp->type, &TerminalType(termp));
+#endif
 #if !USE_REENTRANT
-    strncpy(ttytype, termp->type.term_names, (size_t) NAMESIZE - 1);
-    ttytype[NAMESIZE - 1] = '\0';
+    save_ttytype(termp);
 #endif
 
-    if (command_character)
-	_nc_tinfo_cmdch(termp, *command_character);
+    if (VALID_STRING(command_character))
+	_nc_tinfo_cmdch(termp, UChar(*command_character));
+
+    /*
+     * If an application calls setupterm() rather than initscr() or
+     * newterm(), we will not have the def_prog_mode() call in
+     * _nc_setupscreen().  Do it now anyway, so we can initialize the
+     * baudrate.
+     */
+    if (sp == 0 && NC_ISATTY(termp->Filedes)) {
+	get_baudrate(termp);
+    }
+#if NCURSES_EXT_NUMBERS
+#define cleanup_termtype() \
+    _nc_free_termtype2(&TerminalType(termp)); \
+    _nc_free_termtype(&termp->type)
+#else
+#define cleanup_termtype() \
+    _nc_free_termtype2(&TerminalType(termp))
+#endif
 
     if (generic_type) {
 	/*
@@ -173,13 +235,19 @@
 	if ((VALID_STRING(cursor_address)
 	     || (VALID_STRING(cursor_down) && VALID_STRING(cursor_home)))
 	    && VALID_STRING(clear_screen)) {
-	    ret_error1(TGETENT_YES, "terminal is not really generic.\n", tname);
+	    cleanup_termtype();
+	    ret_error1(TGETENT_YES, "terminal is not really generic.\n",
+		       tname, NO_COPY);
 	} else {
-	    ret_error1(TGETENT_NO, "I need something more specific.\n", tname);
+	    cleanup_termtype();
+	    ret_error1(TGETENT_NO, "I need something more specific.\n",
+		       tname, NO_COPY);
 	}
     }
     if (hard_copy) {
-	ret_error1(TGETENT_YES, "I can't handle hardcopy terminals.\n", tname);
+	cleanup_termtype();
+	ret_error1(TGETENT_YES, "I can't handle hardcopy terminals.\n",
+		   tname, NO_COPY);
     }
 
     returnBool(result);
@@ -261,8 +329,8 @@
 	sp->_has_sgr_39_49 = (NCURSES_SP_NAME(tigetflag) (NCURSES_SP_ARGx
 							  "AX")
 			      == TRUE);
-	sp->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : (fg & C_MASK);
-	sp->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : (bg & C_MASK);
+	sp->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : fg;
+	sp->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : bg;
 	if (sp->_color_pairs != 0) {
 	    bool save = sp->_default_color;
 	    sp->_default_color = TRUE;
@@ -293,23 +361,23 @@
 	if (set_a_foreground) {
 	    TPUTS_TRACE("set_a_foreground");
 	    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				    TPARM_1(set_a_foreground, color), 1, outc);
+				    TIPARM_1(set_a_foreground, color), 1, outc);
 	} else {
 	    TPUTS_TRACE("set_foreground");
 	    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				    TPARM_1(set_foreground,
-					    toggled_colors(color)), 1, outc);
+				    TIPARM_1(set_foreground,
+					     toggled_colors(color)), 1, outc);
 	}
     } else {
 	if (set_a_background) {
 	    TPUTS_TRACE("set_a_background");
 	    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				    TPARM_1(set_a_background, color), 1, outc);
+				    TIPARM_1(set_a_background, color), 1, outc);
 	} else {
 	    TPUTS_TRACE("set_background");
 	    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				    TPARM_1(set_background,
-					    toggled_colors(color)), 1, outc);
+				    TIPARM_1(set_background,
+					     toggled_colors(color)), 1, outc);
 	}
     }
 }
@@ -358,18 +426,25 @@
 
     if (sp) {
 	useEnv = sp->_use_env;
-	useTioctl = sp->_use_tioctl;
+	useTioctl = sp->use_tioctl;
     } else {
 	useEnv = _nc_prescreen.use_env;
 	useTioctl = _nc_prescreen.use_tioctl;
     }
 
+#ifdef EXP_WIN32_DRIVER
+    /* If we are here, then Windows console is used in terminfo mode.
+       We need to figure out the size using the console API
+     */
+    _nc_console_size(linep, colp);
+    T(("screen size: winconsole lines = %d columns = %d", *linep, *colp));
+#else
     /* figure out the size of the screen */
     T(("screen size: terminfo lines = %d columns = %d", lines, columns));
 
     *linep = (int) lines;
     *colp = (int) columns;
-
+#endif
     if (useEnv || useTioctl) {
 	int value;
 
@@ -539,6 +614,8 @@
 	    if ((drv_sgmode(TCB, FALSE, &(_term->Nttyb)) == OK)) {
 #ifdef TERMIOS
 		_term->Nttyb.c_oflag &= (unsigned) ~OFLAGS_TABS;
+#elif defined(EXP_WIN32_DRIVER)
+		/* noop */
 #else
 		_term->Nttyb.sg_flags &= (unsigned) ~XTABS;
 #endif
@@ -564,6 +641,8 @@
 #ifdef TERMIOS
 		if (_term->Ottyb.c_oflag & OFLAGS_TABS)
 		    tab = back_tab = NULL;
+#elif defined(EXP_WIN32_DRIVER)
+		/* noop */
 #else
 		if (_term->Ottyb.sg_flags & XTABS)
 		    tab = back_tab = NULL;
@@ -701,10 +780,10 @@
 	    tp[b].red, tp[b].green, tp[b].blue));
 
 	NCURSES_PUTP2("initialize_pair",
-		      TPARM_7(initialize_pair,
-			      pair,
-			      tp[f].red, tp[f].green, tp[f].blue,
-			      tp[b].red, tp[b].green, tp[b].blue));
+		      TIPARM_7(initialize_pair,
+			       pair,
+			       tp[f].red, tp[f].green, tp[f].blue,
+			       tp[b].red, tp[b].green, tp[b].blue));
     }
 }
 
@@ -737,7 +816,7 @@
     AssertTCB();
     if (initialize_color != NULL) {
 	NCURSES_PUTP2("initialize_color",
-		      TPARM_4(initialize_color, color, r, g, b));
+		      TIPARM_4(initialize_color, color, r, g, b));
     }
 }
 
@@ -749,9 +828,9 @@
 	     NCURSES_SP_OUTC outc)
 {
     SCREEN *sp = TCB->csp;
-    NCURSES_COLOR_T fg = COLOR_DEFAULT;
-    NCURSES_COLOR_T bg = COLOR_DEFAULT;
-    NCURSES_COLOR_T old_fg, old_bg;
+    int fg = COLOR_DEFAULT;
+    int bg = COLOR_DEFAULT;
+    int old_fg, old_bg;
 
     AssertTCB();
     if (sp == 0)
@@ -763,22 +842,16 @@
 	if (set_color_pair) {
 	    TPUTS_TRACE("set_color_pair");
 	    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				    TPARM_1(set_color_pair, pair), 1, outc);
+				    TIPARM_1(set_color_pair, pair), 1, outc);
 	    return;
 	} else if (sp != 0) {
-	    NCURSES_SP_NAME(pair_content) (NCURSES_SP_ARGx
-					   (short) pair,
-					   &fg,
-					   &bg);
+	    _nc_pair_content(SP_PARM, pair, &fg, &bg);
 	}
     }
 
     if (old_pair >= 0
 	&& sp != 0
-	&& NCURSES_SP_NAME(pair_content) (NCURSES_SP_ARGx
-					  (short) old_pair,
-					  &old_fg,
-					  &old_bg) !=ERR) {
+	&& _nc_pair_content(SP_PARM, old_pair, &old_fg, &old_bg) != ERR) {
 	if ((isDefaultColor(fg) && !isDefaultColor(old_fg))
 	    || (isDefaultColor(bg) && !isDefaultColor(old_bg))) {
 #if NCURSES_EXT_FUNCS
@@ -807,13 +880,13 @@
 
 #if NCURSES_EXT_FUNCS
     if (isDefaultColor(fg))
-	fg = (NCURSES_COLOR_T) default_fg(sp);
+	fg = default_fg(sp);
     if (isDefaultColor(bg))
-	bg = (NCURSES_COLOR_T) default_bg(sp);
+	bg = default_bg(sp);
 #endif
 
     if (reverse) {
-	NCURSES_COLOR_T xx = fg;
+	int xx = fg;
 	fg = bg;
 	bg = xx;
     }
@@ -849,12 +922,9 @@
 
     /* we know how to recognize mouse events under "xterm" */
     if (sp != 0) {
-	if (key_mouse != 0) {
-	    if (!strcmp(key_mouse, xterm_kmous)
-		|| strstr(TerminalOf(sp)->type.term_names, "xterm") != 0) {
-		init_xterm_mouse(sp);
-	    }
-	} else if (strstr(TerminalOf(sp)->type.term_names, "xterm") != 0) {
+	if (NonEmpty(key_mouse)) {
+	    init_xterm_mouse(sp);
+	} else if (strstr(SP_TERMTYPE term_names, "xterm") != 0) {
 	    if (_nc_add_to_try(&(sp->_keytry), xterm_kmous, KEY_MOUSE) == OK)
 		init_xterm_mouse(sp);
 	}
@@ -879,11 +949,18 @@
     } else
 #endif
     {
+#ifdef EXP_WIN32_DRIVER
+	rc = _nc_console_testmouse(sp,
+				   _nc_console_handle(sp->_ifd),
+				   delay
+				   EVENTLIST_2nd(evl));
+#else
 	rc = TCBOf(sp)->drv->td_twait(TCBOf(sp),
 				      TWAIT_MASK,
 				      delay,
 				      (int *) 0
 				      EVENTLIST_2nd(evl));
+#endif
 #if USE_SYSMOUSE
 	if ((sp->_mouse_type == M_SYSMOUSE)
 	    && (sp->_sysmouse_head < sp->_sysmouse_tail)
@@ -979,12 +1056,18 @@
 {
     AssertTCB();
 
-    clear_screen = 0;
-    cursor_down = parm_down_cursor = 0;
-    cursor_address = 0;
-    cursor_up = parm_up_cursor = 0;
-    row_address = 0;
-    cursor_home = carriage_return;
+    /* *INDENT-EQLS* */
+    clear_screen     = ABSENT_STRING;
+    cursor_address   = ABSENT_STRING;
+    cursor_down      = ABSENT_STRING;
+    cursor_up        = ABSENT_STRING;
+    parm_down_cursor = ABSENT_STRING;
+    parm_up_cursor   = ABSENT_STRING;
+    row_address      = ABSENT_STRING;
+    cursor_home      = carriage_return;
+
+    if (back_color_erase)
+	clr_eos = ABSENT_STRING;
 }
 
 static void
@@ -1031,8 +1114,13 @@
 	while (i + 1 < length) {
 	    if (acs_chars[i] != 0 && UChar(acs_chars[i]) < ACS_LEN) {
 		real_map[UChar(acs_chars[i])] = UChar(acs_chars[i + 1]) | A_ALTCHARSET;
-		if (sp != 0)
+		T(("#%d real_map[%s] = %s",
+		   (int) i,
+		   _tracechar(UChar(acs_chars[i])),
+		   _tracechtype(real_map[UChar(acs_chars[i])])));
+		if (sp != 0) {
 		    sp->_screen_acs_map[UChar(acs_chars[i])] = TRUE;
+		}
 	    }
 	    i += 2;
 	}
@@ -1062,7 +1150,6 @@
 		   ? "DIFF"
 		   : "SAME"),
 		_nc_visbuf(show));
-
 	_nc_unlock_global(tracef);
     }
 #endif /* TRACE */
@@ -1171,30 +1258,42 @@
 
     AssertTCB();
     SetSP();
-
+#ifdef EXP_WIN32_DRIVER
+    return _nc_console_twait(sp,
+			     _nc_console_handle(sp->_ifd),
+			     mode,
+			     milliseconds,
+			     timeleft EVENTLIST_2nd(evl));
+#else
     return _nc_timed_wait(sp, mode, milliseconds, timeleft EVENTLIST_2nd(evl));
+#endif
 }
 
 static int
 drv_read(TERMINAL_CONTROL_BLOCK * TCB, int *buf)
 {
     SCREEN *sp;
-    unsigned char c2 = 0;
     int n;
+#ifndef EXP_WIN32_DRIVER
+    unsigned char c2 = 0;
+#endif
 
     AssertTCB();
     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),
+			 buf);
+#else
     n = (int) read(sp->_ifd, &c2, (size_t) 1);
-#if USE_PTHREADS_EINTR
-    _nc_globals.read_thread = 0;
 #endif
+    _nc_set_read_thread(FALSE);
+#ifndef EXP_WIN32_DRIVER
     *buf = (int) c2;
+#endif
     return n;
 }
 
@@ -1211,6 +1310,8 @@
 	    request = remaining;
 	}
     }
+#elif defined(EXP_WIN32_DRIVER)
+    Sleep((DWORD) ms);
 #else
     _nc_timed_wait(0, 0, ms, (int *) 0 EVENTLIST_2nd(0));
 #endif
@@ -1279,23 +1380,29 @@
 	unsigned ch = (unsigned) c;
 	if (flag) {
 	    while ((s = _nc_expand_try(sp->_key_ok,
-				       ch, &count, (size_t) 0)) != 0
-		   && _nc_remove_key(&(sp->_key_ok), ch)) {
-		code = _nc_add_to_try(&(sp->_keytry), s, ch);
-		free(s);
-		count = 0;
-		if (code != OK)
-		    break;
+				       ch, &count, (size_t) 0)) != 0) {
+		if (_nc_remove_key(&(sp->_key_ok), ch)) {
+		    code = _nc_add_to_try(&(sp->_keytry), s, ch);
+		    free(s);
+		    count = 0;
+		    if (code != OK)
+			break;
+		} else {
+		    free(s);
+		}
 	    }
 	} else {
 	    while ((s = _nc_expand_try(sp->_keytry,
-				       ch, &count, (size_t) 0)) != 0
-		   && _nc_remove_key(&(sp->_keytry), ch)) {
-		code = _nc_add_to_try(&(sp->_key_ok), s, ch);
-		free(s);
-		count = 0;
-		if (code != OK)
-		    break;
+				       ch, &count, (size_t) 0)) != 0) {
+		if (_nc_remove_key(&(sp->_keytry), ch)) {
+		    code = _nc_add_to_try(&(sp->_key_ok), s, ch);
+		    free(s);
+		    count = 0;
+		    if (code != OK)
+			break;
+		} else {
+		    free(s);
+		}
 	    }
 	}
     }
@@ -1382,3 +1489,66 @@
 	drv_kyExist,		/* kyExist */
 	drv_cursorSet		/* cursorSet */
 };
+
+#ifdef EXP_WIN32_DRIVER
+/*
+ * The terminfo driver is mandatory and must always be present.
+ * So this is the natural place for the driver initialisation
+ * logic.
+ */
+
+typedef struct DriverEntry {
+    const char *name;
+    TERM_DRIVER *driver;
+} DRIVER_ENTRY;
+
+static DRIVER_ENTRY DriverTable[] =
+{
+#ifdef _NC_WINDOWS
+    {"win32console", &_nc_WIN_DRIVER},
+#endif
+    {"tinfo", &_nc_TINFO_DRIVER}	/* must be last */
+};
+
+NCURSES_EXPORT(int)
+_nc_get_driver(TERMINAL_CONTROL_BLOCK * TCB, const char *name, int *errret)
+{
+    int code = ERR;
+    size_t i;
+    TERM_DRIVER *res = (TERM_DRIVER *) 0;
+    TERM_DRIVER *use = 0;
+
+    T((T_CALLED("_nc_get_driver(%p, %s, %p)"),
+       (void *) TCB, NonNull(name), (void *) errret));
+
+    assert(TCB != 0);
+
+    for (i = 0; i < SIZEOF(DriverTable); i++) {
+	res = DriverTable[i].driver;
+#ifdef _NC_WINDOWS
+	if ((i + 1) == SIZEOF(DriverTable)) {
+	    /* For Windows >= 10.0.17763 Windows Console interface implements
+	       virtual Terminal functionality.
+	       If on Windows td_CanHandle returned FALSE although the terminal
+	       name is empty, we default to ms-terminal as tinfo TERM type.
+	     */
+	    if (name == 0 || *name == 0 || (strcmp(name, "unknown") == 0)) {
+		name = MS_TERMINAL;
+		T(("Set TERM=%s", name));
+	    }
+	}
+#endif
+	if (strcmp(DriverTable[i].name, res->td_name(TCB)) == 0) {
+	    if (res->td_CanHandle(TCB, name, errret)) {
+		use = res;
+		break;
+	    }
+	}
+    }
+    if (use != 0) {
+	TCB->drv = use;
+	code = OK;
+    }
+    returnCode(code);
+}
+#endif /* EXP_WIN32_DRIVER */
diff --git a/ncurses/tinfo/trim_sgr0.c b/ncurses/tinfo/trim_sgr0.c
index ec5e2b7..177dcd8 100644
--- a/ncurses/tinfo/trim_sgr0.c
+++ b/ncurses/tinfo/trim_sgr0.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2005-2010,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
+ * Copyright 2005-2012,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -36,22 +37,18 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: trim_sgr0.c,v 1.15 2012/12/15 20:57:17 tom Exp $")
+MODULE_ID("$Id: trim_sgr0.c,v 1.22 2023/09/23 18:47:56 tom Exp $")
 
 #undef CUR
 #define CUR tp->
 
-#define CSI       233
-#define ESC       033		/* ^[ */
-#define L_BRACK   '['
-
 static char *
-set_attribute_9(TERMTYPE *tp, int flag)
+set_attribute_9(TERMTYPE2 *tp, int flag)
 {
     const char *value;
     char *result;
 
-    value = tparm(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, flag);
+    value = TIPARM_9(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, flag);
     if (PRESENT(value))
 	result = strdup(value);
     else
@@ -64,9 +61,9 @@
 {
     int result = 0;
     if (s != 0) {
-	if (UChar(s[0]) == CSI)
+	if (UChar(s[0]) == CSI_CHR)
 	    result = 1;
-	else if (s[0] == ESC && s[1] == L_BRACK)
+	else if (s[0] == ESC_CHR && s[1] == L_BLOCK)
 	    result = 2;
     }
     return result;
@@ -221,7 +218,7 @@
 }
 
 /*
- * While 'sgr0' is the "same" as termcap 'me', there is a compatibility issue. 
+ * While 'sgr0' is the "same" as termcap 'me', there is a compatibility issue.
  * The sgr/sgr0 capabilities include setting/clearing alternate character set
  * mode.  A termcap application cannot use sgr, so sgr0 strings that reset
  * alternate character set mode will be misinterpreted.  Here, we remove those
@@ -232,7 +229,7 @@
  * an error occurs, or the original sgr0 if no change is needed.
  */
 NCURSES_EXPORT(char *)
-_nc_trim_sgr0(TERMTYPE *tp)
+_nc_trim_sgr0(TERMTYPE2 *tp)
 {
     char *result = exit_attribute_mode;
 
@@ -263,7 +260,7 @@
 	    /*
 	     * If rmacs is a substring of sgr(0), remove that chunk.
 	     */
-	    if (exit_alt_charset_mode != 0) {
+	    if (PRESENT(exit_alt_charset_mode)) {
 		TR(TRACE_DATABASE, ("scan for rmacs %s", _nc_visbuf(exit_alt_charset_mode)));
 		j = strlen(off);
 		k = strlen(exit_alt_charset_mode);
diff --git a/ncurses/tinfo/use_screen.c b/ncurses/tinfo/use_screen.c
index 6a0297c..a4bf932 100644
--- a/ncurses/tinfo/use_screen.c
+++ b/ncurses/tinfo/use_screen.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2007-2009,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,15 +33,19 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: use_screen.c,v 1.8 2009/10/24 22:40:20 tom Exp $")
+MODULE_ID("$Id: use_screen.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 use_screen(SCREEN *screen, NCURSES_SCREEN_CB func, void *data)
 {
     SCREEN *save_SP;
     int code = OK;
+    TR_FUNC_BFR(1);
 
-    T((T_CALLED("use_screen(%p,%p,%p)"), (void *) screen, func, (void *) data));
+    T((T_CALLED("use_screen(%p,%s,%p)"),
+       (void *) screen,
+       TR_FUNC_ARG(0, func),
+       (void *) data));
 
     /*
      * FIXME - add a flag so a given thread can check if _it_ has already
diff --git a/ncurses/tinfo/write_entry.c b/ncurses/tinfo/write_entry.c
index b2edd5d..8ccca9e 100644
--- a/ncurses/tinfo/write_entry.c
+++ b/ncurses/tinfo/write_entry.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -41,40 +42,74 @@
 
 #include <tic.h>
 
+MODULE_ID("$Id: write_entry.c,v 1.132 2024/04/20 17:58:51 tom Exp $")
+
 #if 1
 #define TRACE_OUT(p) DEBUG(2, p)
+#define TRACE_NUM(n) if (VALID_NUMERIC(Numbers[n])) { \
+	TRACE_OUT(("put Numbers[%u]=%d", (unsigned) (n), Numbers[n])); }
 #else
 #define TRACE_OUT(p)		/*nothing */
+#define TRACE_NUM(n)		/* nothing */
 #endif
 
-MODULE_ID("$Id: write_entry.c,v 1.92 2014/11/01 14:47:00 tom Exp $")
+/*
+ * FIXME: special case to work around Cygwin bug in link(), which updates
+ * the target file's timestamp.
+ */
+#if HAVE_LINK && !USE_SYMLINKS && !MIXEDCASE_FILENAMES && defined(__CYGWIN__)
+#define LINK_TOUCHES 1
+#else
+#define LINK_TOUCHES 0
+#endif
 
 static int total_written;
+static int total_parts;
+static int total_size;
 
 static int make_db_root(const char *);
-static int write_object(TERMTYPE *, char *, unsigned *, unsigned);
 
 #if !USE_HASHED_DB
 static void
-write_file(char *filename, TERMTYPE *tp)
+write_file(char *filename, TERMTYPE2 *tp)
 {
     char buffer[MAX_ENTRY_SIZE];
     unsigned limit = sizeof(buffer);
     unsigned offset = 0;
 
-    FILE *fp = (_nc_access(filename, W_OK) == 0) ? fopen(filename, "wb") : 0;
-    if (fp == 0) {
-	perror(filename);
-	_nc_syserr_abort("can't open %s/%s", _nc_tic_dir(0), filename);
-    }
-    DEBUG(1, ("Created %s", filename));
+    if (_nc_write_object(tp, buffer, &offset, limit) == ERR) {
+	_nc_warning("entry is larger than %u bytes", limit);
+    } else {
+	FILE *fp = ((_nc_access(filename, W_OK) == 0)
+		    ? safe_fopen(filename, BIN_W)
+		    : 0);
+	size_t actual;
 
-    if (write_object(tp, buffer, &offset, limit) == ERR
-	|| fwrite(buffer, sizeof(char), (size_t) offset, fp) != offset) {
-	_nc_syserr_abort("error writing %s/%s", _nc_tic_dir(0), filename);
-    }
+	if (fp == 0) {
+	    perror(filename);
+	    _nc_syserr_abort("cannot open %s/%s", _nc_tic_dir(0), filename);
+	}
 
-    fclose(fp);
+	actual = fwrite(buffer, sizeof(char), (size_t) offset, fp);
+	if (actual != offset) {
+	    int myerr = ferror(fp) ? errno : 0;
+	    if (myerr) {
+		_nc_syserr_abort("error writing %s/%s: %s",
+				 _nc_tic_dir(NULL),
+				 filename,
+				 strerror(myerr));
+	    } else {
+		_nc_syserr_abort("error writing %s/%s: %u bytes vs actual %lu",
+				 _nc_tic_dir(NULL),
+				 filename,
+				 offset,
+				 (unsigned long) actual);
+	    }
+	} else {
+	    fclose(fp);
+	    DEBUG(1, ("Created %s", filename));
+	}
+    }
 }
 
 /*
@@ -93,18 +128,16 @@
     char dir[sizeof(LEAF_FMT)];
     char *s = 0;
 
-    if (code == 0 || (s = (strchr) (dirnames, code)) == 0)
+    if (code == 0 || (s = (strchr) (dirnames, code)) == 0) {
 	_nc_err_abort("Illegal terminfo subdirectory \"" LEAF_FMT "\"", code);
-
-    if (verified[s - dirnames])
-	return;
-
-    _nc_SPRINTF(dir, _nc_SLIMIT(sizeof(dir)) LEAF_FMT, code);
-    if (make_db_root(dir) < 0) {
-	_nc_err_abort("%s/%s: permission denied", _nc_tic_dir(0), dir);
+    } else if (!verified[s - dirnames]) {
+	_nc_SPRINTF(dir, _nc_SLIMIT(sizeof(dir)) LEAF_FMT, code);
+	if (make_db_root(dir) < 0) {
+	    _nc_err_abort("%s/%s: permission denied", _nc_tic_dir(NULL), dir);
+	} else {
+	    verified[s - dirnames] = TRUE;
+	}
     }
-
-    verified[s - dirnames] = TRUE;
 }
 #endif /* !USE_HASHED_DB */
 
@@ -112,7 +145,7 @@
 make_db_path(char *dst, const char *src, size_t limit)
 {
     int rc = -1;
-    const char *top = _nc_tic_dir(0);
+    const char *top = _nc_tic_dir(NULL);
 
     if (src == top || _nc_is_abs_path(src)) {
 	if (strlen(src) + 1 <= limit) {
@@ -120,7 +153,7 @@
 	    rc = 0;
 	}
     } else {
-	if (strlen(top) + strlen(src) + 2 <= limit) {
+	if ((strlen(top) + strlen(src) + 6) <= limit) {
 	    _nc_SPRINTF(dst, _nc_SLIMIT(limit) "%s/%s", top, src);
 	    rc = 0;
 	}
@@ -165,9 +198,9 @@
 #else
 	struct stat statbuf;
 
-	if ((rc = stat(path, &statbuf)) < 0) {
+	if ((rc = stat(path, &statbuf)) == -1) {
 	    rc = mkdir(path
-#if !defined(__MINGW32__)
+#ifndef _NC_WINDOWS
 		       ,0777
 #endif
 		);
@@ -189,26 +222,30 @@
 {
     const char *destination;
     char actual[PATH_MAX];
+    bool specific = (dir != NULL);
 
-    if (dir == 0
-#ifndef USE_ROOT_ENVIRON
-	&& use_terminfo_vars()
-#endif
-	)
+    if (!specific && use_terminfo_vars())
 	dir = getenv("TERMINFO");
 
-    if (dir != 0)
+    if (dir != NULL)
 	(void) _nc_tic_dir(dir);
 
-    destination = _nc_tic_dir(0);
+    destination = _nc_tic_dir(NULL);
     if (make_db_root(destination) < 0) {
-	char *home = _nc_home_terminfo();
+	bool success = FALSE;
 
-	if (home != 0) {
-	    destination = home;
-	    if (make_db_root(destination) < 0)
-		_nc_err_abort("%s: permission denied (errno %d)",
-			      destination, errno);
+	if (!specific) {
+	    char *home = _nc_home_terminfo();
+
+	    if (home != NULL) {
+		destination = home;
+		if (make_db_root(destination) == 0)
+		    success = TRUE;
+	    }
+	}
+	if (!success) {
+	    _nc_err_abort("%s: permission denied (errno %d)",
+			  destination, errno);
 	}
     }
 
@@ -220,10 +257,10 @@
     make_db_path(actual, destination, sizeof(actual));
 #else
     if (chdir(_nc_tic_dir(destination)) < 0
-	|| getcwd(actual, sizeof(actual)) == 0)
+	|| getcwd(actual, sizeof(actual)) == NULL)
 	_nc_err_abort("%s: not a directory", destination);
 #endif
-    _nc_keep_tic_dir(strdup(actual));
+    _nc_keep_tic_dir(actual);
 }
 
 /*
@@ -247,7 +284,7 @@
  */
 
 NCURSES_EXPORT(void)
-_nc_write_entry(TERMTYPE *const tp)
+_nc_write_entry(TERMTYPE2 *const tp)
 {
 #if USE_HASHED_DB
 
@@ -268,6 +305,9 @@
 #endif
 #endif /* USE_SYMLINKS */
 
+    unsigned limit2 = sizeof(filename) - (2 + LEAF_LEN);
+    char saved = '\0';
+
     static int call_count;
     static time_t start_time;	/* time at start of writes */
 
@@ -299,8 +339,9 @@
     if (ptr != name_list) {
 	*ptr = '\0';
 
-	for (ptr = name_list; *ptr != '\0' && *ptr != '|'; ptr++)
-	    continue;
+	for (ptr = name_list; *ptr != '\0' && *ptr != '|'; ptr++) {
+	    /* EMPTY */ ;
+	}
 
 	if (*ptr == '\0')
 	    other_names = ptr;
@@ -316,11 +357,11 @@
     _nc_set_type(first_name);
 
 #if USE_HASHED_DB
-    if (write_object(tp, buffer + 1, &offset, limit - 1) != ERR) {
-	DB *capdb = _nc_db_open(_nc_tic_dir(0), TRUE);
+    if (_nc_write_object(tp, buffer + 1, &offset, limit - 1) != ERR) {
+	DB *capdb = _nc_db_open(_nc_tic_dir(NULL), TRUE);
 	DBT key, data;
 
-	if (capdb != 0) {
+	if (capdb != NULL) {
 	    buffer[0] = 0;
 
 	    memset(&key, 0, sizeof(key));
@@ -343,6 +384,8 @@
 		       sizeof(buffer) - 1);
 	    data.size = name_size + 1;
 
+	    total_size += (int) data.size;
+	    total_parts++;
 	    _nc_db_put(capdb, &key, &data);
 
 	    while (*other_names != '\0') {
@@ -357,6 +400,8 @@
 		key.data = ptr;
 		key.size = strlen(ptr);
 
+		total_size += (int) data.size;
+		total_parts++;
 		_nc_db_put(capdb, &key, &data);
 	    }
 	}
@@ -366,11 +411,19 @@
 	start_time = 0;
     }
 
-    if (strlen(first_name) >= sizeof(filename) - (2 + LEAF_LEN))
+    if (strlen(first_name) >= limit2) {
 	_nc_warning("terminal name too long.");
+	saved = first_name[limit2];
+	first_name[limit2] = '\0';
+    }
 
     _nc_SPRINTF(filename, _nc_SLIMIT(sizeof(filename))
-		LEAF_FMT "/%s", first_name[0], first_name);
+		LEAF_FMT "/%.*s", UChar(first_name[0]),
+		(int) (sizeof(filename) - (LEAF_LEN + 2)),
+		first_name);
+
+    if (saved)
+	first_name[limit2] = saved;
 
     /*
      * Has this primary name been written since the first call to
@@ -402,10 +455,10 @@
     write_file(filename, tp);
 
     if (start_time == 0) {
-	if (stat(filename, &statbuf) < 0
+	if (stat(filename, &statbuf) == -1
 	    || (start_time = statbuf.st_mtime) == 0) {
 	    _nc_syserr_abort("error obtaining time from %s/%s",
-			     _nc_tic_dir(0), filename);
+			     _nc_tic_dir(NULL), filename);
 	}
     }
     while (*other_names != '\0') {
@@ -420,32 +473,38 @@
 	    _nc_warning("terminal alias %s too long.", ptr);
 	    continue;
 	}
-	if (strchr(ptr, '/') != 0) {
+	if (strchr(ptr, '/') != NULL) {
 	    _nc_warning("cannot link alias %s.", ptr);
 	    continue;
 	}
 
 	check_writeable(ptr[0]);
 	_nc_SPRINTF(linkname, _nc_SLIMIT(sizeof(linkname))
-		    LEAF_FMT "/%s", ptr[0], ptr);
+		    LEAF_FMT "/%.*s", ptr[0],
+		    (int) sizeof(linkname) - (2 + LEAF_LEN), ptr);
 
 	if (strcmp(filename, linkname) == 0) {
 	    _nc_warning("self-synonym ignored");
-	} else if (stat(linkname, &statbuf) >= 0 &&
-		   statbuf.st_mtime < start_time) {
+	}
+#if !LINK_TOUCHES
+	else if (stat(linkname, &statbuf) >= 0 &&
+		 statbuf.st_mtime < start_time) {
 	    _nc_warning("alias %s multiply defined.", ptr);
-	} else if (_nc_access(linkname, W_OK) == 0)
+	}
+#endif
+	else if (_nc_access(linkname, W_OK) == 0)
 #if HAVE_LINK
 	{
 	    int code;
 #if USE_SYMLINKS
-	    if (first_name[0] == linkname[0])
-		strncpy(symlinkname, first_name, sizeof(symlinkname) - 1);
-	    else {
-		_nc_STRCPY(symlinkname, "../", sizeof(suymlinkname));
-		strncat(symlinkname, filename, sizeof(symlinkname) - 4);
+#define MY_SIZE sizeof(symlinkname) - 1
+	    if (first_name[0] == linkname[0]) {
+		_nc_STRNCPY(symlinkname, first_name, MY_SIZE);
+	    } else {
+		_nc_STRCPY(symlinkname, "../", sizeof(symlinkname));
+		_nc_STRNCPY(symlinkname + 3, filename, MY_SIZE - 3);
 	    }
-	    symlinkname[sizeof(symlinkname) - 1] = '\0';
+	    symlinkname[MY_SIZE] = '\0';
 #endif /* USE_SYMLINKS */
 #if HAVE_REMOVE
 	    code = remove(linkname);
@@ -472,9 +531,9 @@
 		    write_file(linkname, tp);
 		else {
 #if MIXEDCASE_FILENAMES
-		    _nc_syserr_abort("can't link %s to %s", filename, linkname);
+		    _nc_syserr_abort("cannot link %s to %s", filename, linkname);
 #else
-		    _nc_warning("can't link %s to %s (errno=%d)", filename,
+		    _nc_warning("cannot link %s to %s (errno=%d)", filename,
 				linkname, errno);
 #endif
 		}
@@ -542,7 +601,7 @@
     return nextfree;
 }
 
-static void
+static size_t
 convert_shorts(unsigned char *buf, short *Numbers, size_t count)
 {
     size_t i;
@@ -557,14 +616,49 @@
 	    TRACE_OUT(("put Numbers[%u]=%d", (unsigned) i, Numbers[i]));
 	}
     }
+    return SIZEOF_SHORT;
 }
 
+#if NCURSES_EXT_NUMBERS
+static size_t
+convert_16bit(unsigned char *buf, NCURSES_INT2 *Numbers, size_t count)
+{
+    size_t i, j;
+    size_t size = SIZEOF_SHORT;
+    for (i = 0; i < count; i++) {
+	unsigned value = (unsigned) Numbers[i];
+	TRACE_NUM(i);
+	for (j = 0; j < size; ++j) {
+	    *buf++ = value & 0xff;
+	    value >>= 8;
+	}
+    }
+    return size;
+}
+
+static size_t
+convert_32bit(unsigned char *buf, NCURSES_INT2 *Numbers, size_t count)
+{
+    size_t i, j;
+    size_t size = SIZEOF_INT2;
+    for (i = 0; i < count; i++) {
+	unsigned value = (unsigned) Numbers[i];
+	TRACE_NUM(i);
+	for (j = 0; j < size; ++j) {
+	    *buf++ = value & 0xff;
+	    value >>= 8;
+	}
+    }
+    return size;
+}
+#endif
+
 #define even_boundary(value) \
 	    ((value) % 2 != 0 && Write(&zero, sizeof(char), 1) != 1)
 
 #if NCURSES_XNAMES
 static unsigned
-extended_Booleans(TERMTYPE *tp)
+extended_Booleans(TERMTYPE2 *tp)
 {
     unsigned result = 0;
     unsigned i;
@@ -577,7 +671,7 @@
 }
 
 static unsigned
-extended_Numbers(TERMTYPE *tp)
+extended_Numbers(TERMTYPE2 *tp)
 {
     unsigned result = 0;
     unsigned i;
@@ -590,7 +684,7 @@
 }
 
 static unsigned
-extended_Strings(TERMTYPE *tp)
+extended_Strings(TERMTYPE2 *tp)
 {
     unsigned short result = 0;
     unsigned short i;
@@ -607,7 +701,7 @@
  * clause - discard the unneeded data.
  */
 static bool
-extended_object(TERMTYPE *tp)
+extended_object(TERMTYPE2 *tp)
 {
     bool result = FALSE;
 
@@ -620,11 +714,11 @@
 }
 #endif
 
-static int
-write_object(TERMTYPE *tp, char *buffer, unsigned *offset, unsigned limit)
+NCURSES_EXPORT(int)
+_nc_write_object(TERMTYPE2 *tp, char *buffer, unsigned *offset, unsigned limit)
 {
     char *namelist;
-    size_t namelen, boolmax, nummax, strmax;
+    size_t namelen, boolmax, nummax, strmax, numlen;
     char zero = '\0';
     size_t i;
     int nextfree;
@@ -633,6 +727,12 @@
     unsigned last_bool = BOOLWRITE;
     unsigned last_num = NUMWRITE;
     unsigned last_str = STRWRITE;
+#if NCURSES_EXT_NUMBERS
+    bool need_ints = FALSE;
+    size_t (*convert_numbers) (unsigned char *, NCURSES_INT2 *, size_t);
+#else
+#define convert_numbers convert_shorts
+#endif
 
 #if NCURSES_XNAMES
     /*
@@ -653,14 +753,21 @@
 
     boolmax = 0;
     for (i = 0; i < last_bool; i++) {
-	if (tp->Booleans[i] == TRUE)
+	if (tp->Booleans[i] == TRUE) {
 	    boolmax = i + 1;
+	}
     }
 
     nummax = 0;
     for (i = 0; i < last_num; i++) {
-	if (tp->Numbers[i] != ABSENT_NUMERIC)
+	if (tp->Numbers[i] != ABSENT_NUMERIC) {
 	    nummax = i + 1;
+#if NCURSES_EXT_NUMBERS
+	    if (tp->Numbers[i] > MAX_OF_TYPE(NCURSES_COLOR_T)) {
+		need_ints = TRUE;
+	    }
+#endif
+	}
     }
 
     strmax = 0;
@@ -672,8 +779,19 @@
     nextfree = compute_offsets(tp->Strings, strmax, offsets);
 
     /* fill in the header */
+#if NCURSES_EXT_NUMBERS
+    if (need_ints) {
+	convert_numbers = convert_32bit;
+	LITTLE_ENDIAN(buf, MAGIC2);
+    } else {
+	convert_numbers = convert_16bit;
+	LITTLE_ENDIAN(buf, MAGIC);
+    }
+#else
     LITTLE_ENDIAN(buf, MAGIC);
-    LITTLE_ENDIAN(buf + 2, min(namelen, MAX_NAME_SIZE + 1));
+#endif
+    namelen = Min(namelen, MAX_NAME_SIZE + 1);
+    LITTLE_ENDIAN(buf + 2, namelen);
     LITTLE_ENDIAN(buf + 4, boolmax);
     LITTLE_ENDIAN(buf + 6, nummax);
     LITTLE_ENDIAN(buf + 8, strmax);
@@ -682,62 +800,81 @@
     /* write out the header */
     TRACE_OUT(("Header of %s @%d", namelist, *offset));
     if (Write(buf, 12, 1) != 1
-	|| Write(namelist, sizeof(char), namelen) != namelen)
-	  return (ERR);
-
-    for (i = 0; i < boolmax; i++)
-	if (tp->Booleans[i] == TRUE)
-	    buf[i] = TRUE;
-	else
-	    buf[i] = FALSE;
-    if (Write(buf, sizeof(char), boolmax) != boolmax)
-	  return (ERR);
-
-    if (even_boundary(namelen + boolmax))
+	|| Write(namelist, sizeof(char), namelen) != namelen) {
 	return (ERR);
+    }
+
+    for (i = 0; i < boolmax; i++) {
+	if (tp->Booleans[i] == TRUE) {
+	    buf[i] = TRUE;
+	} else {
+	    buf[i] = FALSE;
+	}
+    }
+    if (Write(buf, sizeof(char), boolmax) != boolmax) {
+	return (ERR);
+    }
+
+    if (even_boundary(namelen + boolmax)) {
+	return (ERR);
+    }
 
     TRACE_OUT(("Numerics begin at %04x", *offset));
 
     /* the numerics */
-    convert_shorts(buf, tp->Numbers, nummax);
-    if (Write(buf, 2, nummax) != nummax)
+    numlen = convert_numbers(buf, tp->Numbers, nummax);
+    if (Write(buf, numlen, nummax) != nummax) {
 	return (ERR);
+    }
 
     TRACE_OUT(("String offsets begin at %04x", *offset));
 
     /* the string offsets */
     convert_shorts(buf, offsets, strmax);
-    if (Write(buf, 2, strmax) != strmax)
+    if (Write(buf, SIZEOF_SHORT, strmax) != strmax) {
 	return (ERR);
+    }
 
     TRACE_OUT(("String table begins at %04x", *offset));
 
     /* the strings */
-    for (i = 0; i < strmax; i++)
-	if (VALID_STRING(tp->Strings[i]))
-	    if (!WRITE_STRING(tp->Strings[i]))
+    for (i = 0; i < strmax; i++) {
+	if (VALID_STRING(tp->Strings[i])) {
+	    if (!WRITE_STRING(tp->Strings[i])) {
 		return (ERR);
+	    }
+	}
+    }
 
 #if NCURSES_XNAMES
     if (extended_object(tp)) {
-	unsigned extcnt = (unsigned) NUM_EXT_NAMES(tp);
+	unsigned ext_total = (unsigned) NUM_EXT_NAMES(tp);
+	unsigned ext_usage = ext_total;
 
-	if (even_boundary(nextfree))
+	if (even_boundary(nextfree)) {
 	    return (ERR);
+	}
 
 	nextfree = compute_offsets(tp->Strings + STRCOUNT,
 				   (size_t) tp->ext_Strings,
 				   offsets);
 	TRACE_OUT(("after extended string capabilities, nextfree=%d", nextfree));
 
-	if (tp->ext_Strings >= SIZEOF(offsets))
+	if (tp->ext_Strings >= SIZEOF(offsets)) {
 	    return (ERR);
+	}
 
 	nextfree += compute_offsets(tp->ext_Names,
-				    (size_t) extcnt,
+				    (size_t) ext_total,
 				    offsets + tp->ext_Strings);
 	TRACE_OUT(("after extended capnames, nextfree=%d", nextfree));
-	strmax = tp->ext_Strings + extcnt;
+	strmax = tp->ext_Strings + ext_total;
+	for (i = 0; i < tp->ext_Strings; ++i) {
+	    if (VALID_STRING(tp->Strings[i + STRCOUNT])) {
+		ext_usage++;
+	    }
+	}
+	TRACE_OUT(("will write %u/%lu strings", ext_usage, (unsigned long) strmax));
 
 	/*
 	 * Write the extended header
@@ -745,26 +882,30 @@
 	LITTLE_ENDIAN(buf + 0, tp->ext_Booleans);
 	LITTLE_ENDIAN(buf + 2, tp->ext_Numbers);
 	LITTLE_ENDIAN(buf + 4, tp->ext_Strings);
-	LITTLE_ENDIAN(buf + 6, strmax);
+	LITTLE_ENDIAN(buf + 6, ext_usage);
 	LITTLE_ENDIAN(buf + 8, nextfree);
 	TRACE_OUT(("WRITE extended-header @%d", *offset));
-	if (Write(buf, 10, 1) != 1)
+	if (Write(buf, 10, 1) != 1) {
 	    return (ERR);
+	}
 
 	TRACE_OUT(("WRITE %d booleans @%d", tp->ext_Booleans, *offset));
 	if (tp->ext_Booleans
 	    && Write(tp->Booleans + BOOLCOUNT, sizeof(char),
-		     tp->ext_Booleans) != tp->ext_Booleans)
-	      return (ERR);
-
-	if (even_boundary(tp->ext_Booleans))
+		     tp->ext_Booleans) != tp->ext_Booleans) {
 	    return (ERR);
+	}
+
+	if (even_boundary(tp->ext_Booleans)) {
+	    return (ERR);
+	}
 
 	TRACE_OUT(("WRITE %d numbers @%d", tp->ext_Numbers, *offset));
 	if (tp->ext_Numbers) {
-	    convert_shorts(buf, tp->Numbers + NUMCOUNT, (size_t) tp->ext_Numbers);
-	    if (Write(buf, 2, tp->ext_Numbers) != tp->ext_Numbers)
+	    numlen = convert_numbers(buf, tp->Numbers + NUMCOUNT, (size_t) tp->ext_Numbers);
+	    if (Write(buf, numlen, tp->ext_Numbers) != tp->ext_Numbers) {
 		return (ERR);
+	    }
 	}
 
 	/*
@@ -773,8 +914,9 @@
 	 */
 	convert_shorts(buf, offsets, strmax);
 	TRACE_OUT(("WRITE offsets @%d", *offset));
-	if (Write(buf, 2, strmax) != strmax)
+	if (Write(buf, SIZEOF_SHORT, strmax) != strmax) {
 	    return (ERR);
+	}
 
 	/*
 	 * Write the string table after the offset tables so we do not
@@ -784,24 +926,28 @@
 	    if (VALID_STRING(tp->Strings[i + STRCOUNT])) {
 		TRACE_OUT(("WRITE ext_Strings[%d]=%s", (int) i,
 			   _nc_visbuf(tp->Strings[i + STRCOUNT])));
-		if (!WRITE_STRING(tp->Strings[i + STRCOUNT]))
+		if (!WRITE_STRING(tp->Strings[i + STRCOUNT])) {
 		    return (ERR);
+		}
 	    }
 	}
 
 	/*
 	 * Write the extended names
 	 */
-	for (i = 0; i < extcnt; i++) {
+	for (i = 0; i < ext_total; i++) {
 	    TRACE_OUT(("WRITE ext_Names[%d]=%s", (int) i, tp->ext_Names[i]));
-	    if (!WRITE_STRING(tp->ext_Names[i]))
+	    if (!WRITE_STRING(tp->ext_Names[i])) {
 		return (ERR);
+	    }
 	}
 
     }
 #endif /* NCURSES_XNAMES */
 
     total_written++;
+    total_parts++;
+    total_size = total_size + (int) (*offset + 1);
     return (OK);
 }
 
@@ -811,5 +957,7 @@
 NCURSES_EXPORT(int)
 _nc_tic_written(void)
 {
+    TR(TRACE_DATABASE, ("_nc_tic_written %d entries, %d parts, %d size",
+			total_written, total_parts, total_size));
     return total_written;
 }
diff --git a/ncurses/trace/README b/ncurses/trace/README
index e658fec..0a33300 100644
--- a/ncurses/trace/README
+++ b/ncurses/trace/README
@@ -1,5 +1,6 @@
 -------------------------------------------------------------------------------
--- Copyright (c) 1998,2006 Free Software Foundation, Inc.                    --
+-- Copyright 2020 Thomas E. Dickey                                           --
+-- Copyright 1998,2006 Free Software Foundation, Inc.                        --
 --                                                                           --
 -- Permission is hereby granted, free of charge, to any person obtaining a   --
 -- copy of this software and associated documentation files (the             --
@@ -25,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: README,v 1.2 2006/04/22 22:19:37 tom Exp $
+-- $Id: README,v 1.3 2020/02/02 23:34:34 tom Exp $
 -------------------------------------------------------------------------------
 
 The files in this directory (trace) support both the terminfo and ncurses
diff --git a/ncurses/trace/lib_trace.c b/ncurses/trace/lib_trace.c
index cec01de..0904c13 100644
--- a/ncurses/trace/lib_trace.c
+++ b/ncurses/trace/lib_trace.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -36,7 +37,7 @@
 /*
  *	lib_trace.c - Tracing/Debugging routines
  *
- * The _tracef() function is originally from pcurses (by Pavel Curtis) in 1982. 
+ * The _tracef() function is originally from pcurses (by Pavel Curtis) in 1982.
  * pcurses allowed one to enable/disable tracing using traceon() and traceoff()
  * functions.  ncurses provides a trace() function which allows one to
  * selectively enable or disable several tracing features.
@@ -47,7 +48,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_trace.c,v 1.82 2013/07/06 19:42:09 tom Exp $")
+MODULE_ID("$Id: lib_trace.c,v 1.106 2024/02/24 18:28:19 tom Exp $")
 
 NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */
 
@@ -85,60 +86,130 @@
 NCURSES_EXPORT_VAR(long) _nc_outchars = 0;
 #endif
 
-#define TraceFP		_nc_globals.trace_fp
-#define TracePath	_nc_globals.trace_fname
-#define TraceLevel	_nc_globals.trace_level
+#define MyFP		_nc_globals.trace_fp
+#define MyFD		_nc_globals.trace_fd
+#define MyInit		_nc_globals.trace_opened
+#define MyLevel		_nc_globals.trace_level
+#define MyNested	_nc_globals.nested_tracef
+#endif /* TRACE */
 
-NCURSES_EXPORT(void)
-trace(const unsigned int tracelevel)
+#if USE_REENTRANT
+#define Locked(statement) \
+    do { \
+	_nc_lock_global(tst_tracef); \
+	statement; \
+	_nc_unlock_global(tst_tracef); \
+    } while (0)
+#else
+#define Locked(statement) statement
+#endif
+
+NCURSES_EXPORT(unsigned)
+curses_trace(unsigned tracelevel)
 {
-    if ((TraceFP == 0) && tracelevel) {
-	const char *mode = _nc_globals.init_trace ? "ab" : "wb";
+    unsigned result;
 
-	if (TracePath[0] == '\0') {
-	    size_t size = sizeof(TracePath) - 12;
-	    if (getcwd(TracePath, size) == 0) {
-		perror("curses: Can't get working directory");
-		exit(EXIT_FAILURE);
+#if defined(TRACE)
+    int bit;
+
+#define DATA(name) { name, #name }
+    static struct {
+	unsigned mask;
+	const char *name;
+    } trace_names[] = {
+	DATA(TRACE_TIMES),
+	    DATA(TRACE_TPUTS),
+	    DATA(TRACE_UPDATE),
+	    DATA(TRACE_MOVE),
+	    DATA(TRACE_CHARPUT),
+	    DATA(TRACE_CALLS),
+	    DATA(TRACE_VIRTPUT),
+	    DATA(TRACE_IEVENT),
+	    DATA(TRACE_BITS),
+	    DATA(TRACE_ICALLS),
+	    DATA(TRACE_CCALLS),
+	    DATA(TRACE_DATABASE),
+	    DATA(TRACE_ATTRS)
+    };
+#undef DATA
+
+    Locked(result = _nc_tracing);
+
+    if ((MyFP == 0) && tracelevel) {
+	MyInit = TRUE;
+	if (MyFD >= 0) {
+	    MyFP = fdopen(MyFD, BIN_W);
+	} else {
+	    char myFile[80];
+
+	    _nc_STRCPY(myFile, "trace", sizeof(myFile));
+	    if (_nc_is_dir_path(myFile)) {
+		_nc_STRCAT(myFile, ".log", sizeof(myFile));
 	    }
-	    TracePath[size] = '\0';
-	    assert(strlen(TracePath) <= size);
-	    _nc_STRCAT(TracePath, "/trace", sizeof(TracePath));
-	    if (_nc_is_dir_path(TracePath)) {
-		_nc_STRCAT(TracePath, ".log", sizeof(TracePath));
+#define SAFE_MODE (O_CREAT | O_EXCL | O_RDWR)
+	    if (_nc_access(myFile, W_OK) < 0
+		|| (MyFD = safe_open3(myFile, SAFE_MODE, 0600)) < 0
+		|| (MyFP = fdopen(MyFD, BIN_W)) == 0) {
+		;		/* EMPTY */
 	    }
 	}
-
-	_nc_globals.init_trace = TRUE;
-	_nc_tracing = tracelevel;
-	if (_nc_access(TracePath, W_OK) < 0
-	    || (TraceFP = fopen(TracePath, mode)) == 0) {
-	    perror("curses: Can't open 'trace' file");
-	    exit(EXIT_FAILURE);
-	}
+	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. 
+	 * end of each line.  This is useful in case the program dies.
 	 */
+	if (MyFP != 0) {
 #if HAVE_SETVBUF		/* ANSI */
-	(void) setvbuf(TraceFP, (char *) 0, _IOLBF, (size_t) 0);
+	    (void) setvbuf(MyFP, (char *) 0, _IOLBF, (size_t) 0);
 #elif HAVE_SETBUF /* POSIX */
-	(void) setbuffer(TraceFP, (char *) 0);
+	    (void) setbuffer(MyFP, (char *) 0);
 #endif
+	}
 	_tracef("TRACING NCURSES version %s.%d (tracelevel=%#x)",
 		NCURSES_VERSION,
 		NCURSES_VERSION_PATCH,
 		tracelevel);
-    } else if (tracelevel == 0) {
-	if (TraceFP != 0) {
-	    fclose(TraceFP);
-	    TraceFP = 0;
+
+#define SPECIAL_MASK(mask) \
+	    if ((tracelevel & mask) == mask) \
+		_tracef("- %s (%u)", #mask, mask)
+
+	for (bit = 0; bit < TRACE_SHIFT; ++bit) {
+	    unsigned mask = (1U << bit) & tracelevel;
+	    if ((mask & trace_names[bit].mask) != 0) {
+		_tracef("- %s (%u)", trace_names[bit].name, mask);
+	    }
 	}
-	_nc_tracing = tracelevel;
+	SPECIAL_MASK(TRACE_MAXIMUM);
+	else
+	SPECIAL_MASK(TRACE_ORDINARY);
+
+	if (tracelevel > TRACE_MAXIMUM) {
+	    _tracef("- DEBUG_LEVEL(%u)", tracelevel >> TRACE_SHIFT);
+	}
+    } else if (tracelevel == 0) {
+	if (MyFP != 0) {
+	    MyFD = dup(MyFD);	/* allow reopen of same file */
+	    fclose(MyFP);
+	    MyFP = 0;
+	}
+	Locked(_nc_tracing = tracelevel);
     } else if (_nc_tracing != tracelevel) {
-	_nc_tracing = tracelevel;
+	Locked(_nc_tracing = tracelevel);
 	_tracef("tracelevel=%#x", tracelevel);
     }
+#else
+    (void) tracelevel;
+    result = 0;
+#endif
+    return result;
+}
+
+#if defined(TRACE)
+NCURSES_EXPORT(void)
+trace(const unsigned int tracelevel)
+{
+    curses_trace(tracelevel);
 }
 
 static void
@@ -151,16 +222,23 @@
     bool after = FALSE;
     unsigned doit = _nc_tracing;
     int save_err = errno;
+    FILE *fp = MyFP;
+
+#ifdef TRACE
+    /* verbose-trace in the command-line utilities relies on this */
+    if (fp == 0 && !MyInit && _nc_tracing >= DEBUG_LEVEL(1))
+	fp = stderr;
+#endif
 
     if (strlen(fmt) >= sizeof(Called) - 1) {
 	if (!strncmp(fmt, Called, sizeof(Called) - 1)) {
 	    before = TRUE;
-	    TraceLevel++;
+	    MyLevel++;
 	} else if (!strncmp(fmt, Return, sizeof(Return) - 1)) {
 	    after = TRUE;
 	}
 	if (before || after) {
-	    if ((TraceLevel <= 1)
+	    if ((MyLevel <= 1)
 		|| (doit & TRACE_ICALLS) != 0)
 		doit &= (TRACE_CALLS | TRACE_CCALLS);
 	    else
@@ -168,9 +246,7 @@
 	}
     }
 
-    if (doit != 0) {
-	if (TraceFP == 0)
-	    TraceFP = stderr;
+    if (doit != 0 && fp != 0) {
 #ifdef USE_PTHREADS
 	/*
 	 * TRACE_ICALLS is "really" needed to show normal use with threaded
@@ -184,30 +260,32 @@
 # if USE_WEAK_SYMBOLS
 	if ((pthread_self))
 # endif
-#ifdef __MINGW32__
-	    fprintf(TraceFP, "%#lx:", (long) (intptr_t) pthread_self().p);
+	    fprintf(fp, "%#" PRIxPTR ":",
+#ifdef _NC_WINDOWS
+		    CASTxPTR(pthread_self().p)
 #else
-	    fprintf(TraceFP, "%#lx:", (long) (intptr_t) pthread_self());
+		    CASTxPTR(pthread_self())
 #endif
+		);
 #endif
 	if (before || after) {
 	    int n;
-	    for (n = 1; n < TraceLevel; n++)
-		fputs("+ ", TraceFP);
+	    for (n = 1; n < MyLevel; n++)
+		fputs("+ ", fp);
 	}
-	vfprintf(TraceFP, fmt, ap);
-	fputc('\n', TraceFP);
-	fflush(TraceFP);
+	vfprintf(fp, fmt, ap);
+	fputc('\n', fp);
+	fflush(fp);
     }
 
-    if (after && TraceLevel)
-	TraceLevel--;
+    if (after && MyLevel)
+	MyLevel--;
 
     errno = save_err;
 }
 
 NCURSES_EXPORT(void)
-_tracef(const char *fmt,...)
+_tracef(const char *fmt, ...)
 {
     va_list ap;
 
@@ -296,6 +374,39 @@
     return code;
 }
 
+NCURSES_EXPORT(char *)
+_nc_fmt_funcptr(char *target, const char *source, size_t size)
+{
+    size_t n;
+    char *dst = target;
+    bool leading = TRUE;
+
+    union {
+	int value;
+	char bytes[sizeof(int)];
+    } byteorder;
+
+    byteorder.value = 0x1234;
+
+    *dst++ = '0';
+    *dst++ = 'x';
+
+    for (n = 0; n < size; ++n) {
+	unsigned ch = ((byteorder.bytes[0] == 0x34)
+		       ? UChar(source[size - n - 1])
+		       : UChar(source[n]));
+	if (ch != 0 || (n + 1) >= size)
+	    leading = FALSE;
+	if (!leading) {
+	    _nc_SPRINTF(dst, _nc_SLIMIT(TR_FUNC_LEN - (size_t) (dst - target))
+			"%02x", ch & 0xff);
+	    dst += 2;
+	}
+    }
+    *dst = '\0';
+    return target;
+}
+
 #if USE_REENTRANT
 /*
  * Check if the given trace-mask is enabled.
@@ -310,13 +421,13 @@
     bool result = FALSE;
 
     _nc_lock_global(tst_tracef);
-    if (!_nc_globals.nested_tracef++) {
+    if (!MyNested++) {
 	if ((result = (_nc_tracing & (mask))) != 0
 	    && _nc_try_global(tracef) == 0) {
 	    /* we will call _nc_locked_tracef(), no nesting so far */
 	} else {
 	    /* we will not call _nc_locked_tracef() */
-	    _nc_globals.nested_tracef = 0;
+	    MyNested = 0;
 	}
     } else {
 	/* we may call _nc_locked_tracef(), but with nested_tracef > 0 */
@@ -331,7 +442,7 @@
  * the tracef mutex.
  */
 NCURSES_EXPORT(void)
-_nc_locked_tracef(const char *fmt,...)
+_nc_locked_tracef(const char *fmt, ...)
 {
     va_list ap;
 
@@ -339,7 +450,7 @@
     _nc_va_tracef(fmt, ap);
     va_end(ap);
 
-    if (--(_nc_globals.nested_tracef) == 0) {
+    if (--(MyNested) == 0) {
 	_nc_unlock_global(tracef);
     }
 }
diff --git a/ncurses/trace/lib_traceatr.c b/ncurses/trace/lib_traceatr.c
index 24772d8..b362862 100644
--- a/ncurses/trace/lib_traceatr.c
+++ b/ncurses/trace/lib_traceatr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2024 Thomas E. Dickey                                *
+ * Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -43,7 +44,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_traceatr.c,v 1.83 2015/04/04 13:41:37 tom Exp $")
+MODULE_ID("$Id: lib_traceatr.c,v 1.96 2024/02/04 00:11:35 tom Exp $")
 
 #define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
 
@@ -67,7 +68,7 @@
     if (c != my_cached) {
 	my_cached = c;
 	my_select = !my_select;
-	if (c == COLOR_DEFAULT)
+	if (isDefaultColor(c))
 	    _nc_STRCPY(my_buffer[my_select], "default",
 		       COLOR_BUF_SIZE(my_select));
 	else
@@ -123,11 +124,10 @@
 #endif /* !USE_TERMLIB */
     ;
 #undef DATA
-    size_t n;
-    char temp[80];
     char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
 
     if (result != 0) {
+	size_t n;
 	unsigned save_nc_tracing = _nc_tracing;
 
 	_nc_tracing = 0;
@@ -135,12 +135,14 @@
 	_nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum));
 
 	for (n = 0; n < SIZEOF(names); n++) {
+
 	    if ((newmode & names[n].val) != 0) {
 		if (result[1] != '\0')
 		    (void) _nc_trace_bufcat(bufnum, "|");
 		result = _nc_trace_bufcat(bufnum, names[n].name);
 
 		if (names[n].val == A_COLOR) {
+		    char temp[80];
 		    short pairnum = (short) PairNumber(newmode);
 #ifdef USE_TERMLIB
 		    /* pair_content lives in libncurses */
@@ -254,7 +256,6 @@
     if (SP_PARM != 0 && (attr & A_ALTCHARSET) && (acs_chars != 0)) {
 	char *cp;
 	char *found = 0;
-	size_t n;
 
 	for (cp = acs_chars; cp[0] && cp[1]; cp += 2) {
 	    if (ChCharOf(UChar(cp[1])) == ChCharOf(ch)) {
@@ -264,6 +265,8 @@
 	}
 
 	if (found != 0) {
+	    size_t n;
+
 	    ch = ChCharOf(UChar(*found));
 	    for (n = 0; n < SIZEOF(names); ++n) {
 		if (names[n].val == ch) {
@@ -279,22 +282,25 @@
 NCURSES_EXPORT(char *)
 _tracechtype2(int bufnum, chtype ch)
 {
-    const char *found;
     char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
 
     if (result != 0) {
+	const char *found;
+	attr_t attr = ChAttrOf(ch);
+
 	_nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum));
-	if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
+	if ((found = _nc_altcharset_name(attr, ch)) != 0) {
 	    (void) _nc_trace_bufcat(bufnum, found);
+	    attr &= ~A_ALTCHARSET;
 	} else
 	    (void) _nc_trace_bufcat(bufnum,
 				    _nc_tracechar(CURRENT_SCREEN,
 						  (int) ChCharOf(ch)));
 
-	if (ChAttrOf(ch) != A_NORMAL) {
+	if (attr != A_NORMAL) {
 	    (void) _nc_trace_bufcat(bufnum, " | ");
 	    (void) _nc_trace_bufcat(bufnum,
-				    _traceattr2(bufnum + 20, ChAttrOf(ch)));
+				    _traceattr2(bufnum + 20, attr));
 	}
 
 	result = _nc_trace_bufcat(bufnum, r_brace);
@@ -321,13 +327,13 @@
 _tracecchar_t2(int bufnum, const cchar_t *ch)
 {
     char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
-    attr_t attr;
-    const char *found;
 
     if (result != 0) {
 	_nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum));
 	if (ch != 0) {
-	    attr = AttrOfD(ch);
+	    const char *found;
+	    attr_t attr = AttrOfD(ch);
+
 	    if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) {
 		(void) _nc_trace_bufcat(bufnum, found);
 		attr &= ~A_ALTCHARSET;
@@ -337,8 +343,8 @@
 	    } else {
 		PUTC_DATA;
 		int n;
+		int assume_unicode = _nc_unicode_locale()? 128 : 255;
 
-		PUTC_INIT;
 		(void) _nc_trace_bufcat(bufnum, "{ ");
 		for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
 		    PUTC_ch = ch->chars[PUTC_i];
@@ -347,6 +353,7 @@
 			    (void) _nc_trace_bufcat(bufnum, "\\000");
 			break;
 		    }
+		    PUTC_INIT;
 		    PUTC_n = (int) wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
 		    if (PUTC_n <= 0) {
 			if (PUTC_ch != L'\0') {
@@ -356,13 +363,22 @@
 								  UChar(ch->chars[PUTC_i])));
 			}
 			break;
-		    }
-		    for (n = 0; n < PUTC_n; n++) {
-			if (n)
-			    (void) _nc_trace_bufcat(bufnum, ", ");
-			(void) _nc_trace_bufcat(bufnum,
-						_nc_tracechar(CURRENT_SCREEN,
-							      UChar(PUTC_buf[n])));
+		    } else if (ch->chars[PUTC_i] > assume_unicode) {
+			char temp[80];
+			_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+				    "{%d:\\u%04lx}",
+				    _nc_wacs_width(ch->chars[PUTC_i]),
+				    (unsigned long) ch->chars[PUTC_i]);
+			(void) _nc_trace_bufcat(bufnum, temp);
+			attr &= ~A_CHARTEXT;	/* ignore WidecExt(ch) */
+		    } else {
+			for (n = 0; n < PUTC_n; n++) {
+			    if (n)
+				(void) _nc_trace_bufcat(bufnum, ", ");
+			    (void) _nc_trace_bufcat(bufnum,
+						    _nc_tracechar(CURRENT_SCREEN,
+								  UChar(PUTC_buf[n])));
+			}
 		    }
 		}
 		(void) _nc_trace_bufcat(bufnum, " }");
@@ -371,6 +387,18 @@
 		(void) _nc_trace_bufcat(bufnum, " | ");
 		(void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
 	    }
+#if NCURSES_EXT_COLORS
+	    /*
+	     * Just in case the extended color is different from the chtype
+	     * value, trace both.
+	     */
+	    if (ch->ext_color != PairNumber(attr)) {
+		char temp[80];
+		_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+			    " X_COLOR{%d:%d}", ch->ext_color, PairNumber(attr));
+		(void) _nc_trace_bufcat(bufnum, temp);
+	    }
+#endif
 	}
 
 	result = _nc_trace_bufcat(bufnum, r_brace);
diff --git a/ncurses/trace/lib_tracebits.c b/ncurses/trace/lib_tracebits.c
index f880b67..4bc50f3 100644
--- a/ncurses/trace/lib_tracebits.c
+++ b/ncurses/trace/lib_tracebits.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2015 Free Software Foundation, Inc.              *
+ * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2012,2015 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,7 +35,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_tracebits.c,v 1.26 2015/04/19 14:58:39 tom Exp $")
+MODULE_ID("$Id: lib_tracebits.c,v 1.31 2020/11/14 23:38:11 tom Exp $")
 
 #if HAVE_SYS_TERMIO_H
 #include <sys/termio.h>		/* needed for ISC */
@@ -71,9 +72,15 @@
 
 #ifdef TRACE
 
+#if defined(EXP_WIN32_DRIVER)
+#define BITNAMELEN 36
+#else
+#define BITNAMELEN 8
+#endif
+
 typedef struct {
     unsigned int val;
-    const char name[8];
+    const char name[BITNAMELEN];
 } BITNAMES;
 
 #define TRACE_BUF_SIZE(num) (_nc_globals.tracebuf_ptr[num].size)
@@ -97,7 +104,7 @@
 }
 
 NCURSES_EXPORT(char *)
-_nc_trace_ttymode(TTY * tty)
+_nc_trace_ttymode(const TTY * tty)
 /* describe the state of the terminal control bits exactly */
 {
     char *buf;
@@ -130,7 +137,7 @@
 	DATA(ONOCR),
 	DATA(ONLRET),
 	DATAX()
-#define ALLOUT	(OPOST|OFLAGS_TABS|ONLCR|OCRNL|ONOCR|ONLRET)
+#define ALLOUT	(OPOST|OFLAGS_TABS|ONLCR|OCRNL|ONOCR|ONLRET|OFLAGS_TABS)
     }, cflags[] =
     {
 	DATA(CLOCAL),
@@ -211,6 +218,36 @@
 	if (tty->c_lflag & ALLLOCAL)
 	    lookup_bits(buf, lflags, "lflags", tty->c_lflag);
     }
+#elif defined(EXP_WIN32_DRIVER)
+#define DATA(name)        { name, { #name } }
+    static const BITNAMES dwFlagsOut[] =
+    {
+	DATA(ENABLE_PROCESSED_OUTPUT),
+	DATA(ENABLE_WRAP_AT_EOL_OUTPUT),
+	DATA(ENABLE_VIRTUAL_TERMINAL_PROCESSING),
+	DATA(DISABLE_NEWLINE_AUTO_RETURN),
+	DATA(ENABLE_LVB_GRID_WORLDWIDE)
+    };
+    static const BITNAMES dwFlagsIn[] =
+    {
+	DATA(ENABLE_PROCESSED_INPUT),
+	DATA(ENABLE_LINE_INPUT),
+	DATA(ENABLE_ECHO_INPUT),
+	DATA(ENABLE_MOUSE_INPUT),
+	DATA(ENABLE_INSERT_MODE),
+	DATA(ENABLE_QUICK_EDIT_MODE),
+	DATA(ENABLE_EXTENDED_FLAGS),
+	DATA(ENABLE_AUTO_POSITION),
+	DATA(ENABLE_VIRTUAL_TERMINAL_INPUT)
+    };
+
+    buf = _nc_trace_buf(0,
+			8 + sizeof(dwFlagsOut) +
+			8 + sizeof(dwFlagsIn));
+    if (buf != 0) {
+	lookup_bits(buf, dwFlagsIn, "dwIn", tty->dwFlagIn);
+	lookup_bits(buf, dwFlagsOut, "dwOut", tty->dwFlagOut);
+    }
 #else
     /* reference: ttcompat(4M) on SunOS 4.1 */
 #ifndef EVENP
diff --git a/ncurses/trace/lib_tracechr.c b/ncurses/trace/lib_tracechr.c
index 8977f75..9c879dc 100644
--- a/ncurses/trace/lib_tracechr.c
+++ b/ncurses/trace/lib_tracechr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020,2024 Thomas E. Dickey                                     *
+ * Copyright 1998-2009,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_tracechr.c,v 1.22 2012/02/22 22:40:24 tom Exp $")
+MODULE_ID("$Id: lib_tracechr.c,v 1.24 2024/02/04 00:11:35 tom Exp $")
 
 #ifdef TRACE
 
@@ -53,26 +54,28 @@
 		      ? sp->tracechr_buf
 		      : _nc_globals.tracechr_buf);
 
-    if (ch > KEY_MIN || ch < 0) {
+    if ((ch > KEY_MIN && !_nc_unicode_locale()) || ch < 0) {
 	name = safe_keyname(SP_PARM, ch);
 	if (name == 0 || *name == '\0')
 	    name = "NULL";
 	_nc_SPRINTF(MyBuffer, _nc_SLIMIT(MyBufSize)
-		    "'%.30s' = %#03o", name, ch);
-    } else if (!is8bits(ch) || !isprint(UChar(ch))) {
+		    "'%.30s' = \\x%02x", name, ch);
+    } else if (!is8bits(ch)
+	       || (_nc_unicode_locale() && !is7bits(ch))
+	       || !isprint(UChar(ch))) {
 	/*
 	 * workaround for glibc bug:
 	 * sprintf changes the result from unctrl() to an empty string if it
 	 * does not correspond to a valid multibyte sequence.
 	 */
 	_nc_SPRINTF(MyBuffer, _nc_SLIMIT(MyBufSize)
-		    "%#03o", ch);
+		    "\\x%02x", ch);
     } else {
 	name = safe_unctrl(SP_PARM, (chtype) ch);
 	if (name == 0 || *name == 0)
 	    name = "null";	/* shouldn't happen */
 	_nc_SPRINTF(MyBuffer, _nc_SLIMIT(MyBufSize)
-		    "'%.30s' = %#03o", name, ch);
+		    "'%.30s' = \\x%02x", name, ch);
     }
     return (MyBuffer);
 }
diff --git a/ncurses/trace/lib_tracedmp.c b/ncurses/trace/lib_tracedmp.c
index 0fda15b..529148b 100644
--- a/ncurses/trace/lib_tracedmp.c
+++ b/ncurses/trace/lib_tracedmp.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 1998-2012,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_tracedmp.c,v 1.34 2012/10/27 20:54:42 tom Exp $")
+MODULE_ID("$Id: lib_tracedmp.c,v 1.37 2023/06/24 15:49:45 tom Exp $")
 
 #ifdef TRACE
 
@@ -70,13 +71,13 @@
     if (++width + 1 > (int) my_length) {
 	my_length = (unsigned) (2 * (width + 1));
 	my_buffer = typeRealloc(char, my_length, my_buffer);
-	if (my_buffer == 0)
-	    return;
     }
+    if (my_buffer == 0)
+	return;
 
     for (n = 0; n <= win->_maxy; ++n) {
 	char *ep = my_buffer;
-	bool haveattrs, havecolors;
+	bool havecolors;
 
 	/*
 	 * Dump A_CHARTEXT part.  It is more important to make the grid line up
@@ -156,8 +157,8 @@
 	for (i = 0; i < 4; ++i) {
 	    const char *hex = " 123456789ABCDEF";
 	    attr_t mask = (attr_t) (0xf << ((i + 4) * 4));
+	    bool haveattrs = FALSE;
 
-	    haveattrs = FALSE;
 	    for (j = 0; j < width; ++j)
 		if (AttrOf(win->_line[n].text[j]) & mask) {
 		    haveattrs = TRUE;
diff --git a/ncurses/trace/lib_tracemse.c b/ncurses/trace/lib_tracemse.c
index c62b71a..33d4d3d 100644
--- a/ncurses/trace/lib_tracemse.c
+++ b/ncurses/trace/lib_tracemse.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2012,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -38,7 +39,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_tracemse.c,v 1.22 2014/10/10 09:06:26 tom Exp $")
+MODULE_ID("$Id: lib_tracemse.c,v 1.23 2020/02/02 23:34:34 tom Exp $")
 
 #ifdef TRACE
 
diff --git a/ncurses/trace/trace_buf.c b/ncurses/trace/trace_buf.c
index 84a7a0c..91b12e4 100644
--- a/ncurses/trace/trace_buf.c
+++ b/ncurses/trace/trace_buf.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 1998-2011,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -35,7 +36,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: trace_buf.c,v 1.20 2012/02/22 22:34:31 tom Exp $")
+MODULE_ID("$Id: trace_buf.c,v 1.22 2023/06/24 13:37:25 tom Exp $")
 
 #ifdef TRACE
 
@@ -103,7 +104,11 @@
 NCURSES_EXPORT(char *)
 _nc_trace_bufcat(int bufnum, const char *value)
 {
-    char *buffer = _nc_trace_alloc(bufnum, (size_t) 0);
+    char *buffer;
+
+    if (value == NULL)
+	value = "";
+    buffer = _nc_trace_alloc(bufnum, (size_t) 0);
     if (buffer != 0) {
 	size_t have = strlen(buffer);
 	size_t need = strlen(value) + have;
diff --git a/ncurses/trace/trace_tries.c b/ncurses/trace/trace_tries.c
index 50ba016..14f704b 100644
--- a/ncurses/trace/trace_tries.c
+++ b/ncurses/trace/trace_tries.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1999-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1999-2011,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -35,7 +36,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: trace_tries.c,v 1.17 2012/10/27 20:50:50 tom Exp $")
+MODULE_ID("$Id: trace_tries.c,v 1.18 2020/02/02 23:34:34 tom Exp $")
 
 #ifdef TRACE
 #define my_buffer _nc_globals.tracetry_buf
diff --git a/ncurses/trace/trace_xnames.c b/ncurses/trace/trace_xnames.c
index 38a4873..2d74336 100644
--- a/ncurses/trace/trace_xnames.c
+++ b/ncurses/trace/trace_xnames.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1999-2000,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1999-2010,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -35,7 +36,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: trace_xnames.c,v 1.6 2010/01/23 17:59:27 tom Exp $")
+MODULE_ID("$Id: trace_xnames.c,v 1.8 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(void)
 _nc_trace_xnames(TERMTYPE *tp GCC_UNUSED)
@@ -43,8 +44,9 @@
 #ifdef TRACE
 #if NCURSES_XNAMES
     int limit = tp->ext_Booleans + tp->ext_Numbers + tp->ext_Strings;
-    int n, m;
+
     if (limit) {
+	int n;
 	int begin_num = tp->ext_Booleans;
 	int begin_str = tp->ext_Booleans + tp->ext_Numbers;
 
@@ -53,7 +55,10 @@
 		limit,
 		tp->ext_Booleans, tp->ext_Numbers, tp->ext_Strings,
 		tp->num_Booleans, tp->num_Numbers, tp->num_Strings);
+
 	for (n = 0; n < limit; n++) {
+	    int m;
+
 	    if ((m = n - begin_str) >= 0) {
 		_tracef("[%d] %s = %s", n,
 			tp->ext_Names[n],
diff --git a/ncurses/trace/varargs.c b/ncurses/trace/varargs.c
index 66252d8..7b9533b 100644
--- a/ncurses/trace/varargs.c
+++ b/ncurses/trace/varargs.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2001-2008,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 2001-2008,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,7 +35,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: varargs.c,v 1.11 2012/10/27 21:03:28 tom Exp $")
+MODULE_ID("$Id: varargs.c,v 1.13 2023/06/24 13:41:46 tom Exp $")
 
 #ifdef TRACE
 
@@ -58,18 +59,16 @@
 NCURSES_EXPORT(char *)
 _nc_varargs(const char *fmt, va_list ap)
 {
-    static char dummy[] = "";
-
     char buffer[BUFSIZ];
     const char *param;
     int n;
 
     if (fmt == 0 || *fmt == '\0')
-	return dummy;
+	return NULL;
     if (MyLength == 0)
 	MyBuffer = typeMalloc(char, MyLength = BUFSIZ);
     if (MyBuffer == 0)
-	return dummy;
+	return NULL;
     *MyBuffer = '\0';
 
     while (*fmt != '\0') {
@@ -184,7 +183,7 @@
 	}
     }
 
-    return (MyBuffer ? MyBuffer : dummy);
+    return (MyBuffer ? MyBuffer : NULL);
 }
 #else
 EMPTY_MODULE(_nc_varargs)
diff --git a/ncurses/trace/visbuf.c b/ncurses/trace/visbuf.c
index fec0643..590e423 100644
--- a/ncurses/trace/visbuf.c
+++ b/ncurses/trace/visbuf.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2001-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019-2021,2023 Thomas E. Dickey                                *
+ * Copyright 2001-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +43,7 @@
 #include <tic.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: visbuf.c,v 1.44 2014/09/25 08:51:13 tom Exp $")
+MODULE_ID("$Id: visbuf.c,v 1.54 2023/05/27 20:13:10 tom Exp $")
 
 #define NUM_VISBUFS 4
 
@@ -66,7 +67,9 @@
 static char *
 _nc_vischar(char *tp, unsigned c LIMIT_ARG)
 {
-    if (c == '"' || c == '\\') {
+    if (tp == NULL) {
+	return NULL;
+    } else if (c == '"' || c == '\\') {
 	*tp++ = '\\';
 	*tp++ = (char) c;
     } else if (is7bits((int) c) && (isgraph((int) c) || c == ' ')) {
@@ -80,6 +83,9 @@
     } else if (c == '\b') {
 	*tp++ = '\\';
 	*tp++ = 'b';
+    } else if (c == '\t') {
+	*tp++ = '\\';
+	*tp++ = 't';
     } else if (c == '\033') {
 	*tp++ = '\\';
 	*tp++ = 'e';
@@ -105,7 +111,6 @@
 {
     const char *vbuf = 0;
     char *tp;
-    int c;
     int count;
 
     if (buf == 0)
@@ -122,6 +127,8 @@
 #else
     {
 	static char *mybuf[NUM_VISBUFS];
+	int c;
+
 	if (bufnum < 0) {
 	    for (c = 0; c < NUM_VISBUFS; ++c) {
 		FreeAndNull(mybuf[c]);
@@ -134,6 +141,8 @@
     }
 #endif
     if (tp != 0) {
+	int c;
+
 	*tp++ = D_QUOTE;
 	while ((--count >= 0) && (c = *buf++) != '\0') {
 	    tp = VisChar(tp, UChar(c), NormalLen(len));
@@ -185,7 +194,6 @@
 {
     const char *vbuf;
     char *tp;
-    wchar_t c;
     int count;
 
     if (buf == 0)
@@ -205,6 +213,8 @@
     }
 #endif
     if (tp != 0) {
+	wchar_t c;
+
 	*tp++ = D_QUOTE;
 	while ((--count >= 0) && (c = *buf++) != '\0') {
 	    char temp[CCHARW_MAX + 80];
@@ -275,13 +285,13 @@
 
 /* use these functions for displaying parts of a line within a window */
 NCURSES_EXPORT(const char *)
-_nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len)
+_nc_viscbuf2(int bufnum, const NCURSES_CH_T *buf, int len)
 {
     char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
-    int first;
-    const char *found;
 
     if (result != 0) {
+	int first = 0;
+
 #if USE_WIDEC_SUPPORT
 	if (len < 0)
 	    len = _nc_wchstrlen(buf);
@@ -290,7 +300,6 @@
 	/*
 	 * Display one or more strings followed by attributes.
 	 */
-	first = 0;
 	while (first < len) {
 	    attr_t attr = AttrOf(buf[first]);
 	    int last = len - 1;
@@ -306,7 +315,8 @@
 	    (void) _nc_trace_bufcat(bufnum, l_brace);
 	    (void) _nc_trace_bufcat(bufnum, d_quote);
 	    for (j = first; j <= last; ++j) {
-		found = _nc_altcharset_name(attr, (chtype) CharOf(buf[j]));
+		const char *found = _nc_altcharset_name(attr, (chtype)
+							CharOf(buf[j]));
 		if (found != 0) {
 		    (void) _nc_trace_bufcat(bufnum, found);
 		    attr &= ~A_ALTCHARSET;
@@ -315,9 +325,9 @@
 		if (!isWidecExt(buf[j])) {
 		    PUTC_DATA;
 
-		    PUTC_INIT;
 		    for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
 			int k;
+			char temp[80];
 
 			PUTC_ch = buf[j].chars[PUTC_i];
 			if (PUTC_ch == L'\0') {
@@ -325,12 +335,18 @@
 				(void) _nc_trace_bufcat(bufnum, "\\000");
 			    break;
 			}
+			PUTC_INIT;
 			PUTC_n = (int) wcrtomb(PUTC_buf,
 					       buf[j].chars[PUTC_i], &PUT_st);
-			if (PUTC_n <= 0)
+			if (PUTC_n <= 0 || buf[j].chars[PUTC_i] > 255) {
+			    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+					"{%d:\\u%lx}",
+					_nc_wacs_width(buf[j].chars[PUTC_i]),
+					(unsigned long) buf[j].chars[PUTC_i]);
+			    (void) _nc_trace_bufcat(bufnum, temp);
 			    break;
+			}
 			for (k = 0; k < PUTC_n; k++) {
-			    char temp[80];
 			    VisChar(temp, UChar(PUTC_buf[k]), sizeof(temp));
 			    (void) _nc_trace_bufcat(bufnum, temp);
 			}
@@ -357,7 +373,7 @@
 }
 
 NCURSES_EXPORT(const char *)
-_nc_viscbuf(const NCURSES_CH_T * buf, int len)
+_nc_viscbuf(const NCURSES_CH_T *buf, int len)
 {
     return _nc_viscbuf2(0, buf, len);
 }
diff --git a/ncurses/tty/MKexpanded.sh b/ncurses/tty/MKexpanded.sh
index 7a5f599..0072be2 100755
--- a/ncurses/tty/MKexpanded.sh
+++ b/ncurses/tty/MKexpanded.sh
@@ -1,6 +1,7 @@
 #! /bin/sh
 ##############################################################################
-# Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.                #
+# Copyright 2019-2020,2021 Thomas E. Dickey                                  #
+# Copyright 1998-2015,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -29,7 +30,7 @@
 #
 # Author: Thomas E. Dickey, 1997-on
 #
-# $Id: MKexpanded.sh,v 1.17 2010/01/23 17:57:43 tom Exp $
+# $Id: MKexpanded.sh,v 1.24 2022/02/05 17:27:18 tom Exp $
 #
 # Script to generate 'expanded.c', a dummy source that contains functions
 # corresponding to complex macros used in this library.  By making functions,
@@ -48,7 +49,8 @@
 fi
 
 TMP=gen$$.c
-trap "rm -f $TMP" 0 1 2 5 15
+trap "rm -f $TMP; exit 1" 1 2 3 15
+trap "rm -f $TMP" 0
 
 cat <<EOF
 /* generated by MKexpanded.sh */
@@ -80,7 +82,7 @@
 }
 
 NCURSES_EXPORT(void)
-_nc_toggle_attr_off (attr_t *S, attr_t at) 
+_nc_toggle_attr_off (attr_t *S, attr_t at)
 {
 	toggle_attr_off(*S,at);
 }
@@ -125,7 +127,7 @@
 EOF
 
 $preprocessor $TMP 2>/dev/null | \
-	sed -e '1,/^IGNORE$/d' -e 's/^@/#/' -e 's/^#if_/#if /'
+	sed -e '1,/^IGNORE$/d' -e 's/^@/#/' -e 's/^#[ 	]*if_/#if /' -e "s,$TMP,expanded.c,"
 
 cat <<EOF
 #else /* ! NCURSES_EXPANDED */
diff --git a/ncurses/tty/hardscroll.c b/ncurses/tty/hardscroll.c
index d6f28d6..2b1f079 100644
--- a/ncurses/tty/hardscroll.c
+++ b/ncurses/tty/hardscroll.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2015 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -147,7 +148,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: hardscroll.c,v 1.52 2015/07/25 20:13:07 tom Exp $")
+MODULE_ID("$Id: hardscroll.c,v 1.58 2023/09/09 16:04:08 Nicholas.Marriott Exp $")
 
 #if defined(SCROLLDEBUG) || defined(HASHDEBUG)
 
@@ -203,13 +204,19 @@
 	int *new_oldnums = typeRealloc(int,
 				       (size_t) need_lines,
 				       oldnums(SP_PARM));
-	if (!new_oldnums)
+	if (!new_oldnums) {
+	    TR(TRACE_ICALLS, (T_RETURN("")));
 	    return;
+	}
 	oldnums(SP_PARM) = new_oldnums;
 	OLDNUM_SIZE(SP_PARM) = need_lines;
     }
     /* calculate the indices */
     NCURSES_SP_NAME(_nc_hash_map) (NCURSES_SP_ARG);
+    if (SP_PARM->hashtab_len < screen_lines(SP_PARM)) {
+	TR(TRACE_ICALLS, (T_RETURN("")));
+	return;
+    }
 #endif
 #endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */
 
@@ -300,20 +307,27 @@
 NCURSES_SP_NAME(_nc_linedump) (NCURSES_SP_DCL0)
 /* dump the state of the real and virtual oldnum fields */
 {
-    int n;
-    char *buf = 0;
-    size_t want = ((size_t) screen_lines(SP_PARM) + 1) * 4;
-    (void) SP_PARM;
+    if (USE_TRACEF(TRACE_UPDATE | TRACE_MOVE)) {
+	char *buf = 0;
+	size_t want = ((size_t) screen_lines(SP_PARM) + 1) * 4;
+	(void) SP_PARM;
 
-    if ((buf = typeMalloc(char, want)) != 0) {
+	if ((buf = typeMalloc(char, want)) != 0) {
+	    int n;
 
-	*buf = '\0';
-	for (n = 0; n < screen_lines(SP_PARM); n++)
-	    _nc_SPRINTF(buf + strlen(buf),
-			_nc_SLIMIT(want - strlen(buf))
-			" %02d", OLDNUM(SP_PARM, n));
-	TR(TRACE_UPDATE | TRACE_MOVE, ("virt %s", buf));
-	free(buf);
+	    *buf = '\0';
+	    for (n = 0; n < screen_lines(SP_PARM); n++) {
+		int number = OLDNUM(SP_PARM, n);
+		if (number >= -99 && number < 999) {
+		    _nc_SPRINTF(buf + strlen(buf),
+				_nc_SLIMIT(want - strlen(buf))
+				" %02d", number);
+		} else {
+		    _nc_STRCAT(buf, " ??", want - strlen(buf));
+		}
+	    }
+	    free(buf);
+	}
     }
 }
 
diff --git a/ncurses/tty/hashmap.c b/ncurses/tty/hashmap.c
index 8c0fdfd..e50b638 100644
--- a/ncurses/tty/hashmap.c
+++ b/ncurses/tty/hashmap.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -73,7 +74,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: hashmap.c,v 1.65 2015/07/25 20:13:56 tom Exp $")
+MODULE_ID("$Id: hashmap.c,v 1.71 2023/09/16 16:28:53 tom Exp $")
 
 #ifdef HASHDEBUG
 
@@ -87,7 +88,7 @@
 # undef screen_lines
 # define screen_lines(sp) MAXLINES
 # define TEXTWIDTH(sp)	1
-int oldnums[MAXLINES], reallines[MAXLINES];
+static int oldnums[MAXLINES], reallines[MAXLINES];
 static NCURSES_CH_T oldtext[MAXLINES][TEXTWIDTH(sp)];
 static NCURSES_CH_T newtext[MAXLINES][TEXTWIDTH(sp)];
 # define OLDNUM(sp,n)	oldnums[n]
@@ -119,7 +120,7 @@
 static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
 
 static NCURSES_INLINE unsigned long
-hash(SCREEN *sp, NCURSES_CH_T * text)
+hash(SCREEN *sp, NCURSES_CH_T *text)
 {
     int i;
     NCURSES_CH_T ch;
@@ -135,7 +136,7 @@
 
 /* approximate update cost */
 static int
-update_cost(SCREEN *sp, NCURSES_CH_T * from, NCURSES_CH_T * to)
+update_cost(SCREEN *sp, NCURSES_CH_T *from, NCURSES_CH_T *to)
 {
     int cost = 0;
     int i;
@@ -149,7 +150,7 @@
 }
 
 static int
-update_cost_from_blank(SCREEN *sp, NCURSES_CH_T * to)
+update_cost_from_blank(SCREEN *sp, NCURSES_CH_T *to)
 {
     int cost = 0;
     int i;
@@ -198,9 +199,8 @@
 static void
 grow_hunks(SCREEN *sp)
 {
-    int start, end, shift;
-    int back_limit, forward_limit;	/* limits for cells to fill */
-    int back_ref_limit, forward_ref_limit;	/* limits for refrences */
+    int back_limit;		/* limits for cells to fill */
+    int back_ref_limit;		/* limit for references */
     int i;
     int next_hunk;
 
@@ -215,8 +215,11 @@
     while (i < screen_lines(sp) && OLDNUM(sp, i) == _NEWINDEX)
 	i++;
     for (; i < screen_lines(sp); i = next_hunk) {
-	start = i;
-	shift = OLDNUM(sp, i) - i;
+	int forward_limit;
+	int forward_ref_limit;
+	int end;
+	int start = i;
+	int shift = OLDNUM(sp, i) - i;
 
 	/* get forward limit */
 	i = start + 1;
@@ -285,7 +288,6 @@
 {
     HASHMAP *hsp;
     register int i;
-    int start, shift, size;
 
     if (screen_lines(SP_PARM) > lines_alloc(SP_PARM)) {
 	if (hashtab(SP_PARM))
@@ -316,8 +318,11 @@
 	if (newhash(SP_PARM) == 0)
 	    newhash(SP_PARM) = typeCalloc(unsigned long,
 					    (size_t) screen_lines(SP_PARM));
-	if (!oldhash(SP_PARM) || !newhash(SP_PARM))
+	if (!oldhash(SP_PARM) || !newhash(SP_PARM)) {
+	    FreeAndNull(oldhash(SP_PARM));
+	    FreeAndNull(newhash(SP_PARM));
 	    return;		/* malloc failure */
+	}
 	for (i = 0; i < screen_lines(SP_PARM); i++) {
 	    newhash(SP_PARM)[i] = hash(SP_PARM, NEWTEXT(SP_PARM, i));
 	    oldhash(SP_PARM)[i] = hash(SP_PARM, OLDTEXT(SP_PARM, i));
@@ -387,6 +392,8 @@
      * more than carry.
      */
     for (i = 0; i < screen_lines(SP_PARM);) {
+	int start, shift, size;
+
 	while (i < screen_lines(SP_PARM) && OLDNUM(SP_PARM, i) == _NEWINDEX)
 	    i++;
 	if (i >= screen_lines(SP_PARM))
@@ -399,7 +406,7 @@
 	       && OLDNUM(SP_PARM, i) - i == shift)
 	    i++;
 	size = i - start;
-	if (size < 3 || size + min(size / 8, 2) < abs(shift)) {
+	if (size < 3 || size + Min(size / 8, 2) < abs(shift)) {
 	    while (start < i) {
 		OLDNUM(SP_PARM, start) = _NEWINDEX;
 		start++;
@@ -580,11 +587,7 @@
 	    break;
 	}
     }
-#if NO_LEAKS
-    _nc_free_and_exit(EXIT_SUCCESS);
-#else
-    return EXIT_SUCCESS;
-#endif
+    exit_curses(EXIT_SUCCESS);
 }
 
 #endif /* HASHDEBUG */
diff --git a/ncurses/tty/lib_mvcur.c b/ncurses/tty/lib_mvcur.c
index 0b3300b..8fad93c 100644
--- a/ncurses/tty/lib_mvcur.c
+++ b/ncurses/tty/lib_mvcur.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -82,8 +83,8 @@
 
 /*
  * The average overhead of a full optimization computation in character
- * transmission times.  If it's too high, the algorithm will be a bit
- * over-biased toward using cup rather than local motions; if it's too
+ * transmission times.  If it is too high, the algorithm will be a bit
+ * over-biased toward using cup rather than local motions; if it is too
  * low, the algorithm may spend more time than is strictly optimal
  * looking for non-cup motions.  Profile the optimizer using the `t'
  * command of the exerciser (see below), and round to the nearest integer.
@@ -97,7 +98,7 @@
 
 /*
  * LONG_DIST is the distance we consider to be just as costly to move over as a
- * cup sequence is to emit.  In other words, it's the length of a cup sequence
+ * cup sequence is to emit.  In other words, it is the length of a cup sequence
  * adjusted for average computation overhead.  The magic number is the length
  * of "\033[yy;xxH", the typical cup sequence these days.
  */
@@ -147,7 +148,7 @@
  *	int		_rep_cost;	// cost of (repeat_char)
  *
  * The USE_HARD_TABS switch controls whether it is reliable to use tab/backtabs
- * for local motions.  On many systems, it's not, due to uncertainties about
+ * for local motions.  On many systems, it is not, due to uncertainties about
  * tab delays and whether or not tabs will be expanded in raw mode.  If you
  * have parm_right_cursor, tab motions don't win you a lot anyhow.
  */
@@ -159,7 +160,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_mvcur.c,v 1.136 2015/07/25 20:14:57 tom Exp $")
+MODULE_ID("$Id: lib_mvcur.c,v 1.161 2023/09/16 16:29:02 tom Exp $")
 
 #define WANT_CHAR(sp, y, x) NewScreen(sp)->_line[y].text[x]	/* desired state */
 
@@ -231,14 +232,33 @@
 	    /* extract padding, either mandatory or required */
 	    if (cp[0] == '$' && cp[1] == '<' && strchr(cp, '>')) {
 		float number = 0.0;
+		int state = 0;
 
 		for (cp += 2; *cp != '>'; cp++) {
-		    if (isdigit(UChar(*cp)))
-			number = number * 10 + (float) (*cp - '0');
-		    else if (*cp == '*')
-			number *= (float) affcnt;
-		    else if (*cp == '.' && (*++cp != '>') && isdigit(UChar(*cp)))
-			number += (float) ((*cp - '0') / 10.0);
+		    if (isdigit(UChar(*cp))) {
+			switch (state) {
+			case 0:
+			    number = number * 10 + (float) (*cp - '0');
+			    break;
+			case 2:
+			    number += (float) ((*cp - '0') / 10.0);
+			    ++state;
+			    break;
+			}
+		    } else if (*cp == '*') {
+			/* padding is always a suffix */
+			if (state < 4) {
+			    number *= (float) affcnt;
+			    state = 4;
+			}
+		    } else if (*cp == '.') {
+			/* a single decimal point is allowed */
+			state = (state == 0) ? 2 : 3;
+		    }
+		    if (number > MAX_DELAY_MSECS) {
+			number = MAX_DELAY_MSECS;
+			break;
+		    }
 		}
 
 #if NCURSES_NO_PADDING
@@ -278,8 +298,8 @@
 {
     if (change_scroll_region) {
 	NCURSES_PUTP2("change_scroll_region",
-		      TPARM_2(change_scroll_region,
-			      0, screen_lines(SP_PARM) - 1));
+		      TIPARM_2(change_scroll_region,
+			       0, screen_lines(SP_PARM) - 1));
     }
 }
 
@@ -344,7 +364,9 @@
     SP_PARM->_home_cost = CostOf(cursor_home, 0);
     SP_PARM->_ll_cost = CostOf(cursor_to_ll, 0);
 #if USE_HARD_TABS
-    if (getenv("NCURSES_NO_HARD_TABS") == 0) {
+    if (getenv("NCURSES_NO_HARD_TABS") == 0
+	&& dest_tabs_magic_smso == 0
+	&& HasHardTabs()) {
 	SP_PARM->_ht_cost = CostOf(tab, 0);
 	SP_PARM->_cbt_cost = CostOf(back_tab, 0);
     } else {
@@ -396,13 +418,13 @@
      * All these averages depend on the assumption that all parameter values
      * are equally probable.
      */
-    SP_PARM->_cup_cost = CostOf(TPARM_2(SP_PARM->_address_cursor, 23, 23), 1);
-    SP_PARM->_cub_cost = CostOf(TPARM_1(parm_left_cursor, 23), 1);
-    SP_PARM->_cuf_cost = CostOf(TPARM_1(parm_right_cursor, 23), 1);
-    SP_PARM->_cud_cost = CostOf(TPARM_1(parm_down_cursor, 23), 1);
-    SP_PARM->_cuu_cost = CostOf(TPARM_1(parm_up_cursor, 23), 1);
-    SP_PARM->_hpa_cost = CostOf(TPARM_1(column_address, 23), 1);
-    SP_PARM->_vpa_cost = CostOf(TPARM_1(row_address, 23), 1);
+    SP_PARM->_cup_cost = CostOf(TIPARM_2(SP_PARM->_address_cursor, 23, 23), 1);
+    SP_PARM->_cub_cost = CostOf(TIPARM_1(parm_left_cursor, 23), 1);
+    SP_PARM->_cuf_cost = CostOf(TIPARM_1(parm_right_cursor, 23), 1);
+    SP_PARM->_cud_cost = CostOf(TIPARM_1(parm_down_cursor, 23), 1);
+    SP_PARM->_cuu_cost = CostOf(TIPARM_1(parm_up_cursor, 23), 1);
+    SP_PARM->_hpa_cost = CostOf(TIPARM_1(column_address, 23), 1);
+    SP_PARM->_vpa_cost = CostOf(TIPARM_1(row_address, 23), 1);
 
     /* non-parameterized screen-update strings */
     SP_PARM->_ed_cost = NormalizedCost(clr_eos, 1);
@@ -419,19 +441,18 @@
 	SP_PARM->_el_cost = 0;
 
     /* parameterized screen-update strings */
-    SP_PARM->_dch_cost = NormalizedCost(TPARM_1(parm_dch, 23), 1);
-    SP_PARM->_ich_cost = NormalizedCost(TPARM_1(parm_ich, 23), 1);
-    SP_PARM->_ech_cost = NormalizedCost(TPARM_1(erase_chars, 23), 1);
-    SP_PARM->_rep_cost = NormalizedCost(TPARM_2(repeat_char, ' ', 23), 1);
+    SP_PARM->_dch_cost = NormalizedCost(TIPARM_1(parm_dch, 23), 1);
+    SP_PARM->_ich_cost = NormalizedCost(TIPARM_1(parm_ich, 23), 1);
+    SP_PARM->_ech_cost = NormalizedCost(TIPARM_1(erase_chars, 23), 1);
+    SP_PARM->_rep_cost = NormalizedCost(TIPARM_2(repeat_char, ' ', 23), 1);
 
-    SP_PARM->_cup_ch_cost = NormalizedCost(
-					      TPARM_2(SP_PARM->_address_cursor,
-						      23, 23),
-					      1);
-    SP_PARM->_hpa_ch_cost = NormalizedCost(TPARM_1(column_address, 23), 1);
-    SP_PARM->_cuf_ch_cost = NormalizedCost(TPARM_1(parm_right_cursor, 23), 1);
-    SP_PARM->_inline_cost = min(SP_PARM->_cup_ch_cost,
-				min(SP_PARM->_hpa_ch_cost,
+    SP_PARM->_cup_ch_cost = NormalizedCost(TIPARM_2(SP_PARM->_address_cursor,
+						    23, 23),
+					   1);
+    SP_PARM->_hpa_ch_cost = NormalizedCost(TIPARM_1(column_address, 23), 1);
+    SP_PARM->_cuf_ch_cost = NormalizedCost(TIPARM_1(parm_right_cursor, 23), 1);
+    SP_PARM->_inline_cost = Min(SP_PARM->_cup_ch_cost,
+				Min(SP_PARM->_hpa_ch_cost,
 				    SP_PARM->_cuf_ch_cost));
 
     /*
@@ -450,8 +471,8 @@
 
     /*
      * A different, possibly better way to arrange this would be to set the
-     * SCREEN's _endwin to TRUE at window initialization time and let this be
-     * called by doupdate's return-from-shellout code.
+     * SCREEN's _endwin at window initialization time and let this be called by
+     * doupdate's return-from-shellout code.
      */
     NCURSES_SP_NAME(_nc_mvcur_resume) (NCURSES_SP_ARG);
 }
@@ -468,12 +489,12 @@
 NCURSES_SP_NAME(_nc_mvcur_wrap) (NCURSES_SP_DCL0)
 /* wrap up cursor-addressing mode */
 {
-    /* leave cursor at screen bottom */
-    TINFO_MVCUR(NCURSES_SP_ARGx -1, -1, screen_lines(SP_PARM) - 1, 0);
-
     if (!SP_PARM || !IsTermInfo(SP_PARM))
 	return;
 
+    /* leave cursor at screen bottom */
+    TINFO_MVCUR(NCURSES_SP_ARGx -1, -1, screen_lines(SP_PARM) - 1, 0);
+
     /* set cursor to normal mode */
     if (SP_PARM->_cursor != -1) {
 	int cursor = SP_PARM->_cursor;
@@ -560,7 +581,7 @@
 	vcost = INFINITY;
 
 	if (row_address != 0
-	    && _nc_safe_strcat(target, TPARM_1(row_address, to_y))) {
+	    && _nc_safe_strcat(target, TIPARM_1(row_address, to_y))) {
 	    vcost = SP_PARM->_vpa_cost;
 	}
 
@@ -570,12 +591,12 @@
 	    if (parm_down_cursor
 		&& SP_PARM->_cud_cost < vcost
 		&& _nc_safe_strcat(_nc_str_copy(target, &save),
-				   TPARM_1(parm_down_cursor, n))) {
+				   TIPARM_1(parm_down_cursor, n))) {
 		vcost = SP_PARM->_cud_cost;
 	    }
 
 	    if (cursor_down
-		&& (*cursor_down != '\n' || SP_PARM->_nl)
+		&& (*cursor_down != '\n')
 		&& (n * SP_PARM->_cud1_cost < vcost)) {
 		vcost = repeated_append(_nc_str_copy(target, &save), 0,
 					SP_PARM->_cud1_cost, n, cursor_down);
@@ -586,7 +607,7 @@
 	    if (parm_up_cursor
 		&& SP_PARM->_cuu_cost < vcost
 		&& _nc_safe_strcat(_nc_str_copy(target, &save),
-				   TPARM_1(parm_up_cursor, n))) {
+				   TIPARM_1(parm_up_cursor, n))) {
 		vcost = SP_PARM->_cuu_cost;
 	    }
 
@@ -610,7 +631,7 @@
 
 	if (column_address
 	    && _nc_safe_strcat(_nc_str_copy(target, &save),
-			       TPARM_1(column_address, to_x))) {
+			       TIPARM_1(column_address, to_x))) {
 	    hcost = SP_PARM->_hpa_cost;
 	}
 
@@ -620,7 +641,7 @@
 	    if (parm_right_cursor
 		&& SP_PARM->_cuf_cost < hcost
 		&& _nc_safe_strcat(_nc_str_copy(target, &save),
-				   TPARM_1(parm_right_cursor, n))) {
+				   TIPARM_1(parm_right_cursor, n))) {
 		hcost = SP_PARM->_cuf_cost;
 	    }
 
@@ -673,7 +694,7 @@
 		 * and the time the structure WANT_CHAR would access has been
 		 * updated.
 		 */
-		if (ovw) {
+		if (ovw && to_y >= 0) {
 		    int i;
 
 		    for (i = 0; i < n; i++) {
@@ -688,7 +709,7 @@
 			}
 		    }
 		}
-		if (ovw) {
+		if (ovw && to_y >= 0) {
 		    int i;
 
 		    for (i = 0; i < n; i++)
@@ -713,7 +734,7 @@
 	    if (parm_left_cursor
 		&& SP_PARM->_cub_cost < hcost
 		&& _nc_safe_strcat(_nc_str_copy(target, &save),
-				   TPARM_1(parm_left_cursor, n))) {
+				   TIPARM_1(parm_left_cursor, n))) {
 		hcost = SP_PARM->_cub_cost;
 	    }
 
@@ -758,7 +779,7 @@
 #endif /* !NO_OPTIMIZE */
 
 /*
- * With the machinery set up above, it's conceivable that
+ * With the machinery set up above, it is conceivable that
  * onscreen_mvcur could be modified into a recursive function that does
  * an alpha-beta search of motion space, as though it were a chess
  * move tree, with the weight function being boolean and the search
@@ -790,7 +811,8 @@
 #define InitResult _nc_str_init(&result, buffer, sizeof(buffer))
 
     /* tactic #0: use direct cursor addressing */
-    if (_nc_safe_strcpy(InitResult, TPARM_2(SP_PARM->_address_cursor, ynew, xnew))) {
+    if (_nc_safe_strcpy(InitResult, TIPARM_2(SP_PARM->_address_cursor,
+					     ynew, xnew))) {
 	tactic = 0;
 	usecost = SP_PARM->_cup_cost;
 
@@ -935,6 +957,7 @@
 #endif /* MAIN */
 
     if (usecost != INFINITY) {
+	TR(TRACE_MOVE, ("mvcur tactic %d", tactic));
 	TPUTS_TRACE("mvcur");
 	NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
 				buffer, 1, myOutCh);
@@ -958,7 +981,7 @@
     NCURSES_CH_T oldattr;
     int code;
 
-    TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("_nc_tinfo_mvcur(%p,%d,%d,%d,%d)"),
+    TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("_nc_real_mvcur(%p,%d,%d,%d,%d)"),
 				  (void *) SP_PARM, yold, xold, ynew, xnew));
 
     if (SP_PARM == 0) {
@@ -988,42 +1011,33 @@
 	    TR(TRACE_CHARPUT, ("turning off (%#lx) %s before move",
 			       (unsigned long) AttrOf(oldattr),
 			       _traceattr(AttrOf(oldattr))));
-	    (void) VIDATTR(SP_PARM, A_NORMAL, 0);
+	    VIDPUTS(SP_PARM, A_NORMAL, 0);
 	}
 
 	if (xold >= screen_columns(SP_PARM)) {
-	    int l;
 
-	    if (SP_PARM->_nl) {
-		l = (xold + 1) / screen_columns(SP_PARM);
-		yold += l;
-		if (yold >= screen_lines(SP_PARM))
-		    l -= (yold - screen_lines(SP_PARM) - 1);
+	    int l = (xold + 1) / screen_columns(SP_PARM);
 
-		if (l > 0) {
-		    if (carriage_return) {
-			NCURSES_PUTP2("carriage_return", carriage_return);
-		    } else {
-			myOutCh(NCURSES_SP_ARGx '\r');
-		    }
-		    xold = 0;
+	    yold += l;
+	    if (yold >= screen_lines(SP_PARM))
+		l -= (yold - screen_lines(SP_PARM) - 1);
 
-		    while (l > 0) {
-			if (newline) {
-			    NCURSES_PUTP2("newline", newline);
-			} else {
-			    myOutCh(NCURSES_SP_ARGx '\n');
-			}
-			l--;
-		    }
+	    if (l > 0) {
+		if (carriage_return) {
+		    NCURSES_PUTP2("carriage_return", carriage_return);
+		} else {
+		    myOutCh(NCURSES_SP_ARGx '\r');
 		}
-	    } else {
-		/*
-		 * If caller set nonl(), we cannot really use newlines to
-		 * position to the next row.
-		 */
-		xold = -1;
-		yold = -1;
+		xold = 0;
+
+		while (l > 0) {
+		    if (newline) {
+			NCURSES_PUTP2("newline", newline);
+		    } else {
+			myOutCh(NCURSES_SP_ARGx '\n');
+		    }
+		    l--;
+		}
 	    }
 	}
 
@@ -1042,7 +1056,7 @@
 	    TR(TRACE_CHARPUT, ("turning on (%#lx) %s after move",
 			       (unsigned long) AttrOf(oldattr),
 			       _traceattr(AttrOf(oldattr))));
-	    (void) VIDATTR(SP_PARM, AttrOf(oldattr), GetPair(oldattr));
+	    VIDPUTS(SP_PARM, AttrOf(oldattr), GetPair(oldattr));
 	}
     }
     returnCode(code);
@@ -1056,9 +1070,18 @@
 			    int yold, int xold,
 			    int ynew, int xnew)
 {
-    return _nc_real_mvcur(NCURSES_SP_ARGx yold, xold, ynew, xnew,
-			  NCURSES_SP_NAME(_nc_outch),
-			  TRUE);
+    int rc;
+    rc = _nc_real_mvcur(NCURSES_SP_ARGx yold, xold, ynew, xnew,
+			NCURSES_SP_NAME(_nc_outch),
+			TRUE);
+    /*
+     * With the terminal-driver, we cannot distinguish between internal and
+     * external calls.  Flush the output if the screen has not been
+     * initialized, e.g., when used from low-level terminfo programs.
+     */
+    if ((SP_PARM != 0) && (SP_PARM->_endwin == ewInitial))
+	NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
+    return rc;
 }
 
 #if NCURSES_SP_FUNCS
@@ -1077,11 +1100,16 @@
 NCURSES_EXPORT(int)
 TINFO_MVCUR(NCURSES_SP_DCLx int yold, int xold, int ynew, int xnew)
 {
-    return _nc_real_mvcur(NCURSES_SP_ARGx
-			  yold, xold,
-			  ynew, xnew,
-			  NCURSES_SP_NAME(_nc_outch),
-			  TRUE);
+    int rc;
+    rc = _nc_real_mvcur(NCURSES_SP_ARGx
+			yold, xold,
+			ynew, xnew,
+			NCURSES_SP_NAME(_nc_outch),
+			TRUE);
+    if ((SP_PARM != 0) && (SP_PARM->_endwin == ewInitial))
+	NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
+    NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
+    return rc;
 }
 
 #else /* !USE_TERM_DRIVER */
@@ -1181,7 +1209,7 @@
 int
 main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
 {
-    strcpy(tname, getenv("TERM"));
+    _nc_STRCPY(tname, getenv("TERM"), sizeof(tname));
     load_term();
     _nc_setupscreen(lines, columns, stdout, FALSE, 0);
     baudrate();
@@ -1197,27 +1225,26 @@
 	int fy, fx, ty, tx, n, i;
 	char buf[BUFSIZ], capname[BUFSIZ];
 
-	(void) fputs("> ", stdout);
-	(void) fgets(buf, sizeof(buf), stdin);
+	if (fputs("> ", stdout) == EOF)
+	    break;
+	if (fgets(buf, sizeof(buf), stdin) == 0)
+	    break;
 
+#define PUTS(s)   (void) puts(s)
+#define PUTF(s,t) (void) printf(s,t)
 	if (buf[0] == '?') {
-	    (void) puts("?                -- display this help message");
-	    (void)
-		puts("fy fx ty tx      -- (4 numbers) display (fy,fx)->(ty,tx) move");
-	    (void) puts("s[croll] n t b m -- display scrolling sequence");
-	    (void)
-		printf("r[eload]         -- reload terminal info for %s\n",
-		       termname());
-	    (void)
-		puts("l[oad] <term>    -- load terminal info for type <term>");
-	    (void) puts("d[elete] <cap>   -- delete named capability");
-	    (void) puts("i[nspect]        -- display terminal capabilities");
-	    (void)
-		puts("c[ost]           -- dump cursor-optimization cost table");
-	    (void) puts("o[optimize]      -- toggle movement optimization");
-	    (void)
-		puts("t[orture] <num>  -- torture-test with <num> random moves");
-	    (void) puts("q[uit]           -- quit the program");
+	    PUTS("?                -- display this help message");
+	    PUTS("fy fx ty tx      -- (4 numbers) display (fy,fx)->(ty,tx) move");
+	    PUTS("s[croll] n t b m -- display scrolling sequence");
+	    PUTF("r[eload]         -- reload terminal info for %s\n",
+		 termname());
+	    PUTS("l[oad] <term>    -- load terminal info for type <term>");
+	    PUTS("d[elete] <cap>   -- delete named capability");
+	    PUTS("i[nspect]        -- display terminal capabilities");
+	    PUTS("c[ost]           -- dump cursor-optimization cost table");
+	    PUTS("o[optimize]      -- toggle movement optimization");
+	    PUTS("t[orture] <num>  -- torture-test with <num> random moves");
+	    PUTS("q[uit]           -- quit the program");
 	} else if (sscanf(buf, "%d %d %d %d", &fy, &fx, &ty, &tx) == 4) {
 	    struct timeval before, after;
 
@@ -1245,7 +1272,7 @@
 							     before.tv_sec)
 			   * 1000000));
 	} else if (buf[0] == 'r') {
-	    (void) strcpy(tname, termname());
+	    _nc_STRCPY(tname, termname(), sizeof(tname));
 	    load_term();
 	} else if (sscanf(buf, "l %s", tname) == 1) {
 	    load_term();
@@ -1278,8 +1305,9 @@
 		}
 	    }
 	} else if (buf[0] == 'i') {
-	    dump_init(NULL, F_TERMINFO, S_TERMINFO, 70, 0, 0, FALSE, FALSE);
-	    dump_entry(&cur_term->type, FALSE, TRUE, 0, 0);
+	    dump_init(NULL, F_TERMINFO, S_TERMINFO,
+		      FALSE, 70, 0, 0, FALSE, FALSE, 0);
+	    dump_entry(&TerminalType(cur_term), FALSE, TRUE, 0, 0);
 	    putchar('\n');
 	} else if (buf[0] == 'o') {
 	    if (_nc_optimize_enable & OPTIMIZE_MVCUR) {
diff --git a/ncurses/tty/lib_tstp.c b/ncurses/tty/lib_tstp.c
index 8624b76..dd925c7 100644
--- a/ncurses/tty/lib_tstp.c
+++ b/ncurses/tty/lib_tstp.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * 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  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +43,7 @@
 
 #include <SigAction.h>
 
-MODULE_ID("$Id: lib_tstp.c,v 1.48 2014/04/26 18:47:35 juergen Exp $")
+MODULE_ID("$Id: lib_tstp.c,v 1.54 2022/12/24 22:22:10 tom Exp $")
 
 #if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC)
 #define USE_SIGTSTP 1
@@ -129,7 +130,7 @@
  * (this may include XENIX).
  *
  * This implementation will probably be changed to use signal(3) in
- * the future.  If nothing else, it's simpler...
+ * the future.  If nothing else, it is simpler...
  */
 
 #if USE_SIGTSTP
@@ -155,8 +156,10 @@
      * taken ownership of the tty and modified the settings when our
      * parent was stopped before us, and we would likely pick up the
      * settings already modified by the shell.
+     *
+     * Don't do this if we're not in curses -
      */
-    if (sp != 0 && !sp->_endwin)	/* don't do this if we're not in curses */
+    if (sp != 0 && (sp->_endwin == ewRunning))
 #if HAVE_TCGETPGRP
 	if (tcgetpgrp(STDIN_FILENO) == getpgrp())
 #endif
@@ -273,14 +276,32 @@
 		set_term(scan);
 		NCURSES_SP_NAME(endwin) (NCURSES_SP_ARG);
 		if (sp)
-		    sp->_endwin = FALSE;	/* in case of reuse */
+		    sp->_endwin = ewInitial;	/* in case of reuse */
 	    }
 	}
     }
     _exit(EXIT_FAILURE);
 }
 
+# ifndef _nc_set_read_thread
+NCURSES_EXPORT(void)
+_nc_set_read_thread(bool enable)
+{
+    _nc_lock_global(curses);
+    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;
+    }
+    _nc_unlock_global(curses);
+}
+# endif
+
 #if USE_SIGWINCH
+
 static void
 handle_SIGWINCH(int sig GCC_UNUSED)
 {
diff --git a/ncurses/tty/lib_twait.c b/ncurses/tty/lib_twait.c
index 15d07c3..6fa73ee 100644
--- a/ncurses/tty/lib_twait.c
+++ b/ncurses/tty/lib_twait.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -70,13 +71,16 @@
 #  include <sys/select.h>
 # endif
 #endif
-#ifdef __MINGW32__
+#if HAVE_SYS_TIME_H
 #  include <sys/time.h>
 #endif
 #undef CUR
 
-MODULE_ID("$Id: lib_twait.c,v 1.70 2015/07/04 21:01:02 tom Exp $")
+MODULE_ID("$Id: lib_twait.c,v 1.81 2023/09/16 16:30:40 tom Exp $")
 
+/*
+ * Returns an elapsed time, in milliseconds (if possible).
+ */
 static long
 _nc_gettime(TimeType * t0, int first)
 {
@@ -84,18 +88,20 @@
 
 #if PRECISE_GETTIME
     TimeType t1;
-    gettimeofday(&t1, (struct timezone *) 0);
-    if (first) {
+    if (GetClockTime(&t1) == -1) {
+	*t0 = t1;
+	res = first ? 0 : 1;
+    } else if (first) {
 	*t0 = t1;
 	res = 0;
     } else {
 	/* .tv_sec and .tv_usec are unsigned, be careful when subtracting */
-	if (t0->tv_usec > t1.tv_usec) {
-	    t1.tv_usec += 1000000;	/* Convert 1s in 1e6 microsecs */
+	if (t0->sub_secs > t1.sub_secs) {
+	    t1.sub_secs += TimeScale;
 	    t1.tv_sec--;
 	}
-	res = (t1.tv_sec - t0->tv_sec) * 1000
-	    + (t1.tv_usec - t0->tv_usec) / 1000;
+	res = (long) ((t1.tv_sec - t0->tv_sec) * 1000L
+		      + (t1.sub_secs - t0->sub_secs) / (TimeScale / 1000L));
     }
 #else
     time_t t1 = time((time_t *) 0);
@@ -113,9 +119,9 @@
 _nc_eventlist_timeout(_nc_eventlist * evl)
 {
     int event_delay = -1;
-    int n;
 
     if (evl != 0) {
+	int n;
 
 	for (n = 0; n < evl->count; ++n) {
 	    _nc_event *ev = evl->events[n];
@@ -197,6 +203,10 @@
 
     long starttime, returntime;
 
+#ifdef NCURSES_WGETCH_EVENTS
+    (void) timeout_is_event;
+#endif
+
     TR(TRACE_IEVENT, ("start twait: %d milliseconds, mode: %d",
 		      milliseconds, mode));
 
@@ -350,7 +360,7 @@
     if ((mode & TW_MOUSE)
 	&& (fd = sp->_mouse_fd) >= 0) {
 	FD_SET(fd, &set);
-	count = max(fd, count) + 1;
+	count = Max(fd, count) + 1;
     }
 #ifdef NCURSES_WGETCH_EVENTS
     if ((mode & TW_EVENT) && evl) {
@@ -360,7 +370,7 @@
 	    if (ev->type == _NC_EVENT_FILE
 		&& (ev->data.fev.flags & _NC_EVENT_FILE_READABLE)) {
 		FD_SET(ev->data.fev.fd, &set);
-		count = max(ev->data.fev.fd + 1, count);
+		count = Max(ev->data.fev.fd + 1, count);
 	    }
 	}
     }
diff --git a/ncurses/tty/lib_vidattr.c b/ncurses/tty/lib_vidattr.c
index 184d9b9..2c7a0b2 100644
--- a/ncurses/tty/lib_vidattr.c
+++ b/ncurses/tty/lib_vidattr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -69,17 +70,24 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_vidattr.c,v 1.71 2014/09/04 22:01:27 tom Exp $")
+MODULE_ID("$Id: lib_vidattr.c,v 1.79 2023/04/28 20:59:26 tom Exp $")
 
 #define doPut(mode) \
 	TPUTS_TRACE(#mode); \
 	NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc)
 
 #define TurnOn(mask, mode) \
-	if ((turn_on & mask) && mode) { doPut(mode); }
+	if ((turn_on & mask) && mode) { \
+	    TPUTS_TRACE(#mode); \
+	    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc); \
+	}
 
 #define TurnOff(mask, mode) \
-	if ((turn_off & mask) && mode) { doPut(mode); turn_off &= ~mask; }
+	if ((turn_off & mask) && mode) { \
+	    TPUTS_TRACE(#mode); \
+	    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc); \
+	    turn_off &= ~mask; \
+	}
 
 	/* if there is no current screen, assume we *can* do color */
 #define SetColorsIf(why, old_attr) \
@@ -117,7 +125,7 @@
 
     T((T_CALLED("vidputs(%p,%s)"), (void *) SP_PARM, _traceattr(newmode)));
 
-    if (!IsTermInfo(SP_PARM))
+    if (!IsValidTIScreen(SP_PARM))
 	returnCode(ERR);
 
     /* this allows us to go on whether or not newterm() has been called */
@@ -145,7 +153,11 @@
 	};
 	unsigned n;
 	int used = 0;
+#ifdef max_attributes		/* not in U/Win */
 	int limit = (max_attributes <= 0) ? 1 : max_attributes;
+#else
+	int limit = 1;
+#endif
 	chtype retain = 0;
 
 	/*
@@ -237,6 +249,7 @@
 		    TurnOff(A_ITALIC, exit_italics_mode);
 		}
 #endif
+		(void) turn_off;
 	    }
 	    PreviousAttr &= ALL_BUT_COLOR;
 	}
@@ -246,16 +259,16 @@
 	if (turn_on || turn_off) {
 	    TPUTS_TRACE("set_attributes");
 	    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				    tparm(set_attributes,
-					  (newmode & A_STANDOUT) != 0,
-					  (newmode & A_UNDERLINE) != 0,
-					  (newmode & A_REVERSE) != 0,
-					  (newmode & A_BLINK) != 0,
-					  (newmode & A_DIM) != 0,
-					  (newmode & A_BOLD) != 0,
-					  (newmode & A_INVIS) != 0,
-					  (newmode & A_PROTECT) != 0,
-					  (newmode & A_ALTCHARSET) != 0),
+				    TIPARM_9(set_attributes,
+					     (newmode & A_STANDOUT) != 0,
+					     (newmode & A_UNDERLINE) != 0,
+					     (newmode & A_REVERSE) != 0,
+					     (newmode & A_BLINK) != 0,
+					     (newmode & A_DIM) != 0,
+					     (newmode & A_BOLD) != 0,
+					     (newmode & A_INVIS) != 0,
+					     (newmode & A_PROTECT) != 0,
+					     (newmode & A_ALTCHARSET) != 0),
 				    1, outc);
 	    PreviousAttr &= ALL_BUT_COLOR;
 	}
@@ -266,6 +279,7 @@
 	    } else if (turn_off & A_ITALIC) {
 		TurnOff(A_ITALIC, exit_italics_mode);
 	    }
+	    (void) turn_off;
 	}
 #endif
 	SetColorsIf((pair != 0) || fix_pair0, PreviousAttr);
@@ -308,7 +322,7 @@
 #if USE_ITALIC
 	TurnOn(A_ITALIC,	enter_italics_mode);
 #endif
-#if USE_WIDEC_SUPPORT
+#if USE_WIDEC_SUPPORT && defined(enter_horizontal_hl_mode)
 	TurnOn(A_HORIZONTAL,	enter_horizontal_hl_mode);
 	TurnOn(A_LEFT,		enter_left_hl_mode);
 	TurnOn(A_LOW,		enter_low_hl_mode);
@@ -317,7 +331,6 @@
 	TurnOn(A_VERTICAL,	enter_vertical_hl_mode);
 #endif
 	/* *INDENT-ON* */
-
     }
 
     if (reverse)
diff --git a/ncurses/tty/tty_update.c b/ncurses/tty/tty_update.c
index e66f716..0427024 100644
--- a/ncurses/tty/tty_update.c
+++ b/ncurses/tty/tty_update.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -43,6 +44,8 @@
  *
  *-----------------------------------------------------------------*/
 
+#define NEW_PAIR_INTERNAL 1
+
 #include <curses.priv.h>
 
 #ifndef CUR
@@ -82,7 +85,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: tty_update.c,v 1.280 2014/08/23 19:25:18 tom Exp $")
+MODULE_ID("$Id: tty_update.c,v 1.316 2024/02/04 00:09:34 tom Exp $")
 
 /*
  * This define controls the line-breakout optimization.  Every once in a
@@ -114,14 +117,14 @@
 static void ClearScreen(SCREEN *, NCURSES_CH_T blank);
 static void ClrUpdate(SCREEN *);
 static void DelChar(SCREEN *, int count);
-static void InsStr(SCREEN *, NCURSES_CH_T * line, int count);
+static void InsStr(SCREEN *, NCURSES_CH_T *line, int count);
 static void TransformLine(SCREEN *, int const lineno);
 #else
 static int ClrBottom(int total);
 static void ClearScreen(NCURSES_CH_T blank);
 static void ClrUpdate(void);
 static void DelChar(int count);
-static void InsStr(NCURSES_CH_T * line, int count);
+static void InsStr(NCURSES_CH_T *line, int count);
 static void TransformLine(int const lineno);
 #endif
 
@@ -133,7 +136,7 @@
  ****************************************************************************/
 
 static void
-position_check(NCURSES_SP_DCLx int expected_y, int expected_x, char *legend)
+position_check(NCURSES_SP_DCLx int expected_y, int expected_x, const char *legend)
 /* check to see if the real cursor position matches the virtual */
 {
     char buf[20];
@@ -167,9 +170,9 @@
 	if (y - 1 != expected_y || x - 1 != expected_x) {
 	    NCURSES_SP_NAME(beep) (NCURSES_SP_ARG);
 	    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				    tparm("\033[%d;%dH",
-					  expected_y + 1,
-					  expected_x + 1),
+				    TIPARM_2("\033[%d;%dH",
+					     expected_y + 1,
+					     expected_x + 1),
 				    1, NCURSES_SP_NAME(_nc_outch));
 	    _tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s",
 		    y - 1, x - 1, expected_y, expected_x, legend);
@@ -207,6 +210,10 @@
 		   SP_PARM->_curscol, "GoTo2");
 }
 
+#if !NCURSES_WCWIDTH_GRAPHICS
+#define is_wacs_value(ch) (_nc_wacs_width(ch) == 1 && wcwidth(ch) > 1)
+#endif /* !NCURSES_WCWIDTH_GRAPHICS */
+
 static NCURSES_INLINE void
 PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch)
 {
@@ -233,7 +240,7 @@
      * Determine the number of character cells which the 'ch' value will use
      * on the screen.  It should be at least one.
      */
-    if ((chlen = wcwidth(CharOf(CHDEREF(ch)))) <= 0) {
+    if ((chlen = _nc_wacs_width(CharOf(CHDEREF(ch)))) <= 0) {
 	static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
 
 	/*
@@ -249,6 +256,7 @@
 	 *    not checked.
 	 */
 	if (is8bits(CharOf(CHDEREF(ch)))
+	    && (!is7bits(CharOf(CHDEREF(ch))) && _nc_unicode_locale())
 	    && (isprint(CharOf(CHDEREF(ch)))
 		|| (SP_PARM->_legacy_coding > 0 && CharOf(CHDEREF(ch)) >= 160)
 		|| (SP_PARM->_legacy_coding > 1 && CharOf(CHDEREF(ch)) >= 128)
@@ -268,8 +276,14 @@
 
     if ((AttrOf(attr) & A_ALTCHARSET)
 	&& SP_PARM->_acs_map != 0
-	&& CharOfD(ch) < ACS_LEN) {
+	&& ((CharOfD(ch) < ACS_LEN)
+#if !NCURSES_WCWIDTH_GRAPHICS
+	    || is_wacs_value(CharOfD(ch))
+#endif
+	)) {
+	int c8;
 	my_ch = CHDEREF(ch);	/* work around const param */
+	c8 = CharOf(my_ch);
 #if USE_WIDEC_SUPPORT
 	/*
 	 * This is crude & ugly, but works most of the time.  It checks if the
@@ -277,17 +291,39 @@
 	 * character, and uses the wide-character mapping when we expect the
 	 * normal one to be broken (by mis-design ;-).
 	 */
-	if (SP_PARM->_screen_acs_fix
-	    && SP_PARM->_screen_acs_map[CharOf(my_ch)]) {
-	    RemAttr(attr, A_ALTCHARSET);
-	    my_ch = _nc_wacs[CharOf(my_ch)];
-	} else if (SP_PARM->_screen_unicode
-		   && !SP_PARM->_screen_acs_map[CharOf(my_ch)]
-		   && _nc_wacs[CharOf(my_ch)].chars[0]) {
-	    RemAttr(attr, A_ALTCHARSET);
-	    my_ch = _nc_wacs[CharOf(my_ch)];
-	}
+	if (SP_PARM->_screen_unicode
+	    && _nc_wacs[CharOf(my_ch)].chars[0]) {
+	    if (SP_PARM->_screen_acs_map[CharOf(my_ch)]) {
+		if (SP_PARM->_screen_acs_fix) {
+		    RemAttr(attr, A_ALTCHARSET);
+		    my_ch = _nc_wacs[CharOf(my_ch)];
+		}
+	    } else {
+		RemAttr(attr, A_ALTCHARSET);
+		my_ch = _nc_wacs[CharOf(my_ch)];
+	    }
+#if !NCURSES_WCWIDTH_GRAPHICS
+	    if (!(AttrOf(attr) & A_ALTCHARSET)) {
+		chlen = 1;
+	    }
+#endif /* !NCURSES_WCWIDTH_GRAPHICS */
+	} else
 #endif
+	if (!SP_PARM->_screen_acs_map[c8]) {
+	    /*
+	     * If we found no mapping for a given alternate-character set item
+	     * in the terminal description, attempt to use the ASCII fallback
+	     * code which is populated in the _acs_map[] array.  If that did
+	     * not correspond to a line-drawing, etc., graphics character, the
+	     * array entry would be empty.
+	     */
+	    chtype temp = UChar(SP_PARM->_acs_map[c8]);
+	    if (temp) {
+		RemAttr(attr, A_ALTCHARSET);
+		SetChar(my_ch, temp, AttrOf(attr));
+	    }
+	}
+
 	/*
 	 * If we (still) have alternate character set, it is the normal 8bit
 	 * flavor.  The _screen_acs_map[] array tells if the character was
@@ -307,6 +343,11 @@
 	}
 	ch = CHREF(my_ch);
     }
+#if USE_WIDEC_SUPPORT && !NCURSES_WCWIDTH_GRAPHICS
+    else if (chlen > 1 && is_wacs_value(CharOfD(ch))) {
+	chlen = 1;
+    }
+#endif
     if (tilde_glitch && (CharOfD(ch) == L('~'))) {
 	SetChar(tilde, L('`'), AttrOf(attr));
 	ch = CHREF(tilde);
@@ -389,11 +430,12 @@
 	/* we can put the char directly */
 	PutAttrChar(NCURSES_SP_ARGx ch);
     } else if (enter_am_mode && exit_am_mode) {
+	int oldcol = SP_PARM->_curscol;
 	/* we can suppress automargin */
 	NCURSES_PUTP2("exit_am_mode", exit_am_mode);
 
 	PutAttrChar(NCURSES_SP_ARGx ch);
-	SP_PARM->_curscol--;
+	SP_PARM->_curscol = oldcol;
 	position_check(NCURSES_SP_ARGx
 		       SP_PARM->_cursrow,
 		       SP_PARM->_curscol,
@@ -432,7 +474,7 @@
 	 * An aggressive way to handle this would be to emit CR/LF after the
 	 * char and then assume the wrap is done, you're on the first position
 	 * of the next line, and the terminal out of its weird state.  Here
-	 * it's safe to just tell the code that the cursor is in hyperspace and
+	 * it is safe to just tell the code that the cursor is in hyperspace and
 	 * let the next mvcur() call straighten things out.
 	 */
 	SP_PARM->_curscol = -1;
@@ -448,7 +490,7 @@
 	    TR(TRACE_CHARPUT, ("turning off (%#lx) %s before wrapping",
 			       (unsigned long) AttrOf(SCREEN_ATTRS(SP_PARM)),
 			       _traceattr(AttrOf(SCREEN_ATTRS(SP_PARM)))));
-	    (void) VIDATTR(SP_PARM, A_NORMAL, 0);
+	    VIDPUTS(SP_PARM, A_NORMAL, 0);
 	}
     } else {
 	SP_PARM->_curscol--;
@@ -493,14 +535,15 @@
 
 	if (!SP_PARM->_default_color)
 	    return FALSE;
-	if (SP_PARM->_default_fg != C_MASK || SP_PARM->_default_bg != C_MASK)
+	if (!(isDefaultColor(SP_PARM->_default_fg) &&
+	      isDefaultColor(SP_PARM->_default_bg)))
 	    return FALSE;
 	if ((pair = GetPair(CHDEREF(ch))) != 0) {
 	    NCURSES_COLOR_T fg, bg;
 	    if (NCURSES_SP_NAME(pair_content) (NCURSES_SP_ARGx
 					       (short) pair,
 					       &fg, &bg) == ERR
-		|| (fg != C_MASK || bg != C_MASK)) {
+		|| !(isDefaultColor(fg) && isDefaultColor(bg))) {
 		return FALSE;
 	    }
 	}
@@ -526,7 +569,7 @@
  * This code is optimized using ech and rep.
  */
 static int
-EmitRange(NCURSES_SP_DCLx const NCURSES_CH_T * ntext, int num)
+EmitRange(NCURSES_SP_DCLx const NCURSES_CH_T *ntext, int num)
 {
     int i;
 
@@ -564,7 +607,7 @@
 		&& runcount > SP_PARM->_ech_cost + SP_PARM->_cup_ch_cost
 		&& can_clear_with(NCURSES_SP_ARGx CHREF(ntext0))) {
 		UpdateAttrs(SP_PARM, ntext0);
-		NCURSES_PUTP2("erase_chars", TPARM_1(erase_chars, runcount));
+		NCURSES_PUTP2("erase_chars", TIPARM_1(erase_chars, runcount));
 
 		/*
 		 * If this is the last part of the given interval,
@@ -578,7 +621,18 @@
 		} else {
 		    return 1;	/* cursor stays in the middle */
 		}
-	    } else if (repeat_char && runcount > SP_PARM->_rep_cost) {
+	    } else if (repeat_char != 0 &&
+#if BSD_TPUTS
+		       !isdigit(UChar(CharOf(ntext0))) &&
+#endif
+#if USE_WIDEC_SUPPORT
+		       (!SP_PARM->_screen_unicode &&
+			(CharOf(ntext0) < ((AttrOf(ntext0) & A_ALTCHARSET)
+					   ? ACS_LEN
+					   : 256))) &&
+#endif
+		       runcount > SP_PARM->_rep_cost) {
+		NCURSES_CH_T temp;
 		bool wrap_possible = (SP_PARM->_curscol + runcount >=
 				      screen_columns(SP_PARM));
 		int rep_count = runcount;
@@ -587,11 +641,19 @@
 		    rep_count--;
 
 		UpdateAttrs(SP_PARM, ntext0);
+		temp = ntext0;
+		if ((AttrOf(temp) & A_ALTCHARSET) &&
+		    SP_PARM->_acs_map != 0 &&
+		    (SP_PARM->_acs_map[CharOf(temp)] & A_CHARTEXT) != 0) {
+		    SetChar(temp,
+			    (SP_PARM->_acs_map[CharOf(ntext0)] & A_CHARTEXT),
+			    AttrOf(ntext0) | A_ALTCHARSET);
+		}
 		NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-					TPARM_2(repeat_char,
-						CharOf(ntext0),
-						rep_count),
-					rep_count,
+					TIPARM_2(repeat_char,
+						 CharOf(temp),
+						 rep_count),
+					1,
 					NCURSES_SP_NAME(_nc_outch));
 		SP_PARM->_curscol += rep_count;
 
@@ -622,12 +684,11 @@
  */
 static int
 PutRange(NCURSES_SP_DCLx
-	 const NCURSES_CH_T * otext,
-	 const NCURSES_CH_T * ntext,
+	 const NCURSES_CH_T *otext,
+	 const NCURSES_CH_T *ntext,
 	 int row,
 	 int first, int last)
 {
-    int i, j, same;
     int rc;
 
     TR(TRACE_CHARPUT, ("PutRange(%p, %p, %p, %d, %d, %d)",
@@ -638,6 +699,8 @@
 
     if (otext != ntext
 	&& (last - first + 1) > SP_PARM->_inline_cost) {
+	int i, j, same;
+
 	for (j = first, same = 0; j <= last; j++) {
 	    if (!same && isWidecExt(otext[j]))
 		continue;
@@ -680,9 +743,12 @@
 
     T((T_CALLED("_nc_tinfo:doupdate(%p)"), (void *) SP_PARM));
 
-    if (SP_PARM == 0)
-	returnCode(ERR);
+    _nc_lock_global(update);
 
+    if (SP_PARM == 0) {
+	_nc_unlock_global(update);
+	returnCode(ERR);
+    }
 #if !USE_REENTRANT
     /*
      * It is "legal" but unlikely that an application could assign a new
@@ -692,20 +758,27 @@
      * 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
-	|| StdScreen(SP_PARM) == 0)
+	|| StdScreen(SP_PARM) == 0) {
+	_nc_unlock_global(update);
 	returnCode(ERR);
-
+    }
 #ifdef TRACE
     if (USE_TRACEF(TRACE_UPDATE)) {
 	if (CurScreen(SP_PARM)->_clear)
@@ -723,7 +796,8 @@
 	SP_PARM->_fifohold--;
 
 #if USE_SIZECHANGE
-    if (SP_PARM->_endwin || _nc_handle_sigwinch(SP_PARM)) {
+    if ((SP_PARM->_endwin == ewSuspend)
+	|| _nc_handle_sigwinch(SP_PARM)) {
 	/*
 	 * This is a transparent extension:  XSI does not address it,
 	 * and applications need not know that ncurses can do it.
@@ -736,7 +810,7 @@
     }
 #endif
 
-    if (SP_PARM->_endwin) {
+    if (SP_PARM->_endwin == ewSuspend) {
 
 	T(("coming back from shell mode"));
 	NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_ARG);
@@ -745,7 +819,7 @@
 	NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_ARG);
 	SP_PARM->_mouse_resume(SP_PARM);
 
-	SP_PARM->_endwin = FALSE;
+	SP_PARM->_endwin = ewRunning;
     }
 #if USE_TRACE_TIMES
     /* zero the metering machinery */
@@ -756,7 +830,7 @@
     /*
      * This is the support for magic-cookie terminals.  The theory:  we scan
      * the virtual screen looking for attribute turnons.  Where we find one,
-     * check to make sure it's realizable by seeing if the required number of
+     * check to make sure it is realizable by seeing if the required number of
      * un-attributed blanks are present before and after the attributed range;
      * try to shift the range boundaries over blanks (not changing the screen
      * display) so this becomes true.  If it is, shift the beginning attribute
@@ -818,7 +892,7 @@
 		    bool end_onscreen = FALSE;
 		    int m, n = j;
 
-		    /* find end of span, if it's onscreen */
+		    /* find end of span, if it is onscreen */
 		    for (m = i; m < screen_lines(SP_PARM); m++) {
 			for (; n < screen_columns(SP_PARM); n++) {
 			    attr_t testattr =
@@ -931,7 +1005,7 @@
 	if (check_pending(NCURSES_SP_ARG))
 	    goto cleanup;
 
-	nonempty = min(screen_lines(SP_PARM), NewScreen(SP_PARM)->_maxy + 1);
+	nonempty = Min(screen_lines(SP_PARM), NewScreen(SP_PARM)->_maxy + 1);
 
 	if (SP_PARM->_scrolling) {
 	    NCURSES_SP_NAME(_nc_scroll_optimize) (NCURSES_SP_ARG);
@@ -1013,6 +1087,7 @@
 
     _nc_signal_handler(TRUE);
 
+    _nc_unlock_global(update);
     returnCode(OK);
 }
 
@@ -1060,7 +1135,7 @@
     if (0 != SP_PARM) {
 	int i;
 	NCURSES_CH_T blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM));
-	int nonempty = min(screen_lines(SP_PARM),
+	int nonempty = Min(screen_lines(SP_PARM),
 			   NewScreen(SP_PARM)->_maxy + 1);
 
 	ClearScreen(NCURSES_SP_ARGx blank);
@@ -1084,10 +1159,10 @@
 static void
 ClrToEOL(NCURSES_SP_DCLx NCURSES_CH_T blank, int needclear)
 {
-    int j;
-
     if (CurScreen(SP_PARM) != 0
 	&& SP_PARM->_cursrow >= 0) {
+	int j;
+
 	for (j = SP_PARM->_curscol; j < screen_columns(SP_PARM); j++) {
 	    if (j >= 0) {
 		NCURSES_CH_T *cp =
@@ -1158,16 +1233,17 @@
 static int
 ClrBottom(NCURSES_SP_DCLx int total)
 {
-    int row;
-    int col;
     int top = total;
-    int last = min(screen_columns(SP_PARM), NewScreen(SP_PARM)->_maxx + 1);
+    int last = Min(screen_columns(SP_PARM), NewScreen(SP_PARM)->_maxx + 1);
     NCURSES_CH_T blank = NewScreen(SP_PARM)->_line[total - 1].text[last - 1];
-    bool ok;
 
     if (clr_eos && can_clear_with(NCURSES_SP_ARGx CHREF(blank))) {
+	int row;
 
 	for (row = total - 1; row >= 0; row--) {
+	    int col;
+	    bool ok;
+
 	    for (col = 0, ok = TRUE; ok && col < last; col++) {
 		ok = (CharEq(NewScreen(SP_PARM)->_line[row].text[col], blank));
 	    }
@@ -1218,7 +1294,7 @@
 **		nLastChar = position of last different character in new line
 **
 **		move to firstChar
-**		overwrite chars up to min(oLastChar, nLastChar)
+**		overwrite chars up to Min(oLastChar, nLastChar)
 **		if oLastChar < nLastChar
 **			insert newLine[oLastChar+1..nLastChar]
 **		else
@@ -1256,10 +1332,10 @@
 		newPair = GetPair(newLine[n]);
 		if (oldPair != newPair
 		    && unColor(oldLine[n]) == unColor(newLine[n])) {
-		    if (oldPair < SP_PARM->_pair_limit
-			&& newPair < SP_PARM->_pair_limit
-			&& (SP_PARM->_color_pairs[oldPair] ==
-			    SP_PARM->_color_pairs[newPair])) {
+		    if (oldPair < SP_PARM->_pair_alloc
+			&& newPair < SP_PARM->_pair_alloc
+			&& (isSamePair(SP_PARM->_color_pairs[oldPair],
+				       SP_PARM->_color_pairs[newPair]))) {
 			SetPair(oldLine[n], GetPair(newLine[n]));
 		    }
 		}
@@ -1456,7 +1532,7 @@
 		}
 		ClrToEOL(NCURSES_SP_ARGx blank, FALSE);
 	    } else {
-		n = max(nLastChar, oLastChar);
+		n = Max(nLastChar, oLastChar);
 		PutRange(NCURSES_SP_ARGx
 			 oldLine,
 			 newLine,
@@ -1481,7 +1557,7 @@
 		    break;
 	    }
 
-	    n = min(oLastChar, nLastChar);
+	    n = Min(oLastChar, nLastChar);
 	    if (n >= firstChar) {
 		GoTo(NCURSES_SP_ARGx lineno, firstChar);
 		PutRange(NCURSES_SP_ARGx
@@ -1493,7 +1569,7 @@
 	    }
 
 	    if (oLastChar < nLastChar) {
-		int m = max(nLastNonblank, oLastNonblank);
+		int m = Max(nLastNonblank, oLastNonblank);
 #if USE_WIDEC_SUPPORT
 		if (n) {
 		    while (isWidecExt(newLine[n + 1]) && n) {
@@ -1636,7 +1712,7 @@
 */
 
 static void
-InsStr(NCURSES_SP_DCLx NCURSES_CH_T * line, int count)
+InsStr(NCURSES_SP_DCLx NCURSES_CH_T *line, int count)
 {
     TR(TRACE_UPDATE, ("InsStr(%p, %p,%d) called",
 		      (void *) SP_PARM,
@@ -1648,17 +1724,17 @@
     if (parm_ich) {
 	TPUTS_TRACE("parm_ich");
 	NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				TPARM_1(parm_ich, count),
-				count,
+				TIPARM_1(parm_ich, count),
+				1,
 				NCURSES_SP_NAME(_nc_outch));
-	while (count) {
+	while (count > 0) {
 	    PutAttrChar(NCURSES_SP_ARGx CHREF(*line));
 	    line++;
 	    count--;
 	}
     } else if (enter_insert_mode && exit_insert_mode) {
 	NCURSES_PUTP2("enter_insert_mode", enter_insert_mode);
-	while (count) {
+	while (count > 0) {
 	    PutAttrChar(NCURSES_SP_ARGx CHREF(*line));
 	    if (insert_padding) {
 		NCURSES_PUTP2("insert_padding", insert_padding);
@@ -1668,7 +1744,7 @@
 	}
 	NCURSES_PUTP2("exit_insert_mode", exit_insert_mode);
     } else {
-	while (count) {
+	while (count > 0) {
 	    NCURSES_PUTP2("insert_character", insert_character);
 	    PutAttrChar(NCURSES_SP_ARGx CHREF(*line));
 	    if (insert_padding) {
@@ -1693,8 +1769,6 @@
 static void
 DelChar(NCURSES_SP_DCLx int count)
 {
-    int n;
-
     TR(TRACE_UPDATE, ("DelChar(%p, %d) called, position = (%ld,%ld)",
 		      (void *) SP_PARM, count,
 		      (long) NewScreen(SP_PARM)->_cury,
@@ -1703,10 +1777,12 @@
     if (parm_dch) {
 	TPUTS_TRACE("parm_dch");
 	NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				TPARM_1(parm_dch, count),
-				count,
+				TIPARM_1(parm_dch, count),
+				1,
 				NCURSES_SP_NAME(_nc_outch));
     } else {
+	int n;
+
 	for (n = 0; n < count; n++) {
 	    NCURSES_PUTP2("delete_character", delete_character);
 	}
@@ -1770,7 +1846,7 @@
 	UpdateAttrs(SP_PARM, blank);
 	TPUTS_TRACE("parm_index");
 	NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				TPARM_2(parm_index, n, 0),
+				TIPARM_1(parm_index, n),
 				n,
 				NCURSES_SP_NAME(_nc_outch));
     } else if (parm_delete_line && bot == maxy) {
@@ -1778,7 +1854,7 @@
 	UpdateAttrs(SP_PARM, blank);
 	TPUTS_TRACE("parm_delete_line");
 	NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				TPARM_2(parm_delete_line, n, 0),
+				TIPARM_1(parm_delete_line, n),
 				n,
 				NCURSES_SP_NAME(_nc_outch));
     } else if (scroll_forward && top == miny && bot == maxy) {
@@ -1835,7 +1911,7 @@
 	UpdateAttrs(SP_PARM, blank);
 	TPUTS_TRACE("parm_rindex");
 	NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				TPARM_2(parm_rindex, n, 0),
+				TIPARM_1(parm_rindex, n),
 				n,
 				NCURSES_SP_NAME(_nc_outch));
     } else if (parm_insert_line && bot == maxy) {
@@ -1843,7 +1919,7 @@
 	UpdateAttrs(SP_PARM, blank);
 	TPUTS_TRACE("parm_insert_line");
 	NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				TPARM_2(parm_insert_line, n, 0),
+				TIPARM_1(parm_insert_line, n),
 				n,
 				NCURSES_SP_NAME(_nc_outch));
     } else if (scroll_reverse && top == miny && bot == maxy) {
@@ -1891,7 +1967,7 @@
     } else if (parm_delete_line) {
 	TPUTS_TRACE("parm_delete_line");
 	NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				TPARM_2(parm_delete_line, n, 0),
+				TIPARM_1(parm_delete_line, n),
 				n,
 				NCURSES_SP_NAME(_nc_outch));
     } else {			/* if (delete_line) */
@@ -1907,7 +1983,7 @@
     } else if (parm_insert_line) {
 	TPUTS_TRACE("parm_insert_line");
 	NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				TPARM_2(parm_insert_line, n, 0),
+				TIPARM_1(parm_insert_line, n),
 				n,
 				NCURSES_SP_NAME(_nc_outch));
     } else {			/* if (insert_line) */
@@ -1972,7 +2048,7 @@
 		NCURSES_PUTP2("save_cursor", save_cursor);
 	    }
 	    NCURSES_PUTP2("change_scroll_region",
-			  TPARM_2(change_scroll_region, top, bot));
+			  TIPARM_2(change_scroll_region, top, bot));
 	    if (cursor_saved) {
 		NCURSES_PUTP2("restore_cursor", restore_cursor);
 	    } else {
@@ -1982,7 +2058,7 @@
 	    res = scroll_csr_forward(NCURSES_SP_ARGx n, top, bot, top, bot, blank);
 
 	    NCURSES_PUTP2("change_scroll_region",
-			  TPARM_2(change_scroll_region, 0, maxy));
+			  TIPARM_2(change_scroll_region, 0, maxy));
 	    SP_PARM->_cursrow = SP_PARM->_curscol = -1;
 	}
 
@@ -2018,7 +2094,7 @@
 		NCURSES_PUTP2("save_cursor", save_cursor);
 	    }
 	    NCURSES_PUTP2("change_scroll_region",
-			  TPARM_2(change_scroll_region, top, bot));
+			  TIPARM_2(change_scroll_region, top, bot));
 	    if (cursor_saved) {
 		NCURSES_PUTP2("restore_cursor", restore_cursor);
 	    } else {
@@ -2029,7 +2105,7 @@
 				      -n, top, bot, top, bot, blank);
 
 	    NCURSES_PUTP2("change_scroll_region",
-			  TPARM_2(change_scroll_region, 0, maxy));
+			  TIPARM_2(change_scroll_region, 0, maxy));
 	    SP_PARM->_cursrow = SP_PARM->_curscol = -1;
 	}
 
@@ -2085,16 +2161,16 @@
 	NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_ARG);
 
     /* restore user-defined colors, if any */
-    if (SP_PARM->_color_defs < 0) {
+    if (SP_PARM->_color_defs < 0 && !SP_PARM->_direct_color.value) {
 	int n;
 	SP_PARM->_color_defs = -(SP_PARM->_color_defs);
 	for (n = 0; n < SP_PARM->_color_defs; ++n) {
 	    if (SP_PARM->_color_table[n].init) {
-		NCURSES_SP_NAME(init_color) (NCURSES_SP_ARGx
-					     (short) n,
-					     SP_PARM->_color_table[n].r,
-					     SP_PARM->_color_table[n].g,
-					     SP_PARM->_color_table[n].b);
+		_nc_init_color(SP_PARM,
+			       n,
+			       SP_PARM->_color_table[n].r,
+			       SP_PARM->_color_table[n].g,
+			       SP_PARM->_color_table[n].b);
 	    }
 	}
     }
diff --git a/ncurses/unctrl.c b/ncurses/unctrl.c
deleted file mode 100644
index ab7da70..0000000
--- a/ncurses/unctrl.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/* generated by MKunctrl.awk */
-
-#include <curses.priv.h>
-#include <ctype.h>
-
-#undef unctrl
-
-NCURSES_EXPORT(NCURSES_CONST char *) safe_unctrl(SCREEN *sp, chtype ch)
-{
-static const short unctrl_table[] = {
-       0,   3,   6,   9,  12,  15,  18,  21,
-      24,  27,  30,  33,  36,  39,  42,  45,
-      48,  51,  54,  57,  60,  63,  66,  69,
-      72,  75,  78,  81,  84,  87,  90,  93,
-      96,  98, 100, 102, 104, 106, 108, 110,
-     112, 114, 116, 118, 120, 122, 124, 126,
-     128, 130, 132, 134, 136, 138, 140, 142,
-     144, 146, 148, 150, 152, 154, 156, 158,
-     160, 162, 164, 166, 168, 170, 172, 174,
-     176, 178, 180, 182, 184, 186, 188, 190,
-     192, 194, 196, 198, 200, 202, 204, 206,
-     208, 210, 212, 214, 216, 218, 220, 222,
-     224, 226, 228, 230, 232, 234, 236, 238,
-     240, 242, 244, 246, 248, 250, 252, 254,
-     256, 258, 260, 262, 264, 266, 268, 270,
-     272, 274, 276, 278, 280, 282, 284, 286,
-     289, 292, 295, 298, 301, 304, 307, 310,
-     313, 316, 319, 322, 325, 328, 331, 334,
-     337, 340, 343, 346, 349, 352, 355, 358,
-     361, 364, 367, 370, 373, 376, 379, 382,
-     385, 389, 393, 397, 401, 405, 409, 413,
-     417, 421, 425, 429, 433, 437, 441, 445,
-     449, 453, 457, 461, 465, 469, 473, 477,
-     481, 485, 489, 493, 497, 501, 505, 509,
-     513, 517, 521, 525, 529, 533, 537, 541,
-     545, 549, 553, 557, 561, 565, 569, 573,
-     577, 581, 585, 589, 593, 597, 601, 605,
-     609, 613, 617, 621, 625, 629, 633, 637,
-     641, 645, 649, 653, 657, 661, 665, 669,
-     673, 677, 681, 685, 689, 693, 697, 701,
-     705, 709, 713, 717, 721, 725, 729, 733,
-     737, 741, 745, 749, 753, 757, 761, 765,};
-
-#if NCURSES_EXT_FUNCS
-static const short unctrl_c1[] = {
-     768, 770, 772, 774, 776, 778, 780, 782,
-     784, 786, 788, 790, 792, 794, 796, 798,
-     800, 802, 804, 806, 808, 810, 812, 814,
-     816, 818, 820, 822, 824, 826, 828, 830,
-     832, 834, 836, 838, 840, 842, 844, 846,
-     848, 850, 852, 854, 856, 858, 860, 862,
-     864, 866, 868, 870, 872, 874, 876, 878,
-     880, 882, 884, 886, 888, 890, 892, 894,
-     896, 898, 900, 902, 904, 906, 908, 910,
-     912, 914, 916, 918, 920, 922, 924, 926,
-     928, 930, 932, 934, 936, 938, 940, 942,
-     944, 946, 948, 950, 952, 954, 956, 958,
-     960, 962, 964, 966, 968, 970, 972, 974,
-     976, 978, 980, 982, 984, 986, 988, 990,
-     992, 994, 996, 998,1000,1002,1004,1006,
-    1008,1010,1012,1014,1016,1018,1020,1022,};
-#endif /* NCURSES_EXT_FUNCS */
-
-static const char unctrl_blob[] = 
-    "^\100\0^\101\0^\102\0^\103\0^\104\0^\105\0^\106\0^\107\0"
-    "^\110\0^\111\0^\112\0^\113\0^\114\0^\115\0^\116\0^\117\0"
-    "^\120\0^\121\0^\122\0^\123\0^\124\0^\125\0^\126\0^\127\0"
-    "^\130\0^\131\0^\132\0^\133\0^\134\0^\135\0^\136\0^\137\0"
-    "\040\0\041\0\042\0\043\0\044\0\045\0\046\0\047\0"
-    "\050\0\051\0\052\0\053\0\054\0\055\0\056\0\057\0"
-    "\060\0\061\0\062\0\063\0\064\0\065\0\066\0\067\0"
-    "\070\0\071\0\072\0\073\0\074\0\075\0\076\0\077\0"
-    "\100\0\101\0\102\0\103\0\104\0\105\0\106\0\107\0"
-    "\110\0\111\0\112\0\113\0\114\0\115\0\116\0\117\0"
-    "\120\0\121\0\122\0\123\0\124\0\125\0\126\0\127\0"
-    "\130\0\131\0\132\0\133\0\134\0\135\0\136\0\137\0"
-    "\140\0\141\0\142\0\143\0\144\0\145\0\146\0\147\0"
-    "\150\0\151\0\152\0\153\0\154\0\155\0\156\0\157\0"
-    "\160\0\161\0\162\0\163\0\164\0\165\0\166\0\167\0"
-    "\170\0\171\0\172\0\173\0\174\0\175\0\176\0^?\0"
-    "~\100\0~\101\0~\102\0~\103\0~\104\0~\105\0~\106\0~\107\0"
-    "~\110\0~\111\0~\112\0~\113\0~\114\0~\115\0~\116\0~\117\0"
-    "~\120\0~\121\0~\122\0~\123\0~\124\0~\125\0~\126\0~\127\0"
-    "~\130\0~\131\0~\132\0~\133\0~\134\0~\135\0~\136\0~\137\0"
-    "M-\040\0M-\041\0M-\042\0M-\043\0M-\044\0M-\045\0M-\046\0M-\047\0"
-    "M-\050\0M-\051\0M-\052\0M-\053\0M-\054\0M-\055\0M-\056\0M-\057\0"
-    "M-\060\0M-\061\0M-\062\0M-\063\0M-\064\0M-\065\0M-\066\0M-\067\0"
-    "M-\070\0M-\071\0M-\072\0M-\073\0M-\074\0M-\075\0M-\076\0M-\077\0"
-    "M-\100\0M-\101\0M-\102\0M-\103\0M-\104\0M-\105\0M-\106\0M-\107\0"
-    "M-\110\0M-\111\0M-\112\0M-\113\0M-\114\0M-\115\0M-\116\0M-\117\0"
-    "M-\120\0M-\121\0M-\122\0M-\123\0M-\124\0M-\125\0M-\126\0M-\127\0"
-    "M-\130\0M-\131\0M-\132\0M-\133\0M-\134\0M-\135\0M-\136\0M-\137\0"
-    "M-\140\0M-\141\0M-\142\0M-\143\0M-\144\0M-\145\0M-\146\0M-\147\0"
-    "M-\150\0M-\151\0M-\152\0M-\153\0M-\154\0M-\155\0M-\156\0M-\157\0"
-    "M-\160\0M-\161\0M-\162\0M-\163\0M-\164\0M-\165\0M-\166\0M-\167\0"
-    "M-\170\0M-\171\0M-\172\0M-\173\0M-\174\0M-\175\0M-\176\0~?\0"
-/* printable values in 128-255 range */
-    "\200\0\201\0\202\0\203\0\204\0\205\0\206\0\207\0"
-    "\210\0\211\0\212\0\213\0\214\0\215\0\216\0\217\0"
-    "\220\0\221\0\222\0\223\0\224\0\225\0\226\0\227\0"
-    "\230\0\231\0\232\0\233\0\234\0\235\0\236\0\237\0"
-    "\240\0\241\0\242\0\243\0\244\0\245\0\246\0\247\0"
-    "\250\0\251\0\252\0\253\0\254\0\255\0\256\0\257\0"
-    "\260\0\261\0\262\0\263\0\264\0\265\0\266\0\267\0"
-    "\270\0\271\0\272\0\273\0\274\0\275\0\276\0\277\0"
-    "\300\0\301\0\302\0\303\0\304\0\305\0\306\0\307\0"
-    "\310\0\311\0\312\0\313\0\314\0\315\0\316\0\317\0"
-    "\320\0\321\0\322\0\323\0\324\0\325\0\326\0\327\0"
-    "\330\0\331\0\332\0\333\0\334\0\335\0\336\0\337\0"
-    "\340\0\341\0\342\0\343\0\344\0\345\0\346\0\347\0"
-    "\350\0\351\0\352\0\353\0\354\0\355\0\356\0\357\0"
-    "\360\0\361\0\362\0\363\0\364\0\365\0\366\0\367\0"
-    "\370\0\371\0\372\0\373\0\374\0\375\0\376\0\377\0"
-;
-
-	int check = (int) ChCharOf(ch);
-	const char *result;
-
-	if (check >= 0 && check < (int)SIZEOF(unctrl_table)) {
-#if NCURSES_EXT_FUNCS
-		if ((sp != 0)
-		 && (sp->_legacy_coding > 1)
-		 && (check >= 128)
-		 && (check < 160))
-			result = unctrl_blob + unctrl_c1[check - 128];
-		else
-		if ((check >= 160)
-		 && (check < 256)
-		 && ((sp != 0)
-		  && ((sp->_legacy_coding > 0)
-		   || (sp->_legacy_coding == 0
-		       && isprint(check)))))
-			result = unctrl_blob + unctrl_c1[check - 128];
-		else
-#endif /* NCURSES_EXT_FUNCS */
-			result = unctrl_blob + unctrl_table[check];
-	} else {
-		result = 0;
-	}
-	return (NCURSES_CONST char *)result;
-}
-
-NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype ch)
-{
-	return safe_unctrl(CURRENT_SCREEN, ch);
-}
diff --git a/ncurses/wcwidth.h b/ncurses/wcwidth.h
index e261170..76673da 100644
--- a/ncurses/wcwidth.h
+++ b/ncurses/wcwidth.h
@@ -59,6 +59,16 @@
  * Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
  */
 
+#ifndef _WCWIDTH_H_incl
+#define _WCWIDTH_H_incl 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ncurses_cfg.h>
+#include <ncurses_dll.h>
+
 #include <wchar.h>
 
 struct interval {
@@ -119,7 +129,7 @@
  * in ISO 10646.
  */
 
-int mk_wcwidth(wchar_t ucs)
+NCURSES_EXPORT(int) mk_wcwidth(wchar_t ucs)
 {
   /* sorted list of non-overlapping intervals of non-spacing characters */
   /* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */
@@ -187,7 +197,7 @@
 
   /* if we arrive here, ucs is not a combining or C0/C1 control character */
 
-  return 1 + 
+  return 1 +
     (ucs >= 0x1100 &&
      (ucs <= 0x115f ||                    /* Hangul Jamo init. consonants */
       ucs == 0x2329 || ucs == 0x232a ||
@@ -207,7 +217,7 @@
 }
 
 
-int mk_wcswidth(const wchar_t *pwcs, size_t n)
+NCURSES_EXPORT(int) mk_wcswidth(const wchar_t *pwcs, size_t n)
 {
   int w, width = 0;
 
@@ -230,7 +240,7 @@
  * the traditional terminal character-width behaviour. It is not
  * otherwise recommended for general use.
  */
-int mk_wcwidth_cjk(wchar_t ucs)
+NCURSES_EXPORT(int) mk_wcwidth_cjk(wchar_t ucs)
 {
   /* sorted list of non-overlapping intervals of East Asian Ambiguous
    * characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */
@@ -298,7 +308,7 @@
 }
 
 
-int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n)
+NCURSES_EXPORT(int) mk_wcswidth_cjk(const wchar_t *pwcs, size_t n)
 {
   int w, width = 0;
 
@@ -310,3 +320,9 @@
 
   return width;
 }
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _WCWIDTH_H_incl 1 */
diff --git a/ncurses/widechar/charable.c b/ncurses/widechar/charable.c
index 91ceb32..55d4890 100644
--- a/ncurses/widechar/charable.c
+++ b/ncurses/widechar/charable.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2003-2005,2008 Free Software Foundation, Inc.              *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2003-2005,2008 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,7 +33,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: charable.c,v 1.5 2008/07/05 20:51:41 tom Exp $")
+MODULE_ID("$Id: charable.c,v 1.8 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(bool) _nc_is_charable(wchar_t ch)
 {
@@ -57,6 +58,8 @@
 	result = UChar(temp[0]);
     else
 	result = -1;
+#else
+#error expected either wctob/wctomb
 #endif
     return result;
 }
@@ -75,6 +78,8 @@
 	result = convert;
     else
 	result = WEOF;
+#else
+#error expected either btowc/mbtowc
 #endif
     return result;
 }
diff --git a/ncurses/widechar/lib_add_wch.c b/ncurses/widechar/lib_add_wch.c
index 38d3130..be1bbb0 100644
--- a/ncurses/widechar/lib_add_wch.c
+++ b/ncurses/widechar/lib_add_wch.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2004-2010,2011 Free Software Foundation, Inc.              *
+ * Copyright 2019-2021,2023 Thomas E. Dickey                                *
+ * Copyright 2004-2011,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
 #include <wctype.h>
 #endif
 
-MODULE_ID("$Id: lib_add_wch.c,v 1.12 2011/03/22 09:31:15 Petr.Pavlu Exp $")
+MODULE_ID("$Id: lib_add_wch.c,v 1.18 2023/07/15 17:34:12 tom Exp $")
 
 /* clone/adapt lib_addch.c */
 static const cchar_t blankchar = NewChar(BLANK_TEXT);
@@ -55,7 +56,7 @@
  */
 
 /* Return bit mask for clearing color pair number if given ch has color */
-#define COLOR_MASK(ch) (~(attr_t)((ch) & A_COLOR ? A_COLOR : 0))
+#define COLOR_MASK(ch) (~(attr_t)(((ch) & A_COLOR) ? A_COLOR : 0))
 
 static NCURSES_INLINE cchar_t
 render_char(WINDOW *win, cchar_t ch)
@@ -114,7 +115,7 @@
 #endif
 
 static bool
-newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T * ypos)
+newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T *ypos)
 {
     bool result = FALSE;
 
@@ -132,7 +133,7 @@
  * wrapped the cursor.  We don't do anything with this flag except set it when
  * wrapping, and clear it whenever we move the cursor.  If we try to wrap at
  * the lower-right corner of a window, we cannot move the cursor (since that
- * wouldn't be legal).  So we return an error (which is what SVr4 does). 
+ * wouldn't be legal).  So we return an error (which is what SVr4 does).
  * Unlike SVr4, we can successfully add a character to the lower-right corner
  * (Solaris 2.6 does this also, however).
  */
@@ -195,7 +196,7 @@
      * adjustments.
      */
     {
-	int len = wcwidth(CharOf(ch));
+	int len = _nc_wacs_width(CharOf(ch));
 	int i;
 	int j;
 	wchar_t *chars;
@@ -203,10 +204,16 @@
 	if (len == 0) {		/* non-spacing */
 	    if ((x > 0 && y >= 0)
 		|| (win->_maxx >= 0 && win->_cury >= 1)) {
-		if (x > 0 && y >= 0)
-		    chars = (win->_line[y].text[x - 1].chars);
-		else
+		if (x > 0 && y >= 0) {
+		    for (j = x - 1; j > 0; --j) {
+			if (!isWidecExt(win->_line[y].text[j])) {
+			    break;
+			}
+		    }
+		    chars = (win->_line[y].text[j].chars);
+		} else {
 		    chars = (win->_line[y - 1].text[win->_maxx].chars);
+		}
 		for (i = 0; i < CCHARW_MAX; ++i) {
 		    if (chars[i] == 0) {
 			TR(TRACE_VIRTPUT,
diff --git a/ncurses/widechar/lib_box_set.c b/ncurses/widechar/lib_box_set.c
index f9e701f..ef2e1a7 100644
--- a/ncurses/widechar/lib_box_set.c
+++ b/ncurses/widechar/lib_box_set.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2009,2011 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2002-2009,2011 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_box_set.c,v 1.6 2011/06/25 19:02:07 Vassili.Courzakis Exp $")
+MODULE_ID("$Id: lib_box_set.c,v 1.7 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 wborder_set(WINDOW *win,
diff --git a/ncurses/widechar/lib_cchar.c b/ncurses/widechar/lib_cchar.c
index 654bebb..451c5dc 100644
--- a/ncurses/widechar/lib_cchar.c
+++ b/ncurses/widechar/lib_cchar.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2001-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019-2021,2022 Thomas E. Dickey                                *
+ * Copyright 2001-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,10 +35,11 @@
 */
 
 #include <curses.priv.h>
+#include <wchar.h>
 
-MODULE_ID("$Id: lib_cchar.c,v 1.27 2014/02/01 22:10:42 tom Exp $")
+MODULE_ID("$Id: lib_cchar.c,v 1.38 2022/07/27 08:03:16 tom Exp $")
 
-/* 
+/*
  * The SuSv2 description leaves some room for interpretation.  We'll assume wch
  * points to a string which is L'\0' terminated, contains at least one
  * character with strictly positive width, which must be the first, and
@@ -47,22 +49,25 @@
 setcchar(cchar_t *wcval,
 	 const wchar_t *wch,
 	 const attr_t attrs,
-	 NCURSES_PAIRS_T color_pair,
+	 NCURSES_PAIRS_T pair_arg,
 	 const void *opts)
 {
-    unsigned i;
-    unsigned len;
     int code = OK;
+    int color_pair = pair_arg;
+    unsigned len;
 
-    TR(TRACE_CCALLS, (T_CALLED("setcchar(%p,%s,%lu,%d,%p)"),
+    TR(TRACE_CCALLS, (T_CALLED("setcchar(%p,%s,attrs=%lu,pair=%d,%p)"),
 		      (void *) wcval, _nc_viswbuf(wch),
-		      (unsigned long) attrs, (int) color_pair, opts));
+		      (unsigned long) attrs, color_pair, opts));
 
-    if (opts != NULL
-	|| wch == NULL
-	|| ((len = (unsigned) wcslen(wch)) > 1 && wcwidth(wch[0]) < 0)) {
+    set_extended_pair(opts, color_pair);
+    if (wch == NULL
+	|| ((len = (unsigned) wcslen(wch)) > 1 && _nc_wacs_width(wch[0]) < 0)
+	|| color_pair < 0) {
 	code = ERR;
     } else {
+	unsigned i;
+
 	if (len > CCHARW_MAX)
 	    len = CCHARW_MAX;
 
@@ -71,7 +76,7 @@
 	 * are only interested in adding non-spacing characters.
 	 */
 	for (i = 1; i < len; ++i) {
-	    if (wcwidth(wch[i]) != 0) {
+	    if (_nc_wacs_width(wch[i]) != 0) {
 		len = i;
 		break;
 	    }
@@ -96,39 +101,55 @@
 getcchar(const cchar_t *wcval,
 	 wchar_t *wch,
 	 attr_t *attrs,
-	 NCURSES_PAIRS_T *color_pair,
+	 NCURSES_PAIRS_T *pair_arg,
 	 void *opts)
 {
-    wchar_t *wp;
-    int len;
     int code = ERR;
 
     TR(TRACE_CCALLS, (T_CALLED("getcchar(%p,%p,%p,%p,%p)"),
 		      (const void *) wcval,
 		      (void *) wch,
 		      (void *) attrs,
-		      (void *) color_pair,
+		      (void *) pair_arg,
 		      opts));
 
-    if (opts == NULL && wcval != NULL) {
+#if !NCURSES_EXT_COLORS
+    if (opts != NULL) {
+	;			/* empty */
+    } else
+#endif
+    if (wcval != NULL) {
+	wchar_t *wp;
+	int len;
+
+#if HAVE_WMEMCHR
 	len = ((wp = wmemchr(wcval->chars, L'\0', (size_t) CCHARW_MAX))
 	       ? (int) (wp - wcval->chars)
 	       : CCHARW_MAX);
-
+#else
+	len = wcsnlen(wcval->chars, CCHARW_MAX);
+#endif
 	if (wch == NULL) {
 	    /*
 	     * If the value is a null, set the length to 1.
 	     * If the value is not a null, return the length plus 1 for null.
 	     */
 	    code = (len < CCHARW_MAX) ? (len + 1) : CCHARW_MAX;
-	} else if (attrs == 0 || color_pair == 0) {
+	} else if (attrs == 0 || pair_arg == 0) {
 	    code = ERR;
 	} else if (len >= 0) {
+	    int color_pair;
+
+	    TR(TRACE_CCALLS, ("copy %d wchars, first is %s", len,
+			      _tracecchar_t(wcval)));
 	    *attrs = AttrOf(*wcval) & A_ATTRIBUTES;
-	    *color_pair = (NCURSES_PAIRS_T) GetPair(*wcval);
+	    color_pair = GetPair(*wcval);
+	    get_extended_pair(opts, color_pair);
+	    *pair_arg = limit_PAIRS(color_pair);
 	    wmemcpy(wch, wcval->chars, (size_t) len);
 	    wch[len] = L'\0';
-	    code = OK;
+	    if (*pair_arg >= 0)
+		code = OK;
 	}
     }
 
diff --git a/ncurses/widechar/lib_erasewchar.c b/ncurses/widechar/lib_erasewchar.c
index ddce27a..197f80b 100644
--- a/ncurses/widechar/lib_erasewchar.c
+++ b/ncurses/widechar/lib_erasewchar.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2010,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 2002-2010,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,46 +33,64 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_erasewchar.c,v 1.3 2014/02/23 01:21:08 tom Exp $")
+MODULE_ID("$Id: lib_erasewchar.c,v 1.5 2021/05/22 23:51:14 tom Exp $")
 
 /*
  *	erasewchar()
  *
  *	Return erase character as given in cur_term->Ottyb.
- *
  */
 
 NCURSES_EXPORT(int)
-erasewchar(wchar_t *wch)
+NCURSES_SP_NAME(erasewchar) (NCURSES_SP_DCLx wchar_t *wch);
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(erasewchar) (NCURSES_SP_DCLx wchar_t *wch)
 {
     int value;
     int result = ERR;
 
     T((T_CALLED("erasewchar()")));
-    if ((value = erasechar()) != ERR) {
+    if ((value = NCURSES_SP_NAME(erasechar) (NCURSES_SP_ARG)) != ERR) {
 	*wch = (wchar_t) value;
 	result = OK;
     }
     returnCode(result);
 }
 
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+erasewchar(wchar_t *wch)
+{
+    return NCURSES_SP_NAME(erasewchar) (CURRENT_SCREEN, wch);
+}
+#endif
+
 /*
  *	killwchar()
  *
  *	Return kill character as given in cur_term->Ottyb.
- *
  */
 
 NCURSES_EXPORT(int)
-killwchar(wchar_t *wch)
+NCURSES_SP_NAME(killwchar) (NCURSES_SP_DCLx wchar_t *wch);
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(killwchar) (NCURSES_SP_DCLx wchar_t *wch)
 {
     int value;
     int result = ERR;
 
     T((T_CALLED("killwchar()")));
-    if ((value = killchar()) != ERR) {
+    if ((value = NCURSES_SP_NAME(killchar) (NCURSES_SP_ARG)) != ERR) {
 	*wch = (wchar_t) value;
 	result = OK;
     }
     returnCode(result);
 }
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+killwchar(wchar_t *wch)
+{
+    return NCURSES_SP_NAME(killwchar) (CURRENT_SCREEN, wch);
+}
+#endif
diff --git a/ncurses/widechar/lib_get_wch.c b/ncurses/widechar/lib_get_wch.c
index 71d5603..9f10d3b 100644
--- a/ncurses/widechar/lib_get_wch.c
+++ b/ncurses/widechar/lib_get_wch.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2010,2011 Free Software Foundation, Inc.              *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 2002-2011,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,18 +41,14 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_get_wch.c,v 1.23 2011/05/28 23:00:29 tom Exp $")
+MODULE_ID("$Id: lib_get_wch.c,v 1.26 2021/04/17 16:12:54 tom Exp $")
 
 NCURSES_EXPORT(int)
 wget_wch(WINDOW *win, wint_t *result)
 {
     SCREEN *sp;
     int code;
-    char buffer[(MB_LEN_MAX * 9) + 1];	/* allow some redundant shifts */
-    int status;
-    size_t count = 0;
     int value = 0;
-    wchar_t wch;
 #ifndef state_unused
     mbstate_t state;
 #endif
@@ -64,8 +61,13 @@
      */
     _nc_lock_global(curses);
     sp = _nc_screen_of(win);
+
     if (sp != 0) {
+	size_t count = 0;
+
 	for (;;) {
+	    char buffer[(MB_LEN_MAX * 9) + 1];	/* allow some redundant shifts */
+
 	    T(("reading %d of %d", (int) count + 1, (int) sizeof(buffer)));
 	    code = _nc_wgetch(win, &value, TRUE EVENTLIST_2nd((_nc_eventlist
 							       *) 0));
@@ -89,10 +91,13 @@
 		code = ERR;
 		break;
 	    } else {
+		int status;
+
 		buffer[count++] = (char) UChar(value);
 		reset_mbytes(state);
 		status = count_mbytes(buffer, count, state);
 		if (status >= 0) {
+		    wchar_t wch;
 		    reset_mbytes(state);
 		    if (check_mbytes(wch, buffer, count, state) != status) {
 			code = ERR;	/* the two calls should match */
diff --git a/ncurses/widechar/lib_get_wstr.c b/ncurses/widechar/lib_get_wstr.c
index 27cdae0..3b3bd52 100644
--- a/ncurses/widechar/lib_get_wstr.c
+++ b/ncurses/widechar/lib_get_wstr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2009,2011 Free Software Foundation, Inc.              *
+ * Copyright 2018-2021,2023 Thomas E. Dickey                                *
+ * Copyright 2002-2009,2011 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_get_wstr.c,v 1.13 2011/10/22 16:31:35 tom Exp $")
+MODULE_ID("$Id: lib_get_wstr.c,v 1.21 2023/04/29 19:02:03 tom Exp $")
 
 static int
 wadd_wint(WINDOW *win, wint_t *src)
@@ -87,9 +88,9 @@
 {
     SCREEN *sp = _nc_screen_of(win);
     TTY buf;
-    bool oldnl, oldecho, oldraw, oldcbreak;
-    wint_t erasec;
-    wint_t killc;
+    TTY_FLAGS save_flags;
+    wchar_t erasec = 0;
+    wchar_t killc = 0;
     wint_t *oldstr = str;
     wint_t *tmpstr = str;
     wint_t ch;
@@ -100,19 +101,18 @@
     if (!win)
 	returnCode(ERR);
 
+    maxlen = _nc_getstr_limit(maxlen);
+
     _nc_get_tty_mode(&buf);
 
-    oldnl = sp->_nl;
-    oldecho = sp->_echo;
-    oldraw = sp->_raw;
-    oldcbreak = sp->_cbreak;
-    nl();
-    noecho();
-    noraw();
-    cbreak();
+    save_flags = sp->_tty_flags;
+    NCURSES_SP_NAME(nl) (NCURSES_SP_ARG);
+    NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG);
+    if (!save_flags._raw)
+	NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG);
 
-    erasec = (wint_t) erasechar();
-    killc = (wint_t) killchar();
+    NCURSES_SP_NAME(erasewchar) (NCURSES_SP_ARGx &erasec);
+    NCURSES_SP_NAME(killwchar) (NCURSES_SP_ARGx &killc);
 
     getyx(win, y, x);
 
@@ -129,12 +129,12 @@
 	    code = KEY_CODE_YES;
 	    ch = KEY_ENTER;
 	}
-	if (ch < KEY_MIN) {
-	    if (ch == erasec) {
+	if (ch != 0 && ch < KEY_MIN) {
+	    if (ch == (wint_t) erasec) {
 		ch = KEY_BACKSPACE;
 		code = KEY_CODE_YES;
 	    }
-	    if (ch == killc) {
+	    if (ch == (wint_t) killc) {
 		ch = KEY_EOL;
 		code = KEY_CODE_YES;
 	    }
@@ -142,12 +142,12 @@
 	if (code == KEY_CODE_YES) {
 	    /*
 	     * Some terminals (the Wyse-50 is the most common) generate a \n
-	     * from the down-arrow key.  With this logic, it's the user's
+	     * from the down-arrow key.  With this logic, it is the user's
 	     * choice whether to set kcud=\n for wget_wch(); terminating
 	     * *getn_wstr() with \n should work either way.
 	     */
 	    if (ch == KEY_DOWN || ch == KEY_ENTER) {
-		if (oldecho == TRUE
+		if (save_flags._echo == TRUE
 		    && win->_cury == win->_maxy
 		    && win->_scroll)
 		    wechochar(win, (chtype) '\n');
@@ -155,21 +155,21 @@
 	    }
 	    if (ch == KEY_LEFT || ch == KEY_BACKSPACE) {
 		if (tmpstr > oldstr) {
-		    tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho);
+		    tmpstr = WipeOut(win, y, x, oldstr, tmpstr, save_flags._echo);
 		}
 	    } else if (ch == KEY_EOL) {
 		while (tmpstr > oldstr) {
-		    tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho);
+		    tmpstr = WipeOut(win, y, x, oldstr, tmpstr, save_flags._echo);
 		}
 	    } else {
 		beep();
 	    }
-	} else if (maxlen >= 0 && tmpstr - oldstr >= maxlen) {
+	} else if (tmpstr - oldstr >= maxlen) {
 	    beep();
 	} else {
 	    *tmpstr++ = ch;
 	    *tmpstr = 0;
-	    if (oldecho == TRUE) {
+	    if (save_flags._echo == TRUE) {
 		int oldy = win->_cury;
 
 		if (wadd_wint(win, tmpstr - 1) == ERR) {
@@ -179,9 +179,9 @@
 		     */
 		    win->_flags &= ~_WRAPPED;
 		    waddch(win, (chtype) ' ');
-		    tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho);
+		    tmpstr = WipeOut(win, y, x, oldstr, tmpstr, save_flags._echo);
 		    continue;
-		} else if (win->_flags & _WRAPPED) {
+		} else if (IS_WRAPPED(win)) {
 		    /*
 		     * If the last waddch forced a wrap & scroll, adjust our
 		     * reference point for erasures.
@@ -209,11 +209,7 @@
     /* Restore with a single I/O call, to fix minor asymmetry between
      * raw/noraw, etc.
      */
-    sp->_nl = oldnl;
-    sp->_echo = oldecho;
-    sp->_raw = oldraw;
-    sp->_cbreak = oldcbreak;
-
+    sp->_tty_flags = save_flags;
     (void) _nc_set_tty_mode(&buf);
 
     *tmpstr = 0;
diff --git a/ncurses/widechar/lib_hline_set.c b/ncurses/widechar/lib_hline_set.c
index da92b83..8d5e026 100644
--- a/ncurses/widechar/lib_hline_set.c
+++ b/ncurses/widechar/lib_hline_set.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2002-2010,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,23 +40,21 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_hline_set.c,v 1.4 2010/12/19 01:45:03 tom Exp $")
+MODULE_ID("$Id: lib_hline_set.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 whline_set(WINDOW *win, const cchar_t *ch, int n)
 {
     int code = ERR;
-    int start;
-    int end;
 
     T((T_CALLED("whline_set(%p,%s,%d)"), (void *) win, _tracecchar_t(ch), n));
 
     if (win) {
 	struct ldat *line = &(win->_line[win->_cury]);
 	NCURSES_CH_T wch;
+	int start = win->_curx;
+	int end = start + n - 1;
 
-	start = win->_curx;
-	end = start + n - 1;
 	if (end > win->_maxx)
 	    end = win->_maxx;
 
diff --git a/ncurses/widechar/lib_in_wch.c b/ncurses/widechar/lib_in_wch.c
index b239650..1d27332 100644
--- a/ncurses/widechar/lib_in_wch.c
+++ b/ncurses/widechar/lib_in_wch.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2006,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2002-2009,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,17 +40,19 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_in_wch.c,v 1.5 2009/10/24 22:37:55 tom Exp $")
+MODULE_ID("$Id: lib_in_wch.c,v 1.7 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 win_wch(WINDOW *win, cchar_t *wcval)
 {
-    int row, col;
     int code = OK;
 
     TR(TRACE_CCALLS, (T_CALLED("win_wch(%p,%p)"), (void *) win, (void *) wcval));
+
     if (win != 0
 	&& wcval != 0) {
+	int row, col;
+
 	getyx(win, row, col);
 
 	*wcval = win->_line[row].text[col];
diff --git a/ncurses/widechar/lib_in_wchnstr.c b/ncurses/widechar/lib_in_wchnstr.c
index 57cc2ca..40a2bb6 100644
--- a/ncurses/widechar/lib_in_wchnstr.c
+++ b/ncurses/widechar/lib_in_wchnstr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2007,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2002-2007,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_in_wchnstr.c,v 1.8 2009/10/24 22:37:48 tom Exp $")
+MODULE_ID("$Id: lib_in_wchnstr.c,v 1.9 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 win_wchnstr(WINDOW *win, cchar_t *wchstr, int n)
diff --git a/ncurses/widechar/lib_ins_wch.c b/ncurses/widechar/lib_ins_wch.c
index 2aa71a5..ecaabcc 100644
--- a/ncurses/widechar/lib_ins_wch.c
+++ b/ncurses/widechar/lib_ins_wch.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2010,2011 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2023 Thomas E. Dickey                                *
+ * Copyright 2002-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_ins_wch.c,v 1.17 2011/10/22 16:34:50 tom Exp $")
+MODULE_ID("$Id: lib_ins_wch.c,v 1.29 2023/11/21 21:53:28 tom Exp $")
 
 /*
  * Insert the given character, updating the current location to simplify
@@ -48,8 +49,7 @@
 NCURSES_EXPORT(int)
 _nc_insert_wch(WINDOW *win, const cchar_t *wch)
 {
-    int cells = wcwidth(CharOf(CHDEREF(wch)));
-    int cell;
+    int cells = _nc_wacs_width(CharOf(CHDEREF(wch)));
     int code = OK;
 
     if (cells < 0) {
@@ -59,6 +59,7 @@
 	    cells = 1;
 
 	if (win->_curx <= win->_maxx) {
+	    int cell;
 	    struct ldat *line = &(win->_line[win->_cury]);
 	    NCURSES_CH_T *end = &(line->text[win->_curx]);
 	    NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
@@ -73,7 +74,7 @@
 		SetWidecExt(temp1[cell], cell);
 	    }
 
-	    win->_curx++;
+	    win->_curx = (NCURSES_SIZE_T) (win->_curx + cells);
 	}
     }
     return code;
@@ -82,15 +83,13 @@
 NCURSES_EXPORT(int)
 wins_wch(WINDOW *win, const cchar_t *wch)
 {
-    NCURSES_SIZE_T oy;
-    NCURSES_SIZE_T ox;
     int code = ERR;
 
     T((T_CALLED("wins_wch(%p, %s)"), (void *) win, _tracecchar_t(wch)));
 
     if (win != 0) {
-	oy = win->_cury;
-	ox = win->_curx;
+	NCURSES_SIZE_T oy = win->_cury;
+	NCURSES_SIZE_T ox = win->_curx;
 
 	code = _nc_insert_wch(win, wch);
 
@@ -105,25 +104,27 @@
 wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
 {
     int code = ERR;
-    NCURSES_SIZE_T oy;
-    NCURSES_SIZE_T ox;
-    const wchar_t *cp;
 
     T((T_CALLED("wins_nwstr(%p,%s,%d)"),
        (void *) win, _nc_viswbufn(wstr, n), n));
 
     if (win != 0
-	&& wstr != 0) {
-	if (n < 1)
-	    n = (int) wcslen(wstr);
-	code = OK;
-	if (n > 0) {
-	    SCREEN *sp = _nc_screen_of(win);
+	&& wstr != 0
+	&& n != 0) {
 
-	    oy = win->_cury;
-	    ox = win->_curx;
-	    for (cp = wstr; *cp && ((cp - wstr) < n); cp++) {
-		int len = wcwidth(*cp);
+	if (n < 0) {
+	    n = INT_MAX;
+	}
+	code = OK;
+
+	if (n > 0) {
+	    const wchar_t *cp;
+	    SCREEN *sp = _nc_screen_of(win);
+	    NCURSES_SIZE_T oy = win->_cury;
+	    NCURSES_SIZE_T ox = win->_curx;
+
+	    for (cp = wstr; ((cp - wstr) < n) && (*cp != L'\0'); cp++) {
+		int len = _nc_wacs_width(*cp);
 
 		if ((len >= 0 && len != 1) || !is7bits(*cp)) {
 		    cchar_t tmp_cchar;
diff --git a/ncurses/widechar/lib_inwstr.c b/ncurses/widechar/lib_inwstr.c
index a4f5b8e..b2fdaea 100644
--- a/ncurses/widechar/lib_inwstr.c
+++ b/ncurses/widechar/lib_inwstr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2009,2011 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2002-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,31 +40,39 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_inwstr.c,v 1.6 2011/05/28 22:49:49 tom Exp $")
+MODULE_ID("$Id: lib_inwstr.c,v 1.9 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 winnwstr(WINDOW *win, wchar_t *wstr, int n)
 {
-    int row, col, inx;
     int count = 0;
-    int last = 0;
     cchar_t *text;
-    wchar_t wch;
 
     T((T_CALLED("winnwstr(%p,%p,%d)"), (void *) win, (void *) wstr, n));
     if (wstr != 0) {
 	if (win) {
+	    int row, col;
+	    int last = 0;
+	    bool done = FALSE;
+
 	    getyx(win, row, col);
 
 	    text = win->_line[row].text;
-	    while (count < n && count != ERR) {
+	    while (count < n && !done && count != ERR) {
+
 		if (!isWidecExt(text[col])) {
+		    int inx;
+		    wchar_t wch;
+
 		    for (inx = 0; (inx < CCHARW_MAX)
 			 && ((wch = text[col].chars[inx]) != 0);
 			 ++inx) {
 			if (count + 1 > n) {
-			    if ((count = last) == 0) {
+			    done = TRUE;
+			    if (last == 0) {
 				count = ERR;	/* error if we store nothing */
+			    } else {
+				count = last;	/* only store complete chars */
 			    }
 			    break;
 			}
diff --git a/ncurses/widechar/lib_key_name.c b/ncurses/widechar/lib_key_name.c
index da65f21..379bdc2 100644
--- a/ncurses/widechar/lib_key_name.c
+++ b/ncurses/widechar/lib_key_name.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007 Free Software Foundation, Inc.                        *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 2007-2008,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -35,7 +36,9 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_key_name.c,v 1.3 2008/10/11 20:15:14 tom Exp $")
+MODULE_ID("$Id: lib_key_name.c,v 1.6 2023/06/03 12:15:34 tom Exp $")
+
+#define MyData _nc_globals.key_name
 
 NCURSES_EXPORT(NCURSES_CONST char *)
 key_name(wchar_t c)
@@ -43,20 +46,22 @@
     cchar_t my_cchar;
     wchar_t *my_wchars;
     size_t len;
-
-    /* FIXME: move to _nc_globals */
-    static char result[MB_LEN_MAX + 1];
+    NCURSES_CONST char *result = NULL;
 
     memset(&my_cchar, 0, sizeof(my_cchar));
     my_cchar.chars[0] = c;
     my_cchar.chars[1] = L'\0';
 
     my_wchars = wunctrl(&my_cchar);
-    len = wcstombs(result, my_wchars, sizeof(result) - 1);
-    if (isEILSEQ(len) || (len == 0)) {
-	return 0;
+    /*
+     * wunctrl() could return a wide character rather than just a "printable"
+     * representation.  Check for that and return a corresponding multibyte
+     * character string.
+     */
+    len = wcstombs(MyData, my_wchars, sizeof(MyData) - 1);
+    if (!isEILSEQ(len) && (len != 0) && (len <= MB_LEN_MAX)) {
+	MyData[len] = '\0';
+	result = MyData;
     }
-
-    result[len] = '\0';
     return result;
 }
diff --git a/ncurses/widechar/lib_pecho_wchar.c b/ncurses/widechar/lib_pecho_wchar.c
index b6da7a8..502967f 100644
--- a/ncurses/widechar/lib_pecho_wchar.c
+++ b/ncurses/widechar/lib_pecho_wchar.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2004,2009 Free Software Foundation, Inc.                   *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 2004,2009 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,7 +33,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_pecho_wchar.c,v 1.2 2009/10/24 22:43:32 tom Exp $")
+MODULE_ID("$Id: lib_pecho_wchar.c,v 1.4 2021/10/23 17:07:56 tom Exp $")
 
 NCURSES_EXPORT(int)
 pecho_wchar(WINDOW *pad, const cchar_t *wch)
@@ -42,7 +43,7 @@
     if (pad == 0)
 	returnCode(ERR);
 
-    if (!(pad->_flags & _ISPAD))
+    if (!IS_PAD(pad))
 	returnCode(wecho_wchar(pad, wch));
 
     wadd_wch(pad, wch);
diff --git a/ncurses/widechar/lib_slk_wset.c b/ncurses/widechar/lib_slk_wset.c
index 8927556..5aa75ff 100644
--- a/ncurses/widechar/lib_slk_wset.c
+++ b/ncurses/widechar/lib_slk_wset.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2003-2002,2011 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2003-2011,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,23 +41,26 @@
 #include <wctype.h>
 #endif
 
-MODULE_ID("$Id: lib_slk_wset.c,v 1.13 2011/10/22 15:52:20 tom Exp $")
+MODULE_ID("$Id: lib_slk_wset.c,v 1.15 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 slk_wset(int i, const wchar_t *astr, int format)
 {
     int result = ERR;
-    size_t arglen;
     const wchar_t *str;
-    char *mystr;
     mbstate_t state;
 
     T((T_CALLED("slk_wset(%d, %s, %d)"), i, _nc_viswbuf(astr), format));
 
     if (astr != 0) {
+	size_t arglen;
+
 	init_mb(state);
 	str = astr;
+
 	if ((arglen = wcsrtombs(NULL, &str, (size_t) 0, &state)) != (size_t) -1) {
+	    char *mystr;
+
 	    if ((mystr = (char *) _nc_doalloc(0, arglen + 1)) != 0) {
 		str = astr;
 		if (wcsrtombs(mystr, &str, arglen, &state) != (size_t) -1) {
diff --git a/ncurses/widechar/lib_unget_wch.c b/ncurses/widechar/lib_unget_wch.c
index d5ae608..1a81fec 100644
--- a/ncurses/widechar/lib_unget_wch.c
+++ b/ncurses/widechar/lib_unget_wch.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2010,2011 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 2002-2011,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_unget_wch.c,v 1.15 2011/10/22 16:34:50 tom Exp $")
+MODULE_ID("$Id: lib_unget_wch.c,v 1.18 2023/06/03 12:50:52 tom Exp $")
 
 /*
  * Wrapper for wcrtomb() which obtains the length needed for the given
@@ -59,7 +60,7 @@
     } else {
 	result = (int) wcrtomb(target, source, state);
     }
-    if (!isEILSEQ(result) && (result == 0))
+    if (!isEILSEQ(result) && ((result == 0) || (result > MB_LEN_MAX)))
 	result = 1;
     return (size_t) result;
 }
@@ -70,7 +71,6 @@
     int result = OK;
     mbstate_t state;
     size_t length;
-    int n;
 
     T((T_CALLED("unget_wch(%p, %#lx)"), (void *) SP_PARM, (unsigned long) wch));
 
@@ -82,6 +82,8 @@
 	char *string;
 
 	if ((string = (char *) malloc(length)) != 0) {
+	    int n;
+
 	    init_mb(state);
 	    /* ignore the result, since we already validated the character */
 	    IGNORE_RC((int) wcrtomb(string, wch, &state));
diff --git a/ncurses/widechar/lib_vid_attr.c b/ncurses/widechar/lib_vid_attr.c
index 80c1ea4..f108b30 100644
--- a/ncurses/widechar/lib_vid_attr.c
+++ b/ncurses/widechar/lib_vid_attr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
+ * Copyright 2002-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -36,27 +37,34 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_vid_attr.c,v 1.23 2014/06/07 22:13:46 tom Exp $")
+MODULE_ID("$Id: lib_vid_attr.c,v 1.31 2023/04/28 20:59:34 tom Exp $")
 
 #define doPut(mode) \
 	TPUTS_TRACE(#mode); \
 	NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc)
 
 #define TurnOn(mask, mode) \
-	if ((turn_on & mask) && mode) { doPut(mode); }
+	if ((turn_on & mask) && mode) { \
+	    TPUTS_TRACE(#mode); \
+	    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc); \
+	}
 
 #define TurnOff(mask, mode) \
-	if ((turn_off & mask) && mode) { doPut(mode); turn_off &= ~mask; }
+	if ((turn_off & mask) && mode) { \
+	    TPUTS_TRACE(#mode); \
+	    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc); \
+	    turn_off &= ~mask; \
+	}
 
 	/* if there is no current screen, assume we *can* do color */
 #define SetColorsIf(why, old_attr, old_pair) \
 	if (can_color && (why)) { \
-		TR(TRACE_ATTRS, ("old pair = %d -- new pair = %d", old_pair, pair)); \
-		if ((pair != old_pair) \
-		 || (fix_pair0 && (pair == 0)) \
+		TR(TRACE_ATTRS, ("old pair = %d -- new pair = %d", old_pair, color_pair)); \
+		if ((color_pair != old_pair) \
+		 || (fix_pair0 && (color_pair == 0)) \
 		 || (reverse ^ ((old_attr & A_REVERSE) != 0))) { \
 		    NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx \
-						   old_pair, pair, \
+						   old_pair, color_pair, \
 						   reverse, outc); \
 		} \
 	}
@@ -68,10 +76,11 @@
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
 			   attr_t newmode,
-			   NCURSES_PAIRS_T pair,
-			   void *opts GCC_UNUSED,
+			   NCURSES_PAIRS_T pair_arg,
+			   void *opts OPTIONAL_PAIR,
 			   NCURSES_SP_OUTC outc)
 {
+    int color_pair = pair_arg;
 #if NCURSES_EXT_COLORS
     static attr_t previous_attr = A_NORMAL;
     static int previous_pair = 0;
@@ -85,8 +94,12 @@
 #define fix_pair0 FALSE
 #endif
 
+    if (!IsValidTIScreen(SP_PARM))
+	returnCode(ERR);
+
     newmode &= A_ATTRIBUTES;
-    T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), pair));
+    set_extended_pair(opts, color_pair);
+    T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), color_pair));
 
     /* this allows us to go on whether or not newterm() has been called */
     if (SP_PARM) {
@@ -107,7 +120,7 @@
      * If we have a terminal that cannot combine color with video
      * attributes, use the colors in preference.
      */
-    if ((pair != 0
+    if ((color_pair != 0
 	 || fix_pair0)
 	&& (no_color_video > 0)) {
 	/*
@@ -136,7 +149,7 @@
     }
 
     if (newmode == previous_attr
-	&& pair == previous_pair)
+	&& color_pair == previous_pair)
 	returnCode(OK);
 
     if (reverse) {
@@ -146,7 +159,7 @@
     turn_off = (~newmode & previous_attr) & ALL_BUT_COLOR;
     turn_on = (newmode & ~(previous_attr & TPARM_ATTR)) & ALL_BUT_COLOR;
 
-    SetColorsIf(((pair == 0) && !fix_pair0), previous_attr, previous_pair);
+    SetColorsIf(((color_pair == 0) && !fix_pair0), previous_attr, previous_pair);
 
     if (newmode == A_NORMAL) {
 	if ((previous_attr & A_ALTCHARSET) && exit_alt_charset_mode) {
@@ -168,26 +181,27 @@
 		    TurnOff(A_ITALIC, exit_italics_mode);
 		}
 #endif
+		(void) turn_off;
 	    }
 	    previous_attr &= ALL_BUT_COLOR;
 	    previous_pair = 0;
 	}
 
-	SetColorsIf((pair != 0) || fix_pair0, previous_attr, previous_pair);
+	SetColorsIf((color_pair != 0) || fix_pair0, previous_attr, previous_pair);
     } else if (set_attributes) {
 	if (turn_on || turn_off) {
 	    TPUTS_TRACE("set_attributes");
 	    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
-				    TPARM_9(set_attributes,
-					    (newmode & A_STANDOUT) != 0,
-					    (newmode & A_UNDERLINE) != 0,
-					    (newmode & A_REVERSE) != 0,
-					    (newmode & A_BLINK) != 0,
-					    (newmode & A_DIM) != 0,
-					    (newmode & A_BOLD) != 0,
-					    (newmode & A_INVIS) != 0,
-					    (newmode & A_PROTECT) != 0,
-					    (newmode & A_ALTCHARSET) != 0),
+				    TIPARM_9(set_attributes,
+					       (newmode & A_STANDOUT) != 0,
+					       (newmode & A_UNDERLINE) != 0,
+					       (newmode & A_REVERSE) != 0,
+					       (newmode & A_BLINK) != 0,
+					       (newmode & A_DIM) != 0,
+					       (newmode & A_BOLD) != 0,
+					       (newmode & A_INVIS) != 0,
+					       (newmode & A_PROTECT) != 0,
+					       (newmode & A_ALTCHARSET) != 0),
 				    1, outc);
 	    previous_attr &= ALL_BUT_COLOR;
 	    previous_pair = 0;
@@ -199,9 +213,10 @@
 	    } else if (turn_off & A_ITALIC) {
 		TurnOff(A_ITALIC, exit_italics_mode);
 	    }
+	    (void) turn_off;
 	}
 #endif
-	SetColorsIf((pair != 0) || fix_pair0, previous_attr, previous_pair);
+	SetColorsIf((color_pair != 0) || fix_pair0, previous_attr, previous_pair);
     } else {
 
 	TR(TRACE_ATTRS, ("turning %s off", _traceattr(turn_off)));
@@ -226,7 +241,7 @@
 	    previous_attr &= ALL_BUT_COLOR;
 	    previous_pair = 0;
 	}
-	SetColorsIf((pair != 0) || fix_pair0, previous_attr, previous_pair);
+	SetColorsIf((color_pair != 0) || fix_pair0, previous_attr, previous_pair);
 
 	TR(TRACE_ATTRS, ("turning %s on", _traceattr(turn_on)));
 	/* *INDENT-OFF* */
@@ -242,7 +257,7 @@
 #if USE_ITALIC
 	TurnOn(A_ITALIC,	enter_italics_mode);
 #endif
-#if USE_WIDEC_SUPPORT
+#if USE_WIDEC_SUPPORT && defined(enter_horizontal_hl_mode)
 	TurnOn(A_HORIZONTAL,	enter_horizontal_hl_mode);
 	TurnOn(A_LEFT,		enter_left_hl_mode);
 	TurnOn(A_LOW,		enter_low_hl_mode);
@@ -251,7 +266,6 @@
 	TurnOn(A_VERTICAL,	enter_vertical_hl_mode);
 #endif
 	/* *INDENT-ON* */
-
     }
 
     if (reverse)
@@ -259,16 +273,17 @@
 
     if (SP_PARM) {
 	SetAttr(SCREEN_ATTRS(SP_PARM), newmode);
-	SetPair(SCREEN_ATTRS(SP_PARM), pair);
+	SetPair(SCREEN_ATTRS(SP_PARM), color_pair);
     } else {
 	previous_attr = newmode;
-	previous_pair = pair;
+	previous_pair = color_pair;
     }
 
     returnCode(OK);
 #else
-    T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), (int) pair));
-    set_color(newmode, pair);
+    T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), color_pair));
+    (void) opts;
+    set_color(newmode, color_pair);
     returnCode(NCURSES_SP_NAME(vidputs) (NCURSES_SP_ARGx newmode, outc));
 #endif
 }
@@ -276,14 +291,14 @@
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(int)
 vid_puts(attr_t newmode,
-	 NCURSES_PAIRS_T pair,
+	 NCURSES_PAIRS_T pair_arg,
 	 void *opts GCC_UNUSED,
 	 NCURSES_OUTC outc)
 {
     SetSafeOutcWrapper(outc);
     return NCURSES_SP_NAME(vid_puts) (CURRENT_SCREEN,
 				      newmode,
-				      pair,
+				      pair_arg,
 				      opts,
 				      _nc_outc_wrapper);
 }
@@ -293,22 +308,22 @@
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(vid_attr) (NCURSES_SP_DCLx
 			   attr_t newmode,
-			   NCURSES_PAIRS_T pair,
+			   NCURSES_PAIRS_T pair_arg,
 			   void *opts)
 {
-    T((T_CALLED("vid_attr(%s,%d)"), _traceattr(newmode), (int) pair));
+    T((T_CALLED("vid_attr(%s,%d)"), _traceattr(newmode), (int) pair_arg));
     returnCode(NCURSES_SP_NAME(vid_puts) (NCURSES_SP_ARGx
 					  newmode,
-					  pair,
+					  pair_arg,
 					  opts,
 					  NCURSES_SP_NAME(_nc_putchar)));
 }
 
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(int)
-vid_attr(attr_t newmode, NCURSES_PAIRS_T pair, void *opts)
+vid_attr(attr_t newmode, NCURSES_PAIRS_T pair_arg, void *opts)
 {
-    return NCURSES_SP_NAME(vid_attr) (CURRENT_SCREEN, newmode, pair, opts);
+    return NCURSES_SP_NAME(vid_attr) (CURRENT_SCREEN, newmode, pair_arg, opts);
 }
 #endif
 
@@ -325,6 +340,7 @@
     if (SP_PARM) {
 	attrs = NCURSES_SP_NAME(termattrs) (NCURSES_SP_ARG);
 
+#if USE_WIDEC_SUPPORT && defined(enter_horizontal_hl_mode)
 	/* these are only supported for wide-character mode */
 	if (enter_horizontal_hl_mode)
 	    attrs |= WA_HORIZONTAL;
@@ -338,6 +354,7 @@
 	    attrs |= WA_TOP;
 	if (enter_vertical_hl_mode)
 	    attrs |= WA_VERTICAL;
+#endif
     }
 
     returnAttr(attrs);
diff --git a/ncurses/widechar/lib_vline_set.c b/ncurses/widechar/lib_vline_set.c
index 917caac..f7bb581 100644
--- a/ncurses/widechar/lib_vline_set.c
+++ b/ncurses/widechar/lib_vline_set.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2002-2010,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,22 +40,21 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_vline_set.c,v 1.4 2010/12/19 01:50:50 tom Exp $")
+MODULE_ID("$Id: lib_vline_set.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 wvline_set(WINDOW *win, const cchar_t *ch, int n)
 {
     int code = ERR;
-    int row, col;
-    int end;
 
     T((T_CALLED("wvline(%p,%s,%d)"), (void *) win, _tracecchar_t(ch), n));
 
     if (win) {
 	NCURSES_CH_T wch;
-	row = win->_cury;
-	col = win->_curx;
-	end = row + n - 1;
+	int row = win->_cury;
+	int col = win->_curx;
+	int end = row + n - 1;
+
 	if (end > win->_maxy)
 	    end = win->_maxy;
 
diff --git a/ncurses/widechar/lib_wacs.c b/ncurses/widechar/lib_wacs.c
index dc3af21..5b6f6da 100644
--- a/ncurses/widechar/lib_wacs.c
+++ b/ncurses/widechar/lib_wacs.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2002-2015,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,7 +33,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_wacs.c,v 1.14 2014/02/23 01:21:08 tom Exp $")
+MODULE_ID("$Id: lib_wacs.c,v 1.20 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT_VAR(cchar_t) * _nc_wacs = 0;
 
@@ -106,7 +107,6 @@
     };
     /* *INDENT-ON* */
 
-    unsigned n, m;
     int active = _nc_unicode_locale();
 
     /*
@@ -120,9 +120,15 @@
        active ? "" : " not"));
 
     if ((_nc_wacs = typeCalloc(cchar_t, ACS_LEN)) != 0) {
+	unsigned n;
 
 	for (n = 0; n < SIZEOF(table); ++n) {
+	    unsigned m;
+#if NCURSES_WCWIDTH_GRAPHICS
 	    int wide = wcwidth((wchar_t) table[n].value[active]);
+#else
+	    int wide = 1;
+#endif
 
 	    m = table[n].map;
 	    if (active && (wide == 1)) {
@@ -133,9 +139,9 @@
 		SetChar(_nc_wacs[m], table[n].value[0], A_NORMAL);
 	    }
 
-	    T(("#%d, SetChar(%c, %#04x) = %s",
-	       n, m,
-	       table[n].value[active],
+	    T(("#%d, width:%d SetChar(%c, %s) = %s",
+	       n, wide, m,
+	       _tracechar(table[n].value[active]),
 	       _tracecchar_t(&_nc_wacs[m])));
 	}
     }
diff --git a/ncurses/widechar/lib_wunctrl.c b/ncurses/widechar/lib_wunctrl.c
index 45d4952..155da22 100644
--- a/ncurses/widechar/lib_wunctrl.c
+++ b/ncurses/widechar/lib_wunctrl.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2001-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2001-2011,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -35,7 +36,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_wunctrl.c,v 1.16 2012/12/15 20:53:42 tom Exp $")
+MODULE_ID("$Id: lib_wunctrl.c,v 1.17 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(wchar_t *)
 NCURSES_SP_NAME(wunctrl) (NCURSES_SP_DCLx cchar_t *wc)
diff --git a/ncurses/widechar/widechars.c b/ncurses/widechar/widechars.c
index 6951e28..d05ba98 100644
--- a/ncurses/widechar/widechars.c
+++ b/ncurses/widechar/widechars.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2012,2013 Free Software Foundation, Inc.                   *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2012,2013 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -30,9 +31,9 @@
 
 #if USE_WIDEC_SUPPORT
 
-MODULE_ID("$Id: widechars.c,v 1.5 2013/03/02 18:55:51 tom Exp $")
+MODULE_ID("$Id: widechars.c,v 1.9 2020/08/29 16:22:03 juergen Exp $")
 
-#if defined(__MINGW32__)
+#if (defined(_NC_WINDOWS)) && !defined(_NC_MSC)
 /*
  * MinGW has wide-character functions, but they do not work correctly.
  */
@@ -147,6 +148,6 @@
     return result;
 }
 
-#endif /* __MINGW32__ */
+#endif /* _NC_WINDOWS */
 
 #endif /* USE_WIDEC_SUPPORT */
diff --git a/ncurses/win32con/gettimeofday.c b/ncurses/win32con/gettimeofday.c
index 867041f..603a6f4 100644
--- a/ncurses/win32con/gettimeofday.c
+++ b/ncurses/win32con/gettimeofday.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2008-2010,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
+ * Copyright 2008-2010,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -35,11 +36,12 @@
 
 #include <windows.h>
 
-MODULE_ID("$Id: gettimeofday.c,v 1.3 2014/04/26 19:41:34 juergen Exp $")
+MODULE_ID("$Id: gettimeofday.c,v 1.7 2023/02/25 20:05:36 tom Exp $")
 
+#if HAVE_GETTIMEOFDAY == 2
 #define JAN1970 116444736000000000LL	/* the value for 01/01/1970 00:00 */
 
-int
+NCURSES_EXPORT(int)
 gettimeofday(struct timeval *tv, void *tz GCC_UNUSED)
 {
     union {
@@ -52,3 +54,4 @@
     tv->tv_sec = (long) ((data.since1601 - JAN1970) / 10000000LL);
     return (0);
 }
+#endif // HAVE_GETTIMEOFDAY == 2
diff --git a/ncurses/win32con/wcwidth.c b/ncurses/win32con/wcwidth.c
index cdef64a..5584366 100644
--- a/ncurses/win32con/wcwidth.c
+++ b/ncurses/win32con/wcwidth.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2010 Free Software Foundation, Inc.                        *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2010 Free Software Foundation, Inc.                            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -27,7 +28,7 @@
  ****************************************************************************/
 #include <curses.priv.h>
 
-MODULE_ID("$Id: wcwidth.c,v 1.2 2010/08/07 20:52:43 tom Exp $")
+MODULE_ID("$Id: wcwidth.c,v 1.4 2020/07/11 21:02:10 tom Exp $")
 
 #if USE_WIDEC_SUPPORT
 #define mk_wcwidth(ucs)          _nc_wcwidth(ucs)
@@ -35,10 +36,10 @@
 #define mk_wcwidth_cjk(ucs)      _nc_wcwidth_cjk(ucs)
 #define mk_wcswidth_cjk(pwcs, n) _nc_wcswidth_cjk(pwcs, n)
 
-extern int mk_wcwidth(wchar_t);
-extern int mk_wcswidth(const wchar_t *, size_t);
-extern int mk_wcwidth_cjk(wchar_t);
-extern int mk_wcswidth_cjk(const wchar_t *, size_t);
+NCURSES_EXPORT(int) mk_wcwidth(wchar_t);
+NCURSES_EXPORT(int) mk_wcswidth(const wchar_t *, size_t);
+NCURSES_EXPORT(int) mk_wcwidth_cjk(wchar_t);
+NCURSES_EXPORT(int) mk_wcswidth_cjk(const wchar_t *, size_t);
 
 #include <wcwidth.h>
 #else
diff --git a/ncurses/win32con/win32_driver.c b/ncurses/win32con/win32_driver.c
new file mode 100644
index 0000000..0a43588
--- /dev/null
+++ b/ncurses/win32con/win32_driver.c
@@ -0,0 +1,1225 @@
+/****************************************************************************
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
+ * Copyright 2008-2016,2017 Free Software Foundation, Inc.                  *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "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.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *  Author: Juergen Pfeifer                                                 *
+ *     and: Thomas E. Dickey                                                *
+ ****************************************************************************/
+
+/*
+ * TODO - improve screen-repainting performance, using implied wraparound to reduce write's
+ * TODO - make it optional whether screen is restored or not when non-buffered
+ */
+
+#include <curses.priv.h>
+#ifdef _NC_WINDOWS
+#if (defined(__MINGW32__) || defined(__MINGW64__))
+#include <wchar.h>
+#else
+#include <tchar.h>
+#endif
+#include <io.h>
+
+#define CUR TerminalType(my_term).
+
+MODULE_ID("$Id: win32_driver.c,v 1.4 2023/09/16 16:29:24 tom Exp $")
+
+#define WINMAGIC NCDRV_MAGIC(NCDRV_WINCONSOLE)
+#define EXP_OPTIMIZE 0
+
+static bool console_initialized = FALSE;
+
+#define AssertTCB() assert(TCB != 0 && (TCB->magic == WINMAGIC))
+#define validateConsoleHandle() (AssertTCB() , console_initialized ||\
+                                 (console_initialized=\
+                                  _nc_console_checkinit(TRUE,FALSE)))
+#define SetSP() assert(TCB->csp != 0); sp = TCB->csp; (void) sp
+#define AdjustY() (WINCONSOLE.buffered ?\
+                   0 : (int) WINCONSOLE.SBI.srWindow.Top)
+#define RevAttr(attr) (WORD) (((attr) & 0xff00) |   \
+                              ((((attr) & 0x07) << 4) | \
+                               (((attr) & 0x70) >> 4)))
+
+#if USE_WIDEC_SUPPORT
+#define write_screen WriteConsoleOutputW
+#define read_screen  ReadConsoleOutputW
+#else
+#define write_screen WriteConsoleOutput
+#define read_screen  ReadConsoleOutput
+#endif
+
+static WORD
+MapAttr(WORD res, attr_t ch)
+{
+    if (ch & A_COLOR) {
+	int p;
+
+	p = PairNumber(ch);
+	if (p > 0 && p < CON_NUMPAIRS) {
+	    WORD a;
+	    a = WINCONSOLE.pairs[p];
+	    res = (WORD) ((res & 0xff00) | a);
+	}
+    }
+
+    if (ch & A_REVERSE) {
+	res = RevAttr(res);
+    }
+
+    if (ch & A_STANDOUT) {
+	res = RevAttr(res) | BACKGROUND_INTENSITY;
+    }
+
+    if (ch & A_BOLD)
+	res |= FOREGROUND_INTENSITY;
+
+    if (ch & A_DIM)
+	res |= BACKGROUND_INTENSITY;
+
+    return res;
+}
+
+#if 0				/* def TRACE */
+static void
+dump_screen(const char *fn, int ln)
+{
+    int max_cells = (WINCONSOLE.SBI.dwSize.Y *
+		     (1 + WINCONSOLE.SBI.dwSize.X)) + 1;
+    char output[max_cells];
+    CHAR_INFO save_screen[max_cells];
+    COORD save_size;
+    SMALL_RECT save_region;
+    COORD bufferCoord;
+
+    T(("dump_screen %s@%d", fn, ln));
+
+    save_region.Top = WINCONSOLE.SBI.srWindow.Top;
+    save_region.Left = WINCONSOLE.SBI.srWindow.Left;
+    save_region.Bottom = WINCONSOLE.SBI.srWindow.Bottom;
+    save_region.Right = WINCONSOLE.SBI.srWindow.Right;
+
+    save_size.X = (SHORT) (save_region.Right - save_region.Left + 1);
+    save_size.Y = (SHORT) (save_region.Bottom - save_region.Top + 1);
+
+    bufferCoord.X = bufferCoord.Y = 0;
+
+    if (read_screen(WINCONSOLE.hdl,
+		    save_screen,
+		    save_size,
+		    bufferCoord,
+		    &save_region)) {
+	int i, j;
+	int ij = 0;
+	int k = 0;
+
+	for (i = save_region.Top; i <= save_region.Bottom; ++i) {
+	    for (j = save_region.Left; j <= save_region.Right; ++j) {
+		output[k++] = save_screen[ij++].Char.AsciiChar;
+	    }
+	    output[k++] = '\n';
+	}
+	output[k] = 0;
+
+	T(("DUMP: %d,%d - %d,%d",
+	   save_region.Top,
+	   save_region.Left,
+	   save_region.Bottom,
+	   save_region.Right));
+	T(("%s", output));
+    }
+}
+
+#else
+#define dump_screen(fn,ln)	/* nothing */
+#endif
+
+#if USE_WIDEC_SUPPORT
+/*
+ * TODO: support surrogate pairs
+ * TODO: support combining characters
+ * TODO: support acsc
+ * TODO: _nc_wacs should be part of sp.
+ */
+static BOOL
+con_write16(TERMINAL_CONTROL_BLOCK * TCB,
+	    int y, int x, cchar_t *str, int limit)
+{
+    int actual = 0;
+    CHAR_INFO *ci = TypeAlloca(CHAR_INFO, limit);
+    COORD loc, siz;
+    SMALL_RECT rec;
+    int i;
+    cchar_t ch;
+    SCREEN *sp;
+
+    AssertTCB();
+    SetSP();
+
+    for (i = actual = 0; i < limit; i++) {
+	ch = str[i];
+	if (isWidecExt(ch))
+	    continue;
+	ci[actual].Char.UnicodeChar = CharOf(ch);
+	ci[actual].Attributes = MapAttr(WINCONSOLE.SBI.wAttributes,
+					AttrOf(ch));
+	if (AttrOf(ch) & A_ALTCHARSET) {
+	    if (_nc_wacs) {
+		int which = CharOf(ch);
+		if (which > 0
+		    && which < ACS_LEN
+		    && CharOf(_nc_wacs[which]) != 0) {
+		    ci[actual].Char.UnicodeChar = CharOf(_nc_wacs[which]);
+		} else {
+		    ci[actual].Char.UnicodeChar = ' ';
+		}
+	    }
+	}
+	++actual;
+    }
+
+    loc.X = (SHORT) 0;
+    loc.Y = (SHORT) 0;
+    siz.X = (SHORT) actual;
+    siz.Y = 1;
+
+    rec.Left = (SHORT) x;
+    rec.Top = (SHORT) (y + AdjustY());
+    rec.Right = (SHORT) (x + limit - 1);
+    rec.Bottom = rec.Top;
+
+    return write_screen(WINCONSOLE.hdl, ci, siz, loc, &rec);
+}
+#define con_write(tcb, y, x, str, n) con_write16(tcb, y, x, str, n)
+#else
+static BOOL
+con_write8(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, chtype *str, int n)
+{
+    CHAR_INFO *ci = TypeAlloca(CHAR_INFO, n);
+    COORD loc, siz;
+    SMALL_RECT rec;
+    int i;
+    chtype ch;
+    SCREEN *sp;
+
+    AssertTCB();
+    SetSP();
+
+    for (i = 0; i < n; i++) {
+	ch = str[i];
+	ci[i].Char.AsciiChar = ChCharOf(ch);
+	ci[i].Attributes = MapAttr(WINCONSOLE.SBI.wAttributes,
+				   ChAttrOf(ch));
+	if (ChAttrOf(ch) & A_ALTCHARSET) {
+	    if (sp->_acs_map)
+		ci[i].Char.AsciiChar =
+		ChCharOf(NCURSES_SP_NAME(_nc_acs_char) (sp, ChCharOf(ch)));
+	}
+    }
+
+    loc.X = (short) 0;
+    loc.Y = (short) 0;
+    siz.X = (short) n;
+    siz.Y = 1;
+
+    rec.Left = (short) x;
+    rec.Top = (short) y;
+    rec.Right = (short) (x + n - 1);
+    rec.Bottom = rec.Top;
+
+    return write_screen(WINCONSOLE.hdl, ci, siz, loc, &rec);
+}
+#define con_write(tcb, y, x, str, n) con_write8(tcb, y, x, str, n)
+#endif
+
+#if EXP_OPTIMIZE
+/*
+ * Comparing new/current screens, determine the last column-index for a change
+ * beginning on the given row,col position.  Unlike a serial terminal, there is
+ * no cost for "moving" the "cursor" on the line as we update it.
+ */
+static int
+find_end_of_change(SCREEN *sp, int row, int col)
+{
+    int result = col;
+    struct ldat *curdat = CurScreen(sp)->_line + row;
+    struct ldat *newdat = NewScreen(sp)->_line + row;
+
+    while (col <= newdat->lastchar) {
+#if USE_WIDEC_SUPPORT
+	if (isWidecExt(curdat->text[col]) ||
+	    isWidecExt(newdat->text[col])) {
+	    result = col;
+	} else if (memcmp(&curdat->text[col],
+			  &newdat->text[col],
+			  sizeof(curdat->text[0]))) {
+	    result = col;
+	} else {
+	    break;
+	}
+#else
+	if (curdat->text[col] != newdat->text[col]) {
+	    result = col;
+	} else {
+	    break;
+	}
+#endif
+	++col;
+    }
+    return result;
+}
+
+/*
+ * Given a row,col position at the end of a change-chunk, look for the
+ * beginning of the next change-chunk.
+ */
+static int
+find_next_change(SCREEN *sp, int row, int col)
+{
+    struct ldat *curdat = CurScreen(sp)->_line + row;
+    struct ldat *newdat = NewScreen(sp)->_line + row;
+    int result = newdat->lastchar + 1;
+
+    while (++col <= newdat->lastchar) {
+#if USE_WIDEC_SUPPORT
+	if (isWidecExt(curdat->text[col]) !=
+	    isWidecExt(newdat->text[col])) {
+	    result = col;
+	    break;
+	} else if (memcmp(&curdat->text[col],
+			  &newdat->text[col],
+			  sizeof(curdat->text[0]))) {
+	    result = col;
+	    break;
+	}
+#else
+	if (curdat->text[col] != newdat->text[col]) {
+	    result = col;
+	    break;
+	}
+#endif
+    }
+    return result;
+}
+
+#define EndChange(first) \
+	find_end_of_change(sp, y, first)
+#define NextChange(last)                        \
+	find_next_change(sp, y, last)
+
+#endif /* EXP_OPTIMIZE */
+
+#define MARK_NOCHANGE(win,row)                 \
+    win->_line[row].firstchar = _NOCHANGE;     \
+    win->_line[row].lastchar  = _NOCHANGE
+
+static bool
+restore_original_screen(void)
+{
+    COORD bufferCoord;
+    bool result = FALSE;
+    SMALL_RECT save_region = WINCONSOLE.save_region;
+
+    T(("... restoring %s", WINCONSOLE.window_only ?
+       "window" : "entire buffer"));
+
+    bufferCoord.X = (SHORT) (WINCONSOLE.window_only ?
+			     WINCONSOLE.SBI.srWindow.Left : 0);
+    bufferCoord.Y = (SHORT) (WINCONSOLE.window_only ?
+			     WINCONSOLE.SBI.srWindow.Top : 0);
+
+    if (write_screen(WINCONSOLE.hdl,
+		     WINCONSOLE.save_screen,
+		     WINCONSOLE.save_size,
+		     bufferCoord,
+		     &save_region)) {
+	result = TRUE;
+	mvcur(-1, -1, LINES - 2, 0);
+	T(("... restore original screen contents ok %dx%d (%d,%d - %d,%d)",
+	   WINCONSOLE.save_size.Y,
+	   WINCONSOLE.save_size.X,
+	   save_region.Top,
+	   save_region.Left,
+	   save_region.Bottom,
+	   save_region.Right));
+    } else {
+	T(("... restore original screen contents err"));
+    }
+    return result;
+}
+
+static const char *
+wcon_name(TERMINAL_CONTROL_BLOCK * TCB)
+{
+    (void) TCB;
+    return "win32console";
+}
+
+static int
+wcon_doupdate(TERMINAL_CONTROL_BLOCK * TCB)
+{
+    int result = ERR;
+    int y, nonempty, n, x0, x1, Width, Height;
+    SCREEN *sp;
+
+    T((T_CALLED("win32con::wcon_doupdate(%p)"), TCB));
+    if (validateConsoleHandle()) {
+	SetSP();
+
+	Width = screen_columns(sp);
+	Height = screen_lines(sp);
+	nonempty = Min(Height, NewScreen(sp)->_maxy + 1);
+
+	T(("... %dx%d clear cur:%d new:%d",
+	   Height, Width,
+	   CurScreen(sp)->_clear,
+	   NewScreen(sp)->_clear));
+
+	if (SP_PARM->_endwin == ewSuspend) {
+
+	    T(("coming back from shell mode"));
+	    NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_ARG);
+
+	    NCURSES_SP_NAME(_nc_mvcur_resume) (NCURSES_SP_ARG);
+	    NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_ARG);
+	    SP_PARM->_mouse_resume(SP_PARM);
+
+	    SP_PARM->_endwin = ewRunning;
+	}
+
+	if ((CurScreen(sp)->_clear || NewScreen(sp)->_clear)) {
+	    int x;
+#if USE_WIDEC_SUPPORT
+	    cchar_t *empty = TypeAlloca(cchar_t, Width);
+	    wchar_t blank[2] =
+	    {
+		L' ', L'\0'
+	    };
+
+	    for (x = 0; x < Width; x++)
+		setcchar(&empty[x], blank, 0, 0, 0);
+#else
+	    chtype *empty = TypeAlloca(chtype, Width);
+
+	    for (x = 0; x < Width; x++)
+		empty[x] = ' ';
+#endif
+
+	    for (y = 0; y < nonempty; y++) {
+		con_write(TCB, y, 0, empty, Width);
+		memcpy(empty,
+		       CurScreen(sp)->_line[y].text,
+		       (size_t) Width * sizeof(empty[0]));
+	    }
+	    CurScreen(sp)->_clear = FALSE;
+	    NewScreen(sp)->_clear = FALSE;
+	    touchwin(NewScreen(sp));
+	    T(("... cleared %dx%d lines @%d of screen", nonempty, Width,
+	       AdjustY()));
+	}
+
+	for (y = 0; y < nonempty; y++) {
+	    x0 = NewScreen(sp)->_line[y].firstchar;
+	    if (x0 != _NOCHANGE) {
+#if EXP_OPTIMIZE
+		int x2;
+		int limit = NewScreen(sp)->_line[y].lastchar;
+		while ((x1 = EndChange(x0)) <= limit) {
+		    while ((x2 = NextChange(x1)) <=
+			   limit && x2 <= (x1 + 2)) {
+			x1 = x2;
+		    }
+		    n = x1 - x0 + 1;
+		    memcpy(&CurScreen(sp)->_line[y].text[x0],
+			   &NewScreen(sp)->_line[y].text[x0],
+			   n * sizeof(CurScreen(sp)->_line[y].text[x0]));
+		    con_write(TCB,
+			      y,
+			      x0,
+			      &CurScreen(sp)->_line[y].text[x0], n);
+		    x0 = NextChange(x1);
+		}
+
+		/* mark line changed successfully */
+		if (y <= NewScreen(sp)->_maxy) {
+		    MARK_NOCHANGE(NewScreen(sp), y);
+		}
+		if (y <= CurScreen(sp)->_maxy) {
+		    MARK_NOCHANGE(CurScreen(sp), y);
+		}
+#else
+		x1 = NewScreen(sp)->_line[y].lastchar;
+		n = x1 - x0 + 1;
+		if (n > 0) {
+		    memcpy(&CurScreen(sp)->_line[y].text[x0],
+			   &NewScreen(sp)->_line[y].text[x0],
+			   (size_t) n *
+			   sizeof(CurScreen(sp)->_line[y].text[x0]));
+		    con_write(TCB,
+			      y,
+			      x0,
+			      &CurScreen(sp)->_line[y].text[x0], n);
+
+		    /* mark line changed successfully */
+		    if (y <= NewScreen(sp)->_maxy) {
+			MARK_NOCHANGE(NewScreen(sp), y);
+		    }
+		    if (y <= CurScreen(sp)->_maxy) {
+			MARK_NOCHANGE(CurScreen(sp), y);
+		    }
+		}
+#endif
+	    }
+	}
+
+	/* put everything back in sync */
+	for (y = nonempty; y <= NewScreen(sp)->_maxy; y++) {
+	    MARK_NOCHANGE(NewScreen(sp), y);
+	}
+	for (y = nonempty; y <= CurScreen(sp)->_maxy; y++) {
+	    MARK_NOCHANGE(CurScreen(sp), y);
+	}
+
+	if (!NewScreen(sp)->_leaveok) {
+	    CurScreen(sp)->_curx = NewScreen(sp)->_curx;
+	    CurScreen(sp)->_cury = NewScreen(sp)->_cury;
+
+	    TCB->drv->td_hwcur(TCB,
+			       0,
+			       0,
+			       CurScreen(sp)->_cury,
+			       CurScreen(sp)->_curx);
+	}
+	_nc_console_selectActiveHandle();
+	result = OK;
+    }
+    returnCode(result);
+}
+
+static bool
+wcon_CanHandle(TERMINAL_CONTROL_BLOCK * TCB,
+	       const char *tname,
+	       int *errret GCC_UNUSED)
+{
+    bool code = FALSE;
+
+    T((T_CALLED("win32con::wcon_CanHandle(%p)"), TCB));
+
+    assert((TCB != 0) && (tname != 0));
+
+    TCB->magic = WINMAGIC;
+
+    if (tname == 0 || *tname == 0) {
+	if (!_nc_console_vt_supported())
+	    code = TRUE;
+    } else if (tname != 0 && *tname == '#') {
+	/*
+	 * Use "#" (a character which cannot begin a terminal's name) to
+	 * select specific driver from the table.
+	 *
+	 * In principle, we could have more than one non-terminfo driver,
+	 * e.g., "win32gui".
+	 */
+	size_t n = strlen(tname + 1);
+	if (n != 0
+	    && ((strncmp(tname + 1, "win32console", n) == 0)
+		|| (strncmp(tname + 1, "win32con", n) == 0))) {
+	    code = TRUE;
+	}
+    } else if (tname != 0 && stricmp(tname, "unknown") == 0) {
+	code = TRUE;
+    }
+
+    /*
+     * This is intentional, to avoid unnecessary breakage of applications
+     * using <term.h> symbols.
+     */
+    if (code && (TerminalType(&TCB->term).Booleans == 0)) {
+	_nc_init_termtype(&TerminalType(&TCB->term));
+#if NCURSES_EXT_NUMBERS
+	_nc_export_termtype2(&TCB->term.type, &TerminalType(&TCB->term));
+#endif
+    }
+
+    if (!code) {
+	if (_nc_console_test(0)) {
+	    T(("isTermInfoConsole=TRUE"));
+	    WINCONSOLE.isTermInfoConsole = TRUE;
+	}
+    }
+    returnBool(code);
+}
+
+static int
+wcon_dobeepflash(TERMINAL_CONTROL_BLOCK * TCB,
+		 int beepFlag)
+{
+    SCREEN *sp;
+    int res = ERR;
+
+    int high = (WINCONSOLE.SBI.srWindow.Bottom -
+		WINCONSOLE.SBI.srWindow.Top + 1);
+    int wide = (WINCONSOLE.SBI.srWindow.Right -
+		WINCONSOLE.SBI.srWindow.Left + 1);
+    int max_cells = (high * wide);
+    int i;
+
+    CHAR_INFO *this_screen = TypeAlloca(CHAR_INFO, max_cells);
+    CHAR_INFO *that_screen = TypeAlloca(CHAR_INFO, max_cells);
+    COORD this_size;
+    SMALL_RECT this_region;
+    COORD bufferCoord;
+
+    if (validateConsoleHandle()) {
+	SetSP();
+	this_region.Top = WINCONSOLE.SBI.srWindow.Top;
+	this_region.Left = WINCONSOLE.SBI.srWindow.Left;
+	this_region.Bottom = WINCONSOLE.SBI.srWindow.Bottom;
+	this_region.Right = WINCONSOLE.SBI.srWindow.Right;
+
+	this_size.X = (SHORT) wide;
+	this_size.Y = (SHORT) high;
+
+	bufferCoord.X = this_region.Left;
+	bufferCoord.Y = this_region.Top;
+
+	if (!beepFlag &&
+	    read_screen(WINCONSOLE.hdl,
+			this_screen,
+			this_size,
+			bufferCoord,
+			&this_region)) {
+
+	    memcpy(that_screen,
+		   this_screen,
+		   sizeof(CHAR_INFO) * (size_t) max_cells);
+
+	    for (i = 0; i < max_cells; i++) {
+		that_screen[i].Attributes =
+		    RevAttr(that_screen[i].Attributes);
+	    }
+
+	    write_screen(WINCONSOLE.hdl, that_screen, this_size,
+			 bufferCoord, &this_region);
+	    Sleep(200);
+	    write_screen(WINCONSOLE.hdl, this_screen, this_size,
+			 bufferCoord, &this_region);
+
+	} else {
+	    MessageBeep(MB_ICONWARNING);	/* MB_OK might be better */
+	}
+	res = OK;
+    }
+    return res;
+}
+
+static int
+wcon_print(TERMINAL_CONTROL_BLOCK * TCB,
+	   char *data GCC_UNUSED,
+	   int len GCC_UNUSED)
+{
+    SCREEN *sp;
+
+    AssertTCB();
+    SetSP();
+
+    return ERR;
+}
+
+static int
+wcon_defaultcolors(TERMINAL_CONTROL_BLOCK * TCB,
+		   int fg GCC_UNUSED,
+		   int bg GCC_UNUSED)
+{
+    SCREEN *sp;
+    int code = ERR;
+
+    AssertTCB();
+    SetSP();
+
+    return (code);
+}
+
+static void
+wcon_setcolor(TERMINAL_CONTROL_BLOCK * TCB,
+	      int fore,
+	      int color,
+	      int (*outc) (SCREEN *, int) GCC_UNUSED)
+{
+    (void) TCB;
+    if (validateConsoleHandle()) {
+	WORD a = _nc_console_MapColor(fore, color);
+	a |= (WORD) ((WINCONSOLE.SBI.wAttributes) & (fore ? 0xfff8 : 0xff8f));
+	SetConsoleTextAttribute(WINCONSOLE.hdl, a);
+	_nc_console_get_SBI();
+    }
+}
+
+static bool
+wcon_rescol(TERMINAL_CONTROL_BLOCK * TCB)
+{
+    bool res = FALSE;
+
+    (void) TCB;
+    if (validateConsoleHandle()) {
+	WORD a = FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN;
+	SetConsoleTextAttribute(WINCONSOLE.hdl, a);
+	_nc_console_get_SBI();
+	res = TRUE;
+    }
+    return res;
+}
+
+static bool
+wcon_rescolors(TERMINAL_CONTROL_BLOCK * TCB)
+{
+    int result = FALSE;
+    SCREEN *sp;
+
+    AssertTCB();
+    SetSP();
+
+    return result;
+}
+
+static int
+wcon_size(TERMINAL_CONTROL_BLOCK * TCB, int *Lines, int *Cols)
+{
+    int result = ERR;
+
+    T((T_CALLED("win32con::wcon_size(%p)"), TCB));
+
+    if (validateConsoleHandle() &&
+	(Lines != NULL) && (Cols != NULL)) {
+	_nc_console_size(Lines, Cols);
+	result = OK;
+    }
+    returnCode(result);
+}
+
+static int
+wcon_setsize(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED,
+	     int l GCC_UNUSED,
+	     int c GCC_UNUSED)
+{
+    AssertTCB();
+    return ERR;
+}
+
+static int
+wcon_sgmode(TERMINAL_CONTROL_BLOCK * TCB, int setFlag, TTY * buf)
+{
+    int result = ERR;
+
+    T((T_CALLED("win32con::wcon_sgmode(TCB=(%p),setFlag=%d,TTY=(%p)"),
+       TCB, setFlag, buf));
+    if (buf != NULL && validateConsoleHandle()) {
+
+	if (setFlag) {
+	    _nc_console_setmode(WINCONSOLE.hdl, buf);
+	    TCB->term.Nttyb = *buf;
+	} else {
+	    _nc_console_getmode(WINCONSOLE.hdl, &(TCB->term.Nttyb));
+	    *buf = TCB->term.Nttyb;
+	}
+	result = OK;
+    }
+    returnCode(result);
+}
+
+#define MIN_WIDE 80
+#define MIN_HIGH 24
+
+static int
+wcon_mode(TERMINAL_CONTROL_BLOCK * TCB, int progFlag, int defFlag)
+{
+    SCREEN *sp;
+    TERMINAL *_term = (TERMINAL *) TCB;
+    int code = ERR;
+
+    if (validateConsoleHandle()) {
+	sp = TCB->csp;
+
+	T((T_CALLED("win32con::wcon_mode(%p, progFlag=%d, defFlag=%d)"),
+	   TCB, progFlag, defFlag));
+
+	WINCONSOLE.progMode = progFlag;
+	WINCONSOLE.lastOut = progFlag ? WINCONSOLE.hdl : WINCONSOLE.out;
+	SetConsoleActiveScreenBuffer(WINCONSOLE.lastOut);
+
+	if (progFlag) /* prog mode */  {
+	    if (defFlag) {
+		if ((wcon_sgmode(TCB, FALSE, &(_term->Nttyb)) == OK)) {
+		    code = OK;
+		}
+	    } else {
+		/* reset_prog_mode */
+		if (wcon_sgmode(TCB, TRUE, &(_term->Nttyb)) == OK) {
+		    if (sp) {
+			if (sp->_keypad_on)
+			    _nc_keypad(sp, TRUE);
+		    }
+		    if (!WINCONSOLE.buffered) {
+			_nc_console_set_scrollback(FALSE, &WINCONSOLE.SBI);
+		    }
+		    code = OK;
+		}
+	    }
+	    T(("... buffered:%d, clear:%d",
+	       WINCONSOLE.buffered, CurScreen(sp)->_clear));
+	} else {		/* shell mode */
+	    if (defFlag) {
+		/* def_shell_mode */
+		if (wcon_sgmode(TCB, FALSE, &(_term->Ottyb)) == OK) {
+		    code = OK;
+		}
+	    } else {
+		/* reset_shell_mode */
+		if (sp) {
+		    _nc_keypad(sp, FALSE);
+		    NCURSES_SP_NAME(_nc_flush) (sp);
+		}
+		code = wcon_sgmode(TCB, TRUE, &(_term->Ottyb));
+		if (!WINCONSOLE.buffered) {
+		    _nc_console_set_scrollback(TRUE, &WINCONSOLE.save_SBI);
+		    if (!restore_original_screen())
+			code = ERR;
+		}
+		SetConsoleCursorInfo(WINCONSOLE.hdl, &WINCONSOLE.save_CI);
+	    }
+	}
+
+    }
+    returnCode(code);
+}
+
+static void
+wcon_screen_init(SCREEN *sp GCC_UNUSED)
+{
+}
+
+static void
+wcon_wrap(SCREEN *sp GCC_UNUSED)
+{
+}
+
+static void
+wcon_release(TERMINAL_CONTROL_BLOCK * TCB)
+{
+    T((T_CALLED("win32con::wcon_release(%p)"), TCB));
+
+    AssertTCB();
+    if (TCB->prop)
+	free(TCB->prop);
+
+    returnVoid;
+}
+
+static void
+wcon_init(TERMINAL_CONTROL_BLOCK * TCB)
+{
+    T((T_CALLED("win32con::wcon_init(%p)"), TCB));
+
+    AssertTCB();
+
+    if (!(console_initialized = _nc_console_checkinit(TRUE, FALSE))) {
+	returnVoid;
+    }
+
+    if (TCB) {
+	TCB->info.initcolor = TRUE;
+	TCB->info.canchange = FALSE;
+	TCB->info.hascolor = TRUE;
+	TCB->info.caninit = TRUE;
+
+	TCB->info.maxpairs = CON_NUMPAIRS;
+	TCB->info.maxcolors = 8;
+	TCB->info.numlabels = 0;
+	TCB->info.labelwidth = 0;
+	TCB->info.labelheight = 0;
+	TCB->info.nocolorvideo = 1;
+	TCB->info.tabsize = 8;
+
+	TCB->info.numbuttons = WINCONSOLE.numButtons;
+	TCB->info.defaultPalette = _nc_cga_palette;
+
+    }
+    returnVoid;
+}
+
+static void
+wcon_initpair(TERMINAL_CONTROL_BLOCK * TCB,
+	      int pair,
+	      int f,
+	      int b)
+{
+    SCREEN *sp;
+
+    if (validateConsoleHandle()) {
+	SetSP();
+
+	if ((pair > 0) && (pair < CON_NUMPAIRS) && (f >= 0) && (f < 8)
+	    && (b >= 0) && (b < 8)) {
+	    WINCONSOLE.pairs[pair] =
+		_nc_console_MapColor(true, f) |
+		_nc_console_MapColor(false, b);
+	}
+    }
+}
+
+static void
+wcon_initcolor(TERMINAL_CONTROL_BLOCK * TCB,
+	       int color GCC_UNUSED,
+	       int r GCC_UNUSED,
+	       int g GCC_UNUSED,
+	       int b GCC_UNUSED)
+{
+    SCREEN *sp;
+
+    AssertTCB();
+    SetSP();
+}
+
+static void
+wcon_do_color(TERMINAL_CONTROL_BLOCK * TCB,
+	      int old_pair GCC_UNUSED,
+	      int pair GCC_UNUSED,
+	      int reverse GCC_UNUSED,
+	      int (*outc) (SCREEN *, int) GCC_UNUSED
+)
+{
+    SCREEN *sp;
+
+    AssertTCB();
+    SetSP();
+}
+
+static void
+wcon_initmouse(TERMINAL_CONTROL_BLOCK * TCB)
+{
+    SCREEN *sp;
+
+    T((T_CALLED("win32con::wcon_initmouse(%p)"), TCB));
+
+    if (validateConsoleHandle()) {
+	SetSP();
+
+	sp->_mouse_type = M_TERM_DRIVER;
+    }
+    returnVoid;
+}
+
+static int
+wcon_testmouse(TERMINAL_CONTROL_BLOCK * TCB,
+	       int delay
+	       EVENTLIST_2nd(_nc_eventlist * evl))
+{
+    int rc = 0;
+    SCREEN *sp;
+
+    T((T_CALLED("win32con::wcon_testmouse(%p)"), TCB));
+    if (validateConsoleHandle()) {
+	SetSP();
+
+	if (sp->_drv_mouse_head < sp->_drv_mouse_tail) {
+	    rc = TW_MOUSE;
+	} else {
+	    rc = TCBOf(sp)->drv->td_twait(TCBOf(sp),
+					  TWAIT_MASK,
+					  delay,
+					  (int *) 0
+					  EVENTLIST_2nd(evl));
+	}
+    }
+
+    returnCode(rc);
+}
+
+static int
+wcon_mvcur(TERMINAL_CONTROL_BLOCK * TCB,
+	   int yold GCC_UNUSED, int xold GCC_UNUSED,
+	   int y, int x)
+{
+    int ret = ERR;
+
+    (void) TCB;
+    if (validateConsoleHandle()) {
+	COORD loc;
+	loc.X = (short) x;
+	loc.Y = (short) (y + AdjustY());
+	SetConsoleCursorPosition(WINCONSOLE.hdl, loc);
+	ret = OK;
+    }
+    return ret;
+}
+
+static void
+wcon_hwlabel(TERMINAL_CONTROL_BLOCK * TCB,
+	     int labnum GCC_UNUSED,
+	     char *text GCC_UNUSED)
+{
+    SCREEN *sp;
+
+    AssertTCB();
+    SetSP();
+}
+
+static void
+wcon_hwlabelOnOff(TERMINAL_CONTROL_BLOCK * TCB,
+		  int OnFlag GCC_UNUSED)
+{
+    SCREEN *sp;
+
+    AssertTCB();
+    SetSP();
+}
+
+static chtype
+wcon_conattr(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED)
+{
+    chtype res = A_NORMAL;
+    res |= (A_BOLD | A_DIM | A_REVERSE | A_STANDOUT | A_COLOR);
+    return res;
+}
+
+static void
+wcon_setfilter(TERMINAL_CONTROL_BLOCK * TCB)
+{
+    SCREEN *sp;
+
+    AssertTCB();
+    SetSP();
+}
+
+static void
+wcon_initacs(TERMINAL_CONTROL_BLOCK * TCB,
+	     chtype *real_map GCC_UNUSED,
+	     chtype *fake_map GCC_UNUSED)
+{
+#define DATA(a,b) { a, b }
+    static struct {
+	int acs_code;
+	int use_code;
+    } table[] = {
+	DATA('a', 0xb1),	/* ACS_CKBOARD  */
+	    DATA('f', 0xf8),	/* ACS_DEGREE   */
+	    DATA('g', 0xf1),	/* ACS_PLMINUS  */
+	    DATA('j', 0xd9),	/* ACS_LRCORNER */
+	    DATA('l', 0xda),	/* ACS_ULCORNER */
+	    DATA('k', 0xbf),	/* ACS_URCORNER */
+	    DATA('m', 0xc0),	/* ACS_LLCORNER */
+	    DATA('n', 0xc5),	/* ACS_PLUS     */
+	    DATA('q', 0xc4),	/* ACS_HLINE    */
+	    DATA('t', 0xc3),	/* ACS_LTEE     */
+	    DATA('u', 0xb4),	/* ACS_RTEE     */
+	    DATA('v', 0xc1),	/* ACS_BTEE     */
+	    DATA('w', 0xc2),	/* ACS_TTEE     */
+	    DATA('x', 0xb3),	/* ACS_VLINE    */
+	    DATA('y', 0xf3),	/* ACS_LEQUAL   */
+	    DATA('z', 0xf2),	/* ACS_GEQUAL   */
+	    DATA('0', 0xdb),	/* ACS_BLOCK    */
+	    DATA('{', 0xe3),	/* ACS_PI       */
+	    DATA('}', 0x9c),	/* ACS_STERLING */
+	    DATA(',', 0xae),	/* ACS_LARROW   */
+	    DATA('+', 0xaf),	/* ACS_RARROW   */
+	    DATA('~', 0xf9),	/* ACS_BULLET   */
+    };
+#undef DATA
+    unsigned n;
+
+    SCREEN *sp;
+    if (validateConsoleHandle()) {
+	SetSP();
+
+	for (n = 0; n < SIZEOF(table); ++n) {
+	    real_map[table[n].acs_code] =
+		(chtype) table[n].use_code | A_ALTCHARSET;
+	    if (sp != 0)
+		sp->_screen_acs_map[table[n].acs_code] = TRUE;
+	}
+    }
+}
+
+static int
+wcon_twait(TERMINAL_CONTROL_BLOCK * TCB,
+	   int mode,
+	   int milliseconds,
+	   int *timeleft
+	   EVENTLIST_2nd(_nc_eventlist * evl))
+{
+    SCREEN *sp;
+    int code = 0;
+
+    if (validateConsoleHandle()) {
+	SetSP();
+
+	code = _nc_console_twait(sp,
+				 WINCONSOLE.inp,
+				 mode,
+				 milliseconds,
+				 timeleft EVENTLIST_2nd(evl));
+    }
+    return code;
+}
+
+static int
+wcon_read(TERMINAL_CONTROL_BLOCK * TCB, int *buf)
+{
+    SCREEN *sp;
+    int n = -1;
+
+    T((T_CALLED("win32con::wcon_read(%p)"), TCB));
+
+    assert(buf);
+    if (validateConsoleHandle()) {
+	SetSP();
+
+	n = _nc_console_read(sp, WINCONSOLE.inp, buf);
+    }
+    returnCode(n);
+}
+
+static int
+wcon_nap(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED, int ms)
+{
+    T((T_CALLED("win32con::wcon_nap(%p, %d)"), TCB, ms));
+    Sleep((DWORD) ms);
+    returnCode(OK);
+}
+
+static int
+wcon_cursorSet(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED, int mode)
+{
+    int res = -1;
+
+    T((T_CALLED("win32con:wcon_cursorSet(%d)"), mode));
+    if (validateConsoleHandle()) {
+	CONSOLE_CURSOR_INFO this_CI = WINCONSOLE.save_CI;
+	switch (mode) {
+	case 0:
+	    this_CI.bVisible = FALSE;
+	    break;
+	case 1:
+	    break;
+	case 2:
+	    this_CI.dwSize = 100;
+	    break;
+	}
+	SetConsoleCursorInfo(WINCONSOLE.hdl, &this_CI);
+    }
+    returnCode(res);
+}
+
+static bool
+wcon_kyExist(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED, int keycode)
+{
+    bool found = FALSE;
+
+    T((T_CALLED("win32con::wcon_kyExist(%d)"), keycode));
+    found = _nc_console_keyExist(keycode);
+    returnBool(found);
+}
+
+static int
+wcon_kpad(TERMINAL_CONTROL_BLOCK * TCB, int flag GCC_UNUSED)
+{
+    SCREEN *sp;
+    int code = ERR;
+
+    T((T_CALLED("win32con::wcon_kpad(%p, %d)"), TCB, flag));
+
+    if (validateConsoleHandle()) {
+	SetSP();
+
+	if (sp) {
+	    code = OK;
+	}
+    }
+    returnCode(code);
+}
+
+static int
+wcon_keyok(TERMINAL_CONTROL_BLOCK * TCB,
+	   int keycode,
+	   int flag)
+{
+    int code = ERR;
+    SCREEN *sp;
+
+    T((T_CALLED("win32con::wcon_keyok(%p, %d, %d)"), TCB, keycode, flag));
+
+    if (validateConsoleHandle()) {
+	SetSP();
+	if (sp) {
+	    code = _nc_console_keyok(keycode, flag);
+	}
+    }
+    returnCode(code);
+}
+
+NCURSES_EXPORT_VAR (TERM_DRIVER) _nc_WIN_DRIVER = {
+    FALSE,
+	wcon_name,		/* Name          */
+	wcon_CanHandle,		/* CanHandle     */
+	wcon_init,		/* init          */
+	wcon_release,		/* release       */
+	wcon_size,		/* size          */
+	wcon_sgmode,		/* sgmode        */
+	wcon_conattr,		/* conattr       */
+	wcon_mvcur,		/* hwcur         */
+	wcon_mode,		/* mode          */
+	wcon_rescol,		/* rescol        */
+	wcon_rescolors,		/* rescolors     */
+	wcon_setcolor,		/* color         */
+	wcon_dobeepflash,	/* DoBeepFlash   */
+	wcon_initpair,		/* initpair      */
+	wcon_initcolor,		/* initcolor     */
+	wcon_do_color,		/* docolor       */
+	wcon_initmouse,		/* initmouse     */
+	wcon_testmouse,		/* testmouse     */
+	wcon_setfilter,		/* setfilter     */
+	wcon_hwlabel,		/* hwlabel       */
+	wcon_hwlabelOnOff,	/* hwlabelOnOff  */
+	wcon_doupdate,		/* update        */
+	wcon_defaultcolors,	/* defaultcolors */
+	wcon_print,		/* print         */
+	wcon_size,		/* getsize       */
+	wcon_setsize,		/* setsize       */
+	wcon_initacs,		/* initacs       */
+	wcon_screen_init,	/* scinit        */
+	wcon_wrap,		/* scexit        */
+	wcon_twait,		/* twait         */
+	wcon_read,		/* read          */
+	wcon_nap,		/* nap           */
+	wcon_kpad,		/* kpad          */
+	wcon_keyok,		/* kyOk          */
+	wcon_kyExist,		/* kyExist       */
+	wcon_cursorSet		/* cursorSet     */
+};
+
+#endif /* _NC_WINDOWS */
diff --git a/ncurses/win32con/win_driver.c b/ncurses/win32con/win_driver.c
index 78ccfed..2425b3a 100644
--- a/ncurses/win32con/win_driver.c
+++ b/ncurses/win32con/win_driver.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2021,2023 Thomas E. Dickey                                *
+ * Copyright 2008-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +41,7 @@
 
 #include <curses.priv.h>
 
-#ifdef __MINGW32__
+#ifdef _WIN32
 #include <tchar.h>
 #else
 #include <windows.h>
@@ -52,13 +53,13 @@
 #define PSAPI_VERSION 2
 #include <psapi.h>
 
-#define CUR my_term.type.
+#define CUR TerminalType(my_term).
 
-MODULE_ID("$Id: win_driver.c,v 1.55 2015/02/28 21:30:23 tom Exp $")
+#define CONTROL_PRESSED (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)
 
-#ifndef __GNUC__
-#  error We need GCC to compile for MinGW
-#endif
+MODULE_ID("$Id: win_driver.c,v 1.74 2023/09/16 16:27:44 tom Exp $")
+
+#define TypeAlloca(type,count) (type*) _alloca(sizeof(type) * (size_t) (count))
 
 #define WINMAGIC NCDRV_MAGIC(NCDRV_WINCONSOLE)
 
@@ -83,39 +84,40 @@
 #define write_screen WriteConsoleOutput
 #define read_screen  ReadConsoleOutput
 #endif
-
+/* *INDENT-OFF* */
 static const LONG keylist[] =
 {
-    GenMap(VK_PRIOR, KEY_PPAGE),
-    GenMap(VK_NEXT, KEY_NPAGE),
-    GenMap(VK_END, KEY_END),
-    GenMap(VK_HOME, KEY_HOME),
-    GenMap(VK_LEFT, KEY_LEFT),
-    GenMap(VK_UP, KEY_UP),
-    GenMap(VK_RIGHT, KEY_RIGHT),
-    GenMap(VK_DOWN, KEY_DOWN),
+    GenMap(VK_PRIOR,  KEY_PPAGE),
+    GenMap(VK_NEXT,   KEY_NPAGE),
+    GenMap(VK_END,    KEY_END),
+    GenMap(VK_HOME,   KEY_HOME),
+    GenMap(VK_LEFT,   KEY_LEFT),
+    GenMap(VK_UP,     KEY_UP),
+    GenMap(VK_RIGHT,  KEY_RIGHT),
+    GenMap(VK_DOWN,   KEY_DOWN),
     GenMap(VK_DELETE, KEY_DC),
     GenMap(VK_INSERT, KEY_IC)
 };
 static const LONG ansi_keys[] =
 {
-    GenMap(VK_PRIOR, 'I'),
-    GenMap(VK_NEXT, 'Q'),
-    GenMap(VK_END, 'O'),
-    GenMap(VK_HOME, 'H'),
-    GenMap(VK_LEFT, 'K'),
-    GenMap(VK_UP, 'H'),
-    GenMap(VK_RIGHT, 'M'),
-    GenMap(VK_DOWN, 'P'),
+    GenMap(VK_PRIOR,  'I'),
+    GenMap(VK_NEXT,   'Q'),
+    GenMap(VK_END,    'O'),
+    GenMap(VK_HOME,   'H'),
+    GenMap(VK_LEFT,   'K'),
+    GenMap(VK_UP,     'H'),
+    GenMap(VK_RIGHT,  'M'),
+    GenMap(VK_DOWN,   'P'),
     GenMap(VK_DELETE, 'S'),
     GenMap(VK_INSERT, 'R')
 };
+/* *INDENT-ON* */
 #define N_INI ((int)array_length(keylist))
 #define FKEYS 24
 #define MAPSIZE (FKEYS + N_INI)
 #define NUMPAIRS 64
 
-/*   A process can only have a single console, so it's safe
+/*   A process can only have a single console, so it is safe
      to maintain all the information about it in a single
      static structure.
  */
@@ -124,7 +126,6 @@
     BOOL buffered;
     BOOL window_only;
     BOOL progMode;
-    BOOL isMinTTY;
     BOOL isTermInfoConsole;
     HANDLE out;
     HANDLE inp;
@@ -261,7 +262,7 @@
 con_write16(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, cchar_t *str, int limit)
 {
     int actual = 0;
-    CHAR_INFO ci[limit];
+    CHAR_INFO *ci = TypeAlloca(CHAR_INFO, limit);
     COORD loc, siz;
     SMALL_RECT rec;
     int i;
@@ -310,7 +311,7 @@
 static BOOL
 con_write8(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, chtype *str, int n)
 {
-    CHAR_INFO ci[n];
+    CHAR_INFO *ci = TypeAlloca(CHAR_INFO, n);
     COORD loc, siz;
     SMALL_RECT rec;
     int i;
@@ -487,14 +488,14 @@
 
 	Width = screen_columns(sp);
 	Height = screen_lines(sp);
-	nonempty = min(Height, NewScreen(sp)->_maxy + 1);
+	nonempty = Min(Height, NewScreen(sp)->_maxy + 1);
 
 	T(("... %dx%d clear cur:%d new:%d",
 	   Height, Width,
 	   CurScreen(sp)->_clear,
 	   NewScreen(sp)->_clear));
 
-	if (SP_PARM->_endwin) {
+	if (SP_PARM->_endwin == ewSuspend) {
 
 	    T(("coming back from shell mode"));
 	    NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_ARG);
@@ -503,13 +504,13 @@
 	    NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_ARG);
 	    SP_PARM->_mouse_resume(SP_PARM);
 
-	    SP_PARM->_endwin = FALSE;
+	    SP_PARM->_endwin = ewRunning;
 	}
 
 	if ((CurScreen(sp)->_clear || NewScreen(sp)->_clear)) {
 	    int x;
 #if USE_WIDEC_SUPPORT
-	    cchar_t empty[Width];
+	    cchar_t *empty = TypeAlloca(cchar_t, Width);
 	    wchar_t blank[2] =
 	    {
 		L' ', L'\0'
@@ -518,7 +519,7 @@
 	    for (x = 0; x < Width; x++)
 		setcchar(&empty[x], blank, 0, 0, 0);
 #else
-	    chtype empty[Width];
+	    chtype *empty = TypeAlloca(chtype, Width);
 
 	    for (x = 0; x < Width; x++)
 		empty[x] = ' ';
@@ -611,6 +612,12 @@
     returnCode(result);
 }
 
+#ifdef __MING32__
+#define SysISATTY(fd) _isatty(fd)
+#else
+#define SysISATTY(fd) isatty(fd)
+#endif
+
 static bool
 wcon_CanHandle(TERMINAL_CONTROL_BLOCK * TCB,
 	       const char *tname,
@@ -642,14 +649,19 @@
 	}
     } else if (tname != 0 && stricmp(tname, "unknown") == 0) {
 	code = TRUE;
+    } else if (SysISATTY(TCB->term.Filedes)) {
+	code = TRUE;
     }
 
     /*
      * This is intentional, to avoid unnecessary breakage of applications
      * using <term.h> symbols.
      */
-    if (code && (TCB->term.type.Booleans == 0)) {
-	_nc_init_termtype(&(TCB->term.type));
+    if (code && (TerminalType(&TCB->term).Booleans == 0)) {
+	_nc_init_termtype(&TerminalType(&TCB->term));
+#if NCURSES_EXT_NUMBERS
+	_nc_export_termtype2(&TCB->term.type, &TerminalType(&TCB->term));
+#endif
     }
 
     if (!code) {
@@ -671,8 +683,8 @@
     int max_cells = (high * wide);
     int i;
 
-    CHAR_INFO this_screen[max_cells];
-    CHAR_INFO that_screen[max_cells];
+    CHAR_INFO *this_screen = TypeAlloca(CHAR_INFO, max_cells);
+    CHAR_INFO *that_screen = TypeAlloca(CHAR_INFO, max_cells);
     COORD this_size;
     SMALL_RECT this_region;
     COORD bufferCoord;
@@ -697,7 +709,9 @@
 			bufferCoord,
 			&this_region)) {
 
-	    memcpy(that_screen, this_screen, sizeof(that_screen));
+	    memcpy(that_screen,
+		   this_screen,
+		   sizeof(CHAR_INFO) * (size_t) max_cells);
 
 	    for (i = 0; i < max_cells; i++) {
 		that_screen[i].Attributes = RevAttr(that_screen[i].Attributes);
@@ -1313,7 +1327,9 @@
 }
 
 static int
-wcon_testmouse(TERMINAL_CONTROL_BLOCK * TCB, int delay)
+wcon_testmouse(TERMINAL_CONTROL_BLOCK * TCB,
+	       int delay
+	       EVENTLIST_2nd(_nc_eventlist * evl))
 {
     int rc = 0;
     SCREEN *sp;
@@ -1470,10 +1486,10 @@
 		     FROM_LEFT_4TH_BUTTON_PRESSED | \
 		     RIGHTMOST_BUTTON_PRESSED)
 
-static int
+static mmask_t
 decode_mouse(SCREEN *sp, int mask)
 {
-    int result = 0;
+    mmask_t result = 0;
 
     (void) sp;
     assert(sp && console_initialized);
@@ -1525,6 +1541,10 @@
     int diff;
     bool isImmed = (milliseconds == 0);
 
+#ifdef NCURSES_WGETCH_EVENTS
+    (void) evl;			/* TODO: implement wgetch-events */
+#endif
+
 #define CONSUME() ReadConsoleInput(fd,&inp_rec,1,&nRead)
 
     assert(sp);
@@ -1632,7 +1652,7 @@
 			     CON.inp,
 			     mode,
 			     milliseconds,
-			     timeleft EVENTLIST_2nd(_nc_eventlist * evl));
+			     timeleft EVENTLIST_2nd(evl));
     }
     return code;
 }
@@ -1658,14 +1678,14 @@
 
 	if (sp->_drv_mouse_new_buttons) {
 
-	    work.bstate |= (mmask_t) decode_mouse(sp, sp->_drv_mouse_new_buttons);
+	    work.bstate |= decode_mouse(sp, sp->_drv_mouse_new_buttons);
 
 	} else {
 
 	    /* cf: BUTTON_PRESSED, BUTTON_RELEASED */
-	    work.bstate |= (mmask_t) (decode_mouse(sp,
-						   sp->_drv_mouse_old_buttons)
-				      >> 1);
+	    work.bstate |= (decode_mouse(sp,
+					 sp->_drv_mouse_old_buttons)
+			    >> 1);
 
 	    result = TRUE;
 	}
@@ -1857,7 +1877,7 @@
 #if WINVER >= 0x0600
 /*   This function tests, whether or not the ncurses application
      is running as a descendant of MSYS2/cygwin mintty terminal
-     application. mintty doesn't use Windows Console for it's screen
+     application. mintty doesn't use Windows Console for its screen
      I/O, so the native Windows _isatty doesn't recognize it as
      character device. But we can discover we are at the end of an
      Pipe and can query to server side of the pipe, looking whether
@@ -1947,11 +1967,6 @@
 {
     int result = 0;
 
-#ifdef __MING32__
-#define SysISATTY(fd) _isatty(fd)
-#else
-#define SysISATTY(fd) isatty(fd)
-#endif
     if (SysISATTY(fd)) {
 	result = 1;
     } else {
@@ -1964,7 +1979,7 @@
 
 /*   This is used when running in terminfo mode to discover,
      whether or not the "terminal" is actually a Windows
-     Console. It's the responsibilty of the console to deal
+     Console. It is the responsibility of the console to deal
      with the terminal escape sequences that are sent by
      terminfo.
  */
@@ -2066,7 +2081,8 @@
 _nc_mingw_testmouse(
 		       SCREEN *sp,
 		       HANDLE fd,
-		       int delay)
+		       int delay
+		       EVENTLIST_2nd(_nc_eventlist * evl))
 {
     int rc = 0;
 
@@ -2108,16 +2124,16 @@
 	if (b && nRead > 0) {
 	    if (rc < 0)
 		rc = 0;
-	    rc += nRead;
+	    rc = rc + (int) nRead;
 	    if (inp_rec.EventType == KEY_EVENT) {
 		if (!inp_rec.Event.KeyEvent.bKeyDown)
 		    continue;
 		*buf = (int) inp_rec.Event.KeyEvent.uChar.AsciiChar;
 		vk = inp_rec.Event.KeyEvent.wVirtualKeyCode;
 		/*
-		 * There are 24 virtual function-keys, and typically
-		 * 12 function-keys on a keyboard.  Use the shift-modifier
-		 * to provide the remaining 12 keys.
+		 * There are 24 virtual function-keys (defined in winuser.h),
+		 * and typically 12 function-keys on a keyboard.  Use the
+		 * shift-modifier to provide the remaining keys.
 		 */
 		if (vk >= VK_F1 && vk <= VK_F12) {
 		    if (inp_rec.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED) {
@@ -2134,6 +2150,11 @@
 			ungetch('\0');
 			*buf = AnsiKey(vk);
 		    }
+		} else if (vk == VK_BACK) {
+		    if (!(inp_rec.Event.KeyEvent.dwControlKeyState
+			  & (SHIFT_PRESSED | CONTROL_PRESSED))) {
+			*buf = KEY_BACKSPACE;
+		    }
 		}
 		break;
 	    } else if (inp_rec.EventType == MOUSE_EVENT) {
@@ -2152,7 +2173,7 @@
 static bool
 InitConsole(void)
 {
-    /* initalize once, or not at all */
+    /* initialize once, or not at all */
     if (!console_initialized) {
 	int i;
 	DWORD num_buttons;
@@ -2161,9 +2182,6 @@
 	BOOL b;
 
 	START_TRACE();
-	if (_nc_mingw_isatty(0)) {
-	    CON.isMinTTY = TRUE;
-	}
 
 	for (i = 0; i < (N_INI + FKEYS); i++) {
 	    if (i < N_INI) {
@@ -2202,14 +2220,14 @@
 	for (i = 0; i < NUMPAIRS; i++)
 	    CON.pairs[i] = a;
 
-	CON.inp = GetStdHandle(STD_INPUT_HANDLE);
-	CON.out = GetStdHandle(STD_OUTPUT_HANDLE);
-
 	b = AllocConsole();
 
 	if (!b)
 	    b = AttachConsole(ATTACH_PARENT_PROCESS);
 
+	CON.inp = GetDirectHandle("CONIN$", FILE_SHARE_READ);
+	CON.out = GetDirectHandle("CONOUT$", FILE_SHARE_WRITE);
+
 	if (getenv("NCGDB") || getenv("NCURSES_CONSOLE2")) {
 	    T(("... will not buffer console"));
 	    buffered = FALSE;
@@ -2217,7 +2235,7 @@
 	} else {
 	    T(("... creating console buffer"));
 	    CON.hdl = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE,
-						0,
+						FILE_SHARE_READ | FILE_SHARE_WRITE,
 						NULL,
 						CONSOLE_TEXTMODE_BUFFER,
 						NULL);