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/test/Makefile b/test/Makefile
deleted file mode 100644
index 980eac8..0000000
--- a/test/Makefile
+++ /dev/null
@@ -1,1308 +0,0 @@
-# $Id: Makefile.in,v 1.115 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 tests.
-
-# turn off _all_ suffix rules; we'll generate our own
-.SUFFIXES:
-
-SHELL		= /bin/sh
-
-
-
-
-destdir		=
-x		= 
-o		= .o
-
-MODEL		= ../objects
-top_srcdir	= ..
-srcdir		= .
-prefix		= /system
-exec_prefix	= ${prefix}
-datarootdir	= ${prefix}/share
-
-bindir		= ${exec_prefix}/bin
-libdir		= ${exec_prefix}/lib
-includedir	= ${prefix}/include
-includesubdir	= /ncurses
-
-BINDIR		= $(DESTDIR)$(bindir)
-LIBDIR		= $(DESTDIR)$(libdir)
-INCLUDEDIR	= $(DESTDIR)$(includedir)$(includesubdir)
-
-PACKAGE		= ncurses
-
-LIBTOOL		= 
-LIBTOOL_OPTS	= 
-LIBTOOL_CLEAN	= 
-LIBTOOL_COMPILE	= 
-LIBTOOL_LINK	= ${CC}
-
-INSTALL		= /usr/bin/install -c
-INSTALL_PROG	= ${INSTALL}
-transform	= s,x,x,
-TRANSFORM	= sed 's/$x$$//'|sed '$(transform)'|sed 's/$$/$x/'
-
-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 
-CPPFLAGS	= -I. -I$(srcdir) -I../test -DHAVE_CONFIG_H -I. -I../include   -D_XOPEN_SOURCE=500 -D_FILE_OFFSET_BITS=64  -DNDEBUG
-
-CCFLAGS		= $(CPPFLAGS) $(CFLAGS)
-
-CFLAGS_LIBTOOL	= $(CCFLAGS)
-CFLAGS_NORMAL	= $(CCFLAGS)
-CFLAGS_DEBUG	= $(CCFLAGS) -g -DTRACE
-CFLAGS_PROFILE	= $(CCFLAGS) -pg
-CFLAGS_SHARED	= $(CCFLAGS) -fPIC
-
-CFLAGS_DEFAULT	= $(CFLAGS_NORMAL)
-
-REL_VERSION	= 6.0
-ABI_VERSION	= 6
-LOCAL_LIBDIR	= /home/shade/dev/cm/13/external/libncurses/lib
-LOCAL_LIBS	= ../lib/libform.a ../lib/libmenu.a ../lib/libpanel.a ../lib/libncurses.a 
-MATH_LIB	= -lm
-TEST_LIBS	= 
-
-LD		= arm-linux-androideabi-ld
-LINK		=  $(LIBTOOL_LINK) $(CFLAGS)
-
-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
-
-LDFLAGS_LIBTOOL	= $(LDFLAGS) $(CFLAGS_LIBTOOL)
-LDFLAGS_NORMAL	= $(LDFLAGS) $(CFLAGS_NORMAL)
-LDFLAGS_DEBUG	= $(LDFLAGS) $(CFLAGS_DEBUG)
-LDFLAGS_PROFILE	= $(LDFLAGS) $(CFLAGS_PROFILE)
-LDFLAGS_SHARED	= $(LDFLAGS) $(CFLAGS_SHARED) 
-
-TEST_ARGS	=  -L../lib -lform -lmenu -lpanel -lncurses  
-
-# use these for linking with all of the libraries
-LIBS_DEFAULT	= $(TEST_ARGS)  $(TEST_LIBS) $(MATH_LIB)
-LDFLAGS_DEFAULT	= $(LDFLAGS_NORMAL) $(LIBS_DEFAULT)
-
-# use these for linking with the (n)curses library and possibly pthreads
-LIBS_THREADS	= `echo "$(TEST_ARGS) " | sed -e 's/-lform.*-lpanel[^ ]*//'` $(TEST_LIBS) $(MATH_LIB) 
-LDFLAGS_THREADS	= $(LDFLAGS_NORMAL) $(LIBS_THREADS)
-
-# use these for linking with the (n)curses library
-LIBS_CURSES	= `echo "$(TEST_ARGS) " | sed -e 's/-lform.*-lpanel[^ ]*//'` $(TEST_LIBS) $(MATH_LIB)
-LDFLAGS_CURSES	= $(LDFLAGS_NORMAL) $(LIBS_CURSES)
-
-# use these for linking with the tinfo library if we have it, or curses library if not
-LIBS_TINFO	=  -lncurses   $(TEST_LIBS) $(MATH_LIB)
-LDFLAGS_TINFO	= -L../lib $(LDFLAGS_NORMAL) $(LIBS_TINFO)
-
-LINT		= lint
-LINT_OPTS	= 
-LINT_LIBS	= -lform -lmenu -lpanel -lncurses 
-
-HEADER_DEPS	= \
-	../include/curses.h \
-	../include/term.h
-
-# The rest is generated from the "programs" and "modules" files...
-# generated by mk-test.awk
-
-TESTS	= $(destdir)background$x \
-	  $(destdir)blue$x \
-	  $(destdir)bs$x \
-	  $(destdir)cardfile$x \
-	  $(destdir)chgat$x \
-	  $(destdir)clip_printw$x \
-	  $(destdir)color_set$x \
-	  $(destdir)demo_altkeys$x \
-	  $(destdir)demo_defkey$x \
-	  $(destdir)demo_forms$x \
-	  $(destdir)demo_keyok$x \
-	  $(destdir)demo_menus$x \
-	  $(destdir)demo_panels$x \
-	  $(destdir)demo_termcap$x \
-	  $(destdir)demo_terminfo$x \
-	  $(destdir)ditto$x \
-	  $(destdir)dots$x \
-	  $(destdir)dots_curses$x \
-	  $(destdir)dots_mvcur$x \
-	  $(destdir)dots_termcap$x \
-	  $(destdir)echochar$x \
-	  $(destdir)filter$x \
-	  $(destdir)firework$x \
-	  $(destdir)firstlast$x \
-	  $(destdir)foldkeys$x \
-	  $(destdir)form_driver_w$x \
-	  $(destdir)gdc$x \
-	  $(destdir)hanoi$x \
-	  $(destdir)hashtest$x \
-	  $(destdir)inch_wide$x \
-	  $(destdir)inchs$x \
-	  $(destdir)ins_wide$x \
-	  $(destdir)insdelln$x \
-	  $(destdir)inserts$x \
-	  $(destdir)key_names$x \
-	  $(destdir)keynames$x \
-	  $(destdir)knight$x \
-	  $(destdir)lrtest$x \
-	  $(destdir)movewindow$x \
-	  $(destdir)ncurses$x \
-	  $(destdir)newdemo$x \
-	  $(destdir)railroad$x \
-	  $(destdir)rain$x \
-	  $(destdir)redraw$x \
-	  $(destdir)savescreen$x \
-	  $(destdir)tclock$x \
-	  $(destdir)test_add_wchstr$x \
-	  $(destdir)test_addchstr$x \
-	  $(destdir)test_addstr$x \
-	  $(destdir)test_addwstr$x \
-	  $(destdir)test_arrays$x \
-	  $(destdir)test_get_wstr$x \
-	  $(destdir)test_getstr$x \
-	  $(destdir)test_instr$x \
-	  $(destdir)test_inwstr$x \
-	  $(destdir)test_opaque$x \
-	  $(destdir)test_setupterm$x \
-	  $(destdir)test_vid_puts$x \
-	  $(destdir)test_vidputs$x \
-	  $(destdir)testaddch$x \
-	  $(destdir)testcurs$x \
-	  $(destdir)testscanw$x \
-	  $(destdir)view$x \
-	  $(destdir)worm$x \
-	  $(destdir)xmas$x
-
-all: $(TESTS)
-
-sources:
-
-tags:
-	$(CTAGS) *.[ch]
-
-# no libraries here
-libs \
-install.libs \
-uninstall.libs:
-
-install \
-install.test \
-uninstall \
-uninstall.test:
-
-mostlyclean ::
-	-rm -f core tags TAGS *~ *.bak *.i *.ln *.atac trace
-
-clean :: mostlyclean
-	-$(SHELL) -c "if test -n '$x' ; then $(MAKE) clean x=''; fi"
-	-rm -rf *$o screendump *.lis $(TESTS) .libs *.dSYM
-
-distclean :: clean
-	-rm -f Makefile ncurses_cfg.h config.status config.log
-
-realclean :: distclean
-
-lint:
-	$(SHELL) -c 'for N in $(TESTS); do echo LINT:$$N; $(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/$$N.c $(LINT_LIBS); done'
-$(BINDIR) :
-	mkdir -p $@
-
-$(destdir)background$x: $(MODEL)/background$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/background$o $(LDFLAGS_CURSES)
-
-$(destdir)blue$x: $(MODEL)/blue$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/blue$o $(LDFLAGS_CURSES)
-
-$(destdir)bs$x: $(MODEL)/bs$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/bs$o $(LDFLAGS_CURSES)
-
-$(destdir)cardfile$x: $(MODEL)/cardfile$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/cardfile$o $(LDFLAGS_DEFAULT)
-
-$(destdir)chgat$x: $(MODEL)/chgat$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/chgat$o $(LDFLAGS_CURSES)
-
-$(destdir)clip_printw$x: $(MODEL)/clip_printw$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/clip_printw$o $(LDFLAGS_CURSES)
-
-$(destdir)color_set$x: $(MODEL)/color_set$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/color_set$o $(LDFLAGS_CURSES)
-
-$(destdir)demo_altkeys$x: $(MODEL)/demo_altkeys$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/demo_altkeys$o $(LDFLAGS_CURSES)
-
-$(destdir)demo_defkey$x: $(MODEL)/demo_defkey$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/demo_defkey$o $(LDFLAGS_CURSES)
-
-$(destdir)demo_forms$x: $(MODEL)/demo_forms$o $(MODEL)/edit_field$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/demo_forms$o $(MODEL)/edit_field$o $(LDFLAGS_DEFAULT)
-
-$(destdir)demo_keyok$x: $(MODEL)/demo_keyok$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/demo_keyok$o $(LDFLAGS_CURSES)
-
-$(destdir)demo_menus$x: $(MODEL)/demo_menus$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/demo_menus$o $(LDFLAGS_DEFAULT)
-
-$(destdir)demo_panels$x: $(MODEL)/demo_panels$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/demo_panels$o $(LDFLAGS_DEFAULT)
-
-$(destdir)demo_termcap$x: $(MODEL)/demo_termcap$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/demo_termcap$o $(LDFLAGS_TINFO)
-
-$(destdir)demo_terminfo$x: $(MODEL)/demo_terminfo$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/demo_terminfo$o $(LDFLAGS_TINFO)
-
-$(destdir)ditto$x: $(MODEL)/ditto$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/ditto$o $(LDFLAGS_THREADS)
-
-$(destdir)dots$x: $(MODEL)/dots$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/dots$o $(LDFLAGS_TINFO)
-
-$(destdir)dots_curses$x: $(MODEL)/dots_curses$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/dots_curses$o $(LDFLAGS_CURSES)
-
-$(destdir)dots_mvcur$x: $(MODEL)/dots_mvcur$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/dots_mvcur$o $(LDFLAGS_CURSES)
-
-$(destdir)dots_termcap$x: $(MODEL)/dots_termcap$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/dots_termcap$o $(LDFLAGS_TINFO)
-
-$(destdir)echochar$x: $(MODEL)/echochar$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/echochar$o $(LDFLAGS_CURSES)
-
-$(destdir)filter$x: $(MODEL)/filter$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/filter$o $(LDFLAGS_CURSES)
-
-$(destdir)firework$x: $(MODEL)/firework$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/firework$o $(LDFLAGS_CURSES)
-
-$(destdir)firstlast$x: $(MODEL)/firstlast$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/firstlast$o $(LDFLAGS_DEFAULT)
-
-$(destdir)foldkeys$x: $(MODEL)/foldkeys$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/foldkeys$o $(LDFLAGS_CURSES)
-
-$(destdir)form_driver_w$x: $(MODEL)/form_driver_w$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/form_driver_w$o $(LDFLAGS_DEFAULT)
-
-$(destdir)gdc$x: $(MODEL)/gdc$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/gdc$o $(LDFLAGS_CURSES)
-
-$(destdir)hanoi$x: $(MODEL)/hanoi$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/hanoi$o $(LDFLAGS_CURSES)
-
-$(destdir)hashtest$x: $(MODEL)/hashtest$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/hashtest$o $(LDFLAGS_CURSES)
-
-$(destdir)inch_wide$x: $(MODEL)/inch_wide$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/inch_wide$o $(LDFLAGS_CURSES)
-
-$(destdir)inchs$x: $(MODEL)/inchs$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/inchs$o $(LDFLAGS_CURSES)
-
-$(destdir)ins_wide$x: $(MODEL)/ins_wide$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/ins_wide$o $(LDFLAGS_CURSES)
-
-$(destdir)insdelln$x: $(MODEL)/insdelln$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/insdelln$o $(LDFLAGS_CURSES)
-
-$(destdir)inserts$x: $(MODEL)/inserts$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/inserts$o $(LDFLAGS_CURSES)
-
-$(destdir)key_names$x: $(MODEL)/key_names$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/key_names$o $(LDFLAGS_CURSES)
-
-$(destdir)keynames$x: $(MODEL)/keynames$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/keynames$o $(LDFLAGS_CURSES)
-
-$(destdir)knight$x: $(MODEL)/knight$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/knight$o $(LDFLAGS_CURSES)
-
-$(destdir)lrtest$x: $(MODEL)/lrtest$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/lrtest$o $(LDFLAGS_CURSES)
-
-$(destdir)movewindow$x: $(MODEL)/movewindow$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/movewindow$o $(LDFLAGS_CURSES)
-
-$(destdir)ncurses$x: $(MODEL)/ncurses$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/ncurses$o $(LDFLAGS_DEFAULT)
-
-$(destdir)newdemo$x: $(MODEL)/newdemo$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/newdemo$o $(LDFLAGS_CURSES)
-
-$(destdir)railroad$x: $(MODEL)/railroad$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/railroad$o $(LDFLAGS_TINFO)
-
-$(destdir)rain$x: $(MODEL)/rain$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/rain$o $(LDFLAGS_THREADS)
-
-$(destdir)redraw$x: $(MODEL)/redraw$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/redraw$o $(LDFLAGS_CURSES)
-
-$(destdir)savescreen$x: $(MODEL)/savescreen$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/savescreen$o $(LDFLAGS_CURSES)
-
-$(destdir)tclock$x: $(MODEL)/tclock$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/tclock$o $(LDFLAGS_CURSES)
-
-$(destdir)test_add_wchstr$x: $(MODEL)/test_add_wchstr$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/test_add_wchstr$o $(LDFLAGS_CURSES)
-
-$(destdir)test_addchstr$x: $(MODEL)/test_addchstr$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/test_addchstr$o $(LDFLAGS_CURSES)
-
-$(destdir)test_addstr$x: $(MODEL)/test_addstr$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/test_addstr$o $(LDFLAGS_CURSES)
-
-$(destdir)test_addwstr$x: $(MODEL)/test_addwstr$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/test_addwstr$o $(LDFLAGS_CURSES)
-
-$(destdir)test_arrays$x: $(MODEL)/test_arrays$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/test_arrays$o $(LDFLAGS_TINFO)
-
-$(destdir)test_get_wstr$x: $(MODEL)/test_get_wstr$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/test_get_wstr$o $(LDFLAGS_CURSES)
-
-$(destdir)test_getstr$x: $(MODEL)/test_getstr$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/test_getstr$o $(LDFLAGS_CURSES)
-
-$(destdir)test_instr$x: $(MODEL)/test_instr$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/test_instr$o $(LDFLAGS_CURSES)
-
-$(destdir)test_inwstr$x: $(MODEL)/test_inwstr$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/test_inwstr$o $(LDFLAGS_CURSES)
-
-$(destdir)test_opaque$x: $(MODEL)/test_opaque$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/test_opaque$o $(LDFLAGS_CURSES)
-
-$(destdir)test_setupterm$x: $(MODEL)/test_setupterm$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/test_setupterm$o $(LDFLAGS_CURSES)
-
-$(destdir)test_vid_puts$x: $(MODEL)/test_vid_puts$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/test_vid_puts$o $(LDFLAGS_CURSES)
-
-$(destdir)test_vidputs$x: $(MODEL)/test_vidputs$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/test_vidputs$o $(LDFLAGS_CURSES)
-
-$(destdir)testaddch$x: $(MODEL)/testaddch$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/testaddch$o $(LDFLAGS_CURSES)
-
-$(destdir)testcurs$x: $(MODEL)/testcurs$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/testcurs$o $(LDFLAGS_CURSES)
-
-$(destdir)testscanw$x: $(MODEL)/testscanw$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/testscanw$o $(LDFLAGS_CURSES)
-
-$(destdir)view$x: $(MODEL)/view$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/view$o $(LDFLAGS_CURSES)
-
-$(destdir)worm$x: $(MODEL)/worm$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/worm$o $(LDFLAGS_THREADS)
-
-$(destdir)xmas$x: $(MODEL)/xmas$o $(LOCAL_LIBS)
-	$(LINK) -o $@ $(MODEL)/xmas$o $(LDFLAGS_CURSES)
-
-# 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:    test
-#   subsets:    ticlib+termlib+ext_tinfo+base+ext_funcs
-
-.SUFFIXES: .c .cc .h .i .ii
-.c.i :
-	$(CPP) $(CPPFLAGS) $< >$@
-.cc.ii :
-	$(CPP) $(CPPFLAGS) $< >$@
-.h.i :
-	$(CPP) $(CPPFLAGS) $< >$@
-
-C_SRC = \
-	$(srcdir)/background.c \
-	$(srcdir)/blue.c \
-	$(srcdir)/bs.c \
-	$(srcdir)/cardfile.c \
-	$(srcdir)/chgat.c \
-	$(srcdir)/clip_printw.c \
-	$(srcdir)/color_set.c \
-	$(srcdir)/demo_altkeys.c \
-	$(srcdir)/demo_defkey.c \
-	$(srcdir)/demo_forms.c \
-	$(srcdir)/demo_keyok.c \
-	$(srcdir)/demo_menus.c \
-	$(srcdir)/demo_panels.c \
-	$(srcdir)/demo_termcap.c \
-	$(srcdir)/demo_terminfo.c \
-	$(srcdir)/ditto.c \
-	$(srcdir)/dots.c \
-	$(srcdir)/dots_curses.c \
-	$(srcdir)/dots_mvcur.c \
-	$(srcdir)/dots_termcap.c \
-	$(srcdir)/echochar.c \
-	$(srcdir)/edit_field.c \
-	$(srcdir)/filter.c \
-	$(srcdir)/firework.c \
-	$(srcdir)/firstlast.c \
-	$(srcdir)/foldkeys.c \
-	$(srcdir)/form_driver_w.c \
-	$(srcdir)/gdc.c \
-	$(srcdir)/hanoi.c \
-	$(srcdir)/hashtest.c \
-	$(srcdir)/inch_wide.c \
-	$(srcdir)/inchs.c \
-	$(srcdir)/ins_wide.c \
-	$(srcdir)/insdelln.c \
-	$(srcdir)/inserts.c \
-	$(srcdir)/key_names.c \
-	$(srcdir)/keynames.c \
-	$(srcdir)/knight.c \
-	$(srcdir)/lrtest.c \
-	$(srcdir)/movewindow.c \
-	$(srcdir)/ncurses.c \
-	$(srcdir)/newdemo.c \
-	$(srcdir)/railroad.c \
-	$(srcdir)/rain.c \
-	$(srcdir)/redraw.c \
-	$(srcdir)/savescreen.c \
-	$(srcdir)/tclock.c \
-	$(srcdir)/test_add_wchstr.c \
-	$(srcdir)/test_addchstr.c \
-	$(srcdir)/test_addstr.c \
-	$(srcdir)/test_addwstr.c \
-	$(srcdir)/test_arrays.c \
-	$(srcdir)/test_get_wstr.c \
-	$(srcdir)/test_getstr.c \
-	$(srcdir)/test_instr.c \
-	$(srcdir)/test_inwstr.c \
-	$(srcdir)/test_opaque.c \
-	$(srcdir)/test_setupterm.c \
-	$(srcdir)/test_vid_puts.c \
-	$(srcdir)/test_vidputs.c \
-	$(srcdir)/testaddch.c \
-	$(srcdir)/testcurs.c \
-	$(srcdir)/testscanw.c \
-	$(srcdir)/view.c \
-	$(srcdir)/worm.c \
-	$(srcdir)/xmas.c
-
-lintlib :
-	@echo no action needed
-
-# generated by mk-1st.awk (subset=ticlib+termlib+ext_tinfo+base+ext_funcs)
-#  name:          test
-#  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 ./test.priv.h
-#  host:          arm-unknown-linux-androideabi
-
-NORMAL_OBJS = \
-	../objects/background$o \
-	../objects/blue$o \
-	../objects/bs$o \
-	../objects/cardfile$o \
-	../objects/chgat$o \
-	../objects/clip_printw$o \
-	../objects/color_set$o \
-	../objects/demo_altkeys$o \
-	../objects/demo_defkey$o \
-	../objects/demo_forms$o \
-	../objects/demo_keyok$o \
-	../objects/demo_menus$o \
-	../objects/demo_panels$o \
-	../objects/demo_termcap$o \
-	../objects/demo_terminfo$o \
-	../objects/ditto$o \
-	../objects/dots$o \
-	../objects/dots_curses$o \
-	../objects/dots_mvcur$o \
-	../objects/dots_termcap$o \
-	../objects/echochar$o \
-	../objects/edit_field$o \
-	../objects/filter$o \
-	../objects/firework$o \
-	../objects/firstlast$o \
-	../objects/foldkeys$o \
-	../objects/form_driver_w$o \
-	../objects/gdc$o \
-	../objects/hanoi$o \
-	../objects/hashtest$o \
-	../objects/inch_wide$o \
-	../objects/inchs$o \
-	../objects/ins_wide$o \
-	../objects/insdelln$o \
-	../objects/inserts$o \
-	../objects/key_names$o \
-	../objects/keynames$o \
-	../objects/knight$o \
-	../objects/lrtest$o \
-	../objects/movewindow$o \
-	../objects/ncurses$o \
-	../objects/newdemo$o \
-	../objects/railroad$o \
-	../objects/rain$o \
-	../objects/redraw$o \
-	../objects/savescreen$o \
-	../objects/tclock$o \
-	../objects/test_add_wchstr$o \
-	../objects/test_addchstr$o \
-	../objects/test_addstr$o \
-	../objects/test_addwstr$o \
-	../objects/test_arrays$o \
-	../objects/test_get_wstr$o \
-	../objects/test_getstr$o \
-	../objects/test_instr$o \
-	../objects/test_inwstr$o \
-	../objects/test_opaque$o \
-	../objects/test_setupterm$o \
-	../objects/test_vid_puts$o \
-	../objects/test_vidputs$o \
-	../objects/testaddch$o \
-	../objects/testcurs$o \
-	../objects/testscanw$o \
-	../objects/view$o \
-	../objects/worm$o \
-	../objects/xmas$o
-
-$(NORMAL_OBJS) : ../include/ncurses_cfg.h ./test.priv.h
-
-mostlyclean::
-	-rm -f $(NORMAL_OBJS)
-
-clean ::
-	-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/background$o :	$(srcdir)/background.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/background.c -o ../objects/background$o
-
-../objects/blue$o :	$(srcdir)/blue.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/blue.c -o ../objects/blue$o
-
-../objects/bs$o :	$(srcdir)/bs.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/bs.c -o ../objects/bs$o
-
-../objects/cardfile$o :	$(srcdir)/cardfile.c \
-			$(HEADER_DEPS) \
-			../include/panel.h \
-			../include/form.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/cardfile.c -o ../objects/cardfile$o
-
-../objects/chgat$o :	$(srcdir)/chgat.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/chgat.c -o ../objects/chgat$o
-
-../objects/clip_printw$o :	$(srcdir)/clip_printw.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/clip_printw.c -o ../objects/clip_printw$o
-
-../objects/color_set$o :	$(srcdir)/color_set.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/color_set.c -o ../objects/color_set$o
-
-../objects/demo_altkeys$o :	$(srcdir)/demo_altkeys.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/demo_altkeys.c -o ../objects/demo_altkeys$o
-
-../objects/demo_defkey$o :	$(srcdir)/demo_defkey.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/demo_defkey.c -o ../objects/demo_defkey$o
-
-../objects/demo_forms$o :	$(srcdir)/demo_forms.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/edit_field.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/demo_forms.c -o ../objects/demo_forms$o
-
-../objects/demo_keyok$o :	$(srcdir)/demo_keyok.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/demo_keyok.c -o ../objects/demo_keyok$o
-
-../objects/demo_menus$o :	$(srcdir)/demo_menus.c \
-			$(HEADER_DEPS) \
-			../include/menu.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/demo_menus.c -o ../objects/demo_menus$o
-
-../objects/demo_panels$o :	$(srcdir)/demo_panels.c \
-			$(HEADER_DEPS) \
-			../include/panel.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/demo_panels.c -o ../objects/demo_panels$o
-
-../objects/demo_termcap$o :	$(srcdir)/demo_termcap.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/demo_termcap.c -o ../objects/demo_termcap$o
-
-../objects/demo_terminfo$o :	$(srcdir)/demo_terminfo.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/demo_terminfo.c -o ../objects/demo_terminfo$o
-
-../objects/ditto$o :	$(srcdir)/ditto.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/ditto.c -o ../objects/ditto$o
-
-../objects/dots$o :	$(srcdir)/dots.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/dots.c -o ../objects/dots$o
-
-../objects/dots_curses$o :	$(srcdir)/dots_curses.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/dots_curses.c -o ../objects/dots_curses$o
-
-../objects/dots_mvcur$o :	$(srcdir)/dots_mvcur.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/dots_mvcur.c -o ../objects/dots_mvcur$o
-
-../objects/dots_termcap$o :	$(srcdir)/dots_termcap.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/dots_termcap.c -o ../objects/dots_termcap$o
-
-../objects/echochar$o :	$(srcdir)/echochar.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/echochar.c -o ../objects/echochar$o
-
-../objects/edit_field$o :	$(srcdir)/edit_field.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/edit_field.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/edit_field.c -o ../objects/edit_field$o
-
-../objects/filter$o :	$(srcdir)/filter.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/filter.c -o ../objects/filter$o
-
-../objects/firework$o :	$(srcdir)/firework.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/firework.c -o ../objects/firework$o
-
-../objects/firstlast$o :	$(srcdir)/firstlast.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/firstlast.c -o ../objects/firstlast$o
-
-../objects/foldkeys$o :	$(srcdir)/foldkeys.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/foldkeys.c -o ../objects/foldkeys$o
-
-../objects/form_driver_w$o :	$(srcdir)/form_driver_w.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/form_driver_w.c -o ../objects/form_driver_w$o
-
-../objects/gdc$o :	$(srcdir)/gdc.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/gdc.c -o ../objects/gdc$o
-
-../objects/hanoi$o :	$(srcdir)/hanoi.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/hanoi.c -o ../objects/hanoi$o
-
-../objects/hashtest$o :	$(srcdir)/hashtest.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/hashtest.c -o ../objects/hashtest$o
-
-../objects/inch_wide$o :	$(srcdir)/inch_wide.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/inch_wide.c -o ../objects/inch_wide$o
-
-../objects/inchs$o :	$(srcdir)/inchs.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/inchs.c -o ../objects/inchs$o
-
-../objects/ins_wide$o :	$(srcdir)/ins_wide.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/linedata.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/ins_wide.c -o ../objects/ins_wide$o
-
-../objects/insdelln$o :	$(srcdir)/insdelln.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/insdelln.c -o ../objects/insdelln$o
-
-../objects/inserts$o :	$(srcdir)/inserts.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/linedata.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/inserts.c -o ../objects/inserts$o
-
-../objects/key_names$o :	$(srcdir)/key_names.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/key_names.c -o ../objects/key_names$o
-
-../objects/keynames$o :	$(srcdir)/keynames.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/keynames.c -o ../objects/keynames$o
-
-../objects/knight$o :	$(srcdir)/knight.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/knight.c -o ../objects/knight$o
-
-../objects/lrtest$o :	$(srcdir)/lrtest.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/lrtest.c -o ../objects/lrtest$o
-
-../objects/movewindow$o :	$(srcdir)/movewindow.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/movewindow.c -o ../objects/movewindow$o
-
-../objects/ncurses$o :	$(srcdir)/ncurses.c \
-			$(HEADER_DEPS) \
-			../include/panel.h \
-			../include/menu.h \
-			../include/form.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/ncurses.c -o ../objects/ncurses$o
-
-../objects/newdemo$o :	$(srcdir)/newdemo.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/newdemo.c -o ../objects/newdemo$o
-
-../objects/railroad$o :	$(srcdir)/railroad.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/railroad.c -o ../objects/railroad$o
-
-../objects/rain$o :	$(srcdir)/rain.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/rain.c -o ../objects/rain$o
-
-../objects/redraw$o :	$(srcdir)/redraw.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/redraw.c -o ../objects/redraw$o
-
-../objects/savescreen$o :	$(srcdir)/savescreen.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/savescreen.c -o ../objects/savescreen$o
-
-../objects/tclock$o :	$(srcdir)/tclock.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/tclock.c -o ../objects/tclock$o
-
-../objects/test_add_wchstr$o :	$(srcdir)/test_add_wchstr.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/linedata.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/test_add_wchstr.c -o ../objects/test_add_wchstr$o
-
-../objects/test_addchstr$o :	$(srcdir)/test_addchstr.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/linedata.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/test_addchstr.c -o ../objects/test_addchstr$o
-
-../objects/test_addstr$o :	$(srcdir)/test_addstr.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/linedata.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/test_addstr.c -o ../objects/test_addstr$o
-
-../objects/test_addwstr$o :	$(srcdir)/test_addwstr.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/linedata.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/test_addwstr.c -o ../objects/test_addwstr$o
-
-../objects/test_arrays$o :	$(srcdir)/test_arrays.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/test_arrays.c -o ../objects/test_arrays$o
-
-../objects/test_get_wstr$o :	$(srcdir)/test_get_wstr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/test_get_wstr.c -o ../objects/test_get_wstr$o
-
-../objects/test_getstr$o :	$(srcdir)/test_getstr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/test_getstr.c -o ../objects/test_getstr$o
-
-../objects/test_instr$o :	$(srcdir)/test_instr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/test_instr.c -o ../objects/test_instr$o
-
-../objects/test_inwstr$o :	$(srcdir)/test_inwstr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/test_inwstr.c -o ../objects/test_inwstr$o
-
-../objects/test_opaque$o :	$(srcdir)/test_opaque.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/test_opaque.c -o ../objects/test_opaque$o
-
-../objects/test_setupterm$o :	$(srcdir)/test_setupterm.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/test_setupterm.c -o ../objects/test_setupterm$o
-
-../objects/test_vid_puts$o :	$(srcdir)/test_vid_puts.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/test_vid_puts.c -o ../objects/test_vid_puts$o
-
-../objects/test_vidputs$o :	$(srcdir)/test_vidputs.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/test_vidputs.c -o ../objects/test_vidputs$o
-
-../objects/testaddch$o :	$(srcdir)/testaddch.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/testaddch.c -o ../objects/testaddch$o
-
-../objects/testcurs$o :	$(srcdir)/testcurs.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/testcurs.c -o ../objects/testcurs$o
-
-../objects/testscanw$o :	$(srcdir)/testscanw.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/testscanw.c -o ../objects/testscanw$o
-
-../objects/view$o :	$(srcdir)/view.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/widechars.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/view.c -o ../objects/view$o
-
-../objects/worm$o :	$(srcdir)/worm.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/worm.c -o ../objects/worm$o
-
-../objects/xmas$o :	$(srcdir)/xmas.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_NORMAL) -c ../test/xmas.c -o ../objects/xmas$o
-
-
-# generated by mk-1st.awk (subset=ticlib+termlib+ext_tinfo+base+ext_funcs)
-#  name:          test
-#  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 ./test.priv.h
-#  host:          arm-unknown-linux-androideabi
-
-DEBUG_OBJS = \
-	../obj_g/background$o \
-	../obj_g/blue$o \
-	../obj_g/bs$o \
-	../obj_g/cardfile$o \
-	../obj_g/chgat$o \
-	../obj_g/clip_printw$o \
-	../obj_g/color_set$o \
-	../obj_g/demo_altkeys$o \
-	../obj_g/demo_defkey$o \
-	../obj_g/demo_forms$o \
-	../obj_g/demo_keyok$o \
-	../obj_g/demo_menus$o \
-	../obj_g/demo_panels$o \
-	../obj_g/demo_termcap$o \
-	../obj_g/demo_terminfo$o \
-	../obj_g/ditto$o \
-	../obj_g/dots$o \
-	../obj_g/dots_curses$o \
-	../obj_g/dots_mvcur$o \
-	../obj_g/dots_termcap$o \
-	../obj_g/echochar$o \
-	../obj_g/edit_field$o \
-	../obj_g/filter$o \
-	../obj_g/firework$o \
-	../obj_g/firstlast$o \
-	../obj_g/foldkeys$o \
-	../obj_g/form_driver_w$o \
-	../obj_g/gdc$o \
-	../obj_g/hanoi$o \
-	../obj_g/hashtest$o \
-	../obj_g/inch_wide$o \
-	../obj_g/inchs$o \
-	../obj_g/ins_wide$o \
-	../obj_g/insdelln$o \
-	../obj_g/inserts$o \
-	../obj_g/key_names$o \
-	../obj_g/keynames$o \
-	../obj_g/knight$o \
-	../obj_g/lrtest$o \
-	../obj_g/movewindow$o \
-	../obj_g/ncurses$o \
-	../obj_g/newdemo$o \
-	../obj_g/railroad$o \
-	../obj_g/rain$o \
-	../obj_g/redraw$o \
-	../obj_g/savescreen$o \
-	../obj_g/tclock$o \
-	../obj_g/test_add_wchstr$o \
-	../obj_g/test_addchstr$o \
-	../obj_g/test_addstr$o \
-	../obj_g/test_addwstr$o \
-	../obj_g/test_arrays$o \
-	../obj_g/test_get_wstr$o \
-	../obj_g/test_getstr$o \
-	../obj_g/test_instr$o \
-	../obj_g/test_inwstr$o \
-	../obj_g/test_opaque$o \
-	../obj_g/test_setupterm$o \
-	../obj_g/test_vid_puts$o \
-	../obj_g/test_vidputs$o \
-	../obj_g/testaddch$o \
-	../obj_g/testcurs$o \
-	../obj_g/testscanw$o \
-	../obj_g/view$o \
-	../obj_g/worm$o \
-	../obj_g/xmas$o
-
-$(DEBUG_OBJS) : ../include/ncurses_cfg.h ./test.priv.h
-
-mostlyclean::
-	-rm -f $(DEBUG_OBJS)
-
-clean ::
-	-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/background$o :	$(srcdir)/background.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/background.c -o ../obj_g/background$o
-
-../obj_g/blue$o :	$(srcdir)/blue.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/blue.c -o ../obj_g/blue$o
-
-../obj_g/bs$o :	$(srcdir)/bs.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/bs.c -o ../obj_g/bs$o
-
-../obj_g/cardfile$o :	$(srcdir)/cardfile.c \
-			$(HEADER_DEPS) \
-			../include/panel.h \
-			../include/form.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/cardfile.c -o ../obj_g/cardfile$o
-
-../obj_g/chgat$o :	$(srcdir)/chgat.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/chgat.c -o ../obj_g/chgat$o
-
-../obj_g/clip_printw$o :	$(srcdir)/clip_printw.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/clip_printw.c -o ../obj_g/clip_printw$o
-
-../obj_g/color_set$o :	$(srcdir)/color_set.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/color_set.c -o ../obj_g/color_set$o
-
-../obj_g/demo_altkeys$o :	$(srcdir)/demo_altkeys.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/demo_altkeys.c -o ../obj_g/demo_altkeys$o
-
-../obj_g/demo_defkey$o :	$(srcdir)/demo_defkey.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/demo_defkey.c -o ../obj_g/demo_defkey$o
-
-../obj_g/demo_forms$o :	$(srcdir)/demo_forms.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/edit_field.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/demo_forms.c -o ../obj_g/demo_forms$o
-
-../obj_g/demo_keyok$o :	$(srcdir)/demo_keyok.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/demo_keyok.c -o ../obj_g/demo_keyok$o
-
-../obj_g/demo_menus$o :	$(srcdir)/demo_menus.c \
-			$(HEADER_DEPS) \
-			../include/menu.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/demo_menus.c -o ../obj_g/demo_menus$o
-
-../obj_g/demo_panels$o :	$(srcdir)/demo_panels.c \
-			$(HEADER_DEPS) \
-			../include/panel.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/demo_panels.c -o ../obj_g/demo_panels$o
-
-../obj_g/demo_termcap$o :	$(srcdir)/demo_termcap.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/demo_termcap.c -o ../obj_g/demo_termcap$o
-
-../obj_g/demo_terminfo$o :	$(srcdir)/demo_terminfo.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/demo_terminfo.c -o ../obj_g/demo_terminfo$o
-
-../obj_g/ditto$o :	$(srcdir)/ditto.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/ditto.c -o ../obj_g/ditto$o
-
-../obj_g/dots$o :	$(srcdir)/dots.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/dots.c -o ../obj_g/dots$o
-
-../obj_g/dots_curses$o :	$(srcdir)/dots_curses.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/dots_curses.c -o ../obj_g/dots_curses$o
-
-../obj_g/dots_mvcur$o :	$(srcdir)/dots_mvcur.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/dots_mvcur.c -o ../obj_g/dots_mvcur$o
-
-../obj_g/dots_termcap$o :	$(srcdir)/dots_termcap.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/dots_termcap.c -o ../obj_g/dots_termcap$o
-
-../obj_g/echochar$o :	$(srcdir)/echochar.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/echochar.c -o ../obj_g/echochar$o
-
-../obj_g/edit_field$o :	$(srcdir)/edit_field.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/edit_field.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/edit_field.c -o ../obj_g/edit_field$o
-
-../obj_g/filter$o :	$(srcdir)/filter.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/filter.c -o ../obj_g/filter$o
-
-../obj_g/firework$o :	$(srcdir)/firework.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/firework.c -o ../obj_g/firework$o
-
-../obj_g/firstlast$o :	$(srcdir)/firstlast.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/firstlast.c -o ../obj_g/firstlast$o
-
-../obj_g/foldkeys$o :	$(srcdir)/foldkeys.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/foldkeys.c -o ../obj_g/foldkeys$o
-
-../obj_g/form_driver_w$o :	$(srcdir)/form_driver_w.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/form_driver_w.c -o ../obj_g/form_driver_w$o
-
-../obj_g/gdc$o :	$(srcdir)/gdc.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/gdc.c -o ../obj_g/gdc$o
-
-../obj_g/hanoi$o :	$(srcdir)/hanoi.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/hanoi.c -o ../obj_g/hanoi$o
-
-../obj_g/hashtest$o :	$(srcdir)/hashtest.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/hashtest.c -o ../obj_g/hashtest$o
-
-../obj_g/inch_wide$o :	$(srcdir)/inch_wide.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/inch_wide.c -o ../obj_g/inch_wide$o
-
-../obj_g/inchs$o :	$(srcdir)/inchs.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/inchs.c -o ../obj_g/inchs$o
-
-../obj_g/ins_wide$o :	$(srcdir)/ins_wide.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/linedata.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/ins_wide.c -o ../obj_g/ins_wide$o
-
-../obj_g/insdelln$o :	$(srcdir)/insdelln.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/insdelln.c -o ../obj_g/insdelln$o
-
-../obj_g/inserts$o :	$(srcdir)/inserts.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/linedata.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/inserts.c -o ../obj_g/inserts$o
-
-../obj_g/key_names$o :	$(srcdir)/key_names.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/key_names.c -o ../obj_g/key_names$o
-
-../obj_g/keynames$o :	$(srcdir)/keynames.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/keynames.c -o ../obj_g/keynames$o
-
-../obj_g/knight$o :	$(srcdir)/knight.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/knight.c -o ../obj_g/knight$o
-
-../obj_g/lrtest$o :	$(srcdir)/lrtest.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/lrtest.c -o ../obj_g/lrtest$o
-
-../obj_g/movewindow$o :	$(srcdir)/movewindow.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/movewindow.c -o ../obj_g/movewindow$o
-
-../obj_g/ncurses$o :	$(srcdir)/ncurses.c \
-			$(HEADER_DEPS) \
-			../include/panel.h \
-			../include/menu.h \
-			../include/form.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/ncurses.c -o ../obj_g/ncurses$o
-
-../obj_g/newdemo$o :	$(srcdir)/newdemo.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/newdemo.c -o ../obj_g/newdemo$o
-
-../obj_g/railroad$o :	$(srcdir)/railroad.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/railroad.c -o ../obj_g/railroad$o
-
-../obj_g/rain$o :	$(srcdir)/rain.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/rain.c -o ../obj_g/rain$o
-
-../obj_g/redraw$o :	$(srcdir)/redraw.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/redraw.c -o ../obj_g/redraw$o
-
-../obj_g/savescreen$o :	$(srcdir)/savescreen.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/savescreen.c -o ../obj_g/savescreen$o
-
-../obj_g/tclock$o :	$(srcdir)/tclock.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/tclock.c -o ../obj_g/tclock$o
-
-../obj_g/test_add_wchstr$o :	$(srcdir)/test_add_wchstr.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/linedata.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/test_add_wchstr.c -o ../obj_g/test_add_wchstr$o
-
-../obj_g/test_addchstr$o :	$(srcdir)/test_addchstr.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/linedata.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/test_addchstr.c -o ../obj_g/test_addchstr$o
-
-../obj_g/test_addstr$o :	$(srcdir)/test_addstr.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/linedata.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/test_addstr.c -o ../obj_g/test_addstr$o
-
-../obj_g/test_addwstr$o :	$(srcdir)/test_addwstr.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/linedata.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/test_addwstr.c -o ../obj_g/test_addwstr$o
-
-../obj_g/test_arrays$o :	$(srcdir)/test_arrays.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/test_arrays.c -o ../obj_g/test_arrays$o
-
-../obj_g/test_get_wstr$o :	$(srcdir)/test_get_wstr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/test_get_wstr.c -o ../obj_g/test_get_wstr$o
-
-../obj_g/test_getstr$o :	$(srcdir)/test_getstr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/test_getstr.c -o ../obj_g/test_getstr$o
-
-../obj_g/test_instr$o :	$(srcdir)/test_instr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/test_instr.c -o ../obj_g/test_instr$o
-
-../obj_g/test_inwstr$o :	$(srcdir)/test_inwstr.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/test_inwstr.c -o ../obj_g/test_inwstr$o
-
-../obj_g/test_opaque$o :	$(srcdir)/test_opaque.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/test_opaque.c -o ../obj_g/test_opaque$o
-
-../obj_g/test_setupterm$o :	$(srcdir)/test_setupterm.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/test_setupterm.c -o ../obj_g/test_setupterm$o
-
-../obj_g/test_vid_puts$o :	$(srcdir)/test_vid_puts.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/test_vid_puts.c -o ../obj_g/test_vid_puts$o
-
-../obj_g/test_vidputs$o :	$(srcdir)/test_vidputs.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/test_vidputs.c -o ../obj_g/test_vidputs$o
-
-../obj_g/testaddch$o :	$(srcdir)/testaddch.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/testaddch.c -o ../obj_g/testaddch$o
-
-../obj_g/testcurs$o :	$(srcdir)/testcurs.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/testcurs.c -o ../obj_g/testcurs$o
-
-../obj_g/testscanw$o :	$(srcdir)/testscanw.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/testscanw.c -o ../obj_g/testscanw$o
-
-../obj_g/view$o :	$(srcdir)/view.c \
-			$(HEADER_DEPS) \
-			$(srcdir)/widechars.h
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/view.c -o ../obj_g/view$o
-
-../obj_g/worm$o :	$(srcdir)/worm.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/worm.c -o ../obj_g/worm$o
-
-../obj_g/xmas$o :	$(srcdir)/xmas.c \
-			$(HEADER_DEPS)
-	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS_DEBUG) -c ../test/xmas.c -o ../obj_g/xmas$o
-
-depend : ${AUTO_SRC}
-	makedepend -- ${CPPFLAGS} -- ${C_SRC}
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/test/Makefile.in b/test/Makefile.in
index 2911c7e..1d54628 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1,6 +1,7 @@
-# $Id: Makefile.in,v 1.115 2015/08/05 23:15:41 tom Exp $
+# $Id: Makefile.in,v 1.130 2021/12/18 23:00:28 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.                #
+# Copyright 2020,2021 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"), #
@@ -43,6 +44,8 @@
 x		= @EXEEXT@
 o		= .@OBJEXT@
 
+PACKAGE		= @PACKAGE@
+
 MODEL		= ../@DFT_OBJ_SUBDIR@
 top_srcdir	= @top_srcdir@
 srcdir		= @srcdir@
@@ -51,15 +54,19 @@
 datarootdir	= @datarootdir@
 
 bindir		= @bindir@
+libexecdir	= @libexecdir@
 libdir		= @libdir@
-includedir	= @includedir@
-includesubdir	= @includesubdir@
+datarootdir	= @datarootdir@
+datadir		= @datadir@
+
+real_bindir	= $(libexecdir)/$(PACKAGE)
 
 BINDIR		= $(DESTDIR)$(bindir)
+LIBEXECDIR	= $(DESTDIR)$(libexecdir)
 LIBDIR		= $(DESTDIR)$(libdir)
-INCLUDEDIR	= $(DESTDIR)$(includedir)$(includesubdir)
+DATADIR		= $(DESTDIR)$(datadir)
 
-PACKAGE		= @PACKAGE@
+REAL_BINDIR	= $(LIBEXECDIR)/$(PACKAGE)
 
 LIBTOOL		= @LIBTOOL@
 LIBTOOL_OPTS	= @LIBTOOL_OPTS@
@@ -67,8 +74,10 @@
 LIBTOOL_COMPILE	= @LIB_COMPILE@
 LIBTOOL_LINK	= @LIB_LINK@
 
-INSTALL		= @INSTALL@
-INSTALL_PROG	= @INSTALL_PROGRAM@
+INSTALL		= @INSTALL@ @INSTALL_OPT_O@
+INSTALL_PROG	= @INSTALL_PROGRAM@ @INSTALL_OPT_S@
+INSTALL_SCRIPT	= @INSTALL_SCRIPT@
+INSTALL_DATA	= @INSTALL_DATA@
 transform	= @program_transform_name@
 TRANSFORM	= sed 's/$x$$//'|sed '$(transform)'|sed 's/$$/$x/'
 
@@ -79,14 +88,14 @@
 CPP		= @CPP@
 
 CFLAGS		= @CFLAGS@ @EXTRA_CFLAGS@
-CPPFLAGS	= -I. -I$(srcdir) -I../test -DHAVE_CONFIG_H @CPPFLAGS@
+CPPFLAGS	= -I. -I$(srcdir) -I../test -DHAVE_CONFIG_H -DDATA_DIR=\"$(datadir)\" @CPPFLAGS@
 
 CCFLAGS		= $(CPPFLAGS) $(CFLAGS)
 
 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@)
@@ -112,27 +121,57 @@
 TEST_ARGS	= @LDFLAGS_STATIC@ @TEST_ARGS@ @LDFLAGS_SHARED@
 
 # use these for linking with all of the libraries
-LIBS_DEFAULT	= $(TEST_ARGS) @LIBS@ $(TEST_LIBS) $(MATH_LIB)
+LIBS_DEFAULT	= $(TEST_ARGS) @LIBS@ $(TEST_LIBS)
 LDFLAGS_DEFAULT	= $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_DEFAULT)
 
 # use these for linking with the (n)curses library and possibly pthreads
-LIBS_THREADS	= `echo "$(TEST_ARGS) @LIBS@" | sed -e 's/-lform.*-lpanel[^ ]*//'` $(TEST_LIBS) $(MATH_LIB) @PTHREAD@
+LIBS_THREADS	= `echo "$(TEST_ARGS) @LIBS@" | sed -e 's/-l@FORM_NAME@.*-l@PANEL_NAME@[^ ]*//'` $(TEST_LIBS) @PTHREAD@
 LDFLAGS_THREADS	= $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_THREADS)
 
 # use these for linking with the (n)curses library
-LIBS_CURSES	= `echo "$(TEST_ARGS) @LIBS@" | sed -e 's/-lform.*-lpanel[^ ]*//'` $(TEST_LIBS) $(MATH_LIB)
+LIBS_CURSES	= `echo "$(TEST_ARGS) @LIBS@" | sed -e 's/-l@FORM_NAME@.*-l@PANEL_NAME@[^ ]*//'` $(TEST_LIBS)
 LDFLAGS_CURSES	= $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_CURSES)
 
+# use these when we need the math library
+LDFLAGS_CURSES_M= $(LDFLAGS_CURSES) $(MATH_LIB)
+
 # use these for linking with the tinfo library if we have it, or curses library if not
-LIBS_TINFO	= @LDFLAGS_STATIC@ @TINFO_LIBS@ @LDFLAGS_SHARED@ @LIBS@ $(TEST_LIBS) $(MATH_LIB)
+LIBS_TINFO	= @LDFLAGS_STATIC@ @TINFO_LIBS@ @LDFLAGS_SHARED@ @LIBS@ $(TEST_LIBS)
 LDFLAGS_TINFO	= @TINFO_LDFLAGS@ $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_TINFO)
 
 LINT		= @LINT@
 LINT_OPTS	= @LINT_OPTS@
 LINT_LIBS	= -lform -lmenu -lpanel -lncurses @LIBS@
 
+INCDIR		= $(top_srcdir)/include
+incdir		= ../include
+
 HEADER_DEPS	= \
-	../include/curses.h \
-	../include/term.h
+	$(incdir)/curses.h \
+	$(incdir)/term.h \
+	$(incdir)/ncurses_cfg.h \
+	$(incdir)/ncurses_def.h \
+	$(incdir)/ncurses_dll.h \
+	$(incdir)/term.h \
+	$(incdir)/unctrl.h \
+	$(INCDIR)/nc_alloc.h
+
+################################################################################
+
+@MAKE_PHONY@.PHONY :	all
+@MAKE_PHONY@.PHONY :	check
+
+all::
+
+# Verify that each header-file can be compiled without including another.
+check::
+	@$(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.*
 
 # The rest is generated from the "programs" and "modules" files...
diff --git a/test/README b/test/README
index cbcc566..885349d 100644
--- a/test/README
+++ b/test/README
@@ -1,5 +1,6 @@
 -------------------------------------------------------------------------------
--- Copyright (c) 1998-2013,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             --
@@ -25,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: README,v 1.52 2015/07/11 14:17:01 tom Exp $
+-- $Id: README,v 1.82 2024/04/27 18:35:01 tom Exp $
 -------------------------------------------------------------------------------
 
 The programs in this directory are used to test and demonstrate ncurses.
@@ -73,81 +74,80 @@
 These programs provide examples of use, but do not comprise a complete set of
 tests.  Here is a list of library externals, noting those that are used:
 
-
 libform:
 -------
 TYPE_ALNUM			test: demo_forms
-TYPE_ALPHA			test: demo_forms ncurses
+TYPE_ALPHA			test: demo_forms dup_field move_field ncurses
 TYPE_ENUM			test: demo_forms
 TYPE_INTEGER			test: demo_forms
 TYPE_IPV4			test: demo_forms
 TYPE_NUMERIC			test: demo_forms
 TYPE_REGEXP			test: demo_forms
-current_field			test: demo_forms edit_field ncurses
+current_field			test: demo_forms dup_field edit_field move_field ncurses
 data_ahead			test: demo_forms
 data_behind			test: demo_forms
-dup_field			-
+dup_field			test: dup_field
 dynamic_field_info		test: demo_forms
 field_arg			test: demo_forms
 field_back			test: demo_forms edit_field
 field_buffer			test: cardfile demo_forms ncurses
-field_count			test: demo_forms
+field_count			test: demo_forms dup_field move_field
 field_fore			test: demo_forms
 field_index			test: demo_forms
 field_info			test: edit_field ncurses
 field_init			-
 field_just			-
-field_opts			test: demo_forms ncurses
+field_opts			test: demo_forms dup_field move_field ncurses
 field_opts_off			test: cardfile demo_forms form_driver_w
 field_opts_on			test: demo_forms
 field_pad			test: demo_forms
 field_status			test: demo_forms
 field_term			-
 field_type			test: demo_forms
-field_userptr			test: demo_forms edit_field ncurses
-form_driver			test: cardfile demo_forms edit_field ncurses
+field_userptr			test: dup_field edit_field move_field ncurses
+form_driver			test: cardfile demo_forms dup_field edit_field move_field ncurses
 form_driver_w			test: form_driver_w
-form_fields			test: cardfile demo_forms
+form_fields			test: cardfile demo_forms dup_field move_field
 form_init			-
 form_opts			-
 form_opts_off			-
 form_opts_on			-
 form_page			test: demo_forms
 form_request_by_name		-
-form_request_name		test: edit_field
-form_sub			test: cardfile demo_forms ncurses
+form_request_name		test: dup_field edit_field move_field
+form_sub			test: cardfile demo_forms dup_field move_field ncurses
 form_term			-
 form_userptr			-
-form_win			test: cardfile demo_forms edit_field ncurses
-free_field			test: cardfile demo_forms form_driver_w ncurses
+form_win			test: cardfile demo_forms dup_field edit_field form_driver_w move_field ncurses
+free_field			test: cardfile demo_forms dup_field form_driver_w move_field ncurses
 free_fieldtype			test: ncurses
-free_form			test: cardfile demo_forms form_driver_w ncurses
+free_form			test: cardfile demo_forms dup_field form_driver_w move_field ncurses
 link_field			-
 link_fieldtype			-
-move_field			-
-new_field			test: cardfile demo_forms form_driver_w ncurses
+move_field			test: move_field
+new_field			test: cardfile demo_forms dup_field form_driver_w move_field ncurses
 new_fieldtype			test: ncurses
-new_form			test: cardfile demo_forms form_driver_w ncurses
+new_form			test: cardfile demo_forms dup_field form_driver_w move_field ncurses
 new_form_sp			-
 new_page			test: demo_forms
 pos_form_cursor			-
-post_form			test: cardfile demo_forms form_driver_w ncurses
+post_form			test: cardfile demo_forms dup_field form_driver_w move_field ncurses
 scale_form			test: demo_forms ncurses
 set_current_field		test: demo_forms
-set_field_back			test: cardfile demo_forms edit_field form_driver_w ncurses
-set_field_buffer		test: cardfile demo_forms edit_field ncurses
+set_field_back			test: cardfile demo_forms dup_field edit_field form_driver_w move_field ncurses
+set_field_buffer		test: cardfile demo_forms dup_field edit_field move_field ncurses
 set_field_fore			test: demo_forms
 set_field_init			-
 set_field_just			test: cardfile demo_forms
-set_field_opts			test: demo_forms ncurses
+set_field_opts			test: demo_forms dup_field move_field ncurses
 set_field_pad			test: demo_forms
 set_field_status		test: demo_forms
 set_field_term			-
-set_field_type			test: demo_forms ncurses
+set_field_type			test: demo_forms dup_field move_field ncurses
 set_field_userptr		test: edit_field ncurses
 set_fieldtype_arg		-
 set_fieldtype_choice		-
-set_form_fields			-
+set_form_fields			test: dup_field move_field
 set_form_init			-
 set_form_opts			-
 set_form_page			-
@@ -157,12 +157,13 @@
 set_form_win			test: cardfile demo_forms ncurses
 set_max_field			test: demo_forms
 set_new_page			test: demo_forms
-unpost_form			test: cardfile demo_forms form_driver_w ncurses
+unfocus_current_field		-
+unpost_form			test: cardfile demo_forms dup_field form_driver_w move_field ncurses
 
 libmenu:
 -------
 current_item			test: demo_menus ncurses
-free_item			test: ncurses
+free_item			test: demo_menus ncurses
 free_menu			test: demo_menus ncurses
 item_count			test: demo_menus
 item_description		-
@@ -230,120 +231,136 @@
 libncurses:
 ----------
 BC				test: demo_termcap
-COLORS				test: dots_curses echochar ncurses savescreen xmas
-COLOR_PAIR			test: background blue bs cardfile clip_printw demo_forms demo_menus demo_panels dots_curses echochar filter firework gdc hanoi ins_wide insdelln inserts knight ncurses newdemo rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr testaddch testcurs view worm xmas
-COLOR_PAIRS			test: dots_curses echochar ncurses newdemo savescreen
-COLS				test: cardfile demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_panels ditto dots_curses echochar edit_field firework foldkeys hashtest inch_wide inchs ins_wide inserts lrtest movewindow ncurses newdemo rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view worm
+COLORS				test: color_content demo_new_pair dots_curses dots_xcurses echochar ncurses pair_content picsmap savescreen xmas
+COLOR_PAIR			test: background blue bs cardfile clip_printw demo_forms demo_menus demo_panels dots_curses dup_field echochar filter firework gdc hanoi ins_wide insdelln inserts knight move_field ncurses newdemo padview picsmap rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr testaddch testcurs view worm xmas
+COLOR_PAIRS			test: demo_new_pair dots_curses dots_xcurses echochar ncurses newdemo pair_content
+COLS				test: cardfile combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_panels demo_tabs ditto dots_curses dots_xcurses echochar filter firework foldkeys hashtest inch_wide inchs ins_wide inserts lrtest movewindow ncurses newdemo padview picsmap rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view worm
 ESCDELAY			test: test_opaque
-LINES				test: cardfile demo_defkey demo_keyok demo_menus demo_panels ditto dots_curses echochar edit_field firework hanoi hashtest inch_wide inchs ins_wide inserts lrtest movewindow ncurses newdemo rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view worm xmas
-PAIR_NUMBER			test: ncurses
+LINES				test: cardfile combine demo_defkey demo_keyok demo_menus demo_panels demo_tabs ditto dots_curses dots_xcurses echochar firework hanoi hashtest inch_wide inchs ins_wide inserts lrtest move_field movewindow ncurses newdemo padview picsmap rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view worm xmas
+PAIR_NUMBER			test: dump_window ncurses
 PC				test: demo_termcap
 SP				lib: form
 TABSIZE				test: test_opaque
 UP				test: demo_termcap
-acs_map				test: background gdc ins_wide inserts knight movewindow ncurses newdemo savescreen test_add_wchstr test_addchstr test_addstr test_addwstr testcurs
-add_wch				test: demo_panels ncurses test_add_wchstr test_addwstr
+acs_map				test: back_ground background gdc ins_wide inserts knight movewindow ncurses newdemo savescreen test_add_wchstr test_addchstr test_addstr test_addwstr testcurs
+add_wch				test: combine demo_new_pair demo_panels ncurses picsmap savescreen test_add_wchstr test_addwstr
 add_wchnstr			test: test_add_wchstr
 add_wchstr			test: test_add_wchstr view
-addch				test: background blue bs dots_curses echochar hashtest ncurses savescreen test_add_wchstr test_addchstr test_addstr test_addwstr test_opaque testaddch view worm
+addch				test: back_ground background blue bs color_content demo_tabs dots_curses echochar hashtest ncurses padview pair_content picsmap savescreen test_add_wchstr test_addchstr test_addstr test_addwstr test_opaque testaddch view worm
 addchnstr			test: test_addchstr
 addchstr			test: test_addchstr
 addnstr				test: test_addstr
-addnwstr			test: ncurses test_addwstr
-addstr				test: blue bs cardfile gdc hanoi lrtest ncurses test_addstr
-addwstr				test: test_addwstr
-assume_default_colors		test: background ncurses
+addnwstr			test: dots_xcurses ncurses test_addwstr
+addstr				test: blue bs cardfile filter gdc hanoi lrtest ncurses test_addstr
+addwstr				test: blue combine test_addwstr
+alloc_pair			test: demo_new_pair dots_xcurses
+alloc_pair_sp			-
+assume_default_colors		test: back_ground background ncurses
 assume_default_colors_sp	-
 attr_get			-
-attr_off			test: ncurses
-attr_on				test: ncurses
+attr_off			test: combine dots_xcurses ncurses
+attr_on				test: combine dots_xcurses ncurses
 attr_set			test: ncurses
-attroff				test: dots_curses echochar filter gdc ncurses tclock
-attron				test: bs dots_curses echochar filter gdc ncurses
-attrset				test: bs firework gdc hanoi insdelln ncurses rain tclock testaddch testcurs
-baudrate			lib: ncurses
-baudrate_sp			lib: ncurses
-beep				test: blue bs cardfile chgat clip_printw demo_forms demo_menus demo_panels edit_field hanoi inch_wide inchs ins_wide insdelln inserts knight movewindow ncurses savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view xmas
+attroff				test: blue dots_curses echochar filter gdc ncurses tclock
+attron				test: blue bs dots_curses echochar filter gdc ncurses
+attrset				test: bs filter firework gdc hanoi insdelln ncurses picsmap rain tclock testaddch testcurs
+baudrate			test: ncurses
+baudrate_sp			test: sp_tinfo
+beep				test: blue bs cardfile chgat clip_printw demo_forms demo_menus demo_new_pair demo_panels dup_field edit_field firstlast hanoi inch_wide inchs ins_wide insdelln inserts knight move_field movewindow ncurses padview popup_msg rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view xmas
 beep_sp				lib: ncurses
-bkgd				test: background cardfile demo_forms ncurses savescreen tclock view
+bkgd				test: background cardfile demo_forms dup_field move_field ncurses padview savescreen tclock view
 bkgdset				test: background ncurses testaddch
 bkgrnd				test: ncurses
-bkgrndset			test: ncurses
+bkgrndset			test: back_ground ncurses
 boolcodes			test: demo_termcap test_arrays progs: dump_entry
 boolfnames			test: demo_terminfo test_arrays progs: dump_entry
-boolnames			test: demo_termcap demo_terminfo test_arrays progs: dump_entry infocmp
+boolnames			test: demo_terminfo test_arrays progs: dump_entry infocmp
 border				-
 border_set			-
-box				test: cardfile chgat clip_printw demo_forms demo_menus demo_panels ditto edit_field inch_wide inchs ins_wide insdelln inserts lrtest ncurses newdemo redraw savescreen test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs
+box				test: cardfile chgat clip_printw demo_forms demo_menus demo_panels ditto inch_wide inchs ins_wide insdelln inserts lrtest ncurses newdemo popup_msg redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs
 box_set				test: ncurses
-can_change_color		test: ncurses
-can_change_color_sp		-
-cbreak				test: background blue bs cardfile chgat clip_printw color_set demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_panels ditto filter firework foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts knight lrtest movewindow ncurses newdemo savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view worm xmas
-cbreak_sp			lib: ncurses
+can_change_color		test: color_content extended_color ncurses
+can_change_color_sp		test: extended_color
+cbreak				test: back_ground background blue bs cardfile chgat clip_printw color_content color_set combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_new_pair demo_panels demo_tabs ditto dup_field extended_color filter firework foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts knight lrtest move_field movewindow ncurses newdemo padview pair_content picsmap savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_unget_wch testcurs view worm xmas
+cbreak_sp			test: sp_tinfo
 chgat				test: chgat
-clear				test: blue bs gdc ncurses testcurs xmas
+clear				test: blue bs filter gdc ncurses padview testcurs xmas
 clearok				test: bs knight
-clrtobot			test: demo_menus ncurses
-clrtoeol			test: blue bs demo_altkeys foldkeys form_driver_w hanoi hashtest movewindow ncurses view
-color_content			test: ncurses
+clrtobot			test: demo_menus move_field ncurses view
+clrtoeol			test: blue bs demo_altkeys filter foldkeys form_driver_w hanoi hashtest movewindow ncurses padview test_mouse view
+color_content			test: color_content ncurses picsmap
 color_content_sp		-
-color_set			test: color_set ncurses
+color_set			test: color_set dots_xcurses extended_color ncurses
 copywin				test: ncurses testcurs
-cur_term			test: demo_termcap demo_terminfo dots dots_mvcur lrtest test_vid_puts test_vidputs progs: clear tabs tput tset
-curs_set			test: echochar firework gdc hanoi lrtest ncurses newdemo rain savescreen tclock testcurs worm xmas
-curs_set_sp			lib: ncurses
-curscr				test: demo_panels edit_field knight lrtest ncurses savescreen tclock view
-curses_version			test: ncurses progs: infocmp tabs tic toe tput tset
+cur_term			test: demo_termcap demo_terminfo dots dots_mvcur filter list_keys lrtest sp_tinfo test_sgr test_tparm test_vid_puts test_vidputs progs: clear_cmd reset_cmd tabs tput tset
+curs_set			test: demo_new_pair echochar firework gdc hanoi lrtest ncurses newdemo picsmap rain savescreen tclock testcurs worm xmas
+curs_set_sp			test: sp_tinfo
+curscr				test: demo_panels knight lrtest ncurses popup_msg savescreen tclock
+curses_trace			test: demo_menus hashtest lrtest ncurses padview redraw test_sgr test_termattrs test_vid_puts test_vidputs testcurs view worm progs: infocmp tic toe
+curses_version			test: back_ground background blue bs cardfile chgat clip_printw color_content color_set combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_new_pair demo_panels demo_tabs demo_termcap demo_terminfo ditto dots dots_curses dots_mvcur dots_termcap dots_xcurses dup_field echochar extended_color filter firework firstlast foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts key_names keynames knight list_keys lrtest move_field movewindow ncurses newdemo padview pair_content picsmap railroad rain redraw savescreen sp_tinfo tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_arrays test_delwin test_endwin test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_setupterm test_sgr test_termattrs test_tparm test_unget_wch test_vid_puts test_vidputs testaddch testcurs testscanw view worm xmas progs: clear infocmp tabs tic toe tput tset
 def_prog_mode			test: bs ncurses
-def_prog_mode_sp		lib: ncurses
+def_prog_mode_sp		test: sp_tinfo
 def_shell_mode			-
-def_shell_mode_sp		lib: ncurses
+def_shell_mode_sp		test: sp_tinfo
 define_key			test: demo_altkeys demo_defkey foldkeys
-define_key_sp			-
-del_curterm			test: demo_terminfo
+define_key_sp			test: sp_tinfo
+del_curterm			test: demo_terminfo sp_tinfo test_sgr test_tparm
 del_curterm_sp			lib: ncurses
 delay_output			test: newdemo
-delay_output_sp			-
+delay_output_sp			test: sp_tinfo
 delch				-
 deleteln			test: insdelln
-delscreen			test: ditto dots_mvcur
-delwin				test: cardfile chgat clip_printw demo_forms demo_panels edit_field inch_wide inchs ins_wide insdelln inserts movewindow ncurses newdemo redraw savescreen test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs
-derwin				test: cardfile chgat clip_printw demo_forms demo_menus ditto inch_wide inchs ins_wide insdelln inserts movewindow ncurses test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque
-doupdate			test: cardfile demo_menus demo_panels ditto edit_field ins_wide inserts knight movewindow ncurses redraw savescreen test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr
+delscreen			test: ditto dots_mvcur test_delwin
+delwin				test: cardfile chgat clip_printw demo_forms demo_panels dup_field inch_wide inchs ins_wide insdelln inserts move_field ncurses newdemo padview popup_msg redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view
+derwin				test: cardfile chgat clip_printw demo_forms demo_menus ditto inch_wide inchs ins_wide insdelln inserts movewindow ncurses test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_opaque
+doupdate			test: cardfile demo_menus demo_panels ditto ins_wide inserts knight movewindow ncurses padview popup_msg redraw savescreen test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr
 doupdate_sp			lib: ncurses
-dupwin				test: edit_field
+dupwin				test: popup_msg
 echo				test: bs hanoi ncurses test_get_wstr test_getstr testcurs testscanw
 echo_sp				lib: ncurses
 echo_wchar			test: ncurses
 echochar			test: echochar ncurses
-endwin				test: background blue bs cardfile chgat clip_printw color_set demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_panels ditto dots_curses dots_mvcur echochar filter firework firstlast foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts key_names keynames knight lrtest movewindow ncurses newdemo rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testaddch testcurs testscanw view worm xmas
+endwin				test: back_ground background blue bs cardfile chgat clip_printw color_content color_set combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_new_pair demo_panels demo_tabs ditto dots_curses dots_mvcur dots_xcurses dup_field echochar extended_color filter firework firstlast foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts key_names keynames knight lrtest move_field movewindow ncurses newdemo padview pair_content picsmap rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_endwin test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_unget_wch testaddch testcurs testscanw view worm xmas
 endwin_sp			lib: ncurses
-erase				test: cardfile demo_menus filter firework firstlast hanoi lrtest ncurses tclock test_opaque testcurs
-erasechar			lib: ncurses
-erasechar_sp			lib: ncurses
-erasewchar			-
+erase				test: cardfile demo_menus filter firework firstlast hanoi lrtest ncurses picsmap tclock test_opaque testcurs
+erasechar			test: ncurses
+erasechar_sp			test: sp_tinfo
+erasewchar			test: ncurses
+erasewchar_sp			lib: ncurses
+exit_curses			test: back_ground background blue bs cardfile chgat clip_printw color_content color_set combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_new_pair demo_panels demo_tabs ditto dots_curses dots_xcurses dup_field echochar extended_color filter firework firstlast foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts key_names keynames knight lrtest move_field movewindow ncurses newdemo padview pair_content picsmap rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_endwin test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_setupterm test_termattrs test_unget_wch testaddch testcurs testscanw view worm xmas
+exit_terminfo			test: demo_termcap demo_terminfo dots dots_mvcur dots_termcap list_keys railroad sp_tinfo test_arrays test_sgr test_tparm test_vid_puts test_vidputs
+extended_color_content		test: color_content extended_color
+extended_color_content_sp	test: extended_color
+extended_pair_content		test: extended_color pair_content
+extended_pair_content_sp	test: extended_color
+extended_slk_color		test: extended_color
+extended_slk_color_sp		test: extended_color
 filter				test: filter
 filter_sp			-
-flash				test: cardfile lrtest movewindow ncurses tclock testcurs
+find_pair			test: demo_new_pair
+find_pair_sp			-
+flash				test: cardfile filter lrtest movewindow ncurses tclock testcurs
 flash_sp			-
 flushinp			test: ncurses newdemo testcurs
-flushinp_sp			lib: ncurses
+flushinp_sp			test: sp_tinfo
+free_pair			test: demo_new_pair
+free_pair_sp			-
 get_escdelay			-
 get_escdelay_sp			-
-get_wch				test: form_driver_w
+get_wch				test: form_driver_w test_unget_wch
 get_wstr			test: test_get_wstr
 getattrs			-
-getbegx				test: chgat clip_printw demo_menus demo_panels insdelln movewindow ncurses newdemo redraw testcurs
-getbegy				test: chgat clip_printw demo_menus demo_panels insdelln movewindow ncurses newdemo redraw testcurs
+getbegx				test: chgat clip_printw demo_menus demo_panels dump_window insdelln move_field movewindow ncurses newdemo redraw testcurs
+getbegy				test: chgat clip_printw demo_menus demo_panels dump_window insdelln move_field movewindow ncurses newdemo redraw testcurs
 getbkgd				test: ncurses
 getbkgrnd			test: ncurses
-getcchar			test: ncurses view
-getch				test: background blue bs chgat color_set demo_altkeys filter firework firstlast foldkeys hanoi hashtest insdelln lrtest savescreen tclock test_opaque testaddch testcurs view xmas
-getcurx				test: bs chgat clip_printw demo_altkeys demo_defkey demo_panels firstlast foldkeys insdelln movewindow ncurses redraw savescreen test_get_wstr test_getstr test_opaque testcurs
-getcury				test: bs chgat clip_printw demo_altkeys demo_defkey demo_panels edit_field firstlast foldkeys insdelln movewindow ncurses redraw savescreen test_opaque testcurs
-getmaxx				test: chgat clip_printw demo_panels inch_wide inchs insdelln movewindow ncurses newdemo redraw test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs
-getmaxy				test: chgat clip_printw demo_forms demo_panels inch_wide inchs insdelln movewindow ncurses newdemo redraw test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs
-getmouse			test: bs knight movewindow ncurses testcurs
+getcchar			test: demo_new_pair ncurses savescreen view
+getch				test: back_ground background blue bs chgat color_content color_set combine demo_altkeys demo_new_pair demo_tabs extended_color filter firework firstlast foldkeys hanoi hashtest insdelln lrtest padview pair_content picsmap savescreen tclock test_endwin test_mouse test_opaque test_unget_wch testaddch testcurs view xmas
+getcurx				test: bs chgat clip_printw combine demo_altkeys demo_defkey demo_panels dump_window extended_color filter firstlast foldkeys insdelln move_field movewindow ncurses redraw savescreen test_get_wstr test_getstr test_opaque testcurs view
+getcury				test: bs chgat clip_printw demo_altkeys demo_defkey demo_panels dump_window extended_color filter firstlast foldkeys insdelln move_field movewindow ncurses popup_msg redraw savescreen test_mouse test_opaque testcurs view
+getmaxx				test: chgat clip_printw demo_panels dump_window firstlast inch_wide inchs insdelln movewindow ncurses newdemo popup_msg redraw test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs
+getmaxy				test: chgat clip_printw demo_forms demo_panels dump_window firstlast inch_wide inchs insdelln movewindow ncurses newdemo popup_msg redraw test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque testcurs
+getmouse			test: bs demo_menus knight movewindow ncurses test_mouse testcurs
 getmouse_sp			-
 getn_wstr			test: test_get_wstr
 getnstr				test: filter ncurses test_getstr
@@ -352,22 +369,22 @@
 getstr				test: test_getstr
 getwin				test: ncurses
 getwin_sp			-
-halfdelay			test: view
-halfdelay_sp			-
-has_colors			test: background bs cardfile chgat clip_printw color_set demo_forms demo_menus demo_panels dots_curses echochar filter firework gdc hanoi ins_wide insdelln inserts knight ncurses newdemo rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr testcurs view worm xmas
+halfdelay			test: padview view
+halfdelay_sp			test: sp_tinfo
+has_colors			test: back_ground background bs cardfile chgat clip_printw color_content color_set demo_forms demo_menus demo_new_pair demo_panels dots_curses dots_xcurses dup_field echochar extended_color filter firework gdc hanoi ins_wide insdelln inserts knight move_field ncurses newdemo padview pair_content picsmap rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr testcurs view worm xmas
 has_colors_sp			lib: ncurses
-has_ic				test: lrtest
-has_ic_sp			lib: ncurses
-has_il				-
-has_il_sp			lib: ncurses
+has_ic				test: lrtest ncurses
+has_ic_sp			test: sp_tinfo
+has_il				test: ncurses
+has_il_sp			test: sp_tinfo
 has_key				-
-has_key_sp			lib: ncurses
+has_key_sp			test: sp_tinfo
 has_mouse			-
 has_mouse_sp			-
 hline				test: gdc ncurses
 hline_set			-
 idcok				test: test_opaque
-idlok				test: ncurses test_opaque testscanw view
+idlok				test: ncurses padview test_opaque testscanw view
 immedok				test: test_opaque
 in_wch				test: inch_wide
 in_wchnstr			test: inch_wide
@@ -375,11 +392,15 @@
 inch				test: inchs
 inchnstr			test: inchs
 inchstr				test: inchs
-init_color			test: ncurses
-init_color_sp			lib: ncurses
-init_pair			test: background blue bs cardfile chgat clip_printw color_set demo_forms demo_menus demo_panels dots_curses echochar filter firework gdc hanoi ins_wide insdelln inserts knight ncurses newdemo rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr testaddch testcurs view worm xmas
-init_pair_sp			-
-initscr				test: background blue bs cardfile chgat clip_printw color_set demo_defkey demo_forms demo_keyok demo_menus demo_panels dots_curses echochar filter firework firstlast form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts knight lrtest movewindow ncurses newdemo rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testaddch testcurs testscanw view worm xmas
+init_color			test: color_content ncurses
+init_color_sp			-
+init_extended_color		test: color_content extended_color
+init_extended_color_sp		test: extended_color
+init_extended_pair		test: extended_color ncurses pair_content picsmap
+init_extended_pair_sp		test: extended_color
+init_pair			test: back_ground background blue bs cardfile chgat clip_printw color_set demo_forms demo_menus demo_new_pair demo_panels dots_curses dots_xcurses dup_field echochar filter firework gdc hanoi ins_wide insdelln inserts knight move_field ncurses newdemo padview pair_content picsmap rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr testaddch testcurs view worm xmas
+init_pair_sp			lib: ncurses
+initscr				test: back_ground background blue bs cardfile chgat clip_printw color_content color_set combine demo_defkey demo_forms demo_keyok demo_menus demo_panels demo_tabs dots_curses dots_xcurses dup_field echochar filter firework firstlast form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts knight lrtest move_field movewindow ncurses newdemo padview pair_content picsmap rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_endwin test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_unget_wch testaddch testcurs testscanw view worm xmas
 innstr				test: test_instr
 innwstr				test: test_inwstr
 ins_nwstr			test: ins_wide
@@ -391,21 +412,29 @@
 insnstr				test: inserts
 insstr				test: inserts
 instr				test: test_instr
-intrflush			test: demo_forms movewindow
-intrflush_sp			-
+intrflush			test: demo_forms dup_field move_field movewindow
+intrflush_sp			test: sp_tinfo
 inwstr				test: test_inwstr
+is_cbreak			-
+is_cbreak_sp			-
 is_cleared			test: test_opaque
+is_echo				-
+is_echo_sp			-
 is_idcok			test: test_opaque
 is_idlok			test: test_opaque
 is_immedok			test: test_opaque
-is_keypad			test: test_opaque
+is_keypad			test: ncurses test_opaque
 is_leaveok			test: test_opaque
 is_linetouched			lib: form
+is_nl				-
+is_nl_sp			-
 is_nodelay			test: test_opaque
 is_notimeout			test: test_opaque
-is_pad				-
-is_scrollok			test: test_opaque
-is_subwin			-
+is_pad				test: test_opaque
+is_raw				-
+is_raw_sp			-
+is_scrollok			test: ncurses test_opaque
+is_subwin			test: test_opaque
 is_syncok			test: test_opaque
 is_term_resized			-
 is_term_resized_sp		-
@@ -413,29 +442,31 @@
 isendwin			-
 isendwin_sp			-
 key_defined			test: demo_defkey foldkeys
-key_defined_sp			lib: ncurses
-key_name			test: key_names ncurses
+key_defined_sp			test: sp_tinfo
+key_name			test: key_names ncurses test_unget_wch
 keybound			test: demo_altkeys demo_defkey
-keybound_sp			lib: ncurses
-keyname				test: demo_altkeys demo_defkey demo_keyok demo_menus edit_field foldkeys keynames movewindow ncurses redraw test_getstr testcurs view progs: tic
-keyname_sp			lib: ncurses
+keybound_sp			test: sp_tinfo
+keyname				test: combine demo_altkeys demo_defkey demo_keyok demo_menus dup_field edit_field foldkeys keynames move_field movewindow ncurses padview redraw test_getstr test_unget_wch testcurs view progs: tic
+keyname_sp			test: sp_tinfo
 keyok				test: demo_keyok foldkeys
-keyok_sp			lib: ncurses
-keypad				test: bs cardfile chgat clip_printw demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_panels ditto edit_field filter firework foldkeys form_driver_w hashtest inch_wide inchs ins_wide insdelln inserts key_names keynames knight lrtest movewindow ncurses redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs testscanw view
-killchar			lib: ncurses
-killchar_sp			lib: ncurses
-killwchar			-
+keyok_sp			test: sp_tinfo
+keypad				test: bs cardfile chgat clip_printw combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_new_pair demo_panels ditto dup_field filter firework foldkeys form_driver_w hashtest inch_wide inchs ins_wide insdelln inserts key_names keynames knight lrtest move_field movewindow ncurses padview popup_msg redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_unget_wch testcurs testscanw view
+killchar			test: ncurses
+killchar_sp			test: sp_tinfo
+killwchar			test: ncurses
+killwchar_sp			lib: ncurses
 leaveok				test: hanoi test_opaque
-longname			test: testcurs progs: tput
+longname			test: ncurses testcurs progs: tput
+longname_sp			test: sp_tinfo
 mcprint				-
 mcprint_sp			-
 meta				test: key_names keynames ncurses
-mouse_trafo			-
-mouseinterval			-
+mouse_trafo			lib: form
+mouseinterval			test: test_mouse
 mouseinterval_sp		-
-mousemask			test: bs demo_forms demo_menus knight movewindow ncurses testcurs
+mousemask			test: bs demo_forms demo_menus knight movewindow ncurses test_mouse testcurs
 mousemask_sp			-
-move				test: blue bs cardfile chgat demo_altkeys demo_menus dots_curses echochar foldkeys gdc hanoi hashtest inch_wide inchs ins_wide inserts knight lrtest movewindow ncurses savescreen test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testscanw view xmas
+move				test: blue bs cardfile chgat combine demo_altkeys demo_menus demo_new_pair demo_tabs dots_curses dots_xcurses echochar filter foldkeys gdc hanoi hashtest inch_wide inchs ins_wide inserts knight lrtest move_field movewindow ncurses picsmap savescreen test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testscanw view xmas
 mvadd_wch			test: ncurses test_add_wchstr test_addwstr
 mvadd_wchnstr			test: test_add_wchstr
 mvadd_wchstr			test: test_add_wchstr
@@ -475,14 +506,14 @@
 mvinsstr			test: inserts
 mvinstr				test: test_instr
 mvinwstr			test: test_inwstr
-mvprintw			test: background bs firework form_driver_w hanoi ncurses savescreen tclock view
+mvprintw			test: back_ground background bs firework form_driver_w hanoi move_field ncurses padview savescreen tclock view
 mvscanw				-
 mvvline				test: ncurses
 mvvline_set			test: ncurses
 mvwadd_wch			test: test_add_wchstr test_addwstr
 mvwadd_wchnstr			test: test_add_wchstr
 mvwadd_wchstr			test: inch_wide test_add_wchstr
-mvwaddch			test: movewindow newdemo test_add_wchstr test_addchstr test_addstr test_addwstr testcurs xmas
+mvwaddch			test: movewindow ncurses newdemo test_add_wchstr test_addchstr test_addstr test_addwstr testcurs xmas
 mvwaddchnstr			test: test_addchstr
 mvwaddchstr			test: inchs test_addchstr
 mvwaddnstr			test: newdemo test_addstr testcurs
@@ -497,13 +528,13 @@
 mvwgetn_wstr			test: test_get_wstr
 mvwgetnstr			test: test_getstr
 mvwgetstr			test: test_getstr
-mvwhline			test: movewindow
+mvwhline			test: movewindow ncurses
 mvwhline_set			-
-mvwin				test: cardfile demo_menus movewindow testcurs xmas
+mvwin				test: cardfile demo_menus movewindow ncurses testcurs xmas
 mvwin_wch			test: inch_wide
 mvwin_wchnstr			test: inch_wide
 mvwin_wchstr			test: inch_wide
-mvwinch				test: inchs newdemo testcurs
+mvwinch				test: dump_window inchs newdemo testcurs
 mvwinchnstr			test: inchs
 mvwinchstr			test: inchs
 mvwinnstr			test: test_instr testcurs
@@ -516,65 +547,67 @@
 mvwinsstr			test: inserts testcurs
 mvwinstr			test: test_instr
 mvwinwstr			test: test_inwstr
-mvwprintw			test: chgat clip_printw demo_menus demo_panels inch_wide inchs insdelln ncurses test_instr test_inwstr testcurs
+mvwprintw			test: demo_menus demo_panels inch_wide inchs ncurses test_delwin test_instr test_inwstr testcurs
 mvwscanw			test: testcurs
-mvwvline			test: ins_wide inserts movewindow test_add_wchstr test_addchstr test_addstr test_addwstr
+mvwvline			test: ins_wide inserts movewindow ncurses test_add_wchstr test_addchstr test_addstr test_addwstr
 mvwvline_set			-
-napms				test: demo_panels ditto dots dots_curses dots_mvcur echochar firework gdc hanoi lrtest ncurses railroad rain tclock test_opaque testcurs view worm xmas progs: tset
-napms_sp			-
-new_prescr			lib: ncurses
-newpad				test: edit_field ncurses testcurs
+napms				test: demo_panels ditto dots dots_curses dots_mvcur dots_termcap dots_xcurses echochar extended_color firework firstlast gdc hanoi lrtest ncurses padview picsmap railroad rain tclock test_opaque testcurs view worm xmas progs: tset
+napms_sp			test: sp_tinfo
+new_prescr			test: sp_tinfo
+newpad				test: ncurses padview popup_msg testcurs
 newpad_sp			lib: ncurses
 newscr				lib: ncurses
-newterm				test: demo_altkeys ditto dots_mvcur filter foldkeys gdc key_names keynames test_setupterm
+newterm				test: demo_altkeys demo_new_pair ditto dots_mvcur extended_color filter foldkeys gdc key_names keynames redraw test_delwin test_endwin test_mouse test_setupterm test_termattrs
 newterm_sp			-
-newwin				test: cardfile chgat clip_printw demo_defkey demo_forms demo_keyok demo_menus demo_panels ditto edit_field firstlast inch_wide inchs ins_wide insdelln inserts knight movewindow ncurses newdemo redraw savescreen test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs xmas
+newwin				test: cardfile chgat clip_printw demo_defkey demo_forms demo_keyok demo_menus demo_panels ditto firstlast inch_wide inchs ins_wide insdelln inserts knight movewindow ncurses newdemo popup_msg redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view xmas
 newwin_sp			lib: ncurses
-nl				test: demo_forms ncurses rain testcurs
+nl				test: demo_forms dup_field move_field ncurses rain testcurs
 nl_sp				lib: ncurses
 nocbreak			test: testcurs
-nocbreak_sp			lib: ncurses
-nodelay				test: ditto firework gdc lrtest ncurses newdemo rain tclock test_opaque view worm xmas
-noecho				test: background bs cardfile chgat clip_printw color_set demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_panels ditto firework firstlast foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts knight lrtest movewindow ncurses rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs view worm xmas
+nocbreak_sp			test: sp_tinfo
+nodelay				test: demo_new_pair ditto extended_color firework gdc lrtest ncurses newdemo padview rain tclock test_opaque view worm xmas
+noecho				test: back_ground background bs cardfile chgat clip_printw color_content color_set combine demo_altkeys demo_defkey demo_forms demo_keyok demo_menus demo_new_pair demo_panels demo_tabs ditto dup_field extended_color firework firstlast foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts knight lrtest move_field movewindow ncurses padview pair_content picsmap rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_unget_wch testcurs view worm xmas
 noecho_sp			lib: ncurses
 nofilter			-
 nofilter_sp			-
-nonl				test: bs demo_forms hashtest movewindow ncurses view worm xmas
+nonl				test: bs demo_forms dup_field hashtest move_field movewindow ncurses padview test_mouse view worm xmas
 nonl_sp				lib: ncurses
 noqiflush			-
-noqiflush_sp			-
-noraw				test: demo_forms demo_menus ncurses testcurs
-noraw_sp			lib: ncurses
-notimeout			test: test_opaque
+noqiflush_sp			test: sp_tinfo
+noraw				test: demo_forms demo_menus dup_field move_field ncurses test_mouse testcurs
+noraw_sp			test: sp_tinfo
+notimeout			test: ncurses test_opaque
 numcodes			test: demo_termcap test_arrays progs: dump_entry
 numfnames			test: demo_terminfo test_arrays progs: dump_entry
-numnames			test: demo_termcap demo_terminfo test_arrays progs: dump_entry infocmp
+numnames			test: demo_terminfo test_arrays progs: dump_entry infocmp
 ospeed				test: demo_termcap progs: tset
 overlay				test: ncurses testcurs xmas
 overwrite			test: ncurses savescreen
-pair_content			test: background color_set
+pair_content			test: back_ground background color_set pair_content
 pair_content_sp			lib: ncurses
 pecho_wchar			-
 pechochar			-
-pnoutrefresh			test: edit_field ncurses
+pnoutrefresh			test: ncurses padview popup_msg
 prefresh			test: testcurs
-printw				test: background blue bs color_set demo_altkeys demo_defkey demo_keyok filter foldkeys ncurses savescreen testcurs testscanw view
-putp				progs: tput
-putp_sp				-
+printw				test: back_ground background blue bs color_content color_set combine demo_altkeys demo_defkey demo_keyok demo_tabs extended_color filter foldkeys ncurses pair_content savescreen test_delwin test_unget_wch testcurs testscanw view
+putp				test: filter test_mouse test_sgr progs: tput
+putp_sp				test: sp_tinfo
 putwin				test: ncurses
 qiflush				-
-qiflush_sp			-
-raw				test: demo_forms ncurses redraw testcurs
-raw_sp				lib: ncurses
-redrawwin			test: redraw view
-refresh				test: blue bs demo_defkey demo_forms demo_keyok demo_menus demo_panels dots_curses echochar filter firstlast form_driver_w gdc hanoi hashtest lrtest movewindow ncurses savescreen tclock testcurs view xmas
+qiflush_sp			test: sp_tinfo
+raw				test: demo_forms dup_field move_field ncurses redraw test_mouse testcurs
+raw_sp				test: sp_tinfo
+redrawwin			test: combine padview redraw view
+refresh				test: blue bs color_content demo_defkey demo_forms demo_keyok demo_menus demo_panels demo_tabs dots_curses dots_mvcur dots_xcurses dup_field echochar filter firstlast form_driver_w gdc hanoi hashtest lrtest move_field movewindow ncurses pair_content picsmap savescreen tclock test_delwin test_endwin test_mouse testcurs view xmas
+reset_color_pairs		test: picsmap
+reset_color_pairs_sp		-
 reset_prog_mode			test: filter ncurses
-reset_prog_mode_sp		lib: ncurses
+reset_prog_mode_sp		test: sp_tinfo
 reset_shell_mode		test: bs filter savescreen test_setupterm
-reset_shell_mode_sp		lib: ncurses
+reset_shell_mode_sp		test: sp_tinfo
 resetty				-
-resetty_sp			-
-resize_term			test: view
+resetty_sp			test: sp_tinfo
+resize_term			-
 resize_term_sp			-
 resizeterm			-
 resizeterm_sp			lib: ncurses
@@ -583,9 +616,9 @@
 ripoffline			test: demo_menus ncurses
 ripoffline_sp			-
 savetty				-
-savetty_sp			-
+savetty_sp			test: sp_tinfo
 scanw				test: testcurs testscanw
-scr_dump			test: savescreen
+scr_dump			test: combine savescreen
 scr_init			test: savescreen
 scr_init_sp			-
 scr_restore			test: savescreen
@@ -594,17 +627,17 @@
 scr_set_sp			-
 scrl				test: view
 scroll				test: testcurs
-scrollok			test: clip_printw demo_altkeys demo_defkey demo_keyok demo_panels ditto foldkeys hashtest knight ncurses redraw test_opaque testcurs testscanw view
-set_curterm			lib: ncurses
-set_curterm_sp			-
+scrollok			test: clip_printw color_content demo_altkeys demo_defkey demo_keyok demo_new_pair demo_panels ditto foldkeys hashtest knight ncurses pair_content picsmap redraw test_delwin test_opaque test_unget_wch testcurs testscanw view
+set_curterm			test: list_keys sp_tinfo
+set_curterm_sp			test: sp_tinfo
 set_escdelay			test: test_opaque
 set_escdelay_sp			lib: ncurses
-set_tabsize			test: test_opaque
-set_tabsize_sp			-
+set_tabsize			test: demo_tabs test_opaque
+set_tabsize_sp			test: sp_tinfo
 set_term			lib: ncurses
-setcchar			test: demo_panels ins_wide ncurses test_add_wchstr test_addwstr view
+setcchar			test: back_ground combine demo_new_pair demo_panels ins_wide ncurses picsmap savescreen test_add_wchstr test_addwstr
 setscrreg			test: view
-setupterm			test: demo_terminfo dots test_setupterm test_vid_puts test_vidputs progs: clear tabs tput tset
+setupterm			test: demo_terminfo dots list_keys sp_tinfo test_setupterm test_sgr test_termattrs test_tparm test_vid_puts test_vidputs progs: clear tabs tput tset
 slk_attr			-
 slk_attr_off			-
 slk_attr_on			-
@@ -615,89 +648,91 @@
 slk_attroff_sp			-
 slk_attron			lib: ncurses
 slk_attron_sp			-
-slk_attrset			test: ncurses
+slk_attrset			test: extended_color ncurses
 slk_attrset_sp			-
 slk_clear			test: ncurses
 slk_clear_sp			-
 slk_color			test: ncurses
 slk_color_sp			-
-slk_init			test: ncurses
+slk_init			test: extended_color ncurses
 slk_init_sp			-
 slk_label			test: ncurses
 slk_label_sp			-
-slk_noutrefresh			test: ncurses
+slk_noutrefresh			test: extended_color ncurses
 slk_noutrefresh_sp		-
 slk_refresh			test: ncurses
 slk_refresh_sp			lib: ncurses
 slk_restore			test: ncurses
 slk_restore_sp			lib: ncurses
-slk_set				test: ncurses
+slk_set				test: extended_color ncurses
 slk_set_sp			-
-slk_touch			test: ncurses
+slk_touch			test: extended_color ncurses
 slk_touch_sp			lib: ncurses
 slk_wset			test: ncurses
 standend			test: blue gdc ncurses
 standout			test: blue ncurses
-start_color			test: background blue bs cardfile chgat clip_printw color_set demo_forms demo_menus demo_panels dots_curses echochar filter firework gdc hanoi ins_wide insdelln inserts knight ncurses newdemo rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr testaddch testcurs view worm xmas
+start_color			test: back_ground background blue bs cardfile chgat clip_printw color_content color_set demo_forms demo_menus demo_new_pair demo_panels dots_curses dots_xcurses dup_field echochar extended_color filter firework gdc hanoi ins_wide insdelln inserts knight move_field ncurses newdemo padview pair_content picsmap rain savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr testaddch testcurs view worm xmas
 start_color_sp			-
-stdscr				test: bs chgat clip_printw demo_altkeys demo_forms demo_menus demo_panels ditto filter firework foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts key_names keynames knight lrtest movewindow ncurses rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs testscanw view worm xmas
+stdscr				test: back_ground background bs chgat clip_printw color_content combine demo_altkeys demo_forms demo_menus demo_new_pair demo_panels ditto dup_field edit_field extended_color filter firework foldkeys form_driver_w gdc hanoi hashtest inch_wide inchs ins_wide insdelln inserts key_names keynames knight lrtest move_field movewindow ncurses padview pair_content picsmap rain redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque test_unget_wch testcurs testscanw view worm xmas
 strcodes			test: demo_termcap test_arrays progs: dump_entry
-strfnames			test: demo_terminfo test_arrays progs: dump_entry
-strnames			test: demo_termcap demo_terminfo foldkeys test_arrays progs: dump_entry infocmp tic
+strfnames			test: demo_terminfo list_keys test_arrays progs: dump_entry
+strnames			test: demo_terminfo foldkeys list_keys test_arrays test_tparm progs: dump_entry infocmp tic
 subpad				test: testcurs
 subwin				test: movewindow ncurses newdemo testcurs
 syncok				test: test_opaque
-term_attrs			test: ncurses
+term_attrs			test: ncurses test_termattrs
 term_attrs_sp			-
-termattrs			test: ncurses testcurs
+termattrs			test: ncurses test_termattrs testcurs
 termattrs_sp			lib: ncurses
-termname			test: testcurs
-termname_sp			lib: ncurses
+termname			test: list_keys ncurses testcurs
+termname_sp			test: sp_tinfo
 tgetent				test: demo_termcap dots_termcap railroad
-tgetent_sp			-
+tgetent_sp			test: sp_tinfo
 tgetflag			test: demo_termcap
-tgetflag_sp			-
+tgetflag_sp			test: sp_tinfo
 tgetnum				test: demo_termcap dots_termcap railroad
-tgetnum_sp			-
+tgetnum_sp			test: sp_tinfo
 tgetstr				test: demo_termcap dots_termcap railroad
-tgetstr_sp			-
-tgoto				test: dots_termcap railroad
-tigetflag			test: demo_terminfo progs: tic tput
-tigetflag_sp			-
-tigetnum			test: demo_terminfo ncurses progs: tput
-tigetnum_sp			-
-tigetstr			test: demo_defkey demo_terminfo foldkeys testcurs progs: clear tput
-tigetstr_sp			-
-timeout				test: rain savescreen
-tiparm				-
+tgetstr_sp			test: sp_tinfo
+tgoto				test: dots_termcap railroad test_mouse progs: tic
+tigetflag			test: demo_terminfo savescreen progs: tic tput
+tigetflag_sp			test: sp_tinfo
+tigetnum			test: demo_tabs demo_terminfo dots dots_mvcur ncurses savescreen progs: tput
+tigetnum_sp			test: sp_tinfo
+tigetstr			test: blue demo_defkey demo_new_pair demo_terminfo foldkeys list_keys savescreen test_mouse test_sgr test_tparm testcurs progs: clear_cmd tic tput
+tigetstr_sp			test: sp_tinfo
+timeout				test: filter rain savescreen
+tiparm				test: test_tparm
+tiparm_s			test: test_tparm
+tiscan_s			test: test_tparm
 touchline			test: chgat clip_printw insdelln
-touchwin			test: chgat clip_printw demo_menus edit_field filter firstlast inch_wide inchs ins_wide insdelln inserts movewindow ncurses redraw savescreen test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque xmas
-tparm				test: dots dots_mvcur progs: tabs tic tput
-tputs				test: dots dots_mvcur dots_termcap railroad test_vid_puts test_vidputs progs: clear tabs tset
-tputs_sp			lib: ncurses
-trace				test: demo_menus hashtest lrtest ncurses testcurs view worm
-ttytype				test: demo_terminfo
+touchwin			test: chgat clip_printw demo_menus filter firstlast inch_wide inchs ins_wide insdelln inserts movewindow ncurses popup_msg redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin test_get_wstr test_getstr test_instr test_inwstr test_opaque xmas
+tparm				test: dots dots_mvcur test_sgr test_tparm progs: tic tput
+tputs				test: dots dots_mvcur dots_termcap railroad test_tparm test_vid_puts test_vidputs progs: clear_cmd reset_cmd tabs
+tputs_sp			test: sp_tinfo
+trace				-
+ttytype				test: demo_terminfo test_sgr
 typeahead			test: testcurs
-typeahead_sp			lib: ncurses
-unctrl				test: ncurses redraw test_add_wchstr test_addchstr testcurs
-unctrl_sp			lib: ncurses
-unget_wch			-
+typeahead_sp			test: sp_tinfo
+unctrl				test: ncurses redraw test_add_wchstr test_addchstr test_mouse testcurs
+unctrl_sp			test: sp_tinfo
+unget_wch			test: test_unget_wch
 unget_wch_sp			-
-ungetch				test: bs knight
+ungetch				test: bs knight test_unget_wch
 ungetch_sp			lib: ncurses
-ungetmouse			-
+ungetmouse			lib: menu
 ungetmouse_sp			-
 untouchwin			lib: form
-use_default_colors		test: background filter firework gdc hanoi knight ncurses rain tclock worm xmas
+use_default_colors		test: back_ground background dots_curses dots_xcurses filter firework gdc hanoi knight ncurses picsmap rain tclock worm xmas
 use_default_colors_sp		-
-use_env				test: ncurses progs: tput
-use_env_sp			-
-use_extended_names		progs: infocmp tic
+use_env				test: dots dots_curses dots_mvcur dots_xcurses ncurses progs: clear tput
+use_env_sp			test: sp_tinfo
+use_extended_names		test: demo_termcap demo_terminfo list_keys progs: infocmp tic
 use_legacy_coding		-
 use_legacy_coding_sp		-
 use_screen			test: ditto
-use_tioctl			test: ncurses
-use_tioctl_sp			-
+use_tioctl			test: ncurses progs: clear tput
+use_tioctl_sp			test: sp_tinfo
 use_window			test: rain worm
 vid_attr			test: test_vid_puts
 vid_attr_sp			-
@@ -709,28 +744,28 @@
 vidputs_sp			-
 vline				test: gdc ncurses
 vline_set			-
-vw_printw			test: clip_printw
+vw_printw			test: clip_printw movewindow test_mouse
 vw_scanw			-
-vwprintw			test: movewindow
-vwscanw				lib: ncurses
+vwprintw			-
+vwscanw				-
 wadd_wch			test: inch_wide ncurses test_add_wchstr test_addwstr
 wadd_wchnstr			test: savescreen test_add_wchstr
 wadd_wchstr			test: test_add_wchstr
-waddch				test: demo_forms demo_panels ditto firstlast inch_wide inchs knight ncurses test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque worm
+waddch				test: demo_forms demo_panels ditto firstlast inch_wide inchs knight ncurses padview popup_msg redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque view worm
 waddchnstr			test: test_addchstr
 waddchstr			test: test_addchstr
 waddnstr			test: demo_forms test_addstr
 waddnwstr			test: ncurses test_addwstr
-waddstr				test: chgat clip_printw demo_forms demo_panels edit_field firstlast ins_wide insdelln knight ncurses redraw test_add_wchstr test_addstr test_addwstr testcurs
-waddwstr			test: ins_wide ncurses test_add_wchstr test_addwstr test_get_wstr
+waddstr				test: chgat clip_printw demo_forms demo_panels firstlast ins_wide insdelln knight ncurses popup_msg redraw test_add_wchstr test_addstr test_addwstr testcurs
+waddwstr			test: ins_wide ncurses padview test_add_wchstr test_addwstr test_get_wstr view
 wattr_get			test: ncurses
 wattr_off			lib: ncurses
 wattr_on			lib: ncurses
 wattr_set			test: ncurses
-wattroff			test: demo_forms ncurses testcurs xmas
-wattron				test: testcurs xmas
-wattrset			test: clip_printw demo_forms insdelln ncurses newdemo test_get_wstr test_getstr testcurs xmas
-wbkgd				test: cardfile demo_forms demo_menus ncurses newdemo testcurs
+wattroff			test: clip_printw demo_forms ncurses testcurs xmas
+wattron				test: clip_printw testcurs xmas
+wattrset			test: clip_printw demo_forms insdelln ncurses newdemo padview test_get_wstr test_getstr testcurs xmas
+wbkgd				test: cardfile demo_forms demo_menus ncurses newdemo padview testcurs
 wbkgdset			test: demo_panels ins_wide inserts ncurses test_add_wchstr test_addchstr test_addstr test_addwstr
 wbkgrnd				lib: ncurses
 wbkgrndset			lib: ncurses
@@ -738,7 +773,7 @@
 wborder_set			test: ncurses
 wchgat				test: chgat test_get_wstr test_getstr view
 wclear				test: ncurses test_opaque testcurs
-wclrtobot			test: firstlast inch_wide inchs ncurses test_instr test_inwstr testcurs
+wclrtobot			test: firstlast inch_wide inchs ncurses test_delwin test_instr test_inwstr testcurs
 wclrtoeol			test: chgat clip_printw demo_defkey demo_keyok demo_menus demo_panels firstlast inch_wide inchs ins_wide insdelln inserts knight ncurses test_add_wchstr test_addchstr test_addstr test_addwstr test_instr test_inwstr testcurs
 wcolor_set			lib: ncurses
 wcursyncup			lib: form
@@ -747,12 +782,12 @@
 wecho_wchar			lib: ncurses
 wechochar			lib: ncurses
 wenclose			test: ncurses
-werase				test: cardfile demo_forms demo_menus demo_panels edit_field firstlast knight ncurses newdemo test_get_wstr test_getstr test_opaque testcurs xmas
+werase				test: cardfile demo_forms demo_menus demo_panels dup_field firstlast knight move_field ncurses newdemo popup_msg test_get_wstr test_getstr test_opaque testcurs view xmas
 wget_wch			test: ins_wide ncurses test_add_wchstr test_addwstr
 wget_wstr			test: test_get_wstr
 wgetbkgrnd			lib: ncurses
-wgetch				test: cardfile chgat clip_printw demo_defkey demo_keyok demo_menus demo_panels ditto edit_field gdc insdelln inserts knight movewindow ncurses newdemo rain redraw savescreen test_addchstr test_addstr test_opaque testcurs worm
-wgetdelay			-
+wgetch				test: cardfile chgat clip_printw demo_defkey demo_keyok demo_menus demo_panels ditto dump_window dup_field edit_field gdc insdelln inserts knight move_field movewindow ncurses newdemo popup_msg rain redraw test_addchstr test_addstr test_delwin test_opaque testcurs worm
+wgetdelay			test: test_opaque
 wgetn_wstr			test: ncurses test_get_wstr
 wgetnstr			test: ncurses test_getstr
 wgetparent			test: test_opaque
@@ -761,7 +796,7 @@
 whline				test: testcurs
 whline_set			lib: ncurses
 win_wch				test: inch_wide savescreen
-win_wchnstr			test: inch_wide
+win_wchnstr			test: inch_wide view
 win_wchstr			test: inch_wide
 winch				test: inchs knight testcurs
 winchnstr			test: inchs
@@ -779,15 +814,15 @@
 winstr				test: test_instr
 winwstr				test: test_inwstr
 wmouse_trafo			test: ncurses
-wmove				test: chgat clip_printw demo_altkeys demo_defkey demo_keyok demo_menus demo_panels firstlast foldkeys inch_wide inchs ins_wide insdelln inserts knight movewindow ncurses newdemo redraw savescreen test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs worm
-wnoutrefresh			test: demo_menus ditto edit_field inch_wide inchs ins_wide inserts knight movewindow ncurses redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque
-wprintw				test: chgat clip_printw demo_defkey demo_forms demo_keyok demo_menus demo_panels edit_field inch_wide inchs ins_wide insdelln inserts knight movewindow ncurses savescreen test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque testcurs
+wmove				test: chgat clip_printw demo_altkeys demo_defkey demo_keyok demo_menus demo_panels dump_window extended_color firstlast foldkeys inch_wide inchs ins_wide insdelln inserts knight movewindow ncurses newdemo padview picsmap redraw savescreen test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque testcurs view worm
+wnoutrefresh			test: demo_menus ditto inch_wide inchs ins_wide inserts knight movewindow ncurses padview popup_msg redraw test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_opaque
+wprintw				test: chgat clip_printw demo_defkey demo_forms demo_keyok demo_menus demo_panels inch_wide inchs ins_wide insdelln inserts knight ncurses test_add_wchstr test_addchstr test_addstr test_addwstr test_get_wstr test_getstr test_instr test_inwstr test_mouse test_opaque testcurs
 wredrawln			test: redraw
-wrefresh			test: chgat clip_printw demo_forms demo_keyok demo_menus demo_panels edit_field firstlast ins_wide insdelln inserts knight lrtest movewindow ncurses newdemo redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr testcurs view worm xmas
-wresize				test: cardfile ncurses
+wrefresh			test: chgat clip_printw demo_forms demo_keyok demo_menus demo_panels dup_field firstlast ins_wide insdelln inserts knight lrtest move_field movewindow ncurses newdemo popup_msg redraw savescreen tclock test_add_wchstr test_addchstr test_addstr test_addwstr test_delwin testcurs worm xmas
+wresize				test: cardfile demo_menus ncurses
 wscanw				test: testcurs
 wscrl				test: ncurses testcurs
-wsetscrreg			test: ncurses testcurs
+wsetscrreg			test: ncurses test_delwin testcurs
 wstandend			test: ncurses test_opaque xmas
 wstandout			test: ncurses test_opaque xmas
 wsyncdown			test: movewindow
@@ -819,3 +854,5 @@
 top_panel			test: cardfile demo_panels ncurses
 update_panels			test: cardfile demo_panels ncurses
 update_panels_sp		-
+
+-- vile:txtmode
diff --git a/test/aclocal.m4 b/test/aclocal.m4
index 0ea83b5..fdab359 100644
--- a/test/aclocal.m4
+++ b/test/aclocal.m4
@@ -1,5 +1,6 @@
 dnl***************************************************************************
-dnl Copyright (c) 2003-2014,2015 Free Software Foundation, Inc.              *
+dnl Copyright 2018-2023,2024 Thomas E. Dickey                                *
+dnl Copyright 2003-2017,2018 Free Software Foundation, Inc.                  *
 dnl                                                                          *
 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
 dnl copy of this software and associated documentation files (the            *
@@ -26,7 +27,7 @@
 dnl authorization.                                                           *
 dnl***************************************************************************
 dnl
-dnl $Id: aclocal.m4,v 1.120 2015/08/08 14:27:27 tom Exp $
+dnl $Id: aclocal.m4,v 1.221 2024/01/19 18:27:20 tom Exp $
 dnl
 dnl Author: Thomas E. Dickey
 dnl
@@ -36,10 +37,37 @@
 dnl this file applies to the aggregation of macros and does not affect use of
 dnl these macros in other applications.
 dnl
-dnl See http://invisible-island.net/autoconf/ for additional information.
+dnl See these pages for additional information:
+dnl		https://invisible-island.net/autoconf/
+dnl		https://invisible-island.net/autoconf/my-autoconf.html
 dnl
 dnl ---------------------------------------------------------------------------
 dnl ---------------------------------------------------------------------------
+dnl AM_LANGINFO_CODESET version: 7 updated: 2023/01/11 04:05:23
+dnl -------------------
+dnl Inserted as requested by gettext 0.10.40
+dnl File from /usr/share/aclocal
+dnl codeset.m4
+dnl ====================
+dnl serial AM1
+dnl
+dnl From Bruno Haible.
+AC_DEFUN([AM_LANGINFO_CODESET],
+[
+AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
+	[AC_TRY_LINK([
+$ac_includes_default
+#include <langinfo.h>],
+	[char* cs = nl_langinfo(CODESET); (void)cs],
+	am_cv_langinfo_codeset=yes,
+	am_cv_langinfo_codeset=no)
+	])
+	if test "$am_cv_langinfo_codeset" = yes; then
+		AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
+		[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
+	fi
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49
 dnl ------------------
 dnl Conditionally generate script according to whether we're using a given autoconf.
@@ -66,10 +94,11 @@
 [ifelse([$8], , ,[$8])],
 [ifelse([$9], , ,[$9])])])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_ADD_CFLAGS version: 12 updated: 2015/04/12 15:39:00
+dnl CF_ADD_CFLAGS version: 15 updated: 2020/12/31 10:54:15
 dnl -------------
 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
-dnl The second parameter if given makes this macro verbose.
+dnl $1 = flags to add
+dnl $2 = if given makes this macro verbose.
 dnl
 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
@@ -83,23 +112,23 @@
 
 for cf_add_cflags in $1
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
 				continue
 			fi
 			;;
@@ -108,25 +137,25 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+			CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+		CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+	CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[[^"]]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -137,26 +166,26 @@
 
 if test -n "$cf_new_cflags" ; then
 	ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	CF_APPEND_TEXT(CFLAGS,$cf_new_cflags)
 fi
 
 if test -n "$cf_new_cppflags" ; then
 	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags)
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 	ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags)
 fi
 
 AC_SUBST(EXTRA_CPPFLAGS)
 
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_ADD_INCDIR version: 14 updated: 2015/05/25 20:53:04
+dnl CF_ADD_INCDIR version: 17 updated: 2021/09/04 06:35:04
 dnl -------------
-dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
+dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it is
 dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
 dnl but old versions (and some misinstalled ones) need that.  To make things
 dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
@@ -166,9 +195,9 @@
 if test -n "$1" ; then
   for cf_add_incdir in $1
   do
-	while test $cf_add_incdir != /usr/include
+	while test "$cf_add_incdir" != /usr/include
 	do
-	  if test -d $cf_add_incdir
+	  if test -d "$cf_add_incdir"
 	  then
 		cf_have_incdir=no
 		if test -n "$CFLAGS$CPPFLAGS" ; then
@@ -185,7 +214,7 @@
 			if test "$GCC" = yes
 			then
 			  cf_save_CPPFLAGS=$CPPFLAGS
-			  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+			  CF_APPEND_TEXT(CPPFLAGS,-I$cf_add_incdir)
 			  AC_TRY_COMPILE([#include <stdio.h>],
 				  [printf("Hello")],
 				  [],
@@ -199,7 +228,7 @@
 		  CF_VERBOSE(adding $cf_add_incdir to include-path)
 		  ifelse([$2],,CPPFLAGS,[$2])="$ifelse([$2],,CPPFLAGS,[$2]) -I$cf_add_incdir"
 
-		  cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
+		  cf_top_incdir=`echo "$cf_add_incdir" | sed -e 's%/include/.*$%/include%'`
 		  test "$cf_top_incdir" = "$cf_add_incdir" && break
 		  cf_add_incdir="$cf_top_incdir"
 		else
@@ -221,7 +250,7 @@
 dnl $2 = variable to update (default $LIBS)
 AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_ADD_LIBDIR version: 10 updated: 2015/04/18 08:56:57
+dnl CF_ADD_LIBDIR version: 11 updated: 2020/12/31 20:19:42
 dnl -------------
 dnl	Adds to the library-path
 dnl
@@ -235,9 +264,9 @@
 if test -n "$1" ; then
 	for cf_add_libdir in $1
 	do
-		if test $cf_add_libdir = /usr/lib ; then
+		if test "$cf_add_libdir" = /usr/lib ; then
 			:
-		elif test -d $cf_add_libdir
+		elif test -d "$cf_add_libdir"
 		then
 			cf_have_libdir=no
 			if test -n "$LDFLAGS$LIBS" ; then
@@ -257,7 +286,7 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_ADD_LIBS version: 2 updated: 2014/07/13 14:33:27
+dnl CF_ADD_LIBS version: 3 updated: 2019/11/02 16:47:33
 dnl -----------
 dnl Add one or more libraries, used to enforce consistency.  Libraries are
 dnl prepended to an existing list, since their dependencies are assumed to
@@ -266,19 +295,19 @@
 dnl $1 = libraries to add, with the "-l", etc.
 dnl $2 = variable to update (default $LIBS)
 AC_DEFUN([CF_ADD_LIBS],[
-cf_add_libs="$1"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in [$]ifelse($2,,LIBS,[$2])
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="[$]ifelse($2,,LIBS,[$2])"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $1; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 ifelse($2,,LIBS,[$2])="$cf_add_libs"
 ])dnl
@@ -296,7 +325,7 @@
 CF_VERBOSE(...after  $LIBS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_ADD_SUBDIR_PATH version: 4 updated: 2013/10/08 17:47:05
+dnl CF_ADD_SUBDIR_PATH version: 5 updated: 2020/12/31 20:19:42
 dnl ------------------
 dnl Append to a search-list for a nonstandard header/lib-file
 dnl	$1 = the variable to return as result
@@ -308,16 +337,45 @@
 [
 test "x$4" != "x$5" && \
 test -d "$4" && \
-ifelse([$5],NONE,,[(test -z "$5" || test x$5 = xNONE || test "x$4" != "x$5") &&]) {
+ifelse([$5],NONE,,[{ test -z "$5" || test "x$5" = xNONE || test "x$4" != "x$5"; } &&]) {
 	test -n "$verbose" && echo "	... testing for $3-directories under $4"
-	test -d $4/$3 &&          $1="[$]$1 $4/$3"
-	test -d $4/$3/$2 &&       $1="[$]$1 $4/$3/$2"
-	test -d $4/$3/$2/$3 &&    $1="[$]$1 $4/$3/$2/$3"
-	test -d $4/$2/$3 &&       $1="[$]$1 $4/$2/$3"
-	test -d $4/$2/$3/$2 &&    $1="[$]$1 $4/$2/$3/$2"
+	test -d "$4/$3" &&          $1="[$]$1 $4/$3"
+	test -d "$4/$3/$2" &&       $1="[$]$1 $4/$3/$2"
+	test -d "$4/$3/$2/$3" &&    $1="[$]$1 $4/$3/$2/$3"
+	test -d "$4/$2/$3" &&       $1="[$]$1 $4/$2/$3"
+	test -d "$4/$2/$3/$2" &&    $1="[$]$1 $4/$2/$3/$2"
 }
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_APPEND_CFLAGS version: 3 updated: 2021/09/05 17:25:40
+dnl ----------------
+dnl Use CF_ADD_CFLAGS after first checking for potential redefinitions.
+dnl $1 = flags to add
+dnl $2 = if given makes this macro verbose.
+define([CF_APPEND_CFLAGS],
+[
+for cf_add_cflags in $1
+do
+	case "x$cf_add_cflags" in
+	(x-[[DU]]*)
+		CF_REMOVE_CFLAGS($cf_add_cflags,CFLAGS,[$2])
+		CF_REMOVE_CFLAGS($cf_add_cflags,CPPFLAGS,[$2])
+		;;
+	esac
+	CF_ADD_CFLAGS([$cf_add_cflags],[$2])
+done
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
+dnl --------------
+dnl use this macro for appending text without introducing an extra blank at
+dnl the beginning
+define([CF_APPEND_TEXT],
+[
+	test -n "[$]$1" && $1="[$]$1 "
+	$1="[$]{$1}$2"
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
 dnl --------------
 dnl Allow user to disable a normally-on option.
@@ -353,25 +411,101 @@
 ])dnl
 ])])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CC_ENV_FLAGS version: 2 updated: 2015/04/12 15:39:00
+dnl CF_C11_NORETURN version: 4 updated: 2023/02/18 17:41:25
+dnl ---------------
+AC_DEFUN([CF_C11_NORETURN],
+[
+AC_MSG_CHECKING(if you want to use C11 _Noreturn feature)
+CF_ARG_ENABLE(stdnoreturn,
+	[  --enable-stdnoreturn    enable C11 _Noreturn feature for diagnostics],
+	[enable_stdnoreturn=yes],
+	[enable_stdnoreturn=no])
+AC_MSG_RESULT($enable_stdnoreturn)
+
+if test $enable_stdnoreturn = yes; then
+AC_CACHE_CHECK([for C11 _Noreturn feature], cf_cv_c11_noreturn,
+	[AC_TRY_COMPILE([
+$ac_includes_default
+#include <stdnoreturn.h>
+static _Noreturn void giveup(void) { exit(0); }
+	],
+	[if (feof(stdin)) giveup()],
+	cf_cv_c11_noreturn=yes,
+	cf_cv_c11_noreturn=no)
+	])
+else
+	cf_cv_c11_noreturn=no,
+fi
+
+if test "$cf_cv_c11_noreturn" = yes; then
+	AC_DEFINE(HAVE_STDNORETURN_H, 1,[Define if <stdnoreturn.h> header is available and working])
+	AC_DEFINE_UNQUOTED(STDC_NORETURN,_Noreturn,[Define if C11 _Noreturn keyword is supported])
+	HAVE_STDNORETURN_H=1
+else
+	HAVE_STDNORETURN_H=0
+fi
+
+AC_SUBST(HAVE_STDNORETURN_H)
+AC_SUBST(STDC_NORETURN)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_CC_ENV_FLAGS version: 11 updated: 2023/02/20 11:15:46
 dnl ---------------
 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
-dnl into CC.  This will not help with broken scripts that wrap the compiler with
-dnl options, but eliminates a more common category of user confusion.
+dnl into CC.  This will not help with broken scripts that wrap the compiler
+dnl with options, but eliminates a more common category of user confusion.
+dnl
+dnl In particular, it addresses the problem of being able to run the C
+dnl preprocessor in a consistent manner.
+dnl
+dnl Caveat: this also disallows blanks in the pathname for the compiler, but
+dnl the nuisance of having inconsistent settings for compiler and preprocessor
+dnl outweighs that limitation.
 AC_DEFUN([CF_CC_ENV_FLAGS],
 [
 # This should have been defined by AC_PROG_CC
-: ${CC:=cc}
+: "${CC:=cc}"
+
+AC_MSG_CHECKING(\$CFLAGS variable)
+case "x$CFLAGS" in
+(*-[[IUD]]*)
+	AC_MSG_RESULT(broken)
+	AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
+	cf_flags="$CFLAGS"
+	CFLAGS=
+	for cf_arg in $cf_flags
+	do
+		CF_ADD_CFLAGS($cf_arg)
+	done
+	;;
+(*)
+	AC_MSG_RESULT(ok)
+	;;
+esac
 
 AC_MSG_CHECKING(\$CC variable)
 case "$CC" in
-(*[[\ \	]]-[[IUD]]*)
+(*[[\ \	]]-*)
 	AC_MSG_RESULT(broken)
-	AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
+	AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
 	# humor him...
-	cf_flags=`echo "$CC" | sed -e 's/^[[^ 	]]*[[ 	]]//'`
-	CC=`echo "$CC" | sed -e 's/[[ 	]].*//'`
-	CF_ADD_CFLAGS($cf_flags)
+	cf_prog=`echo "$CC" | sed -e 's/	/ /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
+	cf_flags=`echo "$CC" | sed -e "s%^$cf_prog%%"`
+	CC="$cf_prog"
+	for cf_arg in $cf_flags
+	do
+		case "x$cf_arg" in
+		(x-[[IUDfgOW]]*)
+			CF_ADD_CFLAGS($cf_arg)
+			;;
+		(*)
+			CC="$CC $cf_arg"
+			;;
+		esac
+	done
+	CF_VERBOSE(resulting CC: '$CC')
+	CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
+	CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
 	;;
 (*)
 	AC_MSG_RESULT(ok)
@@ -379,7 +513,7 @@
 esac
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
+dnl CF_CHECK_CACHE version: 13 updated: 2020/12/31 10:54:15
 dnl --------------
 dnl Check if we're accidentally using a cache from a different machine.
 dnl Derive the system name, as a check for reusing the autoconf cache.
@@ -393,7 +527,7 @@
 dnl autoconf 2.5x broke compatibility with autoconf 2.13
 AC_DEFUN([CF_CHECK_CACHE],
 [
-if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
+if test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then
 	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
 	system_name="$host_os"
 else
@@ -414,7 +548,7 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CHECK_CFLAGS version: 3 updated: 2014/07/22 05:32:57
+dnl CF_CHECK_CFLAGS version: 4 updated: 2021/01/02 19:22:58
 dnl ---------------
 dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
 dnl a build-configuration such as imake.  These have the pitfall that they
@@ -432,24 +566,70 @@
 	 if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
 		 CF_VERBOSE(but keeping change to \$CPPFLAGS)
 	 fi
-	 CFLAGS="$cf_check_flags"])
+	 CFLAGS="$cf_check_cflags"])
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CHECK_CURSES_LIB version: 1 updated: 2015/04/25 20:53:11
+dnl CF_CHECK_CURSES_LIB version: 4 updated: 2021/09/05 17:25:40
 dnl -------------------
 dnl $1 = nominal library name, used also for header lookup
 dnl $2 = suffix to append to library name
 dnl $3 = function to check for using AC_CHECK_LIB
+dnl $4 = optional parameter list for $3
 AC_DEFUN([CF_CHECK_CURSES_LIB],
 [
-AC_CHECK_LIB($1$2,$3,[
-CF_UPPER(cf_upper,have_lib$1)
-CF_ADD_LIBS(-l$1$2)
-AC_DEFINE_UNQUOTED($cf_upper,1)])
+AC_REQUIRE([CF_PKG_CONFIG])
+
+cf_have_curses_lib=no
+
+: ${NCURSES_CONFIG_PKG:=none}
+if test "x${NCURSES_CONFIG_PKG}" = xnone; then
+	:
+elif test "x${PKG_CONFIG:=none}" != xnone; then
+	AC_MSG_CHECKING(pkg-config for $1$2)
+	if "$PKG_CONFIG" --exists "$1$2" ; then
+		AC_MSG_RESULT(yes)
+
+		AC_MSG_CHECKING(if the $1$2 package files work)
+
+		cf_save_CFLAGS="$CFLAGS"
+		cf_save_CPPFLAGS="$CPPFLAGS"
+		cf_save_LIBS="$LIBS"
+
+		CF_APPEND_CFLAGS(`$PKG_CONFIG --cflags "$1$2"`)
+		CF_ADD_LIBS(`$PKG_CONFIG --libs "$1$2"`)
+
+		AC_TRY_LINK([#include <$1.h>],
+			[(void) $3 ( ]ifelse([$4],,,[[$4]])[ );],
+			[AC_TRY_RUN([#include <$1.h>
+				int main(void)
+				{ (void) $3 ( ]ifelse([$4],,,[[$4]])[ ); return 0; }],
+				[cf_have_curses_lib=yes],
+				[cf_have_curses_lib=no],
+				[cf_have_curses_lib=maybe])],
+			[cf_have_curses_lib=no])
+		AC_MSG_RESULT($cf_have_curses_lib)
+		test "$cf_have_curses_lib" = maybe && cf_have_curses_lib=yes
+		if test "$cf_have_curses_lib" = "yes"
+		then
+			CF_UPPER(cf_upper,have_lib$1)
+			AC_DEFINE_UNQUOTED($cf_upper,1)
+		else
+			CFLAGS="$cf_save_CFLAGS"
+			CPPFLAGS="$cf_save_CPPFLAGS"
+			LIBS="$cf_save_LIBS"
+		fi
+	fi
+fi
+if test "$cf_have_curses_lib" = no; then
+	AC_CHECK_LIB($1$2,$3,[
+		CF_UPPER(cf_upper,have_lib$1)
+		CF_ADD_LIBS(-l$1$2)
+		AC_DEFINE_UNQUOTED($cf_upper,1)])
+fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CLANG_COMPILER version: 2 updated: 2013/11/19 19:23:35
+dnl CF_CLANG_COMPILER version: 9 updated: 2023/02/18 17:41:25
 dnl -----------------
 dnl Check if the given compiler is really clang.  clang's C driver defines
 dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
@@ -468,21 +648,117 @@
 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
 	AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
 	cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
-	ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
 	AC_TRY_COMPILE([],[
 #ifdef __clang__
 #else
-make an error
+#error __clang__ is not defined
 #endif
 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
-cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
 ],[])
 	ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
 	AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
 fi
+
+CLANG_VERSION=none
+
+if test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then
+	case "$CC" in
+	(c[[1-9]][[0-9]]|*/c[[1-9]][[0-9]])
+		AC_MSG_WARN(replacing broken compiler alias $CC)
+		CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`"
+		CC=clang
+		;;
+	esac
+
+	AC_MSG_CHECKING(version of $CC)
+	CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
+	test -z "$CLANG_VERSION" && CLANG_VERSION=unknown
+	AC_MSG_RESULT($CLANG_VERSION)
+
+	for cf_clang_opt in \
+		-Qunused-arguments \
+		-Wno-error=implicit-function-declaration
+	do
+		AC_MSG_CHECKING(if option $cf_clang_opt works)
+		cf_save_CFLAGS="$CFLAGS"
+		CFLAGS="$CFLAGS $cf_clang_opt"
+		AC_TRY_LINK([
+			#include <stdio.h>],[
+			printf("hello!\\n");],[
+			cf_clang_optok=yes],[
+			cf_clang_optok=no])
+		AC_MSG_RESULT($cf_clang_optok)
+		CFLAGS="$cf_save_CFLAGS"
+		if test "$cf_clang_optok" = yes; then
+			CF_VERBOSE(adding option $cf_clang_opt)
+			CF_APPEND_TEXT(CFLAGS,$cf_clang_opt)
+		fi
+	done
+fi
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_CURSES_ACS_MAP version: 7 updated: 2012/10/06 16:39:58
+dnl CF_CONST_X_STRING version: 8 updated: 2023/12/01 17:22:50
+dnl -----------------
+dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
+dnl character-strings.
+dnl
+dnl It is ambiguous because the specification accommodated the pre-ANSI
+dnl compilers bundled by more than one vendor in lieu of providing a standard C
+dnl compiler other than by costly add-ons.  Because of this, the specification
+dnl did not take into account the use of const for telling the compiler that
+dnl string literals would be in readonly memory.
+dnl
+dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
+dnl let the compiler decide how to represent Xt's strings which were #define'd.
+dnl That does not solve the problem of using the block of Xt's strings which
+dnl are compiled into the library (and is less efficient than one might want).
+dnl
+dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
+dnl when compiling the library and compiling using the library, to tell the
+dnl compiler that String is const.
+AC_DEFUN([CF_CONST_X_STRING],
+[
+AC_REQUIRE([AC_PATH_XTRA])
+
+CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
+
+AC_TRY_COMPILE(
+[
+#include <stdlib.h>
+#include <X11/Intrinsic.h>
+],
+[String foo = malloc(1); free((void*)foo)],[
+
+AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
+	AC_TRY_COMPILE(
+		[
+#undef  _CONST_X_STRING
+#define _CONST_X_STRING	/* X11R7.8 (perhaps) */
+#undef  XTSTRINGDEFINES	/* X11R5 and later */
+#include <stdlib.h>
+#include <X11/Intrinsic.h>
+		],[String foo = malloc(1); *foo = 0],[
+			cf_cv_const_x_string=no
+		],[
+			cf_cv_const_x_string=yes
+		])
+])
+
+CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
+
+case "$cf_cv_const_x_string" in
+(no)
+	CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
+	;;
+(*)
+	CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
+	;;
+esac
+
+])
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_CURSES_ACS_MAP version: 8 updated: 2021/01/04 19:45:09
 dnl -----------------
 dnl Check for likely values of acs_map[]:
 AC_DEFUN([CF_CURSES_ACS_MAP],
@@ -495,7 +771,7 @@
 AC_TRY_LINK([
 #include <${cf_cv_ncurses_header:-curses.h}>
 ],[
-$name['k'] = ACS_PLUS
+${name}['k'] = ACS_PLUS
 ],[cf_cv_curses_acs_map=$name; break])
 done
 ])
@@ -503,53 +779,61 @@
 test "$cf_cv_curses_acs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_ACS_ARRAY,$cf_cv_curses_acs_map,[Define as needed to override ncurses prefix _nc_])
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_CURSES_CHECK_DATA version: 5 updated: 2014/07/19 18:41:17
+dnl CF_CURSES_CHECK_DATA version: 10 updated: 2021/01/04 19:45:09
 dnl --------------------
 dnl Check if curses.h defines the given data/variable.
 dnl Use this after CF_NCURSES_CONFIG or CF_CURSES_CONFIG.
+dnl
+dnl $1 = data item(s) to check for
+dnl $2 = action on success, e.g., "break" to quit checking a series of choices
 AC_DEFUN([CF_CURSES_CHECK_DATA],
 [
-AC_MSG_CHECKING(for data $1 declaration in ${cf_cv_ncurses_header:-curses.h})
+for cf_data in $1
+do
+AC_MSG_CHECKING(for data $cf_data declaration in ${cf_cv_ncurses_header:-curses.h})
 
-AC_TRY_COMPILE(CF__CURSES_HEAD,[
-void *foo = &($1)
-],cf_result=yes,cf_result=no)
+AC_TRY_COMPILE(CF__CURSES_HEAD,
+CF__CURSES_DATA(foo,$cf_data)
+,[cf_result=yes
+],[cf_result=no])
 AC_MSG_RESULT($cf_result)
 
-if test $cf_result = yes ; then
-	CF_UPPER(cf_result,have_curses_data_$1)
+if test "$cf_result" = yes ; then
+	CF_UPPER(cf_result,have_curses_data_$cf_data)
 	AC_DEFINE_UNQUOTED($cf_result)
+	ifelse($2,,,[$2])
 else
-	AC_MSG_CHECKING(for data $1 in library)
+	AC_MSG_CHECKING(for data $cf_data in library)
 	# BSD linkers insist on making weak linkage, but resolve at runtime.
 	AC_TRY_RUN(CF__CURSES_HEAD
 [
-extern char $1;
+extern char $cf_data;
 int main(void)
 {
-	void *foo = &($1);
-	fprintf(stderr, "testing linkage of $1:%p\n", foo);
+	]CF__CURSES_DATA(foo,$cf_data)[
 	${cf_cv_main_return:-return}(foo == 0);
-}],[cf_result=yes],[cf_result=no],[
+}],[cf_result=yes
+],[cf_result=no],[
 	# cross-compiling
 	AC_TRY_LINK(CF__CURSES_HEAD
-[extern char $1;],[
+[extern char $cf_data;],[
 	do {
-		void *foo = &($1);
-		fprintf(stderr, "testing linkage of $1:%p\n", foo);
+		]CF__CURSES_DATA(foo,$cf_data)[
 		${cf_cv_main_return:-return}(foo == 0);
 	} while (0)
 ],[cf_result=yes],[cf_result=no])
 ])
 	AC_MSG_RESULT($cf_result)
-	if test $cf_result = yes ; then
-		CF_UPPER(cf_result,decl_curses_data_$1)
+	if test "$cf_result" = yes ; then
+		CF_UPPER(cf_result,decl_curses_data_$cf_data)
 		AC_DEFINE_UNQUOTED($cf_result)
+		# do not exit loop here, since we prefer system's declarations
 	fi
 fi
+done
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CURSES_CHECK_TYPE version: 4 updated: 2012/10/06 16:39:58
+dnl CF_CURSES_CHECK_TYPE version: 5 updated: 2021/01/04 19:45:09
 dnl --------------------
 dnl Check if curses.h defines the given type
 AC_DEFUN([CF_CURSES_CHECK_TYPE],
@@ -563,7 +847,7 @@
 $1 foo
 ],cf_result=yes,cf_result=no)
 AC_MSG_RESULT($cf_result)
-if test $cf_result = yes ; then
+if test "$cf_result" = yes ; then
 	CF_UPPER(cf_result,have_type_$1)
 	AC_DEFINE_UNQUOTED($cf_result,1,[Define to 1 if we have type $1])
 else
@@ -583,14 +867,14 @@
 CF_CURSES_LIBS
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CURSES_CPPFLAGS version: 12 updated: 2015/04/15 19:08:48
+dnl CF_CURSES_CPPFLAGS version: 14 updated: 2021/01/02 09:31:20
 dnl ------------------
 dnl Look for the curses headers.
 AC_DEFUN([CF_CURSES_CPPFLAGS],[
 
 AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
 cf_cv_curses_incdir=no
-case $host_os in
+case "$host_os" in
 (hpux10.*)
 	if test "x$cf_cv_screen" = "xcurses_colr"
 	then
@@ -608,13 +892,16 @@
 	;;
 esac
 ])
-test "$cf_cv_curses_incdir" != no && CPPFLAGS="$CPPFLAGS $cf_cv_curses_incdir"
+if test "$cf_cv_curses_incdir" != no
+then
+	CF_APPEND_TEXT(CPPFLAGS,$cf_cv_curses_incdir)
+fi
 
 CF_CURSES_HEADER
 CF_TERM_HEADER
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CURSES_FUNCS version: 18 updated: 2014/07/19 18:44:41
+dnl CF_CURSES_FUNCS version: 20 updated: 2020/12/31 20:19:42
 dnl ---------------
 dnl Curses-functions are a little complicated, since a lot of them are macros.
 AC_DEFUN([CF_CURSES_FUNCS],
@@ -635,26 +922,26 @@
 			[
 #ifndef ${cf_func}
 long foo = (long)(&${cf_func});
-fprintf(stderr, "testing linkage of $cf_func:%p\n", foo);
-if (foo + 1234 > 5678)
-	${cf_cv_main_return:-return}(foo);
+fprintf(stderr, "testing linkage of $cf_func:%p\\n", (void *)foo);
+if (foo + 1234L > 5678L)
+	${cf_cv_main_return:-return}(foo != 0);
 #endif
 			],
 			[cf_result=yes],
 			[cf_result=no])
 		fi
-		eval 'cf_cv_func_'$cf_func'=$cf_result'
+		eval 'cf_cv_func_'$cf_func'="$cf_result"'
 	])
 	# use the computed/retrieved cache-value:
 	eval 'cf_result=$cf_cv_func_'$cf_func
 	AC_MSG_RESULT($cf_result)
-	if test $cf_result != no; then
+	if test "$cf_result" != no; then
 		AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func})
 	fi
 done
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CURSES_HEADER version: 5 updated: 2015/04/23 20:35:30
+dnl CF_CURSES_HEADER version: 6 updated: 2022/12/02 20:06:52
 dnl ----------------
 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
 dnl variations of ncurses' installs.
@@ -668,7 +955,7 @@
 	curses.h ifelse($1,,,[$1/curses.h]) ifelse($1,,[ncurses/ncurses.h ncurses/curses.h])
 do
 AC_TRY_COMPILE([#include <${cf_header}>],
-	[initscr(); tgoto("?", 0,0)],
+	[initscr(); endwin()],
 	[cf_cv_ncurses_header=$cf_header; break],[])
 done
 ])
@@ -681,7 +968,7 @@
 AC_CHECK_HEADERS($cf_cv_ncurses_header)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CURSES_LIBS version: 39 updated: 2015/05/10 19:52:14
+dnl CF_CURSES_LIBS version: 45 updated: 2022/12/02 20:06:52
 dnl --------------
 dnl Look for the curses libraries.  Older curses implementations may require
 dnl termcap/termlib to be linked as well.  Call CF_CURSES_CPPFLAGS first.
@@ -690,13 +977,13 @@
 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
 AC_MSG_CHECKING(if we have identified curses libraries)
 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
-	[initscr(); tgoto("?", 0,0)],
+	[initscr(); endwin()],
 	cf_result=yes,
 	cf_result=no)
 AC_MSG_RESULT($cf_result)
 
 if test "$cf_result" = no ; then
-case $host_os in
+case "$host_os" in
 (freebsd*)
 	AC_CHECK_LIB(mytinfo,tgoto,[CF_ADD_LIBS(-lmytinfo)])
 	;;
@@ -714,7 +1001,7 @@
 		AC_CHECK_LIB(Hcurses,initscr,[
 			# HP's header uses __HP_CURSES, but user claims _HP_CURSES.
 			CF_ADD_LIBS(-lHcurses)
-			CPPFLAGS="$CPPFLAGS -D__HP_CURSES -D_HP_CURSES"
+			CF_APPEND_TEXT(CPPFLAGS,-D__HP_CURSES -D_HP_CURSES)
 			ac_cv_func_initscr=yes
 			])])
 	fi
@@ -763,7 +1050,10 @@
 		AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
 			for cf_term_lib in $cf_check_list otermcap termcap tinfo termlib unknown
 			do
-				AC_CHECK_LIB($cf_term_lib,tgoto,[break])
+				AC_CHECK_LIB($cf_term_lib,tgoto,[
+					: "${cf_nculib_root:=$cf_term_lib}"
+					break
+				])
 			done
 		])
 	fi
@@ -774,42 +1064,41 @@
 	then
 		for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
 		do
-			AC_CHECK_LIB($cf_curs_lib,initscr,[break])
+			LIBS="-l$cf_curs_lib $cf_save_LIBS"
+			if test "$cf_term_lib" = unknown || test "$cf_term_lib" = "$cf_curs_lib" ; then
+				AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
+				AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
+					[initscr()],
+					[cf_result=yes],
+					[cf_result=no])
+				AC_MSG_RESULT($cf_result)
+				test "$cf_result" = yes && break
+			elif test "$cf_curs_lib" = "$cf_term_lib" ; then
+				cf_result=no
+			elif test "$cf_term_lib" != predefined ; then
+				AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
+				AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
+					[initscr(); endwin();],
+					[cf_result=no],
+					[
+					LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
+					AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
+						[initscr()],
+						[cf_result=yes],
+						[cf_result=error])
+					])
+				AC_MSG_RESULT($cf_result)
+				test "$cf_result" != error && break
+			fi
 		done
 	fi
-	test $cf_curs_lib = unknown && AC_MSG_ERROR(no curses library found)
-
-	LIBS="-l$cf_curs_lib $cf_save_LIBS"
-	if test "$cf_term_lib" = unknown ; then
-		AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
-		AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
-			[initscr()],
-			[cf_result=yes],
-			[cf_result=no])
-		AC_MSG_RESULT($cf_result)
-		test $cf_result = no && AC_MSG_ERROR(Cannot link curses library)
-	elif test "$cf_curs_lib" = "$cf_term_lib" ; then
-		:
-	elif test "$cf_term_lib" != predefined ; then
-		AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
-		AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
-			[initscr(); tgoto((char *)0, 0, 0);],
-			[cf_result=no],
-			[
-			LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
-			AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
-				[initscr()],
-				[cf_result=yes],
-				[cf_result=error])
-			])
-		AC_MSG_RESULT($cf_result)
-	fi
+	test "$cf_curs_lib" = unknown && AC_MSG_ERROR(no curses library found)
 fi
 fi
 
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CURSES_TERM_H version: 11 updated: 2015/04/15 19:08:48
+dnl CF_CURSES_TERM_H version: 16 updated: 2024/01/07 06:34:16
 dnl ----------------
 dnl SVr4 curses should have term.h as well (where it puts the definitions of
 dnl the low-level interface).  This may not be true in old/broken implementations,
@@ -826,9 +1115,9 @@
 
 cf_header_list="term.h ncurses/term.h ncursesw/term.h"
 
-case ${cf_cv_ncurses_header:-curses.h} in
+case "${cf_cv_ncurses_header:-curses.h}" in
 (*/*)
-	cf_header_item=`echo ${cf_cv_ncurses_header:-curses.h} | sed -e 's%\..*%%' -e 's%/.*%/%'`term.h
+	cf_header_item=`echo "${cf_cv_ncurses_header:-curses.h}" | sed -e 's%\..*%%' -e 's%/.*%/%'`term.h
 	cf_header_list="$cf_header_item $cf_header_list"
 	;;
 esac
@@ -838,13 +1127,13 @@
 	AC_TRY_COMPILE([
 #include <${cf_cv_ncurses_header:-curses.h}>
 #include <${cf_header}>],
-	[WINDOW *x],
+	[WINDOW *x; (void)x],
 	[cf_cv_term_header=$cf_header
 	 break],
 	[cf_cv_term_header=no])
 done
 
-case $cf_cv_term_header in
+case "$cf_cv_term_header" in
 (no)
 	# If curses is ncurses, some packagers still mess it up by trying to make
 	# us use GNU termcap.  This handles the most common case.
@@ -855,9 +1144,9 @@
 #ifdef NCURSES_VERSION
 #include <${cf_header}>
 #else
-make an error
+#error expected NCURSES_VERSION to be defined
 #endif],
-			[WINDOW *x],
+			[WINDOW *x; (void)x],
 			[cf_cv_term_header=$cf_header
 			 break],
 			[cf_cv_term_header=no])
@@ -866,7 +1155,7 @@
 esac
 ])
 
-case $cf_cv_term_header in
+case "$cf_cv_term_header" in
 (term.h)
 	AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
 	;;
@@ -879,7 +1168,7 @@
 esac
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CURSES_UNCTRL_H version: 4 updated: 2015/04/15 19:08:48
+dnl CF_CURSES_UNCTRL_H version: 8 updated: 2021/01/02 09:31:20
 dnl ------------------
 dnl Any X/Open curses implementation must have unctrl.h, but ncurses packages
 dnl may put it in a subdirectory (along with ncurses' other headers, of
@@ -896,9 +1185,9 @@
 
 cf_header_list="unctrl.h ncurses/unctrl.h ncursesw/unctrl.h"
 
-case ${cf_cv_ncurses_header:-curses.h} in
+case "${cf_cv_ncurses_header:-curses.h}" in
 (*/*)
-	cf_header_item=`echo ${cf_cv_ncurses_header:-curses.h} | sed -e 's%\..*%%' -e 's%/.*%/%'`unctrl.h
+	cf_header_item=`echo "${cf_cv_ncurses_header:-curses.h}" | sed -e 's%\..*%%' -e 's%/.*%/%'`unctrl.h
 	cf_header_list="$cf_header_item $cf_header_list"
 	;;
 esac
@@ -908,20 +1197,20 @@
 	AC_TRY_COMPILE([
 #include <${cf_cv_ncurses_header:-curses.h}>
 #include <${cf_header}>],
-	[WINDOW *x],
+	[WINDOW *x; (void)x],
 	[cf_cv_unctrl_header=$cf_header
 	 break],
 	[cf_cv_unctrl_header=no])
 done
 ])
 
-case $cf_cv_unctrl_header in
+case "$cf_cv_unctrl_header" in
 (no)
 	AC_MSG_WARN(unctrl.h header not found)
 	;;
 esac
 
-case $cf_cv_unctrl_header in
+case "$cf_cv_unctrl_header" in
 (unctrl.h)
 	AC_DEFINE(HAVE_UNCTRL_H,1,[Define to 1 if we have unctrl.h])
 	;;
@@ -934,7 +1223,7 @@
 esac
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CURSES_WACS_MAP version: 6 updated: 2012/10/06 08:57:51
+dnl CF_CURSES_WACS_MAP version: 8 updated: 2021/01/04 19:45:09
 dnl ------------------
 dnl Check for likely values of wacs_map[].
 AC_DEFUN([CF_CURSES_WACS_MAP],
@@ -948,7 +1237,7 @@
 #define _XOPEN_SOURCE_EXTENDED
 #endif
 #include <${cf_cv_ncurses_header:-curses.h}>],
-	[void *foo = &($name['k'])],
+	[void *foo = &(${name}['k']); (void)foo],
 	[cf_cv_curses_wacs_map=$name
 	 break])
 	done])
@@ -956,7 +1245,7 @@
 test "$cf_cv_curses_wacs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_WACS_ARRAY,$cf_cv_curses_wacs_map,[Define to name of (n)curses wide-character array])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CURSES_WACS_SYMBOLS version: 2 updated: 2012/10/06 08:57:51
+dnl CF_CURSES_WACS_SYMBOLS version: 4 updated: 2021/01/04 19:45:09
 dnl ----------------------
 dnl Do a check to see if the WACS_xxx constants are defined compatibly with
 dnl X/Open Curses.  In particular, NetBSD's implementation of the WACS_xxx
@@ -975,7 +1264,7 @@
 #endif
 #include <${cf_cv_ncurses_header:-curses.h}>],
 	[cchar_t *foo = WACS_PLUS;
-	 $cf_cv_curses_wacs_map['k'] = *WACS_PLUS],
+	 ${cf_cv_curses_wacs_map}['k'] = *WACS_PLUS; (void)foo],
 	[cf_cv_curses_wacs_symbols=yes])
 else
 	AC_TRY_LINK([
@@ -983,7 +1272,7 @@
 #define _XOPEN_SOURCE_EXTENDED
 #endif
 #include <${cf_cv_ncurses_header:-curses.h}>],
-	[cchar_t *foo = WACS_PLUS],
+	[cchar_t *foo = WACS_PLUS; (void)foo],
 	[cf_cv_curses_wacs_symbols=yes])
 fi
 ])
@@ -991,14 +1280,14 @@
 test "$cf_cv_curses_wacs_symbols" != no && AC_DEFINE(CURSES_WACS_SYMBOLS,1,[Define to 1 if (n)curses supports wide-character WACS_ symbols])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
+dnl CF_DIRNAME version: 5 updated: 2020/12/31 20:19:42
 dnl ----------
 dnl "dirname" is not portable, so we fake it with a shell script.
-AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
+AC_DEFUN([CF_DIRNAME],[$1=`echo "$2" | sed -e 's%/[[^/]]*$%%'`])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
+dnl CF_DISABLE_ECHO version: 14 updated: 2021/09/04 06:35:04
 dnl ---------------
-dnl You can always use "make -n" to see the actual options, but it's hard to
+dnl You can always use "make -n" to see the actual options, but it is hard to
 dnl pick out/analyze warning messages when the compile-line is long.
 dnl
 dnl Sets:
@@ -1033,7 +1322,7 @@
 AC_SUBST(ECHO_CC)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
+dnl CF_DISABLE_LEAKS version: 9 updated: 2021/04/03 16:41:50
 dnl ----------------
 dnl Combine no-leak checks with the libraries or tools that are used for the
 dnl checks.
@@ -1046,17 +1335,19 @@
 AC_MSG_CHECKING(if you want to perform memory-leak testing)
 AC_ARG_ENABLE(leaks,
 	[  --disable-leaks         test: free permanent memory, analyze leaks],
-	[if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
-	: ${with_no_leaks:=no})
+	[enable_leaks=$enableval],
+	[enable_leaks=yes])
+dnl with_no_leaks is more readable...
+if test "x$enable_leaks" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi
 AC_MSG_RESULT($with_no_leaks)
 
-if test "$with_no_leaks" = yes ; then
+if test "$enable_leaks" = no ; then
 	AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
 	AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_DISABLE_RPATH_HACK version: 2 updated: 2011/02/13 13:31:33
+dnl CF_DISABLE_RPATH_HACK version: 3 updated: 2021/01/05 20:14:44
 dnl ---------------------
 dnl The rpath-hack makes it simpler to build programs, particularly with the
 dnl *BSD ports which may have essential libraries in unusual places.  But it
@@ -1067,35 +1358,88 @@
 AC_MSG_CHECKING(if rpath-hack should be disabled)
 CF_ARG_DISABLE(rpath-hack,
 	[  --disable-rpath-hack    don't add rpath options for additional libraries],
-	[cf_disable_rpath_hack=yes],
-	[cf_disable_rpath_hack=no])
+	[enable_rpath_hack=no],
+	[enable_rpath_hack=yes])
+dnl TODO - drop cf_disable_rpath_hack
+if test "x$enable_rpath_hack" = xno; then cf_disable_rpath_hack=yes; else cf_disable_rpath_hack=no; fi
 AC_MSG_RESULT($cf_disable_rpath_hack)
-if test "$cf_disable_rpath_hack" = no ; then
+
+if test "$enable_rpath_hack" = yes ; then
 	CF_RPATH_HACK
 fi
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_ENABLE_WARNINGS version: 4 updated: 2009/07/26 17:53:03
-dnl ------------------
-dnl Configure-option to enable gcc warnings
-AC_DEFUN([CF_ENABLE_WARNINGS],[
-if ( test "$GCC" = yes || test "$GXX" = yes )
-then
-AC_MSG_CHECKING(if you want to turn on gcc warnings)
-CF_ARG_ENABLE(warnings,
-	[  --enable-warnings       test: turn on gcc compiler warnings],
-	[with_warnings=yes],
-	[with_warnings=no])
-AC_MSG_RESULT($with_warnings)
-if test "$with_warnings" = "yes"
-then
-	CF_GCC_ATTRIBUTES
-	CF_GCC_WARNINGS
-fi
+dnl CF_ENABLE_STRING_HACKS version: 6 updated: 2021/01/05 19:23:48
+dnl ----------------------
+dnl On a few platforms, the compiler and/or loader nags with untruthful
+dnl comments stating that "most" uses of strcat/strcpy/sprintf are incorrect,
+dnl and implying that most uses of the recommended alternatives are correct.
+dnl
+dnl Factually speaking, no one has actually counted the number of uses of these
+dnl functions versus the total of incorrect uses.  Samples of a few thousand
+dnl instances are meaningless compared to the hundreds of millions of lines of
+dnl existing C code.
+dnl
+dnl strlcat/strlcpy are (as of 2012) non-standard, and are available on some
+dnl platforms, in implementations of varying quality.  Likewise, snprintf is
+dnl standard - but evolved through phases, and older implementations are likely
+dnl to yield surprising results, as documented in manpages on various systems.
+AC_DEFUN([CF_ENABLE_STRING_HACKS],
+[
+AC_MSG_CHECKING(if you want to work around bogus compiler/loader warnings)
+AC_ARG_ENABLE(string-hacks,
+	[  --enable-string-hacks   work around bogus compiler/loader warnings],
+	[enable_string_hacks=$enableval],
+	[enable_string_hacks=no])
+AC_MSG_RESULT($enable_string_hacks)
+
+if test "x$enable_string_hacks" = "xyes"; then
+ 	AC_DEFINE(USE_STRING_HACKS,1,[Define to 1 to work around bogus compiler/loader warnings])
+	AC_MSG_WARN(enabling string-hacks to work around bogus compiler/loader warnings)
+	AC_CHECK_FUNC(strlcat,[
+		AC_DEFINE(HAVE_STRLCAT,1,[Define to 1 if we have strlcat function])
+		],[
+		AC_CHECK_LIB(bsd,strlcat,[
+			CF_ADD_LIB(bsd)
+			AC_CHECK_HEADERS(bsd/string.h)
+			AC_DEFINE(HAVE_STRLCAT,1,[Define to 1 if we have strlcat function])
+			])
+		])
+	AC_CHECK_FUNCS( strlcpy snprintf )
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_FIND_LIBRARY version: 9 updated: 2008/03/23 14:48:54
+dnl CF_ENABLE_WARNINGS version: 9 updated: 2021/01/05 19:40:50
+dnl ------------------
+dnl Configure-option to enable gcc warnings
+dnl
+dnl $1 = extra options to add, if supported
+dnl $2 = option for checking attributes.  By default, this is done when
+dnl      warnings are enabled.  For other values:
+dnl      yes: always do this, e.g., to use in generated library-headers
+dnl      no: never do this
+AC_DEFUN([CF_ENABLE_WARNINGS],[
+if test "$GCC" = yes || test "$GXX" = yes
+then
+CF_FIX_WARNINGS(CFLAGS)
+CF_FIX_WARNINGS(CPPFLAGS)
+CF_FIX_WARNINGS(LDFLAGS)
+AC_MSG_CHECKING(if you want to turn on gcc warnings)
+CF_ARG_ENABLE(warnings,
+	[  --enable-warnings       test: turn on gcc compiler warnings],
+	[enable_warnings=yes],
+	[enable_warnings=no])
+AC_MSG_RESULT($enable_warnings)
+if test "$enable_warnings" = "yes"
+then
+	ifelse($2,,[CF_GCC_ATTRIBUTES])
+	CF_GCC_WARNINGS($1)
+fi
+ifelse($2,yes,[CF_GCC_ATTRIBUTES])
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_FIND_LIBRARY version: 11 updated: 2021/01/02 09:31:20
 dnl ---------------
 dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
 dnl prefer a standard location, and use -L options only if we do not find the
@@ -1111,16 +1455,16 @@
 dnl to use a -L option.
 AC_DEFUN([CF_FIND_LIBRARY],
 [
-	eval 'cf_cv_have_lib_'$1'=no'
+	eval 'cf_cv_have_lib_'"$1"'=no'
 	cf_libdir=""
 	AC_CHECK_FUNC($5,
-		eval 'cf_cv_have_lib_'$1'=yes',[
+		eval 'cf_cv_have_lib_'"$1"'=yes',[
 		cf_save_LIBS="$LIBS"
 		AC_MSG_CHECKING(for $5 in -l$1)
 		LIBS="-l$1 $LIBS"
 		AC_TRY_LINK([$3],[$4],
 			[AC_MSG_RESULT(yes)
-			 eval 'cf_cv_have_lib_'$1'=yes'
+			 eval 'cf_cv_have_lib_'"$1"'=yes'
 			],
 			[AC_MSG_RESULT(no)
 			CF_LIBRARY_PATH(cf_search,$2)
@@ -1130,22 +1474,22 @@
 				LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
 				AC_TRY_LINK([$3],[$4],
 					[AC_MSG_RESULT(yes)
-			 		 eval 'cf_cv_have_lib_'$1'=yes'
+			 		 eval 'cf_cv_have_lib_'"$1"'=yes'
 					 break],
 					[AC_MSG_RESULT(no)
 					 LIBS="$cf_save_LIBS"])
 			done
 			])
 		])
-eval 'cf_found_library=[$]cf_cv_have_lib_'$1
+eval 'cf_found_library="[$]cf_cv_have_lib_'"$1"\"
 ifelse($6,,[
-if test $cf_found_library = no ; then
+if test "$cf_found_library" = no ; then
 	AC_MSG_ERROR(Cannot link $1 library)
 fi
 ])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_FIND_LINKAGE version: 20 updated: 2015/04/18 08:56:57
+dnl CF_FIND_LINKAGE version: 22 updated: 2020/12/31 20:19:42
 dnl ---------------
 dnl Find a library (specifically the linkage used in the code fragment),
 dnl searching for it if it is not already in the library path.
@@ -1202,9 +1546,10 @@
 	CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
 	for cf_cv_header_path_$3 in $cf_search
 	do
-		if test -d $cf_cv_header_path_$3 ; then
+		if test -d "$cf_cv_header_path_$3" ; then
 			CF_VERBOSE(... testing $cf_cv_header_path_$3)
-			CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
+			CPPFLAGS="$cf_save_CPPFLAGS"
+			CF_APPEND_TEXT(CPPFLAGS,-I$cf_cv_header_path_$3)
 			AC_TRY_COMPILE([$1],[$2],[
 				CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
 				cf_cv_find_linkage_$3=maybe
@@ -1236,7 +1581,7 @@
 			CF_LIBRARY_PATH(cf_search,$3)
 			for cf_cv_library_path_$3 in $cf_search
 			do
-				if test -d $cf_cv_library_path_$3 ; then
+				if test -d "$cf_cv_library_path_$3" ; then
 					CF_VERBOSE(... testing $cf_cv_library_path_$3)
 					CPPFLAGS="$cf_test_CPPFLAGS"
 					LIBS="-l$3 $7 $cf_save_LIBS"
@@ -1275,7 +1620,47 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_FUNC_CURSES_VERSION version: 6 updated: 2012/10/06 16:39:58
+dnl CF_FIX_WARNINGS version: 4 updated: 2021/12/16 18:22:31
+dnl ---------------
+dnl Warning flags do not belong in CFLAGS, CPPFLAGS, etc.  Any of gcc's
+dnl "-Werror" flags can interfere with configure-checks.  Those go into
+dnl EXTRA_CFLAGS.
+dnl
+dnl $1 = variable name to repair
+define([CF_FIX_WARNINGS],[
+if test "$GCC" = yes || test "$GXX" = yes
+then
+	case [$]$1 in
+	(*-Werror=*)
+		cf_temp_flags=
+		for cf_temp_scan in [$]$1
+		do
+			case "x$cf_temp_scan" in
+			(x-Werror=format*)
+				CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
+				;;
+			(x-Werror=*)
+				CF_APPEND_TEXT(EXTRA_CFLAGS,$cf_temp_scan)
+				;;
+			(*)
+				CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
+				;;
+			esac
+		done
+		if test "x[$]$1" != "x$cf_temp_flags"
+		then
+			CF_VERBOSE(repairing $1: [$]$1)
+			$1="$cf_temp_flags"
+			CF_VERBOSE(... fixed [$]$1)
+			CF_VERBOSE(... extra $EXTRA_CFLAGS)
+		fi
+		;;
+	esac
+fi
+AC_SUBST(EXTRA_CFLAGS)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_FUNC_CURSES_VERSION version: 9 updated: 2023/01/05 18:06:10
 dnl ----------------------
 dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS.
 dnl It's a character string "SVR4", not documented.
@@ -1283,11 +1668,14 @@
 [
 AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
 AC_TRY_RUN([
+$ac_includes_default
+
 #include <${cf_cv_ncurses_header:-curses.h}>
-int main()
+
+int main(void)
 {
 	char temp[1024];
-	sprintf(temp, "%s\n", curses_version());
+	sprintf(temp, "%.999s\\n", curses_version());
 	${cf_cv_main_return:-return}(0);
 }]
 ,[cf_cv_func_curses_version=yes]
@@ -1297,14 +1685,72 @@
 test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION,1,[Define to 1 if we have curses_version function])
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_GCC_ATTRIBUTES version: 17 updated: 2015/04/12 15:39:00
+dnl CF_FUNC_GETTIME version: 2 updated: 2023/02/25 08:45:56
+dnl ---------------
+dnl Check for gettimeofday or clock_gettime.  In 2023, the former is still more
+dnl widely supported, but "deprecated" (2008), so we will use the latter if it
+dnl is available, to reduce compiler warnings.
+AC_DEFUN([CF_FUNC_GETTIME],[
+AC_CACHE_CHECK(for clock_gettime,cf_cv_func_clock_gettime,[
+		AC_TRY_LINK([#include <time.h>],
+		[struct timespec ts;
+		int rc = clock_gettime(CLOCK_REALTIME, &ts); (void) rc; (void)ts],
+		[cf_cv_func_clock_gettime=yes],
+		[cf_cv_func_clock_gettime=no])
+])
+
+if test "$cf_cv_func_clock_gettime" = yes
+then
+	AC_DEFINE(HAVE_CLOCK_GETTIME,1,[Define to 1 if we have clock_gettime function])
+else
+AC_CHECK_FUNC(gettimeofday,
+	AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define to 1 if we have gettimeofday function]),[
+
+AC_CHECK_LIB(bsd, gettimeofday,
+	AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define to 1 if we have gettimeofday function])
+	CF_ADD_LIB(bsd))])dnl CLIX: bzero, select, gettimeofday
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_FUNC_OPENPTY version: 7 updated: 2023/12/03 09:21:34
+dnl ---------------
+dnl Check for openpty() function, along with <pty.h> header.  It may need the
+dnl "util" library as well.
+AC_DEFUN([CF_FUNC_OPENPTY],
+[
+AC_CHECK_LIB(util,openpty,cf_cv_lib_util=yes,cf_cv_lib_util=no)
+AC_CACHE_CHECK(for openpty header,cf_cv_func_openpty,[
+	cf_save_LIBS="$LIBS"
+	test "$cf_cv_lib_util" = yes && { CF_ADD_LIB(util) }
+	for cf_header in pty.h libutil.h util.h
+	do
+	AC_TRY_LINK([
+#include <$cf_header>
+],[
+	int x = openpty((int *)0, (int *)0, (char *)0,
+				   (struct termios *)0, (struct winsize *)0);
+	(void)x;
+],[
+		cf_cv_func_openpty=$cf_header
+		break
+],[
+		cf_cv_func_openpty=no
+])
+	done
+	LIBS="$cf_save_LIBS"
+])
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_GCC_ATTRIBUTES version: 24 updated: 2021/03/20 12:00:25
 dnl -----------------
 dnl Test for availability of useful gcc __attribute__ directives to quiet
 dnl compiler warnings.  Though useful, not all are supported -- and contrary
 dnl to documentation, unrecognized directives cause older compilers to barf.
 AC_DEFUN([CF_GCC_ATTRIBUTES],
-[
-if test "$GCC" = yes
+[AC_REQUIRE([AC_PROG_FGREP])dnl
+AC_REQUIRE([CF_C11_NORETURN])dnl
+
+if test "$GCC" = yes || test "$GXX" = yes
 then
 cat > conftest.i <<EOF
 #ifndef GCC_PRINTF
@@ -1323,8 +1769,9 @@
 if test "$GCC" = yes
 then
 	AC_CHECKING([for $CC __attribute__ directives])
-cat > conftest.$ac_ext <<EOF
+cat > "conftest.$ac_ext" <<EOF
 #line __oline__ "${as_me:-configure}"
+#include <stdio.h>
 #include "confdefs.h"
 #include "conftest.h"
 #include "conftest.i"
@@ -1339,9 +1786,9 @@
 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
 #endif
 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
-extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
-extern void foo(void) GCC_NORETURN;
-int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
+extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2);
+extern GCC_NORETURN void foo(void);
+int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
 EOF
 	cf_printf_attribute=no
 	cf_scanf_attribute=no
@@ -1351,7 +1798,7 @@
 		cf_directive="__attribute__(($cf_attribute))"
 		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
 
-		case $cf_attribute in
+		case "$cf_attribute" in
 		(printf)
 			cf_printf_attribute=yes
 			cat >conftest.h <<EOF
@@ -1374,7 +1821,7 @@
 		if AC_TRY_EVAL(ac_compile); then
 			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
 			cat conftest.h >>confdefs.h
-			case $cf_attribute in
+			case "$cf_attribute" in
 			(noreturn)
 				AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
 				;;
@@ -1401,32 +1848,36 @@
 		fi
 	done
 else
-	fgrep define conftest.i >>confdefs.h
+	${FGREP-fgrep} define conftest.i >>confdefs.h
 fi
-rm -rf conftest*
+rm -rf ./conftest*
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
+dnl CF_GCC_VERSION version: 9 updated: 2023/03/05 14:30:13
 dnl --------------
-dnl Find version of gcc
+dnl Find version of gcc, and (because icc/clang pretend to be gcc without being
+dnl compatible), attempt to determine if icc/clang is actually used.
 AC_DEFUN([CF_GCC_VERSION],[
 AC_REQUIRE([AC_PROG_CC])
 GCC_VERSION=none
 if test "$GCC" = yes ; then
 	AC_MSG_CHECKING(version of $CC)
-	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
+	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[[^(]]*([[^)]][[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
 	test -z "$GCC_VERSION" && GCC_VERSION=unknown
 	AC_MSG_RESULT($GCC_VERSION)
 fi
+CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
+CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_GCC_WARNINGS version: 32 updated: 2015/04/12 15:39:00
+dnl CF_GCC_WARNINGS version: 41 updated: 2021/01/01 16:53:59
 dnl ---------------
 dnl Check if the compiler supports useful warning options.  There's a few that
 dnl we don't use, simply because they're too noisy:
 dnl
 dnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
+dnl	-Winline (usually not worthwhile)
 dnl	-Wredundant-decls (system headers make this too noisy)
 dnl	-Wtraditional (combines too many unrelated messages, only a few useful)
 dnl	-Wwrite-strings (too noisy, but should review occasionally).  This
@@ -1443,14 +1894,11 @@
 AC_DEFUN([CF_GCC_WARNINGS],
 [
 AC_REQUIRE([CF_GCC_VERSION])
-CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
-CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
-
-cat > conftest.$ac_ext <<EOF
+if test "x$have_x" = xyes; then CF_CONST_X_STRING fi
+cat > "conftest.$ac_ext" <<EOF
 #line __oline__ "${as_me:-configure}"
 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
 EOF
-
 if test "$INTEL_COMPILER" = yes
 then
 # The "-wdXXX" options suppress warnings:
@@ -1466,7 +1914,7 @@
 
 	AC_CHECKING([for $CC warning options])
 	cf_save_CFLAGS="$CFLAGS"
-	EXTRA_CFLAGS="-Wall"
+	EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
 	for cf_opt in \
 		wd1419 \
 		wd1683 \
@@ -1485,12 +1933,10 @@
 		fi
 	done
 	CFLAGS="$cf_save_CFLAGS"
-
-elif test "$GCC" = yes
+elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
 then
 	AC_CHECKING([for $CC warning options])
 	cf_save_CFLAGS="$CFLAGS"
-	EXTRA_CFLAGS=
 	cf_warn_CONST=""
 	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
 	cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
@@ -1508,24 +1954,21 @@
 		Wpointer-arith \
 		Wshadow \
 		Wstrict-prototypes \
-		Wundef $cf_gcc_warnings $cf_warn_CONST $1
+		Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
 	do
 		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
 		if AC_TRY_EVAL(ac_compile); then
 			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
-			case $cf_opt in
-			(Wcast-qual)
-				CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
-				;;
+			case "$cf_opt" in
 			(Winline)
-				case $GCC_VERSION in
+				case "$GCC_VERSION" in
 				([[34]].*)
 					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
 					continue;;
 				esac
 				;;
 			(Wpointer-arith)
-				case $GCC_VERSION in
+				case "$GCC_VERSION" in
 				([[12]].*)
 					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
 					continue;;
@@ -1537,12 +1980,12 @@
 	done
 	CFLAGS="$cf_save_CFLAGS"
 fi
-rm -rf conftest*
+rm -rf ./conftest*
 
 AC_SUBST(EXTRA_CFLAGS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_GETOPT_HEADER version: 6 updated: 2014/07/22 14:45:54
+dnl CF_GETOPT_HEADER version: 8 updated: 2021/06/19 19:16:16
 dnl ----------------
 dnl Check for getopt's variables which are commonly defined in stdlib.h,
 dnl unistd.h or (nonstandard) in getopt.h
@@ -1555,20 +1998,20 @@
 do
 AC_TRY_COMPILE([
 #include <$cf_header>],
-[int x = optind; char *y = optarg],
+[int x = optind; char *y = optarg; (void)x; (void)y],
 [cf_cv_getopt_header=$cf_header
  break])
 done
 ])
-if test $cf_cv_getopt_header != none ; then
+if test "$cf_cv_getopt_header" != none ; then
 	AC_DEFINE(HAVE_GETOPT_HEADER,1,[Define to 1 if getopt variables are declared in header])
 fi
-if test $cf_cv_getopt_header = getopt.h ; then
+if test "$cf_cv_getopt_header" = getopt.h ; then
 	AC_DEFINE(NEED_GETOPT_H,1,[Define to 1 if we must include getopt.h])
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
+dnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41
 dnl -------------
 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
@@ -1576,29 +2019,110 @@
 dnl since it is interwoven with GNU extensions.
 dnl
 dnl Well, yes we could work around it...
+dnl
+dnl Parameters:
+dnl	$1 is the nominal value for _XOPEN_SOURCE
 AC_DEFUN([CF_GNU_SOURCE],
 [
-AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
+cf_gnu_xopen_source=ifelse($1,,500,$1)
+
+AC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[
 AC_TRY_COMPILE([#include <sys/types.h>],[
-#ifndef _XOPEN_SOURCE
-make an error
-#endif],
-	[cf_cv_gnu_source=no],
-	[cf_save="$CPPFLAGS"
-	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
-	 AC_TRY_COMPILE([#include <sys/types.h>],[
-#ifdef _XOPEN_SOURCE
-make an error
-#endif],
-	[cf_cv_gnu_source=no],
-	[cf_cv_gnu_source=yes])
-	CPPFLAGS="$cf_save"
-	])
+	#if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
+		return 0;
+	#elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
+		return 0;
+	#else
+	#	error not GNU C library
+	#endif],
+	[cf_cv_gnu_library=yes],
+	[cf_cv_gnu_library=no])
 ])
-test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+
+if test x$cf_cv_gnu_library = xyes; then
+
+	# With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
+	# was changed to help a little.  newlib incorporated the change about 4
+	# years later.
+	AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
+		cf_save="$CPPFLAGS"
+		CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
+		AC_TRY_COMPILE([#include <sys/types.h>],[
+			#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
+				return 0;
+			#elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
+				return 0;
+			#else
+			#	error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
+			#endif],
+			[cf_cv_gnu_library_219=yes],
+			[cf_cv_gnu_library_219=no])
+		CPPFLAGS="$cf_save"
+	])
+
+	if test "x$cf_cv_gnu_library_219" = xyes; then
+		cf_save="$CPPFLAGS"
+		AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[
+			CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source)
+			AC_TRY_COMPILE([
+				#include <limits.h>
+				#include <sys/types.h>
+				],[
+				#if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
+					return 0;
+				#else
+				#	error GNU C library is too old
+				#endif],
+				[cf_cv_gnu_dftsrc_219=yes],
+				[cf_cv_gnu_dftsrc_219=no])
+			])
+		test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
+	else
+		cf_cv_gnu_dftsrc_219=maybe
+	fi
+
+	if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
+
+		AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
+		AC_TRY_COMPILE([#include <sys/types.h>],[
+			#ifndef _XOPEN_SOURCE
+			#error	expected _XOPEN_SOURCE to be defined
+			#endif],
+			[cf_cv_gnu_source=no],
+			[cf_save="$CPPFLAGS"
+			 CF_ADD_CFLAGS(-D_GNU_SOURCE)
+			 AC_TRY_COMPILE([#include <sys/types.h>],[
+				#ifdef _XOPEN_SOURCE
+				#error	expected _XOPEN_SOURCE to be undefined
+				#endif],
+				[cf_cv_gnu_source=no],
+				[cf_cv_gnu_source=yes])
+			CPPFLAGS="$cf_save"
+			])
+		])
+
+		if test "$cf_cv_gnu_source" = yes
+		then
+		AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
+			CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
+			AC_TRY_COMPILE([#include <sys/types.h>],[
+				#ifdef _DEFAULT_SOURCE
+				#error	expected _DEFAULT_SOURCE to be undefined
+				#endif],
+				[cf_cv_default_source=no],
+				[cf_cv_default_source=yes])
+			])
+			if test "$cf_cv_default_source" = yes
+			then
+				CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
+			fi
+		fi
+	fi
+
+fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_HEADER_PATH version: 13 updated: 2015/04/15 19:08:48
+dnl CF_HEADER_PATH version: 15 updated: 2021/01/01 13:31:04
 dnl --------------
 dnl Construct a search-list of directories for a nonstandard header-file
 dnl
@@ -1614,7 +2138,7 @@
 if test -n "${CFLAGS}${CPPFLAGS}" ; then
 	for cf_header_path in $CPPFLAGS $CFLAGS
 	do
-		case $cf_header_path in
+		case "$cf_header_path" in
 		(-I*)
 			cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
 			CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
@@ -1630,25 +2154,26 @@
 test "$includedir" != NONE && \
 test "$includedir" != "/usr/include" && \
 test -d "$includedir" && {
-	test -d $includedir &&    $1="[$]$1 $includedir"
-	test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
+	test -d "$includedir" &&    $1="[$]$1 $includedir"
+	test -d "$includedir/$2" && $1="[$]$1 $includedir/$2"
 }
 
 test "$oldincludedir" != NONE && \
 test "$oldincludedir" != "/usr/include" && \
 test -d "$oldincludedir" && {
-	test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
-	test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
+	test -d "$oldincludedir"    && $1="[$]$1 $oldincludedir"
+	test -d "$oldincludedir/$2" && $1="[$]$1 $oldincludedir/$2"
 }
 
 $1="[$]$1 $cf_header_path_list"
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
+dnl CF_HELP_MESSAGE version: 4 updated: 2019/12/31 08:53:54
 dnl ---------------
 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
 AC_DEFUN([CF_HELP_MESSAGE],
-[AC_DIVERT_HELP([$1])dnl
+[CF_ACVERSION_CHECK(2.53,[],[
+AC_DIVERT_HELP($1)])dnl
 ])dnl
 dnl ---------------------------------------------------------------------------
 dnl CF_INHERIT_SCRIPT version: 2 updated: 2003/03/01 23:50:42
@@ -1659,7 +2184,168 @@
 test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_INTEL_COMPILER version: 7 updated: 2015/04/12 15:39:00
+dnl CF_INSTALL_OPTS version: 3 updated: 2023/06/03 15:17:30
+dnl ---------------
+dnl prompt for/fill-in useful install-program options
+AC_DEFUN([CF_INSTALL_OPTS],
+[
+CF_INSTALL_OPT_S
+CF_INSTALL_OPT_P
+CF_INSTALL_OPT_O
+CF_INSTALL_OPT_STRIP_PROG
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_INSTALL_OPT_O version: 3 updated: 2020/12/31 20:19:42
+dnl ----------------
+dnl Almost all "install" programs default to the current user's ownership.
+dnl Almost - MINIX is an exception.
+AC_DEFUN([CF_INSTALL_OPT_O],
+[
+AC_MSG_CHECKING(if install needs to be told about ownership)
+case `$ac_config_guess` in
+(*minix)
+	with_install_o=yes
+	;;
+(*)
+	with_install_o=no
+	;;
+esac
+
+AC_MSG_RESULT($with_install_o)
+if test "x$with_install_o" = xyes
+then
+	INSTALL_OPT_O="`id root|sed -e 's/uid=[[0-9]]*(/ -o /' -e 's/gid=[[0-9]]*(/ -g /' -e 's/ [[^=[:space:]]][[^=[:space:]]]*=.*/ /' -e 's/)//g'`"
+else
+	INSTALL_OPT_O=
+fi
+
+AC_SUBST(INSTALL_OPT_O)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_INSTALL_OPT_P version: 3 updated: 2021/01/01 13:31:04
+dnl ----------------
+dnl Some install-programs accept a "-p" option to preserve file modification
+dnl timestamps.  That can be useful as an install option, as well as a way to
+dnl avoid the need for ranlib after copying a static archive.
+AC_DEFUN([CF_INSTALL_OPT_P],
+[
+: "${INSTALL:=install}"
+AC_CACHE_CHECK(if install accepts -p option, cf_cv_install_p,[
+	rm -rf ./conftest*
+	date >conftest.in
+	mkdir conftest.out
+	sleep 3
+	if $INSTALL -p conftest.in conftest.out 2>/dev/null
+	then
+		if test -f conftest.out/conftest.in
+		then
+			test conftest.in -nt conftest.out/conftest.in 2>conftest.err && \
+			test conftest.out/conftest.in -nt conftest.in 2>conftest.err
+			if test -s conftest.err
+			then
+				cf_cv_install_p=no
+			else
+				cf_cv_install_p=yes
+			fi
+		else
+			cf_cv_install_p=no
+		fi
+	else
+		cf_cv_install_p=no
+	fi
+	rm -rf ./conftest*
+])
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_INSTALL_OPT_S version: 3 updated: 2021/01/05 19:23:48
+dnl ----------------
+dnl By default, we should strip executables which are installed, but leave the
+dnl ability to suppress that for unit-testing.
+AC_DEFUN([CF_INSTALL_OPT_S],
+[
+AC_MSG_CHECKING(if you want to install stripped executables)
+CF_ARG_DISABLE(stripping,
+	[  --disable-stripping     do not strip (debug info) installed executables],
+	[enable_stripping=no],
+	[enable_stripping=yes])
+AC_MSG_RESULT($enable_stripping)
+
+if test "$enable_stripping" = yes
+then
+	INSTALL_OPT_S="-s"
+else
+	INSTALL_OPT_S=
+fi
+AC_SUBST(INSTALL_OPT_S)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_INSTALL_OPT_STRIP_PROG version: 1 updated: 2023/06/03 15:17:30
+dnl -------------------------
+dnl Provide an option for overriding the strip program used in install "-s"
+dnl
+dnl coreutils install provides a --strip-program option
+dnl FreeBSD uses STRIPBIN environment variable, while NetBSD and OpenBSD use
+dnl STRIP environment variable.  Other versions of install do not support this.
+AC_DEFUN([CF_INSTALL_OPT_STRIP_PROG],
+[
+AC_REQUIRE([CF_INSTALL_OPT_S])
+if test -n "$INSTALL_OPT_S"
+then
+	AC_MSG_CHECKING(if you want to specify strip-program)
+	AC_ARG_WITH(strip-program,
+		[  --with-strip-program=XX specify program to use when stripping in install],
+		[with_strip_program=$withval],
+		[with_strip_program=no])
+	AC_MSG_RESULT($with_strip_program)
+	if test "$with_strip_program" != no
+	then
+		AC_MSG_CHECKING(if strip-program is supported with this installer)
+		cf_install_program=`echo "$INSTALL" | sed -e 's%[[ ]]*[[ ]]-.%%'`
+		check_install_strip=no
+		if test -f "$cf_install_program"
+		then
+			check_install_version=`"$cf_install_program" --version 2>/dev/null | head -n 1 | grep coreutils`
+			if test -n "$check_install_version"
+			then
+				check_install_strip="option"
+			else
+				for check_strip_variable in STRIPBIN STRIP
+				do
+					if strings "$cf_install_program" | grep "^$check_strip_variable[$]" >/dev/null
+					then
+						check_install_strip="environ"
+						break
+					fi
+				done
+			fi
+		fi
+		AC_MSG_RESULT($check_install_strip)
+		case "$check_install_strip" in
+		(no)
+			AC_MSG_WARN($cf_install_program does not support strip program option)
+			with_strip_program=no
+			;;
+		(environ)
+			cat >install.tmp <<-CF_EOF
+			#! $SHELL
+			STRIPBIN="$with_strip_program" \\
+			STRIP="$with_strip_program" \\
+			$INSTALL "[$]@"
+			CF_EOF
+			INSTALL="`pwd`/install.tmp"
+			chmod +x "$INSTALL"
+			CF_VERBOSE(created $INSTALL)
+			;;
+		(option)
+			INSTALL_OPT_S="$INSTALL_OPT_S --strip-program=\"$with_strip_program\""
+			;;
+		esac
+	fi
+fi
+AC_SUBST(INSTALL_OPT_S)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_INTEL_COMPILER version: 9 updated: 2023/02/18 17:41:25
 dnl -----------------
 dnl Check if the given compiler is really the Intel compiler for Linux.  It
 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
@@ -1677,7 +2363,7 @@
 ifelse([$2],,INTEL_COMPILER,[$2])=no
 
 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
-	case $host_os in
+	case "$host_os" in
 	(linux*|gnu*)
 		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
 		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
@@ -1685,7 +2371,7 @@
 		AC_TRY_COMPILE([],[
 #ifdef __INTEL_COMPILER
 #else
-make an error
+#error __INTEL_COMPILER is not defined
 #endif
 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
@@ -1697,7 +2383,7 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_LD_RPATH_OPT version: 6 updated: 2015/04/12 15:39:00
+dnl CF_LD_RPATH_OPT version: 9 updated: 2021/01/01 13:31:04
 dnl ---------------
 dnl For the given system and compiler, find the compiler flags to pass to the
 dnl loader to use the "rpath" feature.
@@ -1706,52 +2392,55 @@
 AC_REQUIRE([CF_CHECK_CACHE])
 
 LD_RPATH_OPT=
-AC_MSG_CHECKING(for an rpath option)
-case $cf_cv_system_name in
-(irix*)
-	if test "$GCC" = yes; then
+if test "x$cf_cv_enable_rpath" != xno
+then
+	AC_MSG_CHECKING(for an rpath option)
+	case "$cf_cv_system_name" in
+	(irix*)
+		if test "$GCC" = yes; then
+			LD_RPATH_OPT="-Wl,-rpath,"
+		else
+			LD_RPATH_OPT="-rpath "
+		fi
+		;;
+	(linux*|gnu*|k*bsd*-gnu|freebsd*)
 		LD_RPATH_OPT="-Wl,-rpath,"
-	else
+		;;
+	(openbsd[[2-9]].*|mirbsd*)
+		LD_RPATH_OPT="-Wl,-rpath,"
+		;;
+	(dragonfly*)
 		LD_RPATH_OPT="-rpath "
-	fi
-	;;
-(linux*|gnu*|k*bsd*-gnu)
-	LD_RPATH_OPT="-Wl,-rpath,"
-	;;
-(openbsd[[2-9]].*|mirbsd*)
-	LD_RPATH_OPT="-Wl,-rpath,"
-	;;
-(dragonfly*|freebsd*)
-	LD_RPATH_OPT="-rpath "
-	;;
-(netbsd*)
-	LD_RPATH_OPT="-Wl,-rpath,"
-	;;
-(osf*|mls+*)
-	LD_RPATH_OPT="-rpath "
-	;;
-(solaris2*)
-	LD_RPATH_OPT="-R"
-	;;
-(*)
-	;;
-esac
-AC_MSG_RESULT($LD_RPATH_OPT)
+		;;
+	(netbsd*)
+		LD_RPATH_OPT="-Wl,-rpath,"
+		;;
+	(osf*|mls+*)
+		LD_RPATH_OPT="-rpath "
+		;;
+	(solaris2*)
+		LD_RPATH_OPT="-R"
+		;;
+	(*)
+		;;
+	esac
+	AC_MSG_RESULT($LD_RPATH_OPT)
 
-case "x$LD_RPATH_OPT" in
-(x-R*)
-	AC_MSG_CHECKING(if we need a space after rpath option)
-	cf_save_LIBS="$LIBS"
-	CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
-	AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
-	LIBS="$cf_save_LIBS"
-	AC_MSG_RESULT($cf_rpath_space)
-	test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
-	;;
-esac
+	case "x$LD_RPATH_OPT" in
+	(x-R*)
+		AC_MSG_CHECKING(if we need a space after rpath option)
+		cf_save_LIBS="$LIBS"
+		CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
+		AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
+		LIBS="$cf_save_LIBS"
+		AC_MSG_RESULT($cf_rpath_space)
+		test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
+		;;
+	esac
+fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_LIBRARY_PATH version: 10 updated: 2015/04/15 19:08:48
+dnl CF_LIBRARY_PATH version: 11 updated: 2021/01/01 13:31:04
 dnl ---------------
 dnl Construct a search-list of directories for a nonstandard library-file
 dnl
@@ -1765,7 +2454,7 @@
 if test -n "${LDFLAGS}${LIBS}" ; then
 	for cf_library_path in $LDFLAGS $LIBS
 	do
-		case $cf_library_path in
+		case "$cf_library_path" in
 		(-L*)
 			cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
 			CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
@@ -1780,6 +2469,89 @@
 $1="$cf_library_path_list [$]$1"
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_MAKE_PHONY version: 3 updated: 2021/01/08 16:08:21
+dnl -------------
+dnl Check if the make-program handles a ".PHONY" target, e.g,. a target which
+dnl acts as a placeholder.
+dnl
+dnl The ".PHONY" feature was proposed in 2011 here
+dnl     https://www.austingroupbugs.net/view.php?id=523
+dnl and is scheduled for release in P1003.1 Issue 8 (late 2022).
+dnl
+dnl This is not supported by SVr4 make (or SunOS 4, 4.3SD, etc), but works with
+dnl a few others (i.e., GNU make and the non-POSIX "BSD" make):
+dnl
+dnl + This is a GNU make feature (since April 1988, but in turn from binutils,
+dnl   date unspecified).
+dnl
+dnl + It was adopted in NetBSD make in June 1995.
+dnl
+dnl + The other BSD make programs are derived from the NetBSD make (and for
+dnl   that reason are not actually different "implementations").
+dnl
+dnl + Some features of NetBSD make were actually adapted from pmake, which
+dnl   began as a modified GNU make starting in 1993.
+dnl
+dnl + Version 3.8 of the dmake program in January 1992 also implemented this
+dnl   GNU make extension, but is less well known than the BSD make.
+AC_DEFUN([CF_MAKE_PHONY],[
+AC_CACHE_CHECK(for \".PHONY\" make-support, cf_cv_make_PHONY,[
+	rm -rf conftest*
+	(
+		mkdir conftest || exit 1
+		cd conftest
+		cat >makefile <<'CF_EOF'
+.PHONY: always
+DATA=0
+always:	always.out
+	@echo "** making [$]@ [$](DATA)"
+once: once.out
+	@echo "** making [$]@ [$](DATA)"
+always.out:
+	@echo "** making [$]@ [$](DATA)"
+	echo [$](DATA) > [$]@
+once.out:
+	@echo "** making [$]@ [$](DATA)"
+	echo [$](DATA) > [$]@
+CF_EOF
+		for cf_data in 1 2 3
+		do
+			${MAKE:-make} always DATA=$cf_data
+			${MAKE:-make} once   DATA=$cf_data
+			${MAKE:-make} -t always once
+			if test -f always ; then
+				echo "no (case 1)" > ../conftest.tmp
+			elif test ! -f always.out ; then
+				echo "no (case 2)" > ../conftest.tmp
+			elif test ! -f once.out ; then
+				echo "no (case 3)" > ../conftest.tmp
+			elif ! cmp -s always.out once.out ; then
+				echo "no (case 4)" > ../conftest.tmp
+				diff always.out once.out
+			else
+				cf_check="`cat always.out`"
+				if test "x$cf_check" != "x$cf_data" ; then
+					echo "no (case 5)" > ../conftest.tmp
+				else
+					echo yes > ../conftest.tmp
+					rm -f ./*.out
+					continue
+				fi
+			fi
+			break
+		done
+	) >&AC_FD_CC 2>&1
+	cf_cv_make_PHONY="`cat conftest.tmp`"
+	rm -rf conftest*
+])
+MAKE_NO_PHONY="#"
+MAKE_PHONY="#"
+test "x$cf_cv_make_PHONY" = xyes && MAKE_PHONY=
+test "x$cf_cv_make_PHONY" != xyes && MAKE_NO_PHONY=
+AC_SUBST(MAKE_NO_PHONY)
+AC_SUBST(MAKE_PHONY)
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
 dnl ------------
 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
@@ -1817,7 +2589,7 @@
 AC_SUBST(MAKE_LOWER_TAGS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_MATH_LIB version: 8 updated: 2010/05/29 16:31:02
+dnl CF_MATH_LIB version: 11 updated: 2022/07/27 19:01:48
 dnl -----------
 dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
 dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
@@ -1827,21 +2599,46 @@
 AC_CACHE_CHECK(if -lm needed for math functions,
 	cf_cv_need_libm,[
 	AC_TRY_LINK([
-	#include <stdio.h>
-	#include <math.h>
+		#include <stdio.h>
+		#include <stdlib.h>
+		#include <math.h>
 	],
-	[double x = rand(); printf("result = %g\n", ]ifelse([$2],,sin(x),$2)[)],
+	[double x = rand(); printf("result = %g\\n", ]ifelse([$2],,sin(x),$2)[)],
 	[cf_cv_need_libm=no],
 	[cf_cv_need_libm=yes])])
+
 if test "$cf_cv_need_libm" = yes
 then
-ifelse($1,,[
-	CF_ADD_LIB(m)
-],[$1=-lm])
+
+	cf_save_LIBS="$LIBS"
+	LIBS="$LIBS -lm"
+	AC_CACHE_CHECK(if -lm is available for math functions,
+	cf_cv_have_libm,[
+	AC_TRY_LINK([
+		#include <stdio.h>
+		#include <stdlib.h>
+		#include <math.h>
+	],
+	[double x = rand(); printf("result = %g\\n", ]ifelse([$2],,sin(x),$2)[)],
+	[cf_cv_have_libm=yes],
+	[cf_cv_have_libm=no])])
+	LIBS="$cf_save_LIBS"
+
+	if test "$cf_cv_have_libm" = yes
+	then
+		ifelse($1,,[CF_ADD_LIB(m)],[$1=-lm])
+	fi
+else
+	cf_cv_have_libm=yes
+fi
+
+if test "$cf_cv_have_libm" = yes
+then
+	AC_DEFINE(HAVE_MATH_FUNCS,1,[Define to 1 if math functions are available])
 fi
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_MIXEDCASE_FILENAMES version: 7 updated: 2015/04/12 15:39:00
+dnl CF_MIXEDCASE_FILENAMES version: 9 updated: 2021/01/01 16:53:59
 dnl ----------------------
 dnl Check if the file-system supports mixed-case filenames.  If we're able to
 dnl create a lowercase name and see it as uppercase, it doesn't support that.
@@ -1849,8 +2646,8 @@
 [
 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
 if test "$cross_compiling" = yes ; then
-	case $target_alias in
-	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*)
+	case "$target_alias" in
+	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*|darwin*)
 		cf_cv_mixedcase=no
 		;;
 	(*)
@@ -1879,7 +2676,7 @@
 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_NCURSES_CC_CHECK version: 4 updated: 2007/07/29 10:39:05
+dnl CF_NCURSES_CC_CHECK version: 6 updated: 2023/02/18 17:47:58
 dnl -------------------
 dnl Check if we can compile with ncurses' header file
 dnl $1 is the cache variable to set
@@ -1896,15 +2693,15 @@
 #ifdef NCURSES_VERSION
 ]ifelse($3,ncursesw,[
 #ifndef WACS_BSSB
-	make an error
+	#error WACS_BSSB is not defined
 #endif
 ])[
-printf("%s\n", NCURSES_VERSION);
+printf("%s\\n", NCURSES_VERSION);
 #else
 #ifdef __NCURSES_H
-printf("old\n");
+printf("old\\n");
 #else
-	make an error
+	#error __NCURSES_H is not defined
 #endif
 #endif
 	]
@@ -1912,7 +2709,7 @@
 	,[$1=no])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_NCURSES_CONFIG version: 17 updated: 2015/07/07 04:22:07
+dnl CF_NCURSES_CONFIG version: 28 updated: 2021/08/28 15:20:37
 dnl -----------------
 dnl Tie together the configure-script macros for ncurses, preferring these in
 dnl order:
@@ -1934,17 +2731,53 @@
 		AC_MSG_CHECKING(if the $cf_ncuconfig_root package files work)
 		cf_have_ncuconfig=unknown
 
+		cf_save_CFLAGS="$CFLAGS"
 		cf_save_CPPFLAGS="$CPPFLAGS"
 		cf_save_LIBS="$LIBS"
 
-		CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags $cf_ncuconfig_root`"
-		CF_ADD_LIBS(`$PKG_CONFIG --libs $cf_ncuconfig_root`)
+		cf_pkg_cflags="`$PKG_CONFIG --cflags $cf_ncuconfig_root`"
+		cf_pkg_libs="`$PKG_CONFIG --libs $cf_ncuconfig_root`"
+
+		# while -W for passing linker flags is prevalent, it is not "standard".
+		# At least one wrapper for c89/c99 (in Apple's xcode) has its own
+		# incompatible _and_ non-standard -W option which gives an error.  Work
+		# around that pitfall.
+		case "x${CC}@@${cf_pkg_libs}@${cf_pkg_cflags}" in
+		(x*c[[89]]9@@*-W*)
+			CF_ADD_CFLAGS($cf_pkg_cflags)
+			CF_ADD_LIBS($cf_pkg_libs)
+
+			AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
+				[initscr(); mousemask(0,0); tigetstr((char *)0);],
+				[AC_TRY_RUN([#include <${cf_cv_ncurses_header:-curses.h}>
+					int main(void)
+					{ const char *xx = curses_version(); return (xx == 0); }],
+					[cf_test_ncuconfig=yes],
+					[cf_test_ncuconfig=no],
+					[cf_test_ncuconfig=maybe])],
+				[cf_test_ncuconfig=no])
+
+			CFLAGS="$cf_save_CFLAGS"
+			CPPFLAGS="$cf_save_CPPFLAGS"
+			LIBS="$cf_save_LIBS"
+
+			if test "x$cf_test_ncuconfig" != xyes; then
+				cf_temp=`echo "x$cf_pkg_cflags" | sed -e s/^x// -e 's/-W[[^ 	]]*//g'`
+				cf_pkg_cflags="$cf_temp"
+				cf_temp=`echo "x$cf_pkg_libs" | sed -e s/^x// -e 's/-W[[^ 	]]*//g'`
+				cf_pkg_libs="$cf_temp"
+			fi
+			;;
+		esac
+
+		CF_APPEND_CFLAGS($cf_pkg_cflags)
+		CF_ADD_LIBS($cf_pkg_libs)
 
 		AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
-			[initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
+			[initscr(); mousemask(0,0); tigetstr((char *)0);],
 			[AC_TRY_RUN([#include <${cf_cv_ncurses_header:-curses.h}>
 				int main(void)
-				{ char *xx = curses_version(); return (xx == 0); }],
+				{ const char *xx = curses_version(); return (xx == 0); }],
 				[cf_have_ncuconfig=yes],
 				[cf_have_ncuconfig=no],
 				[cf_have_ncuconfig=maybe])],
@@ -1959,6 +2792,7 @@
 		else
 			AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
 			NCURSES_CONFIG_PKG=$cf_ncuconfig_root
+			CF_TERM_HEADER
 		fi
 
 	else
@@ -1970,15 +2804,15 @@
 fi
 
 if test "x$cf_have_ncuconfig" = "xno"; then
-	echo "Looking for ${cf_ncuconfig_root}-config"
+	cf_ncurses_config="${cf_ncuconfig_root}${NCURSES_CONFIG_SUFFIX}-config"; echo "Looking for ${cf_ncurses_config}"
 
 	CF_ACVERSION_CHECK(2.52,
-		[AC_CHECK_TOOLS(NCURSES_CONFIG, ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)],
-		[AC_PATH_PROGS(NCURSES_CONFIG,  ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)])
+		[AC_CHECK_TOOLS(NCURSES_CONFIG, ${cf_ncurses_config} ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)],
+		[AC_PATH_PROGS(NCURSES_CONFIG,  ${cf_ncurses_config} ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)])
 
 	if test "$NCURSES_CONFIG" != none ; then
 
-		CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
+		CF_APPEND_CFLAGS(`$NCURSES_CONFIG --cflags`)
 		CF_ADD_LIBS(`$NCURSES_CONFIG --libs`)
 
 		# even with config script, some packages use no-override for curses.h
@@ -1992,7 +2826,7 @@
 		AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
 
 		dnl like CF_NCURSES_VERSION
-		cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
+		cf_cv_ncurses_version="`$NCURSES_CONFIG --version`"
 
 	else
 
@@ -2005,7 +2839,7 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_NCURSES_CPPFLAGS version: 21 updated: 2012/10/06 08:57:51
+dnl CF_NCURSES_CPPFLAGS version: 22 updated: 2021/01/02 09:31:20
 dnl -------------------
 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
 dnl the CPPFLAGS variable so we can include its header.
@@ -2039,7 +2873,7 @@
 
 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
 	cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
-	( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
+	{ test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw; } && cf_header_list="$cf_header_list curses.h ncurses.h"
 	for cf_header in $cf_header_list
 	do
 		CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
@@ -2091,7 +2925,7 @@
 test "$cf_cv_ncurses_ext_funcs" = yes && AC_DEFINE(NCURSES_EXT_FUNCS,1,[Define to 1 if we have ncurses extensions])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_NCURSES_HEADER version: 4 updated: 2015/04/15 19:08:48
+dnl CF_NCURSES_HEADER version: 7 updated: 2021/01/04 19:33:05
 dnl -----------------
 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
 dnl variations of ncurses' installs.
@@ -2106,7 +2940,7 @@
 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
 	test -n "$verbose" && echo
 	CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
-	test -n "$verbose" && echo search path $cf_search
+	test -n "$verbose" && echo "search path $cf_search"
 	cf_save2_CPPFLAGS="$CPPFLAGS"
 	for cf_incdir in $cf_search
 	do
@@ -2118,7 +2952,7 @@
 			CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
 			if test "$cf_cv_ncurses_h2" != no ; then
 				cf_cv_ncurses_h2=$cf_incdir/$cf_header
-				test -n "$verbose" && echo $ac_n "	... found $ac_c" 1>&AC_FD_MSG
+				test -n "$verbose" && echo $ECHO_N "	... found $ECHO_C" 1>&AC_FD_MSG
 				break
 			fi
 			test -n "$verbose" && echo "	... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
@@ -2130,9 +2964,9 @@
 	])
 
 	CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
-	cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
-	if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
-		cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
+	cf_cv_ncurses_header="`basename "$cf_cv_ncurses_h2"`"
+	if test "`basename "$cf_1st_incdir"`" = "$cf_ncuhdr_root" ; then
+		cf_cv_ncurses_header="$cf_ncuhdr_root/$cf_cv_ncurses_header"
 	fi
 	CF_ADD_INCDIR($cf_1st_incdir)
 
@@ -2140,13 +2974,13 @@
 
 # Set definitions to allow ifdef'ing for ncurses.h
 
-case $cf_cv_ncurses_header in
+case "$cf_cv_ncurses_header" in
 (*ncurses.h)
 	AC_DEFINE(HAVE_NCURSES_H,1,[Define to 1 if we have ncurses.h])
 	;;
 esac
 
-case $cf_cv_ncurses_header in
+case "$cf_cv_ncurses_header" in
 (ncurses/curses.h|ncurses/ncurses.h)
 	AC_DEFINE(HAVE_NCURSES_NCURSES_H,1,[Define to 1 if we have ncurses/ncurses.h])
 	;;
@@ -2157,7 +2991,7 @@
 
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_NCURSES_LIBS version: 17 updated: 2015/04/15 19:08:48
+dnl CF_NCURSES_LIBS version: 21 updated: 2021/09/04 06:37:12
 dnl ---------------
 dnl Look for the ncurses library.  This is a little complicated on Linux,
 dnl because it may be linked with the gpm (general purpose mouse) library.
@@ -2183,10 +3017,10 @@
 		[LIBS="$cf_ncurses_SAVE"],
 		[cf_ncurses_LIBS="-lgpm"])])
 
-case $host_os in
+case "$host_os" in
 (freebsd*)
 	# This is only necessary if you are linking against an obsolete
-	# version of ncurses (but it should do no harm, since it's static).
+	# version of ncurses (but it should do no harm, since it is static).
 	if test "$cf_nculib_root" = ncurses ; then
 		AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
 	fi
@@ -2195,7 +3029,7 @@
 
 CF_ADD_LIBS($cf_ncurses_LIBS)
 
-if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
+if test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no"
 then
 	CF_ADD_LIBS(-l$cf_nculib_root)
 else
@@ -2209,13 +3043,13 @@
 	AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
 	cf_ncurses_SAVE="$LIBS"
 	for p in $cf_ncurses_LIBS ; do
-		q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
+		q=`echo "$LIBS" | sed -e "s%$p %%" -e "s%$p$%%"`
 		if test "$q" != "$LIBS" ; then
 			LIBS="$q"
 		fi
 	done
 	AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
-		[initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
+		[initscr(); mousemask(0,0); tigetstr((char *)0);],
 		[AC_MSG_RESULT(yes)],
 		[AC_MSG_RESULT(no)
 		 LIBS="$cf_ncurses_SAVE"])
@@ -2225,7 +3059,22 @@
 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_NCURSES_VERSION version: 14 updated: 2012/10/06 08:57:51
+dnl CF_NCURSES_PTHREADS version: 2 updated: 2016/04/22 05:07:41
+dnl -------------------
+dnl Use this followup check to ensure that we link with pthreads if ncurses
+dnl uses it.
+AC_DEFUN([CF_NCURSES_PTHREADS],[
+: ${cf_nculib_root:=ifelse($1,,ncurses,$1)}
+AC_CHECK_LIB($cf_nculib_root,_nc_init_pthreads,
+	cf_cv_ncurses_pthreads=yes,
+	cf_cv_ncurses_pthreads=no)
+if test "$cf_cv_ncurses_pthreads" = yes
+then
+	CF_ADD_LIBS(-lpthread)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_NCURSES_VERSION version: 18 updated: 2024/01/07 06:34:16
 dnl ------------------
 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
@@ -2236,24 +3085,26 @@
 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
 	cf_cv_ncurses_version=no
 	cf_tempfile=out$$
-	rm -f $cf_tempfile
+	rm -f "$cf_tempfile"
 	AC_TRY_RUN([
+$ac_includes_default
+
 #include <${cf_cv_ncurses_header:-curses.h}>
-#include <stdio.h>
-int main()
+
+int main(void)
 {
 	FILE *fp = fopen("$cf_tempfile", "w");
 #ifdef NCURSES_VERSION
 # ifdef NCURSES_VERSION_PATCH
-	fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
+	fprintf(fp, "%s.%d\\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
 # else
-	fprintf(fp, "%s\n", NCURSES_VERSION);
+	fprintf(fp, "%s\\n", NCURSES_VERSION);
 # endif
 #else
 # ifdef __NCURSES_H
-	fprintf(fp, "old\n");
+	fprintf(fp, "old\\n");
 # else
-	make an error
+	#error expected ncurses header to define __NCURSES_H
 # endif
 #endif
 	${cf_cv_main_return:-return}(0);
@@ -2262,7 +3113,7 @@
 
 	# This will not work if the preprocessor splits the line after the
 	# Autoconf token.  The 'unproto' program does that.
-	cat > conftest.$ac_ext <<EOF
+	cat > "conftest.$ac_ext" <<EOF
 #include <${cf_cv_ncurses_header:-curses.h}>
 #undef Autoconf
 #ifdef NCURSES_VERSION
@@ -2277,12 +3128,12 @@
 	cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
 	AC_TRY_EVAL(cf_try)
 	if test -f conftest.out ; then
-		cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
+		cf_out=`sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%' conftest.out`
 		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
 		rm -f conftest.out
 	fi
 ])
-	rm -f $cf_tempfile
+	rm -f "$cf_tempfile"
 ])
 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
 ])dnl
@@ -2342,23 +3193,33 @@
 test "$cf_cv_netbsd_menu_h" = yes && AC_DEFINE(HAVE_NETBSD_MENU_H,1,[Define to 1 if we appear to be using NetBSD menu.h])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_NO_LEAKS_OPTION version: 6 updated: 2015/04/12 15:39:00
+dnl CF_NO_LEAKS_OPTION version: 9 updated: 2021/06/13 19:45:41
 dnl ------------------
 dnl see CF_WITH_NO_LEAKS
+dnl
+dnl $1 = option/name
+dnl $2 = help-text
+dnl $3 = symbol to define if the option is set
+dnl $4 = additional actions to take if the option is set
 AC_DEFUN([CF_NO_LEAKS_OPTION],[
 AC_MSG_CHECKING(if you want to use $1 for testing)
 AC_ARG_WITH($1,
 	[$2],
-	[AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
+	[case "x$withval" in
+	(x|xno) ;;
+	(*)
+		: "${with_cflags:=-g}"
+		: "${enable_leaks:=no}"
+		with_$1=yes
+		AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
 	 $4
 ])
-	: ${with_cflags:=-g}
-	: ${with_no_leaks:=yes}
-	 with_$1=yes],
+		;;
+	esac],
 	[with_$1=])
 AC_MSG_RESULT(${with_$1:-no})
 
-case .$with_cflags in
+case ".$with_cflags" in
 (.*-g*)
 	case .$CFLAGS in
 	(.*-g*)
@@ -2371,7 +3232,7 @@
 esac
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
+dnl CF_PATH_SYNTAX version: 18 updated: 2020/12/31 18:40:20
 dnl --------------
 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
 dnl begins with one of the prefix/exec_prefix variables, and then again if the
@@ -2391,16 +3252,16 @@
 	;;
 (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
 	;;
-(.\[$]{*prefix}*|.\[$]{*dir}*)
+(.\[$]\{*prefix\}*|.\[$]\{*dir\}*)
 	eval $1="[$]$1"
 	case ".[$]$1" in
 	(.NONE/*)
-		$1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
+		$1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
 		;;
 	esac
 	;;
 (.no|.NONE/*)
-	$1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
+	$1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
 	;;
 (*)
 	ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
@@ -2408,7 +3269,7 @@
 esac
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_PDCURSES_X11 version: 13 updated: 2012/10/06 16:39:58
+dnl CF_PDCURSES_X11 version: 15 updated: 2021/01/02 09:31:20
 dnl ---------------
 dnl Configure for PDCurses' X11 library
 AC_DEFUN([CF_PDCURSES_X11],[
@@ -2420,7 +3281,7 @@
 
 if test "$XCURSES_CONFIG" != none ; then
 
-CPPFLAGS="$CPPFLAGS `$XCURSES_CONFIG --cflags`"
+CF_ADD_CFLAGS(`$XCURSES_CONFIG --cflags`)
 CF_ADD_LIBS(`$XCURSES_CONFIG --libs`)
 
 cf_cv_lib_XCurses=yes
@@ -2444,7 +3305,7 @@
 
 fi
 
-if test $cf_cv_lib_XCurses = yes ; then
+if test "$cf_cv_lib_XCurses" = yes ; then
 	AC_DEFINE(UNIX,1,[Define to 1 if using PDCurses on Unix])
 	AC_DEFINE(XCURSES,1,[Define to 1 if using PDCurses on Unix])
 	AC_CHECK_HEADER(xcurses.h, AC_DEFINE(HAVE_XCURSES,1,[Define to 1 if using PDCurses on Unix]))
@@ -2453,19 +3314,21 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_PKG_CONFIG version: 10 updated: 2015/04/26 18:06:58
+dnl CF_PKG_CONFIG version: 13 updated: 2023/10/28 11:59:01
 dnl -------------
 dnl Check for the package-config program, unless disabled by command-line.
+dnl
+dnl Sets $PKG_CONFIG to the pathname of the pkg-config program.
 AC_DEFUN([CF_PKG_CONFIG],
 [
 AC_MSG_CHECKING(if you want to use pkg-config)
 AC_ARG_WITH(pkg-config,
-	[  --with-pkg-config{=path} enable/disable use of pkg-config],
+	[[  --with-pkg-config[=CMD] enable/disable use of pkg-config and its name CMD]],
 	[cf_pkg_config=$withval],
 	[cf_pkg_config=yes])
 AC_MSG_RESULT($cf_pkg_config)
 
-case $cf_pkg_config in
+case "$cf_pkg_config" in
 (no)
 	PKG_CONFIG=none
 	;;
@@ -2489,7 +3352,7 @@
 AC_SUBST(PKG_CONFIG)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_POSIX_C_SOURCE version: 9 updated: 2015/04/12 15:39:00
+dnl CF_POSIX_C_SOURCE version: 12 updated: 2023/02/18 17:41:25
 dnl -----------------
 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
 dnl
@@ -2504,7 +3367,10 @@
 dnl Parameters:
 dnl	$1 is the nominal value for _POSIX_C_SOURCE
 AC_DEFUN([CF_POSIX_C_SOURCE],
-[
+[AC_REQUIRE([CF_POSIX_VISIBLE])dnl
+
+if test "$cf_cv_posix_visible" = no; then
+
 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
 
 cf_save_CFLAGS="$CFLAGS"
@@ -2517,7 +3383,7 @@
 	CF_MSG_LOG(if the symbol is already defined go no further)
 	AC_TRY_COMPILE([#include <sys/types.h>],[
 #ifndef _POSIX_C_SOURCE
-make an error
+#error _POSIX_C_SOURCE is not defined
 #endif],
 	[cf_cv_posix_c_source=no],
 	[cf_want_posix_source=no
@@ -2536,17 +3402,18 @@
 	 if test "$cf_want_posix_source" = yes ; then
 		AC_TRY_COMPILE([#include <sys/types.h>],[
 #ifdef _POSIX_SOURCE
-make an error
+#error _POSIX_SOURCE is defined
 #endif],[],
 		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
 	 fi
 	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
 	 CFLAGS="$cf_trim_CFLAGS"
-	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
+	 CPPFLAGS="$cf_trim_CPPFLAGS"
+	 CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source)
 	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
 	 AC_TRY_COMPILE([#include <sys/types.h>],[
 #ifndef _POSIX_C_SOURCE
-make an error
+#error _POSIX_C_SOURCE is not defined
 #endif],,
 	 [cf_cv_posix_c_source=no])
 	 CFLAGS="$cf_save_CFLAGS"
@@ -2560,9 +3427,38 @@
 	CF_ADD_CFLAGS($cf_cv_posix_c_source)
 fi
 
+fi # cf_cv_posix_visible
+
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
+dnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17
+dnl ----------------
+dnl POSIX documents test-macros which an application may set before any system
+dnl headers are included to make features available.
+dnl
+dnl Some BSD platforms (originally FreeBSD, but copied by a few others)
+dnl diverged from POSIX in 2002 by setting symbols which make all of the most
+dnl recent features visible in the system header files unless the application
+dnl overrides the corresponding test-macros.  Doing that introduces portability
+dnl problems.
+dnl
+dnl This macro makes a special check for the symbols used for this, to avoid a
+dnl conflicting definition.
+AC_DEFUN([CF_POSIX_VISIBLE],
+[
+AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[
+AC_TRY_COMPILE([#include <stdio.h>],[
+#if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
+	&& defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
+	&& defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
+	&& defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
+#error conflicting symbols found
+#endif
+],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
+])
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_PRG_RULES version: 2 updated: 2021/01/01 13:31:04
 dnl ------------
 dnl Append definitions and rules for the given programs to the subdirectory
 dnl Makefiles, and the recursion rule for the top-level Makefile.
@@ -2577,20 +3473,24 @@
 [
 for cf_dir in $2
 do
-	if test ! -d $srcdir/$cf_dir; then
+	if test ! -d "$srcdir/$cf_dir" ; then
 		continue
-	elif test -f $srcdir/$cf_dir/programs; then
-		$AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
+	elif test -f "$srcdir/$cf_dir/programs" ; then
+		$AWK -f $1 "$srcdir/$cf_dir/programs" >>$cf_dir/Makefile
 	fi
 done
 
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_PROG_CC version: 4 updated: 2014/07/12 18:57:58
+dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54
 dnl ----------
 dnl standard check for CC, plus followup sanity checks
 dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
 AC_DEFUN([CF_PROG_CC],[
+CF_ACVERSION_CHECK(2.53,
+	[AC_MSG_WARN(this will incorrectly handle gnatgcc choice)
+	 AC_REQUIRE([AC_PROG_CC])],
+	[])
 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
 CF_GCC_VERSION
 CF_ACVERSION_CHECK(2.52,
@@ -2599,7 +3499,7 @@
 CF_CC_ENV_FLAGS
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_PROG_INSTALL version: 7 updated: 2015/04/18 08:56:57
+dnl CF_PROG_INSTALL version: 10 updated: 2021/01/04 19:33:05
 dnl ---------------
 dnl Force $INSTALL to be an absolute-path.  Otherwise, edit_man.sh and the
 dnl misc/tabset install won't work properly.  Usually this happens only when
@@ -2612,17 +3512,41 @@
 (*)
 	CF_DIRNAME(cf_dir,$INSTALL)
 	test -z "$cf_dir" && cf_dir=.
-	INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
+	INSTALL="`cd \"$cf_dir\" && pwd`"/"`echo "$INSTALL" | sed -e 's%^.*/%%'`"
 	;;
 esac
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
+dnl CF_PROG_LINT version: 5 updated: 2022/08/20 15:44:13
 dnl ------------
 AC_DEFUN([CF_PROG_LINT],
 [
-AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
+AC_CHECK_PROGS(LINT, lint cppcheck splint)
+case "x$LINT" in
+(xcppcheck|x*/cppcheck)
+	test -z "$LINT_OPTS" && LINT_OPTS="--enable=all"
+	;;
+esac
 AC_SUBST(LINT_OPTS)
+AC_SUBST(LINT_LIBS)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_REMOVE_CFLAGS version: 3 updated: 2021/09/05 17:25:40
+dnl ----------------
+dnl Remove a given option from CFLAGS/CPPFLAGS
+dnl $1 = option to remove
+dnl $2 = variable to update
+dnl $3 = nonempty to allow verbose message
+define([CF_REMOVE_CFLAGS],
+[
+cf_tmp_cflag=`echo "x$1" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x[$]$2" | sed -e 's/^.//' -e 's/[[ 	]][[ 	]]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[[^ 	]][[^ 	]]*\\)\?%%" -e 's/^[[ 	]]*//' -e 's%[[ ]][[ ]]*-D% -D%g' -e 's%[[ ]][[ ]]*-I% -I%g'`
+	test "[$]$2" != "$cf_old_cflag" || break
+	ifelse([$3],,,[CF_VERBOSE(removing old option $1 from $2)])
+	$2="$cf_old_cflag"
+done
 ])dnl
 dnl ---------------------------------------------------------------------------
 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
@@ -2642,11 +3566,23 @@
 		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_RPATH_HACK version: 11 updated: 2013/09/01 13:02:00
+dnl CF_RESTORE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:47:45
+dnl ---------------------
+dnl Restore flags saved in CF_SAVE_XTRA_FLAGS
+dnl $1 = name of current macro
+define([CF_RESTORE_XTRA_FLAGS],
+[
+LIBS="$cf_save_LIBS_$1"
+CFLAGS="$cf_save_CFLAGS_$1"
+CPPFLAGS="$cf_save_CPPFLAGS_$1"
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_RPATH_HACK version: 13 updated: 2021/01/03 18:30:50
 dnl -------------
 AC_DEFUN([CF_RPATH_HACK],
-[
-AC_REQUIRE([CF_LD_RPATH_OPT])
+[AC_REQUIRE([AC_PROG_FGREP])dnl
+AC_REQUIRE([CF_LD_RPATH_OPT])dnl
+
 AC_MSG_CHECKING(for updated LDFLAGS)
 if test -n "$LD_RPATH_OPT" ; then
 	AC_MSG_RESULT(maybe)
@@ -2659,8 +3595,8 @@
 
 AC_TRY_LINK([#include <stdio.h>],
 		[printf("Hello");],
-		[cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
-		 cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
+		[cf_rpath_oops=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
+		 cf_rpath_list=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
 
 		# If we passed the link-test, but get a "not found" on a given library,
 		# this could be due to inept reconfiguration of gcc to make it only
@@ -2676,7 +3612,7 @@
 					/usr/pkg \
 					/opt/sfw
 				do
-					if test -f $cf_rpath_dir/lib/$cf_rpath_src
+					if test -f "$cf_rpath_dir/lib/$cf_rpath_src"
 					then
 						CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
 						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
@@ -2699,7 +3635,7 @@
 AC_SUBST(EXTRA_LDFLAGS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_RPATH_HACK_2 version: 7 updated: 2015/04/12 15:39:00
+dnl CF_RPATH_HACK_2 version: 8 updated: 2021/01/01 13:31:04
 dnl ---------------
 dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
 dnl EXTRA_LDFLAGS for each -L option found.
@@ -2715,7 +3651,7 @@
 cf_rpath_dst=
 for cf_rpath_src in [$]$1
 do
-	case $cf_rpath_src in
+	case "$cf_rpath_src" in
 	(-L*)
 
 		# check if this refers to a directory which we will ignore
@@ -2759,9 +3695,93 @@
 AC_SUBST(EXTRA_LDFLAGS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_SIG_ATOMIC_T version: 3 updated: 2012/10/04 20:12:20
+dnl CF_SAVE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:46:44
+dnl ------------------
+dnl Use this macro to save CFLAGS/CPPFLAGS/LIBS before checks against X headers
+dnl and libraries which do not update those variables.
+dnl
+dnl $1 = name of current macro
+define([CF_SAVE_XTRA_FLAGS],
+[
+cf_save_LIBS_$1="$LIBS"
+cf_save_CFLAGS_$1="$CFLAGS"
+cf_save_CPPFLAGS_$1="$CPPFLAGS"
+LIBS="$LIBS ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}"
+for cf_X_CFLAGS in $X_CFLAGS
+do
+	case "x$cf_X_CFLAGS" in
+	x-[[IUD]]*)
+		CPPFLAGS="$CPPFLAGS $cf_X_CFLAGS"
+		;;
+	*)
+		CFLAGS="$CFLAGS $cf_X_CFLAGS"
+		;;
+	esac
+done
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_SIGWINCH version: 7 updated: 2023/02/18 17:41:25
+dnl -----------
+dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
+dnl programs need this test).
+dnl
+dnl This is really a Mac OS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
+dnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
+dnl winsize declaration is left alone - we may revisit this if Apple choose to
+dnl break that part of the interface as well.
+AC_DEFUN([CF_SIGWINCH],
+[
+AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
+	AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/signal.h>
+],[int x = SIGWINCH; (void)x],
+	[cf_cv_define_sigwinch=yes],
+	[AC_TRY_COMPILE([
+#undef _XOPEN_SOURCE
+#undef _POSIX_SOURCE
+#undef _POSIX_C_SOURCE
+#include <sys/types.h>
+#include <sys/signal.h>
+],[int x = SIGWINCH; (void)x],
+	[cf_cv_define_sigwinch=maybe],
+	[cf_cv_define_sigwinch=no])
+])
+])
+
+if test "$cf_cv_define_sigwinch" = maybe ; then
+AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
+cf_cv_fixup_sigwinch=unknown
+cf_sigwinch=32
+while test "$cf_sigwinch" != 1
+do
+	AC_TRY_COMPILE([
+#undef _XOPEN_SOURCE
+#undef _POSIX_SOURCE
+#undef _POSIX_C_SOURCE
+#include <sys/types.h>
+#include <sys/signal.h>
+],[
+#if SIGWINCH != $cf_sigwinch
+#error SIGWINCH is not $cf_sigwinch
+#endif
+int x = SIGWINCH; (void)x],
+	[cf_cv_fixup_sigwinch=$cf_sigwinch
+	 break])
+
+cf_sigwinch="`expr "$cf_sigwinch" - 1`"
+done
+])
+
+	if test "$cf_cv_fixup_sigwinch" != unknown ; then
+		CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
+	fi
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_SIG_ATOMIC_T version: 5 updated: 2020/03/10 18:53:47
 dnl ---------------
-dnl signal handler, but there are some gcc depedencies in that recommendation.
+dnl signal handler, but there are some gcc dependencies in that recommendation.
 dnl Try anyway.
 AC_DEFUN([CF_SIG_ATOMIC_T],
 [
@@ -2781,6 +3801,7 @@
 $cf_type x;
 static void handler(int sig)
 {
+	(void)sig;
 	x = 5;
 }],
 		[signal(SIGINT, handler);
@@ -2841,14 +3862,14 @@
 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT,1,[Define to 1 if we can include <sys/time.h> with <sys/select.h>])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_TERM_HEADER version: 4 updated: 2015/04/15 19:08:48
+dnl CF_TERM_HEADER version: 6 updated: 2021/01/02 09:31:20
 dnl --------------
 dnl Look for term.h, which is part of X/Open curses.  It defines the interface
 dnl to terminfo database.  Usually it is in the same include-path as curses.h,
 dnl but some packagers change this, breaking various applications.
 AC_DEFUN([CF_TERM_HEADER],[
 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
-case ${cf_cv_ncurses_header} in
+case "${cf_cv_ncurses_header}" in
 (*/ncurses.h|*/ncursesw.h)
 	cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
 	;;
@@ -2862,7 +3883,7 @@
 AC_TRY_COMPILE([#include <stdio.h>
 #include <${cf_cv_ncurses_header:-curses.h}>
 #include <$cf_test>
-],[int x = auto_left_margin],[
+],[int x = auto_left_margin; (void)x],[
 	cf_cv_term_header="$cf_test"],[
 	cf_cv_term_header=unknown
 	])
@@ -2872,13 +3893,13 @@
 
 # Set definitions to allow ifdef'ing to accommodate subdirectories
 
-case $cf_cv_term_header in
+case "$cf_cv_term_header" in
 (*term.h)
 	AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
 	;;
 esac
 
-case $cf_cv_term_header in
+case "$cf_cv_term_header" in
 (ncurses/term.h)
 	AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
 	;;
@@ -2897,21 +3918,21 @@
 AC_SUBST(top_builddir)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_TPUTS_PROTO version: 3 updated: 2015/04/17 21:26:14
+dnl CF_TPUTS_PROTO version: 4 updated: 2021/01/04 19:45:09
 dnl --------------
 dnl Check for type of function-pointer passed to tputs.  Some old
 dnl implementations used functions that had different prototypes, making it
 dnl hard to compile portable programs using tputs.
 AC_DEFUN([CF_TPUTS_PROTO],[
 CF_CURSES_FUNCS(tputs)
-if test x$cf_cv_func_tputs = xyes
+if test "x$cf_cv_func_tputs" = xyes
 then
 	cf_done=no
 	for cf_arg in int char
 	do
 		for cf_ret in int void
 		do
-			if test $cf_ret = void
+			if test "$cf_ret" = void
 			then
 				cf_return="/* nothing */"
 			else
@@ -2936,7 +3957,7 @@
 		break
 ])
 		done
-		test $cf_done = yes && break
+		test "$cf_done" = yes && break
 	done
 fi
 ])dnl
@@ -2957,21 +3978,21 @@
 	done
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_TRY_PKG_CONFIG version: 5 updated: 2013/07/06 21:27:06
+dnl CF_TRY_PKG_CONFIG version: 6 updated: 2020/12/31 10:54:15
 dnl -----------------
 dnl This is a simple wrapper to use for pkg-config, for libraries which may be
 dnl available in that form.
 dnl
-dnl $1 = package name
+dnl $1 = package name, which may be a shell variable
 dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
 dnl $3 = logic to use if pkg-config does not have the package
 AC_DEFUN([CF_TRY_PKG_CONFIG],[
 AC_REQUIRE([CF_PKG_CONFIG])
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $1; then
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "$1"; then
 	CF_VERBOSE(found package $1)
-	cf_pkgconfig_incs="`$PKG_CONFIG --cflags $1 2>/dev/null`"
-	cf_pkgconfig_libs="`$PKG_CONFIG --libs   $1 2>/dev/null`"
+	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "$1" 2>/dev/null`"
+	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "$1" 2>/dev/null`"
 	CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
 	CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
 	CF_ADD_CFLAGS($cf_pkgconfig_incs)
@@ -2984,34 +4005,20 @@
 fi
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
+dnl CF_TRY_XOPEN_SOURCE version: 4 updated: 2022/09/10 15:16:16
 dnl -------------------
 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
 dnl can define it successfully.
 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
-	AC_TRY_COMPILE([
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-],[
-#ifndef _XOPEN_SOURCE
-make an error
-#endif],
+	AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,
 	[cf_cv_xopen_source=no],
 	[cf_save="$CPPFLAGS"
-	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
-	 AC_TRY_COMPILE([
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-],[
-#ifdef _XOPEN_SOURCE
-make an error
-#endif],
-	[cf_cv_xopen_source=no],
-	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
-	CPPFLAGS="$cf_save"
+	 CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
+	 AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,
+		[cf_cv_xopen_source=no],
+		[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
+		CPPFLAGS="$cf_save"
 	])
 ])
 
@@ -3019,7 +4026,7 @@
 	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
 	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
 	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
-	CF_ADD_CFLAGS($cf_temp_xopen_source)
+	CF_APPEND_CFLAGS($cf_temp_xopen_source)
 fi
 ])
 dnl ---------------------------------------------------------------------------
@@ -3032,15 +4039,20 @@
 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_UTF8_LIB version: 8 updated: 2012/10/06 08:57:51
+dnl CF_UTF8_LIB version: 10 updated: 2023/01/11 04:05:23
 dnl -----------
 dnl Check for multibyte support, and if not found, utf8 compatibility library
 AC_DEFUN([CF_UTF8_LIB],
 [
+AC_HAVE_HEADERS(wchar.h)
 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
 	cf_save_LIBS="$LIBS"
 	AC_TRY_LINK([
-#include <stdlib.h>],[putwc(0,0);],
+$ac_includes_default
+#ifdef HAVE_WCHAR_H
+#include <wchar.h>
+#endif
+],[putwc(0,0);],
 	[cf_cv_utf8_lib=yes],
 	[CF_FIND_LINKAGE([
 #include <libutf8.h>],[putwc(0,0);],utf8,
@@ -3066,7 +4078,7 @@
 CF_MSG_LOG([$1])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WCHAR_TYPE version: 4 updated: 2012/10/06 16:39:58
+dnl CF_WCHAR_TYPE version: 5 updated: 2023/12/03 09:21:34
 dnl -------------
 dnl Check if type wide-character type $1 is declared, and if so, which header
 dnl file is needed.  The second parameter is used to set a shell variable when
@@ -3083,7 +4095,7 @@
 #ifdef HAVE_LIBUTF8_H
 #include <libutf8.h>
 #endif],
-	[$1 state],
+	[$1 state; (void)state],
 	[cf_cv_$1=no],
 	[AC_TRY_COMPILE([
 #include <stdlib.h>
@@ -3093,7 +4105,7 @@
 #ifdef HAVE_LIBUTF8_H
 #include <libutf8.h>
 #endif],
-	[$1 value],
+	[$1 value; (void) value],
 	[cf_cv_$1=yes],
 	[cf_cv_$1=unknown])])])
 
@@ -3116,7 +4128,7 @@
 ])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_CURSES_DIR version: 3 updated: 2010/11/20 17:02:38
+dnl CF_WITH_CURSES_DIR version: 4 updated: 2021/01/02 19:22:58
 dnl ------------------
 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
 dnl libraries.
@@ -3129,7 +4141,7 @@
 	[cf_cv_curses_dir=no])
 AC_MSG_RESULT($cf_cv_curses_dir)
 
-if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
+if test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no"
 then
 	CF_PATH_SYNTAX(withval)
 	if test -d "$cf_cv_curses_dir"
@@ -3170,7 +4182,36 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_NCURSES_ETC version: 4 updated: 2015/04/25 20:53:11
+dnl CF_WITH_LIB_BASENAME version: 2 updated: 2023/11/22 20:48:30
+dnl --------------------
+dnl Allow for overriding the basename of a library, i.e., the part to which
+dnl prefixes/suffixes are attached.
+dnl
+dnl $1 = variable to set
+dnl $2 = option name
+dnl $3 = default basename for library, if omitted use $2
+AC_DEFUN([CF_WITH_LIB_BASENAME],
+[
+AC_MSG_CHECKING(for desired basename for $2 library)
+AC_ARG_WITH($2-libname,
+	[[  --with-$2-libname[=XXX] override ifelse($3,,$2,$3) basename of library]],
+	[with_lib_basename=$withval],
+	[with_lib_basename=ifelse($3,,$2,$3)])
+$1="$with_lib_basename"
+
+case "x[$]$1" in
+(x|xno|xnone|xyes)
+	$1=ifelse($3,,$2,$3)
+	;;
+(*)
+	;;
+esac
+
+AC_MSG_RESULT([$]$1)
+AC_SUBST($1)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_WITH_NCURSES_ETC version: 6 updated: 2023/01/16 10:10:06
 dnl -------------------
 dnl Use this macro for programs which use any variant of "curses", e.g.,
 dnl "ncurses", and "PDCurses".  Programs that can use curses and some unrelated
@@ -3229,6 +4270,26 @@
 	;;
 esac
 
+CF_NCURSES_PTHREADS($cf_cv_screen)
+AC_SUBST(cf_cv_screen)
+
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_WITH_SCREEN_PDCURSES version: 1 updated: 2020/08/28 16:56:27
+dnl -----------------------
+dnl Call this macro before CF_ENABLE_WARNINGS for configure scripts which use
+dnl the "--with-screen=pdcurses" selection.  Doing that allows the configure
+dnl script to search for the X11/Xt header files to declare (or not) the
+dnl symbol needed to enable "const" in those header files.  If that configure
+dnl option is not used, then those checks are unnecessary.
+AC_DEFUN([CF_WITH_SCREEN_PDCURSES],[
+AC_PROVIDE([AC_PATH_XTRA])
+AC_PROVIDE([AC_PATH_X])
+if test -n "$with_screen" && test "x$with_screen" = "xpdcurses"
+then
+	AC_PATH_X
+	AC_PATH_XTRA
+fi
 ])dnl
 dnl ---------------------------------------------------------------------------
 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
@@ -3239,7 +4300,93 @@
 	[USE_VALGRIND])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_XOPEN_CURSES version: 11 updated: 2011/01/18 18:15:30
+dnl CF_WITH_X11_RGB version: 3 updated: 2023/10/28 11:59:01
+dnl ---------------
+dnl Handle configure option "--with-x11-rgb", setting these shell
+dnl variables:
+dnl
+dnl $RGB_PATH is the option value, used for finding the X11 rgb file.
+dnl $no_x11_rgb is a "#" (comment) if "--without-x11-rgb" is given.
+dnl
+dnl Most Linux's use this:
+dnl 	/usr/share/X11/rgb.txt
+dnl Debian uses this:
+dnl 	/etc/X11/rgb.txt
+dnl DragonFlyBSD ports uses this:
+dnl 	/usr/pkg/lib/X11/rgb.txt
+dnl FreeBSD ports use these:
+dnl 	/usr/local/lib/X11/rgb.txt
+dnl 	/usr/local/share/X11/rgb.txt
+dnl Mandriva has these:
+dnl 	/usr/lib/X11/rgb.txt
+dnl 	/usr/lib64/X11/rgb.txt
+dnl NetBSD has these
+dnl 	/usr/X11R7/lib/X11/rgb.txt
+dnl OpenSolaris uses
+dnl 	32-bit:
+dnl 	/usr/X11/etc/X11/rgb.txt
+dnl 	/usr/X11/share/X11/rgb.txt
+dnl 	/usr/X11/lib/X11/rgb.txt
+dnl OSX uses
+dnl		/opt/local/share/X11/rgb.txt (MacPorts)
+dnl		/opt/X11/share/X11/rgb.txt (non-ports)
+dnl	64-bit:
+dnl 	/usr/X11/etc/X11/rgb.txt
+dnl 	/usr/X11/share/X11/rgb.txt (perhaps)
+dnl 	/usr/X11/lib/amd64/X11/rgb.txt
+dnl Solaris10 uses (in this order):
+dnl 	/usr/openwin/lib/X11/rgb.txt
+dnl 	/usr/X11/lib/X11/rgb.txt
+AC_DEFUN([CF_WITH_X11_RGB],[
+AC_MSG_CHECKING(for X11 rgb file)
+AC_ARG_WITH(x11-rgb,
+	[  --with-x11-rgb=FILE     obtain X11 color definitions from FILE (default: EPREFIX/lib/X11/rgb.txt)],
+	[RGB_PATH=$withval],
+	[RGB_PATH=auto])
+
+if test "x[$]RGB_PATH" = xauto
+then
+	RGB_PATH='${exec_prefix}/lib/X11/rgb.txt'
+	for cf_path in \
+		/opt/local/share/X11/rgb.txt \
+		/opt/X11/share/X11/rgb.txt \
+		/usr/share/X11/rgb.txt \
+		/usr/X11/share/X11/rgb.txt \
+		/usr/X11/lib/X11/rgb.txt \
+		/usr/lib/X11/rgb.txt \
+		/etc/X11/rgb.txt \
+		/usr/pkg/lib/X11/rgb.txt \
+		/usr/X11R7/lib/X11/rgb.txt \
+		/usr/X11R6/lib/X11/rgb.txt \
+		/usr/X11R5/lib/X11/rgb.txt \
+		/usr/X11R4/lib/X11/rgb.txt \
+		/usr/local/lib/X11/rgb.txt \
+		/usr/local/share/X11/rgb.txt \
+		/usr/lib64/X11/rgb.txt
+	do
+		if test -f "$cf_path" ; then
+			RGB_PATH="$cf_path"
+			break
+		fi
+	done
+else
+	cf_path=$RGB_PATH
+	CF_PATH_SYNTAX(cf_path)
+fi
+
+AC_MSG_RESULT($RGB_PATH)
+AC_SUBST(RGB_PATH)
+AC_DEFINE_UNQUOTED(RGB_PATH,"$cf_path",[Define to the full pathname of rgb.txt])
+
+no_x11_rgb=
+if test "$RGB_PATH" = no
+then
+	no_x11_rgb="#"
+fi
+AC_SUBST(no_x11_rgb)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_XOPEN_CURSES version: 20 updated: 2024/01/07 06:54:12
 dnl ---------------
 dnl Test if we should define X/Open source for curses, needed on Digital Unix
 dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
@@ -3249,36 +4396,63 @@
 AC_DEFUN([CF_XOPEN_CURSES],
 [
 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
-AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[
+AC_CACHE_CHECK(definition to turn on extended curses functions,cf_cv_need_xopen_extension,[
+cf_cv_need_xopen_extension=unknown
 AC_TRY_LINK([
-#include <stdlib.h>
+$ac_includes_default
 #include <${cf_cv_ncurses_header:-curses.h}>],[
 #if defined(NCURSES_VERSION_PATCH)
 #if (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
-	make an error
+	#error disallow ncurses versions between 2020/04/03 and 2010/05/01
 #endif
 #endif
-	long x = winnstr(stdscr, "", 0);
-	int x1, y1;
-	getbegyx(stdscr, y1, x1)],
-	[cf_cv_need_xopen_extension=no],
-	[AC_TRY_LINK([
-#define _XOPEN_SOURCE_EXTENDED
-#include <stdlib.h>
-#include <${cf_cv_ncurses_header:-curses.h}>],[
-#ifdef NCURSES_VERSION
+#ifdef NCURSES_WIDECHAR
+#error prefer to fall-through on the second checks
+#endif
+	static char dummy[10];
 	cchar_t check;
 	int check2 = curs_set((int)sizeof(check));
-#endif
-	long x = winnstr(stdscr, "", 0);
+	long x = winnstr(stdscr, dummy, 5);
 	int x1, y1;
-	getbegyx(stdscr, y1, x1)],
-	[cf_cv_need_xopen_extension=yes],
-	[cf_cv_need_xopen_extension=unknown])])])
-test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
+	(void)check2;
+	getbegyx(stdscr, y1, x1);
+	(void)x;
+	(void)y1;
+	(void)x1;
+	],
+	[cf_cv_need_xopen_extension=none],
+	[
+	for cf_try_xopen_extension in _XOPEN_SOURCE_EXTENDED NCURSES_WIDECHAR
+	do
+		AC_TRY_LINK([
+#define $cf_try_xopen_extension 1
+$ac_includes_default
+#include <${cf_cv_ncurses_header:-curses.h}>],[
+		static char dummy[10];
+		cchar_t check;
+		int check2 = curs_set((int)sizeof(check));
+		long x = winnstr(stdscr, dummy, 5);
+		int x1, y1;
+		getbegyx(stdscr, y1, x1);
+		(void)check2;
+		(void)x;
+		(void)y1;
+		(void)x1;
+		],
+		[cf_cv_need_xopen_extension=$cf_try_xopen_extension; break])
+	done
+	])
+])
+
+case "$cf_cv_need_xopen_extension" in
+(*_*)
+	CF_APPEND_TEXT(CPPFLAGS,-D$cf_cv_need_xopen_extension)
+	;;
+esac
+
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_XOPEN_SOURCE version: 49 updated: 2015/04/12 15:39:00
+dnl CF_XOPEN_SOURCE version: 67 updated: 2023/09/06 18:55:27
 dnl ---------------
 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
 dnl or adapt to the vendor's definitions to get equivalent functionality,
@@ -3287,20 +4461,32 @@
 dnl Parameters:
 dnl	$1 is the nominal value for _XOPEN_SOURCE
 dnl	$2 is the nominal value for _POSIX_C_SOURCE
+dnl
+dnl The default case prefers _XOPEN_SOURCE over _POSIX_C_SOURCE if the
+dnl implementation predefines it, because X/Open and most implementations agree
+dnl that the latter is a legacy or "aligned" value.
+dnl
+dnl Because _XOPEN_SOURCE is preferred, if defining _POSIX_C_SOURCE turns
+dnl that off, then refrain from setting _POSIX_C_SOURCE explicitly.
+dnl
+dnl References:
+dnl https://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html
+dnl https://docs.oracle.com/cd/E19253-01/816-5175/standards-5/index.html
+dnl https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
 AC_DEFUN([CF_XOPEN_SOURCE],[
 AC_REQUIRE([AC_CANONICAL_HOST])
+AC_REQUIRE([CF_POSIX_VISIBLE])
+
+if test "$cf_cv_posix_visible" = no; then
 
 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
 cf_xopen_source=
 
-case $host_os in
+case "$host_os" in
 (aix[[4-7]]*)
 	cf_xopen_source="-D_ALL_SOURCE"
 	;;
-(cygwin|msys)
-	cf_XOPEN_SOURCE=600
-	;;
 (darwin[[0-8]].*)
 	cf_xopen_source="-D_APPLE_C_SOURCE"
 	;;
@@ -3308,7 +4494,7 @@
 	cf_xopen_source="-D_DARWIN_C_SOURCE"
 	cf_XOPEN_SOURCE=
 	;;
-(freebsd*|dragonfly*)
+(freebsd*|dragonfly*|midnightbsd*)
 	# 5.x headers associate
 	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
 	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
@@ -3326,8 +4512,8 @@
 	cf_xopen_source="-D_SGI_SOURCE"
 	cf_XOPEN_SOURCE=
 	;;
-(linux*|gnu*|mint*|k*bsd*-gnu)
-	CF_GNU_SOURCE
+(linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys|mingw*|linux*uclibc)
+	CF_GNU_SOURCE($cf_XOPEN_SOURCE)
 	;;
 (minix*)
 	cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
@@ -3340,7 +4526,15 @@
 (netbsd*)
 	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
 	;;
-(openbsd[[4-9]]*)
+(openbsd[[6-9]]*)
+	# OpenBSD 6.x has broken locale support, both compile-time and runtime.
+	# see https://www.mail-archive.com/bugs@openbsd.org/msg13200.html
+	# Abusing the conformance level is a workaround.
+	AC_MSG_WARN(this system does not provide usable locale support)
+	cf_xopen_source="-D_BSD_SOURCE"
+	cf_XOPEN_SOURCE=700
+	;;
+(openbsd[[4-5]]*)
 	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
 	cf_xopen_source="-D_BSD_SOURCE"
 	cf_XOPEN_SOURCE=600
@@ -3367,12 +4561,20 @@
 	;;
 (*)
 	CF_TRY_XOPEN_SOURCE
+	cf_save_xopen_cppflags="$CPPFLAGS"
 	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
+	# Some of these niche implementations use copy/paste, double-check...
+	if test "$cf_cv_xopen_source" = no ; then
+		CF_VERBOSE(checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE)
+		AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,,[
+			AC_MSG_WARN(_POSIX_C_SOURCE definition is not usable)
+			CPPFLAGS="$cf_save_xopen_cppflags"])
+	fi
 	;;
 esac
 
 if test -n "$cf_xopen_source" ; then
-	CF_ADD_CFLAGS($cf_xopen_source,true)
+	CF_APPEND_CFLAGS($cf_xopen_source,true)
 fi
 
 dnl In anything but the default case, we may have system-specific setting
@@ -3382,20 +4584,20 @@
 	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
 	AC_TRY_COMPILE([#include <stdlib.h>],[
 #ifndef _XOPEN_SOURCE
-make an error
+#error _XOPEN_SOURCE is not defined
 #endif],
 	[cf_XOPEN_SOURCE_set=yes],
 	[cf_XOPEN_SOURCE_set=no])
 	AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
-	if test $cf_XOPEN_SOURCE_set = yes
+	if test "$cf_XOPEN_SOURCE_set" = yes
 	then
 		AC_TRY_COMPILE([#include <stdlib.h>],[
 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
-make an error
+#error (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
 #endif],
 		[cf_XOPEN_SOURCE_set_ok=yes],
 		[cf_XOPEN_SOURCE_set_ok=no])
-		if test $cf_XOPEN_SOURCE_set_ok = no
+		if test "$cf_XOPEN_SOURCE_set_ok" = no
 		then
 			AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
 		fi
@@ -3403,9 +4605,10 @@
 		CF_TRY_XOPEN_SOURCE
 	fi
 fi
+fi # cf_cv_posix_visible
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_X_ATHENA version: 23 updated: 2015/04/12 15:39:00
+dnl CF_X_ATHENA version: 25 updated: 2023/01/11 04:05:23
 dnl -----------
 dnl Check for Xaw (Athena) libraries
 dnl
@@ -3479,9 +4682,11 @@
 
 AC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
 AC_TRY_LINK([
+$ac_includes_default
 #include <X11/Xmu/CharSet.h>
 ],[
-int check = XmuCompareISOLatin1("big", "small")
+int check = XmuCompareISOLatin1("big", "small");
+(void)check;
 ],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
 
 			if test "$cf_cv_xaw_compat" = no
@@ -3517,12 +4722,13 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_X_ATHENA_CPPFLAGS version: 5 updated: 2010/05/26 17:35:30
+dnl CF_X_ATHENA_CPPFLAGS version: 9 updated: 2020/12/31 10:54:15
 dnl --------------------
 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
 AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
 [
+AC_REQUIRE([AC_PATH_XTRA])
 cf_x_athena_root=ifelse([$1],,Xaw,[$1])
 cf_x_athena_inc=""
 
@@ -3533,10 +4739,10 @@
 	/usr/local
 do
 	if test -z "$cf_x_athena_inc" ; then
-		cf_save="$CPPFLAGS"
+		CF_SAVE_XTRA_FLAGS([CF_X_ATHENA_CPPFLAGS])
 		cf_test=X11/$cf_x_athena_root/SimpleMenu.h
-		if test $cf_path != default ; then
-			CPPFLAGS="$cf_save -I$cf_path/include"
+		if test "$cf_path" != default ; then
+			CF_APPEND_TEXT(CPPFLAGS,-I$cf_path/include)
 			AC_MSG_CHECKING(for $cf_test in $cf_path)
 		else
 			AC_MSG_CHECKING(for $cf_test)
@@ -3547,24 +4753,23 @@
 			[cf_result=yes],
 			[cf_result=no])
 		AC_MSG_RESULT($cf_result)
+		CF_RESTORE_XTRA_FLAGS([CF_X_ATHENA_CPPFLAGS])
 		if test "$cf_result" = yes ; then
-			cf_x_athena_inc=$cf_path
+			test "$cf_path"  = default && cf_x_athena_inc=default
+			test "$cf_path" != default && cf_x_athena_inc="$cf_path/include"
 			break
-		else
-			CPPFLAGS="$cf_save"
 		fi
 	fi
 done
 
 if test -z "$cf_x_athena_inc" ; then
-	AC_MSG_WARN(
-[Unable to successfully find Athena header files with test program])
+	AC_MSG_WARN([Unable to find Athena header files])
 elif test "$cf_x_athena_inc" != default ; then
-	CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
+	CF_APPEND_TEXT(CPPFLAGS,-I$cf_x_athena_inc)
 fi
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_X_ATHENA_LIBS version: 12 updated: 2011/07/17 19:55:02
+dnl CF_X_ATHENA_LIBS version: 14 updated: 2023/01/11 04:05:23
 dnl ----------------
 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
@@ -3589,29 +4794,27 @@
 		"-l$cf_lib -lXpm -lXmu" \
 		"-l${cf_lib}_s -lXmu_s"
 	do
-		if test -z "$cf_x_athena_lib" ; then
-			cf_save="$LIBS"
-			cf_test=XawSimpleMenuAddGlobalActions
-			if test $cf_path != default ; then
-				CF_ADD_LIBS(-L$cf_path/lib $cf_libs)
-				AC_MSG_CHECKING(for $cf_libs in $cf_path)
-			else
-				CF_ADD_LIBS($cf_libs)
-				AC_MSG_CHECKING(for $cf_test in $cf_libs)
-			fi
-			AC_TRY_LINK([
+		test -n "$cf_x_athena_lib" && break
+
+		CF_SAVE_XTRA_FLAGS([CF_X_ATHENA_LIBS])
+		cf_test=XawSimpleMenuAddGlobalActions
+		test "$cf_path" != default && cf_libs="-L$cf_path/lib $cf_libs"
+		CF_ADD_LIBS($cf_libs)
+		AC_MSG_CHECKING(for $cf_test in $cf_libs)
+		AC_TRY_LINK([
+$ac_includes_default
 #include <X11/Intrinsic.h>
 #include <X11/$cf_x_athena_root/SimpleMenu.h>
 ],[
 $cf_test((XtAppContext) 0)],
-				[cf_result=yes],
-				[cf_result=no])
-			AC_MSG_RESULT($cf_result)
-			if test "$cf_result" = yes ; then
-				cf_x_athena_lib="$cf_libs"
-				break
-			fi
-			LIBS="$cf_save"
+			[cf_result=yes],
+			[cf_result=no])
+		AC_MSG_RESULT($cf_result)
+		CF_RESTORE_XTRA_FLAGS([CF_X_ATHENA_LIBS])
+
+		if test "$cf_result" = yes ; then
+			cf_x_athena_lib="$cf_libs"
+			break
 		fi
 	done # cf_libs
 		test -n "$cf_x_athena_lib" && break
@@ -3623,6 +4826,7 @@
 [Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
 fi
 
+CF_ADD_LIBS($cf_x_athena_lib)
 CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
 AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
 ])
@@ -3635,7 +4839,7 @@
 		[CF_ADD_LIB(Xext)])])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_X_TOOLKIT version: 23 updated: 2015/04/12 15:39:00
+dnl CF_X_TOOLKIT version: 27 updated: 2023/01/11 04:05:23
 dnl ------------
 dnl Check for X Toolkit libraries
 AC_DEFUN([CF_X_TOOLKIT],
@@ -3643,7 +4847,7 @@
 AC_REQUIRE([AC_PATH_XTRA])
 AC_REQUIRE([CF_CHECK_CACHE])
 
-# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new), and (and
+# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new) (and
 # in some cases has installed dummy files in the former, other cases replaced
 # it with a link to the new location).  This complicates the configure script.
 # Check for that pitfall, and recover using pkg-config
@@ -3655,6 +4859,8 @@
 	CF_TRY_PKG_CONFIG(ice,,[AC_MSG_WARN(unable to find ICE library)])
 	CF_TRY_PKG_CONFIG(sm,,[AC_MSG_WARN(unable to find SM library)])
 	CF_TRY_PKG_CONFIG(xt,,[AC_MSG_WARN(unable to find Xt library)])
+else
+	LIBS="$X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
 fi
 
 cf_have_X_LIBS=no
@@ -3668,6 +4874,7 @@
 # we have an "xt" package, but it may omit Xt's dependency on X11
 AC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
 AC_TRY_LINK([
+$ac_includes_default
 #include <X11/Xlib.h>
 ],[
 	int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
@@ -3686,8 +4893,9 @@
 
 AC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
 AC_TRY_LINK([
+$ac_includes_default
 #include <X11/Shell.h>
-],[int num = IceConnectionNumber(0)
+],[int num = IceConnectionNumber(0); (void) num
 ],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
 
 	if test "$cf_cv_xt_ice_compat" = no
@@ -3717,18 +4925,16 @@
 
 	AC_CHECK_FUNC(XOpenDisplay,,[
 	AC_CHECK_LIB(X11,XOpenDisplay,
-		[CF_ADD_LIB(X11)],,
-		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
+		[CF_ADD_LIB(X11)])])
 
 	AC_CHECK_FUNC(XtAppInitialize,,[
 	AC_CHECK_LIB(Xt, XtAppInitialize,
 		[AC_DEFINE(HAVE_LIBXT,1,[Define to 1 if we can compile with the Xt library])
 		 cf_have_X_LIBS=Xt
-		 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
-		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
+		 LIBS="-lXt $LIBS"])])
 ])
 
-if test $cf_have_X_LIBS = no ; then
+if test "$cf_have_X_LIBS" = no ; then
 	AC_MSG_WARN(
 [Unable to successfully link X Toolkit library (-lXt) with
 test program.  You will have to check and add the proper libraries by hand
@@ -3736,6 +4942,24 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF__CURSES_DATA version: 3 updated: 2021/01/04 19:45:09
+dnl ---------------
+dnl Attempt to make a copy of a curses data item.  This is needed in the
+dnl check-data configure tests when using ncurses, because the symbol may be
+dnl actually a function return-value.  That could happen if the linker is
+dnl broken (does not resolve data-only references), or if ncurses is configured
+dnl to support re-entrant code.
+dnl $1 = target
+dnl $2 = source
+define([CF__CURSES_DATA],[
+#if defined($2) && ((defined(NCURSES_WRAPPED_VAR) && (NCURSES_VERSION_PATCH < 20200208)) || defined(NCURSES_BROKEN_LINKER) || defined(NCURSES_REENTRANT))
+	const void *$1 = (const void *)($2);
+#else
+	const void *$1 = &($2);
+#endif
+	fprintf(stderr, "testing linkage of $2:%p\\n", (const void *)$1);
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF__CURSES_HEAD version: 2 updated: 2010/10/23 15:54:49
 dnl ---------------
 dnl Define a reusable chunk which includes <curses.h> and <term.h> when they
@@ -3755,3 +4979,21 @@
 #endif
 #endif
 ])
+dnl ---------------------------------------------------------------------------
+dnl CF__XOPEN_SOURCE_BODY version: 2 updated: 2023/02/18 17:41:25
+dnl ---------------------
+dnl body of test when test-compiling for _XOPEN_SOURCE check
+define([CF__XOPEN_SOURCE_BODY],
+[
+#ifndef _XOPEN_SOURCE
+#error _XOPEN_SOURCE is not defined
+#endif
+])
+dnl ---------------------------------------------------------------------------
+dnl CF__XOPEN_SOURCE_HEAD version: 2 updated: 2023/02/18 17:41:25
+dnl ---------------------
+dnl headers to include when test-compiling for _XOPEN_SOURCE check
+define([CF__XOPEN_SOURCE_HEAD],
+[
+$ac_includes_default
+])
diff --git a/test/back_ground.c b/test/back_ground.c
new file mode 100644
index 0000000..c53c2a3
--- /dev/null
+++ b/test/back_ground.c
@@ -0,0 +1,308 @@
+/****************************************************************************
+ * Copyright 2021,2022 Thomas E. Dickey                                     *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+/*
+ * $Id: back_ground.c,v 1.9 2022/12/10 22:28:50 tom Exp $
+ */
+
+#include <test.priv.h>
+
+#if USE_WIDEC_SUPPORT
+
+#define NEED_COLOR_CODE 1
+#define NEED_COLOR_NAME 1
+#include <color_name.h>
+#include <dump_window.h>
+
+static int default_bg = COLOR_BLACK;
+static int default_fg = COLOR_WHITE;
+static wchar_t wide_fill = L' ';
+
+static wchar_t
+decode_wchar(const char *value)
+{
+    long result;
+    char *next = NULL;
+    int radix = 0;
+
+    if (!strncmp(value, "U+", 2)) {
+	value += 2;
+	radix = 16;
+    }
+    result = strtol(value, &next, radix);
+    if (next == value || (next == NULL || *next != '\0')) {
+	fprintf(stderr, "decoding wchar_t: %s\n", value);
+	exit(EXIT_FAILURE);
+    }
+    return (wchar_t) result;
+}
+
+static void
+test_background(void)
+{
+    NCURSES_COLOR_T f, b;
+    int row;
+    int chr;
+    wchar_t blank[2];
+    wchar_t graphics[2];
+    cchar_t data;
+
+    if (pair_content(0, &f, &b) == ERR) {
+	printw("pair 0 contains no data\n");
+    } else {
+	printw("pair 0 contains (%d,%d)\n", (int) f, (int) b);
+    }
+    dump_window(stdscr);
+
+    blank[0] = wide_fill;
+    blank[1] = L'\0';
+
+    printw("Initializing pair 1 to red/%s\n", color_name(default_bg));
+    init_pair(1, COLOR_RED, (NCURSES_COLOR_T) default_bg);
+    setcchar(&data, blank, A_NORMAL, 1, NULL);
+    bkgrndset(&data);
+    printw("RED/BLACK\n");
+    dump_window(stdscr);
+
+    printw("Initializing pair 2 to %s/blue\n", color_name(default_fg));
+    init_pair(2, (NCURSES_COLOR_T) default_fg, COLOR_BLUE);
+    setcchar(&data, blank, A_NORMAL, 2, NULL);
+    bkgrndset(&data);
+    printw("This line should be %s/blue\n", color_name(default_fg));
+    dump_window(stdscr);
+
+    printw("Initializing pair 3 to %s/cyan (ACS_HLINE)\n", color_name(default_fg));
+    init_pair(3, (NCURSES_COLOR_T) default_fg, COLOR_CYAN);
+    printw("...and drawing a box which should be followed by lines\n");
+    graphics[0] = ACS_HLINE & A_CHARTEXT;
+    graphics[1] = L'\0';
+    setcchar(&data, graphics, A_ALTCHARSET, 3, NULL);
+    bkgrndset(&data);
+    /*
+     * Characters from vt100 line-drawing should be mapped to line-drawing,
+     * since A_ALTCHARSET is set in the background, and the character part
+     * of the background is replaced by the nonblank characters written.
+     *
+     * Characters not in the line-drawing range are usually sent as-is.
+     *
+     * With SVr4 curses it is possible to rely on this to mix uppercase text
+     * with the (lowercase) line-drawing characters.  ncurses uses some of
+     * the uppercase characters for encoding thick- and double-lines.
+     */
+    row = 7;
+    mvprintw(row++, 10, "l");
+    for (chr = 0; chr < 32; ++chr)
+	AddCh(' ');
+    printw("x\n");
+    chr = 32;
+    while (chr < 128) {
+	if ((chr % 32) == 0)
+	    mvprintw(row++, 10, "x");
+	AddCh((chr == 127) ? ' ' : chr);
+	if ((++chr % 32) == 0)
+	    printw("x\n");
+    }
+    mvprintw(row++, 10, "m");
+    for (chr = 0; chr < 32; ++chr)
+	AddCh(' ');
+    printw("j\n");
+    dump_window(stdscr);
+
+    setcchar(&data, blank, A_NORMAL, 0, NULL);
+    bkgrndset(&data);
+    printw("Default Colors\n");
+    dump_window(stdscr);
+
+    printw("Resetting colors to pair 1\n");
+    setcchar(&data, blank, A_NORMAL, 1, NULL);
+    bkgrndset(&data);
+    printw("This line should be red/%s\n", color_name(default_bg));
+    dump_window(stdscr);
+
+    printw("Setting screen to pair 0\n");
+    setcchar(&data, blank, A_NORMAL, 0, NULL);
+    bkgrndset(&data);
+    dump_window(stdscr);
+
+    printw("Setting screen to pair 1\n");
+    setcchar(&data, blank, A_NORMAL, 1, NULL);
+    bkgrndset(&data);
+    dump_window(stdscr);
+
+    printw("Setting screen to pair 2\n");
+    setcchar(&data, blank, A_NORMAL, 2, NULL);
+    bkgrndset(&data);
+    dump_window(stdscr);
+
+    printw("Setting screen to pair 3\n");
+    setcchar(&data, blank, A_NORMAL, 3, NULL);
+    bkgrndset(&data);
+    dump_window(stdscr);
+
+    printw("Setting screen to pair 0\n");
+    setcchar(&data, blank, A_NORMAL, 0, NULL);
+    bkgrndset(&data);
+    dump_window(stdscr);
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: background [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+#if HAVE_ASSUME_DEFAULT_COLORS
+	," -a       invoke assume_default_colors, repeat to use in init_pair"
+#endif
+	," -b XXX   specify background color"
+#if HAVE_USE_DEFAULT_COLORS
+	," -d       invoke use_default_colors, repeat to use in init_pair"
+#endif
+	," -f XXX   specify foreground color"
+	," -l FILE  log window-dumps to this file"
+	," -w       fill background with stipple pattern"
+	," -W CODE  fill background with this Unicode value"
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+#if HAVE_ASSUME_DEFAULT_COLORS
+    int a_option = 0;
+#endif
+#if HAVE_USE_DEFAULT_COLORS
+    int d_option = 0;
+#endif
+    int ch;
+
+    setlocale(LC_ALL, "");
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "ab:df:l:wW:")) != -1) {
+	switch (ch) {
+#if HAVE_ASSUME_DEFAULT_COLORS
+	case 'a':
+	    ++a_option;
+	    break;
+#endif
+	case 'b':
+	    default_bg = color_code(optarg);
+	    break;
+#if HAVE_USE_DEFAULT_COLORS
+	case 'd':
+	    ++d_option;
+	    break;
+#endif
+	case 'f':
+	    default_fg = color_code(optarg);
+	    break;
+	case 'l':
+	    if (!open_dump(optarg))
+		usage(FALSE);
+	    break;
+	case 'w':
+	    wide_fill = L'\u2591';
+	    break;
+	case 'W':
+	    wide_fill = decode_wchar(optarg);
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+#if HAVE_USE_DEFAULT_COLORS && HAVE_ASSUME_DEFAULT_COLORS
+    if (a_option && d_option) {
+	fprintf(stderr, "Use either -a or -d option, but not both\n");
+	ExitProgram(EXIT_FAILURE);
+    }
+#endif
+
+    initscr();
+    cbreak();
+    noecho();
+
+    if (has_colors()) {
+	start_color();
+
+#if HAVE_USE_DEFAULT_COLORS
+	if (d_option) {
+	    printw("Using default colors...\n");
+	    use_default_colors();
+	    if (d_option > 1) {
+		default_fg = -1;
+		default_bg = -1;
+	    }
+	}
+#endif
+#if HAVE_ASSUME_DEFAULT_COLORS
+	if (a_option) {
+	    printw("Using assumed colors %s/%s...\n",
+		   color_name(default_fg),
+		   color_name(default_bg));
+	    assume_default_colors(default_fg, default_bg);
+	    if (a_option > 1) {
+		default_fg = -1;
+		default_bg = -1;
+	    }
+	}
+#endif
+
+	test_background();
+
+    } else {
+	printw("This demo requires a color terminal");
+	getch();
+    }
+    endwin();
+    close_dump();
+    ExitProgram(EXIT_SUCCESS);
+}
+
+#else
+int
+main(void)
+{
+    printf("This program requires the wide-curses library\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif /* USE_WIDEC_SUPPORT */
diff --git a/test/background b/test/background
deleted file mode 100755
index 993b257..0000000
--- a/test/background
+++ /dev/null
Binary files differ
diff --git a/test/background.c b/test/background.c
index 291851b..5942deb 100644
--- a/test/background.c
+++ b/test/background.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2003-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2021,2022 Thomas E. Dickey                                *
+ * Copyright 2003-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            *
@@ -26,12 +27,13 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: background.c,v 1.15 2014/08/09 22:31:23 tom Exp $
+ * $Id: background.c,v 1.24 2022/12/10 22:28:50 tom Exp $
  */
 
 #define NEED_COLOR_CODE 1
 #define NEED_COLOR_NAME 1
 #include <color_name.h>
+#include <dump_window.h>
 
 static int default_bg = COLOR_BLACK;
 static int default_fg = COLOR_WHITE;
@@ -48,24 +50,24 @@
     } else {
 	printw("pair 0 contains (%d,%d)\n", (int) f, (int) b);
     }
-    getch();
+    dump_window(stdscr);
 
     printw("Initializing pair 1 to red/%s\n", color_name(default_bg));
     init_pair(1, COLOR_RED, (NCURSES_COLOR_T) default_bg);
     bkgdset((chtype) (' ' | COLOR_PAIR(1)));
     printw("RED/BLACK\n");
-    getch();
+    dump_window(stdscr);
 
     printw("Initializing pair 2 to %s/blue\n", color_name(default_fg));
     init_pair(2, (NCURSES_COLOR_T) default_fg, COLOR_BLUE);
     bkgdset((chtype) (' ' | COLOR_PAIR(2)));
     printw("This line should be %s/blue\n", color_name(default_fg));
-    getch();
+    dump_window(stdscr);
 
     printw("Initializing pair 3 to %s/cyan (ACS_HLINE)\n", color_name(default_fg));
     init_pair(3, (NCURSES_COLOR_T) default_fg, COLOR_CYAN);
     printw("...and drawing a box which should be followed by lines\n");
-    bkgdset(ACS_HLINE | (attr_t) COLOR_PAIR(3));
+    bkgdset(ACS_HLINE | (chtype) COLOR_PAIR(3));
     /*
      * Characters from vt100 line-drawing should be mapped to line-drawing,
      * since A_ALTCHARSET is set in the background, and the character part
@@ -80,59 +82,60 @@
     row = 7;
     mvprintw(row++, 10, "l");
     for (chr = 0; chr < 32; ++chr)
-	addch(' ');
+	AddCh(' ');
     printw("x\n");
     chr = 32;
     while (chr < 128) {
 	if ((chr % 32) == 0)
 	    mvprintw(row++, 10, "x");
-	addch((chtype) ((chr == 127) ? ' ' : chr));
+	AddCh((chr == 127) ? ' ' : chr);
 	if ((++chr % 32) == 0)
 	    printw("x\n");
     }
     mvprintw(row++, 10, "m");
     for (chr = 0; chr < 32; ++chr)
-	addch(' ');
+	AddCh(' ');
     printw("j\n");
-    getch();
+    dump_window(stdscr);
 
     bkgdset((chtype) (' ' | COLOR_PAIR(0)));
     printw("Default Colors\n");
-    getch();
+    dump_window(stdscr);
 
     printw("Resetting colors to pair 1\n");
     bkgdset((chtype) (' ' | COLOR_PAIR(1)));
     printw("This line should be red/%s\n", color_name(default_bg));
-    getch();
+    dump_window(stdscr);
 
     printw("Setting screen to pair 0\n");
     bkgd((chtype) (' ' | COLOR_PAIR(0)));
-    getch();
+    dump_window(stdscr);
 
     printw("Setting screen to pair 1\n");
     bkgd((chtype) (' ' | COLOR_PAIR(1)));
-    getch();
+    dump_window(stdscr);
 
     printw("Setting screen to pair 2\n");
     bkgd((chtype) (' ' | COLOR_PAIR(2)));
-    getch();
+    dump_window(stdscr);
 
     printw("Setting screen to pair 3\n");
     bkgd((chtype) (' ' | COLOR_PAIR(3)));
-    getch();
+    dump_window(stdscr);
 
     printw("Setting screen to pair 0\n");
     bkgd((chtype) (' ' | COLOR_PAIR(0)));
-    getch();
+    dump_window(stdscr);
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *msg[] =
     {
 	"Usage: background [options]"
 	,""
+	,USAGE_COMMON
 	,"Options:"
 #if HAVE_ASSUME_DEFAULT_COLORS
 	," -a       invoke assume_default_colors, repeat to use in init_pair"
@@ -142,17 +145,21 @@
 	," -d       invoke use_default_colors, repeat to use in init_pair"
 #endif
 	," -f XXX   specify foreground color"
+	," -l FILE  log window-dumps to this file"
     };
     size_t n;
 
     for (n = 0; n < SIZEOF(msg); n++)
 	fprintf(stderr, "%s\n", msg[n]);
 
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
 #if HAVE_ASSUME_DEFAULT_COLORS
     int a_option = 0;
@@ -160,12 +167,12 @@
 #if HAVE_USE_DEFAULT_COLORS
     int d_option = 0;
 #endif
-    int n;
+    int ch;
 
     setlocale(LC_ALL, "");
 
-    while ((n = getopt(argc, argv, "ab:df:")) != -1) {
-	switch (n) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "ab:df:l:")) != -1) {
+	switch (ch) {
 #if HAVE_ASSUME_DEFAULT_COLORS
 	case 'a':
 	    ++a_option;
@@ -182,8 +189,16 @@
 	case 'f':
 	    default_fg = color_code(optarg);
 	    break;
+	case 'l':
+	    if (!open_dump(optarg))
+		usage(FALSE);
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
 #if HAVE_USE_DEFAULT_COLORS && HAVE_ASSUME_DEFAULT_COLORS
@@ -230,6 +245,6 @@
 	getch();
     }
     endwin();
-
+    close_dump();
     ExitProgram(EXIT_SUCCESS);
 }
diff --git a/test/blue b/test/blue
deleted file mode 100755
index 3fbc888..0000000
--- a/test/blue
+++ /dev/null
Binary files differ
diff --git a/test/blue.c b/test/blue.c
index 50d48b1..90f240b 100644
--- a/test/blue.c
+++ b/test/blue.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2013 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,17 +37,17 @@
  *****************************************************************************/
 
 /*
- * Compile this with the command `cc -O blue.c -lcurses -o blue'.  For best
- * results, use the ncurses(3) library.  On non-Intel machines, SVr4 curses is
- * just as good.
- *
- * $Id: blue.c,v 1.35 2013/04/27 19:46:53 tom Exp $
+ * $Id: blue.c,v 1.55 2022/12/10 23:31:31 tom Exp $
  */
 
 #include <test.priv.h>
 
 #include <time.h>
 
+#if HAVE_LANGINFO_CODESET
+#include <langinfo.h>
+#endif
+
 #define NOCARD		(-1)
 
 #define ACE		0
@@ -70,7 +71,7 @@
 #define BLACK_ON_WHITE  2
 #define BLUE_ON_WHITE   3
 
-static void die(int onsig) GCC_NORETURN;
+static GCC_NORETURN void die(int onsig);
 
 static int deck_size = PACK_SIZE;	/* initial deck */
 static int deck[PACK_SIZE];
@@ -97,40 +98,38 @@
     {' ', 'K'}
 };
 
-/* Please note, that this is a bad example.
-   Color values should not be or'ed in. This
-   only works, because the characters used here
-   are plain and have no color attribute themselves. */
-#ifdef COLOR_PAIR
-#define OR_COLORS(value,pair) ((value) | COLOR_PAIR(pair))
-#else
-#define OR_COLORS(value,pair) (value)
+static int letters[4] =
+{
+    'h',			/* hearts */
+    's',			/* spades */
+    'd',			/* diamonds */
+    'c',			/* clubs */
+};
+
+#if HAVE_LANGINFO_CODESET
+
+#if HAVE_TIGETSTR
+static int glyphs[] =
+{
+    '\003',			/* hearts */
+    '\006',			/* spades */
+    '\004',			/* diamonds */
+    '\005',			/* clubs */
+};
 #endif
 
-#define PC_COLORS(value,pair) (OR_COLORS(value,pair) | A_ALTCHARSET)
-
-static chtype letters[4] =
+#if USE_WIDEC_SUPPORT
+static int uglyphs[] =
 {
-    OR_COLORS('h', RED_ON_WHITE),	/* hearts */
-    OR_COLORS('s', BLACK_ON_WHITE),	/* spades */
-    OR_COLORS('d', RED_ON_WHITE),	/* diamonds */
-    OR_COLORS('c', BLACK_ON_WHITE),	/* clubs */
+    0x2665,			/* hearts */
+    0x2660,			/* spades */
+    0x2666,			/* diamonds */
+    0x2663			/* clubs */
 };
+#endif
+#endif /* HAVE_LANGINFO_CODESET */
 
-#if defined(__i386__) && defined(A_ALTCHARSET) && HAVE_TIGETSTR
-static chtype glyphs[] =
-{
-    PC_COLORS('\003', RED_ON_WHITE),	/* hearts */
-    PC_COLORS('\006', BLACK_ON_WHITE),	/* spades */
-    PC_COLORS('\004', RED_ON_WHITE),	/* diamonds */
-    PC_COLORS('\005', BLACK_ON_WHITE),	/* clubs */
-};
-#define USE_CP437 1
-#else
-#define USE_CP437 0
-#endif /* __i386__ */
-
-static chtype *suits = letters;	/* this may change to glyphs below */
+static int *suits = letters;	/* this may change to glyphs below */
 
 static void
 die(int onsig)
@@ -155,14 +154,14 @@
 static void
 shuffle(int size)
 {
-    int i, j, numswaps, swapnum, temp;
+    int numswaps, swapnum;
 
     numswaps = size * 10;	/* an arbitrary figure */
 
     for (swapnum = 0; swapnum < numswaps; swapnum++) {
-	i = rand() % size;
-	j = rand() % size;
-	temp = deck[i];
+	int i = rand() % size;
+	int j = rand() % size;
+	int temp = deck[i];
 	deck[i] = deck[j];
 	deck[j] = temp;
     }
@@ -171,11 +170,11 @@
 static void
 deal_cards(void)
 {
-    int ptr, card = 0, value, csuit, crank, suit, aces[4];
+    int card = 0, value, csuit, crank, suit, aces[4];
 
     memset(aces, 0, sizeof(aces));
     for (suit = HEARTS; suit <= CLUBS; suit++) {
-	ptr = freeptr[suit];
+	int ptr = freeptr[suit];
 	grid[ptr++] = NOCARD;	/* 1st card space is blank */
 	while ((ptr % GRID_WIDTH) != 0) {
 	    value = deck[card++];
@@ -198,15 +197,41 @@
 static void
 printcard(int value)
 {
-    (void) addch(' ');
-    if (value == NOCARD)
+    AddCh(' ');
+    if (value == NOCARD) {
 	(void) addstr("   ");
-    else {
-	addch(ranks[value % SUIT_LENGTH][0] | (chtype) COLOR_PAIR(BLUE_ON_WHITE));
-	addch(ranks[value % SUIT_LENGTH][1] | (chtype) COLOR_PAIR(BLUE_ON_WHITE));
-	addch(suits[value / SUIT_LENGTH]);
+    } else {
+	int which = (value / SUIT_LENGTH);
+	int isuit = (value % SUIT_LENGTH);
+	chtype color = (chtype) COLOR_PAIR(((which % 2) == 0)
+					   ? RED_ON_WHITE
+					   : BLACK_ON_WHITE);
+
+	AddCh(ranks[isuit][0] | (chtype) COLOR_PAIR(BLUE_ON_WHITE));
+	AddCh(ranks[isuit][1] | (chtype) COLOR_PAIR(BLUE_ON_WHITE));
+
+#ifdef NCURSES_VERSION
+	(attron) ((int) color);	/* quieter compiler warnings */
+#else
+	attron(color);		/* PDCurses, etc., either no macro or wrong */
+#endif
+#if USE_WIDEC_SUPPORT
+	{
+	    wchar_t values[2];
+	    values[0] = (wchar_t) suits[which];
+	    values[1] = 0;
+	    addwstr(values);
+	}
+#else
+	AddCh(suits[which]);
+#endif
+#ifdef NCURSES_VERSION
+	(attroff) ((int) color);
+#else
+	attroff(color);
+#endif
     }
-    (void) addch(' ');
+    AddCh(' ');
 }
 
 static void
@@ -315,16 +340,16 @@
 	    } else {
 		char buf[BUFSIZ];
 
-		(void) sprintf(buf,
-			       "Type [%s] to move, r to redraw, q or INTR to quit: ",
-			       live);
+		_nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf))
+			    "Type [%s] to move, r to redraw, q or INTR to quit: ",
+			    live);
 
 		do {
 		    move(PROMPTROW, 0);
 		    (void) addstr(buf);
 		    move(PROMPTROW, (int) strlen(buf));
 		    clrtoeol();
-		    (void) addch(' ');
+		    AddCh(' ');
 		} while
 		    (((c = (char) getch()) < 'a' || c > 'd')
 		     && (c != 'r')
@@ -364,10 +389,10 @@
 static int
 collect_discards(void)
 {
-    int row, col, cardno = 0, finish, gridno;
+    int row, col, cardno = 0, gridno;
 
     for (row = HEARTS; row <= CLUBS; row++) {
-	finish = 0;
+	int finish = 0;
 	for (col = 1; col < GRID_WIDTH; col++) {
 	    gridno = row * GRID_WIDTH + col;
 
@@ -402,41 +427,93 @@
     refresh();
 }
 
+#if HAVE_LANGINFO_CODESET
+/*
+ * This program first appeared in ncurses in January 1995.  At that point, the
+ * Linux console was able to display CP437 graphic characters, e.g., in the
+ * range 0-31.  As of 2016, most Linux consoles are running with the UTF-8
+ * (partial) support.  Incidentally, that makes all of the cards diamonds.
+ */
+static void
+use_pc_display(void)
+{
+    char *check = nl_langinfo(CODESET);
+    if (!strcmp(check, "UTF-8")) {
+#if USE_WIDEC_SUPPORT
+	suits = uglyphs;
+#endif
+    } else {
+#if HAVE_TIGETSTR
+	if (!strcmp(check, "IBM437") ||
+	    !strcmp(check, "CP437") ||
+	    !strcmp(check, "IBM850") ||
+	    !strcmp(check, "CP850")) {
+	    char *smacs = tigetstr("smacs");
+	    char *smpch = tigetstr("smpch");
+	    /*
+	     * The ncurses library makes this check to decide whether to allow
+	     * the alternate character set for the (normally) nonprinting codes.
+	     */
+	    if (smacs != 0 && smpch != 0 && !strcmp(smacs, smpch)) {
+		suits = glyphs;
+	    }
+	}
+#endif
+    }
+}
+#else
+#define use_pc_display()	/* nothing */
+#endif /* HAVE_LANGINFO_CODESET */
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: blue [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
 main(int argc, char *argv[])
 {
-    CATCHALL(die);
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
 
     setlocale(LC_ALL, "");
 
-    initscr();
+    use_pc_display();
 
-    /*
-     * We use COLOR_GREEN because COLOR_BLACK is wired to the wrong thing.
-     */
+    InitAndCatch(initscr(), die);
+
     start_color();
     init_pair(RED_ON_WHITE, COLOR_RED, COLOR_WHITE);
     init_pair(BLUE_ON_WHITE, COLOR_BLUE, COLOR_WHITE);
     init_pair(BLACK_ON_WHITE, COLOR_BLACK, COLOR_WHITE);
 
-#ifndef COLOR_PAIR
-    letters[0] = OR_COLORS('h', RED_ON_WHITE);	/* hearts */
-    letters[1] = OR_COLORS('s', BLACK_ON_WHITE);	/* spades */
-    letters[2] = OR_COLORS('d', RED_ON_WHITE);	/* diamonds */
-    letters[3] = OR_COLORS('c', BLACK_ON_WHITE);	/* clubs */
-#if USE_CP437
-    glyphs[0] = PC_COLORS('\003', RED_ON_WHITE);	/* hearts */
-    glyphs[1] = PC_COLORS('\006', BLACK_ON_WHITE);	/* spades */
-    glyphs[2] = PC_COLORS('\004', RED_ON_WHITE);	/* diamonds */
-    glyphs[3] = PC_COLORS('\005', BLACK_ON_WHITE);	/* clubs */
-#endif
-#endif
-
-#if USE_CP437
-    if (tigetstr("smpch"))
-	suits = glyphs;
-#endif /* USE_CP437 */
-
     cbreak();
 
     if (argc == 2)
diff --git a/test/bs b/test/bs
deleted file mode 100755
index 2e5f082..0000000
--- a/test/bs
+++ /dev/null
Binary files differ
diff --git a/test/bs.6 b/test/bs.6
index 657f538..12295a3 100644
--- a/test/bs.6
+++ b/test/bs.6
@@ -1,5 +1,6 @@
 .\"***************************************************************************
-.\" Copyright (c) 1998,2006 Free Software Foundation, Inc.                   *
+.\" Copyright 2020,2021 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            *
@@ -26,8 +27,8 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: bs.6,v 1.2 2006/04/22 22:42:44 tom Exp $
-.TH BATTLESHIPS 6 "Aug 23, 1989"
+.\" $Id: bs.6,v 1.5 2021/06/17 21:20:30 tom Exp $
+.TH BATTLESHIPS 6 2021-06-17 ncurses-examples Games
 .SH NAME
 bs \- battleships game
 .SH SYNOPSIS
@@ -44,7 +45,7 @@
 selected ship. The `R' command will place all remaining ships randomly. The ^L
 command (form feed, ASCII 12) will force a screen redraw).
 .PP
-The command-line arguments control game modes. 
+The command-line arguments control game modes.
 
 .nf
 	-b selects a `blitz' variant
diff --git a/test/bs.c b/test/bs.c
index a74f643..c7569cf 100644
--- a/test/bs.c
+++ b/test/bs.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            *
@@ -25,7 +26,7 @@
  * sale, use or other dealings in this Software without prior written       *
  * authorization.                                                           *
  ****************************************************************************/
-/* 
+/*
  * bs.c - original author: Bruce Holloway
  *		salvo option by: Chuck A DeGaul
  * with improved user interface, autoconfiguration and code cleanup
@@ -34,7 +35,7 @@
  * v2.0 featuring strict ANSI/POSIX conformance, November 1993.
  * v2.1 with ncurses mouse support, September 1995
  *
- * $Id: bs.c,v 1.63 2014/08/09 22:27:12 tom Exp $
+ * $Id: bs.c,v 1.79 2023/05/27 20:13:10 tom Exp $
  */
 
 #include <test.priv.h>
@@ -64,6 +65,8 @@
 #define CTRLC		'\003'	/* used as terminate command */
 #define FF		'\014'	/* used as redraw command */
 
+#define is_QUIT(c) ((c) == CTRLC || (c) == QUIT)
+
 /* coordinate handling */
 #define BWIDTH		10
 #define BDEPTH		10
@@ -114,17 +117,20 @@
 static char dftname[] = "stranger";
 
 /* direction constants */
-#define E	0
-#define SE	1
-#define S	2
-#define SW	3
-#define W	4
-#define NW	5
-#define N	6
-#define NE	7
-static int xincr[8] =
+typedef enum {
+    dir_E = 0
+    ,dir_SE
+    ,dir_S
+    ,dir_SW
+    ,dir_W
+    ,dir_NW
+    ,dir_N
+    ,dir_NE
+    ,dir_MAX
+} DIRECTIONS;
+static int xincr[dir_MAX + 2] =
 {1, 1, 0, -1, -1, -1, 0, 1};
-static int yincr[8] =
+static int yincr[dir_MAX + 2] =
 {0, 1, 1, 1, 0, -1, -1, -1};
 
 /* current ship position and direction */
@@ -145,6 +151,7 @@
 
 #define SHIPIT(name, symbol, length) { name, 0, symbol, length, 0,0, 0, FALSE }
 
+/* "ply=player", "cpu=computer" */
 static ship_t plyship[SHIPTYPES] =
 {
     SHIPIT(carrier, 'A', 5),
@@ -174,7 +181,7 @@
 
 #define	PR	(void)addstr
 
-static void uninitgame(int sig) GCC_NORETURN;
+static GCC_NORETURN void uninitgame(int sig);
 
 static void
 uninitgame(int sig GCC_UNUSED)
@@ -185,6 +192,7 @@
     (void) reset_shell_mode();
     (void) echo();
     (void) endwin();
+    free(your_name);
     ExitProgram(sig ? EXIT_FAILURE : EXIT_SUCCESS);
 }
 
@@ -214,20 +222,19 @@
 static void
 intro(void)
 {
-    char *tmpname;
+    const char *tmpname;
 
     srand((unsigned) (time(0L) + getpid()));	/* Kick the random number generator */
 
-    CATCHALL(uninitgame);
+    InitAndCatch(initscr(), uninitgame);
 
     if ((tmpname = getlogin()) != 0 &&
 	(your_name = strdup(tmpname)) != 0) {
 	your_name[0] = (char) toupper(UChar(your_name[0]));
     } else {
-	your_name = dftname;
+	your_name = strdup(dftname);
     }
 
-    (void) initscr();
     keypad(stdscr, TRUE);
     (void) def_prog_mode();
     (void) nonl();
@@ -306,7 +313,7 @@
 	board[b][newx][newy] = ss->symbol;
 	if (vis) {
 	    pgoto(newy, newx);
-	    (void) addch((chtype) ss->symbol);
+	    AddCh(ss->symbol);
 	}
     }
     ss->hits = 0;
@@ -324,9 +331,9 @@
 {
 
     do {
-	ss->dir = rnd(2) ? E : S;
-	ss->x = rnd(BWIDTH - (ss->dir == E ? ss->length : 0));
-	ss->y = rnd(BDEPTH - (ss->dir == S ? ss->length : 0));
+	ss->dir = rnd(2) ? dir_E : dir_S;
+	ss->x = rnd(BWIDTH - (ss->dir == dir_E ? ss->length : 0));
+	ss->y = rnd(BDEPTH - (ss->dir == dir_S ? ss->length : 0));
     } while
 	(!checkplace(b, ss, FALSE));
 }
@@ -371,14 +378,14 @@
 	if (has_colors())
 	    attron(COLOR_PAIR(COLOR_BLUE));
 #endif /* A_COLOR */
-	(void) addch(' ');
+	AddCh(' ');
 	for (j = 0; j < BWIDTH; j++)
 	    (void) addstr(" . ");
 #ifdef A_COLOR
 	(void) attrset(0);
 #endif /* A_COLOR */
-	(void) addch(' ');
-	(void) addch((chtype) (i + 'A'));
+	AddCh(' ');
+	AddCh(i + 'A');
     }
     MvAddStr(PYBASE + BDEPTH, PXBASE - 3, numbers);
     MvAddStr(CYBASE - 2, CXBASE + 7, "Hit/Miss Board");
@@ -389,14 +396,14 @@
 	if (has_colors())
 	    attron(COLOR_PAIR(COLOR_BLUE));
 #endif /* A_COLOR */
-	(void) addch(' ');
+	AddCh(' ');
 	for (j = 0; j < BWIDTH; j++)
 	    (void) addstr(" . ");
 #ifdef A_COLOR
 	(void) attrset(0);
 #endif /* A_COLOR */
-	(void) addch(' ');
-	(void) addch((chtype) (i + 'A'));
+	AddCh(' ');
+	AddCh(i + 'A');
     }
 
     MvAddStr(CYBASE + BDEPTH, CXBASE - 3, numbers);
@@ -461,9 +468,11 @@
 	do {
 	    c = (char) getch();
 	} while
-	    (!(strchr("hjkl8462rR", c) || c == FF));
+	    (!(strchr("hjkl8462rR", c) || c == FF || is_QUIT(c)));
 
-	if (c == FF) {
+	if (is_QUIT(c)) {
+	    uninitgame(0);
+	} else if (c == FF) {
 	    (void) clearok(stdscr, TRUE);
 	    (void) refresh();
 	} else if (ss == 0) {
@@ -490,19 +499,19 @@
 	    switch (c) {
 	    case 'k':
 	    case '8':
-		ss->dir = N;
+		ss->dir = dir_N;
 		break;
 	    case 'j':
 	    case '2':
-		ss->dir = S;
+		ss->dir = dir_S;
 		break;
 	    case 'h':
 	    case '4':
-		ss->dir = W;
+		ss->dir = dir_W;
 		break;
 	    case 'l':
 	    case '6':
-		ss->dir = E;
+		ss->dir = dir_E;
 		break;
 	    }
 
@@ -540,14 +549,15 @@
 static int
 getcoord(int atcpu)
 {
-    int ny, nx, c;
-
     if (atcpu)
 	cgoto(cury, curx);
     else
 	pgoto(cury, curx);
     (void) refresh();
+
     for (;;) {
+	int ny, nx, c;
+
 	if (atcpu) {
 	    MvPrintw(CYBASE + BDEPTH + 1, CXBASE + 11, "(%d, %c)",
 		     curx, 'A' + cury);
@@ -660,7 +670,7 @@
     if (!closepack) {
 	int i;
 
-	for (i = 0; i < 8; i++) {
+	for (i = 0; i < dir_MAX; i++) {
 	    int xend, yend;
 
 	    yend = y + yincr[i];
@@ -723,10 +733,9 @@
 awinna(void)
 {
     int i, j;
-    ship_t *ss;
 
     for (i = 0; i < 2; ++i) {
-	ss = (i) ? cpuship : plyship;
+	ship_t *ss = (i) ? cpuship : plyship;
 	for (j = 0; j < SHIPTYPES; ++j, ++ss)
 	    if (ss->length > ss->hits)
 		break;
@@ -753,12 +762,14 @@
 	    if (++ss->hits < ss->length)	/* still afloat? */
 		return ((ship_t *) NULL);
 	    else {		/* sunk! */
-		int i, j;
+		int i;
 
-		if (!closepack)
+		if (!closepack) {
+		    int j;
+
 		    for (j = -1; j <= 1; j++) {
-			int bx = ss->x + j * xincr[(ss->dir + 2) % 8];
-			int by = ss->y + j * yincr[(ss->dir + 2) % 8];
+			int bx = ss->x + j * xincr[(ss->dir + 2) % dir_MAX];
+			int by = ss->y + j * yincr[(ss->dir + 2) % dir_MAX];
 
 			for (i = -1; i <= ss->length; ++i) {
 			    int x1, y1;
@@ -773,17 +784,18 @@
 				    if (has_colors())
 					attron(COLOR_PAIR(COLOR_GREEN));
 #endif /* A_COLOR */
-				    (void) addch(MARK_MISS);
+				    AddCh(MARK_MISS);
 #ifdef A_COLOR
 				    (void) attrset(0);
 #endif /* A_COLOR */
 				} else {
 				    pgoto(y1, x1);
-				    (void) addch(SHOWSPLASH);
+				    AddCh(SHOWSPLASH);
 				}
 			    }
 			}
 		    }
+		}
 
 		for (i = 0; i < ss->length; ++i) {
 		    int x1 = ss->x + i * xincr[ss->dir];
@@ -792,14 +804,14 @@
 		    hits[turn][x1][y1] = ss->symbol;
 		    if (turn % 2 == PLAYER) {
 			cgoto(y1, x1);
-			(void) addch((chtype) (ss->symbol));
+			AddCh(ss->symbol);
 		    } else {
 			pgoto(y1, x1);
 #ifdef A_COLOR
 			if (has_colors())
 			    attron(COLOR_PAIR(COLOR_RED));
 #endif /* A_COLOR */
-			(void) addch(SHOWHIT);
+			AddCh(SHOWHIT);
 #ifdef A_COLOR
 			(void) attrset(0);
 #endif /* A_COLOR */
@@ -841,7 +853,7 @@
 	    attron(COLOR_PAIR(COLOR_GREEN));
     }
 #endif /* A_COLOR */
-    (void) addch((chtype) hits[PLAYER][curx][cury]);
+    AddCh(hits[PLAYER][curx][cury]);
 #ifdef A_COLOR
     (void) attrset(0);
 #endif /* A_COLOR */
@@ -876,20 +888,21 @@
 static int
 sgetc(const char *s)
 {
-    const char *s1;
-    int ch;
-
     (void) refresh();
+
     for (;;) {
-	ch = getch();
+	int ch = getch();
+	const char *s1;
+
 	if (islower(ch))
 	    ch = toupper(ch);
-	if (ch == CTRLC)
+	if (is_QUIT(ch))
 	    uninitgame(0);
-	for (s1 = s; *s1 && ch != *s1; ++s1)
-	    continue;
+	for (s1 = s; *s1 && ch != *s1; ++s1) {
+	    /* EMPTY */ ;
+	}
 	if (*s1) {
-	    (void) addch((chtype) ch);
+	    AddCh(ch);
 	    (void) refresh();
 	    return (ch);
 	}
@@ -974,7 +987,7 @@
 	    attron(COLOR_PAIR(COLOR_GREEN));
     }
 #endif /* A_COLOR */
-    (void) addch((chtype) (hit ? SHOWHIT : SHOWSPLASH));
+    AddCh((hit ? SHOWHIT : SHOWSPLASH));
 #ifdef A_COLOR
     (void) attrset(0);
 #endif /* A_COLOR */
@@ -1002,7 +1015,7 @@
 #define REVERSE_JUMP	4
 #define SECOND_PASS	5
     static int next = RANDOM_FIRE;
-    static bool used[4];
+    static bool used[5];
     static ship_t ts;
     int navail, x, y, d, n;
     int hit = S_MISS;
@@ -1022,11 +1035,14 @@
 	break;
 
     case RANDOM_HIT:		/* last shot was random and hit */
-	used[E / 2] = used[S / 2] = used[W / 2] = used[N / 2] = FALSE;
+	used[dir_E / 2] =
+	    used[dir_S / 2] =
+	    used[dir_W / 2] =
+	    used[dir_N / 2] = FALSE;
 	/* FALLTHROUGH */
 
     case HUNT_DIRECT:		/* last shot hit, we're looking for ship's long axis */
-	for (d = navail = 0; d < 4; d++) {
+	for (d = navail = 0; d < (dir_MAX) / 2; d++) {
 	    x = ts.x + xincr[d * 2];
 	    y = ts.y + yincr[d * 2];
 	    if (!used[d] && POSSIBLE(x, y))
@@ -1038,13 +1054,13 @@
 	    goto refire;	/* ...so we must random-fire */
 	else {
 	    n = rnd(navail) + 1;
-	    for (d = 0; used[d]; d++) ;
+	    for (d = 0; d < (dir_MAX) / 2 && used[d]; d++) ;
 	    /* used[d] is first that == 0 */
 	    for (; n > 1; n--)
-		while (used[++d]) ;
+		while (d < (dir_MAX) / 2 && used[++d]) ;
 	    /* used[d] is next that == 0 */
 
-	    assert(d < 4);
+	    assert(d < (dir_MAX) / 2);
 	    assert(used[d] == FALSE);
 
 	    used[d] = TRUE;
@@ -1078,7 +1094,7 @@
 	break;
 
     case REVERSE_JUMP:		/* nail down the ship's other end */
-	d = (ts.dir + 4) % 8;
+	d = (ts.dir + (dir_MAX) / 2) % dir_MAX;
 	x = ts.x + ts.hits * xincr[d];
 	y = ts.y + ts.hits * yincr[d];
 	if (POSSIBLE(x, y) && (hit = cpufire(x, y))) {
@@ -1127,7 +1143,7 @@
     for (ss = cpuship; ss < cpuship + SHIPTYPES; ss++)
 	for (j = 0; j < ss->length; j++) {
 	    cgoto(ss->y + j * yincr[ss->dir], ss->x + j * xincr[ss->dir]);
-	    (void) addch((chtype) ss->symbol);
+	    AddCh(ss->symbol);
 	}
 
     if (awinna())
@@ -1147,55 +1163,6 @@
     return (sgetc("YN") == 'Y');
 }
 
-static void
-do_options(int c, char *op[])
-{
-    register int i;
-
-    if (c > 1) {
-	for (i = 1; i < c; i++) {
-	    switch (op[i][0]) {
-	    default:
-	    case '?':
-		(void) fprintf(stderr, "Usage: battle [-s | -b] [-c]\n");
-		(void) fprintf(stderr, "\tWhere the options are:\n");
-		(void) fprintf(stderr, "\t-s : play a salvo game\n");
-		(void) fprintf(stderr, "\t-b : play a blitz game\n");
-		(void) fprintf(stderr, "\t-c : ships may be adjacent\n");
-		ExitProgram(EXIT_FAILURE);
-		break;
-	    case '-':
-		switch (op[i][1]) {
-		case 'b':
-		    blitz = 1;
-		    if (salvo == 1) {
-			(void) fprintf(stderr,
-				       "Bad Arg: -b and -s are mutually exclusive\n");
-			ExitProgram(EXIT_FAILURE);
-		    }
-		    break;
-		case 's':
-		    salvo = 1;
-		    if (blitz == 1) {
-			(void) fprintf(stderr,
-				       "Bad Arg: -s and -b are mutually exclusive\n");
-			ExitProgram(EXIT_FAILURE);
-		    }
-		    break;
-		case 'c':
-		    closepack = 1;
-		    break;
-		default:
-		    (void) fprintf(stderr,
-				   "Bad arg: type \"%s ?\" for usage message\n",
-				   op[0]);
-		    ExitProgram(EXIT_FAILURE);
-		}
-	    }
-	}
-    }
-}
-
 static int
 scount(int who)
 {
@@ -1216,12 +1183,68 @@
     return (shots);
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: bs [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -b       play a blitz game"
+	," -c       ships may be adjacent"
+	," -s       play a salvo game"
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
 main(int argc, char *argv[])
 {
-    setlocale(LC_ALL, "");
+    int ch;
 
-    do_options(argc, argv);
+    while ((ch = getopt(argc, argv, OPTS_COMMON "bcs")) != -1) {
+	switch (ch) {
+	case 'b':
+	    blitz = 1;
+	    if (salvo == 1) {
+		(void) fprintf(stderr,
+			       "Bad Arg: -b and -s are mutually exclusive\n");
+		ExitProgram(EXIT_FAILURE);
+	    }
+	    break;
+	case 's':
+	    salvo = 1;
+	    if (blitz == 1) {
+		(void) fprintf(stderr,
+			       "Bad Arg: -s and -b are mutually exclusive\n");
+		ExitProgram(EXIT_FAILURE);
+	    }
+	    break;
+	case 'c':
+	    closepack = 1;
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
+    setlocale(LC_ALL, "");
 
     intro();
     do {
@@ -1248,8 +1271,9 @@
 		    }
 		}
 	    } else
-		while ((turn ? cputurn() : plyturn()) && awinna() == -1)
-		    continue;
+		while ((turn ? cputurn() : plyturn()) && awinna() == -1) {
+		    /* EMPTY */ ;
+		}
 	    turn = OTHER;
 	}
     } while
diff --git a/test/bulgarian-utf8-tabs.txt b/test/bulgarian-utf8-tabs.txt
new file mode 100644
index 0000000..65e42bb
--- /dev/null
+++ b/test/bulgarian-utf8-tabs.txt
@@ -0,0 +1,6 @@
+Показване на помощна информация	-- 1
+Създаване на дялове		-- 2
+Избор на дял и форматиране	-- 3
+Записване в избрания дял	-- 4
+Инсталиране на LILO		-- 5
+Изход от програмата		-- 6
diff --git a/test/cardfile.c b/test/cardfile.c
index b750241..092483b 100644
--- a/test/cardfile.c
+++ b/test/cardfile.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1999-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2019-2021,2022 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            *
@@ -29,7 +30,7 @@
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: cardfile.c,v 1.42 2013/09/28 22:02:17 tom Exp $
+ * $Id: cardfile.c,v 1.51 2022/12/04 00:40:11 tom Exp $
  *
  * File format: text beginning in column 1 is a title; other text is content.
  */
@@ -125,15 +126,19 @@
 static void
 add_content(CARD * card, const char *content)
 {
-    size_t total, offset;
+    size_t total;
 
     content = skip(content);
     if ((total = strlen(content)) != 0) {
+	size_t offset;
+
 	if (card->content != 0 && (offset = strlen(card->content)) != 0) {
 	    total += 1 + offset;
 	    card->content = typeRealloc(char, total + 1, card->content);
-	    if (card->content)
-		strcpy(card->content + offset++, " ");
+	    if (card->content) {
+		_nc_STRCPY(card->content + offset, " ", total + 1 - offset);
+		offset++;
+	    }
 	} else {
 	    offset = 0;
 	    if (card->content != 0)
@@ -141,7 +146,7 @@
 	    card->content = typeMalloc(char, total + 1);
 	}
 	if (card->content)
-	    strcpy(card->content + offset, content);
+	    _nc_STRCPY(card->content + offset, content, total + 1 - offset);
 	else
 	    failed("add_content");
     }
@@ -171,10 +176,11 @@
 read_data(char *fname)
 {
     FILE *fp;
-    CARD *card = 0;
-    char buffer[BUFSIZ];
 
     if ((fp = fopen(fname, "r")) != 0) {
+	CARD *card = 0;
+	char buffer[BUFSIZ];
+
 	while (fgets(buffer, sizeof(buffer), fp)) {
 	    trim(buffer);
 	    if (isspace(UChar(*buffer))) {
@@ -195,15 +201,17 @@
 write_data(const char *fname)
 {
     FILE *fp;
-    CARD *p = 0;
-    int n;
 
     if (!strcmp(fname, default_name))
 	fname = "cardfile.out";
 
     if ((fp = fopen(fname, "w")) != 0) {
+	CARD *p = 0;
+
 	for (p = all_cards; p != 0; p = p->link) {
 	    FIELD **f = form_fields(p->form);
+	    int n;
+
 	    for (n = 0; f[n] != 0; n++) {
 		char *s = field_buffer(f[n], 0);
 		if (s != 0
@@ -288,7 +296,7 @@
 static CARD *
 first_card(CARD * now)
 {
-    if (!isVisible(now))
+    if (now != NULL && !isVisible(now))
 	now = next_card(now);
     return now;
 }
@@ -363,7 +371,7 @@
 
 #if (defined(KEY_RESIZE) && HAVE_WRESIZE) || NO_LEAKS
 static void
-free_form_fields(FIELD ** f)
+free_form_fields(FIELD **f)
 {
     int n;
 
@@ -389,7 +397,6 @@
     int form_high;
     int y;
     int x;
-    int ch = ERR;
     int finished = FALSE;
 
     show_legend();
@@ -430,6 +437,8 @@
     order_cards(top_card, visible_cards);
 
     while (!finished) {
+	int ch = ERR;
+
 	update_panels();
 	doupdate();
 
@@ -520,13 +529,11 @@
     }
 #if NO_LEAKS
     while (all_cards != 0) {
-	FIELD **f;
-
 	p = all_cards;
 	all_cards = all_cards->link;
 
 	if (isVisible(p)) {
-	    f = form_fields(p->form);
+	    FIELD **f = form_fields(p->form);
 
 	    unpost_form(p->form);	/* ...so we can free it */
 	    free_form(p->form);	/* this also disconnects the fields */
@@ -543,37 +550,45 @@
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *msg[] =
     {
-	"Usage: view [options] file"
+	"Usage: cardfile [options] file"
 	,""
+	,USAGE_COMMON
 	,"Options:"
 	," -c       use color if terminal supports it"
     };
     size_t n;
     for (n = 0; n < SIZEOF(msg); n++)
 	fprintf(stderr, "%s\n", msg[n]);
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
 
 /*******************************************************************************/
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
 {
-    int n;
+    int ch;
 
     setlocale(LC_ALL, "");
 
-    while ((n = getopt(argc, argv, "c")) != -1) {
-	switch (n) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "c")) != -1) {
+	switch (ch) {
 	case 'c':
 	    try_color = TRUE;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
 
@@ -593,6 +608,7 @@
     }
 
     if (optind + 1 == argc) {
+	int n;
 	for (n = 1; n < argc; n++)
 	    read_data(argv[n]);
 	if (count_cards() == 0)
diff --git a/test/chgat.c b/test/chgat.c
index 919b5c9..2c2b539 100644
--- a/test/chgat.c
+++ b/test/chgat.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2006-2010,2012 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2022 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            *
@@ -26,12 +27,13 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: chgat.c,v 1.12 2012/11/18 01:55:35 tom Exp $
+ * $Id: chgat.c,v 1.20 2022/12/10 23:31:31 tom Exp $
  *
  * test-driver for chgat/wchgat/mvchgat/mvwchgat
  */
 
 #include <test.priv.h>
+#include <popup_msg.h>
 
 #if HAVE_CHGAT
 
@@ -45,10 +47,10 @@
 #endif
 
 typedef struct {
-    unsigned c;
-    unsigned v;
+    size_t c;
+    size_t v;
     short pair;
-    unsigned attr;
+    attr_t attr;
     int count;
     int ch;
     const char *c_msg;
@@ -60,7 +62,7 @@
 } STATUS;
 
 static const char *
-color_params(unsigned state, short *pair)
+color_params(size_t state, short *pair)
 {
     /* *INDENT-OFF* */
     static struct {
@@ -74,12 +76,13 @@
     };
     /* *INDENT-ON* */
 
-    static bool first = TRUE;
     const char *result = 0;
 
     if (has_colors()) {
+	static bool first = TRUE;
+
 	if (first) {
-	    unsigned n;
+	    size_t n;
 
 	    start_color();
 	    for (n = 0; n < SIZEOF(table); ++n) {
@@ -95,18 +98,18 @@
 }
 
 static const char *
-video_params(unsigned state, unsigned *attr)
+video_params(size_t state, attr_t *attr)
 {
     /* *INDENT-OFF* */
     static struct {
-	unsigned attr;
+	attr_t attr;
 	const char *msg;
     } table[] = {
-	{ A_NORMAL,	"normal" },
-	{ A_BOLD,	"bold" },
-	{ A_REVERSE,	"reverse" },
-	{ A_UNDERLINE,	"underline" },
-	{ A_BLINK, 	"blink" },
+	{ WA_NORMAL,	"normal" },
+	{ WA_BOLD,	"bold" },
+	{ WA_REVERSE,	"reverse" },
+	{ WA_UNDERLINE,	"underline" },
+	{ WA_BLINK, 	"blink" },
     };
     /* *INDENT-ON* */
 
@@ -200,7 +203,7 @@
 static void
 show_help(WINDOW *win)
 {
-    static const char *table[] =
+    static const char *msgs[] =
     {
 	"Basic commands:"
 	,"Use h/j/k/l or arrow keys to move the cursor."
@@ -214,19 +217,10 @@
 	,"=     resets count to zero."
 	,"-     negates count."
 	,"?     shows this help-window"
-	,""
-	,""
+	,0
     };
 
-    int y_max, x_max;
-    int row;
-
-    getmaxyx(win, y_max, x_max);
-    for (row = 0; row < (int) SIZEOF(table) && row < y_max; ++row) {
-	MvWPrintw(win, row, 0, "%.*s", x_max, table[row]);
-    }
-    while (wgetch(win) != 'q')
-	beep();
+    popup_msg(win, msgs);
 }
 
 static void
@@ -280,8 +274,8 @@
 	sp->count = -(sp->count);
 	show_status(win, sp);
 	break;
-    case '?':
-	do_subwindow(win, sp, show_help);
+    case HELP_KEY_1:
+	show_help(win);
 	break;
     default:
 	if (isdigit(sp->ch)) {
@@ -354,9 +348,44 @@
     } while ((st.ch = getch()) != ERR);
 }
 
-int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+static void
+usage(int ok)
 {
+    static const char *msg[] =
+    {
+	"Usage: chgat [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
     initscr();
     cbreak();
     noecho();
diff --git a/test/clip_printw.c b/test/clip_printw.c
index d40bf01..c34a1e0 100644
--- a/test/clip_printw.c
+++ b/test/clip_printw.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2008-2012,2014 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            *
@@ -26,21 +27,28 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: clip_printw.c,v 1.10 2014/08/02 23:13:29 tom Exp $
+ * $Id: clip_printw.c,v 1.23 2023/09/30 19:57:44 tom Exp $
  *
- * demonstrate how to use printw without wrapping.
+ * demonstrate how to use printw with/without wrapping.
  */
 
 #include <test.priv.h>
+#include <popup_msg.h>
 
 #ifdef HAVE_VW_PRINTW
 
 #define SHOW(n) ((n) == ERR ? "ERR" : "OK")
 #define COLOR_DEFAULT (-1)
 
+#define X_BASE 0
+#define Y_BASE 1
+#define MARGIN 1
+#define Y_TOP  (Y_BASE + MARGIN)
+
 typedef struct {
     unsigned c;
     unsigned v;
+    bool single;
     int status;
     int pair;
     attr_t attr;
@@ -55,21 +63,29 @@
 } STATUS;
 
 static int
-clip_wprintw(WINDOW *win, NCURSES_CONST char *fmt,...)
+clip_wprintw(WINDOW *win, bool single, NCURSES_CONST char *fmt, ...)
 {
     int y0, x0, y1, x1, width;
     WINDOW *sub;
     va_list ap;
     int rc;
 
-    /*
-     * Allocate a single-line derived window extending from the current
-     * cursor position to the end of the current line in the given window.
-     * Disable scrolling in the derived window.
-     */
     getyx(win, y0, x0);
     width = getmaxx(win) - x0;
-    sub = derwin(win, 1, width, y0, x0);
+    if (single) {
+	/*
+	 * Allocate a single-line derived window extending from the current
+	 * cursor position to the end of the current line in the given window.
+	 * Disable scrolling in the derived window.
+	 */
+	sub = derwin(win, 1, width, y0, x0);
+    } else {
+	/*
+	 * Allow printw to wrap through the entire window.
+	 */
+	sub = derwin(win, getmaxy(win), getmaxx(win), 0, 0);
+	wmove(sub, y0, x0);
+    }
     scrollok(sub, FALSE);
 
     /*
@@ -82,7 +98,11 @@
     getyx(sub, y1, x1);
     delwin(sub);
 
-    wmove(win, y1 + y0, x1 + x0);
+    if (single) {
+	wmove(win, y1 + y0, x1 + x0);
+    } else {
+	wmove(win, y1, x1);
+    }
 
     return rc;
 }
@@ -102,10 +122,11 @@
     };
     /* *INDENT-ON* */
 
-    static bool first = TRUE;
     const char *result = 0;
 
     if (has_colors()) {
+	static bool first = TRUE;
+
 	if (first) {
 	    unsigned n;
 
@@ -132,11 +153,11 @@
 	attr_t attr;
 	const char *msg;
     } table[] = {
-	{ A_NORMAL,	"normal" },
-	{ A_BOLD,	"bold" },
-	{ A_REVERSE,	"reverse" },
-	{ A_UNDERLINE,	"underline" },
-	{ A_BLINK, 	"blink" },
+	{ WA_NORMAL,	"normal" },
+	{ WA_BOLD,	"bold" },
+	{ WA_REVERSE,	"reverse" },
+	{ WA_UNDERLINE,	"underline" },
+	{ WA_BLINK, 	"blink" },
     };
     /* *INDENT-ON* */
 
@@ -153,11 +174,12 @@
 static void
 fill_window(WINDOW *win)
 {
+    int y_top = (win == stdscr) ? Y_BASE : MARGIN;
     int y, x;
     int y0 = -1, x0 = -1;
 
     getyx(win, y, x);
-    wmove(win, 0, 0);
+    wmove(win, y_top, 0);
     while (waddstr(win, "0123456789 abcdefghijklmnopqrstuvwxyz ") != ERR) {
 	int y1, x1;
 	getyx(win, y1, x1);
@@ -175,25 +197,34 @@
     int y, x;
 
     getyx(win, y, x);
+    wattron(win, A_REVERSE);
     wmove(win, 0, 0);
-    wprintw(win, "Count %d", sp->count);
+    wprintw(win, "Clip %s", sp->single ? "line" : "window");
+    wprintw(win, " Count %d", sp->count);
     if (sp->v_msg != 0)
 	wprintw(win, " Video %s", sp->v_msg);
     if (sp->c_msg != 0)
 	wprintw(win, " Color %s", sp->c_msg);
     wprintw(win, " (%d)", sp->status);
     wclrtoeol(win);
+    wattroff(win, A_REVERSE);
     wmove(win, y, x);
 }
 
 static void
 do_subwindow(WINDOW *win, STATUS * sp, void func(WINDOW *))
 {
-    WINDOW *win1 = newwin(sp->y_max - 2, sp->x_max - 2,
-			  sp->y_beg + 1, sp->x_beg + 1);
+    WINDOW *win1 = newwin(sp->y_max - (2 * MARGIN),
+			  sp->x_max - (2 * MARGIN),
+			  sp->y_beg + MARGIN,
+			  sp->x_beg + MARGIN);
 
     if (win1 != 0 && sp->y_max > 4 && sp->x_max > 4) {
-	WINDOW *win2 = derwin(win1, sp->y_max - 4, sp->x_max - 4, 1, 1);
+	WINDOW *win2 = derwin(win1,
+			      sp->y_max - (2 * MARGIN) - 2,
+			      sp->x_max - (2 * MARGIN) - 2,
+			      (win == stdscr) ? Y_BASE : Y_BASE,
+			      MARGIN);
 
 	if (win2 != 0) {
 	    box(win1, 0, 0);
@@ -213,10 +244,14 @@
     }
 }
 
+/*
+ * The status line is within the same window as the test-data.
+ */
 static void
 init_status(WINDOW *win, STATUS * sp)
 {
     memset(sp, 0, sizeof(*sp));
+    sp->single = TRUE;
     sp->c = 99;
     sp->v = 99;
     sp->ch = ' ';
@@ -226,12 +261,14 @@
 
     getbegyx(win, sp->y_beg, sp->x_beg);
     getmaxyx(win, sp->y_max, sp->x_max);
+
+    wmove(win, sp->y_val = Y_BASE, sp->x_val = 0);
 }
 
 static void
 show_help(WINDOW *win)
 {
-    static const char *table[] =
+    static const char *msgs[] =
     {
 	"Basic commands:"
 	,"Use h/j/k/l or arrow keys to move the cursor."
@@ -239,27 +276,24 @@
 	,""
 	,"Other commands:"
 	,"space toggles through the set of video attributes and colors."
+	,"q     exit subwindow, quit if last window."
+	,"s     toggles single-line updates versus entire windows."
 	,"t     touches (forces repaint) of the current line."
-	,".     calls clip_wprintw at the current position with the given count."
+	,"w     create subwindow."
+	,".     calls vw_printw at the current position with the given count."
 	,"=     resets count to zero."
 	,"?     shows this help-window"
-	,""
+	,0
     };
 
-    int y_max, x_max;
-    int row;
-
-    getmaxyx(win, y_max, x_max);
-    for (row = 0; row < (int) SIZEOF(table) && row < y_max; ++row) {
-	MvWPrintw(win, row, 0, "%.*s", x_max, table[row]);
-    }
-    while (wgetch(win) != 'q')
-	beep();
+    popup_msg(win, msgs);
 }
 
 static void
 update_status(WINDOW *win, STATUS * sp)
 {
+    int margin = 0;
+
     switch (sp->ch) {
     case ' ':			/* next test-iteration */
 	if (has_colors()) {
@@ -277,24 +311,40 @@
 	sp->count = 0;
 	show_status(win, sp);
 	break;
+    case KEY_HOME:
+    case '^':
+	wmove(win, sp->y_val, sp->x_val = margin);
+	break;
+    case KEY_END:
+    case '$':
+	wmove(win, sp->y_val, sp->x_val = (sp->x_max - margin - 1));
+	break;
+    case KEY_PPAGE:
+    case CTRL('B'):
+	wmove(win, sp->y_val = Y_BASE, sp->x_val);
+	break;
+    case KEY_NPAGE:
+    case CTRL('F'):
+	wmove(win, sp->y_val = (sp->y_max - margin - 1), sp->x_val);
+	break;
     case KEY_LEFT:
     case 'h':
-	if (sp->x_val > 0)
+	if (sp->x_val > margin)
 	    wmove(win, sp->y_val, --(sp->x_val));
 	break;
     case KEY_DOWN:
     case 'j':
-	if (sp->y_val < sp->y_max)
+	if (sp->y_val < (sp->y_max - margin))
 	    wmove(win, ++(sp->y_val), sp->x_val);
 	break;
     case KEY_UP:
     case 'k':
-	if (sp->y_val > 0)
+	if (sp->y_val > Y_BASE)
 	    wmove(win, --(sp->y_val), sp->x_val);
 	break;
     case KEY_RIGHT:
     case 'l':
-	if (sp->x_val < sp->x_max)
+	if (sp->x_val < (sp->x_max - margin))
 	    wmove(win, sp->y_val, ++(sp->x_val));
 	break;
     case 't':
@@ -304,8 +354,12 @@
 	sp->count = 0;
 	show_status(win, sp);
 	break;
-    case '?':
-	do_subwindow(win, sp, show_help);
+    case 's':
+	sp->single = !sp->single;
+	show_status(win, sp);
+	break;
+    case HELP_KEY_1:
+	show_help(win);
 	break;
     default:
 	if (isdigit(sp->ch)) {
@@ -334,17 +388,20 @@
 	    (void) wattrset(win, AttrArg(COLOR_PAIR(st.pair), st.attr));
 	    if (st.count > 0) {
 		need = (unsigned) st.count + 1;
-		sprintf(fmt, "%%c%%%ds%%c", st.count);
+		_nc_SPRINTF(fmt, _nc_SLIMIT(sizeof(fmt)) "%%c%%%ds%%c", st.count);
 	    } else {
-		need = (unsigned) getmaxx(win) - 1;
-		strcpy(fmt, "%c%s%c");
+		int want = getmaxx(win);
+		if (want < 10)
+		    want = 10;
+		need = (unsigned) want - 1;
+		_nc_STRCPY(fmt, "%c%s%c", sizeof(fmt));
 	    }
 	    if ((buffer = typeMalloc(char, need + 1)) != 0) {
 		for (j = 0; j < need; ++j) {
 		    buffer[j] = (char) ('A' + (j % 26));
 		}
 		buffer[need - 1] = '\0';
-		st.status = clip_wprintw(win, fmt, '[', buffer, ']');
+		st.status = clip_wprintw(win, st.single, fmt, '[', buffer, ']');
 		free(buffer);
 	    }
 	    break;
@@ -360,9 +417,45 @@
     } while ((st.ch = wgetch(win)) != ERR);
 }
 
-int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+static void
+usage(int ok)
 {
+    static const char *msg[] =
+    {
+	"Usage: clip_printw [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
+    setlocale(LC_ALL, "");
     initscr();
     cbreak();
     noecho();
diff --git a/test/color_content.c b/test/color_content.c
new file mode 100644
index 0000000..d08dffb
--- /dev/null
+++ b/test/color_content.c
@@ -0,0 +1,324 @@
+/****************************************************************************
+ * Copyright 2018-2022,2023 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: color_content.c,v 1.19 2023/02/25 16:48:02 tom Exp $
+ */
+
+#define NEED_TIME_H
+#include <test.priv.h>
+
+#if USE_EXTENDED_COLOR
+typedef int my_color_t;
+#else
+typedef NCURSES_COLOR_T my_color_t;
+#endif
+
+typedef struct {
+    my_color_t r;
+    my_color_t g;
+    my_color_t b;
+} MYCOLOR;
+
+static int f_opt;
+static int i_opt;
+static int l_opt;
+static int n_opt;
+static int p_opt;
+static int r_opt;
+static int s_opt;
+
+#if USE_EXTENDED_COLOR
+static int x_opt;
+#endif
+
+static MYCOLOR *expected;
+
+static TimeType initial_time;
+static TimeType finish_time;
+
+static void
+failed(const char *msg)
+{
+    printw("%s", msg);
+    getch();
+    endwin();
+    ExitProgram(EXIT_FAILURE);
+}
+
+#if USE_EXTENDED_COLOR
+static int
+InitColor(int pair, int r, int g, int b)
+{
+    int rc;
+    if (x_opt) {
+	rc = init_extended_color(pair, r, g, b);
+    } else {
+	rc = init_color((NCURSES_PAIRS_T) pair,
+			(NCURSES_COLOR_T) r,
+			(NCURSES_COLOR_T) g,
+			(NCURSES_COLOR_T) b);
+    }
+    return rc;
+}
+
+static int
+ColorContent(int color, int *rp, int *gp, int *bp)
+{
+    int rc;
+    if (x_opt) {
+	rc = extended_color_content(color, rp, gp, bp);
+    } else {
+	NCURSES_COLOR_T r, g, b;
+	if ((rc = color_content((NCURSES_COLOR_T) color, &r, &g, &b)) == OK) {
+	    *rp = r;
+	    *gp = g;
+	    *bp = b;
+	}
+    }
+    return rc;
+}
+#else
+#define InitColor(color,r,g,b)       init_color((NCURSES_COLOR_T)color,(NCURSES_COLOR_T)r,(NCURSES_COLOR_T)g,(NCURSES_COLOR_T)b)
+#define ColorContent(color,rp,gp,bp) color_content((NCURSES_COLOR_T)color,rp,gp,bp)
+#endif
+
+static my_color_t
+random_color(void)
+{
+    return (my_color_t) (rand() % 1000);
+}
+
+static void
+setup_test(void)
+{
+    setlocale(LC_ALL, "");
+    initscr();
+    cbreak();
+    noecho();
+    scrollok(stdscr, TRUE);
+    if (has_colors()) {
+	start_color();
+	if (!can_change_color() && !p_opt)
+	    failed("this terminal cannot initialize colors");
+
+	if (!f_opt)
+	    f_opt = 0;
+	if (!l_opt)
+	    l_opt = COLORS;
+	if (l_opt <= 0)
+	    failed("color limit must be greater than zero");
+
+	if (!n_opt) {
+	    int color;
+	    size_t need = (size_t) ((l_opt > COLORS) ? l_opt : COLORS) + 1;
+
+	    expected = typeCalloc(MYCOLOR, need);
+	    if (s_opt) {
+		int r;
+		int g;
+		int b;
+		color = f_opt;
+		for (r = 0; r < 1000; ++r) {
+		    for (g = 0; g < 1000; ++g) {
+			for (b = 0; b < 1000; ++b) {
+			    if (color < l_opt) {
+				InitColor(color, r, g, b);
+				expected[color].r = (my_color_t) r;
+				expected[color].g = (my_color_t) g;
+				expected[color].b = (my_color_t) b;
+				++color;
+			    } else {
+				break;
+			    }
+			}
+		    }
+		}
+	    } else {
+		for (color = f_opt; color < l_opt; ++color) {
+		    expected[color].r = random_color();
+		    expected[color].g = random_color();
+		    expected[color].b = random_color();
+		    InitColor(color,
+			      expected[color].r,
+			      expected[color].g,
+			      expected[color].b);
+		}
+	    }
+	}
+    } else {
+	failed("This demo requires a color terminal");
+    }
+    GetClockTime(&initial_time);
+}
+
+static void
+run_test(void)
+{
+    int color;
+    bool success = TRUE;
+    for (color = f_opt; color < l_opt; ++color) {
+	my_color_t r;
+	my_color_t g;
+	my_color_t b;
+	if (ColorContent(color, &r, &g, &b) == OK) {
+	    if (expected != 0) {
+		if (r != expected[color].r)
+		    success = FALSE;
+		if (g != expected[color].g)
+		    success = FALSE;
+		if (b != expected[color].b)
+		    success = FALSE;
+	    }
+	}
+    }
+    if (i_opt) {
+	addch(success ? '.' : '?');
+	refresh();
+    }
+}
+
+static void
+finish_test(void)
+{
+    getch();
+    endwin();
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: color_content [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -f COLOR first color value to test (default: 0)"
+	," -i       interactive, showing test-progress"
+	," -l COLOR last color value to test (default: max_colors-1)"
+	," -n       do not initialize color pairs"
+	," -p       print data for color content instead of testing"
+	," -r COUNT repeat for given count"
+	," -s       initialize pairs sequentially rather than random"
+#if USE_EXTENDED_COLOR
+	," -x       use extended color pairs/values"
+#endif
+    };
+    size_t n;
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "f:il:npr:sx")) != -1) {
+	switch (ch) {
+	case 'f':
+	    if ((f_opt = atoi(optarg)) <= 0)
+		usage(FALSE);
+	    break;
+	case 'i':
+	    i_opt = 1;
+	    break;
+	case 'l':
+	    if ((l_opt = atoi(optarg)) <= 0)
+		usage(FALSE);
+	    break;
+	case 'n':
+	    n_opt = 1;
+	    break;
+	case 'p':
+	    p_opt = 1;
+	    break;
+	case 'r':
+	    if ((r_opt = atoi(optarg)) <= 0)
+		usage(FALSE);
+	    break;
+	case 's':
+	    s_opt = 1;
+	    break;
+#if USE_EXTENDED_COLOR
+	case 'x':
+	    x_opt = 1;
+	    break;
+#endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+    if (r_opt <= 0)
+	r_opt = 1;
+
+    setup_test();
+    if (p_opt) {
+	int i;
+	endwin();
+	for (i = 0; i < COLORS; ++i) {
+	    my_color_t r, g, b;
+	    if (ColorContent(i, &r, &g, &b) == OK) {
+		printf("%d: %d %d %d\n", i, r, g, b);
+	    } else {
+		printf("%d: ? ?\n", i);
+	    }
+	}
+    } else {
+	int repeat;
+
+	for (repeat = 0; repeat < r_opt; ++repeat) {
+	    run_test();
+	    if (i_opt) {
+		addch('.');
+		refresh();
+	    }
+	}
+
+	if (i_opt) {
+	    addch('\n');
+	}
+	printw("DONE: ");
+	GetClockTime(&finish_time);
+	printw("%.03f seconds", ElapsedSeconds(&finish_time, &initial_time));
+	finish_test();
+    }
+
+    free(expected);
+    ExitProgram(EXIT_SUCCESS);
+}
diff --git a/test/color_name.h b/test/color_name.h
index 81a3b31..867396c 100644
--- a/test/color_name.h
+++ b/test/color_name.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2011,2012 Free Software Foundation, Inc.                   *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2011-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: color_name.h,v 1.4 2012/11/18 01:59:32 tom Exp $
+ * $Id: color_name.h,v 1.9 2021/04/24 23:25:29 tom Exp $
  */
 
 #ifndef __COLORNAME_H
@@ -36,7 +37,7 @@
 #include <test.priv.h>
 #endif
 
-static NCURSES_CONST char *the_color_names[] =
+static NCURSES_CONST char *const the_color_names[] =
 {
     "black",
     "red",
@@ -79,7 +80,7 @@
     }
     return result;
 }
-#endif /* NEED_COLOR_NAME */
+#endif /* NEED_COLOR_CODE */
 
 #ifdef NEED_COLOR_NAME
 static const char *
@@ -89,7 +90,7 @@
     const char *result = 0;
 
     if (color >= (int) SIZEOF(the_color_names)) {
-	sprintf(temp, "%d", color);
+	_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "%d", color);
 	result = temp;
     } else if (color < 0) {
 	result = "default";
diff --git a/test/color_set.c b/test/color_set.c
index 477d049..5510a0f 100644
--- a/test/color_set.c
+++ b/test/color_set.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2003-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020,2020,2022 Thomas E. Dickey                                *
+ * Copyright 2003-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: color_set.c,v 1.8 2014/02/01 22:10:42 tom Exp $
+ * $Id: color_set.c,v 1.12 2022/12/10 23:36:59 tom Exp $
  */
 
 #include <test.priv.h>
@@ -35,17 +36,53 @@
 
 #define SHOW(n) ((n) == ERR ? "ERR" : "OK")
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: color_set [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     NCURSES_COLOR_T f, b;
-    int i;
+    int ch;
 
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
+    setlocale(LC_ALL, "");
     initscr();
     cbreak();
     noecho();
 
     if (has_colors()) {
+	int i;
+
 	start_color();
 
 	(void) pair_content(0, &f, &b);
diff --git a/test/combine.c b/test/combine.c
new file mode 100644
index 0000000..eca72b8
--- /dev/null
+++ b/test/combine.c
@@ -0,0 +1,313 @@
+/****************************************************************************
+ * Copyright 2021,2022 Thomas E. Dickey                                     *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+/*
+ * $Id: combine.c,v 1.23 2022/12/10 22:28:50 tom Exp $
+ */
+
+#include <test.priv.h>
+
+#if USE_WIDEC_SUPPORT
+
+#include <wctype.h>
+#include <dump_window.h>
+#include <popup_msg.h>
+
+static int c_opt;
+static int r_opt;
+
+static int
+next_char(int value)
+{
+    do {
+	++value;
+    } while (!iswprint((wint_t) value));
+    return value;
+}
+
+static int
+prev_char(int value)
+{
+    do {
+	--value;
+    } while (!iswprint((wint_t) value));
+    return value;
+}
+
+static void
+do_row(int row, int base_ch, int over_ch)
+{
+    int col = 0;
+    bool done = FALSE;
+    bool reverse = (r_opt && !(row % 2));
+
+    move(row, col);
+    printw("[U+%04X]", over_ch);
+    do {
+	if (c_opt) {
+	    wchar_t source[2];
+	    cchar_t target;
+	    attr_t attr = reverse ? A_REVERSE : A_NORMAL;
+
+	    source[1] = 0;
+
+	    source[0] = (wchar_t) base_ch;
+	    setcchar(&target, source, attr, 0, NULL);
+	    add_wch(&target);
+
+	    source[0] = (wchar_t) over_ch;
+	    setcchar(&target, source, attr, 0, NULL);
+	    add_wch(&target);
+	} else {
+	    wchar_t data[3];
+
+	    data[0] = (wchar_t) base_ch;
+	    data[1] = (wchar_t) over_ch;
+	    data[2] = 0;
+	    if (reverse)
+		attr_on(A_REVERSE, NULL);
+	    addwstr(data);
+	    if (reverse)
+		attr_off(A_REVERSE, NULL);
+	}
+	col = getcurx(stdscr);
+	base_ch = next_char(base_ch);
+	done = (col + 1 >= COLS);
+    } while (!done);
+}
+
+#define LAST_OVER 0x6f
+
+static int
+next_over(int value)
+{
+    if (++value > LAST_OVER)
+	value = 0;
+    return value;
+}
+
+static int
+prev_over(int value)
+{
+    if (--value < 0)
+	value = LAST_OVER;
+    return value;
+}
+
+static void
+do_all(int left_at, int over_it)
+{
+    int row;
+
+    for (row = 0; row < LINES; ++row) {
+	do_row(row, left_at, 0x300 + over_it);
+	over_it = next_over(over_it);
+    }
+}
+
+static void
+show_help(WINDOW *current)
+{
+    /* *INDENT-OFF* */
+    static struct {
+	int	key;
+	CONST_FMT char * msg;
+    } help[] = {
+	{ HELP_KEY_1,	"Show this screen" },
+	{ CTRL('L'),	"Repaint screen" },
+	{ '$',		"Scroll to end of combining-character range" },
+	{ '+',		"Scroll to next combining-character in range" },
+	{ KEY_DOWN,	"(same as \"+\")" },
+	{ '-',		"Scroll to previous combining-character in range" },
+	{ KEY_UP,	"(same as \"-\")" },
+	{ '0',		"Scroll to beginning of combining-character range" },
+	{ 'c',		"Toggle command-line option \"-c\"" },
+	{ 'd',		"Dump screen using scr_dump unless \"-l\" option used" },
+	{ 'h',		"Scroll test-data left one column" },
+	{ 'j',		"Scroll test-data down one row" },
+	{ 'k',		"Scroll test-data up one row" },
+	{ 'l',		"Scroll test-data right one column" },
+	{ 'q',		"Quit" },
+	{ ESCAPE,	"(same as \"q\")" },
+	{ QUIT,		"(same as \"q\")" },
+	{ 'r',		"Toggle command-line option \"-r\"" },
+    };
+    /* *INDENT-ON* */
+
+    char **msgs = typeCalloc(char *, SIZEOF(help) + 3);
+    size_t s;
+    int d = 0;
+
+    msgs[d++] = strdup("Test diacritic combining-characters range "
+		       "U+0300..U+036F");
+    msgs[d++] = strdup("");
+    for (s = 0; s < SIZEOF(help); ++s) {
+	char *name = strdup(keyname(help[s].key));
+	size_t need = (11 + strlen(name) + strlen(help[s].msg));
+	msgs[d] = typeMalloc(char, need);
+	_nc_SPRINTF(msgs[d], _nc_SLIMIT(need) "%-10s%s", name, help[s].msg);
+	free(name);
+	++d;
+    }
+    popup_msg2(current, msgs);
+    for (s = 0; msgs[s] != 0; ++s) {
+	free(msgs[s]);
+    }
+    free(msgs);
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: combine [options]"
+	,""
+	,USAGE_COMMON
+	,"Demonstrate combining-characters."
+	,""
+	,"Options:"
+	," -c       use cchar_t data rather than wchar_t string"
+	," -l FILE  log window-dumps to this file"
+	," -r       draw even-numbered rows in reverse-video"
+    };
+    unsigned n;
+    for (n = 0; n < SIZEOF(msg); ++n) {
+	fprintf(stderr, "%s\n", msg[n]);
+    }
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+    int left_at = ' ';
+    int over_it = 0;
+    bool done = FALSE;
+    bool log_option = FALSE;
+    const char *dump_log = "combine.log";
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "cl:r")) != -1) {
+	switch (ch) {
+	case 'c':
+	    c_opt = TRUE;
+	    break;
+	case 'l':
+	    log_option = TRUE;
+	    if (!open_dump(optarg))
+		usage(FALSE);
+	    break;
+	case 'r':
+	    r_opt = TRUE;
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+
+    setlocale(LC_ALL, "");
+    initscr();
+    cbreak();
+    noecho();
+    keypad(stdscr, TRUE);
+
+    do {
+	do_all(left_at, over_it);
+	switch (getch()) {
+	case HELP_KEY_1:
+	    show_help(stdscr);
+	    break;
+	case 'q':
+	case QUIT:
+	case ESCAPE:
+	    done = TRUE;
+	    break;
+	case CTRL('L'):
+	    redrawwin(stdscr);
+	    break;
+	case 'd':
+	    if (log_option)
+		dump_window(stdscr);
+#if HAVE_SCR_DUMP
+	    else
+		scr_dump(dump_log);
+#endif
+	    break;
+	case 'h':
+	    if (left_at > ' ')
+		left_at = prev_char(left_at);
+	    break;
+	case 'l':
+	    left_at = next_char(left_at);
+	    break;
+	case 'c':
+	    c_opt = !c_opt;
+	    break;
+	case 'r':
+	    r_opt = !r_opt;
+	    break;
+	case KEY_HOME:
+	case '0':
+	    over_it = 0;
+	    break;
+	case KEY_END:
+	case '$':
+	    over_it = LAST_OVER;
+	    break;
+	case KEY_UP:
+	case 'k':
+	case '-':
+	    over_it = prev_over(over_it);
+	    break;
+	case KEY_DOWN:
+	case 'j':
+	case '+':
+	    over_it = next_over(over_it);
+	    break;
+	}
+    } while (!done);
+
+    endwin();
+
+    ExitProgram(EXIT_SUCCESS);
+}
+#else
+int
+main(void)
+{
+    printf("This program requires wide-curses functions\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
diff --git a/test/configure b/test/configure
index 29e858c..4f155cd 100755
--- a/test/configure
+++ b/test/configure
@@ -1,7 +1,8 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by Autoconf 2.52.20141204.
+# Generated by Autoconf 2.52.20231210.
 #
+# Copyright 2003-2022,2023	Thomas E. Dickey
 # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
 # Free Software Foundation, Inc.
 # This configure script is free software; the Free Software Foundation
@@ -32,9 +33,9 @@
 as_me=`echo "$0" |sed 's,.*[\\/],,'`
 
 if expr a : '\(a\)' >/dev/null 2>&1; then
-  as_expr=expr
+  as_expr="expr"
 else
-  as_expr=false
+  as_expr="false"
 fi
 
 rm -f conf$$ conf$$.exe conf$$.file
@@ -49,7 +50,7 @@
     as_ln_s='ln -s'
   fi
 elif ln conf$$.file conf$$ 2>/dev/null; then
-  as_ln_s=ln
+  as_ln_s='ln'
 else
   as_ln_s='cp -p'
 fi
@@ -59,9 +60,9 @@
 
 # Support unset when possible.
 if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
-  as_unset=unset
+  as_unset="unset"
 else
-  as_unset=false
+  as_unset="false"
 fi
 
 # NLS nuisances.
@@ -96,15 +97,52 @@
 ac_default_prefix=/usr/local
 cross_compiling=no
 subdirs=
-MFLAGS= MAKEFLAGS=
+MFLAGS=
+MAKEFLAGS=
 SHELL=${CONFIG_SHELL-/bin/sh}
 
 # Maximum number of lines to put in a shell here document.
 # This variable seems obsolete.  It should probably be removed, and
 # only ac_max_sed_lines should be used.
-: ${ac_max_here_lines=38}
+: "${ac_max_here_lines=38}"
 
 ac_unique_file="ncurses.c"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+#  include <stdint.h>
+# endif
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
 
 # Initialize some variables set by options.
 ac_init_help=
@@ -139,6 +177,7 @@
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 libdir='${exec_prefix}/lib'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
@@ -166,7 +205,7 @@
 
   # Accept the important Cygnus configure options, so we can diagnose typos.
 
-  case $ac_option in
+  case "$ac_option" in
 
   -bindir | --bindir | --bindi | --bind | --bin | --bi)
     ac_prev=bindir ;;
@@ -207,7 +246,7 @@
     expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
       { echo "$as_me: error: invalid feature name: $ac_feature" >&2
    { (exit 1); exit 1; }; }
-    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+    ac_feature=`echo "$ac_feature" | sed 's/-/_/g'`
     eval "enable_$ac_feature=no" ;;
 
   -enable-* | --enable-*)
@@ -216,8 +255,8 @@
     expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
       { echo "$as_me: error: invalid feature name: $ac_feature" >&2
    { (exit 1); exit 1; }; }
-    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
-    case $ac_option in
+    ac_feature=`echo "$ac_feature" | sed 's/-/_/g'`
+    case "$ac_option" in
       *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
       *) ac_optarg=yes ;;
     esac
@@ -281,6 +320,15 @@
   | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
     localstatedir=$ac_optarg ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst \
+  | --runs | --run | --ru)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* \
+  | --runs=* | --run=* | --ru=*)
+    runstatedir=$ac_optarg ;;
+
   -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
     ac_prev=mandir ;;
   -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
@@ -398,8 +446,8 @@
     expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
       { echo "$as_me: error: invalid package name: $ac_package" >&2
    { (exit 1); exit 1; }; }
-    ac_package=`echo $ac_package| sed 's/-/_/g'`
-    case $ac_option in
+    ac_package=`echo "$ac_package" | sed 's/-/_/g'`
+    case "$ac_option" in
       *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
       *) ac_optarg=yes ;;
     esac
@@ -411,7 +459,7 @@
     expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
       { echo "$as_me: error: invalid package name: $ac_package" >&2
    { (exit 1); exit 1; }; }
-    ac_package=`echo $ac_package | sed 's/-/_/g'`
+    ac_package=`echo "$ac_package" | sed 's/-/_/g'`
     eval "with_$ac_package=no" ;;
 
   --x)
@@ -445,21 +493,21 @@
    { (exit 1); exit 1; }; }
     ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
     eval "$ac_envvar='$ac_optarg'"
-    export $ac_envvar ;;
+    export "$ac_envvar" ;;
 
   *)
     # FIXME: should be removed in autoconf 3.0.
     echo "$as_me: WARNING: you should use --build, --host, --target" >&2
     expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
       echo "$as_me: WARNING: invalid host type: $ac_option" >&2
-    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+    : "${build_alias=$ac_option}" "${host_alias=$ac_option}" "${target_alias=$ac_option}"
     ;;
 
   esac
 done
 
 if test -n "$ac_prev"; then
-  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  ac_option=--`echo "$ac_prev" | sed 's/_/-/g'`
   { echo "$as_me: error: missing argument to $ac_option" >&2
    { (exit 1); exit 1; }; }
 fi
@@ -467,8 +515,8 @@
 # Be sure to have absolute paths.
 for ac_var in exec_prefix prefix
 do
-  eval ac_val=$`echo $ac_var`
-  case $ac_val in
+  eval ac_val=$`echo "$ac_var"`
+  case "$ac_val" in
     [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
     *)  { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2
    { (exit 1); exit 1; }; };;
@@ -479,8 +527,8 @@
 for ac_var in bindir sbindir libexecdir datarootdir datadir sysconfdir sharedstatedir \
               localstatedir libdir includedir oldincludedir infodir mandir
 do
-  eval ac_val=$`echo $ac_var`
-  case $ac_val in
+  eval ac_val=$`echo "$ac_var"`
+  case "$ac_val" in
     [\\/$]* | ?:[\\/]* ) ;;
     *)  { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2
    { (exit 1); exit 1; }; };;
@@ -517,13 +565,13 @@
   ac_confdir=`echo "$ac_prog" | sed 's%[\\/][^\\/][^\\/]*$%%'`
   test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
   srcdir=$ac_confdir
-  if test ! -r $srcdir/$ac_unique_file; then
+  if test ! -r "$srcdir/$ac_unique_file"; then
     srcdir=..
   fi
 else
   ac_srcdir_defaulted=no
 fi
-if test ! -r $srcdir/$ac_unique_file; then
+if test ! -r "$srcdir/$ac_unique_file"; then
   if test "$ac_srcdir_defaulted" = yes; then
     { echo "$as_me: error: cannot find sources in $ac_confdir or .." >&2
    { (exit 1); exit 1; }; }
@@ -618,6 +666,7 @@
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       extra definition of runtime data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -646,16 +695,20 @@
 
   cat <<\EOF
 
-Optional Packages:
-  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-
 Optional Features:
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
 
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+
 General Options:
-  --with-pkg-config{=path} enable/disable use of pkg-config
+  --disable-stripping     do not strip (debug info) installed executables
+  --with-strip-program=XX specify program to use when stripping in install
+  --enable-stdnoreturn    enable C11 _Noreturn feature for diagnostics
+  --enable-string-hacks   work around bogus compiler/loader warnings
+  --with-pkg-config[=CMD] enable/disable use of pkg-config and its name CMD
   --disable-echo          do not display "compiling" commands
 Curses Version-dependent Options:
   --with-ncurses-wrap-prefix naming-prefix for ncurses wrapped-variables
@@ -672,6 +725,13 @@
   --with-neXtaw           link with neXT Athena library
   --with-XawPlus          link with Athena-Plus library
   --with-x                use the X Window System
+  --with-x11-rgb=FILE     obtain X11 color definitions from FILE (default: EPREFIX/lib/X11/rgb.txt)
+  --with-form-libname[=XXX] override ifelse(,,form,) basename of library
+  --with-menu-libname[=XXX] override ifelse(,,menu,) basename of library
+  --with-panel-libname[=XXX] override ifelse(,,panel,) basename of library
+  --disable-panel         disable checks for panel functions
+  --disable-menu          disable checks for menu functions
+  --disable-form          disable checks for form functions
 Testing/development Options:
   --enable-warnings       test: turn on gcc compiler warnings
   --with-dmalloc          test: use Gray Watson's dmalloc library
@@ -699,42 +759,43 @@
   # If there are subdirs, report their specific --help.
   ac_popdir=`pwd`
   for ac_subdir in : $ac_subdirs_all; do test "x$ac_subdir" = x: && continue
-    cd $ac_subdir
+    cd "$ac_subdir"
     # A "../" for each directory in /$ac_subdir.
-    ac_dots=`echo $ac_subdir |
+    ac_dots=`echo "$ac_subdir" |
              sed 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g'`
 
-    case $srcdir in
+    case "$srcdir" in
     .) # No --srcdir option.  We are building in place.
-      ac_sub_srcdir=$srcdir ;;
+      ac_sub_srcdir="$srcdir" ;;
     [\\/]* | ?:[\\/]* ) # Absolute path.
-      ac_sub_srcdir=$srcdir/$ac_subdir ;;
+      ac_sub_srcdir="$srcdir/$ac_subdir" ;;
     *) # Relative path.
-      ac_sub_srcdir=$ac_dots$srcdir/$ac_subdir ;;
+      ac_sub_srcdir="$ac_dots$srcdir/$ac_subdir" ;;
     esac
 
     # Check for guested configure; otherwise get Cygnus style configure.
-    if test -f $ac_sub_srcdir/configure.gnu; then
+    if test -f "$ac_sub_srcdir/configure.gnu"; then
       echo
-      $SHELL $ac_sub_srcdir/configure.gnu  --help=recursive
-    elif test -f $ac_sub_srcdir/configure; then
+      $SHELL "$ac_sub_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_sub_srcdir/configure"; then
       echo
-      $SHELL $ac_sub_srcdir/configure  --help=recursive
-    elif test -f $ac_sub_srcdir/configure.ac ||
-           test -f $ac_sub_srcdir/configure.in; then
+      $SHELL "$ac_sub_srcdir/configure" --help=recursive
+    elif test -f "$ac_sub_srcdir/configure.ac" ||
+           test -f "$ac_sub_srcdir/configure.in"; then
       echo
-      $ac_configure --help
+      "$ac_configure" --help
     else
       echo "$as_me: WARNING: no configuration information is in $ac_subdir" >&2
     fi
-    cd $ac_popdir
+    cd "$ac_popdir"
   done
 fi
 
 test -n "$ac_init_help" && exit 0
-if $ac_init_version; then
+if "$ac_init_version"; then
   cat <<\EOF
 
+Copyright 2003-2022,2023	Thomas E. Dickey
 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
@@ -748,7 +809,7 @@
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by $as_me, which was
-generated by GNU Autoconf 2.52.20141204.  Invocation command line was
+generated by GNU Autoconf 2.52.20231210.  Invocation command line was
 
   $ $0 $@
 
@@ -795,7 +856,7 @@
 ac_sep=
 for ac_arg
 do
-  case $ac_arg in
+  case "$ac_arg" in
   -no-create | --no-create | --no-creat | --no-crea | --no-cre \
   | --no-cr | --no-c) ;;
   -no-recursion | --no-recursion | --no-recursio | --no-recursi \
@@ -852,7 +913,7 @@
     exit $exit_status
      ' 0
 for ac_signal in 1 2 13 15; do
-  trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+  trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' "$ac_signal"
 done
 ac_signal=0
 
@@ -872,7 +933,7 @@
 fi
 for ac_site_file in $CONFIG_SITE; do
   if test -r "$ac_site_file"; then
-    { echo "$as_me:875: loading site script $ac_site_file" >&5
+    { echo "$as_me:936: loading site script $ac_site_file" >&5
 echo "$as_me: loading site script $ac_site_file" >&6;}
     cat "$ac_site_file" >&5
     . "$ac_site_file"
@@ -883,7 +944,7 @@
   # Some versions of bash will fail to source /dev/null (special
   # files actually), so we avoid doing that.
   if test -f "$cache_file"; then
-    { echo "$as_me:886: loading cache $cache_file" >&5
+    { echo "$as_me:947: loading cache $cache_file" >&5
 echo "$as_me: loading cache $cache_file" >&6;}
     case $cache_file in
       [\\/]* | ?:[\\/]* ) . $cache_file;;
@@ -891,7 +952,7 @@
     esac
   fi
 else
-  { echo "$as_me:894: creating cache $cache_file" >&5
+  { echo "$as_me:955: creating cache $cache_file" >&5
 echo "$as_me: creating cache $cache_file" >&6;}
   >$cache_file
 fi
@@ -905,23 +966,23 @@
   eval ac_new_set=\$ac_env_${ac_var}_set
   eval ac_old_val="\$ac_cv_env_${ac_var}_value"
   eval ac_new_val="\$ac_env_${ac_var}_value"
-  case $ac_old_set,$ac_new_set in
+  case "$ac_old_set,$ac_new_set" in
     set,)
-      { echo "$as_me:910: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+      { echo "$as_me:971: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,set)
-      { echo "$as_me:914: error: \`$ac_var' was not set in the previous run" >&5
+      { echo "$as_me:975: error: \`$ac_var' was not set in the previous run" >&5
 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,);;
     *)
       if test "x$ac_old_val" != "x$ac_new_val"; then
-        { echo "$as_me:920: error: \`$ac_var' has changed since the previous run:" >&5
+        { echo "$as_me:981: error: \`$ac_var' has changed since the previous run:" >&5
 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
-        { echo "$as_me:922:   former value:  $ac_old_val" >&5
+        { echo "$as_me:983:   former value:  $ac_old_val" >&5
 echo "$as_me:   former value:  $ac_old_val" >&2;}
-        { echo "$as_me:924:   current value: $ac_new_val" >&5
+        { echo "$as_me:985:   current value: $ac_new_val" >&5
 echo "$as_me:   current value: $ac_new_val" >&2;}
         ac_cache_corrupted=:
       fi;;
@@ -929,7 +990,7 @@
   # Pass precious variables to config.status.  It doesn't matter if
   # we pass some twice (in addition to the command line arguments).
   if test "$ac_new_set" = set; then
-    case $ac_new_val in
+    case "$ac_new_val" in
     *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
       ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"`
       ac_configure_args="$ac_configure_args '$ac_arg'"
@@ -939,35 +1000,43 @@
     esac
   fi
 done
-if $ac_cache_corrupted; then
-  { echo "$as_me:943: error: changes in the environment can compromise the build" >&5
+if "$ac_cache_corrupted"; then
+  { echo "$as_me:1004: error: changes in the environment can compromise the build" >&5
 echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  { { echo "$as_me:945: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+  { { echo "$as_me:1006: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5'
+ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
-ac_main_return=return
+ac_main_return="return"
 
 case `echo "testing\c" 2>/dev/null; echo 1,2,3`,`echo -n testing 2>/dev/null; echo 1,2,3` in
-  *c*,-n*) ECHO_N= ECHO_C=	# newlines do not sed ;-) only broken shells would use this case anyway
-		   ECHO_T='	' ;;
-  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
-  *)      ECHO_N= ECHO_C='\c' ECHO_T= ;;
+  *c*,-n*) ECHO_N=
+           ECHO_C=      # newlines do not sed ;-) only broken shells would use this case anyway
+           ECHO_T='	'
+           ;;
+  *c*,*  ) ECHO_N=-n
+           ECHO_C=
+           ECHO_T=
+           ;;
+  *)       ECHO_N=
+           ECHO_C='\c'
+           ECHO_T=
+           ;;
 esac
 echo "#! $SHELL" >conftest.sh
 echo  "exit 0"   >>conftest.sh
 chmod +x conftest.sh
-if { (echo "$as_me:966: PATH=\".;.\"; conftest.sh") >&5
+if { (echo "$as_me:1035: PATH=\".;.\"; conftest.sh") >&5
   (PATH=".;."; conftest.sh) 2>&5
   ac_status=$?
-  echo "$as_me:969: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
+  echo "$as_me:1038: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; then
   ac_path_separator=';'
 else
   ac_path_separator=:
@@ -983,22 +1052,22 @@
 
 ac_aux_dir=
 for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
-  if test -f $ac_dir/install-sh; then
+  if test -f "$ac_dir/install-sh"; then
     ac_aux_dir=$ac_dir
     ac_install_sh="$ac_aux_dir/install-sh -c"
     break
-  elif test -f $ac_dir/install.sh; then
+  elif test -f "$ac_dir/install.sh"; then
     ac_aux_dir=$ac_dir
     ac_install_sh="$ac_aux_dir/install.sh -c"
     break
-  elif test -f $ac_dir/shtool; then
+  elif test -f "$ac_dir/shtool"; then
     ac_aux_dir=$ac_dir
     ac_install_sh="$ac_aux_dir/shtool install -c"
     break
   fi
 done
 if test -z "$ac_aux_dir"; then
-  { { echo "$as_me:1001: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+  { { echo "$as_me:1070: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
 echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1008,11 +1077,11 @@
 
 # Make sure we can run config.sub.
 $ac_config_sub sun4 >/dev/null 2>&1 ||
-  { { echo "$as_me:1011: error: cannot run $ac_config_sub" >&5
+  { { echo "$as_me:1080: error: cannot run $ac_config_sub" >&5
 echo "$as_me: error: cannot run $ac_config_sub" >&2;}
    { (exit 1); exit 1; }; }
 
-echo "$as_me:1015: checking build system type" >&5
+echo "$as_me:1084: checking build system type" >&5
 echo $ECHO_N "checking build system type... $ECHO_C" >&6
 if test "${ac_cv_build+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1021,24 +1090,24 @@
 test -z "$ac_cv_build_alias" &&
   ac_cv_build_alias=`$ac_config_guess`
 test -z "$ac_cv_build_alias" &&
-  { { echo "$as_me:1024: error: cannot guess build type; you must specify one" >&5
+  { { echo "$as_me:1093: error: cannot guess build type; you must specify one" >&5
 echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
    { (exit 1); exit 1; }; }
-ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
-  { { echo "$as_me:1028: error: $ac_config_sub $ac_cv_build_alias failed." >&5
+ac_cv_build=`$ac_config_sub "$ac_cv_build_alias"` ||
+  { { echo "$as_me:1097: error: $ac_config_sub $ac_cv_build_alias failed." >&5
 echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed." >&2;}
    { (exit 1); exit 1; }; }
 
 fi
-echo "$as_me:1033: result: $ac_cv_build" >&5
+echo "$as_me:1102: result: $ac_cv_build" >&5
 echo "${ECHO_T}$ac_cv_build" >&6
 build=$ac_cv_build
-build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+build_cpu=`echo "$ac_cv_build" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo "$ac_cv_build" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo "$ac_cv_build" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 
-if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
-	echo "$as_me:1041: checking host system type" >&5
+if test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then
+	echo "$as_me:1110: checking host system type" >&5
 echo $ECHO_N "checking host system type... $ECHO_C" >&6
 if test "${ac_cv_host+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1046,18 +1115,18 @@
   ac_cv_host_alias=$host_alias
 test -z "$ac_cv_host_alias" &&
   ac_cv_host_alias=$ac_cv_build_alias
-ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
-  { { echo "$as_me:1050: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+ac_cv_host=`$ac_config_sub "$ac_cv_host_alias"` ||
+  { { echo "$as_me:1119: error: $ac_config_sub $ac_cv_host_alias failed" >&5
 echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
    { (exit 1); exit 1; }; }
 
 fi
-echo "$as_me:1055: result: $ac_cv_host" >&5
+echo "$as_me:1124: result: $ac_cv_host" >&5
 echo "${ECHO_T}$ac_cv_host" >&6
 host=$ac_cv_host
-host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+host_cpu=`echo "$ac_cv_host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo "$ac_cv_host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo "$ac_cv_host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 
 	system_name="$host_os"
 else
@@ -1078,13 +1147,13 @@
 fi
 
 test -z "$system_name" && system_name="$cf_cv_system_name"
-test -n "$cf_cv_system_name" && echo "$as_me:1081: result: Configuring for $cf_cv_system_name" >&5
+test -n "$cf_cv_system_name" && echo "$as_me:1150: result: Configuring for $cf_cv_system_name" >&5
 echo "${ECHO_T}Configuring for $cf_cv_system_name" >&6
 
 if test ".$system_name" != ".$cf_cv_system_name" ; then
-	echo "$as_me:1085: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5
+	echo "$as_me:1154: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5
 echo "${ECHO_T}Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&6
-	{ { echo "$as_me:1087: error: \"Please remove config.cache and try again.\"" >&5
+	{ { echo "$as_me:1156: error: \"Please remove config.cache and try again.\"" >&5
 echo "$as_me: error: \"Please remove config.cache and try again.\"" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1102,7 +1171,7 @@
 program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
 rm conftest.sed
 
-echo "$as_me:1105: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "$as_me:1174: checking whether ${MAKE-make} sets \${MAKE}" >&5
 echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'`
 if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
@@ -1122,25 +1191,25 @@
 rm -f conftest.make
 fi
 if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
-  echo "$as_me:1125: result: yes" >&5
+  echo "$as_me:1194: result: yes" >&5
 echo "${ECHO_T}yes" >&6
   SET_MAKE=
 else
-  echo "$as_me:1129: result: no" >&5
+  echo "$as_me:1198: result: no" >&5
 echo "${ECHO_T}no" >&6
   SET_MAKE="MAKE=${MAKE-make}"
 fi
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5'
+ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
-ac_main_return=return
+ac_main_return="return"
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}gcc; ac_word=$2
-echo "$as_me:1143: checking for $ac_word" >&5
+echo "$as_me:1212: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1155,7 +1224,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_CC="${ac_tool_prefix}gcc"
-echo "$as_me:1158: found $ac_dir/$ac_word" >&5
+echo "$as_me:1227: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1163,10 +1232,10 @@
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1166: result: $CC" >&5
+  echo "$as_me:1235: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1169: result: no" >&5
+  echo "$as_me:1238: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1175,7 +1244,7 @@
   ac_ct_CC=$CC
   # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
-echo "$as_me:1178: checking for $ac_word" >&5
+echo "$as_me:1247: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1190,7 +1259,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_CC="gcc"
-echo "$as_me:1193: found $ac_dir/$ac_word" >&5
+echo "$as_me:1262: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1198,10 +1267,10 @@
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:1201: result: $ac_ct_CC" >&5
+  echo "$as_me:1270: result: $ac_ct_CC" >&5
 echo "${ECHO_T}$ac_ct_CC" >&6
 else
-  echo "$as_me:1204: result: no" >&5
+  echo "$as_me:1273: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1214,7 +1283,7 @@
   if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}cc; ac_word=$2
-echo "$as_me:1217: checking for $ac_word" >&5
+echo "$as_me:1286: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1229,7 +1298,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_CC="${ac_tool_prefix}cc"
-echo "$as_me:1232: found $ac_dir/$ac_word" >&5
+echo "$as_me:1301: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1237,10 +1306,10 @@
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1240: result: $CC" >&5
+  echo "$as_me:1309: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1243: result: no" >&5
+  echo "$as_me:1312: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1249,7 +1318,7 @@
   ac_ct_CC=$CC
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-echo "$as_me:1252: checking for $ac_word" >&5
+echo "$as_me:1321: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1264,7 +1333,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_CC="cc"
-echo "$as_me:1267: found $ac_dir/$ac_word" >&5
+echo "$as_me:1336: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1272,10 +1341,10 @@
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:1275: result: $ac_ct_CC" >&5
+  echo "$as_me:1344: result: $ac_ct_CC" >&5
 echo "${ECHO_T}$ac_ct_CC" >&6
 else
-  echo "$as_me:1278: result: no" >&5
+  echo "$as_me:1347: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1288,7 +1357,7 @@
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-echo "$as_me:1291: checking for $ac_word" >&5
+echo "$as_me:1360: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1308,11 +1377,11 @@
   continue
 fi
 ac_cv_prog_CC="cc"
-echo "$as_me:1311: found $ac_dir/$ac_word" >&5
+echo "$as_me:1380: found $ac_dir/$ac_word" >&5
 break
 done
 
-if test $ac_prog_rejected = yes; then
+if test "$ac_prog_rejected" = yes; then
   # We found a bogon in the path, so make sure we never use it.
   set dummy $ac_cv_prog_CC
   shift
@@ -1330,10 +1399,10 @@
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1333: result: $CC" >&5
+  echo "$as_me:1402: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1336: result: no" >&5
+  echo "$as_me:1405: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1344,7 +1413,7 @@
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:1347: checking for $ac_word" >&5
+echo "$as_me:1416: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1359,7 +1428,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-echo "$as_me:1362: found $ac_dir/$ac_word" >&5
+echo "$as_me:1431: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1367,10 +1436,10 @@
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1370: result: $CC" >&5
+  echo "$as_me:1439: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1373: result: no" >&5
+  echo "$as_me:1442: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1383,7 +1452,7 @@
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:1386: checking for $ac_word" >&5
+echo "$as_me:1455: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1398,7 +1467,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_CC="$ac_prog"
-echo "$as_me:1401: found $ac_dir/$ac_word" >&5
+echo "$as_me:1470: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1406,10 +1475,10 @@
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:1409: result: $ac_ct_CC" >&5
+  echo "$as_me:1478: result: $ac_ct_CC" >&5
 echo "${ECHO_T}$ac_ct_CC" >&6
 else
-  echo "$as_me:1412: result: no" >&5
+  echo "$as_me:1481: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1421,36 +1490,36 @@
 
 fi
 
-test -z "$CC" && { { echo "$as_me:1424: error: no acceptable cc found in \$PATH" >&5
+test -z "$CC" && { { echo "$as_me:1493: error: no acceptable cc found in \$PATH" >&5
 echo "$as_me: error: no acceptable cc found in \$PATH" >&2;}
    { (exit 1); exit 1; }; }
 
 # Provide some information about the compiler.
-echo "$as_me:1429:" \
+echo "$as_me:1498:" \
      "checking for C compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:1432: \"$ac_compiler --version </dev/null >&5\"") >&5
+ac_compiler=`set X $ac_compile; echo "$2"`
+{ (eval echo "$as_me:1501: \"$ac_compiler --version </dev/null >&5\"") >&5
   (eval $ac_compiler --version </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:1435: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (eval echo "$as_me:1437: \"$ac_compiler -v </dev/null >&5\"") >&5
+  echo "$as_me:1504: \$? = $ac_status" >&5
+  (exit "$ac_status"); }
+{ (eval echo "$as_me:1506: \"$ac_compiler -v </dev/null >&5\"") >&5
   (eval $ac_compiler -v </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:1440: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (eval echo "$as_me:1442: \"$ac_compiler -V </dev/null >&5\"") >&5
+  echo "$as_me:1509: \$? = $ac_status" >&5
+  (exit "$ac_status"); }
+{ (eval echo "$as_me:1511: \"$ac_compiler -V </dev/null >&5\"") >&5
   (eval $ac_compiler -V </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:1445: \$? = $ac_status" >&5
-  (exit $ac_status); }
+  echo "$as_me:1514: \$? = $ac_status" >&5
+  (exit "$ac_status"); }
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 1449 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 1518 "configure"
 #include "confdefs.h"
 
 int
-main ()
+main (void)
 {
 
   ;
@@ -1462,14 +1531,14 @@
 # Try to create an executable without -o first, disregard a.out.
 # It will help us diagnose broken compilers, and finding out an intuition
 # of exeext.
-echo "$as_me:1465: checking for C compiler default output" >&5
+echo "$as_me:1534: checking for C compiler default output" >&5
 echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6
-ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-if { (eval echo "$as_me:1468: \"$ac_link_default\"") >&5
+ac_link_default=`echo "$ac_link" | sed 's/ -o *"conftest[^"]*"//'`
+if { (eval echo "$as_me:1537: \"$ac_link_default\"") >&5
   (eval $ac_link_default) 2>&5
   ac_status=$?
-  echo "$as_me:1471: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
+  echo "$as_me:1540: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; then
   # Find the output, starting from the most likely.  This scheme is
 # not robust to junk in `.', hence go to wildcards (a.*) only as a last
 # resort.
@@ -1490,35 +1559,35 @@
 done
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-{ { echo "$as_me:1494: error: C compiler cannot create executables" >&5
+cat "conftest.$ac_ext" >&5
+{ { echo "$as_me:1563: error: C compiler cannot create executables" >&5
 echo "$as_me: error: C compiler cannot create executables" >&2;}
    { (exit 77); exit 77; }; }
 fi
 
 ac_exeext=$ac_cv_exeext
-echo "$as_me:1500: result: $ac_file" >&5
+echo "$as_me:1569: result: $ac_file" >&5
 echo "${ECHO_T}$ac_file" >&6
 
 # Check the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-echo "$as_me:1505: checking whether the C compiler works" >&5
+echo "$as_me:1574: checking whether the C compiler works" >&5
 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0
 # If not cross compiling, check that we can run a simple program.
 if test "$cross_compiling" != yes; then
   if { ac_try='./$ac_file'
-  { (eval echo "$as_me:1511: \"$ac_try\"") >&5
+  { (eval echo "$as_me:1580: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1514: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:1583: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
     cross_compiling=no
   else
     if test "$cross_compiling" = maybe; then
 	cross_compiling=yes
     else
-	{ { echo "$as_me:1521: error: cannot run C compiled programs.
+	{ { echo "$as_me:1590: error: cannot run C compiled programs.
 If you meant to cross compile, use \`--host'." >&5
 echo "$as_me: error: cannot run C compiled programs.
 If you meant to cross compile, use \`--host'." >&2;}
@@ -1526,25 +1595,25 @@
     fi
   fi
 fi
-echo "$as_me:1529: result: yes" >&5
+echo "$as_me:1598: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 
-rm -f a.out a.exe conftest$ac_cv_exeext
+rm -f a.out a.exe "conftest$ac_cv_exeext"
 ac_clean_files=$ac_clean_files_save
 # Check the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-echo "$as_me:1536: checking whether we are cross compiling" >&5
+echo "$as_me:1605: checking whether we are cross compiling" >&5
 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
-echo "$as_me:1538: result: $cross_compiling" >&5
+echo "$as_me:1607: result: $cross_compiling" >&5
 echo "${ECHO_T}$cross_compiling" >&6
 
-echo "$as_me:1541: checking for executable suffix" >&5
+echo "$as_me:1610: checking for executable suffix" >&5
 echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6
-if { (eval echo "$as_me:1543: \"$ac_link\"") >&5
+if { (eval echo "$as_me:1612: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:1546: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
+  echo "$as_me:1615: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; then
   # If both `conftest.exe' and `conftest' are `present' (well, observable)
 # catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
 # work properly (i.e., refer to `conftest.exe'), while it won't with
@@ -1559,29 +1628,29 @@
   esac
 done
 else
-  { { echo "$as_me:1562: error: cannot compute EXEEXT: cannot compile and link" >&5
+  { { echo "$as_me:1631: error: cannot compute EXEEXT: cannot compile and link" >&5
 echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
-rm -f conftest$ac_cv_exeext
-echo "$as_me:1568: result: $ac_cv_exeext" >&5
+rm -f "conftest$ac_cv_exeext"
+echo "$as_me:1637: result: $ac_cv_exeext" >&5
 echo "${ECHO_T}$ac_cv_exeext" >&6
 
-rm -f conftest.$ac_ext
+rm -f "conftest.$ac_ext"
 EXEEXT=$ac_cv_exeext
 ac_exeext=$EXEEXT
-echo "$as_me:1574: checking for object suffix" >&5
+echo "$as_me:1643: checking for object suffix" >&5
 echo $ECHO_N "checking for object suffix... $ECHO_C" >&6
 if test "${ac_cv_objext+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 1580 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 1649 "configure"
 #include "confdefs.h"
 
 int
-main ()
+main (void)
 {
 
   ;
@@ -1589,11 +1658,11 @@
 }
 _ACEOF
 rm -f conftest.o conftest.obj
-if { (eval echo "$as_me:1592: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:1661: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1595: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
+  echo "$as_me:1664: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; then
   for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
   case $ac_file in
     *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.map | *.inf ) ;;
@@ -1603,29 +1672,29 @@
 done
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-{ { echo "$as_me:1607: error: cannot compute OBJEXT: cannot compile" >&5
+cat "conftest.$ac_ext" >&5
+{ { echo "$as_me:1676: error: cannot compute OBJEXT: cannot compile" >&5
 echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
-rm -f conftest.$ac_cv_objext conftest.$ac_ext
+rm -f "conftest.$ac_cv_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:1614: result: $ac_cv_objext" >&5
+echo "$as_me:1683: result: $ac_cv_objext" >&5
 echo "${ECHO_T}$ac_cv_objext" >&6
 OBJEXT=$ac_cv_objext
 ac_objext=$OBJEXT
-echo "$as_me:1618: checking whether we are using the GNU C compiler" >&5
+echo "$as_me:1687: checking whether we are using the GNU C compiler" >&5
 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
 if test "${ac_cv_c_compiler_gnu+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 1624 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 1693 "configure"
 #include "confdefs.h"
 
 int
-main ()
+main (void)
 {
 #ifndef __GNUC__
        choke me
@@ -1635,72 +1704,72 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1639: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:1708: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1642: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1645: \"$ac_try\"") >&5
+  echo "$as_me:1711: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:1714: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1648: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:1717: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_compiler_gnu=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_compiler_gnu=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 ac_cv_c_compiler_gnu=$ac_compiler_gnu
 
 fi
-echo "$as_me:1660: result: $ac_cv_c_compiler_gnu" >&5
+echo "$as_me:1729: result: $ac_cv_c_compiler_gnu" >&5
 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
 GCC=`test $ac_compiler_gnu = yes && echo yes`
 ac_test_CFLAGS=${CFLAGS+set}
 ac_save_CFLAGS=$CFLAGS
 CFLAGS="-g"
-echo "$as_me:1666: checking whether $CC accepts -g" >&5
+echo "$as_me:1735: checking whether $CC accepts -g" >&5
 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
 if test "${ac_cv_prog_cc_g+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 1672 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 1741 "configure"
 #include "confdefs.h"
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1684: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:1753: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1687: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1690: \"$ac_try\"") >&5
+  echo "$as_me:1756: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:1759: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1693: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:1762: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_prog_cc_g=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_prog_cc_g=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:1703: result: $ac_cv_prog_cc_g" >&5
+echo "$as_me:1772: result: $ac_cv_prog_cc_g" >&5
 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
 if test "$ac_test_CFLAGS" = set; then
   CFLAGS=$ac_save_CFLAGS
@@ -1721,23 +1790,23 @@
 # in C++ we need to declare it.  In case someone uses the same compiler
 # for both compiling C and C++ we need to have the C++ compiler decide
 # the declaration of exit, since it's the most demanding environment.
-cat >conftest.$ac_ext <<_ACEOF
+cat >"conftest.$ac_ext" <<_ACEOF
 #ifndef __cplusplus
   choke me
 #endif
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1730: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:1799: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1733: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1736: \"$ac_try\"") >&5
+  echo "$as_me:1802: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:1805: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1739: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:1808: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   for ac_declaration in \
    ''\
    '#include <stdlib.h>' \
@@ -1747,107 +1816,284 @@
    'extern "C" void exit (int);' \
    'void exit (int);'
 do
-  cat >conftest.$ac_ext <<_ACEOF
-#line 1751 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 1820 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 $ac_declaration
 int
-main ()
+main (void)
 {
 exit (42);
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1764: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:1833: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1767: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1770: \"$ac_try\"") >&5
+  echo "$as_me:1836: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:1839: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1773: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:1842: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 continue
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-  cat >conftest.$ac_ext <<_ACEOF
-#line 1783 "configure"
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 1852 "configure"
 #include "confdefs.h"
 $ac_declaration
 int
-main ()
+main (void)
 {
 exit (42);
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1795: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:1864: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1798: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1801: \"$ac_try\"") >&5
+  echo "$as_me:1867: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:1870: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1804: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:1873: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 done
 rm -rf conftest*
 if test -n "$ac_declaration"; then
   echo '#ifdef __cplusplus' >>confdefs.h
-  echo $ac_declaration      >>confdefs.h
+  echo "$ac_declaration"    >>confdefs.h
   echo '#endif'             >>confdefs.h
 fi
 
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5'
+ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
-ac_main_return=return
+ac_main_return="return"
 
 GCC_VERSION=none
 if test "$GCC" = yes ; then
-	echo "$as_me:1834: checking version of $CC" >&5
+	echo "$as_me:1903: checking version of $CC" >&5
 echo $ECHO_N "checking version of $CC... $ECHO_C" >&6
-	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[^)]*) //' -e 's/^.*(Debian[^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
+	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[^(]*([^)][^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
 	test -z "$GCC_VERSION" && GCC_VERSION=unknown
-	echo "$as_me:1838: result: $GCC_VERSION" >&5
+	echo "$as_me:1907: result: $GCC_VERSION" >&5
 echo "${ECHO_T}$GCC_VERSION" >&6
 fi
 
-echo "$as_me:1842: checking for $CC option to accept ANSI C" >&5
+INTEL_COMPILER=no
+
+if test "$GCC" = yes ; then
+	case "$host_os" in
+	(linux*|gnu*)
+		echo "$as_me:1916: checking if this is really Intel C compiler" >&5
+echo $ECHO_N "checking if this is really Intel C compiler... $ECHO_C" >&6
+		cf_save_CFLAGS="$CFLAGS"
+		CFLAGS="$CFLAGS -no-gcc"
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 1921 "configure"
+#include "confdefs.h"
+
+int
+main (void)
+{
+
+#ifdef __INTEL_COMPILER
+#else
+#error __INTEL_COMPILER is not defined
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:1938: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:1941: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:1944: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:1947: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  INTEL_COMPILER=yes
+cf_save_CFLAGS="$cf_save_CFLAGS -we147"
+
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+		CFLAGS="$cf_save_CFLAGS"
+		echo "$as_me:1958: result: $INTEL_COMPILER" >&5
+echo "${ECHO_T}$INTEL_COMPILER" >&6
+		;;
+	esac
+fi
+
+CLANG_COMPILER=no
+
+if test "$GCC" = yes ; then
+	echo "$as_me:1967: checking if this is really Clang C compiler" >&5
+echo $ECHO_N "checking if this is really Clang C compiler... $ECHO_C" >&6
+	cf_save_CFLAGS="$CFLAGS"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 1971 "configure"
+#include "confdefs.h"
+
+int
+main (void)
+{
+
+#ifdef __clang__
+#else
+#error __clang__ is not defined
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:1988: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:1991: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:1994: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:1997: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  CLANG_COMPILER=yes
+
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+	CFLAGS="$cf_save_CFLAGS"
+	echo "$as_me:2007: result: $CLANG_COMPILER" >&5
+echo "${ECHO_T}$CLANG_COMPILER" >&6
+fi
+
+CLANG_VERSION=none
+
+if test "x$CLANG_COMPILER" = "xyes" ; then
+	case "$CC" in
+	(c[1-9][0-9]|*/c[1-9][0-9])
+		{ echo "$as_me:2016: WARNING: replacing broken compiler alias $CC" >&5
+echo "$as_me: WARNING: replacing broken compiler alias $CC" >&2;}
+		CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`"
+		CC=clang
+		;;
+	esac
+
+	echo "$as_me:2023: checking version of $CC" >&5
+echo $ECHO_N "checking version of $CC... $ECHO_C" >&6
+	CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[^)]*) //' -e 's/^.*(Debian[^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
+	test -z "$CLANG_VERSION" && CLANG_VERSION=unknown
+	echo "$as_me:2027: result: $CLANG_VERSION" >&5
+echo "${ECHO_T}$CLANG_VERSION" >&6
+
+	for cf_clang_opt in \
+		-Qunused-arguments \
+		-Wno-error=implicit-function-declaration
+	do
+		echo "$as_me:2034: checking if option $cf_clang_opt works" >&5
+echo $ECHO_N "checking if option $cf_clang_opt works... $ECHO_C" >&6
+		cf_save_CFLAGS="$CFLAGS"
+		CFLAGS="$CFLAGS $cf_clang_opt"
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 2039 "configure"
+#include "confdefs.h"
+
+			#include <stdio.h>
+int
+main (void)
+{
+
+			printf("hello!\\n");
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:2053: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:2056: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:2059: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2062: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+
+			cf_clang_optok=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+
+			cf_clang_optok=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+		echo "$as_me:2073: result: $cf_clang_optok" >&5
+echo "${ECHO_T}$cf_clang_optok" >&6
+		CFLAGS="$cf_save_CFLAGS"
+		if test "$cf_clang_optok" = yes; then
+			test -n "$verbose" && echo "	adding option $cf_clang_opt" 1>&6
+
+echo "${as_me:-configure}:2079: testing adding option $cf_clang_opt ..." 1>&5
+
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_clang_opt"
+
+		fi
+	done
+fi
+
+echo "$as_me:2088: checking for $CC option to accept ANSI C" >&5
 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
 if test "${ac_cv_prog_cc_stdc+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_cv_prog_cc_stdc=no
 ac_save_CC=$CC
-cat >conftest.$ac_ext <<_ACEOF
-#line 1850 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 2096 "configure"
 #include "confdefs.h"
 #include <stdarg.h>
 #include <stdio.h>
@@ -1856,9 +2102,7 @@
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 struct buf { int x; };
 FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
+static char *e (char **p, int i)
 {
   return p[i];
 }
@@ -1878,7 +2122,7 @@
 int argc;
 char **argv;
 int
-main ()
+main (void)
 {
 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
   ;
@@ -1895,80 +2139,87 @@
 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
 do
   CC="$ac_save_CC $ac_arg"
-  rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1899: \"$ac_compile\"") >&5
+  rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:2143: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1902: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1905: \"$ac_try\"") >&5
+  echo "$as_me:2146: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:2149: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1908: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:2152: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_prog_cc_stdc=$ac_arg
 break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f conftest.$ac_objext
+rm -f "conftest.$ac_objext"
 done
-rm -f conftest.$ac_ext conftest.$ac_objext
+rm -f "conftest.$ac_ext" "conftest.$ac_objext"
 CC=$ac_save_CC
 
 fi
 
 case "x$ac_cv_prog_cc_stdc" in
   x|xno)
-    echo "$as_me:1925: result: none needed" >&5
+    echo "$as_me:2169: result: none needed" >&5
 echo "${ECHO_T}none needed" >&6 ;;
   *)
-    echo "$as_me:1928: result: $ac_cv_prog_cc_stdc" >&5
+    echo "$as_me:2172: result: $ac_cv_prog_cc_stdc" >&5
 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
     CC="$CC $ac_cv_prog_cc_stdc" ;;
 esac
 
 # This should have been defined by AC_PROG_CC
-: ${CC:=cc}
+: "${CC:=cc}"
 
-echo "$as_me:1936: checking \$CC variable" >&5
-echo $ECHO_N "checking \$CC variable... $ECHO_C" >&6
-case "$CC" in
-(*[\ \	]-[IUD]*)
-	echo "$as_me:1940: result: broken" >&5
+echo "$as_me:2180: checking \$CFLAGS variable" >&5
+echo $ECHO_N "checking \$CFLAGS variable... $ECHO_C" >&6
+case "x$CFLAGS" in
+(*-[IUD]*)
+	echo "$as_me:2184: result: broken" >&5
 echo "${ECHO_T}broken" >&6
-	{ echo "$as_me:1942: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&5
-echo "$as_me: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&2;}
-	# humor him...
-	cf_flags=`echo "$CC" | sed -e 's/^[^ 	]*[ 	]//'`
-	CC=`echo "$CC" | sed -e 's/[ 	].*//'`
+	{ echo "$as_me:2186: WARNING: your environment uses the CFLAGS variable to hold CPPFLAGS options" >&5
+echo "$as_me: WARNING: your environment uses the CFLAGS variable to hold CPPFLAGS options" >&2;}
+	cf_flags="$CFLAGS"
+	CFLAGS=
+	for cf_arg in $cf_flags
+	do
 
 cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
 cf_new_extra_cppflags=
 
-for cf_add_cflags in $cf_flags
+for cf_add_cflags in $cf_arg
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -1977,7 +2228,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -1987,19 +2238,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -2010,33 +2269,330 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
+	done
 	;;
 (*)
-	echo "$as_me:2028: result: ok" >&5
+	echo "$as_me:2294: result: ok" >&5
 echo "${ECHO_T}ok" >&6
 	;;
 esac
 
+echo "$as_me:2299: checking \$CC variable" >&5
+echo $ECHO_N "checking \$CC variable... $ECHO_C" >&6
+case "$CC" in
+(*[\ \	]-*)
+	echo "$as_me:2303: result: broken" >&5
+echo "${ECHO_T}broken" >&6
+	{ echo "$as_me:2305: WARNING: your environment uses the CC variable to hold CFLAGS/CPPFLAGS options" >&5
+echo "$as_me: WARNING: your environment uses the CC variable to hold CFLAGS/CPPFLAGS options" >&2;}
+	# humor him...
+	cf_prog=`echo "$CC" | sed -e 's/	/ /g' -e 's/[ ]* / /g' -e 's/[ ]*[ ]-[^ ].*//'`
+	cf_flags=`echo "$CC" | sed -e "s%^$cf_prog%%"`
+	CC="$cf_prog"
+	for cf_arg in $cf_flags
+	do
+		case "x$cf_arg" in
+		(x-[IUDfgOW]*)
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_arg
+do
+case "$cf_fix_cppflags" in
+(no)
+	case "$cf_add_cflags" in
+	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+		case "$cf_add_cflags" in
+		(-D*)
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+				&& test -z "${cf_tst_cflags}" \
+				&& cf_fix_cppflags=yes
+
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		(*$cf_add_cflags)
+			;;
+		(*)
+			case "$cf_add_cflags" in
+			(-D*)
+				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
+		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`
+
+				;;
+			esac
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
+			;;
+		esac
+		;;
+	(*)
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
+		;;
+	esac
+	;;
+(yes)
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
+
+	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+		&& test -z "${cf_tst_cflags}" \
+		&& cf_fix_cppflags=no
+	;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+			;;
+		(*)
+			CC="$CC $cf_arg"
+			;;
+		esac
+	done
+	test -n "$verbose" && echo "	resulting CC: '$CC'" 1>&6
+
+echo "${as_me:-configure}:2422: testing resulting CC: '$CC' ..." 1>&5
+
+	test -n "$verbose" && echo "	resulting CFLAGS: '$CFLAGS'" 1>&6
+
+echo "${as_me:-configure}:2426: testing resulting CFLAGS: '$CFLAGS' ..." 1>&5
+
+	test -n "$verbose" && echo "	resulting CPPFLAGS: '$CPPFLAGS'" 1>&6
+
+echo "${as_me:-configure}:2430: testing resulting CPPFLAGS: '$CPPFLAGS' ..." 1>&5
+
+	;;
+(*)
+	echo "$as_me:2434: result: ok" >&5
+echo "${ECHO_T}ok" >&6
+	;;
+esac
+
+echo "$as_me:2439: checking for inline" >&5
+echo $ECHO_N "checking for inline... $ECHO_C" >&6
+if test "${ac_cv_c_inline+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 2447 "configure"
+#include "confdefs.h"
+#ifndef __cplusplus
+static $ac_kw int static_foo (void) {return 0; }
+$ac_kw int foo (void) {return 0; }
+#endif
+
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:2456: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2459: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:2462: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2465: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_c_inline=$ac_kw; break
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+done
+
+fi
+echo "$as_me:2476: result: $ac_cv_c_inline" >&5
+echo "${ECHO_T}$ac_cv_c_inline" >&6
+case $ac_cv_c_inline in
+  inline | yes) ;;
+  no)
+cat >>confdefs.h <<\EOF
+#define inline
+EOF
+ ;;
+  *)  cat >>confdefs.h <<EOF
+#define inline $ac_cv_c_inline
+EOF
+ ;;
+esac
+
+for ac_prog in ggrep grep
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:2495: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_GREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$GREP"; then
+  ac_cv_prog_GREP="$GREP" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_GREP="$ac_prog"
+echo "$as_me:2510: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+GREP=$ac_cv_prog_GREP
+if test -n "$GREP"; then
+  echo "$as_me:2518: result: $GREP" >&5
+echo "${ECHO_T}$GREP" >&6
+else
+  echo "$as_me:2521: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$GREP" && break
+done
+test -n "$GREP" || GREP=": "
+
+echo "$as_me:2529: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6
+if test "${ac_cv_path_EGREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     for ac_prog in gegrep egrep
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:2541: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_EGREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $EGREP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_EGREP="$EGREP" # Let the user override the test with a path.
+  ;;
+  *)
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  if $as_executable_p "$ac_dir/$ac_word"; then
+   ac_cv_path_EGREP="$ac_dir/$ac_word"
+   echo "$as_me:2558: found $ac_dir/$ac_word" >&5
+   break
+fi
+done
+
+  ;;
+esac
+fi
+EGREP=$ac_cv_path_EGREP
+
+if test -n "$EGREP"; then
+  echo "$as_me:2569: result: $EGREP" >&5
+echo "${ECHO_T}$EGREP" >&6
+else
+  echo "$as_me:2572: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$EGREP" && break
+done
+test -n "$EGREP" || EGREP=": "
+
+     test "x$ac_cv_path_EGREP" = "x:" && { { echo "$as_me:2580: error: cannot find workable egrep" >&5
+echo "$as_me: error: cannot find workable egrep" >&2;}
+   { (exit 1); exit 1; }; }
+   fi
+fi
+echo "$as_me:2585: result: $ac_cv_path_EGREP" >&5
+echo "${ECHO_T}$ac_cv_path_EGREP" >&6
+ EGREP="$ac_cv_path_EGREP"
+
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5'
+ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
-ac_main_return=return
-echo "$as_me:2039: checking how to run the C preprocessor" >&5
+ac_main_return="return"
+echo "$as_me:2595: checking how to run the C preprocessor" >&5
 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
@@ -2056,20 +2612,20 @@
   # with a fresh cross-compiler works.
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 2060 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 2616 "configure"
 #include "confdefs.h"
 #include <assert.h>
                      Syntax error
 _ACEOF
-if { (eval echo "$as_me:2065: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (eval echo "$as_me:2621: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2071: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
+  echo "$as_me:2627: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
   else
@@ -2082,27 +2638,27 @@
   :
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat "conftest.$ac_ext" >&5
   # Broken: fails on valid input.
 continue
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 
   # OK, works on sane cases.  Now check whether non-existent headers
   # can be detected and how.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 2094 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 2650 "configure"
 #include "confdefs.h"
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:2098: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (eval echo "$as_me:2654: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2104: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
+  echo "$as_me:2660: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
   else
@@ -2116,16 +2672,16 @@
 continue
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat "conftest.$ac_ext" >&5
   # Passes both tests.
 ac_preproc_ok=:
 break
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 if $ac_preproc_ok; then
   break
 fi
@@ -2138,7 +2694,7 @@
 else
   ac_cv_prog_CPP=$CPP
 fi
-echo "$as_me:2141: result: $CPP" >&5
+echo "$as_me:2697: result: $CPP" >&5
 echo "${ECHO_T}$CPP" >&6
 ac_preproc_ok=false
 for ac_c_preproc_warn_flag in '' yes
@@ -2147,20 +2703,20 @@
   # with a fresh cross-compiler works.
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 2151 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 2707 "configure"
 #include "confdefs.h"
 #include <assert.h>
                      Syntax error
 _ACEOF
-if { (eval echo "$as_me:2156: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (eval echo "$as_me:2712: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2162: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
+  echo "$as_me:2718: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
   else
@@ -2173,27 +2729,27 @@
   :
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat "conftest.$ac_ext" >&5
   # Broken: fails on valid input.
 continue
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 
   # OK, works on sane cases.  Now check whether non-existent headers
   # can be detected and how.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 2185 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 2741 "configure"
 #include "confdefs.h"
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:2189: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (eval echo "$as_me:2745: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2195: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
+  echo "$as_me:2751: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
   else
@@ -2207,36 +2763,36 @@
 continue
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat "conftest.$ac_ext" >&5
   # Passes both tests.
 ac_preproc_ok=:
 break
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 if $ac_preproc_ok; then
   :
 else
-  { { echo "$as_me:2223: error: C preprocessor \"$CPP\" fails sanity check" >&5
+  { { echo "$as_me:2779: error: C preprocessor \"$CPP\" fails sanity check" >&5
 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5'
+ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
-ac_main_return=return
+ac_main_return="return"
 
 for ac_prog in mawk gawk nawk awk
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:2239: checking for $ac_word" >&5
+echo "$as_me:2795: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_AWK+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2251,7 +2807,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_AWK="$ac_prog"
-echo "$as_me:2254: found $ac_dir/$ac_word" >&5
+echo "$as_me:2810: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -2259,10 +2815,10 @@
 fi
 AWK=$ac_cv_prog_AWK
 if test -n "$AWK"; then
-  echo "$as_me:2262: result: $AWK" >&5
+  echo "$as_me:2818: result: $AWK" >&5
 echo "${ECHO_T}$AWK" >&6
 else
-  echo "$as_me:2265: result: no" >&5
+  echo "$as_me:2821: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -2281,7 +2837,7 @@
 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
-echo "$as_me:2284: checking for a BSD compatible install" >&5
+echo "$as_me:2840: checking for a BSD compatible install" >&5
 echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6
 if test -z "$INSTALL"; then
 if test "${ac_cv_path_install+set}" = set; then
@@ -2330,7 +2886,7 @@
     INSTALL=$ac_install_sh
   fi
 fi
-echo "$as_me:2333: result: $INSTALL" >&5
+echo "$as_me:2889: result: $INSTALL" >&5
 echo "${ECHO_T}$INSTALL" >&6
 
 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
@@ -2345,17 +2901,165 @@
 (/*)
 	;;
 (*)
-	cf_dir=`echo $INSTALL | sed -e 's%/[^/]*$%%'`
+	cf_dir=`echo "$INSTALL" | sed -e 's%/[^/]*$%%'`
 	test -z "$cf_dir" && cf_dir=.
-	INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
+	INSTALL="`cd \"$cf_dir\" && pwd`"/"`echo "$INSTALL" | sed -e 's%^.*/%%'`"
 	;;
 esac
 
-for ac_prog in tdlint lint alint splint lclint
+echo "$as_me:2910: checking if you want to install stripped executables" >&5
+echo $ECHO_N "checking if you want to install stripped executables... $ECHO_C" >&6
+
+# Check whether --enable-stripping or --disable-stripping was given.
+if test "${enable_stripping+set}" = set; then
+  enableval="$enable_stripping"
+  test "$enableval" != no && enableval=yes
+	if test "$enableval" != "yes" ; then
+    enable_stripping=no
+	else
+		enable_stripping=yes
+	fi
+else
+  enableval=yes
+	enable_stripping=yes
+
+fi;
+echo "$as_me:2927: result: $enable_stripping" >&5
+echo "${ECHO_T}$enable_stripping" >&6
+
+if test "$enable_stripping" = yes
+then
+	INSTALL_OPT_S="-s"
+else
+	INSTALL_OPT_S=
+fi
+
+: "${INSTALL:=install}"
+echo "$as_me:2938: checking if install accepts -p option" >&5
+echo $ECHO_N "checking if install accepts -p option... $ECHO_C" >&6
+if test "${cf_cv_install_p+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+	rm -rf ./conftest*
+	date >conftest.in
+	mkdir conftest.out
+	sleep 3
+	if $INSTALL -p conftest.in conftest.out 2>/dev/null
+	then
+		if test -f conftest.out/conftest.in
+		then
+			test conftest.in -nt conftest.out/conftest.in 2>conftest.err && \
+			test conftest.out/conftest.in -nt conftest.in 2>conftest.err
+			if test -s conftest.err
+			then
+				cf_cv_install_p=no
+			else
+				cf_cv_install_p=yes
+			fi
+		else
+			cf_cv_install_p=no
+		fi
+	else
+		cf_cv_install_p=no
+	fi
+	rm -rf ./conftest*
+
+fi
+echo "$as_me:2969: result: $cf_cv_install_p" >&5
+echo "${ECHO_T}$cf_cv_install_p" >&6
+
+echo "$as_me:2972: checking if install needs to be told about ownership" >&5
+echo $ECHO_N "checking if install needs to be told about ownership... $ECHO_C" >&6
+case `$ac_config_guess` in
+(*minix)
+	with_install_o=yes
+	;;
+(*)
+	with_install_o=no
+	;;
+esac
+
+echo "$as_me:2983: result: $with_install_o" >&5
+echo "${ECHO_T}$with_install_o" >&6
+if test "x$with_install_o" = xyes
+then
+	INSTALL_OPT_O="`id root|sed -e 's/uid=[0-9]*(/ -o /' -e 's/gid=[0-9]*(/ -g /' -e 's/ [^=[:space:]][^=[:space:]]*=.*/ /' -e 's/)//g'`"
+else
+	INSTALL_OPT_O=
+fi
+
+if test -n "$INSTALL_OPT_S"
+then
+	echo "$as_me:2994: checking if you want to specify strip-program" >&5
+echo $ECHO_N "checking if you want to specify strip-program... $ECHO_C" >&6
+
+# Check whether --with-strip-program or --without-strip-program was given.
+if test "${with_strip_program+set}" = set; then
+  withval="$with_strip_program"
+  with_strip_program=$withval
+else
+  with_strip_program=no
+fi;
+	echo "$as_me:3004: result: $with_strip_program" >&5
+echo "${ECHO_T}$with_strip_program" >&6
+	if test "$with_strip_program" != no
+	then
+		echo "$as_me:3008: checking if strip-program is supported with this installer" >&5
+echo $ECHO_N "checking if strip-program is supported with this installer... $ECHO_C" >&6
+		cf_install_program=`echo "$INSTALL" | sed -e 's%[ ]*[ ]-.%%'`
+		check_install_strip=no
+		if test -f "$cf_install_program"
+		then
+			check_install_version=`"$cf_install_program" --version 2>/dev/null | head -n 1 | grep coreutils`
+			if test -n "$check_install_version"
+			then
+				check_install_strip="option"
+			else
+				for check_strip_variable in STRIPBIN STRIP
+				do
+					if strings "$cf_install_program" | grep "^$check_strip_variable$" >/dev/null
+					then
+						check_install_strip="environ"
+						break
+					fi
+				done
+			fi
+		fi
+		echo "$as_me:3029: result: $check_install_strip" >&5
+echo "${ECHO_T}$check_install_strip" >&6
+		case "$check_install_strip" in
+		(no)
+			{ echo "$as_me:3033: WARNING: $cf_install_program does not support strip program option" >&5
+echo "$as_me: WARNING: $cf_install_program does not support strip program option" >&2;}
+			with_strip_program=no
+			;;
+		(environ)
+			cat >install.tmp <<-CF_EOF
+			#! $SHELL
+			STRIPBIN="$with_strip_program" \\
+			STRIP="$with_strip_program" \\
+			$INSTALL "$@"
+			CF_EOF
+			INSTALL="`pwd`/install.tmp"
+			chmod +x "$INSTALL"
+			test -n "$verbose" && echo "	created $INSTALL" 1>&6
+
+echo "${as_me:-configure}:3048: testing created $INSTALL ..." 1>&5
+
+			;;
+		(option)
+			INSTALL_OPT_S="$INSTALL_OPT_S --strip-program=\"$with_strip_program\""
+			;;
+		esac
+	fi
+fi
+
+for ac_prog in lint cppcheck splint
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:2358: checking for $ac_word" >&5
+echo "$as_me:3062: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_LINT+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2370,7 +3074,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_LINT="$ac_prog"
-echo "$as_me:2373: found $ac_dir/$ac_word" >&5
+echo "$as_me:3077: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -2378,25 +3082,93 @@
 fi
 LINT=$ac_cv_prog_LINT
 if test -n "$LINT"; then
-  echo "$as_me:2381: result: $LINT" >&5
+  echo "$as_me:3085: result: $LINT" >&5
 echo "${ECHO_T}$LINT" >&6
 else
-  echo "$as_me:2384: result: no" >&5
+  echo "$as_me:3088: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
   test -n "$LINT" && break
 done
 
-echo "$as_me:2391: checking if filesystem supports mixed-case filenames" >&5
+case "x$LINT" in
+(xcppcheck|x*/cppcheck)
+	test -z "$LINT_OPTS" && LINT_OPTS="--enable=all"
+	;;
+esac
+
+echo "$as_me:3101: checking for \".PHONY\" make-support" >&5
+echo $ECHO_N "checking for \".PHONY\" make-support... $ECHO_C" >&6
+if test "${cf_cv_make_PHONY+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+	rm -rf conftest*
+	(
+		mkdir conftest || exit 1
+		cd conftest
+		cat >makefile <<'CF_EOF'
+.PHONY: always
+DATA=0
+always:	always.out
+	@echo "** making $@ $(DATA)"
+once: once.out
+	@echo "** making $@ $(DATA)"
+always.out:
+	@echo "** making $@ $(DATA)"
+	echo $(DATA) > $@
+once.out:
+	@echo "** making $@ $(DATA)"
+	echo $(DATA) > $@
+CF_EOF
+		for cf_data in 1 2 3
+		do
+			${MAKE:-make} always DATA=$cf_data
+			${MAKE:-make} once   DATA=$cf_data
+			${MAKE:-make} -t always once
+			if test -f always ; then
+				echo "no (case 1)" > ../conftest.tmp
+			elif test ! -f always.out ; then
+				echo "no (case 2)" > ../conftest.tmp
+			elif test ! -f once.out ; then
+				echo "no (case 3)" > ../conftest.tmp
+			elif ! cmp -s always.out once.out ; then
+				echo "no (case 4)" > ../conftest.tmp
+				diff always.out once.out
+			else
+				cf_check="`cat always.out`"
+				if test "x$cf_check" != "x$cf_data" ; then
+					echo "no (case 5)" > ../conftest.tmp
+				else
+					echo yes > ../conftest.tmp
+					rm -f ./*.out
+					continue
+				fi
+			fi
+			break
+		done
+	) >&5 2>&1
+	cf_cv_make_PHONY="`cat conftest.tmp`"
+	rm -rf conftest*
+
+fi
+echo "$as_me:3156: result: $cf_cv_make_PHONY" >&5
+echo "${ECHO_T}$cf_cv_make_PHONY" >&6
+MAKE_NO_PHONY="#"
+MAKE_PHONY="#"
+test "x$cf_cv_make_PHONY" = xyes && MAKE_PHONY=
+test "x$cf_cv_make_PHONY" != xyes && MAKE_NO_PHONY=
+
+echo "$as_me:3163: checking if filesystem supports mixed-case filenames" >&5
 echo $ECHO_N "checking if filesystem supports mixed-case filenames... $ECHO_C" >&6
 if test "${cf_cv_mixedcase+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 if test "$cross_compiling" = yes ; then
-	case $target_alias in
-	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*)
+	case "$target_alias" in
+	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*|darwin*)
 		cf_cv_mixedcase=no
 		;;
 	(*)
@@ -2415,7 +3187,7 @@
 fi
 
 fi
-echo "$as_me:2418: result: $cf_cv_mixedcase" >&5
+echo "$as_me:3190: result: $cf_cv_mixedcase" >&5
 echo "${ECHO_T}$cf_cv_mixedcase" >&6
 test "$cf_cv_mixedcase" = yes &&
 cat >>confdefs.h <<\EOF
@@ -2426,7 +3198,7 @@
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:2429: checking for $ac_word" >&5
+echo "$as_me:3201: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CTAGS+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2441,7 +3213,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_CTAGS="$ac_prog"
-echo "$as_me:2444: found $ac_dir/$ac_word" >&5
+echo "$as_me:3216: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -2449,10 +3221,10 @@
 fi
 CTAGS=$ac_cv_prog_CTAGS
 if test -n "$CTAGS"; then
-  echo "$as_me:2452: result: $CTAGS" >&5
+  echo "$as_me:3224: result: $CTAGS" >&5
 echo "${ECHO_T}$CTAGS" >&6
 else
-  echo "$as_me:2455: result: no" >&5
+  echo "$as_me:3227: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -2463,7 +3235,7 @@
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:2466: checking for $ac_word" >&5
+echo "$as_me:3238: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ETAGS+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2478,7 +3250,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ETAGS="$ac_prog"
-echo "$as_me:2481: found $ac_dir/$ac_word" >&5
+echo "$as_me:3253: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -2486,10 +3258,10 @@
 fi
 ETAGS=$ac_cv_prog_ETAGS
 if test -n "$ETAGS"; then
-  echo "$as_me:2489: result: $ETAGS" >&5
+  echo "$as_me:3261: result: $ETAGS" >&5
 echo "${ECHO_T}$ETAGS" >&6
 else
-  echo "$as_me:2492: result: no" >&5
+  echo "$as_me:3264: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -2498,7 +3270,7 @@
 
 # Extract the first word of "${CTAGS:-ctags}", so it can be a program name with args.
 set dummy ${CTAGS:-ctags}; ac_word=$2
-echo "$as_me:2501: checking for $ac_word" >&5
+echo "$as_me:3273: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_MAKE_LOWER_TAGS+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2513,7 +3285,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_MAKE_LOWER_TAGS="yes"
-echo "$as_me:2516: found $ac_dir/$ac_word" >&5
+echo "$as_me:3288: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -2522,17 +3294,17 @@
 fi
 MAKE_LOWER_TAGS=$ac_cv_prog_MAKE_LOWER_TAGS
 if test -n "$MAKE_LOWER_TAGS"; then
-  echo "$as_me:2525: result: $MAKE_LOWER_TAGS" >&5
+  echo "$as_me:3297: result: $MAKE_LOWER_TAGS" >&5
 echo "${ECHO_T}$MAKE_LOWER_TAGS" >&6
 else
-  echo "$as_me:2528: result: no" >&5
+  echo "$as_me:3300: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
 if test "$cf_cv_mixedcase" = yes ; then
 	# Extract the first word of "${ETAGS:-etags}", so it can be a program name with args.
 set dummy ${ETAGS:-etags}; ac_word=$2
-echo "$as_me:2535: checking for $ac_word" >&5
+echo "$as_me:3307: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_MAKE_UPPER_TAGS+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2547,7 +3319,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_MAKE_UPPER_TAGS="yes"
-echo "$as_me:2550: found $ac_dir/$ac_word" >&5
+echo "$as_me:3322: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -2556,10 +3328,10 @@
 fi
 MAKE_UPPER_TAGS=$ac_cv_prog_MAKE_UPPER_TAGS
 if test -n "$MAKE_UPPER_TAGS"; then
-  echo "$as_me:2559: result: $MAKE_UPPER_TAGS" >&5
+  echo "$as_me:3331: result: $MAKE_UPPER_TAGS" >&5
 echo "${ECHO_T}$MAKE_UPPER_TAGS" >&6
 else
-  echo "$as_me:2562: result: no" >&5
+  echo "$as_me:3334: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -2579,52 +3351,117 @@
 	MAKE_LOWER_TAGS="#"
 fi
 
-echo "$as_me:2582: checking if -lm needed for math functions" >&5
+echo "$as_me:3354: checking if -lm needed for math functions" >&5
 echo $ECHO_N "checking if -lm needed for math functions... $ECHO_C" >&6
 if test "${cf_cv_need_libm+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-	cat >conftest.$ac_ext <<_ACEOF
-#line 2589 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 3361 "configure"
 #include "confdefs.h"
 
-	#include <stdio.h>
-	#include <math.h>
+		#include <stdio.h>
+		#include <stdlib.h>
+		#include <math.h>
 
 int
-main ()
+main (void)
 {
-double x = rand(); printf("result = %g\n", pow(sin(x),x))
+double x = rand(); printf("result = %g\\n", pow(sin(x),x))
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:2604: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:3377: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:2607: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:2610: \"$ac_try\"") >&5
+  echo "$as_me:3380: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:3383: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2613: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:3386: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_need_libm=no
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_need_libm=yes
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:2623: result: $cf_cv_need_libm" >&5
+echo "$as_me:3396: result: $cf_cv_need_libm" >&5
 echo "${ECHO_T}$cf_cv_need_libm" >&6
+
 if test "$cf_cv_need_libm" = yes
 then
-MATH_LIB=-lm
+
+	cf_save_LIBS="$LIBS"
+	LIBS="$LIBS -lm"
+	echo "$as_me:3404: checking if -lm is available for math functions" >&5
+echo $ECHO_N "checking if -lm is available for math functions... $ECHO_C" >&6
+if test "${cf_cv_have_libm+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 3411 "configure"
+#include "confdefs.h"
+
+		#include <stdio.h>
+		#include <stdlib.h>
+		#include <math.h>
+
+int
+main (void)
+{
+double x = rand(); printf("result = %g\\n", pow(sin(x),x))
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:3427: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3430: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:3433: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3436: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_have_libm=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_have_libm=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+fi
+echo "$as_me:3446: result: $cf_cv_have_libm" >&5
+echo "${ECHO_T}$cf_cv_have_libm" >&6
+	LIBS="$cf_save_LIBS"
+
+	if test "$cf_cv_have_libm" = yes
+	then
+		MATH_LIB=-lm
+	fi
+else
+	cf_cv_have_libm=yes
+fi
+
+if test "$cf_cv_have_libm" = yes
+then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_MATH_FUNCS 1
+EOF
+
 fi
 
 top_builddir=`pwd`
@@ -2661,7 +3498,151 @@
 cf_cv_screen=curses
 cf_cv_libtype=
 
-if test "$GCC" = yes
+echo "$as_me:3501: checking for fgrep" >&5
+echo $ECHO_N "checking for fgrep... $ECHO_C" >&6
+if test "${ac_cv_path_FGREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
+   then ac_cv_path_FGREP="$GREP -F"
+   else
+     for ac_prog in gfgrep fgrep
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:3513: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_FGREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $FGREP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_FGREP="$FGREP" # Let the user override the test with a path.
+  ;;
+  *)
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  if $as_executable_p "$ac_dir/$ac_word"; then
+   ac_cv_path_FGREP="$ac_dir/$ac_word"
+   echo "$as_me:3530: found $ac_dir/$ac_word" >&5
+   break
+fi
+done
+
+  ;;
+esac
+fi
+FGREP=$ac_cv_path_FGREP
+
+if test -n "$FGREP"; then
+  echo "$as_me:3541: result: $FGREP" >&5
+echo "${ECHO_T}$FGREP" >&6
+else
+  echo "$as_me:3544: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$FGREP" && break
+done
+test -n "$FGREP" || FGREP=": "
+
+     test "x$ac_cv_path_FGREP" = "x:" && { { echo "$as_me:3552: error: cannot find workable fgrep" >&5
+echo "$as_me: error: cannot find workable fgrep" >&2;}
+   { (exit 1); exit 1; }; }
+   fi
+fi
+echo "$as_me:3557: result: $ac_cv_path_FGREP" >&5
+echo "${ECHO_T}$ac_cv_path_FGREP" >&6
+ FGREP="$ac_cv_path_FGREP"
+
+echo "$as_me:3561: checking if you want to use C11 _Noreturn feature" >&5
+echo $ECHO_N "checking if you want to use C11 _Noreturn feature... $ECHO_C" >&6
+
+# Check whether --enable-stdnoreturn or --disable-stdnoreturn was given.
+if test "${enable_stdnoreturn+set}" = set; then
+  enableval="$enable_stdnoreturn"
+  test "$enableval" != yes && enableval=no
+	if test "$enableval" != "no" ; then
+    enable_stdnoreturn=yes
+	else
+		enable_stdnoreturn=no
+	fi
+else
+  enableval=no
+	enable_stdnoreturn=no
+
+fi;
+echo "$as_me:3578: result: $enable_stdnoreturn" >&5
+echo "${ECHO_T}$enable_stdnoreturn" >&6
+
+if test $enable_stdnoreturn = yes; then
+echo "$as_me:3582: checking for C11 _Noreturn feature" >&5
+echo $ECHO_N "checking for C11 _Noreturn feature... $ECHO_C" >&6
+if test "${cf_cv_c11_noreturn+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 3588 "configure"
+#include "confdefs.h"
+
+$ac_includes_default
+#include <stdnoreturn.h>
+static _Noreturn void giveup(void) { exit(0); }
+
+int
+main (void)
+{
+if (feof(stdin)) giveup()
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:3604: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:3607: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:3610: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3613: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_c11_noreturn=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_c11_noreturn=no
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+
+fi
+echo "$as_me:3624: result: $cf_cv_c11_noreturn" >&5
+echo "${ECHO_T}$cf_cv_c11_noreturn" >&6
+else
+	cf_cv_c11_noreturn=no,
+fi
+
+if test "$cf_cv_c11_noreturn" = yes; then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_STDNORETURN_H 1
+EOF
+
+cat >>confdefs.h <<EOF
+#define STDC_NORETURN _Noreturn
+EOF
+
+	HAVE_STDNORETURN_H=1
+else
+	HAVE_STDNORETURN_H=0
+fi
+
+if test "$GCC" = yes || test "$GXX" = yes
 then
 cat > conftest.i <<EOF
 #ifndef GCC_PRINTF
@@ -2679,10 +3660,11 @@
 EOF
 if test "$GCC" = yes
 then
-	{ echo "$as_me:2682: checking for $CC __attribute__ directives..." >&5
+	{ echo "$as_me:3663: checking for $CC __attribute__ directives..." >&5
 echo "$as_me: checking for $CC __attribute__ directives..." >&6;}
-cat > conftest.$ac_ext <<EOF
-#line 2685 "${as_me:-configure}"
+cat > "conftest.$ac_ext" <<EOF
+#line 3666 "${as_me:-configure}"
+#include <stdio.h>
 #include "confdefs.h"
 #include "conftest.h"
 #include "conftest.i"
@@ -2697,9 +3679,9 @@
 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
 #endif
 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
-extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
-extern void foo(void) GCC_NORETURN;
-int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; }
+extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2);
+extern GCC_NORETURN void foo(void);
+int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
 EOF
 	cf_printf_attribute=no
 	cf_scanf_attribute=no
@@ -2711,7 +3693,7 @@
 		cf_directive="__attribute__(($cf_attribute))"
 		echo "checking for $CC $cf_directive" 1>&5
 
-		case $cf_attribute in
+		case "$cf_attribute" in
 		(printf)
 			cf_printf_attribute=yes
 			cat >conftest.h <<EOF
@@ -2731,15 +3713,15 @@
 			;;
 		esac
 
-		if { (eval echo "$as_me:2734: \"$ac_compile\"") >&5
+		if { (eval echo "$as_me:3716: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2737: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-			test -n "$verbose" && echo "$as_me:2739: result: ... $cf_attribute" >&5
+  echo "$as_me:3719: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; then
+			test -n "$verbose" && echo "$as_me:3721: result: ... $cf_attribute" >&5
 echo "${ECHO_T}... $cf_attribute" >&6
 			cat conftest.h >>confdefs.h
-			case $cf_attribute in
+			case "$cf_attribute" in
 			(noreturn)
 
 cat >>confdefs.h <<EOF
@@ -2790,22 +3772,351 @@
 		fi
 	done
 else
-	fgrep define conftest.i >>confdefs.h
+	${FGREP-fgrep} define conftest.i >>confdefs.h
 fi
-rm -rf conftest*
+rm -rf ./conftest*
 fi
 
-cf_XOPEN_SOURCE=500
+echo "$as_me:3780: checking if you want to work around bogus compiler/loader warnings" >&5
+echo $ECHO_N "checking if you want to work around bogus compiler/loader warnings... $ECHO_C" >&6
+
+# Check whether --enable-string-hacks or --disable-string-hacks was given.
+if test "${enable_string_hacks+set}" = set; then
+  enableval="$enable_string_hacks"
+  enable_string_hacks=$enableval
+else
+  enable_string_hacks=no
+fi;
+echo "$as_me:3790: result: $enable_string_hacks" >&5
+echo "${ECHO_T}$enable_string_hacks" >&6
+
+if test "x$enable_string_hacks" = "xyes"; then
+
+cat >>confdefs.h <<\EOF
+#define USE_STRING_HACKS 1
+EOF
+
+	{ echo "$as_me:3799: WARNING: enabling string-hacks to work around bogus compiler/loader warnings" >&5
+echo "$as_me: WARNING: enabling string-hacks to work around bogus compiler/loader warnings" >&2;}
+	echo "$as_me:3801: checking for strlcat" >&5
+echo $ECHO_N "checking for strlcat... $ECHO_C" >&6
+if test "${ac_cv_func_strlcat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 3807 "configure"
+#include "confdefs.h"
+#define strlcat autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef strlcat
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char strlcat (void);
+
+int
+main (void)
+{
+
+/* The GNU C library defines stubs for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_strlcat) || defined (__stub___strlcat)
+#error found stub for strlcat
+#endif
+
+	return strlcat ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:3838: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3841: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:3844: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3847: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_func_strlcat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_func_strlcat=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+fi
+echo "$as_me:3857: result: $ac_cv_func_strlcat" >&5
+echo "${ECHO_T}$ac_cv_func_strlcat" >&6
+if test "$ac_cv_func_strlcat" = yes; then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_STRLCAT 1
+EOF
+
+else
+
+		echo "$as_me:3867: checking for strlcat in -lbsd" >&5
+echo $ECHO_N "checking for strlcat in -lbsd... $ECHO_C" >&6
+if test "${ac_cv_lib_bsd_strlcat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lbsd  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 3875 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char strlcat (void);
+int
+main (void)
+{
+strlcat ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:3894: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3897: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:3900: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3903: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_lib_bsd_strlcat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_lib_bsd_strlcat=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:3914: result: $ac_cv_lib_bsd_strlcat" >&5
+echo "${ECHO_T}$ac_cv_lib_bsd_strlcat" >&6
+if test "$ac_cv_lib_bsd_strlcat" = yes; then
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -lbsd; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
+			cf_add_1lib=
+			break
+		fi
+	done
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
+done
+LIBS="$cf_add_libs"
+
+for ac_header in bsd/string.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:3937: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 3943 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:3947: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:3953: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat "conftest.$ac_ext" >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err "conftest.$ac_ext"
+fi
+echo "$as_me:3972: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+cat >>confdefs.h <<\EOF
+#define HAVE_STRLCAT 1
+EOF
+
+fi
+
+fi
+
+for ac_func in strlcpy snprintf
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:3993: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 3999 "configure"
+#include "confdefs.h"
+#define $ac_func autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef $ac_func
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func (void);
+
+int
+main (void)
+{
+
+/* The GNU C library defines stubs for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+#error found stub for $ac_func
+#endif
+
+	return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:4030: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4033: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:4036: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4039: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+eval "$as_ac_var=no"
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+fi
+echo "$as_me:4049: result: `eval echo '${'"$as_ac_var"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_var"'}'`" >&6
+if test "`eval echo '${'"$as_ac_var"'}'`" = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+fi
+
+echo "$as_me:4061: checking if the POSIX test-macros are already defined" >&5
+echo $ECHO_N "checking if the POSIX test-macros are already defined... $ECHO_C" >&6
+if test "${cf_cv_posix_visible+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 4068 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+int
+main (void)
+{
+
+#if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
+	&& defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
+	&& defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
+	&& defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
+#error conflicting symbols found
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:4087: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4090: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:4093: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4096: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_posix_visible=no
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_posix_visible=yes
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+
+fi
+echo "$as_me:4107: result: $cf_cv_posix_visible" >&5
+echo "${ECHO_T}$cf_cv_posix_visible" >&6
+
+if test "$cf_cv_posix_visible" = no; then
+
+cf_XOPEN_SOURCE=600
 cf_POSIX_C_SOURCE=199506L
 cf_xopen_source=
 
-case $host_os in
+case "$host_os" in
 (aix[4-7]*)
 	cf_xopen_source="-D_ALL_SOURCE"
 	;;
-(cygwin|msys)
-	cf_XOPEN_SOURCE=600
-	;;
 (darwin[0-8].*)
 	cf_xopen_source="-D_APPLE_C_SOURCE"
 	;;
@@ -2813,7 +4124,7 @@
 	cf_xopen_source="-D_DARWIN_C_SOURCE"
 	cf_XOPEN_SOURCE=
 	;;
-(freebsd*|dragonfly*)
+(freebsd*|dragonfly*|midnightbsd*)
 	# 5.x headers associate
 	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
 	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
@@ -2831,90 +4142,515 @@
 	cf_xopen_source="-D_SGI_SOURCE"
 	cf_XOPEN_SOURCE=
 	;;
-(linux*|gnu*|mint*|k*bsd*-gnu)
+(linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys|mingw*|linux*uclibc)
 
-echo "$as_me:2836: checking if we must define _GNU_SOURCE" >&5
+cf_gnu_xopen_source=$cf_XOPEN_SOURCE
+
+echo "$as_me:4149: checking if this is the GNU C library" >&5
+echo $ECHO_N "checking if this is the GNU C library... $ECHO_C" >&6
+if test "${cf_cv_gnu_library+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 4156 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main (void)
+{
+
+	#if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
+		return 0;
+	#elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
+		return 0;
+	#else
+	#	error not GNU C library
+	#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:4175: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4178: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:4181: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4184: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_gnu_library=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_gnu_library=no
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+
+fi
+echo "$as_me:4195: result: $cf_cv_gnu_library" >&5
+echo "${ECHO_T}$cf_cv_gnu_library" >&6
+
+if test x$cf_cv_gnu_library = xyes; then
+
+	# With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
+	# was changed to help a little.  newlib incorporated the change about 4
+	# years later.
+	echo "$as_me:4203: checking if _DEFAULT_SOURCE can be used as a basis" >&5
+echo $ECHO_N "checking if _DEFAULT_SOURCE can be used as a basis... $ECHO_C" >&6
+if test "${cf_cv_gnu_library_219+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+		cf_save="$CPPFLAGS"
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-D_DEFAULT_SOURCE"
+
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 4215 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main (void)
+{
+
+			#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
+				return 0;
+			#elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
+				return 0;
+			#else
+			#	error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
+			#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:4234: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4237: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:4240: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4243: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_gnu_library_219=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_gnu_library_219=no
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+		CPPFLAGS="$cf_save"
+
+fi
+echo "$as_me:4255: result: $cf_cv_gnu_library_219" >&5
+echo "${ECHO_T}$cf_cv_gnu_library_219" >&6
+
+	if test "x$cf_cv_gnu_library_219" = xyes; then
+		cf_save="$CPPFLAGS"
+		echo "$as_me:4260: checking if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE" >&5
+echo $ECHO_N "checking if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_gnu_dftsrc_219+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source
+do
+case "$cf_fix_cppflags" in
+(no)
+	case "$cf_add_cflags" in
+	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+		case "$cf_add_cflags" in
+		(-D*)
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+				&& test -z "${cf_tst_cflags}" \
+				&& cf_fix_cppflags=yes
+
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		(*$cf_add_cflags)
+			;;
+		(*)
+			case "$cf_add_cflags" in
+			(-D*)
+				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
+		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`
+
+				;;
+			esac
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
+			;;
+		esac
+		;;
+	(*)
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
+		;;
+	esac
+	;;
+(yes)
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
+
+	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+		&& test -z "${cf_tst_cflags}" \
+		&& cf_fix_cppflags=no
+	;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+			cat >"conftest.$ac_ext" <<_ACEOF
+#line 4365 "configure"
+#include "confdefs.h"
+
+				#include <limits.h>
+				#include <sys/types.h>
+
+int
+main (void)
+{
+
+				#if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
+					return 0;
+				#else
+				#	error GNU C library is too old
+				#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:4385: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4388: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:4391: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4394: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_gnu_dftsrc_219=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_gnu_dftsrc_219=no
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+
+fi
+echo "$as_me:4405: result: $cf_cv_gnu_dftsrc_219" >&5
+echo "${ECHO_T}$cf_cv_gnu_dftsrc_219" >&6
+		test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
+	else
+		cf_cv_gnu_dftsrc_219=maybe
+	fi
+
+	if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
+
+		echo "$as_me:4414: checking if we must define _GNU_SOURCE" >&5
 echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6
 if test "${cf_cv_gnu_source+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 2843 "configure"
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 4421 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
-main ()
+main (void)
 {
 
-#ifndef _XOPEN_SOURCE
-make an error
-#endif
+			#ifndef _XOPEN_SOURCE
+			#error	expected _XOPEN_SOURCE to be defined
+			#endif
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2858: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:4436: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2861: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2864: \"$ac_try\"") >&5
+  echo "$as_me:4439: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:4442: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2867: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:4445: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_gnu_source=no
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_save="$CPPFLAGS"
-	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
-	 cat >conftest.$ac_ext <<_ACEOF
-#line 2876 "configure"
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in -D_GNU_SOURCE
+do
+case "$cf_fix_cppflags" in
+(no)
+	case "$cf_add_cflags" in
+	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+		case "$cf_add_cflags" in
+		(-D*)
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+				&& test -z "${cf_tst_cflags}" \
+				&& cf_fix_cppflags=yes
+
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		(*$cf_add_cflags)
+			;;
+		(*)
+			case "$cf_add_cflags" in
+			(-D*)
+				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
+		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`
+
+				;;
+			esac
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
+			;;
+		esac
+		;;
+	(*)
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
+		;;
+	esac
+	;;
+(yes)
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
+
+	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+		&& test -z "${cf_tst_cflags}" \
+		&& cf_fix_cppflags=no
+	;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+			 cat >"conftest.$ac_ext" <<_ACEOF
+#line 4552 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
-main ()
+main (void)
 {
 
-#ifdef _XOPEN_SOURCE
-make an error
-#endif
+				#ifdef _XOPEN_SOURCE
+				#error	expected _XOPEN_SOURCE to be undefined
+				#endif
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2891: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:4567: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2894: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2897: \"$ac_try\"") >&5
+  echo "$as_me:4570: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:4573: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2900: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:4576: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_gnu_source=no
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_gnu_source=yes
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-	CPPFLAGS="$cf_save"
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+			CPPFLAGS="$cf_save"
 
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:2915: result: $cf_cv_gnu_source" >&5
+echo "$as_me:4591: result: $cf_cv_gnu_source" >&5
 echo "${ECHO_T}$cf_cv_gnu_source" >&6
-test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+
+		if test "$cf_cv_gnu_source" = yes
+		then
+		echo "$as_me:4596: checking if we should also define _DEFAULT_SOURCE" >&5
+echo $ECHO_N "checking if we should also define _DEFAULT_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_default_source+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-D_GNU_SOURCE"
+
+			cat >"conftest.$ac_ext" <<_ACEOF
+#line 4606 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main (void)
+{
+
+				#ifdef _DEFAULT_SOURCE
+				#error	expected _DEFAULT_SOURCE to be undefined
+				#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:4621: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4624: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:4627: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4630: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_default_source=no
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_default_source=yes
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+
+fi
+echo "$as_me:4641: result: $cf_cv_default_source" >&5
+echo "${ECHO_T}$cf_cv_default_source" >&6
+			if test "$cf_cv_default_source" = yes
+			then
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-D_DEFAULT_SOURCE"
+
+			fi
+		fi
+	fi
+
+fi
 
 	;;
 (minix*)
@@ -2924,6 +4660,8 @@
 	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
 	cf_XOPEN_SOURCE=
 
+if test "$cf_cv_posix_visible" = no; then
+
 cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE
 
 cf_save_CFLAGS="$CFLAGS"
@@ -2937,45 +4675,45 @@
 	sed	-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
 		-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?$//g'`
 
-echo "$as_me:2940: checking if we should define _POSIX_C_SOURCE" >&5
+echo "$as_me:4678: checking if we should define _POSIX_C_SOURCE" >&5
 echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6
 if test "${cf_cv_posix_c_source+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-echo "${as_me:-configure}:2946: testing if the symbol is already defined go no further ..." 1>&5
+echo "${as_me:-configure}:4684: testing if the symbol is already defined go no further ..." 1>&5
 
-	cat >conftest.$ac_ext <<_ACEOF
-#line 2949 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 4687 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
-main ()
+main (void)
 {
 
 #ifndef _POSIX_C_SOURCE
-make an error
+#error _POSIX_C_SOURCE is not defined
 #endif
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2964: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:4702: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2967: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2970: \"$ac_try\"") >&5
+  echo "$as_me:4705: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:4708: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2973: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:4711: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_posix_c_source=no
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_want_posix_source=no
 	 case .$cf_POSIX_C_SOURCE in
 	 (.[12]??*)
@@ -2990,91 +4728,94 @@
 		;;
 	 esac
 	 if test "$cf_want_posix_source" = yes ; then
-		cat >conftest.$ac_ext <<_ACEOF
-#line 2994 "configure"
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 4732 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
-main ()
+main (void)
 {
 
 #ifdef _POSIX_SOURCE
-make an error
+#error _POSIX_SOURCE is defined
 #endif
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3009: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:4747: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3012: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3015: \"$ac_try\"") >&5
+  echo "$as_me:4750: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:4753: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3018: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:4756: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE"
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 	 fi
 
-echo "${as_me:-configure}:3029: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
+echo "${as_me:-configure}:4767: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
 
 	 CFLAGS="$cf_trim_CFLAGS"
-	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
+	 CPPFLAGS="$cf_trim_CPPFLAGS"
 
-echo "${as_me:-configure}:3034: testing if the second compile does not leave our definition intact error ..." 1>&5
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_cv_posix_c_source"
 
-	 cat >conftest.$ac_ext <<_ACEOF
-#line 3037 "configure"
+echo "${as_me:-configure}:4775: testing if the second compile does not leave our definition intact error ..." 1>&5
+
+	 cat >"conftest.$ac_ext" <<_ACEOF
+#line 4778 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
-main ()
+main (void)
 {
 
 #ifndef _POSIX_C_SOURCE
-make an error
+#error _POSIX_C_SOURCE is not defined
 #endif
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3052: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:4793: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3055: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3058: \"$ac_try\"") >&5
+  echo "$as_me:4796: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:4799: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3061: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:4802: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_posix_c_source=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 	 CFLAGS="$cf_save_CFLAGS"
 	 CPPFLAGS="$cf_save_CPPFLAGS"
 
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:3077: result: $cf_cv_posix_c_source" >&5
+echo "$as_me:4818: result: $cf_cv_posix_c_source" >&5
 echo "${ECHO_T}$cf_cv_posix_c_source" >&6
 
 if test "$cf_cv_posix_c_source" != no ; then
@@ -3088,23 +4829,29 @@
 
 for cf_add_cflags in $cf_cv_posix_c_source
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -3113,7 +4860,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -3123,19 +4870,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -3146,26 +4901,43 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
 fi
 
+fi # cf_cv_posix_visible
+
 	;;
 (netbsd*)
 	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
 	;;
-(openbsd[4-9]*)
+(openbsd[6-9]*)
+	# OpenBSD 6.x has broken locale support, both compile-time and runtime.
+	# see https://www.mail-archive.com/bugs@openbsd.org/msg13200.html
+	# Abusing the conformance level is a workaround.
+	{ echo "$as_me:4935: WARNING: this system does not provide usable locale support" >&5
+echo "$as_me: WARNING: this system does not provide usable locale support" >&2;}
+	cf_xopen_source="-D_BSD_SOURCE"
+	cf_XOPEN_SOURCE=700
+	;;
+(openbsd[4-5]*)
 	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
 	cf_xopen_source="-D_BSD_SOURCE"
 	cf_XOPEN_SOURCE=600
@@ -3192,94 +4964,95 @@
 	;;
 (*)
 
-echo "$as_me:3195: checking if we should define _XOPEN_SOURCE" >&5
+echo "$as_me:4967: checking if we should define _XOPEN_SOURCE" >&5
 echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
 if test "${cf_cv_xopen_source+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-	cat >conftest.$ac_ext <<_ACEOF
-#line 3202 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 4974 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
+$ac_includes_default
 
 int
-main ()
+main (void)
 {
 
 #ifndef _XOPEN_SOURCE
-make an error
+#error _XOPEN_SOURCE is not defined
 #endif
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3221: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:4992: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3224: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3227: \"$ac_try\"") >&5
+  echo "$as_me:4995: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:4998: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3230: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:5001: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_xopen_source=no
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_save="$CPPFLAGS"
-	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
-	 cat >conftest.$ac_ext <<_ACEOF
-#line 3239 "configure"
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+
+	 cat >"conftest.$ac_ext" <<_ACEOF
+#line 5013 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
+$ac_includes_default
 
 int
-main ()
+main (void)
 {
 
-#ifdef _XOPEN_SOURCE
-make an error
+#ifndef _XOPEN_SOURCE
+#error _XOPEN_SOURCE is not defined
 #endif
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3258: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:5031: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3261: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3264: \"$ac_try\"") >&5
+  echo "$as_me:5034: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:5037: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3267: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:5040: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_xopen_source=no
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_xopen_source=$cf_XOPEN_SOURCE
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-	CPPFLAGS="$cf_save"
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+		CPPFLAGS="$cf_save"
 
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:3282: result: $cf_cv_xopen_source" >&5
+echo "$as_me:5055: result: $cf_cv_xopen_source" >&5
 echo "${ECHO_T}$cf_cv_xopen_source" >&6
 
 if test "$cf_cv_xopen_source" != no ; then
@@ -3294,30 +5067,62 @@
 
 	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
 
+for cf_add_cflags in $cf_temp_xopen_source
+do
+	case "x$cf_add_cflags" in
+	(x-[DU]*)
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CFLAGS" != "$cf_old_cflag" || break
+
+	CFLAGS="$cf_old_cflag"
+done
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CPPFLAGS" != "$cf_old_cflag" || break
+
+	CPPFLAGS="$cf_old_cflag"
+done
+
+		;;
+	esac
+
 cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
 cf_new_extra_cppflags=
 
-for cf_add_cflags in $cf_temp_xopen_source
+for cf_add_cflags in $cf_add_cflags
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -3326,7 +5131,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -3336,19 +5141,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -3359,21 +5172,33 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
-fi
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
 
 fi
 
+done
+
+fi
+
+	cf_save_xopen_cppflags="$CPPFLAGS"
+
+if test "$cf_cv_posix_visible" = no; then
+
 cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE
 
 cf_save_CFLAGS="$CFLAGS"
@@ -3387,45 +5212,45 @@
 	sed	-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
 		-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?$//g'`
 
-echo "$as_me:3390: checking if we should define _POSIX_C_SOURCE" >&5
+echo "$as_me:5215: checking if we should define _POSIX_C_SOURCE" >&5
 echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6
 if test "${cf_cv_posix_c_source+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-echo "${as_me:-configure}:3396: testing if the symbol is already defined go no further ..." 1>&5
+echo "${as_me:-configure}:5221: testing if the symbol is already defined go no further ..." 1>&5
 
-	cat >conftest.$ac_ext <<_ACEOF
-#line 3399 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 5224 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
-main ()
+main (void)
 {
 
 #ifndef _POSIX_C_SOURCE
-make an error
+#error _POSIX_C_SOURCE is not defined
 #endif
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3414: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:5239: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3417: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3420: \"$ac_try\"") >&5
+  echo "$as_me:5242: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:5245: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3423: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:5248: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_posix_c_source=no
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_want_posix_source=no
 	 case .$cf_POSIX_C_SOURCE in
 	 (.[12]??*)
@@ -3440,91 +5265,94 @@
 		;;
 	 esac
 	 if test "$cf_want_posix_source" = yes ; then
-		cat >conftest.$ac_ext <<_ACEOF
-#line 3444 "configure"
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 5269 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
-main ()
+main (void)
 {
 
 #ifdef _POSIX_SOURCE
-make an error
+#error _POSIX_SOURCE is defined
 #endif
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3459: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:5284: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3462: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3465: \"$ac_try\"") >&5
+  echo "$as_me:5287: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:5290: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3468: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:5293: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE"
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 	 fi
 
-echo "${as_me:-configure}:3479: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
+echo "${as_me:-configure}:5304: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
 
 	 CFLAGS="$cf_trim_CFLAGS"
-	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
+	 CPPFLAGS="$cf_trim_CPPFLAGS"
 
-echo "${as_me:-configure}:3484: testing if the second compile does not leave our definition intact error ..." 1>&5
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_cv_posix_c_source"
 
-	 cat >conftest.$ac_ext <<_ACEOF
-#line 3487 "configure"
+echo "${as_me:-configure}:5312: testing if the second compile does not leave our definition intact error ..." 1>&5
+
+	 cat >"conftest.$ac_ext" <<_ACEOF
+#line 5315 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
-main ()
+main (void)
 {
 
 #ifndef _POSIX_C_SOURCE
-make an error
+#error _POSIX_C_SOURCE is not defined
 #endif
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3502: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:5330: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3505: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3508: \"$ac_try\"") >&5
+  echo "$as_me:5333: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:5336: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3511: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:5339: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_posix_c_source=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 	 CFLAGS="$cf_save_CFLAGS"
 	 CPPFLAGS="$cf_save_CPPFLAGS"
 
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:3527: result: $cf_cv_posix_c_source" >&5
+echo "$as_me:5355: result: $cf_cv_posix_c_source" >&5
 echo "${ECHO_T}$cf_cv_posix_c_source" >&6
 
 if test "$cf_cv_posix_c_source" != no ; then
@@ -3538,23 +5366,29 @@
 
 for cf_add_cflags in $cf_cv_posix_c_source
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -3563,7 +5397,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -3573,19 +5407,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -3596,50 +5438,143 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
 fi
 
+fi # cf_cv_posix_visible
+
+	# Some of these niche implementations use copy/paste, double-check...
+	if test "$cf_cv_xopen_source" = no ; then
+		test -n "$verbose" && echo "	checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE" 1>&6
+
+echo "${as_me:-configure}:5468: testing checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE ..." 1>&5
+
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 5471 "configure"
+#include "confdefs.h"
+
+$ac_includes_default
+
+int
+main (void)
+{
+
+#ifndef _XOPEN_SOURCE
+#error _XOPEN_SOURCE is not defined
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:5489: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:5492: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:5495: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:5498: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+
+			{ echo "$as_me:5505: WARNING: _POSIX_C_SOURCE definition is not usable" >&5
+echo "$as_me: WARNING: _POSIX_C_SOURCE definition is not usable" >&2;}
+			CPPFLAGS="$cf_save_xopen_cppflags"
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+	fi
 	;;
 esac
 
 if test -n "$cf_xopen_source" ; then
 
+for cf_add_cflags in $cf_xopen_source
+do
+	case "x$cf_add_cflags" in
+	(x-[DU]*)
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CFLAGS" != "$cf_old_cflag" || break
+	test -n "$verbose" && echo "	removing old option $cf_add_cflags from CFLAGS" 1>&6
+
+echo "${as_me:-configure}:5528: testing removing old option $cf_add_cflags from CFLAGS ..." 1>&5
+
+	CFLAGS="$cf_old_cflag"
+done
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CPPFLAGS" != "$cf_old_cflag" || break
+	test -n "$verbose" && echo "	removing old option $cf_add_cflags from CPPFLAGS" 1>&6
+
+echo "${as_me:-configure}:5540: testing removing old option $cf_add_cflags from CPPFLAGS ..." 1>&5
+
+	CPPFLAGS="$cf_old_cflag"
+done
+
+		;;
+	esac
+
 cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
 cf_new_extra_cppflags=
 
-for cf_add_cflags in $cf_xopen_source
+for cf_add_cflags in $cf_add_cflags
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -3648,7 +5583,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -3658,19 +5593,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -3682,199 +5625,208 @@
 if test -n "$cf_new_cflags" ; then
 	test -n "$verbose" && echo "	add to \$CFLAGS $cf_new_cflags" 1>&6
 
-echo "${as_me:-configure}:3685: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
+echo "${as_me:-configure}:5628: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 	test -n "$verbose" && echo "	add to \$CPPFLAGS $cf_new_cppflags" 1>&6
 
-echo "${as_me:-configure}:3693: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
+echo "${as_me:-configure}:5638: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 	test -n "$verbose" && echo "	add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6
 
-echo "${as_me:-configure}:3701: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
+echo "${as_me:-configure}:5648: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
+done
+
 fi
 
 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
-	echo "$as_me:3709: checking if _XOPEN_SOURCE really is set" >&5
+	echo "$as_me:5660: checking if _XOPEN_SOURCE really is set" >&5
 echo $ECHO_N "checking if _XOPEN_SOURCE really is set... $ECHO_C" >&6
-	cat >conftest.$ac_ext <<_ACEOF
-#line 3712 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 5663 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 int
-main ()
+main (void)
 {
 
 #ifndef _XOPEN_SOURCE
-make an error
+#error _XOPEN_SOURCE is not defined
 #endif
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3727: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:5678: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3730: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3733: \"$ac_try\"") >&5
+  echo "$as_me:5681: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:5684: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3736: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:5687: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_XOPEN_SOURCE_set=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_XOPEN_SOURCE_set=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-	echo "$as_me:3745: result: $cf_XOPEN_SOURCE_set" >&5
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+	echo "$as_me:5696: result: $cf_XOPEN_SOURCE_set" >&5
 echo "${ECHO_T}$cf_XOPEN_SOURCE_set" >&6
-	if test $cf_XOPEN_SOURCE_set = yes
+	if test "$cf_XOPEN_SOURCE_set" = yes
 	then
-		cat >conftest.$ac_ext <<_ACEOF
-#line 3750 "configure"
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 5701 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 int
-main ()
+main (void)
 {
 
 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
-make an error
+#error (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
 #endif
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3765: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:5716: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3768: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3771: \"$ac_try\"") >&5
+  echo "$as_me:5719: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:5722: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3774: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:5725: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_XOPEN_SOURCE_set_ok=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_XOPEN_SOURCE_set_ok=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-		if test $cf_XOPEN_SOURCE_set_ok = no
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+		if test "$cf_XOPEN_SOURCE_set_ok" = no
 		then
-			{ echo "$as_me:3785: WARNING: _XOPEN_SOURCE is lower than requested" >&5
+			{ echo "$as_me:5736: WARNING: _XOPEN_SOURCE is lower than requested" >&5
 echo "$as_me: WARNING: _XOPEN_SOURCE is lower than requested" >&2;}
 		fi
 	else
 
-echo "$as_me:3790: checking if we should define _XOPEN_SOURCE" >&5
+echo "$as_me:5741: checking if we should define _XOPEN_SOURCE" >&5
 echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
 if test "${cf_cv_xopen_source+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-	cat >conftest.$ac_ext <<_ACEOF
-#line 3797 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 5748 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
+$ac_includes_default
 
 int
-main ()
+main (void)
 {
 
 #ifndef _XOPEN_SOURCE
-make an error
+#error _XOPEN_SOURCE is not defined
 #endif
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3816: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:5766: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3819: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3822: \"$ac_try\"") >&5
+  echo "$as_me:5769: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:5772: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3825: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:5775: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_xopen_source=no
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_save="$CPPFLAGS"
-	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
-	 cat >conftest.$ac_ext <<_ACEOF
-#line 3834 "configure"
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+
+	 cat >"conftest.$ac_ext" <<_ACEOF
+#line 5787 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
+$ac_includes_default
 
 int
-main ()
+main (void)
 {
 
-#ifdef _XOPEN_SOURCE
-make an error
+#ifndef _XOPEN_SOURCE
+#error _XOPEN_SOURCE is not defined
 #endif
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:3853: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:5805: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3856: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:3859: \"$ac_try\"") >&5
+  echo "$as_me:5808: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:5811: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3862: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:5814: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_xopen_source=no
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_xopen_source=$cf_XOPEN_SOURCE
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-	CPPFLAGS="$cf_save"
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+		CPPFLAGS="$cf_save"
 
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:3877: result: $cf_cv_xopen_source" >&5
+echo "$as_me:5829: result: $cf_cv_xopen_source" >&5
 echo "${ECHO_T}$cf_cv_xopen_source" >&6
 
 if test "$cf_cv_xopen_source" != no ; then
@@ -3889,30 +5841,62 @@
 
 	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
 
+for cf_add_cflags in $cf_temp_xopen_source
+do
+	case "x$cf_add_cflags" in
+	(x-[DU]*)
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CFLAGS" != "$cf_old_cflag" || break
+
+	CFLAGS="$cf_old_cflag"
+done
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CPPFLAGS" != "$cf_old_cflag" || break
+
+	CPPFLAGS="$cf_old_cflag"
+done
+
+		;;
+	esac
+
 cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
 cf_new_extra_cppflags=
 
-for cf_add_cflags in $cf_temp_xopen_source
+for cf_add_cflags in $cf_add_cflags
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -3921,7 +5905,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -3931,19 +5915,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -3954,25 +5946,262 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
+done
+
 fi
 
 	fi
 fi
+fi # cf_cv_posix_visible
 
-echo "$as_me:3975: checking for signal global datatype" >&5
+echo "$as_me:5976: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 5982 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+_ACEOF
+if { (eval echo "$as_me:5990: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:5996: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_cv_header_stdc=yes
+else
+  echo "$as_me: failed program was:" >&5
+  cat "conftest.$ac_ext" >&5
+  ac_cv_header_stdc=no
+fi
+rm -f conftest.err "conftest.$ac_ext"
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 6018 "configure"
+#include "confdefs.h"
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -rf conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 6036 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -rf conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then
+  :
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 6057 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
+                     || ('j' <= (c) && (c) <= 'r') \
+                     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main (void)
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+        || toupper (i) != TOUPPER (i))
+      $ac_main_return(2);
+  $ac_main_return (0);
+}
+_ACEOF
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:6083: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6086: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:6088: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6091: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  :
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_header_stdc=no
+fi
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+fi
+fi
+echo "$as_me:6104: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+                  inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:6120: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 6126 "configure"
+#include "confdefs.h"
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:6132: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6135: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:6138: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6141: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+eval "$as_ac_Header=no"
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+echo "$as_me:6151: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+echo "$as_me:6161: checking whether exit is declared" >&5
+echo $ECHO_N "checking whether exit is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_exit+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 6167 "configure"
+#include "confdefs.h"
+$ac_includes_default
+int
+main (void)
+{
+#ifndef exit
+  (void) exit;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:6182: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6185: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:6188: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6191: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_have_decl_exit=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_have_decl_exit=no
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+echo "$as_me:6201: result: $ac_cv_have_decl_exit" >&5
+echo "${ECHO_T}$ac_cv_have_decl_exit" >&6
+
+echo "$as_me:6204: checking for signal global datatype" >&5
 echo $ECHO_N "checking for signal global datatype... $ECHO_C" >&6
 if test "${cf_cv_sig_atomic_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3983,8 +6212,8 @@
 		"sig_atomic_t" \
 		"int"
 	do
-	cat >conftest.$ac_ext <<_ACEOF
-#line 3987 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 6216 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -3995,10 +6224,11 @@
 $cf_type x;
 static void handler(int sig)
 {
+	(void)sig;
 	x = 5;
 }
 int
-main ()
+main (void)
 {
 signal(SIGINT, handler);
 		 x = 1
@@ -4006,38 +6236,239 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4010: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:6240: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:4013: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:4016: \"$ac_try\"") >&5
+  echo "$as_me:6243: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:6246: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4019: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:6249: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_sig_atomic_t=$cf_type
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_sig_atomic_t=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 		test "$cf_cv_sig_atomic_t" != no && break
 	done
 
 fi
 
-echo "$as_me:4033: result: $cf_cv_sig_atomic_t" >&5
+echo "$as_me:6263: result: $cf_cv_sig_atomic_t" >&5
 echo "${ECHO_T}$cf_cv_sig_atomic_t" >&6
 test "$cf_cv_sig_atomic_t" != no &&
 cat >>confdefs.h <<EOF
 #define SIG_ATOMIC_T $cf_cv_sig_atomic_t
 EOF
 
-echo "$as_me:4040: checking if you want to use pkg-config" >&5
+# Work around breakage on OS X
+
+echo "$as_me:6272: checking if SIGWINCH is defined" >&5
+echo $ECHO_N "checking if SIGWINCH is defined... $ECHO_C" >&6
+if test "${cf_cv_define_sigwinch+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 6279 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <sys/signal.h>
+
+int
+main (void)
+{
+int x = SIGWINCH; (void)x
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:6294: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6297: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:6300: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6303: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_define_sigwinch=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 6310 "configure"
+#include "confdefs.h"
+
+#undef _XOPEN_SOURCE
+#undef _POSIX_SOURCE
+#undef _POSIX_C_SOURCE
+#include <sys/types.h>
+#include <sys/signal.h>
+
+int
+main (void)
+{
+int x = SIGWINCH; (void)x
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:6328: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6331: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:6334: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6337: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_define_sigwinch=maybe
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_define_sigwinch=no
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+
+fi
+echo "$as_me:6351: result: $cf_cv_define_sigwinch" >&5
+echo "${ECHO_T}$cf_cv_define_sigwinch" >&6
+
+if test "$cf_cv_define_sigwinch" = maybe ; then
+echo "$as_me:6355: checking for actual SIGWINCH definition" >&5
+echo $ECHO_N "checking for actual SIGWINCH definition... $ECHO_C" >&6
+if test "${cf_cv_fixup_sigwinch+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cf_cv_fixup_sigwinch=unknown
+cf_sigwinch=32
+while test "$cf_sigwinch" != 1
+do
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 6366 "configure"
+#include "confdefs.h"
+
+#undef _XOPEN_SOURCE
+#undef _POSIX_SOURCE
+#undef _POSIX_C_SOURCE
+#include <sys/types.h>
+#include <sys/signal.h>
+
+int
+main (void)
+{
+
+#if SIGWINCH != $cf_sigwinch
+#error SIGWINCH is not $cf_sigwinch
+#endif
+int x = SIGWINCH; (void)x
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:6388: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6391: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:6394: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6397: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_fixup_sigwinch=$cf_sigwinch
+	 break
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+
+cf_sigwinch="`expr "$cf_sigwinch" - 1`"
+done
+
+fi
+echo "$as_me:6411: result: $cf_cv_fixup_sigwinch" >&5
+echo "${ECHO_T}$cf_cv_fixup_sigwinch" >&6
+
+	if test "$cf_cv_fixup_sigwinch" != unknown ; then
+		CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
+	fi
+fi
+
+# Checks for CODESET support.
+
+echo "$as_me:6421: checking for nl_langinfo and CODESET" >&5
+echo $ECHO_N "checking for nl_langinfo and CODESET... $ECHO_C" >&6
+if test "${am_cv_langinfo_codeset+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 6427 "configure"
+#include "confdefs.h"
+
+$ac_includes_default
+#include <langinfo.h>
+int
+main (void)
+{
+char* cs = nl_langinfo(CODESET); (void)cs
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:6441: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6444: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:6447: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6450: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  am_cv_langinfo_codeset=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+am_cv_langinfo_codeset=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+
+fi
+echo "$as_me:6461: result: $am_cv_langinfo_codeset" >&5
+echo "${ECHO_T}$am_cv_langinfo_codeset" >&6
+	if test "$am_cv_langinfo_codeset" = yes; then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_LANGINFO_CODESET 1
+EOF
+
+	fi
+
+echo "$as_me:6471: checking if you want to use pkg-config" >&5
 echo $ECHO_N "checking if you want to use pkg-config... $ECHO_C" >&6
 
 # Check whether --with-pkg-config or --without-pkg-config was given.
@@ -4047,10 +6478,10 @@
 else
   cf_pkg_config=yes
 fi;
-echo "$as_me:4050: result: $cf_pkg_config" >&5
+echo "$as_me:6481: result: $cf_pkg_config" >&5
 echo "${ECHO_T}$cf_pkg_config" >&6
 
-case $cf_pkg_config in
+case "$cf_pkg_config" in
 (no)
 	PKG_CONFIG=none
 	;;
@@ -4059,7 +6490,7 @@
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
 set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
-echo "$as_me:4062: checking for $ac_word" >&5
+echo "$as_me:6493: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4076,7 +6507,7 @@
   test -z "$ac_dir" && ac_dir=.
   if $as_executable_p "$ac_dir/$ac_word"; then
    ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word"
-   echo "$as_me:4079: found $ac_dir/$ac_word" >&5
+   echo "$as_me:6510: found $ac_dir/$ac_word" >&5
    break
 fi
 done
@@ -4087,10 +6518,10 @@
 PKG_CONFIG=$ac_cv_path_PKG_CONFIG
 
 if test -n "$PKG_CONFIG"; then
-  echo "$as_me:4090: result: $PKG_CONFIG" >&5
+  echo "$as_me:6521: result: $PKG_CONFIG" >&5
 echo "${ECHO_T}$PKG_CONFIG" >&6
 else
-  echo "$as_me:4093: result: no" >&5
+  echo "$as_me:6524: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4099,7 +6530,7 @@
   ac_pt_PKG_CONFIG=$PKG_CONFIG
   # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
-echo "$as_me:4102: checking for $ac_word" >&5
+echo "$as_me:6533: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4116,7 +6547,7 @@
   test -z "$ac_dir" && ac_dir=.
   if $as_executable_p "$ac_dir/$ac_word"; then
    ac_cv_path_ac_pt_PKG_CONFIG="$ac_dir/$ac_word"
-   echo "$as_me:4119: found $ac_dir/$ac_word" >&5
+   echo "$as_me:6550: found $ac_dir/$ac_word" >&5
    break
 fi
 done
@@ -4128,10 +6559,10 @@
 ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
 
 if test -n "$ac_pt_PKG_CONFIG"; then
-  echo "$as_me:4131: result: $ac_pt_PKG_CONFIG" >&5
+  echo "$as_me:6562: result: $ac_pt_PKG_CONFIG" >&5
 echo "${ECHO_T}$ac_pt_PKG_CONFIG" >&6
 else
-  echo "$as_me:4134: result: no" >&5
+  echo "$as_me:6565: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4162,30 +6593,30 @@
 	;;
 (.[a-zA-Z]:[\\/]*) # OS/2 EMX
 	;;
-(.\${*prefix}*|.\${*dir}*)
+(.\$\{*prefix\}*|.\$\{*dir\}*)
 	eval PKG_CONFIG="$PKG_CONFIG"
 	case ".$PKG_CONFIG" in
 	(.NONE/*)
-		PKG_CONFIG=`echo $PKG_CONFIG | sed -e s%NONE%$cf_path_syntax%`
+		PKG_CONFIG=`echo "$PKG_CONFIG" | sed -e s%NONE%$cf_path_syntax%`
 		;;
 	esac
 	;;
 (.no|.NONE/*)
-	PKG_CONFIG=`echo $PKG_CONFIG | sed -e s%NONE%$cf_path_syntax%`
+	PKG_CONFIG=`echo "$PKG_CONFIG" | sed -e s%NONE%$cf_path_syntax%`
 	;;
 (*)
-	{ { echo "$as_me:4177: error: expected a pathname, not \"$PKG_CONFIG\"" >&5
+	{ { echo "$as_me:6608: error: expected a pathname, not \"$PKG_CONFIG\"" >&5
 echo "$as_me: error: expected a pathname, not \"$PKG_CONFIG\"" >&2;}
    { (exit 1); exit 1; }; }
 	;;
 esac
 
 elif test "x$cf_pkg_config" != xno ; then
-	{ echo "$as_me:4184: WARNING: pkg-config is not installed" >&5
+	{ echo "$as_me:6615: WARNING: pkg-config is not installed" >&5
 echo "$as_me: WARNING: pkg-config is not installed" >&2;}
 fi
 
-echo "$as_me:4188: checking if you want to see long compiling messages" >&5
+echo "$as_me:6619: checking if you want to see long compiling messages" >&5
 echo $ECHO_N "checking if you want to see long compiling messages... $ECHO_C" >&6
 
 # Check whether --enable-echo or --disable-echo was given.
@@ -4219,10 +6650,10 @@
 	ECHO_CC=''
 
 fi;
-echo "$as_me:4222: result: $enableval" >&5
+echo "$as_me:6653: result: $enableval" >&5
 echo "${ECHO_T}$enableval" >&6
 
-echo "$as_me:4225: checking for ncurses wrap-prefix" >&5
+echo "$as_me:6656: checking for ncurses wrap-prefix" >&5
 echo $ECHO_N "checking for ncurses wrap-prefix... $ECHO_C" >&6
 
 # Check whether --with-ncurses-wrap-prefix or --without-ncurses-wrap-prefix was given.
@@ -4232,10 +6663,10 @@
 else
   NCURSES_WRAP_PREFIX=_nc_
 fi;
-echo "$as_me:4235: result: $NCURSES_WRAP_PREFIX" >&5
+echo "$as_me:6666: result: $NCURSES_WRAP_PREFIX" >&5
 echo "${ECHO_T}$NCURSES_WRAP_PREFIX" >&6
 
-echo "$as_me:4238: checking if you want to check for wide-character functions" >&5
+echo "$as_me:6669: checking if you want to check for wide-character functions" >&5
 echo $ECHO_N "checking if you want to check for wide-character functions... $ECHO_C" >&6
 
 # Check whether --enable-widec or --disable-widec was given.
@@ -4252,10 +6683,10 @@
 	cf_enable_widec=yes
 
 fi;
-echo "$as_me:4255: result: $cf_enable_widec" >&5
+echo "$as_me:6686: result: $cf_enable_widec" >&5
 echo "${ECHO_T}$cf_enable_widec" >&6
 
-echo "$as_me:4258: checking for specific curses-directory" >&5
+echo "$as_me:6689: checking for specific curses-directory" >&5
 echo $ECHO_N "checking for specific curses-directory... $ECHO_C" >&6
 
 # Check whether --with-curses-dir or --without-curses-dir was given.
@@ -4265,10 +6696,10 @@
 else
   cf_cv_curses_dir=no
 fi;
-echo "$as_me:4268: result: $cf_cv_curses_dir" >&5
+echo "$as_me:6699: result: $cf_cv_curses_dir" >&5
 echo "${ECHO_T}$cf_cv_curses_dir" >&6
 
-if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
+if test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no"
 then
 
 if test "x$prefix" != xNONE; then
@@ -4284,19 +6715,19 @@
 	;;
 (.[a-zA-Z]:[\\/]*) # OS/2 EMX
 	;;
-(.\${*prefix}*|.\${*dir}*)
+(.\$\{*prefix\}*|.\$\{*dir\}*)
 	eval withval="$withval"
 	case ".$withval" in
 	(.NONE/*)
-		withval=`echo $withval | sed -e s%NONE%$cf_path_syntax%`
+		withval=`echo "$withval" | sed -e s%NONE%$cf_path_syntax%`
 		;;
 	esac
 	;;
 (.no|.NONE/*)
-	withval=`echo $withval | sed -e s%NONE%$cf_path_syntax%`
+	withval=`echo "$withval" | sed -e s%NONE%$cf_path_syntax%`
 	;;
 (*)
-	{ { echo "$as_me:4299: error: expected a pathname, not \"$withval\"" >&5
+	{ { echo "$as_me:6730: error: expected a pathname, not \"$withval\"" >&5
 echo "$as_me: error: expected a pathname, not \"$withval\"" >&2;}
    { (exit 1); exit 1; }; }
 	;;
@@ -4308,9 +6739,9 @@
 if test -n "$cf_cv_curses_dir/include" ; then
   for cf_add_incdir in $cf_cv_curses_dir/include
   do
-	while test $cf_add_incdir != /usr/include
+	while test "$cf_add_incdir" != /usr/include
 	do
-	  if test -d $cf_add_incdir
+	  if test -d "$cf_add_incdir"
 	  then
 		cf_have_incdir=no
 		if test -n "$CFLAGS$CPPFLAGS" ; then
@@ -4327,38 +6758,41 @@
 			if test "$GCC" = yes
 			then
 			  cf_save_CPPFLAGS=$CPPFLAGS
-			  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-			  cat >conftest.$ac_ext <<_ACEOF
-#line 4332 "configure"
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-I$cf_add_incdir"
+
+			  cat >"conftest.$ac_ext" <<_ACEOF
+#line 6766 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 printf("Hello")
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4344: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:6778: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:4347: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:4350: \"$ac_try\"") >&5
+  echo "$as_me:6781: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:6784: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4353: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:6787: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_have_incdir=yes
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 			  CPPFLAGS=$cf_save_CPPFLAGS
 			fi
 		  fi
@@ -4367,11 +6801,11 @@
 		if test "$cf_have_incdir" = no ; then
 		  test -n "$verbose" && echo "	adding $cf_add_incdir to include-path" 1>&6
 
-echo "${as_me:-configure}:4370: testing adding $cf_add_incdir to include-path ..." 1>&5
+echo "${as_me:-configure}:6804: testing adding $cf_add_incdir to include-path ..." 1>&5
 
 		  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 
-		  cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
+		  cf_top_incdir=`echo "$cf_add_incdir" | sed -e 's%/include/.*$%/include%'`
 		  test "$cf_top_incdir" = "$cf_add_incdir" && break
 		  cf_add_incdir="$cf_top_incdir"
 		else
@@ -4387,9 +6821,9 @@
 if test -n "$cf_cv_curses_dir/lib" ; then
 	for cf_add_libdir in $cf_cv_curses_dir/lib
 	do
-		if test $cf_add_libdir = /usr/lib ; then
+		if test "$cf_add_libdir" = /usr/lib ; then
 			:
-		elif test -d $cf_add_libdir
+		elif test -d "$cf_add_libdir"
 		then
 			cf_have_libdir=no
 			if test -n "$LDFLAGS$LIBS" ; then
@@ -4403,7 +6837,7 @@
 			if test "$cf_have_libdir" = no ; then
 				test -n "$verbose" && echo "	adding $cf_add_libdir to library-path" 1>&6
 
-echo "${as_me:-configure}:4406: testing adding $cf_add_libdir to library-path ..." 1>&5
+echo "${as_me:-configure}:6840: testing adding $cf_add_libdir to library-path ..." 1>&5
 
 				LDFLAGS="-L$cf_add_libdir $LDFLAGS"
 			fi
@@ -4416,7 +6850,7 @@
 
 cf_cv_screen=curses
 
-echo "$as_me:4419: checking for specified curses library type" >&5
+echo "$as_me:6853: checking for specified curses library type" >&5
 echo $ECHO_N "checking for specified curses library type... $ECHO_C" >&6
 
 # Check whether --with-screen or --without-screen was given.
@@ -4460,20 +6894,20 @@
 fi;
 fi;
 
-echo "$as_me:4463: result: $cf_cv_screen" >&5
+echo "$as_me:6897: result: $cf_cv_screen" >&5
 echo "${ECHO_T}$cf_cv_screen" >&6
 
 case $cf_cv_screen in
 (curses|curses_*)
 
-echo "$as_me:4469: checking for extra include directories" >&5
+echo "$as_me:6903: checking for extra include directories" >&5
 echo $ECHO_N "checking for extra include directories... $ECHO_C" >&6
 if test "${cf_cv_curses_incdir+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cf_cv_curses_incdir=no
-case $host_os in
+case "$host_os" in
 (hpux10.*)
 	if test "x$cf_cv_screen" = "xcurses_colr"
 	then
@@ -4492,11 +6926,17 @@
 esac
 
 fi
-echo "$as_me:4495: result: $cf_cv_curses_incdir" >&5
+echo "$as_me:6929: result: $cf_cv_curses_incdir" >&5
 echo "${ECHO_T}$cf_cv_curses_incdir" >&6
-test "$cf_cv_curses_incdir" != no && CPPFLAGS="$CPPFLAGS $cf_cv_curses_incdir"
+if test "$cf_cv_curses_incdir" != no
+then
 
-echo "$as_me:4499: checking if we have identified curses headers" >&5
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_cv_curses_incdir"
+
+fi
+
+echo "$as_me:6939: checking if we have identified curses headers" >&5
 echo $ECHO_N "checking if we have identified curses headers... $ECHO_C" >&6
 if test "${cf_cv_ncurses_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4507,44 +6947,44 @@
 	ncurses.h  \
 	curses.h  ncurses/ncurses.h ncurses/curses.h
 do
-cat >conftest.$ac_ext <<_ACEOF
-#line 4511 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 6951 "configure"
 #include "confdefs.h"
 #include <${cf_header}>
 int
-main ()
+main (void)
 {
-initscr(); tgoto("?", 0,0)
+initscr(); endwin()
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4523: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:6963: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:4526: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:4529: \"$ac_try\"") >&5
+  echo "$as_me:6966: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:6969: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4532: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:6972: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_ncurses_header=$cf_header; break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 done
 
 fi
-echo "$as_me:4543: result: $cf_cv_ncurses_header" >&5
+echo "$as_me:6983: result: $cf_cv_ncurses_header" >&5
 echo "${ECHO_T}$cf_cv_ncurses_header" >&6
 
 if test "$cf_cv_ncurses_header" = none ; then
-	{ { echo "$as_me:4547: error: No curses header-files found" >&5
+	{ { echo "$as_me:6987: error: No curses header-files found" >&5
 echo "$as_me: error: No curses header-files found" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -4554,24 +6994,24 @@
 for ac_header in $cf_cv_ncurses_header
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:4557: checking for $ac_header" >&5
+echo "$as_me:6997: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 4563 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 7003 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:4567: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (eval echo "$as_me:7007: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:4573: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
+  echo "$as_me:7013: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
   else
@@ -4584,14 +7024,14 @@
   eval "$as_ac_Header=yes"
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat "conftest.$ac_ext" >&5
   eval "$as_ac_Header=no"
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:4592: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
+echo "$as_me:7032: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
 EOF
@@ -4599,13 +7039,13 @@
 fi
 done
 
-echo "$as_me:4602: checking for terminfo header" >&5
+echo "$as_me:7042: checking for terminfo header" >&5
 echo $ECHO_N "checking for terminfo header... $ECHO_C" >&6
 if test "${cf_cv_term_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-case ${cf_cv_ncurses_header} in
+case "${cf_cv_ncurses_header}" in
 (*/ncurses.h|*/ncursesw.h)
 	cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[^.]*\.h$%term.h%'`
 	;;
@@ -4616,53 +7056,53 @@
 
 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
 do
-cat >conftest.$ac_ext <<_ACEOF
-#line 4620 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 7060 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #include <${cf_cv_ncurses_header:-curses.h}>
 #include <$cf_test>
 
 int
-main ()
+main (void)
 {
-int x = auto_left_margin
+int x = auto_left_margin; (void)x
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4635: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:7075: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:4638: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:4641: \"$ac_try\"") >&5
+  echo "$as_me:7078: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:7081: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4644: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:7084: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
 
 	cf_cv_term_header="$cf_test"
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 
 	cf_cv_term_header=unknown
 
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 	test "$cf_cv_term_header" != unknown && break
 done
 
 fi
-echo "$as_me:4660: result: $cf_cv_term_header" >&5
+echo "$as_me:7100: result: $cf_cv_term_header" >&5
 echo "${ECHO_T}$cf_cv_term_header" >&6
 
 # Set definitions to allow ifdef'ing to accommodate subdirectories
 
-case $cf_cv_term_header in
+case "$cf_cv_term_header" in
 (*term.h)
 
 cat >>confdefs.h <<\EOF
@@ -4672,7 +7112,7 @@
 	;;
 esac
 
-case $cf_cv_term_header in
+case "$cf_cv_term_header" in
 (ncurses/term.h)
 
 cat >>confdefs.h <<\EOF
@@ -4689,7 +7129,7 @@
 	;;
 esac
 
-echo "$as_me:4692: checking for ncurses version" >&5
+echo "$as_me:7132: checking for ncurses version" >&5
 echo $ECHO_N "checking for ncurses version... $ECHO_C" >&6
 if test "${cf_cv_ncurses_version+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4697,12 +7137,12 @@
 
 	cf_cv_ncurses_version=no
 	cf_tempfile=out$$
-	rm -f $cf_tempfile
+	rm -f "$cf_tempfile"
 	if test "$cross_compiling" = yes; then
 
 	# This will not work if the preprocessor splits the line after the
 	# Autoconf token.  The 'unproto' program does that.
-	cat > conftest.$ac_ext <<EOF
+	cat > "conftest.$ac_ext" <<EOF
 #include <${cf_cv_ncurses_header:-curses.h}>
 #undef Autoconf
 #ifdef NCURSES_VERSION
@@ -4715,121 +7155,123 @@
 #endif
 EOF
 	cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
-	{ (eval echo "$as_me:4718: \"$cf_try\"") >&5
+	{ (eval echo "$as_me:7158: \"$cf_try\"") >&5
   (eval $cf_try) 2>&5
   ac_status=$?
-  echo "$as_me:4721: \$? = $ac_status" >&5
-  (exit $ac_status); }
+  echo "$as_me:7161: \$? = $ac_status" >&5
+  (exit "$ac_status"); }
 	if test -f conftest.out ; then
-		cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
+		cf_out=`sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%' conftest.out`
 		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
 		rm -f conftest.out
 	fi
 
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 4731 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 7171 "configure"
 #include "confdefs.h"
 
+$ac_includes_default
+
 #include <${cf_cv_ncurses_header:-curses.h}>
-#include <stdio.h>
-int main()
+
+int main(void)
 {
 	FILE *fp = fopen("$cf_tempfile", "w");
 #ifdef NCURSES_VERSION
 # ifdef NCURSES_VERSION_PATCH
-	fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
+	fprintf(fp, "%s.%d\\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
 # else
-	fprintf(fp, "%s\n", NCURSES_VERSION);
+	fprintf(fp, "%s\\n", NCURSES_VERSION);
 # endif
 #else
 # ifdef __NCURSES_H
-	fprintf(fp, "old\n");
+	fprintf(fp, "old\\n");
 # else
-	make an error
+	#error expected ncurses header to define __NCURSES_H
 # endif
 #endif
 	${cf_cv_main_return:-return}(0);
 }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:4756: \"$ac_link\"") >&5
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:7198: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:4759: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:4761: \"$ac_try\"") >&5
+  echo "$as_me:7201: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:7203: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4764: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:7206: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
 
 	cf_cv_ncurses_version=`cat $cf_tempfile`
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-	rm -f $cf_tempfile
+	rm -f "$cf_tempfile"
 
 fi
-echo "$as_me:4778: result: $cf_cv_ncurses_version" >&5
+echo "$as_me:7220: result: $cf_cv_ncurses_version" >&5
 echo "${ECHO_T}$cf_cv_ncurses_version" >&6
 test "$cf_cv_ncurses_version" = no ||
 cat >>confdefs.h <<\EOF
 #define NCURSES 1
 EOF
 
-echo "$as_me:4785: checking if we have identified curses libraries" >&5
+echo "$as_me:7227: checking if we have identified curses libraries" >&5
 echo $ECHO_N "checking if we have identified curses libraries... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line 4788 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 7230 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-initscr(); tgoto("?", 0,0)
+initscr(); endwin()
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:4800: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:7242: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:4803: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:4806: \"$ac_try\"") >&5
+  echo "$as_me:7245: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:7248: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4809: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:7251: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_result=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-echo "$as_me:4818: result: $cf_result" >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+echo "$as_me:7260: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
 
 if test "$cf_result" = no ; then
-case $host_os in
+case "$host_os" in
 (freebsd*)
-	echo "$as_me:4824: checking for tgoto in -lmytinfo" >&5
+	echo "$as_me:7266: checking for tgoto in -lmytinfo" >&5
 echo $ECHO_N "checking for tgoto in -lmytinfo... $ECHO_C" >&6
 if test "${ac_cv_lib_mytinfo_tgoto+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lmytinfo  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 4832 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 7274 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -4838,53 +7280,53 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char tgoto ();
+char tgoto (void);
 int
-main ()
+main (void)
 {
 tgoto ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:4851: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:7293: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:4854: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:4857: \"$ac_try\"") >&5
+  echo "$as_me:7296: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:7299: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4860: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:7302: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_mytinfo_tgoto=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_mytinfo_tgoto=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:4871: result: $ac_cv_lib_mytinfo_tgoto" >&5
+echo "$as_me:7313: result: $ac_cv_lib_mytinfo_tgoto" >&5
 echo "${ECHO_T}$ac_cv_lib_mytinfo_tgoto" >&6
-if test $ac_cv_lib_mytinfo_tgoto = yes; then
+if test "$ac_cv_lib_mytinfo_tgoto" = yes; then
 
-cf_add_libs="-lmytinfo"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -lmytinfo; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -4898,15 +7340,15 @@
 	# term.h) for cur_colr
 	if test "x$cf_cv_screen" = "xcurses_colr"
 	then
-		echo "$as_me:4901: checking for initscr in -lcur_colr" >&5
+		echo "$as_me:7343: checking for initscr in -lcur_colr" >&5
 echo $ECHO_N "checking for initscr in -lcur_colr... $ECHO_C" >&6
 if test "${ac_cv_lib_cur_colr_initscr+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lcur_colr  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 4909 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 7351 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -4915,53 +7357,53 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char initscr ();
+char initscr (void);
 int
-main ()
+main (void)
 {
 initscr ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:4928: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:7370: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:4931: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:4934: \"$ac_try\"") >&5
+  echo "$as_me:7373: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:7376: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4937: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:7379: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_cur_colr_initscr=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_cur_colr_initscr=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:4948: result: $ac_cv_lib_cur_colr_initscr" >&5
+echo "$as_me:7390: result: $ac_cv_lib_cur_colr_initscr" >&5
 echo "${ECHO_T}$ac_cv_lib_cur_colr_initscr" >&6
-if test $ac_cv_lib_cur_colr_initscr = yes; then
+if test "$ac_cv_lib_cur_colr_initscr" = yes; then
 
-cf_add_libs="-lcur_colr"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -lcur_colr; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -4969,15 +7411,15 @@
 
 else
 
-		echo "$as_me:4972: checking for initscr in -lHcurses" >&5
+		echo "$as_me:7414: checking for initscr in -lHcurses" >&5
 echo $ECHO_N "checking for initscr in -lHcurses... $ECHO_C" >&6
 if test "${ac_cv_lib_Hcurses_initscr+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lHcurses  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 4980 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 7422 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -4986,59 +7428,61 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char initscr ();
+char initscr (void);
 int
-main ()
+main (void)
 {
 initscr ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:4999: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:7441: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5002: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5005: \"$ac_try\"") >&5
+  echo "$as_me:7444: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:7447: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5008: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:7450: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_Hcurses_initscr=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_Hcurses_initscr=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:5019: result: $ac_cv_lib_Hcurses_initscr" >&5
+echo "$as_me:7461: result: $ac_cv_lib_Hcurses_initscr" >&5
 echo "${ECHO_T}$ac_cv_lib_Hcurses_initscr" >&6
-if test $ac_cv_lib_Hcurses_initscr = yes; then
+if test "$ac_cv_lib_Hcurses_initscr" = yes; then
 
 			# HP's header uses __HP_CURSES, but user claims _HP_CURSES.
 
-cf_add_libs="-lHcurses"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -lHcurses; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
-			CPPFLAGS="$CPPFLAGS -D__HP_CURSES -D_HP_CURSES"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-D__HP_CURSES -D_HP_CURSES"
+
 			ac_cv_func_initscr=yes
 
 fi
@@ -5056,9 +7500,9 @@
 if test -n "/lib64" ; then
 	for cf_add_libdir in /lib64
 	do
-		if test $cf_add_libdir = /usr/lib ; then
+		if test "$cf_add_libdir" = /usr/lib ; then
 			:
-		elif test -d $cf_add_libdir
+		elif test -d "$cf_add_libdir"
 		then
 			cf_have_libdir=no
 			if test -n "$LDFLAGS$LIBS" ; then
@@ -5072,7 +7516,7 @@
 			if test "$cf_have_libdir" = no ; then
 				test -n "$verbose" && echo "	adding $cf_add_libdir to library-path" 1>&6
 
-echo "${as_me:-configure}:5075: testing adding $cf_add_libdir to library-path ..." 1>&5
+echo "${as_me:-configure}:7519: testing adding $cf_add_libdir to library-path ..." 1>&5
 
 				LDFLAGS="-L$cf_add_libdir $LDFLAGS"
 			fi
@@ -5085,9 +7529,9 @@
 if test -n "/lib" ; then
 	for cf_add_libdir in /lib
 	do
-		if test $cf_add_libdir = /usr/lib ; then
+		if test "$cf_add_libdir" = /usr/lib ; then
 			:
-		elif test -d $cf_add_libdir
+		elif test -d "$cf_add_libdir"
 		then
 			cf_have_libdir=no
 			if test -n "$LDFLAGS$LIBS" ; then
@@ -5101,7 +7545,7 @@
 			if test "$cf_have_libdir" = no ; then
 				test -n "$verbose" && echo "	adding $cf_add_libdir to library-path" 1>&6
 
-echo "${as_me:-configure}:5104: testing adding $cf_add_libdir to library-path ..." 1>&5
+echo "${as_me:-configure}:7548: testing adding $cf_add_libdir to library-path ..." 1>&5
 
 				LDFLAGS="-L$cf_add_libdir $LDFLAGS"
 			fi
@@ -5116,9 +7560,9 @@
 if test -n "/lib" ; then
 	for cf_add_libdir in /lib
 	do
-		if test $cf_add_libdir = /usr/lib ; then
+		if test "$cf_add_libdir" = /usr/lib ; then
 			:
-		elif test -d $cf_add_libdir
+		elif test -d "$cf_add_libdir"
 		then
 			cf_have_libdir=no
 			if test -n "$LDFLAGS$LIBS" ; then
@@ -5132,7 +7576,7 @@
 			if test "$cf_have_libdir" = no ; then
 				test -n "$verbose" && echo "	adding $cf_add_libdir to library-path" 1>&6
 
-echo "${as_me:-configure}:5135: testing adding $cf_add_libdir to library-path ..." 1>&5
+echo "${as_me:-configure}:7579: testing adding $cf_add_libdir to library-path ..." 1>&5
 
 				LDFLAGS="-L$cf_add_libdir $LDFLAGS"
 			fi
@@ -5151,9 +7595,9 @@
 if test -n "/usr/5lib" ; then
 	for cf_add_libdir in /usr/5lib
 	do
-		if test $cf_add_libdir = /usr/lib ; then
+		if test "$cf_add_libdir" = /usr/lib ; then
 			:
-		elif test -d $cf_add_libdir
+		elif test -d "$cf_add_libdir"
 		then
 			cf_have_libdir=no
 			if test -n "$LDFLAGS$LIBS" ; then
@@ -5167,7 +7611,7 @@
 			if test "$cf_have_libdir" = no ; then
 				test -n "$verbose" && echo "	adding $cf_add_libdir to library-path" 1>&6
 
-echo "${as_me:-configure}:5170: testing adding $cf_add_libdir to library-path ..." 1>&5
+echo "${as_me:-configure}:7614: testing adding $cf_add_libdir to library-path ..." 1>&5
 
 				LDFLAGS="-L$cf_add_libdir $LDFLAGS"
 			fi
@@ -5175,19 +7619,19 @@
 	done
 fi
 
-cf_add_libs="-lcurses -ltermcap"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -lcurses -ltermcap; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -5211,80 +7655,80 @@
 	# because it may be needed to link the test-case for initscr.
 	if test "x$cf_term_lib" = x
 	then
-		echo "$as_me:5214: checking for tgoto" >&5
+		echo "$as_me:7658: checking for tgoto" >&5
 echo $ECHO_N "checking for tgoto... $ECHO_C" >&6
 if test "${ac_cv_func_tgoto+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 5220 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 7664 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char tgoto (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
+#define tgoto autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef tgoto
+
 #ifdef __cplusplus
 extern "C"
 #endif
+
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char tgoto ();
-char (*f) ();
+char tgoto (void);
 
 int
-main ()
+main (void)
 {
-/* The GNU C library defines this for functions which it implements
+
+/* The GNU C library defines stubs for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined (__stub_tgoto) || defined (__stub___tgoto)
-choke me
-#else
-f = tgoto; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#error found stub for tgoto
 #endif
 
+	return tgoto ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5251: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:7695: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5254: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5257: \"$ac_try\"") >&5
+  echo "$as_me:7698: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:7701: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5260: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:7704: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_func_tgoto=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_func_tgoto=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:5270: result: $ac_cv_func_tgoto" >&5
+echo "$as_me:7714: result: $ac_cv_func_tgoto" >&5
 echo "${ECHO_T}$ac_cv_func_tgoto" >&6
-if test $ac_cv_func_tgoto = yes; then
+if test "$ac_cv_func_tgoto" = yes; then
   cf_term_lib=predefined
 else
 
 			for cf_term_lib in $cf_check_list otermcap termcap tinfo termlib unknown
 			do
 				as_ac_Lib=`echo "ac_cv_lib_$cf_term_lib''_tgoto" | $as_tr_sh`
-echo "$as_me:5279: checking for tgoto in -l$cf_term_lib" >&5
+echo "$as_me:7723: checking for tgoto in -l$cf_term_lib" >&5
 echo $ECHO_N "checking for tgoto in -l$cf_term_lib... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Lib+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-l$cf_term_lib  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 5287 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 7731 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -5293,40 +7737,43 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char tgoto ();
+char tgoto (void);
 int
-main ()
+main (void)
 {
 tgoto ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5306: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:7750: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5309: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5312: \"$ac_try\"") >&5
+  echo "$as_me:7753: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:7756: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5315: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:7759: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   eval "$as_ac_Lib=yes"
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 eval "$as_ac_Lib=no"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:5326: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-  break
+echo "$as_me:7770: result: `eval echo '${'"$as_ac_Lib"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Lib"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Lib"'}'`" = yes; then
+
+					: "${cf_nculib_root:=$cf_term_lib}"
+					break
+
 fi
 
 			done
@@ -5341,255 +7788,251 @@
 	then
 		for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
 		do
-			as_ac_Lib=`echo "ac_cv_lib_$cf_curs_lib''_initscr" | $as_tr_sh`
-echo "$as_me:5345: checking for initscr in -l$cf_curs_lib" >&5
-echo $ECHO_N "checking for initscr in -l$cf_curs_lib... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$cf_curs_lib  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 5353 "configure"
-#include "confdefs.h"
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char initscr ();
-int
-main ()
-{
-initscr ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5372: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:5375: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5378: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:5381: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-eval "$as_ac_Lib=no"
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:5392: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-  break
-fi
-
-		done
-	fi
-	test $cf_curs_lib = unknown && { { echo "$as_me:5400: error: no curses library found" >&5
-echo "$as_me: error: no curses library found" >&2;}
-   { (exit 1); exit 1; }; }
-
-	LIBS="-l$cf_curs_lib $cf_save_LIBS"
-	if test "$cf_term_lib" = unknown ; then
-		echo "$as_me:5406: checking if we can link with $cf_curs_lib library" >&5
+			LIBS="-l$cf_curs_lib $cf_save_LIBS"
+			if test "$cf_term_lib" = unknown || test "$cf_term_lib" = "$cf_curs_lib" ; then
+				echo "$as_me:7793: checking if we can link with $cf_curs_lib library" >&5
 echo $ECHO_N "checking if we can link with $cf_curs_lib library... $ECHO_C" >&6
-		cat >conftest.$ac_ext <<_ACEOF
-#line 5409 "configure"
+				cat >"conftest.$ac_ext" <<_ACEOF
+#line 7796 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 initscr()
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5421: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:7808: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5424: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5427: \"$ac_try\"") >&5
+  echo "$as_me:7811: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:7814: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5430: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:7817: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_result=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-		echo "$as_me:5439: result: $cf_result" >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+				echo "$as_me:7826: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
-		test $cf_result = no && { { echo "$as_me:5441: error: Cannot link curses library" >&5
-echo "$as_me: error: Cannot link curses library" >&2;}
-   { (exit 1); exit 1; }; }
-	elif test "$cf_curs_lib" = "$cf_term_lib" ; then
-		:
-	elif test "$cf_term_lib" != predefined ; then
-		echo "$as_me:5447: checking if we need both $cf_curs_lib and $cf_term_lib libraries" >&5
+				test "$cf_result" = yes && break
+			elif test "$cf_curs_lib" = "$cf_term_lib" ; then
+				cf_result=no
+			elif test "$cf_term_lib" != predefined ; then
+				echo "$as_me:7832: checking if we need both $cf_curs_lib and $cf_term_lib libraries" >&5
 echo $ECHO_N "checking if we need both $cf_curs_lib and $cf_term_lib libraries... $ECHO_C" >&6
-		cat >conftest.$ac_ext <<_ACEOF
-#line 5450 "configure"
+				cat >"conftest.$ac_ext" <<_ACEOF
+#line 7835 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-initscr(); tgoto((char *)0, 0, 0);
+initscr(); endwin();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5462: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:7847: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5465: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5468: \"$ac_try\"") >&5
+  echo "$as_me:7850: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:7853: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5471: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:7856: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_result=no
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 
-			LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
-			cat >conftest.$ac_ext <<_ACEOF
-#line 5480 "configure"
+					LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
+					cat >"conftest.$ac_ext" <<_ACEOF
+#line 7865 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 initscr()
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5492: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:7877: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5495: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5498: \"$ac_try\"") >&5
+  echo "$as_me:7880: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:7883: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5501: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:7886: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_result=error
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-		echo "$as_me:5513: result: $cf_result" >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+				echo "$as_me:7898: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
+				test "$cf_result" != error && break
+			fi
+		done
 	fi
+	test "$cf_curs_lib" = unknown && { { echo "$as_me:7904: error: no curses library found" >&5
+echo "$as_me: error: no curses library found" >&2;}
+   { (exit 1); exit 1; }; }
 fi
 fi
 
 	;;
 (ncursesw*)
 
-echo "$as_me:5522: checking for multibyte character support" >&5
+for ac_header in wchar.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:7916: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 7922 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:7926: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:7932: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat "conftest.$ac_ext" >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err "conftest.$ac_ext"
+fi
+echo "$as_me:7951: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+echo "$as_me:7961: checking for multibyte character support" >&5
 echo $ECHO_N "checking for multibyte character support... $ECHO_C" >&6
 if test "${cf_cv_utf8_lib+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cf_save_LIBS="$LIBS"
-	cat >conftest.$ac_ext <<_ACEOF
-#line 5530 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 7969 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
+$ac_includes_default
+#ifdef HAVE_WCHAR_H
+#include <wchar.h>
+#endif
+
 int
-main ()
+main (void)
 {
 putwc(0,0);
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5543: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:7986: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5546: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5549: \"$ac_try\"") >&5
+  echo "$as_me:7989: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:7992: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5552: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:7995: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_utf8_lib=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 
 # If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
 # will be set on completion of the AC_TRY_LINK below.
 cf_cv_header_path_utf8=
 cf_cv_library_path_utf8=
 
-echo "${as_me:-configure}:5564: testing Starting FIND_LINKAGE(utf8,) ..." 1>&5
+echo "${as_me:-configure}:8007: testing Starting FIND_LINKAGE(utf8,) ..." 1>&5
 
 cf_save_LIBS="$LIBS"
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 5569 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 8012 "configure"
 #include "confdefs.h"
 
 #include <libutf8.h>
 int
-main ()
+main (void)
 {
 putwc(0,0);
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5582: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:8025: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5585: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5588: \"$ac_try\"") >&5
+  echo "$as_me:8028: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:8031: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5591: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:8034: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
 
 	cf_cv_find_linkage_utf8=yes
 	cf_cv_header_path_utf8=/usr/include
@@ -5597,35 +8040,35 @@
 
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 
 LIBS="-lutf8  $cf_save_LIBS"
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 5605 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 8048 "configure"
 #include "confdefs.h"
 
 #include <libutf8.h>
 int
-main ()
+main (void)
 {
 putwc(0,0);
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5618: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:8061: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5621: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5624: \"$ac_try\"") >&5
+  echo "$as_me:8064: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:8067: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5627: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:8070: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
 
 	cf_cv_find_linkage_utf8=yes
 	cf_cv_header_path_utf8=/usr/include
@@ -5634,16 +8077,16 @@
 
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 
 	cf_cv_find_linkage_utf8=no
 	LIBS="$cf_save_LIBS"
 
 	test -n "$verbose" && echo "	find linkage for utf8 library" 1>&6
 
-echo "${as_me:-configure}:5644: testing find linkage for utf8 library ..." 1>&5
+echo "${as_me:-configure}:8087: testing find linkage for utf8 library ..." 1>&5
 
-echo "${as_me:-configure}:5646: testing Searching for headers in FIND_LINKAGE(utf8,) ..." 1>&5
+echo "${as_me:-configure}:8089: testing Searching for headers in FIND_LINKAGE(utf8,) ..." 1>&5
 
 	cf_save_CPPFLAGS="$CPPFLAGS"
 	cf_test_CPPFLAGS="$CPPFLAGS"
@@ -5655,7 +8098,7 @@
 if test -n "${CFLAGS}${CPPFLAGS}" ; then
 	for cf_header_path in $CPPFLAGS $CFLAGS
 	do
-		case $cf_header_path in
+		case "$cf_header_path" in
 		(-I*)
 			cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
 
@@ -5663,11 +8106,11 @@
 test -d "$cf_header_path" && \
  {
 	test -n "$verbose" && echo "	... testing for include-directories under $cf_header_path"
-	test -d $cf_header_path/include &&          cf_search="$cf_search $cf_header_path/include"
-	test -d $cf_header_path/include/utf8 &&       cf_search="$cf_search $cf_header_path/include/utf8"
-	test -d $cf_header_path/include/utf8/include &&    cf_search="$cf_search $cf_header_path/include/utf8/include"
-	test -d $cf_header_path/utf8/include &&       cf_search="$cf_search $cf_header_path/utf8/include"
-	test -d $cf_header_path/utf8/include/utf8 &&    cf_search="$cf_search $cf_header_path/utf8/include/utf8"
+	test -d "$cf_header_path/include" &&          cf_search="$cf_search $cf_header_path/include"
+	test -d "$cf_header_path/include/utf8" &&       cf_search="$cf_search $cf_header_path/include/utf8"
+	test -d "$cf_header_path/include/utf8/include" &&    cf_search="$cf_search $cf_header_path/include/utf8/include"
+	test -d "$cf_header_path/utf8/include" &&       cf_search="$cf_search $cf_header_path/utf8/include"
+	test -d "$cf_header_path/utf8/include/utf8" &&    cf_search="$cf_search $cf_header_path/utf8/include/utf8"
 }
 
 			cf_header_path_list="$cf_header_path_list $cf_search"
@@ -5684,11 +8127,11 @@
 test -d "$prefix" && \
  {
 	test -n "$verbose" && echo "	... testing for include-directories under $prefix"
-	test -d $prefix/include &&          cf_search="$cf_search $prefix/include"
-	test -d $prefix/include/utf8 &&       cf_search="$cf_search $prefix/include/utf8"
-	test -d $prefix/include/utf8/include &&    cf_search="$cf_search $prefix/include/utf8/include"
-	test -d $prefix/utf8/include &&       cf_search="$cf_search $prefix/utf8/include"
-	test -d $prefix/utf8/include/utf8 &&    cf_search="$cf_search $prefix/utf8/include/utf8"
+	test -d "$prefix/include" &&          cf_search="$cf_search $prefix/include"
+	test -d "$prefix/include/utf8" &&       cf_search="$cf_search $prefix/include/utf8"
+	test -d "$prefix/include/utf8/include" &&    cf_search="$cf_search $prefix/include/utf8/include"
+	test -d "$prefix/utf8/include" &&       cf_search="$cf_search $prefix/utf8/include"
+	test -d "$prefix/utf8/include/utf8" &&    cf_search="$cf_search $prefix/utf8/include/utf8"
 }
 
 for cf_subdir_prefix in \
@@ -5702,13 +8145,13 @@
 
 test "x$cf_subdir_prefix" != "x$prefix" && \
 test -d "$cf_subdir_prefix" && \
-(test -z "$prefix" || test x$prefix = xNONE || test "x$cf_subdir_prefix" != "x$prefix") && {
+{ test -z "$prefix" || test "x$prefix" = xNONE || test "x$cf_subdir_prefix" != "x$prefix"; } && {
 	test -n "$verbose" && echo "	... testing for include-directories under $cf_subdir_prefix"
-	test -d $cf_subdir_prefix/include &&          cf_search="$cf_search $cf_subdir_prefix/include"
-	test -d $cf_subdir_prefix/include/utf8 &&       cf_search="$cf_search $cf_subdir_prefix/include/utf8"
-	test -d $cf_subdir_prefix/include/utf8/include &&    cf_search="$cf_search $cf_subdir_prefix/include/utf8/include"
-	test -d $cf_subdir_prefix/utf8/include &&       cf_search="$cf_search $cf_subdir_prefix/utf8/include"
-	test -d $cf_subdir_prefix/utf8/include/utf8 &&    cf_search="$cf_search $cf_subdir_prefix/utf8/include/utf8"
+	test -d "$cf_subdir_prefix/include" &&          cf_search="$cf_search $cf_subdir_prefix/include"
+	test -d "$cf_subdir_prefix/include/utf8" &&       cf_search="$cf_search $cf_subdir_prefix/include/utf8"
+	test -d "$cf_subdir_prefix/include/utf8/include" &&    cf_search="$cf_search $cf_subdir_prefix/include/utf8/include"
+	test -d "$cf_subdir_prefix/utf8/include" &&       cf_search="$cf_search $cf_subdir_prefix/utf8/include"
+	test -d "$cf_subdir_prefix/utf8/include/utf8" &&    cf_search="$cf_search $cf_subdir_prefix/utf8/include/utf8"
 }
 
 done
@@ -5716,74 +8159,78 @@
 test "$includedir" != NONE && \
 test "$includedir" != "/usr/include" && \
 test -d "$includedir" && {
-	test -d $includedir &&    cf_search="$cf_search $includedir"
-	test -d $includedir/utf8 && cf_search="$cf_search $includedir/utf8"
+	test -d "$includedir" &&    cf_search="$cf_search $includedir"
+	test -d "$includedir/utf8" && cf_search="$cf_search $includedir/utf8"
 }
 
 test "$oldincludedir" != NONE && \
 test "$oldincludedir" != "/usr/include" && \
 test -d "$oldincludedir" && {
-	test -d $oldincludedir    && cf_search="$cf_search $oldincludedir"
-	test -d $oldincludedir/utf8 && cf_search="$cf_search $oldincludedir/utf8"
+	test -d "$oldincludedir"    && cf_search="$cf_search $oldincludedir"
+	test -d "$oldincludedir/utf8" && cf_search="$cf_search $oldincludedir/utf8"
 }
 
 cf_search="$cf_search $cf_header_path_list"
 
 	for cf_cv_header_path_utf8 in $cf_search
 	do
-		if test -d $cf_cv_header_path_utf8 ; then
+		if test -d "$cf_cv_header_path_utf8" ; then
 			test -n "$verbose" && echo "	... testing $cf_cv_header_path_utf8" 1>&6
 
-echo "${as_me:-configure}:5737: testing ... testing $cf_cv_header_path_utf8 ..." 1>&5
+echo "${as_me:-configure}:8180: testing ... testing $cf_cv_header_path_utf8 ..." 1>&5
 
-			CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_utf8"
-			cat >conftest.$ac_ext <<_ACEOF
-#line 5741 "configure"
+			CPPFLAGS="$cf_save_CPPFLAGS"
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-I$cf_cv_header_path_utf8"
+
+			cat >"conftest.$ac_ext" <<_ACEOF
+#line 8188 "configure"
 #include "confdefs.h"
 
 #include <libutf8.h>
 int
-main ()
+main (void)
 {
 putwc(0,0);
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:5754: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:8201: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:5757: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:5760: \"$ac_try\"") >&5
+  echo "$as_me:8204: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:8207: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5763: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:8210: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
 
 				test -n "$verbose" && echo "	... found utf8 headers in $cf_cv_header_path_utf8" 1>&6
 
-echo "${as_me:-configure}:5768: testing ... found utf8 headers in $cf_cv_header_path_utf8 ..." 1>&5
+echo "${as_me:-configure}:8215: testing ... found utf8 headers in $cf_cv_header_path_utf8 ..." 1>&5
 
 				cf_cv_find_linkage_utf8=maybe
 				cf_test_CPPFLAGS="$CPPFLAGS"
 				break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 
 				CPPFLAGS="$cf_save_CPPFLAGS"
 
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 		fi
 	done
 
 	if test "$cf_cv_find_linkage_utf8" = maybe ; then
 
-echo "${as_me:-configure}:5786: testing Searching for utf8 library in FIND_LINKAGE(utf8,) ..." 1>&5
+echo "${as_me:-configure}:8233: testing Searching for utf8 library in FIND_LINKAGE(utf8,) ..." 1>&5
 
 		cf_save_LIBS="$LIBS"
 		cf_save_LDFLAGS="$LDFLAGS"
@@ -5795,7 +8242,7 @@
 if test -n "${LDFLAGS}${LIBS}" ; then
 	for cf_library_path in $LDFLAGS $LIBS
 	do
-		case $cf_library_path in
+		case "$cf_library_path" in
 		(-L*)
 			cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
 
@@ -5803,11 +8250,11 @@
 test -d "$cf_library_path" && \
  {
 	test -n "$verbose" && echo "	... testing for lib-directories under $cf_library_path"
-	test -d $cf_library_path/lib &&          cf_search="$cf_search $cf_library_path/lib"
-	test -d $cf_library_path/lib/utf8 &&       cf_search="$cf_search $cf_library_path/lib/utf8"
-	test -d $cf_library_path/lib/utf8/lib &&    cf_search="$cf_search $cf_library_path/lib/utf8/lib"
-	test -d $cf_library_path/utf8/lib &&       cf_search="$cf_search $cf_library_path/utf8/lib"
-	test -d $cf_library_path/utf8/lib/utf8 &&    cf_search="$cf_search $cf_library_path/utf8/lib/utf8"
+	test -d "$cf_library_path/lib" &&          cf_search="$cf_search $cf_library_path/lib"
+	test -d "$cf_library_path/lib/utf8" &&       cf_search="$cf_search $cf_library_path/lib/utf8"
+	test -d "$cf_library_path/lib/utf8/lib" &&    cf_search="$cf_search $cf_library_path/lib/utf8/lib"
+	test -d "$cf_library_path/utf8/lib" &&       cf_search="$cf_search $cf_library_path/utf8/lib"
+	test -d "$cf_library_path/utf8/lib/utf8" &&    cf_search="$cf_search $cf_library_path/utf8/lib/utf8"
 }
 
 			cf_library_path_list="$cf_library_path_list $cf_search"
@@ -5822,11 +8269,11 @@
 test -d "$prefix" && \
  {
 	test -n "$verbose" && echo "	... testing for lib-directories under $prefix"
-	test -d $prefix/lib &&          cf_search="$cf_search $prefix/lib"
-	test -d $prefix/lib/utf8 &&       cf_search="$cf_search $prefix/lib/utf8"
-	test -d $prefix/lib/utf8/lib &&    cf_search="$cf_search $prefix/lib/utf8/lib"
-	test -d $prefix/utf8/lib &&       cf_search="$cf_search $prefix/utf8/lib"
-	test -d $prefix/utf8/lib/utf8 &&    cf_search="$cf_search $prefix/utf8/lib/utf8"
+	test -d "$prefix/lib" &&          cf_search="$cf_search $prefix/lib"
+	test -d "$prefix/lib/utf8" &&       cf_search="$cf_search $prefix/lib/utf8"
+	test -d "$prefix/lib/utf8/lib" &&    cf_search="$cf_search $prefix/lib/utf8/lib"
+	test -d "$prefix/utf8/lib" &&       cf_search="$cf_search $prefix/utf8/lib"
+	test -d "$prefix/utf8/lib/utf8" &&    cf_search="$cf_search $prefix/utf8/lib/utf8"
 }
 
 for cf_subdir_prefix in \
@@ -5840,13 +8287,13 @@
 
 test "x$cf_subdir_prefix" != "x$prefix" && \
 test -d "$cf_subdir_prefix" && \
-(test -z "$prefix" || test x$prefix = xNONE || test "x$cf_subdir_prefix" != "x$prefix") && {
+{ test -z "$prefix" || test "x$prefix" = xNONE || test "x$cf_subdir_prefix" != "x$prefix"; } && {
 	test -n "$verbose" && echo "	... testing for lib-directories under $cf_subdir_prefix"
-	test -d $cf_subdir_prefix/lib &&          cf_search="$cf_search $cf_subdir_prefix/lib"
-	test -d $cf_subdir_prefix/lib/utf8 &&       cf_search="$cf_search $cf_subdir_prefix/lib/utf8"
-	test -d $cf_subdir_prefix/lib/utf8/lib &&    cf_search="$cf_search $cf_subdir_prefix/lib/utf8/lib"
-	test -d $cf_subdir_prefix/utf8/lib &&       cf_search="$cf_search $cf_subdir_prefix/utf8/lib"
-	test -d $cf_subdir_prefix/utf8/lib/utf8 &&    cf_search="$cf_search $cf_subdir_prefix/utf8/lib/utf8"
+	test -d "$cf_subdir_prefix/lib" &&          cf_search="$cf_search $cf_subdir_prefix/lib"
+	test -d "$cf_subdir_prefix/lib/utf8" &&       cf_search="$cf_search $cf_subdir_prefix/lib/utf8"
+	test -d "$cf_subdir_prefix/lib/utf8/lib" &&    cf_search="$cf_search $cf_subdir_prefix/lib/utf8/lib"
+	test -d "$cf_subdir_prefix/utf8/lib" &&       cf_search="$cf_search $cf_subdir_prefix/utf8/lib"
+	test -d "$cf_subdir_prefix/utf8/lib/utf8" &&    cf_search="$cf_search $cf_subdir_prefix/utf8/lib/utf8"
 }
 
 done
@@ -5855,57 +8302,57 @@
 
 			for cf_cv_library_path_utf8 in $cf_search
 			do
-				if test -d $cf_cv_library_path_utf8 ; then
+				if test -d "$cf_cv_library_path_utf8" ; then
 					test -n "$verbose" && echo "	... testing $cf_cv_library_path_utf8" 1>&6
 
-echo "${as_me:-configure}:5861: testing ... testing $cf_cv_library_path_utf8 ..." 1>&5
+echo "${as_me:-configure}:8308: testing ... testing $cf_cv_library_path_utf8 ..." 1>&5
 
 					CPPFLAGS="$cf_test_CPPFLAGS"
 					LIBS="-lutf8  $cf_save_LIBS"
 					LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_utf8"
-					cat >conftest.$ac_ext <<_ACEOF
-#line 5867 "configure"
+					cat >"conftest.$ac_ext" <<_ACEOF
+#line 8314 "configure"
 #include "confdefs.h"
 
 #include <libutf8.h>
 int
-main ()
+main (void)
 {
 putwc(0,0);
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5880: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:8327: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5883: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5886: \"$ac_try\"") >&5
+  echo "$as_me:8330: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:8333: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5889: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:8336: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
 
 					test -n "$verbose" && echo "	... found utf8 library in $cf_cv_library_path_utf8" 1>&6
 
-echo "${as_me:-configure}:5894: testing ... found utf8 library in $cf_cv_library_path_utf8 ..." 1>&5
+echo "${as_me:-configure}:8341: testing ... found utf8 library in $cf_cv_library_path_utf8 ..." 1>&5
 
 					cf_cv_find_linkage_utf8=yes
 					cf_cv_library_file_utf8="-lutf8"
 					break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 
 					CPPFLAGS="$cf_save_CPPFLAGS"
 					LIBS="$cf_save_LIBS"
 					LDFLAGS="$cf_save_LDFLAGS"
 
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 				fi
 			done
 			CPPFLAGS="$cf_save_CPPFLAGS"
@@ -5917,10 +8364,10 @@
 	fi
 
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 LIBS="$cf_save_LIBS"
 
@@ -5931,9 +8378,9 @@
 fi
 
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:5936: result: $cf_cv_utf8_lib" >&5
+echo "$as_me:8383: result: $cf_cv_utf8_lib" >&5
 echo "${ECHO_T}$cf_cv_utf8_lib" >&6
 
 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
@@ -5947,9 +8394,9 @@
 if test -n "$cf_cv_header_path_utf8" ; then
   for cf_add_incdir in $cf_cv_header_path_utf8
   do
-	while test $cf_add_incdir != /usr/include
+	while test "$cf_add_incdir" != /usr/include
 	do
-	  if test -d $cf_add_incdir
+	  if test -d "$cf_add_incdir"
 	  then
 		cf_have_incdir=no
 		if test -n "$CFLAGS$CPPFLAGS" ; then
@@ -5966,38 +8413,41 @@
 			if test "$GCC" = yes
 			then
 			  cf_save_CPPFLAGS=$CPPFLAGS
-			  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-			  cat >conftest.$ac_ext <<_ACEOF
-#line 5971 "configure"
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-I$cf_add_incdir"
+
+			  cat >"conftest.$ac_ext" <<_ACEOF
+#line 8421 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 printf("Hello")
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:5983: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:8433: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:5986: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:5989: \"$ac_try\"") >&5
+  echo "$as_me:8436: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:8439: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5992: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:8442: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_have_incdir=yes
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 			  CPPFLAGS=$cf_save_CPPFLAGS
 			fi
 		  fi
@@ -6006,11 +8456,11 @@
 		if test "$cf_have_incdir" = no ; then
 		  test -n "$verbose" && echo "	adding $cf_add_incdir to include-path" 1>&6
 
-echo "${as_me:-configure}:6009: testing adding $cf_add_incdir to include-path ..." 1>&5
+echo "${as_me:-configure}:8459: testing adding $cf_add_incdir to include-path ..." 1>&5
 
 		  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 
-		  cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
+		  cf_top_incdir=`echo "$cf_add_incdir" | sed -e 's%/include/.*$%/include%'`
 		  test "$cf_top_incdir" = "$cf_add_incdir" && break
 		  cf_add_incdir="$cf_top_incdir"
 		else
@@ -6026,9 +8476,9 @@
 if test -n "$cf_cv_library_path_utf8" ; then
 	for cf_add_libdir in $cf_cv_library_path_utf8
 	do
-		if test $cf_add_libdir = /usr/lib ; then
+		if test "$cf_add_libdir" = /usr/lib ; then
 			:
-		elif test -d $cf_add_libdir
+		elif test -d "$cf_add_libdir"
 		then
 			cf_have_libdir=no
 			if test -n "$LDFLAGS$LIBS" ; then
@@ -6042,7 +8492,7 @@
 			if test "$cf_have_libdir" = no ; then
 				test -n "$verbose" && echo "	adding $cf_add_libdir to library-path" 1>&6
 
-echo "${as_me:-configure}:6045: testing adding $cf_add_libdir to library-path ..." 1>&5
+echo "${as_me:-configure}:8495: testing adding $cf_add_libdir to library-path ..." 1>&5
 
 				LDFLAGS="-L$cf_add_libdir $LDFLAGS"
 			fi
@@ -6050,19 +8500,19 @@
 	done
 fi
 
-cf_add_libs="$cf_cv_library_file_utf8"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_cv_library_file_utf8; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -6072,98 +8522,421 @@
 cf_have_ncuconfig=no
 
 if test "x${PKG_CONFIG:=none}" != xnone; then
-	echo "$as_me:6075: checking pkg-config for $cf_ncuconfig_root" >&5
+	echo "$as_me:8525: checking pkg-config for $cf_ncuconfig_root" >&5
 echo $ECHO_N "checking pkg-config for $cf_ncuconfig_root... $ECHO_C" >&6
 	if "$PKG_CONFIG" --exists $cf_ncuconfig_root ; then
-		echo "$as_me:6078: result: yes" >&5
+		echo "$as_me:8528: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 
-		echo "$as_me:6081: checking if the $cf_ncuconfig_root package files work" >&5
+		echo "$as_me:8531: checking if the $cf_ncuconfig_root package files work" >&5
 echo $ECHO_N "checking if the $cf_ncuconfig_root package files work... $ECHO_C" >&6
 		cf_have_ncuconfig=unknown
 
+		cf_save_CFLAGS="$CFLAGS"
 		cf_save_CPPFLAGS="$CPPFLAGS"
 		cf_save_LIBS="$LIBS"
 
-		CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags $cf_ncuconfig_root`"
+		cf_pkg_cflags="`$PKG_CONFIG --cflags $cf_ncuconfig_root`"
+		cf_pkg_libs="`$PKG_CONFIG --libs $cf_ncuconfig_root`"
 
-cf_add_libs="`$PKG_CONFIG --libs $cf_ncuconfig_root`"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
+		# while -W for passing linker flags is prevalent, it is not "standard".
+		# At least one wrapper for c89/c99 (in Apple's xcode) has its own
+		# incompatible _and_ non-standard -W option which gives an error.  Work
+		# around that pitfall.
+		case "x${CC}@@${cf_pkg_libs}@${cf_pkg_cflags}" in
+		(x*c[89]9@@*-W*)
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkg_cflags
 do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+case "$cf_fix_cppflags" in
+(no)
+	case "$cf_add_cflags" in
+	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+		case "$cf_add_cflags" in
+		(-D*)
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+				&& test -z "${cf_tst_cflags}" \
+				&& cf_fix_cppflags=yes
+
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		(*$cf_add_cflags)
+			;;
+		(*)
+			case "$cf_add_cflags" in
+			(-D*)
+				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
+		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`
+
+				;;
+			esac
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
+			;;
+		esac
+		;;
+	(*)
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
+		;;
+	esac
+	;;
+(yes)
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
+
+	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+		&& test -z "${cf_tst_cflags}" \
+		&& cf_fix_cppflags=no
+	;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_pkg_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
-		cat >conftest.$ac_ext <<_ACEOF
-#line 6107 "configure"
+			cat >"conftest.$ac_ext" <<_ACEOF
+#line 8664 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
+initscr(); mousemask(0,0); tigetstr((char *)0);
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:6119: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:8676: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:6122: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:6125: \"$ac_try\"") >&5
+  echo "$as_me:8679: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:8682: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6128: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:8685: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  if test "$cross_compiling" = yes; then
+  cf_test_ncuconfig=maybe
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 8691 "configure"
+#include "confdefs.h"
+#include <${cf_cv_ncurses_header:-curses.h}>
+					int main(void)
+					{ const char *xx = curses_version(); return (xx == 0); }
+_ACEOF
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:8698: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:8701: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:8703: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:8706: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_test_ncuconfig=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_test_ncuconfig=no
+fi
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_test_ncuconfig=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+
+			CFLAGS="$cf_save_CFLAGS"
+			CPPFLAGS="$cf_save_CPPFLAGS"
+			LIBS="$cf_save_LIBS"
+
+			if test "x$cf_test_ncuconfig" != xyes; then
+				cf_temp=`echo "x$cf_pkg_cflags" | sed -e s/^x// -e 's/-W[^ 	]*//g'`
+				cf_pkg_cflags="$cf_temp"
+				cf_temp=`echo "x$cf_pkg_libs" | sed -e s/^x// -e 's/-W[^ 	]*//g'`
+				cf_pkg_libs="$cf_temp"
+			fi
+			;;
+		esac
+
+for cf_add_cflags in $cf_pkg_cflags
+do
+	case "x$cf_add_cflags" in
+	(x-[DU]*)
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CFLAGS" != "$cf_old_cflag" || break
+
+	CFLAGS="$cf_old_cflag"
+done
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CPPFLAGS" != "$cf_old_cflag" || break
+
+	CPPFLAGS="$cf_old_cflag"
+done
+
+		;;
+	esac
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_add_cflags
+do
+case "$cf_fix_cppflags" in
+(no)
+	case "$cf_add_cflags" in
+	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+		case "$cf_add_cflags" in
+		(-D*)
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+				&& test -z "${cf_tst_cflags}" \
+				&& cf_fix_cppflags=yes
+
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		(*$cf_add_cflags)
+			;;
+		(*)
+			case "$cf_add_cflags" in
+			(-D*)
+				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
+		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`
+
+				;;
+			esac
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
+			;;
+		esac
+		;;
+	(*)
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
+		;;
+	esac
+	;;
+(yes)
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
+
+	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+		&& test -z "${cf_tst_cflags}" \
+		&& cf_fix_cppflags=no
+	;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+done
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_pkg_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
+			cf_add_1lib=
+			break
+		fi
+	done
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
+done
+LIBS="$cf_add_libs"
+
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 8880 "configure"
+#include "confdefs.h"
+#include <${cf_cv_ncurses_header:-curses.h}>
+int
+main (void)
+{
+initscr(); mousemask(0,0); tigetstr((char *)0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:8892: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:8895: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:8898: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:8901: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   if test "$cross_compiling" = yes; then
   cf_have_ncuconfig=maybe
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 6134 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 8907 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 				int main(void)
-				{ char *xx = curses_version(); return (xx == 0); }
+				{ const char *xx = curses_version(); return (xx == 0); }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:6141: \"$ac_link\"") >&5
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:8914: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:6144: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:6146: \"$ac_try\"") >&5
+  echo "$as_me:8917: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:8919: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6149: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:8922: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_have_ncuconfig=yes
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_have_ncuconfig=no
 fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_have_ncuconfig=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-		echo "$as_me:6166: result: $cf_have_ncuconfig" >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+		echo "$as_me:8939: result: $cf_have_ncuconfig" >&5
 echo "${ECHO_T}$cf_have_ncuconfig" >&6
 		test "$cf_have_ncuconfig" = maybe && cf_have_ncuconfig=yes
 		if test "$cf_have_ncuconfig" != "yes"
@@ -6178,10 +8951,101 @@
 EOF
 
 			NCURSES_CONFIG_PKG=$cf_ncuconfig_root
+
+echo "$as_me:8955: checking for terminfo header" >&5
+echo $ECHO_N "checking for terminfo header... $ECHO_C" >&6
+if test "${cf_cv_term_header+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+case "${cf_cv_ncurses_header}" in
+(*/ncurses.h|*/ncursesw.h)
+	cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[^.]*\.h$%term.h%'`
+	;;
+(*)
+	cf_term_header=term.h
+	;;
+esac
+
+for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
+do
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 8973 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+#include <${cf_cv_ncurses_header:-curses.h}>
+#include <$cf_test>
+
+int
+main (void)
+{
+int x = auto_left_margin; (void)x
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:8988: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:8991: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:8994: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:8997: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+
+	cf_cv_term_header="$cf_test"
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+
+	cf_cv_term_header=unknown
+
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+	test "$cf_cv_term_header" != unknown && break
+done
+
+fi
+echo "$as_me:9013: result: $cf_cv_term_header" >&5
+echo "${ECHO_T}$cf_cv_term_header" >&6
+
+# Set definitions to allow ifdef'ing to accommodate subdirectories
+
+case "$cf_cv_term_header" in
+(*term.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_TERM_H 1
+EOF
+
+	;;
+esac
+
+case "$cf_cv_term_header" in
+(ncurses/term.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSES_TERM_H 1
+EOF
+
+	;;
+(ncursesw/term.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSESW_TERM_H 1
+EOF
+
+	;;
+esac
+
 		fi
 
 	else
-		echo "$as_me:6184: result: no" >&5
+		echo "$as_me:9048: result: no" >&5
 echo "${ECHO_T}no" >&6
 		NCURSES_CONFIG_PKG=none
 	fi
@@ -6190,14 +9054,14 @@
 fi
 
 if test "x$cf_have_ncuconfig" = "xno"; then
-	echo "Looking for ${cf_ncuconfig_root}-config"
+	cf_ncurses_config="${cf_ncuconfig_root}${NCURSES_CONFIG_SUFFIX}-config"; echo "Looking for ${cf_ncurses_config}"
 
 if test -n "$ac_tool_prefix"; then
-  for ac_prog in ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
+  for ac_prog in ${cf_ncurses_config} ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:6200: checking for $ac_word" >&5
+echo "$as_me:9064: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_NCURSES_CONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -6212,7 +9076,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_NCURSES_CONFIG="$ac_tool_prefix$ac_prog"
-echo "$as_me:6215: found $ac_dir/$ac_word" >&5
+echo "$as_me:9079: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -6220,10 +9084,10 @@
 fi
 NCURSES_CONFIG=$ac_cv_prog_NCURSES_CONFIG
 if test -n "$NCURSES_CONFIG"; then
-  echo "$as_me:6223: result: $NCURSES_CONFIG" >&5
+  echo "$as_me:9087: result: $NCURSES_CONFIG" >&5
 echo "${ECHO_T}$NCURSES_CONFIG" >&6
 else
-  echo "$as_me:6226: result: no" >&5
+  echo "$as_me:9090: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -6232,11 +9096,11 @@
 fi
 if test -z "$NCURSES_CONFIG"; then
   ac_ct_NCURSES_CONFIG=$NCURSES_CONFIG
-  for ac_prog in ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
+  for ac_prog in ${cf_ncurses_config} ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:6239: checking for $ac_word" >&5
+echo "$as_me:9103: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_NCURSES_CONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -6251,7 +9115,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_NCURSES_CONFIG="$ac_prog"
-echo "$as_me:6254: found $ac_dir/$ac_word" >&5
+echo "$as_me:9118: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -6259,10 +9123,10 @@
 fi
 ac_ct_NCURSES_CONFIG=$ac_cv_prog_ac_ct_NCURSES_CONFIG
 if test -n "$ac_ct_NCURSES_CONFIG"; then
-  echo "$as_me:6262: result: $ac_ct_NCURSES_CONFIG" >&5
+  echo "$as_me:9126: result: $ac_ct_NCURSES_CONFIG" >&5
 echo "${ECHO_T}$ac_ct_NCURSES_CONFIG" >&6
 else
-  echo "$as_me:6265: result: no" >&5
+  echo "$as_me:9129: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -6275,27 +9139,151 @@
 
 	if test "$NCURSES_CONFIG" != none ; then
 
-		CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
-
-cf_add_libs="`$NCURSES_CONFIG --libs`"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
+for cf_add_cflags in `$NCURSES_CONFIG --cflags`
 do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+	case "x$cf_add_cflags" in
+	(x-[DU]*)
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CFLAGS" != "$cf_old_cflag" || break
+
+	CFLAGS="$cf_old_cflag"
+done
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CPPFLAGS" != "$cf_old_cflag" || break
+
+	CPPFLAGS="$cf_old_cflag"
+done
+
+		;;
+	esac
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_add_cflags
+do
+case "$cf_fix_cppflags" in
+(no)
+	case "$cf_add_cflags" in
+	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+		case "$cf_add_cflags" in
+		(-D*)
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+				&& test -z "${cf_tst_cflags}" \
+				&& cf_fix_cppflags=yes
+
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		(*$cf_add_cflags)
+			;;
+		(*)
+			case "$cf_add_cflags" in
+			(-D*)
+				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
+		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`
+
+				;;
+			esac
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
+			;;
+		esac
+		;;
+	(*)
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
+		;;
+	esac
+	;;
+(yes)
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
+
+	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+		&& test -z "${cf_tst_cflags}" \
+		&& cf_fix_cppflags=no
+	;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+done
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in `$NCURSES_CONFIG --libs`; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
 		# even with config script, some packages use no-override for curses.h
 
-echo "$as_me:6298: checking if we have identified curses headers" >&5
+echo "$as_me:9286: checking if we have identified curses headers" >&5
 echo $ECHO_N "checking if we have identified curses headers... $ECHO_C" >&6
 if test "${cf_cv_ncurses_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -6306,44 +9294,44 @@
 	ncurses.h $cf_cv_screen/ncurses.h \
 	curses.h $cf_cv_screen/curses.h
 do
-cat >conftest.$ac_ext <<_ACEOF
-#line 6310 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 9298 "configure"
 #include "confdefs.h"
 #include <${cf_header}>
 int
-main ()
+main (void)
 {
-initscr(); tgoto("?", 0,0)
+initscr(); endwin()
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6322: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:9310: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6325: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6328: \"$ac_try\"") >&5
+  echo "$as_me:9313: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:9316: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6331: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:9319: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_ncurses_header=$cf_header; break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 done
 
 fi
-echo "$as_me:6342: result: $cf_cv_ncurses_header" >&5
+echo "$as_me:9330: result: $cf_cv_ncurses_header" >&5
 echo "${ECHO_T}$cf_cv_ncurses_header" >&6
 
 if test "$cf_cv_ncurses_header" = none ; then
-	{ { echo "$as_me:6346: error: No curses header-files found" >&5
+	{ { echo "$as_me:9334: error: No curses header-files found" >&5
 echo "$as_me: error: No curses header-files found" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -6353,24 +9341,24 @@
 for ac_header in $cf_cv_ncurses_header
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:6356: checking for $ac_header" >&5
+echo "$as_me:9344: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 6362 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 9350 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:6366: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (eval echo "$as_me:9354: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:6372: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
+  echo "$as_me:9360: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
   else
@@ -6383,14 +9371,14 @@
   eval "$as_ac_Header=yes"
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat "conftest.$ac_ext" >&5
   eval "$as_ac_Header=no"
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:6391: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
+echo "$as_me:9379: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
 EOF
@@ -6408,7 +9396,7 @@
 #define $cf_nculib_ROOT 1
 EOF
 
-				cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
+				cf_cv_ncurses_version="`$NCURSES_CONFIG --version`"
 
 	else
 
@@ -6420,9 +9408,9 @@
 if test -n "$cf_cv_curses_dir/include/$cf_ncuhdr_root" ; then
   for cf_add_incdir in $cf_cv_curses_dir/include/$cf_ncuhdr_root
   do
-	while test $cf_add_incdir != /usr/include
+	while test "$cf_add_incdir" != /usr/include
 	do
-	  if test -d $cf_add_incdir
+	  if test -d "$cf_add_incdir"
 	  then
 		cf_have_incdir=no
 		if test -n "$CFLAGS$CPPFLAGS" ; then
@@ -6439,38 +9427,41 @@
 			if test "$GCC" = yes
 			then
 			  cf_save_CPPFLAGS=$CPPFLAGS
-			  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-			  cat >conftest.$ac_ext <<_ACEOF
-#line 6444 "configure"
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-I$cf_add_incdir"
+
+			  cat >"conftest.$ac_ext" <<_ACEOF
+#line 9435 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 printf("Hello")
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6456: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:9447: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6459: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6462: \"$ac_try\"") >&5
+  echo "$as_me:9450: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:9453: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6465: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:9456: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_have_incdir=yes
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 			  CPPFLAGS=$cf_save_CPPFLAGS
 			fi
 		  fi
@@ -6479,11 +9470,11 @@
 		if test "$cf_have_incdir" = no ; then
 		  test -n "$verbose" && echo "	adding $cf_add_incdir to include-path" 1>&6
 
-echo "${as_me:-configure}:6482: testing adding $cf_add_incdir to include-path ..." 1>&5
+echo "${as_me:-configure}:9473: testing adding $cf_add_incdir to include-path ..." 1>&5
 
 		  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 
-		  cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
+		  cf_top_incdir=`echo "$cf_add_incdir" | sed -e 's%/include/.*$%/include%'`
 		  test "$cf_top_incdir" = "$cf_add_incdir" && break
 		  cf_add_incdir="$cf_top_incdir"
 		else
@@ -6498,34 +9489,34 @@
 
 }
 
-echo "$as_me:6501: checking for $cf_ncuhdr_root header in include-path" >&5
+echo "$as_me:9492: checking for $cf_ncuhdr_root header in include-path" >&5
 echo $ECHO_N "checking for $cf_ncuhdr_root header in include-path... $ECHO_C" >&6
 if test "${cf_cv_ncurses_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
-	( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
+	{ test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw; } && cf_header_list="$cf_header_list curses.h ncurses.h"
 	for cf_header in $cf_header_list
 	do
 
-	cat >conftest.$ac_ext <<_ACEOF
-#line 6513 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 9504 "configure"
 #include "confdefs.h"
 
 #include <$cf_header>
 int
-main ()
+main (void)
 {
 
 #ifdef NCURSES_VERSION
 
-printf("%s\n", NCURSES_VERSION);
+printf("%s\\n", NCURSES_VERSION);
 #else
 #ifdef __NCURSES_H
-printf("old\n");
+printf("old\\n");
 #else
-	make an error
+	#error __NCURSES_H is not defined
 #endif
 #endif
 
@@ -6533,39 +9524,39 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6537: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:9528: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6540: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6543: \"$ac_try\"") >&5
+  echo "$as_me:9531: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:9534: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6546: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:9537: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_ncurses_h=$cf_header
 
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_ncurses_h=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 		test "$cf_cv_ncurses_h" != no && break
 	done
 
 fi
-echo "$as_me:6561: result: $cf_cv_ncurses_h" >&5
+echo "$as_me:9552: result: $cf_cv_ncurses_h" >&5
 echo "${ECHO_T}$cf_cv_ncurses_h" >&6
 
 if test "$cf_cv_ncurses_h" != no ; then
 	cf_cv_ncurses_header=$cf_cv_ncurses_h
 else
 
-echo "$as_me:6568: checking for $cf_ncuhdr_root include-path" >&5
+echo "$as_me:9559: checking for $cf_ncuhdr_root include-path" >&5
 echo $ECHO_N "checking for $cf_ncuhdr_root include-path... $ECHO_C" >&6
 if test "${cf_cv_ncurses_h2+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -6580,7 +9571,7 @@
 if test -n "${CFLAGS}${CPPFLAGS}" ; then
 	for cf_header_path in $CPPFLAGS $CFLAGS
 	do
-		case $cf_header_path in
+		case "$cf_header_path" in
 		(-I*)
 			cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
 
@@ -6588,11 +9579,11 @@
 test -d "$cf_header_path" && \
  {
 	test -n "$verbose" && echo "	... testing for include-directories under $cf_header_path"
-	test -d $cf_header_path/include &&          cf_search="$cf_search $cf_header_path/include"
-	test -d $cf_header_path/include/$cf_ncuhdr_root &&       cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root"
-	test -d $cf_header_path/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root/include"
-	test -d $cf_header_path/$cf_ncuhdr_root/include &&       cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include"
-	test -d $cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
+	test -d "$cf_header_path/include" &&          cf_search="$cf_search $cf_header_path/include"
+	test -d "$cf_header_path/include/$cf_ncuhdr_root" &&       cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root"
+	test -d "$cf_header_path/include/$cf_ncuhdr_root/include" &&    cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root/include"
+	test -d "$cf_header_path/$cf_ncuhdr_root/include" &&       cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include"
+	test -d "$cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root" &&    cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
 }
 
 			cf_header_path_list="$cf_header_path_list $cf_search"
@@ -6609,11 +9600,11 @@
 test -d "$prefix" && \
  {
 	test -n "$verbose" && echo "	... testing for include-directories under $prefix"
-	test -d $prefix/include &&          cf_search="$cf_search $prefix/include"
-	test -d $prefix/include/$cf_ncuhdr_root &&       cf_search="$cf_search $prefix/include/$cf_ncuhdr_root"
-	test -d $prefix/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $prefix/include/$cf_ncuhdr_root/include"
-	test -d $prefix/$cf_ncuhdr_root/include &&       cf_search="$cf_search $prefix/$cf_ncuhdr_root/include"
-	test -d $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
+	test -d "$prefix/include" &&          cf_search="$cf_search $prefix/include"
+	test -d "$prefix/include/$cf_ncuhdr_root" &&       cf_search="$cf_search $prefix/include/$cf_ncuhdr_root"
+	test -d "$prefix/include/$cf_ncuhdr_root/include" &&    cf_search="$cf_search $prefix/include/$cf_ncuhdr_root/include"
+	test -d "$prefix/$cf_ncuhdr_root/include" &&       cf_search="$cf_search $prefix/$cf_ncuhdr_root/include"
+	test -d "$prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root" &&    cf_search="$cf_search $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
 }
 
 for cf_subdir_prefix in \
@@ -6627,13 +9618,13 @@
 
 test "x$cf_subdir_prefix" != "x$prefix" && \
 test -d "$cf_subdir_prefix" && \
-(test -z "$prefix" || test x$prefix = xNONE || test "x$cf_subdir_prefix" != "x$prefix") && {
+{ test -z "$prefix" || test "x$prefix" = xNONE || test "x$cf_subdir_prefix" != "x$prefix"; } && {
 	test -n "$verbose" && echo "	... testing for include-directories under $cf_subdir_prefix"
-	test -d $cf_subdir_prefix/include &&          cf_search="$cf_search $cf_subdir_prefix/include"
-	test -d $cf_subdir_prefix/include/$cf_ncuhdr_root &&       cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root"
-	test -d $cf_subdir_prefix/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root/include"
-	test -d $cf_subdir_prefix/$cf_ncuhdr_root/include &&       cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include"
-	test -d $cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
+	test -d "$cf_subdir_prefix/include" &&          cf_search="$cf_search $cf_subdir_prefix/include"
+	test -d "$cf_subdir_prefix/include/$cf_ncuhdr_root" &&       cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root"
+	test -d "$cf_subdir_prefix/include/$cf_ncuhdr_root/include" &&    cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root/include"
+	test -d "$cf_subdir_prefix/$cf_ncuhdr_root/include" &&       cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include"
+	test -d "$cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root" &&    cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
 }
 
 done
@@ -6641,20 +9632,20 @@
 test "$includedir" != NONE && \
 test "$includedir" != "/usr/include" && \
 test -d "$includedir" && {
-	test -d $includedir &&    cf_search="$cf_search $includedir"
-	test -d $includedir/$cf_ncuhdr_root && cf_search="$cf_search $includedir/$cf_ncuhdr_root"
+	test -d "$includedir" &&    cf_search="$cf_search $includedir"
+	test -d "$includedir/$cf_ncuhdr_root" && cf_search="$cf_search $includedir/$cf_ncuhdr_root"
 }
 
 test "$oldincludedir" != NONE && \
 test "$oldincludedir" != "/usr/include" && \
 test -d "$oldincludedir" && {
-	test -d $oldincludedir    && cf_search="$cf_search $oldincludedir"
-	test -d $oldincludedir/$cf_ncuhdr_root && cf_search="$cf_search $oldincludedir/$cf_ncuhdr_root"
+	test -d "$oldincludedir"    && cf_search="$cf_search $oldincludedir"
+	test -d "$oldincludedir/$cf_ncuhdr_root" && cf_search="$cf_search $oldincludedir/$cf_ncuhdr_root"
 }
 
 cf_search="$cf_search $cf_header_path_list"
 
-	test -n "$verbose" && echo search path $cf_search
+	test -n "$verbose" && echo "search path $cf_search"
 	cf_save2_CPPFLAGS="$CPPFLAGS"
 	for cf_incdir in $cf_search
 	do
@@ -6662,9 +9653,9 @@
 if test -n "$cf_incdir" ; then
   for cf_add_incdir in $cf_incdir
   do
-	while test $cf_add_incdir != /usr/include
+	while test "$cf_add_incdir" != /usr/include
 	do
-	  if test -d $cf_add_incdir
+	  if test -d "$cf_add_incdir"
 	  then
 		cf_have_incdir=no
 		if test -n "$CFLAGS$CPPFLAGS" ; then
@@ -6681,38 +9672,41 @@
 			if test "$GCC" = yes
 			then
 			  cf_save_CPPFLAGS=$CPPFLAGS
-			  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-			  cat >conftest.$ac_ext <<_ACEOF
-#line 6686 "configure"
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-I$cf_add_incdir"
+
+			  cat >"conftest.$ac_ext" <<_ACEOF
+#line 9680 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 printf("Hello")
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6698: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:9692: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6701: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6704: \"$ac_try\"") >&5
+  echo "$as_me:9695: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:9698: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6707: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:9701: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_have_incdir=yes
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 			  CPPFLAGS=$cf_save_CPPFLAGS
 			fi
 		  fi
@@ -6721,11 +9715,11 @@
 		if test "$cf_have_incdir" = no ; then
 		  test -n "$verbose" && echo "	adding $cf_add_incdir to include-path" 1>&6
 
-echo "${as_me:-configure}:6724: testing adding $cf_add_incdir to include-path ..." 1>&5
+echo "${as_me:-configure}:9718: testing adding $cf_add_incdir to include-path ..." 1>&5
 
 		  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 
-		  cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
+		  cf_top_incdir=`echo "$cf_add_incdir" | sed -e 's%/include/.*$%/include%'`
 		  test "$cf_top_incdir" = "$cf_add_incdir" && break
 		  cf_add_incdir="$cf_top_incdir"
 		else
@@ -6743,23 +9737,23 @@
 			curses.h
 		do
 
-	cat >conftest.$ac_ext <<_ACEOF
-#line 6747 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 9741 "configure"
 #include "confdefs.h"
 
 #include <$cf_header>
 int
-main ()
+main (void)
 {
 
 #ifdef NCURSES_VERSION
 
-printf("%s\n", NCURSES_VERSION);
+printf("%s\\n", NCURSES_VERSION);
 #else
 #ifdef __NCURSES_H
-printf("old\n");
+printf("old\\n");
 #else
-	make an error
+	#error __NCURSES_H is not defined
 #endif
 #endif
 
@@ -6767,30 +9761,30 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6771: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:9765: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6774: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6777: \"$ac_try\"") >&5
+  echo "$as_me:9768: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:9771: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6780: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:9774: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_ncurses_h2=$cf_header
 
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_ncurses_h2=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 			if test "$cf_cv_ncurses_h2" != no ; then
 				cf_cv_ncurses_h2=$cf_incdir/$cf_header
-				test -n "$verbose" && echo $ac_n "	... found $ac_c" 1>&6
+				test -n "$verbose" && echo $ECHO_N "	... found $ECHO_C" 1>&6
 				break
 			fi
 			test -n "$verbose" && echo "	... tested $cf_incdir/$cf_header" 1>&6
@@ -6798,26 +9792,26 @@
 		CPPFLAGS="$cf_save2_CPPFLAGS"
 		test "$cf_cv_ncurses_h2" != no && break
 	done
-	test "$cf_cv_ncurses_h2" = no && { { echo "$as_me:6801: error: not found" >&5
+	test "$cf_cv_ncurses_h2" = no && { { echo "$as_me:9795: error: not found" >&5
 echo "$as_me: error: not found" >&2;}
    { (exit 1); exit 1; }; }
 
 fi
-echo "$as_me:6806: result: $cf_cv_ncurses_h2" >&5
+echo "$as_me:9800: result: $cf_cv_ncurses_h2" >&5
 echo "${ECHO_T}$cf_cv_ncurses_h2" >&6
 
-	cf_1st_incdir=`echo $cf_cv_ncurses_h2 | sed -e 's%/[^/]*$%%'`
-	cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
-	if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
-		cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
+	cf_1st_incdir=`echo "$cf_cv_ncurses_h2" | sed -e 's%/[^/]*$%%'`
+	cf_cv_ncurses_header="`basename "$cf_cv_ncurses_h2"`"
+	if test "`basename "$cf_1st_incdir"`" = "$cf_ncuhdr_root" ; then
+		cf_cv_ncurses_header="$cf_ncuhdr_root/$cf_cv_ncurses_header"
 	fi
 
 if test -n "$cf_1st_incdir" ; then
   for cf_add_incdir in $cf_1st_incdir
   do
-	while test $cf_add_incdir != /usr/include
+	while test "$cf_add_incdir" != /usr/include
 	do
-	  if test -d $cf_add_incdir
+	  if test -d "$cf_add_incdir"
 	  then
 		cf_have_incdir=no
 		if test -n "$CFLAGS$CPPFLAGS" ; then
@@ -6834,38 +9828,41 @@
 			if test "$GCC" = yes
 			then
 			  cf_save_CPPFLAGS=$CPPFLAGS
-			  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-			  cat >conftest.$ac_ext <<_ACEOF
-#line 6839 "configure"
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-I$cf_add_incdir"
+
+			  cat >"conftest.$ac_ext" <<_ACEOF
+#line 9836 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 printf("Hello")
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6851: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:9848: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6854: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6857: \"$ac_try\"") >&5
+  echo "$as_me:9851: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:9854: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6860: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:9857: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_have_incdir=yes
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 			  CPPFLAGS=$cf_save_CPPFLAGS
 			fi
 		  fi
@@ -6874,11 +9871,11 @@
 		if test "$cf_have_incdir" = no ; then
 		  test -n "$verbose" && echo "	adding $cf_add_incdir to include-path" 1>&6
 
-echo "${as_me:-configure}:6877: testing adding $cf_add_incdir to include-path ..." 1>&5
+echo "${as_me:-configure}:9874: testing adding $cf_add_incdir to include-path ..." 1>&5
 
 		  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 
-		  cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
+		  cf_top_incdir=`echo "$cf_add_incdir" | sed -e 's%/include/.*$%/include%'`
 		  test "$cf_top_incdir" = "$cf_add_incdir" && break
 		  cf_add_incdir="$cf_top_incdir"
 		else
@@ -6895,7 +9892,7 @@
 
 # Set definitions to allow ifdef'ing for ncurses.h
 
-case $cf_cv_ncurses_header in
+case "$cf_cv_ncurses_header" in
 (*ncurses.h)
 
 cat >>confdefs.h <<\EOF
@@ -6905,7 +9902,7 @@
 	;;
 esac
 
-case $cf_cv_ncurses_header in
+case "$cf_cv_ncurses_header" in
 (ncurses/curses.h|ncurses/ncurses.h)
 
 cat >>confdefs.h <<\EOF
@@ -6922,13 +9919,13 @@
 	;;
 esac
 
-echo "$as_me:6925: checking for terminfo header" >&5
+echo "$as_me:9922: checking for terminfo header" >&5
 echo $ECHO_N "checking for terminfo header... $ECHO_C" >&6
 if test "${cf_cv_term_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-case ${cf_cv_ncurses_header} in
+case "${cf_cv_ncurses_header}" in
 (*/ncurses.h|*/ncursesw.h)
 	cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[^.]*\.h$%term.h%'`
 	;;
@@ -6939,53 +9936,53 @@
 
 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
 do
-cat >conftest.$ac_ext <<_ACEOF
-#line 6943 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 9940 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #include <${cf_cv_ncurses_header:-curses.h}>
 #include <$cf_test>
 
 int
-main ()
+main (void)
 {
-int x = auto_left_margin
+int x = auto_left_margin; (void)x
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6958: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:9955: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6961: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6964: \"$ac_try\"") >&5
+  echo "$as_me:9958: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:9961: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6967: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:9964: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
 
 	cf_cv_term_header="$cf_test"
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 
 	cf_cv_term_header=unknown
 
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 	test "$cf_cv_term_header" != unknown && break
 done
 
 fi
-echo "$as_me:6983: result: $cf_cv_term_header" >&5
+echo "$as_me:9980: result: $cf_cv_term_header" >&5
 echo "${ECHO_T}$cf_cv_term_header" >&6
 
 # Set definitions to allow ifdef'ing to accommodate subdirectories
 
-case $cf_cv_term_header in
+case "$cf_cv_term_header" in
 (*term.h)
 
 cat >>confdefs.h <<\EOF
@@ -6995,7 +9992,7 @@
 	;;
 esac
 
-case $cf_cv_term_header in
+case "$cf_cv_term_header" in
 (ncurses/term.h)
 
 cat >>confdefs.h <<\EOF
@@ -7018,7 +10015,7 @@
 #define NCURSES 1
 EOF
 
-echo "$as_me:7021: checking for ncurses version" >&5
+echo "$as_me:10018: checking for ncurses version" >&5
 echo $ECHO_N "checking for ncurses version... $ECHO_C" >&6
 if test "${cf_cv_ncurses_version+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7026,12 +10023,12 @@
 
 	cf_cv_ncurses_version=no
 	cf_tempfile=out$$
-	rm -f $cf_tempfile
+	rm -f "$cf_tempfile"
 	if test "$cross_compiling" = yes; then
 
 	# This will not work if the preprocessor splits the line after the
 	# Autoconf token.  The 'unproto' program does that.
-	cat > conftest.$ac_ext <<EOF
+	cat > "conftest.$ac_ext" <<EOF
 #include <${cf_cv_ncurses_header:-curses.h}>
 #undef Autoconf
 #ifdef NCURSES_VERSION
@@ -7044,67 +10041,69 @@
 #endif
 EOF
 	cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
-	{ (eval echo "$as_me:7047: \"$cf_try\"") >&5
+	{ (eval echo "$as_me:10044: \"$cf_try\"") >&5
   (eval $cf_try) 2>&5
   ac_status=$?
-  echo "$as_me:7050: \$? = $ac_status" >&5
-  (exit $ac_status); }
+  echo "$as_me:10047: \$? = $ac_status" >&5
+  (exit "$ac_status"); }
 	if test -f conftest.out ; then
-		cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
+		cf_out=`sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%' conftest.out`
 		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
 		rm -f conftest.out
 	fi
 
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 7060 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 10057 "configure"
 #include "confdefs.h"
 
+$ac_includes_default
+
 #include <${cf_cv_ncurses_header:-curses.h}>
-#include <stdio.h>
-int main()
+
+int main(void)
 {
 	FILE *fp = fopen("$cf_tempfile", "w");
 #ifdef NCURSES_VERSION
 # ifdef NCURSES_VERSION_PATCH
-	fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
+	fprintf(fp, "%s.%d\\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
 # else
-	fprintf(fp, "%s\n", NCURSES_VERSION);
+	fprintf(fp, "%s\\n", NCURSES_VERSION);
 # endif
 #else
 # ifdef __NCURSES_H
-	fprintf(fp, "old\n");
+	fprintf(fp, "old\\n");
 # else
-	make an error
+	#error expected ncurses header to define __NCURSES_H
 # endif
 #endif
 	${cf_cv_main_return:-return}(0);
 }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:7085: \"$ac_link\"") >&5
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:10084: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7088: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:7090: \"$ac_try\"") >&5
+  echo "$as_me:10087: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:10089: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7093: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:10092: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
 
 	cf_cv_ncurses_version=`cat $cf_tempfile`
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-	rm -f $cf_tempfile
+	rm -f "$cf_tempfile"
 
 fi
-echo "$as_me:7107: result: $cf_cv_ncurses_version" >&5
+echo "$as_me:10106: result: $cf_cv_ncurses_version" >&5
 echo "${ECHO_T}$cf_cv_ncurses_version" >&6
 test "$cf_cv_ncurses_version" = no ||
 cat >>confdefs.h <<\EOF
@@ -7117,15 +10116,15 @@
 	# to link gpm.
 cf_ncurses_LIBS=""
 cf_ncurses_SAVE="$LIBS"
-echo "$as_me:7120: checking for Gpm_Open in -lgpm" >&5
+echo "$as_me:10119: checking for Gpm_Open in -lgpm" >&5
 echo $ECHO_N "checking for Gpm_Open in -lgpm... $ECHO_C" >&6
 if test "${ac_cv_lib_gpm_Gpm_Open+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lgpm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 7128 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 10127 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -7134,48 +10133,48 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char Gpm_Open ();
+char Gpm_Open (void);
 int
-main ()
+main (void)
 {
 Gpm_Open ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7147: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:10146: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7150: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7153: \"$ac_try\"") >&5
+  echo "$as_me:10149: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:10152: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7156: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:10155: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_gpm_Gpm_Open=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_gpm_Gpm_Open=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:7167: result: $ac_cv_lib_gpm_Gpm_Open" >&5
+echo "$as_me:10166: result: $ac_cv_lib_gpm_Gpm_Open" >&5
 echo "${ECHO_T}$ac_cv_lib_gpm_Gpm_Open" >&6
-if test $ac_cv_lib_gpm_Gpm_Open = yes; then
-  echo "$as_me:7170: checking for initscr in -lgpm" >&5
+if test "$ac_cv_lib_gpm_Gpm_Open" = yes; then
+  echo "$as_me:10169: checking for initscr in -lgpm" >&5
 echo $ECHO_N "checking for initscr in -lgpm... $ECHO_C" >&6
 if test "${ac_cv_lib_gpm_initscr+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lgpm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 7178 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 10177 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -7184,39 +10183,39 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char initscr ();
+char initscr (void);
 int
-main ()
+main (void)
 {
 initscr ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7197: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:10196: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7200: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7203: \"$ac_try\"") >&5
+  echo "$as_me:10199: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:10202: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7206: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:10205: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_gpm_initscr=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_gpm_initscr=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:7217: result: $ac_cv_lib_gpm_initscr" >&5
+echo "$as_me:10216: result: $ac_cv_lib_gpm_initscr" >&5
 echo "${ECHO_T}$ac_cv_lib_gpm_initscr" >&6
-if test $ac_cv_lib_gpm_initscr = yes; then
+if test "$ac_cv_lib_gpm_initscr" = yes; then
   LIBS="$cf_ncurses_SAVE"
 else
   cf_ncurses_LIBS="-lgpm"
@@ -7224,20 +10223,20 @@
 
 fi
 
-case $host_os in
+case "$host_os" in
 (freebsd*)
 	# This is only necessary if you are linking against an obsolete
-	# version of ncurses (but it should do no harm, since it's static).
+	# version of ncurses (but it should do no harm, since it is static).
 	if test "$cf_nculib_root" = ncurses ; then
-		echo "$as_me:7232: checking for tgoto in -lmytinfo" >&5
+		echo "$as_me:10231: checking for tgoto in -lmytinfo" >&5
 echo $ECHO_N "checking for tgoto in -lmytinfo... $ECHO_C" >&6
 if test "${ac_cv_lib_mytinfo_tgoto+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lmytinfo  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 7240 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 10239 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -7246,39 +10245,39 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char tgoto ();
+char tgoto (void);
 int
-main ()
+main (void)
 {
 tgoto ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7259: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:10258: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7262: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7265: \"$ac_try\"") >&5
+  echo "$as_me:10261: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:10264: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7268: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:10267: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_mytinfo_tgoto=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_mytinfo_tgoto=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:7279: result: $ac_cv_lib_mytinfo_tgoto" >&5
+echo "$as_me:10278: result: $ac_cv_lib_mytinfo_tgoto" >&5
 echo "${ECHO_T}$ac_cv_lib_mytinfo_tgoto" >&6
-if test $ac_cv_lib_mytinfo_tgoto = yes; then
+if test "$ac_cv_lib_mytinfo_tgoto" = yes; then
   cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"
 fi
 
@@ -7286,143 +10285,143 @@
 	;;
 esac
 
-cf_add_libs="$cf_ncurses_LIBS"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_ncurses_LIBS; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
-if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
+if test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no"
 then
 
-cf_add_libs="-l$cf_nculib_root"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -l$cf_nculib_root; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
 else
 
-	eval 'cf_cv_have_lib_'$cf_nculib_root'=no'
+	eval 'cf_cv_have_lib_'"$cf_nculib_root"'=no'
 	cf_libdir=""
-	echo "$as_me:7328: checking for initscr" >&5
+	echo "$as_me:10327: checking for initscr" >&5
 echo $ECHO_N "checking for initscr... $ECHO_C" >&6
 if test "${ac_cv_func_initscr+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 7334 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 10333 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char initscr (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
+#define initscr autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef initscr
+
 #ifdef __cplusplus
 extern "C"
 #endif
+
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char initscr ();
-char (*f) ();
+char initscr (void);
 
 int
-main ()
+main (void)
 {
-/* The GNU C library defines this for functions which it implements
+
+/* The GNU C library defines stubs for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined (__stub_initscr) || defined (__stub___initscr)
-choke me
-#else
-f = initscr; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#error found stub for initscr
 #endif
 
+	return initscr ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7365: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:10364: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7368: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7371: \"$ac_try\"") >&5
+  echo "$as_me:10367: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:10370: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7374: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:10373: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_func_initscr=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_func_initscr=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:7384: result: $ac_cv_func_initscr" >&5
+echo "$as_me:10383: result: $ac_cv_func_initscr" >&5
 echo "${ECHO_T}$ac_cv_func_initscr" >&6
-if test $ac_cv_func_initscr = yes; then
-  eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
+if test "$ac_cv_func_initscr" = yes; then
+  eval 'cf_cv_have_lib_'"$cf_nculib_root"'=yes'
 else
 
 		cf_save_LIBS="$LIBS"
-		echo "$as_me:7391: checking for initscr in -l$cf_nculib_root" >&5
+		echo "$as_me:10390: checking for initscr in -l$cf_nculib_root" >&5
 echo $ECHO_N "checking for initscr in -l$cf_nculib_root... $ECHO_C" >&6
 		LIBS="-l$cf_nculib_root $LIBS"
-		cat >conftest.$ac_ext <<_ACEOF
-#line 7395 "configure"
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 10394 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 initscr()
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7407: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:10406: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7410: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7413: \"$ac_try\"") >&5
+  echo "$as_me:10409: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:10412: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7416: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  echo "$as_me:7418: result: yes" >&5
+  echo "$as_me:10415: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  echo "$as_me:10417: result: yes" >&5
 echo "${ECHO_T}yes" >&6
-			 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
+			 eval 'cf_cv_have_lib_'"$cf_nculib_root"'=yes'
 
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-echo "$as_me:7425: result: no" >&5
+cat "conftest.$ac_ext" >&5
+echo "$as_me:10424: result: no" >&5
 echo "${ECHO_T}no" >&6
 
 cf_search=
@@ -7430,7 +10429,7 @@
 if test -n "${LDFLAGS}${LIBS}" ; then
 	for cf_library_path in $LDFLAGS $LIBS
 	do
-		case $cf_library_path in
+		case "$cf_library_path" in
 		(-L*)
 			cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
 
@@ -7438,11 +10437,11 @@
 test -d "$cf_library_path" && \
  {
 	test -n "$verbose" && echo "	... testing for lib-directories under $cf_library_path"
-	test -d $cf_library_path/lib &&          cf_search="$cf_search $cf_library_path/lib"
-	test -d $cf_library_path/lib/$cf_nculib_root &&       cf_search="$cf_search $cf_library_path/lib/$cf_nculib_root"
-	test -d $cf_library_path/lib/$cf_nculib_root/lib &&    cf_search="$cf_search $cf_library_path/lib/$cf_nculib_root/lib"
-	test -d $cf_library_path/$cf_nculib_root/lib &&       cf_search="$cf_search $cf_library_path/$cf_nculib_root/lib"
-	test -d $cf_library_path/$cf_nculib_root/lib/$cf_nculib_root &&    cf_search="$cf_search $cf_library_path/$cf_nculib_root/lib/$cf_nculib_root"
+	test -d "$cf_library_path/lib" &&          cf_search="$cf_search $cf_library_path/lib"
+	test -d "$cf_library_path/lib/$cf_nculib_root" &&       cf_search="$cf_search $cf_library_path/lib/$cf_nculib_root"
+	test -d "$cf_library_path/lib/$cf_nculib_root/lib" &&    cf_search="$cf_search $cf_library_path/lib/$cf_nculib_root/lib"
+	test -d "$cf_library_path/$cf_nculib_root/lib" &&       cf_search="$cf_search $cf_library_path/$cf_nculib_root/lib"
+	test -d "$cf_library_path/$cf_nculib_root/lib/$cf_nculib_root" &&    cf_search="$cf_search $cf_library_path/$cf_nculib_root/lib/$cf_nculib_root"
 }
 
 			cf_library_path_list="$cf_library_path_list $cf_search"
@@ -7457,11 +10456,11 @@
 test -d "$prefix" && \
  {
 	test -n "$verbose" && echo "	... testing for lib-directories under $prefix"
-	test -d $prefix/lib &&          cf_search="$cf_search $prefix/lib"
-	test -d $prefix/lib/$cf_nculib_root &&       cf_search="$cf_search $prefix/lib/$cf_nculib_root"
-	test -d $prefix/lib/$cf_nculib_root/lib &&    cf_search="$cf_search $prefix/lib/$cf_nculib_root/lib"
-	test -d $prefix/$cf_nculib_root/lib &&       cf_search="$cf_search $prefix/$cf_nculib_root/lib"
-	test -d $prefix/$cf_nculib_root/lib/$cf_nculib_root &&    cf_search="$cf_search $prefix/$cf_nculib_root/lib/$cf_nculib_root"
+	test -d "$prefix/lib" &&          cf_search="$cf_search $prefix/lib"
+	test -d "$prefix/lib/$cf_nculib_root" &&       cf_search="$cf_search $prefix/lib/$cf_nculib_root"
+	test -d "$prefix/lib/$cf_nculib_root/lib" &&    cf_search="$cf_search $prefix/lib/$cf_nculib_root/lib"
+	test -d "$prefix/$cf_nculib_root/lib" &&       cf_search="$cf_search $prefix/$cf_nculib_root/lib"
+	test -d "$prefix/$cf_nculib_root/lib/$cf_nculib_root" &&    cf_search="$cf_search $prefix/$cf_nculib_root/lib/$cf_nculib_root"
 }
 
 for cf_subdir_prefix in \
@@ -7475,13 +10474,13 @@
 
 test "x$cf_subdir_prefix" != "x$prefix" && \
 test -d "$cf_subdir_prefix" && \
-(test -z "$prefix" || test x$prefix = xNONE || test "x$cf_subdir_prefix" != "x$prefix") && {
+{ test -z "$prefix" || test "x$prefix" = xNONE || test "x$cf_subdir_prefix" != "x$prefix"; } && {
 	test -n "$verbose" && echo "	... testing for lib-directories under $cf_subdir_prefix"
-	test -d $cf_subdir_prefix/lib &&          cf_search="$cf_search $cf_subdir_prefix/lib"
-	test -d $cf_subdir_prefix/lib/$cf_nculib_root &&       cf_search="$cf_search $cf_subdir_prefix/lib/$cf_nculib_root"
-	test -d $cf_subdir_prefix/lib/$cf_nculib_root/lib &&    cf_search="$cf_search $cf_subdir_prefix/lib/$cf_nculib_root/lib"
-	test -d $cf_subdir_prefix/$cf_nculib_root/lib &&       cf_search="$cf_search $cf_subdir_prefix/$cf_nculib_root/lib"
-	test -d $cf_subdir_prefix/$cf_nculib_root/lib/$cf_nculib_root &&    cf_search="$cf_search $cf_subdir_prefix/$cf_nculib_root/lib/$cf_nculib_root"
+	test -d "$cf_subdir_prefix/lib" &&          cf_search="$cf_search $cf_subdir_prefix/lib"
+	test -d "$cf_subdir_prefix/lib/$cf_nculib_root" &&       cf_search="$cf_search $cf_subdir_prefix/lib/$cf_nculib_root"
+	test -d "$cf_subdir_prefix/lib/$cf_nculib_root/lib" &&    cf_search="$cf_search $cf_subdir_prefix/lib/$cf_nculib_root/lib"
+	test -d "$cf_subdir_prefix/$cf_nculib_root/lib" &&       cf_search="$cf_search $cf_subdir_prefix/$cf_nculib_root/lib"
+	test -d "$cf_subdir_prefix/$cf_nculib_root/lib/$cf_nculib_root" &&    cf_search="$cf_search $cf_subdir_prefix/$cf_nculib_root/lib/$cf_nculib_root"
 }
 
 done
@@ -7490,56 +10489,56 @@
 
 			for cf_libdir in $cf_search
 			do
-				echo "$as_me:7493: checking for -l$cf_nculib_root in $cf_libdir" >&5
+				echo "$as_me:10492: checking for -l$cf_nculib_root in $cf_libdir" >&5
 echo $ECHO_N "checking for -l$cf_nculib_root in $cf_libdir... $ECHO_C" >&6
 				LIBS="-L$cf_libdir -l$cf_nculib_root $cf_save_LIBS"
-				cat >conftest.$ac_ext <<_ACEOF
-#line 7497 "configure"
+				cat >"conftest.$ac_ext" <<_ACEOF
+#line 10496 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 initscr()
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7509: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:10508: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7512: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7515: \"$ac_try\"") >&5
+  echo "$as_me:10511: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:10514: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7518: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  echo "$as_me:7520: result: yes" >&5
+  echo "$as_me:10517: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  echo "$as_me:10519: result: yes" >&5
 echo "${ECHO_T}yes" >&6
-			 		 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
+			 		 eval 'cf_cv_have_lib_'"$cf_nculib_root"'=yes'
 					 break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-echo "$as_me:7527: result: no" >&5
+cat "conftest.$ac_ext" >&5
+echo "$as_me:10526: result: no" >&5
 echo "${ECHO_T}no" >&6
 					 LIBS="$cf_save_LIBS"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 			done
 
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 fi
 
-eval 'cf_found_library=$cf_cv_have_lib_'$cf_nculib_root
+eval 'cf_found_library="$cf_cv_have_lib_'"$cf_nculib_root"\"
 
-if test $cf_found_library = no ; then
-	{ { echo "$as_me:7542: error: Cannot link $cf_nculib_root library" >&5
+if test "$cf_found_library" = no ; then
+	{ { echo "$as_me:10541: error: Cannot link $cf_nculib_root library" >&5
 echo "$as_me: error: Cannot link $cf_nculib_root library" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -7547,49 +10546,49 @@
 fi
 
 if test -n "$cf_ncurses_LIBS" ; then
-	echo "$as_me:7550: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
+	echo "$as_me:10549: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
 echo $ECHO_N "checking if we can link $cf_nculib_root without $cf_ncurses_LIBS... $ECHO_C" >&6
 	cf_ncurses_SAVE="$LIBS"
 	for p in $cf_ncurses_LIBS ; do
-		q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
+		q=`echo "$LIBS" | sed -e "s%$p %%" -e "s%$p$%%"`
 		if test "$q" != "$LIBS" ; then
 			LIBS="$q"
 		fi
 	done
-	cat >conftest.$ac_ext <<_ACEOF
-#line 7560 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 10559 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
+initscr(); mousemask(0,0); tigetstr((char *)0);
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7572: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:10571: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7575: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7578: \"$ac_try\"") >&5
+  echo "$as_me:10574: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:10577: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7581: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  echo "$as_me:7583: result: yes" >&5
+  echo "$as_me:10580: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  echo "$as_me:10582: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-echo "$as_me:7588: result: no" >&5
+cat "conftest.$ac_ext" >&5
+echo "$as_me:10587: result: no" >&5
 echo "${ECHO_T}no" >&6
 		 LIBS="$cf_ncurses_SAVE"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
 
 cf_nculib_ROOT=`echo "HAVE_LIB$cf_nculib_root" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
@@ -7610,98 +10609,421 @@
 cf_have_ncuconfig=no
 
 if test "x${PKG_CONFIG:=none}" != xnone; then
-	echo "$as_me:7613: checking pkg-config for $cf_ncuconfig_root" >&5
+	echo "$as_me:10612: checking pkg-config for $cf_ncuconfig_root" >&5
 echo $ECHO_N "checking pkg-config for $cf_ncuconfig_root... $ECHO_C" >&6
 	if "$PKG_CONFIG" --exists $cf_ncuconfig_root ; then
-		echo "$as_me:7616: result: yes" >&5
+		echo "$as_me:10615: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 
-		echo "$as_me:7619: checking if the $cf_ncuconfig_root package files work" >&5
+		echo "$as_me:10618: checking if the $cf_ncuconfig_root package files work" >&5
 echo $ECHO_N "checking if the $cf_ncuconfig_root package files work... $ECHO_C" >&6
 		cf_have_ncuconfig=unknown
 
+		cf_save_CFLAGS="$CFLAGS"
 		cf_save_CPPFLAGS="$CPPFLAGS"
 		cf_save_LIBS="$LIBS"
 
-		CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags $cf_ncuconfig_root`"
+		cf_pkg_cflags="`$PKG_CONFIG --cflags $cf_ncuconfig_root`"
+		cf_pkg_libs="`$PKG_CONFIG --libs $cf_ncuconfig_root`"
 
-cf_add_libs="`$PKG_CONFIG --libs $cf_ncuconfig_root`"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
+		# while -W for passing linker flags is prevalent, it is not "standard".
+		# At least one wrapper for c89/c99 (in Apple's xcode) has its own
+		# incompatible _and_ non-standard -W option which gives an error.  Work
+		# around that pitfall.
+		case "x${CC}@@${cf_pkg_libs}@${cf_pkg_cflags}" in
+		(x*c[89]9@@*-W*)
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkg_cflags
 do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+case "$cf_fix_cppflags" in
+(no)
+	case "$cf_add_cflags" in
+	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+		case "$cf_add_cflags" in
+		(-D*)
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+				&& test -z "${cf_tst_cflags}" \
+				&& cf_fix_cppflags=yes
+
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		(*$cf_add_cflags)
+			;;
+		(*)
+			case "$cf_add_cflags" in
+			(-D*)
+				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
+		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`
+
+				;;
+			esac
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
+			;;
+		esac
+		;;
+	(*)
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
+		;;
+	esac
+	;;
+(yes)
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
+
+	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+		&& test -z "${cf_tst_cflags}" \
+		&& cf_fix_cppflags=no
+	;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_pkg_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
-		cat >conftest.$ac_ext <<_ACEOF
-#line 7645 "configure"
+			cat >"conftest.$ac_ext" <<_ACEOF
+#line 10751 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
+initscr(); mousemask(0,0); tigetstr((char *)0);
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7657: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:10763: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7660: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7663: \"$ac_try\"") >&5
+  echo "$as_me:10766: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:10769: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7666: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:10772: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  if test "$cross_compiling" = yes; then
+  cf_test_ncuconfig=maybe
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 10778 "configure"
+#include "confdefs.h"
+#include <${cf_cv_ncurses_header:-curses.h}>
+					int main(void)
+					{ const char *xx = curses_version(); return (xx == 0); }
+_ACEOF
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:10785: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10788: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:10790: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10793: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_test_ncuconfig=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_test_ncuconfig=no
+fi
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_test_ncuconfig=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+
+			CFLAGS="$cf_save_CFLAGS"
+			CPPFLAGS="$cf_save_CPPFLAGS"
+			LIBS="$cf_save_LIBS"
+
+			if test "x$cf_test_ncuconfig" != xyes; then
+				cf_temp=`echo "x$cf_pkg_cflags" | sed -e s/^x// -e 's/-W[^ 	]*//g'`
+				cf_pkg_cflags="$cf_temp"
+				cf_temp=`echo "x$cf_pkg_libs" | sed -e s/^x// -e 's/-W[^ 	]*//g'`
+				cf_pkg_libs="$cf_temp"
+			fi
+			;;
+		esac
+
+for cf_add_cflags in $cf_pkg_cflags
+do
+	case "x$cf_add_cflags" in
+	(x-[DU]*)
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CFLAGS" != "$cf_old_cflag" || break
+
+	CFLAGS="$cf_old_cflag"
+done
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CPPFLAGS" != "$cf_old_cflag" || break
+
+	CPPFLAGS="$cf_old_cflag"
+done
+
+		;;
+	esac
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_add_cflags
+do
+case "$cf_fix_cppflags" in
+(no)
+	case "$cf_add_cflags" in
+	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+		case "$cf_add_cflags" in
+		(-D*)
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+				&& test -z "${cf_tst_cflags}" \
+				&& cf_fix_cppflags=yes
+
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		(*$cf_add_cflags)
+			;;
+		(*)
+			case "$cf_add_cflags" in
+			(-D*)
+				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
+		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`
+
+				;;
+			esac
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
+			;;
+		esac
+		;;
+	(*)
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
+		;;
+	esac
+	;;
+(yes)
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
+
+	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+		&& test -z "${cf_tst_cflags}" \
+		&& cf_fix_cppflags=no
+	;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+done
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_pkg_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
+			cf_add_1lib=
+			break
+		fi
+	done
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
+done
+LIBS="$cf_add_libs"
+
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 10967 "configure"
+#include "confdefs.h"
+#include <${cf_cv_ncurses_header:-curses.h}>
+int
+main (void)
+{
+initscr(); mousemask(0,0); tigetstr((char *)0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:10979: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10982: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:10985: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10988: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   if test "$cross_compiling" = yes; then
   cf_have_ncuconfig=maybe
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 7672 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 10994 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 				int main(void)
-				{ char *xx = curses_version(); return (xx == 0); }
+				{ const char *xx = curses_version(); return (xx == 0); }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:7679: \"$ac_link\"") >&5
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:11001: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7682: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:7684: \"$ac_try\"") >&5
+  echo "$as_me:11004: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:11006: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7687: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:11009: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_have_ncuconfig=yes
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_have_ncuconfig=no
 fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_have_ncuconfig=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-		echo "$as_me:7704: result: $cf_have_ncuconfig" >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+		echo "$as_me:11026: result: $cf_have_ncuconfig" >&5
 echo "${ECHO_T}$cf_have_ncuconfig" >&6
 		test "$cf_have_ncuconfig" = maybe && cf_have_ncuconfig=yes
 		if test "$cf_have_ncuconfig" != "yes"
@@ -7716,10 +11038,101 @@
 EOF
 
 			NCURSES_CONFIG_PKG=$cf_ncuconfig_root
+
+echo "$as_me:11042: checking for terminfo header" >&5
+echo $ECHO_N "checking for terminfo header... $ECHO_C" >&6
+if test "${cf_cv_term_header+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+case "${cf_cv_ncurses_header}" in
+(*/ncurses.h|*/ncursesw.h)
+	cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[^.]*\.h$%term.h%'`
+	;;
+(*)
+	cf_term_header=term.h
+	;;
+esac
+
+for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
+do
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 11060 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+#include <${cf_cv_ncurses_header:-curses.h}>
+#include <$cf_test>
+
+int
+main (void)
+{
+int x = auto_left_margin; (void)x
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:11075: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:11078: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:11081: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11084: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+
+	cf_cv_term_header="$cf_test"
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+
+	cf_cv_term_header=unknown
+
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+	test "$cf_cv_term_header" != unknown && break
+done
+
+fi
+echo "$as_me:11100: result: $cf_cv_term_header" >&5
+echo "${ECHO_T}$cf_cv_term_header" >&6
+
+# Set definitions to allow ifdef'ing to accommodate subdirectories
+
+case "$cf_cv_term_header" in
+(*term.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_TERM_H 1
+EOF
+
+	;;
+esac
+
+case "$cf_cv_term_header" in
+(ncurses/term.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSES_TERM_H 1
+EOF
+
+	;;
+(ncursesw/term.h)
+
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSESW_TERM_H 1
+EOF
+
+	;;
+esac
+
 		fi
 
 	else
-		echo "$as_me:7722: result: no" >&5
+		echo "$as_me:11135: result: no" >&5
 echo "${ECHO_T}no" >&6
 		NCURSES_CONFIG_PKG=none
 	fi
@@ -7728,14 +11141,14 @@
 fi
 
 if test "x$cf_have_ncuconfig" = "xno"; then
-	echo "Looking for ${cf_ncuconfig_root}-config"
+	cf_ncurses_config="${cf_ncuconfig_root}${NCURSES_CONFIG_SUFFIX}-config"; echo "Looking for ${cf_ncurses_config}"
 
 if test -n "$ac_tool_prefix"; then
-  for ac_prog in ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
+  for ac_prog in ${cf_ncurses_config} ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:7738: checking for $ac_word" >&5
+echo "$as_me:11151: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_NCURSES_CONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7750,7 +11163,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_NCURSES_CONFIG="$ac_tool_prefix$ac_prog"
-echo "$as_me:7753: found $ac_dir/$ac_word" >&5
+echo "$as_me:11166: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -7758,10 +11171,10 @@
 fi
 NCURSES_CONFIG=$ac_cv_prog_NCURSES_CONFIG
 if test -n "$NCURSES_CONFIG"; then
-  echo "$as_me:7761: result: $NCURSES_CONFIG" >&5
+  echo "$as_me:11174: result: $NCURSES_CONFIG" >&5
 echo "${ECHO_T}$NCURSES_CONFIG" >&6
 else
-  echo "$as_me:7764: result: no" >&5
+  echo "$as_me:11177: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -7770,11 +11183,11 @@
 fi
 if test -z "$NCURSES_CONFIG"; then
   ac_ct_NCURSES_CONFIG=$NCURSES_CONFIG
-  for ac_prog in ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
+  for ac_prog in ${cf_ncurses_config} ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:7777: checking for $ac_word" >&5
+echo "$as_me:11190: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_NCURSES_CONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7789,7 +11202,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_NCURSES_CONFIG="$ac_prog"
-echo "$as_me:7792: found $ac_dir/$ac_word" >&5
+echo "$as_me:11205: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -7797,10 +11210,10 @@
 fi
 ac_ct_NCURSES_CONFIG=$ac_cv_prog_ac_ct_NCURSES_CONFIG
 if test -n "$ac_ct_NCURSES_CONFIG"; then
-  echo "$as_me:7800: result: $ac_ct_NCURSES_CONFIG" >&5
+  echo "$as_me:11213: result: $ac_ct_NCURSES_CONFIG" >&5
 echo "${ECHO_T}$ac_ct_NCURSES_CONFIG" >&6
 else
-  echo "$as_me:7803: result: no" >&5
+  echo "$as_me:11216: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -7813,27 +11226,151 @@
 
 	if test "$NCURSES_CONFIG" != none ; then
 
-		CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
-
-cf_add_libs="`$NCURSES_CONFIG --libs`"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
+for cf_add_cflags in `$NCURSES_CONFIG --cflags`
 do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+	case "x$cf_add_cflags" in
+	(x-[DU]*)
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CFLAGS" != "$cf_old_cflag" || break
+
+	CFLAGS="$cf_old_cflag"
+done
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CPPFLAGS" != "$cf_old_cflag" || break
+
+	CPPFLAGS="$cf_old_cflag"
+done
+
+		;;
+	esac
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_add_cflags
+do
+case "$cf_fix_cppflags" in
+(no)
+	case "$cf_add_cflags" in
+	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+		case "$cf_add_cflags" in
+		(-D*)
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+				&& test -z "${cf_tst_cflags}" \
+				&& cf_fix_cppflags=yes
+
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		(*$cf_add_cflags)
+			;;
+		(*)
+			case "$cf_add_cflags" in
+			(-D*)
+				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
+		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`
+
+				;;
+			esac
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
+			;;
+		esac
+		;;
+	(*)
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
+		;;
+	esac
+	;;
+(yes)
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
+
+	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+		&& test -z "${cf_tst_cflags}" \
+		&& cf_fix_cppflags=no
+	;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+done
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in `$NCURSES_CONFIG --libs`; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
 		# even with config script, some packages use no-override for curses.h
 
-echo "$as_me:7836: checking if we have identified curses headers" >&5
+echo "$as_me:11373: checking if we have identified curses headers" >&5
 echo $ECHO_N "checking if we have identified curses headers... $ECHO_C" >&6
 if test "${cf_cv_ncurses_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7844,44 +11381,44 @@
 	ncurses.h $cf_cv_screen/ncurses.h \
 	curses.h $cf_cv_screen/curses.h
 do
-cat >conftest.$ac_ext <<_ACEOF
-#line 7848 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 11385 "configure"
 #include "confdefs.h"
 #include <${cf_header}>
 int
-main ()
+main (void)
 {
-initscr(); tgoto("?", 0,0)
+initscr(); endwin()
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:7860: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:11397: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7863: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:7866: \"$ac_try\"") >&5
+  echo "$as_me:11400: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:11403: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7869: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:11406: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_ncurses_header=$cf_header; break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 done
 
 fi
-echo "$as_me:7880: result: $cf_cv_ncurses_header" >&5
+echo "$as_me:11417: result: $cf_cv_ncurses_header" >&5
 echo "${ECHO_T}$cf_cv_ncurses_header" >&6
 
 if test "$cf_cv_ncurses_header" = none ; then
-	{ { echo "$as_me:7884: error: No curses header-files found" >&5
+	{ { echo "$as_me:11421: error: No curses header-files found" >&5
 echo "$as_me: error: No curses header-files found" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -7891,24 +11428,24 @@
 for ac_header in $cf_cv_ncurses_header
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:7894: checking for $ac_header" >&5
+echo "$as_me:11431: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 7900 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 11437 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:7904: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (eval echo "$as_me:11441: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:7910: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
+  echo "$as_me:11447: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
   else
@@ -7921,14 +11458,14 @@
   eval "$as_ac_Header=yes"
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat "conftest.$ac_ext" >&5
   eval "$as_ac_Header=no"
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:7929: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
+echo "$as_me:11466: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
 EOF
@@ -7946,7 +11483,7 @@
 #define $cf_nculib_ROOT 1
 EOF
 
-				cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
+				cf_cv_ncurses_version="`$NCURSES_CONFIG --version`"
 
 	else
 
@@ -7958,9 +11495,9 @@
 if test -n "$cf_cv_curses_dir/include/$cf_ncuhdr_root" ; then
   for cf_add_incdir in $cf_cv_curses_dir/include/$cf_ncuhdr_root
   do
-	while test $cf_add_incdir != /usr/include
+	while test "$cf_add_incdir" != /usr/include
 	do
-	  if test -d $cf_add_incdir
+	  if test -d "$cf_add_incdir"
 	  then
 		cf_have_incdir=no
 		if test -n "$CFLAGS$CPPFLAGS" ; then
@@ -7977,38 +11514,41 @@
 			if test "$GCC" = yes
 			then
 			  cf_save_CPPFLAGS=$CPPFLAGS
-			  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-			  cat >conftest.$ac_ext <<_ACEOF
-#line 7982 "configure"
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-I$cf_add_incdir"
+
+			  cat >"conftest.$ac_ext" <<_ACEOF
+#line 11522 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 printf("Hello")
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:7994: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:11534: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7997: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8000: \"$ac_try\"") >&5
+  echo "$as_me:11537: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:11540: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8003: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:11543: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_have_incdir=yes
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 			  CPPFLAGS=$cf_save_CPPFLAGS
 			fi
 		  fi
@@ -8017,11 +11557,11 @@
 		if test "$cf_have_incdir" = no ; then
 		  test -n "$verbose" && echo "	adding $cf_add_incdir to include-path" 1>&6
 
-echo "${as_me:-configure}:8020: testing adding $cf_add_incdir to include-path ..." 1>&5
+echo "${as_me:-configure}:11560: testing adding $cf_add_incdir to include-path ..." 1>&5
 
 		  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 
-		  cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
+		  cf_top_incdir=`echo "$cf_add_incdir" | sed -e 's%/include/.*$%/include%'`
 		  test "$cf_top_incdir" = "$cf_add_incdir" && break
 		  cf_add_incdir="$cf_top_incdir"
 		else
@@ -8036,34 +11576,34 @@
 
 }
 
-echo "$as_me:8039: checking for $cf_ncuhdr_root header in include-path" >&5
+echo "$as_me:11579: checking for $cf_ncuhdr_root header in include-path" >&5
 echo $ECHO_N "checking for $cf_ncuhdr_root header in include-path... $ECHO_C" >&6
 if test "${cf_cv_ncurses_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
-	( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
+	{ test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw; } && cf_header_list="$cf_header_list curses.h ncurses.h"
 	for cf_header in $cf_header_list
 	do
 
-	cat >conftest.$ac_ext <<_ACEOF
-#line 8051 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 11591 "configure"
 #include "confdefs.h"
 
 #include <$cf_header>
 int
-main ()
+main (void)
 {
 
 #ifdef NCURSES_VERSION
 
-printf("%s\n", NCURSES_VERSION);
+printf("%s\\n", NCURSES_VERSION);
 #else
 #ifdef __NCURSES_H
-printf("old\n");
+printf("old\\n");
 #else
-	make an error
+	#error __NCURSES_H is not defined
 #endif
 #endif
 
@@ -8071,39 +11611,39 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8075: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:11615: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8078: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8081: \"$ac_try\"") >&5
+  echo "$as_me:11618: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:11621: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8084: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:11624: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_ncurses_h=$cf_header
 
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_ncurses_h=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 		test "$cf_cv_ncurses_h" != no && break
 	done
 
 fi
-echo "$as_me:8099: result: $cf_cv_ncurses_h" >&5
+echo "$as_me:11639: result: $cf_cv_ncurses_h" >&5
 echo "${ECHO_T}$cf_cv_ncurses_h" >&6
 
 if test "$cf_cv_ncurses_h" != no ; then
 	cf_cv_ncurses_header=$cf_cv_ncurses_h
 else
 
-echo "$as_me:8106: checking for $cf_ncuhdr_root include-path" >&5
+echo "$as_me:11646: checking for $cf_ncuhdr_root include-path" >&5
 echo $ECHO_N "checking for $cf_ncuhdr_root include-path... $ECHO_C" >&6
 if test "${cf_cv_ncurses_h2+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8118,7 +11658,7 @@
 if test -n "${CFLAGS}${CPPFLAGS}" ; then
 	for cf_header_path in $CPPFLAGS $CFLAGS
 	do
-		case $cf_header_path in
+		case "$cf_header_path" in
 		(-I*)
 			cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
 
@@ -8126,11 +11666,11 @@
 test -d "$cf_header_path" && \
  {
 	test -n "$verbose" && echo "	... testing for include-directories under $cf_header_path"
-	test -d $cf_header_path/include &&          cf_search="$cf_search $cf_header_path/include"
-	test -d $cf_header_path/include/$cf_ncuhdr_root &&       cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root"
-	test -d $cf_header_path/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root/include"
-	test -d $cf_header_path/$cf_ncuhdr_root/include &&       cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include"
-	test -d $cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
+	test -d "$cf_header_path/include" &&          cf_search="$cf_search $cf_header_path/include"
+	test -d "$cf_header_path/include/$cf_ncuhdr_root" &&       cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root"
+	test -d "$cf_header_path/include/$cf_ncuhdr_root/include" &&    cf_search="$cf_search $cf_header_path/include/$cf_ncuhdr_root/include"
+	test -d "$cf_header_path/$cf_ncuhdr_root/include" &&       cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include"
+	test -d "$cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root" &&    cf_search="$cf_search $cf_header_path/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
 }
 
 			cf_header_path_list="$cf_header_path_list $cf_search"
@@ -8147,11 +11687,11 @@
 test -d "$prefix" && \
  {
 	test -n "$verbose" && echo "	... testing for include-directories under $prefix"
-	test -d $prefix/include &&          cf_search="$cf_search $prefix/include"
-	test -d $prefix/include/$cf_ncuhdr_root &&       cf_search="$cf_search $prefix/include/$cf_ncuhdr_root"
-	test -d $prefix/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $prefix/include/$cf_ncuhdr_root/include"
-	test -d $prefix/$cf_ncuhdr_root/include &&       cf_search="$cf_search $prefix/$cf_ncuhdr_root/include"
-	test -d $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
+	test -d "$prefix/include" &&          cf_search="$cf_search $prefix/include"
+	test -d "$prefix/include/$cf_ncuhdr_root" &&       cf_search="$cf_search $prefix/include/$cf_ncuhdr_root"
+	test -d "$prefix/include/$cf_ncuhdr_root/include" &&    cf_search="$cf_search $prefix/include/$cf_ncuhdr_root/include"
+	test -d "$prefix/$cf_ncuhdr_root/include" &&       cf_search="$cf_search $prefix/$cf_ncuhdr_root/include"
+	test -d "$prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root" &&    cf_search="$cf_search $prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
 }
 
 for cf_subdir_prefix in \
@@ -8165,13 +11705,13 @@
 
 test "x$cf_subdir_prefix" != "x$prefix" && \
 test -d "$cf_subdir_prefix" && \
-(test -z "$prefix" || test x$prefix = xNONE || test "x$cf_subdir_prefix" != "x$prefix") && {
+{ test -z "$prefix" || test "x$prefix" = xNONE || test "x$cf_subdir_prefix" != "x$prefix"; } && {
 	test -n "$verbose" && echo "	... testing for include-directories under $cf_subdir_prefix"
-	test -d $cf_subdir_prefix/include &&          cf_search="$cf_search $cf_subdir_prefix/include"
-	test -d $cf_subdir_prefix/include/$cf_ncuhdr_root &&       cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root"
-	test -d $cf_subdir_prefix/include/$cf_ncuhdr_root/include &&    cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root/include"
-	test -d $cf_subdir_prefix/$cf_ncuhdr_root/include &&       cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include"
-	test -d $cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root &&    cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
+	test -d "$cf_subdir_prefix/include" &&          cf_search="$cf_search $cf_subdir_prefix/include"
+	test -d "$cf_subdir_prefix/include/$cf_ncuhdr_root" &&       cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root"
+	test -d "$cf_subdir_prefix/include/$cf_ncuhdr_root/include" &&    cf_search="$cf_search $cf_subdir_prefix/include/$cf_ncuhdr_root/include"
+	test -d "$cf_subdir_prefix/$cf_ncuhdr_root/include" &&       cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include"
+	test -d "$cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root" &&    cf_search="$cf_search $cf_subdir_prefix/$cf_ncuhdr_root/include/$cf_ncuhdr_root"
 }
 
 done
@@ -8179,20 +11719,20 @@
 test "$includedir" != NONE && \
 test "$includedir" != "/usr/include" && \
 test -d "$includedir" && {
-	test -d $includedir &&    cf_search="$cf_search $includedir"
-	test -d $includedir/$cf_ncuhdr_root && cf_search="$cf_search $includedir/$cf_ncuhdr_root"
+	test -d "$includedir" &&    cf_search="$cf_search $includedir"
+	test -d "$includedir/$cf_ncuhdr_root" && cf_search="$cf_search $includedir/$cf_ncuhdr_root"
 }
 
 test "$oldincludedir" != NONE && \
 test "$oldincludedir" != "/usr/include" && \
 test -d "$oldincludedir" && {
-	test -d $oldincludedir    && cf_search="$cf_search $oldincludedir"
-	test -d $oldincludedir/$cf_ncuhdr_root && cf_search="$cf_search $oldincludedir/$cf_ncuhdr_root"
+	test -d "$oldincludedir"    && cf_search="$cf_search $oldincludedir"
+	test -d "$oldincludedir/$cf_ncuhdr_root" && cf_search="$cf_search $oldincludedir/$cf_ncuhdr_root"
 }
 
 cf_search="$cf_search $cf_header_path_list"
 
-	test -n "$verbose" && echo search path $cf_search
+	test -n "$verbose" && echo "search path $cf_search"
 	cf_save2_CPPFLAGS="$CPPFLAGS"
 	for cf_incdir in $cf_search
 	do
@@ -8200,9 +11740,9 @@
 if test -n "$cf_incdir" ; then
   for cf_add_incdir in $cf_incdir
   do
-	while test $cf_add_incdir != /usr/include
+	while test "$cf_add_incdir" != /usr/include
 	do
-	  if test -d $cf_add_incdir
+	  if test -d "$cf_add_incdir"
 	  then
 		cf_have_incdir=no
 		if test -n "$CFLAGS$CPPFLAGS" ; then
@@ -8219,38 +11759,41 @@
 			if test "$GCC" = yes
 			then
 			  cf_save_CPPFLAGS=$CPPFLAGS
-			  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-			  cat >conftest.$ac_ext <<_ACEOF
-#line 8224 "configure"
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-I$cf_add_incdir"
+
+			  cat >"conftest.$ac_ext" <<_ACEOF
+#line 11767 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 printf("Hello")
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8236: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:11779: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8239: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8242: \"$ac_try\"") >&5
+  echo "$as_me:11782: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:11785: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8245: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:11788: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_have_incdir=yes
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 			  CPPFLAGS=$cf_save_CPPFLAGS
 			fi
 		  fi
@@ -8259,11 +11802,11 @@
 		if test "$cf_have_incdir" = no ; then
 		  test -n "$verbose" && echo "	adding $cf_add_incdir to include-path" 1>&6
 
-echo "${as_me:-configure}:8262: testing adding $cf_add_incdir to include-path ..." 1>&5
+echo "${as_me:-configure}:11805: testing adding $cf_add_incdir to include-path ..." 1>&5
 
 		  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 
-		  cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
+		  cf_top_incdir=`echo "$cf_add_incdir" | sed -e 's%/include/.*$%/include%'`
 		  test "$cf_top_incdir" = "$cf_add_incdir" && break
 		  cf_add_incdir="$cf_top_incdir"
 		else
@@ -8281,23 +11824,23 @@
 			curses.h
 		do
 
-	cat >conftest.$ac_ext <<_ACEOF
-#line 8285 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 11828 "configure"
 #include "confdefs.h"
 
 #include <$cf_header>
 int
-main ()
+main (void)
 {
 
 #ifdef NCURSES_VERSION
 
-printf("%s\n", NCURSES_VERSION);
+printf("%s\\n", NCURSES_VERSION);
 #else
 #ifdef __NCURSES_H
-printf("old\n");
+printf("old\\n");
 #else
-	make an error
+	#error __NCURSES_H is not defined
 #endif
 #endif
 
@@ -8305,30 +11848,30 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8309: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:11852: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8312: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8315: \"$ac_try\"") >&5
+  echo "$as_me:11855: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:11858: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8318: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:11861: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_ncurses_h2=$cf_header
 
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_ncurses_h2=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 			if test "$cf_cv_ncurses_h2" != no ; then
 				cf_cv_ncurses_h2=$cf_incdir/$cf_header
-				test -n "$verbose" && echo $ac_n "	... found $ac_c" 1>&6
+				test -n "$verbose" && echo $ECHO_N "	... found $ECHO_C" 1>&6
 				break
 			fi
 			test -n "$verbose" && echo "	... tested $cf_incdir/$cf_header" 1>&6
@@ -8336,26 +11879,26 @@
 		CPPFLAGS="$cf_save2_CPPFLAGS"
 		test "$cf_cv_ncurses_h2" != no && break
 	done
-	test "$cf_cv_ncurses_h2" = no && { { echo "$as_me:8339: error: not found" >&5
+	test "$cf_cv_ncurses_h2" = no && { { echo "$as_me:11882: error: not found" >&5
 echo "$as_me: error: not found" >&2;}
    { (exit 1); exit 1; }; }
 
 fi
-echo "$as_me:8344: result: $cf_cv_ncurses_h2" >&5
+echo "$as_me:11887: result: $cf_cv_ncurses_h2" >&5
 echo "${ECHO_T}$cf_cv_ncurses_h2" >&6
 
-	cf_1st_incdir=`echo $cf_cv_ncurses_h2 | sed -e 's%/[^/]*$%%'`
-	cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
-	if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
-		cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
+	cf_1st_incdir=`echo "$cf_cv_ncurses_h2" | sed -e 's%/[^/]*$%%'`
+	cf_cv_ncurses_header="`basename "$cf_cv_ncurses_h2"`"
+	if test "`basename "$cf_1st_incdir"`" = "$cf_ncuhdr_root" ; then
+		cf_cv_ncurses_header="$cf_ncuhdr_root/$cf_cv_ncurses_header"
 	fi
 
 if test -n "$cf_1st_incdir" ; then
   for cf_add_incdir in $cf_1st_incdir
   do
-	while test $cf_add_incdir != /usr/include
+	while test "$cf_add_incdir" != /usr/include
 	do
-	  if test -d $cf_add_incdir
+	  if test -d "$cf_add_incdir"
 	  then
 		cf_have_incdir=no
 		if test -n "$CFLAGS$CPPFLAGS" ; then
@@ -8372,38 +11915,41 @@
 			if test "$GCC" = yes
 			then
 			  cf_save_CPPFLAGS=$CPPFLAGS
-			  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
-			  cat >conftest.$ac_ext <<_ACEOF
-#line 8377 "configure"
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-I$cf_add_incdir"
+
+			  cat >"conftest.$ac_ext" <<_ACEOF
+#line 11923 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 printf("Hello")
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8389: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:11935: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8392: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8395: \"$ac_try\"") >&5
+  echo "$as_me:11938: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:11941: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8398: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:11944: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_have_incdir=yes
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 			  CPPFLAGS=$cf_save_CPPFLAGS
 			fi
 		  fi
@@ -8412,11 +11958,11 @@
 		if test "$cf_have_incdir" = no ; then
 		  test -n "$verbose" && echo "	adding $cf_add_incdir to include-path" 1>&6
 
-echo "${as_me:-configure}:8415: testing adding $cf_add_incdir to include-path ..." 1>&5
+echo "${as_me:-configure}:11961: testing adding $cf_add_incdir to include-path ..." 1>&5
 
 		  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 
-		  cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
+		  cf_top_incdir=`echo "$cf_add_incdir" | sed -e 's%/include/.*$%/include%'`
 		  test "$cf_top_incdir" = "$cf_add_incdir" && break
 		  cf_add_incdir="$cf_top_incdir"
 		else
@@ -8433,7 +11979,7 @@
 
 # Set definitions to allow ifdef'ing for ncurses.h
 
-case $cf_cv_ncurses_header in
+case "$cf_cv_ncurses_header" in
 (*ncurses.h)
 
 cat >>confdefs.h <<\EOF
@@ -8443,7 +11989,7 @@
 	;;
 esac
 
-case $cf_cv_ncurses_header in
+case "$cf_cv_ncurses_header" in
 (ncurses/curses.h|ncurses/ncurses.h)
 
 cat >>confdefs.h <<\EOF
@@ -8460,13 +12006,13 @@
 	;;
 esac
 
-echo "$as_me:8463: checking for terminfo header" >&5
+echo "$as_me:12009: checking for terminfo header" >&5
 echo $ECHO_N "checking for terminfo header... $ECHO_C" >&6
 if test "${cf_cv_term_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-case ${cf_cv_ncurses_header} in
+case "${cf_cv_ncurses_header}" in
 (*/ncurses.h|*/ncursesw.h)
 	cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[^.]*\.h$%term.h%'`
 	;;
@@ -8477,53 +12023,53 @@
 
 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
 do
-cat >conftest.$ac_ext <<_ACEOF
-#line 8481 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 12027 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #include <${cf_cv_ncurses_header:-curses.h}>
 #include <$cf_test>
 
 int
-main ()
+main (void)
 {
-int x = auto_left_margin
+int x = auto_left_margin; (void)x
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8496: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:12042: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8499: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8502: \"$ac_try\"") >&5
+  echo "$as_me:12045: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:12048: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8505: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:12051: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
 
 	cf_cv_term_header="$cf_test"
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 
 	cf_cv_term_header=unknown
 
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 	test "$cf_cv_term_header" != unknown && break
 done
 
 fi
-echo "$as_me:8521: result: $cf_cv_term_header" >&5
+echo "$as_me:12067: result: $cf_cv_term_header" >&5
 echo "${ECHO_T}$cf_cv_term_header" >&6
 
 # Set definitions to allow ifdef'ing to accommodate subdirectories
 
-case $cf_cv_term_header in
+case "$cf_cv_term_header" in
 (*term.h)
 
 cat >>confdefs.h <<\EOF
@@ -8533,7 +12079,7 @@
 	;;
 esac
 
-case $cf_cv_term_header in
+case "$cf_cv_term_header" in
 (ncurses/term.h)
 
 cat >>confdefs.h <<\EOF
@@ -8556,7 +12102,7 @@
 #define NCURSES 1
 EOF
 
-echo "$as_me:8559: checking for ncurses version" >&5
+echo "$as_me:12105: checking for ncurses version" >&5
 echo $ECHO_N "checking for ncurses version... $ECHO_C" >&6
 if test "${cf_cv_ncurses_version+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8564,12 +12110,12 @@
 
 	cf_cv_ncurses_version=no
 	cf_tempfile=out$$
-	rm -f $cf_tempfile
+	rm -f "$cf_tempfile"
 	if test "$cross_compiling" = yes; then
 
 	# This will not work if the preprocessor splits the line after the
 	# Autoconf token.  The 'unproto' program does that.
-	cat > conftest.$ac_ext <<EOF
+	cat > "conftest.$ac_ext" <<EOF
 #include <${cf_cv_ncurses_header:-curses.h}>
 #undef Autoconf
 #ifdef NCURSES_VERSION
@@ -8582,67 +12128,69 @@
 #endif
 EOF
 	cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
-	{ (eval echo "$as_me:8585: \"$cf_try\"") >&5
+	{ (eval echo "$as_me:12131: \"$cf_try\"") >&5
   (eval $cf_try) 2>&5
   ac_status=$?
-  echo "$as_me:8588: \$? = $ac_status" >&5
-  (exit $ac_status); }
+  echo "$as_me:12134: \$? = $ac_status" >&5
+  (exit "$ac_status"); }
 	if test -f conftest.out ; then
-		cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
+		cf_out=`sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%' conftest.out`
 		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
 		rm -f conftest.out
 	fi
 
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 8598 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 12144 "configure"
 #include "confdefs.h"
 
+$ac_includes_default
+
 #include <${cf_cv_ncurses_header:-curses.h}>
-#include <stdio.h>
-int main()
+
+int main(void)
 {
 	FILE *fp = fopen("$cf_tempfile", "w");
 #ifdef NCURSES_VERSION
 # ifdef NCURSES_VERSION_PATCH
-	fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
+	fprintf(fp, "%s.%d\\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
 # else
-	fprintf(fp, "%s\n", NCURSES_VERSION);
+	fprintf(fp, "%s\\n", NCURSES_VERSION);
 # endif
 #else
 # ifdef __NCURSES_H
-	fprintf(fp, "old\n");
+	fprintf(fp, "old\\n");
 # else
-	make an error
+	#error expected ncurses header to define __NCURSES_H
 # endif
 #endif
 	${cf_cv_main_return:-return}(0);
 }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:8623: \"$ac_link\"") >&5
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:12171: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8626: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:8628: \"$ac_try\"") >&5
+  echo "$as_me:12174: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:12176: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8631: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:12179: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
 
 	cf_cv_ncurses_version=`cat $cf_tempfile`
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-	rm -f $cf_tempfile
+	rm -f "$cf_tempfile"
 
 fi
-echo "$as_me:8645: result: $cf_cv_ncurses_version" >&5
+echo "$as_me:12193: result: $cf_cv_ncurses_version" >&5
 echo "${ECHO_T}$cf_cv_ncurses_version" >&6
 test "$cf_cv_ncurses_version" = no ||
 cat >>confdefs.h <<\EOF
@@ -8655,15 +12203,15 @@
 	# to link gpm.
 cf_ncurses_LIBS=""
 cf_ncurses_SAVE="$LIBS"
-echo "$as_me:8658: checking for Gpm_Open in -lgpm" >&5
+echo "$as_me:12206: checking for Gpm_Open in -lgpm" >&5
 echo $ECHO_N "checking for Gpm_Open in -lgpm... $ECHO_C" >&6
 if test "${ac_cv_lib_gpm_Gpm_Open+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lgpm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 8666 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 12214 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -8672,48 +12220,48 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char Gpm_Open ();
+char Gpm_Open (void);
 int
-main ()
+main (void)
 {
 Gpm_Open ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8685: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:12233: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8688: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8691: \"$ac_try\"") >&5
+  echo "$as_me:12236: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:12239: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8694: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:12242: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_gpm_Gpm_Open=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_gpm_Gpm_Open=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:8705: result: $ac_cv_lib_gpm_Gpm_Open" >&5
+echo "$as_me:12253: result: $ac_cv_lib_gpm_Gpm_Open" >&5
 echo "${ECHO_T}$ac_cv_lib_gpm_Gpm_Open" >&6
-if test $ac_cv_lib_gpm_Gpm_Open = yes; then
-  echo "$as_me:8708: checking for initscr in -lgpm" >&5
+if test "$ac_cv_lib_gpm_Gpm_Open" = yes; then
+  echo "$as_me:12256: checking for initscr in -lgpm" >&5
 echo $ECHO_N "checking for initscr in -lgpm... $ECHO_C" >&6
 if test "${ac_cv_lib_gpm_initscr+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lgpm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 8716 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 12264 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -8722,39 +12270,39 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char initscr ();
+char initscr (void);
 int
-main ()
+main (void)
 {
 initscr ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8735: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:12283: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8738: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8741: \"$ac_try\"") >&5
+  echo "$as_me:12286: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:12289: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8744: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:12292: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_gpm_initscr=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_gpm_initscr=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:8755: result: $ac_cv_lib_gpm_initscr" >&5
+echo "$as_me:12303: result: $ac_cv_lib_gpm_initscr" >&5
 echo "${ECHO_T}$ac_cv_lib_gpm_initscr" >&6
-if test $ac_cv_lib_gpm_initscr = yes; then
+if test "$ac_cv_lib_gpm_initscr" = yes; then
   LIBS="$cf_ncurses_SAVE"
 else
   cf_ncurses_LIBS="-lgpm"
@@ -8762,20 +12310,20 @@
 
 fi
 
-case $host_os in
+case "$host_os" in
 (freebsd*)
 	# This is only necessary if you are linking against an obsolete
-	# version of ncurses (but it should do no harm, since it's static).
+	# version of ncurses (but it should do no harm, since it is static).
 	if test "$cf_nculib_root" = ncurses ; then
-		echo "$as_me:8770: checking for tgoto in -lmytinfo" >&5
+		echo "$as_me:12318: checking for tgoto in -lmytinfo" >&5
 echo $ECHO_N "checking for tgoto in -lmytinfo... $ECHO_C" >&6
 if test "${ac_cv_lib_mytinfo_tgoto+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lmytinfo  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 8778 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 12326 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -8784,39 +12332,39 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char tgoto ();
+char tgoto (void);
 int
-main ()
+main (void)
 {
 tgoto ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8797: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:12345: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8800: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8803: \"$ac_try\"") >&5
+  echo "$as_me:12348: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:12351: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8806: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:12354: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_mytinfo_tgoto=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_mytinfo_tgoto=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:8817: result: $ac_cv_lib_mytinfo_tgoto" >&5
+echo "$as_me:12365: result: $ac_cv_lib_mytinfo_tgoto" >&5
 echo "${ECHO_T}$ac_cv_lib_mytinfo_tgoto" >&6
-if test $ac_cv_lib_mytinfo_tgoto = yes; then
+if test "$ac_cv_lib_mytinfo_tgoto" = yes; then
   cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"
 fi
 
@@ -8824,143 +12372,143 @@
 	;;
 esac
 
-cf_add_libs="$cf_ncurses_LIBS"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_ncurses_LIBS; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
-if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
+if test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no"
 then
 
-cf_add_libs="-l$cf_nculib_root"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -l$cf_nculib_root; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
 else
 
-	eval 'cf_cv_have_lib_'$cf_nculib_root'=no'
+	eval 'cf_cv_have_lib_'"$cf_nculib_root"'=no'
 	cf_libdir=""
-	echo "$as_me:8866: checking for initscr" >&5
+	echo "$as_me:12414: checking for initscr" >&5
 echo $ECHO_N "checking for initscr... $ECHO_C" >&6
 if test "${ac_cv_func_initscr+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 8872 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 12420 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char initscr (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
+#define initscr autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef initscr
+
 #ifdef __cplusplus
 extern "C"
 #endif
+
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char initscr ();
-char (*f) ();
+char initscr (void);
 
 int
-main ()
+main (void)
 {
-/* The GNU C library defines this for functions which it implements
+
+/* The GNU C library defines stubs for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined (__stub_initscr) || defined (__stub___initscr)
-choke me
-#else
-f = initscr; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#error found stub for initscr
 #endif
 
+	return initscr ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8903: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:12451: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8906: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8909: \"$ac_try\"") >&5
+  echo "$as_me:12454: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:12457: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8912: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:12460: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_func_initscr=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_func_initscr=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:8922: result: $ac_cv_func_initscr" >&5
+echo "$as_me:12470: result: $ac_cv_func_initscr" >&5
 echo "${ECHO_T}$ac_cv_func_initscr" >&6
-if test $ac_cv_func_initscr = yes; then
-  eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
+if test "$ac_cv_func_initscr" = yes; then
+  eval 'cf_cv_have_lib_'"$cf_nculib_root"'=yes'
 else
 
 		cf_save_LIBS="$LIBS"
-		echo "$as_me:8929: checking for initscr in -l$cf_nculib_root" >&5
+		echo "$as_me:12477: checking for initscr in -l$cf_nculib_root" >&5
 echo $ECHO_N "checking for initscr in -l$cf_nculib_root... $ECHO_C" >&6
 		LIBS="-l$cf_nculib_root $LIBS"
-		cat >conftest.$ac_ext <<_ACEOF
-#line 8933 "configure"
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 12481 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 initscr()
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8945: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:12493: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8948: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8951: \"$ac_try\"") >&5
+  echo "$as_me:12496: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:12499: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8954: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  echo "$as_me:8956: result: yes" >&5
+  echo "$as_me:12502: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  echo "$as_me:12504: result: yes" >&5
 echo "${ECHO_T}yes" >&6
-			 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
+			 eval 'cf_cv_have_lib_'"$cf_nculib_root"'=yes'
 
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-echo "$as_me:8963: result: no" >&5
+cat "conftest.$ac_ext" >&5
+echo "$as_me:12511: result: no" >&5
 echo "${ECHO_T}no" >&6
 
 cf_search=
@@ -8968,7 +12516,7 @@
 if test -n "${LDFLAGS}${LIBS}" ; then
 	for cf_library_path in $LDFLAGS $LIBS
 	do
-		case $cf_library_path in
+		case "$cf_library_path" in
 		(-L*)
 			cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
 
@@ -8976,11 +12524,11 @@
 test -d "$cf_library_path" && \
  {
 	test -n "$verbose" && echo "	... testing for lib-directories under $cf_library_path"
-	test -d $cf_library_path/lib &&          cf_search="$cf_search $cf_library_path/lib"
-	test -d $cf_library_path/lib/$cf_nculib_root &&       cf_search="$cf_search $cf_library_path/lib/$cf_nculib_root"
-	test -d $cf_library_path/lib/$cf_nculib_root/lib &&    cf_search="$cf_search $cf_library_path/lib/$cf_nculib_root/lib"
-	test -d $cf_library_path/$cf_nculib_root/lib &&       cf_search="$cf_search $cf_library_path/$cf_nculib_root/lib"
-	test -d $cf_library_path/$cf_nculib_root/lib/$cf_nculib_root &&    cf_search="$cf_search $cf_library_path/$cf_nculib_root/lib/$cf_nculib_root"
+	test -d "$cf_library_path/lib" &&          cf_search="$cf_search $cf_library_path/lib"
+	test -d "$cf_library_path/lib/$cf_nculib_root" &&       cf_search="$cf_search $cf_library_path/lib/$cf_nculib_root"
+	test -d "$cf_library_path/lib/$cf_nculib_root/lib" &&    cf_search="$cf_search $cf_library_path/lib/$cf_nculib_root/lib"
+	test -d "$cf_library_path/$cf_nculib_root/lib" &&       cf_search="$cf_search $cf_library_path/$cf_nculib_root/lib"
+	test -d "$cf_library_path/$cf_nculib_root/lib/$cf_nculib_root" &&    cf_search="$cf_search $cf_library_path/$cf_nculib_root/lib/$cf_nculib_root"
 }
 
 			cf_library_path_list="$cf_library_path_list $cf_search"
@@ -8995,11 +12543,11 @@
 test -d "$prefix" && \
  {
 	test -n "$verbose" && echo "	... testing for lib-directories under $prefix"
-	test -d $prefix/lib &&          cf_search="$cf_search $prefix/lib"
-	test -d $prefix/lib/$cf_nculib_root &&       cf_search="$cf_search $prefix/lib/$cf_nculib_root"
-	test -d $prefix/lib/$cf_nculib_root/lib &&    cf_search="$cf_search $prefix/lib/$cf_nculib_root/lib"
-	test -d $prefix/$cf_nculib_root/lib &&       cf_search="$cf_search $prefix/$cf_nculib_root/lib"
-	test -d $prefix/$cf_nculib_root/lib/$cf_nculib_root &&    cf_search="$cf_search $prefix/$cf_nculib_root/lib/$cf_nculib_root"
+	test -d "$prefix/lib" &&          cf_search="$cf_search $prefix/lib"
+	test -d "$prefix/lib/$cf_nculib_root" &&       cf_search="$cf_search $prefix/lib/$cf_nculib_root"
+	test -d "$prefix/lib/$cf_nculib_root/lib" &&    cf_search="$cf_search $prefix/lib/$cf_nculib_root/lib"
+	test -d "$prefix/$cf_nculib_root/lib" &&       cf_search="$cf_search $prefix/$cf_nculib_root/lib"
+	test -d "$prefix/$cf_nculib_root/lib/$cf_nculib_root" &&    cf_search="$cf_search $prefix/$cf_nculib_root/lib/$cf_nculib_root"
 }
 
 for cf_subdir_prefix in \
@@ -9013,13 +12561,13 @@
 
 test "x$cf_subdir_prefix" != "x$prefix" && \
 test -d "$cf_subdir_prefix" && \
-(test -z "$prefix" || test x$prefix = xNONE || test "x$cf_subdir_prefix" != "x$prefix") && {
+{ test -z "$prefix" || test "x$prefix" = xNONE || test "x$cf_subdir_prefix" != "x$prefix"; } && {
 	test -n "$verbose" && echo "	... testing for lib-directories under $cf_subdir_prefix"
-	test -d $cf_subdir_prefix/lib &&          cf_search="$cf_search $cf_subdir_prefix/lib"
-	test -d $cf_subdir_prefix/lib/$cf_nculib_root &&       cf_search="$cf_search $cf_subdir_prefix/lib/$cf_nculib_root"
-	test -d $cf_subdir_prefix/lib/$cf_nculib_root/lib &&    cf_search="$cf_search $cf_subdir_prefix/lib/$cf_nculib_root/lib"
-	test -d $cf_subdir_prefix/$cf_nculib_root/lib &&       cf_search="$cf_search $cf_subdir_prefix/$cf_nculib_root/lib"
-	test -d $cf_subdir_prefix/$cf_nculib_root/lib/$cf_nculib_root &&    cf_search="$cf_search $cf_subdir_prefix/$cf_nculib_root/lib/$cf_nculib_root"
+	test -d "$cf_subdir_prefix/lib" &&          cf_search="$cf_search $cf_subdir_prefix/lib"
+	test -d "$cf_subdir_prefix/lib/$cf_nculib_root" &&       cf_search="$cf_search $cf_subdir_prefix/lib/$cf_nculib_root"
+	test -d "$cf_subdir_prefix/lib/$cf_nculib_root/lib" &&    cf_search="$cf_search $cf_subdir_prefix/lib/$cf_nculib_root/lib"
+	test -d "$cf_subdir_prefix/$cf_nculib_root/lib" &&       cf_search="$cf_search $cf_subdir_prefix/$cf_nculib_root/lib"
+	test -d "$cf_subdir_prefix/$cf_nculib_root/lib/$cf_nculib_root" &&    cf_search="$cf_search $cf_subdir_prefix/$cf_nculib_root/lib/$cf_nculib_root"
 }
 
 done
@@ -9028,56 +12576,56 @@
 
 			for cf_libdir in $cf_search
 			do
-				echo "$as_me:9031: checking for -l$cf_nculib_root in $cf_libdir" >&5
+				echo "$as_me:12579: checking for -l$cf_nculib_root in $cf_libdir" >&5
 echo $ECHO_N "checking for -l$cf_nculib_root in $cf_libdir... $ECHO_C" >&6
 				LIBS="-L$cf_libdir -l$cf_nculib_root $cf_save_LIBS"
-				cat >conftest.$ac_ext <<_ACEOF
-#line 9035 "configure"
+				cat >"conftest.$ac_ext" <<_ACEOF
+#line 12583 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 initscr()
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9047: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:12595: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9050: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9053: \"$ac_try\"") >&5
+  echo "$as_me:12598: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:12601: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9056: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  echo "$as_me:9058: result: yes" >&5
+  echo "$as_me:12604: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  echo "$as_me:12606: result: yes" >&5
 echo "${ECHO_T}yes" >&6
-			 		 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
+			 		 eval 'cf_cv_have_lib_'"$cf_nculib_root"'=yes'
 					 break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-echo "$as_me:9065: result: no" >&5
+cat "conftest.$ac_ext" >&5
+echo "$as_me:12613: result: no" >&5
 echo "${ECHO_T}no" >&6
 					 LIBS="$cf_save_LIBS"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 			done
 
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 fi
 
-eval 'cf_found_library=$cf_cv_have_lib_'$cf_nculib_root
+eval 'cf_found_library="$cf_cv_have_lib_'"$cf_nculib_root"\"
 
-if test $cf_found_library = no ; then
-	{ { echo "$as_me:9080: error: Cannot link $cf_nculib_root library" >&5
+if test "$cf_found_library" = no ; then
+	{ { echo "$as_me:12628: error: Cannot link $cf_nculib_root library" >&5
 echo "$as_me: error: Cannot link $cf_nculib_root library" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -9085,49 +12633,49 @@
 fi
 
 if test -n "$cf_ncurses_LIBS" ; then
-	echo "$as_me:9088: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
+	echo "$as_me:12636: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
 echo $ECHO_N "checking if we can link $cf_nculib_root without $cf_ncurses_LIBS... $ECHO_C" >&6
 	cf_ncurses_SAVE="$LIBS"
 	for p in $cf_ncurses_LIBS ; do
-		q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
+		q=`echo "$LIBS" | sed -e "s%$p %%" -e "s%$p$%%"`
 		if test "$q" != "$LIBS" ; then
 			LIBS="$q"
 		fi
 	done
-	cat >conftest.$ac_ext <<_ACEOF
-#line 9098 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 12646 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
+initscr(); mousemask(0,0); tigetstr((char *)0);
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9110: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:12658: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9113: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9116: \"$ac_try\"") >&5
+  echo "$as_me:12661: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:12664: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9119: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  echo "$as_me:9121: result: yes" >&5
+  echo "$as_me:12667: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  echo "$as_me:12669: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-echo "$as_me:9126: result: no" >&5
+cat "conftest.$ac_ext" >&5
+echo "$as_me:12674: result: no" >&5
 echo "${ECHO_T}no" >&6
 		 LIBS="$cf_ncurses_SAVE"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
 
 cf_nculib_ROOT=`echo "HAVE_LIB$cf_nculib_root" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
@@ -9143,7 +12691,7 @@
 
 	;;
 (pdcurses)
-	echo "$as_me:9146: checking for X" >&5
+	echo "$as_me:12694: checking for X" >&5
 echo $ECHO_N "checking for X... $ECHO_C" >&6
 
 # Check whether --with-x or --without-x was given.
@@ -9175,11 +12723,11 @@
 EOF
   if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
     # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
-    eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
+    eval "`${MAKE-make} acfindx 2>/dev/null | grep -v make`"
     # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
     for ac_extension in a so sl dylib dll; do
-      if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
-         test -f $ac_im_libdir/libX11.$ac_extension; then
+      if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" &&
+         test -f "$ac_im_libdir/libX11.$ac_extension"; then
         ac_im_usrlibdir=$ac_im_libdir; break
       fi
     done
@@ -9203,21 +12751,28 @@
 # Check X11 before X11Rn because it is often a symlink to the current release.
 ac_x_header_dirs='
 /usr/X11/include
+/usr/X11R7/include
 /usr/X11R6/include
 /usr/X11R5/include
 /usr/X11R4/include
 
+/opt/local/include
+/opt/X11/include
+
 /usr/include/X11
+/usr/include/X11R7
 /usr/include/X11R6
 /usr/include/X11R5
 /usr/include/X11R4
 
 /usr/local/X11/include
+/usr/local/X11R7/include
 /usr/local/X11R6/include
 /usr/local/X11R5/include
 /usr/local/X11R4/include
 
 /usr/local/include/X11
+/usr/local/include/X11R7
 /usr/local/include/X11R6
 /usr/local/include/X11R5
 /usr/local/include/X11R4
@@ -9239,19 +12794,19 @@
 if test "$ac_x_includes" = no; then
   # Guess where to find include files, by looking for Intrinsic.h.
   # First, try using that file with no special directory specified.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 9243 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 12798 "configure"
 #include "confdefs.h"
 #include <X11/Intrinsic.h>
 _ACEOF
-if { (eval echo "$as_me:9247: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (eval echo "$as_me:12802: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:9253: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
+  echo "$as_me:12808: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
   else
@@ -9265,7 +12820,7 @@
 ac_x_includes=
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat "conftest.$ac_ext" >&5
   for ac_dir in $ac_x_header_dirs; do
   if test -r "$ac_dir/X11/Intrinsic.h"; then
     ac_x_includes=$ac_dir
@@ -9273,7 +12828,7 @@
   fi
 done
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 fi # $ac_x_includes = no
 
 if test "$ac_x_libraries" = no; then
@@ -9282,49 +12837,49 @@
   # Don't add to $LIBS permanently.
   ac_save_LIBS=$LIBS
   LIBS="-lXt $LIBS"
-  cat >conftest.$ac_ext <<_ACEOF
-#line 9286 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 12841 "configure"
 #include "confdefs.h"
 #include <X11/Intrinsic.h>
 int
-main ()
+main (void)
 {
 XtMalloc (0)
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9298: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:12853: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9301: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9304: \"$ac_try\"") >&5
+  echo "$as_me:12856: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:12859: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9307: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:12862: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   LIBS=$ac_save_LIBS
 # We can link X programs with no special library path.
 ac_x_libraries=
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 LIBS=$ac_save_LIBS
 for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
 do
   # Don't even attempt the hair of trying to link an X program!
   for ac_extension in a so sl dylib dll; do
-    if test -r $ac_dir/libXt.$ac_extension; then
+    if test -r "$ac_dir/libXt.$ac_extension"; then
       ac_x_libraries=$ac_dir
       break 2
     fi
   done
 done
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi # $ac_x_libraries = no
 
 if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then
@@ -9342,7 +12897,7 @@
 fi # $with_x != no
 
 if test "$have_x" != yes; then
-  echo "$as_me:9345: result: $have_x" >&5
+  echo "$as_me:12900: result: $have_x" >&5
 echo "${ECHO_T}$have_x" >&6
   no_x=yes
 else
@@ -9352,7 +12907,7 @@
   # Update the cache value to reflect the command line values.
   ac_cv_have_x="have_x=yes \
 		ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
-  echo "$as_me:9355: result: libraries $x_libraries, headers $x_includes" >&5
+  echo "$as_me:12910: result: libraries $x_libraries, headers $x_includes" >&5
 echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6
 fi
 
@@ -9363,7 +12918,10 @@
 #define X_DISPLAY_MISSING 1
 EOF
 
-  X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
+  X_CFLAGS=
+  X_PRE_LIBS=
+  X_LIBS=
+  X_EXTRA_LIBS=
 else
   if test -n "$x_includes"; then
     X_CFLAGS="$X_CFLAGS -I$x_includes"
@@ -9376,83 +12934,83 @@
     # others require no space.  Words are not sufficient . . . .
     case `(uname -sr) 2>/dev/null` in
     "SunOS 5"*)
-      echo "$as_me:9379: checking whether -R must be followed by a space" >&5
+      echo "$as_me:12937: checking whether -R must be followed by a space" >&5
 echo $ECHO_N "checking whether -R must be followed by a space... $ECHO_C" >&6
       ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries"
-      cat >conftest.$ac_ext <<_ACEOF
-#line 9383 "configure"
+      cat >"conftest.$ac_ext" <<_ACEOF
+#line 12941 "configure"
 #include "confdefs.h"
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9395: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:12953: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9398: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9401: \"$ac_try\"") >&5
+  echo "$as_me:12956: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:12959: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9404: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:12962: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_R_nospace=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_R_nospace=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
       if test $ac_R_nospace = yes; then
-	echo "$as_me:9414: result: no" >&5
+	echo "$as_me:12972: result: no" >&5
 echo "${ECHO_T}no" >&6
 	X_LIBS="$X_LIBS -R$x_libraries"
       else
 	LIBS="$ac_xsave_LIBS -R $x_libraries"
-	cat >conftest.$ac_ext <<_ACEOF
-#line 9420 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 12978 "configure"
 #include "confdefs.h"
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9432: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:12990: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9435: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9438: \"$ac_try\"") >&5
+  echo "$as_me:12993: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:12996: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9441: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:12999: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_R_space=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_R_space=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 	if test $ac_R_space = yes; then
-	  echo "$as_me:9451: result: yes" >&5
+	  echo "$as_me:13009: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 	  X_LIBS="$X_LIBS -R $x_libraries"
 	else
-	  echo "$as_me:9455: result: neither works" >&5
+	  echo "$as_me:13013: result: neither works" >&5
 echo "${ECHO_T}neither works" >&6
 	fi
       fi
@@ -9471,8 +13029,8 @@
     # libraries were built with DECnet support.  And Karl Berry says
     # the Alpha needs dnet_stub (dnet does not exist).
     ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
-    cat >conftest.$ac_ext <<_ACEOF
-#line 9475 "configure"
+    cat >"conftest.$ac_ext" <<_ACEOF
+#line 13033 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -9481,40 +13039,40 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char XOpenDisplay ();
+char XOpenDisplay (void);
 int
-main ()
+main (void)
 {
 XOpenDisplay ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9494: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:13052: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9497: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9500: \"$ac_try\"") >&5
+  echo "$as_me:13055: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:13058: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9503: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:13061: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-echo "$as_me:9509: checking for dnet_ntoa in -ldnet" >&5
+cat "conftest.$ac_ext" >&5
+echo "$as_me:13067: checking for dnet_ntoa in -ldnet" >&5
 echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6
 if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldnet  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 9517 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 13075 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -9523,52 +13081,52 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char dnet_ntoa ();
+char dnet_ntoa (void);
 int
-main ()
+main (void)
 {
 dnet_ntoa ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9536: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:13094: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9539: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9542: \"$ac_try\"") >&5
+  echo "$as_me:13097: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:13100: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9545: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:13103: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_dnet_dnet_ntoa=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_dnet_dnet_ntoa=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:9556: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
+echo "$as_me:13114: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
 echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6
-if test $ac_cv_lib_dnet_dnet_ntoa = yes; then
+if test "$ac_cv_lib_dnet_dnet_ntoa" = yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
 fi
 
     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
-      echo "$as_me:9563: checking for dnet_ntoa in -ldnet_stub" >&5
+      echo "$as_me:13121: checking for dnet_ntoa in -ldnet_stub" >&5
 echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6
 if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldnet_stub  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 9571 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 13129 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -9577,45 +13135,45 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char dnet_ntoa ();
+char dnet_ntoa (void);
 int
-main ()
+main (void)
 {
 dnet_ntoa ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9590: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:13148: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9593: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9596: \"$ac_try\"") >&5
+  echo "$as_me:13151: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:13154: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9599: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:13157: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_dnet_stub_dnet_ntoa=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_dnet_stub_dnet_ntoa=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:9610: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5
+echo "$as_me:13168: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5
 echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6
-if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then
+if test "$ac_cv_lib_dnet_stub_dnet_ntoa" = yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
 fi
 
     fi
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
     LIBS="$ac_xsave_LIBS"
 
     # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
@@ -9626,75 +13184,75 @@
     # on Irix 5.2, according to T.E. Dickey.
     # The functions gethostbyname, getservbyname, and inet_addr are
     # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking.
-    echo "$as_me:9629: checking for gethostbyname" >&5
+    echo "$as_me:13187: checking for gethostbyname" >&5
 echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6
 if test "${ac_cv_func_gethostbyname+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 9635 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 13193 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char gethostbyname (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
+#define gethostbyname autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef gethostbyname
+
 #ifdef __cplusplus
 extern "C"
 #endif
+
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char gethostbyname ();
-char (*f) ();
+char gethostbyname (void);
 
 int
-main ()
+main (void)
 {
-/* The GNU C library defines this for functions which it implements
+
+/* The GNU C library defines stubs for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined (__stub_gethostbyname) || defined (__stub___gethostbyname)
-choke me
-#else
-f = gethostbyname; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#error found stub for gethostbyname
 #endif
 
+	return gethostbyname ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9666: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:13224: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9669: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9672: \"$ac_try\"") >&5
+  echo "$as_me:13227: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:13230: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9675: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:13233: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_func_gethostbyname=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_func_gethostbyname=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:9685: result: $ac_cv_func_gethostbyname" >&5
+echo "$as_me:13243: result: $ac_cv_func_gethostbyname" >&5
 echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6
 
     if test $ac_cv_func_gethostbyname = no; then
-      echo "$as_me:9689: checking for gethostbyname in -lnsl" >&5
+      echo "$as_me:13247: checking for gethostbyname in -lnsl" >&5
 echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6
 if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lnsl  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 9697 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 13255 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -9703,52 +13261,52 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char gethostbyname ();
+char gethostbyname (void);
 int
-main ()
+main (void)
 {
 gethostbyname ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9716: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:13274: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9719: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9722: \"$ac_try\"") >&5
+  echo "$as_me:13277: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:13280: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9725: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:13283: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_nsl_gethostbyname=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_nsl_gethostbyname=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:9736: result: $ac_cv_lib_nsl_gethostbyname" >&5
+echo "$as_me:13294: result: $ac_cv_lib_nsl_gethostbyname" >&5
 echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6
-if test $ac_cv_lib_nsl_gethostbyname = yes; then
+if test "$ac_cv_lib_nsl_gethostbyname" = yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
 fi
 
       if test $ac_cv_lib_nsl_gethostbyname = no; then
-        echo "$as_me:9743: checking for gethostbyname in -lbsd" >&5
+        echo "$as_me:13301: checking for gethostbyname in -lbsd" >&5
 echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6
 if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lbsd  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 9751 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 13309 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -9757,39 +13315,39 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char gethostbyname ();
+char gethostbyname (void);
 int
-main ()
+main (void)
 {
 gethostbyname ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9770: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:13328: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9773: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9776: \"$ac_try\"") >&5
+  echo "$as_me:13331: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:13334: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9779: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:13337: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_bsd_gethostbyname=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_bsd_gethostbyname=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:9790: result: $ac_cv_lib_bsd_gethostbyname" >&5
+echo "$as_me:13348: result: $ac_cv_lib_bsd_gethostbyname" >&5
 echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6
-if test $ac_cv_lib_bsd_gethostbyname = yes; then
+if test "$ac_cv_lib_bsd_gethostbyname" = yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd"
 fi
 
@@ -9803,75 +13361,75 @@
     # variants that don't use the nameserver (or something).  -lsocket
     # must be given before -lnsl if both are needed.  We assume that
     # if connect needs -lnsl, so does gethostbyname.
-    echo "$as_me:9806: checking for connect" >&5
+    echo "$as_me:13364: checking for connect" >&5
 echo $ECHO_N "checking for connect... $ECHO_C" >&6
 if test "${ac_cv_func_connect+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 9812 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 13370 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char connect (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
+#define connect autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef connect
+
 #ifdef __cplusplus
 extern "C"
 #endif
+
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char connect ();
-char (*f) ();
+char connect (void);
 
 int
-main ()
+main (void)
 {
-/* The GNU C library defines this for functions which it implements
+
+/* The GNU C library defines stubs for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined (__stub_connect) || defined (__stub___connect)
-choke me
-#else
-f = connect; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#error found stub for connect
 #endif
 
+	return connect ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9843: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:13401: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9846: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9849: \"$ac_try\"") >&5
+  echo "$as_me:13404: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:13407: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9852: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:13410: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_func_connect=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_func_connect=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:9862: result: $ac_cv_func_connect" >&5
+echo "$as_me:13420: result: $ac_cv_func_connect" >&5
 echo "${ECHO_T}$ac_cv_func_connect" >&6
 
     if test $ac_cv_func_connect = no; then
-      echo "$as_me:9866: checking for connect in -lsocket" >&5
+      echo "$as_me:13424: checking for connect in -lsocket" >&5
 echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6
 if test "${ac_cv_lib_socket_connect+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 9874 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 13432 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -9880,114 +13438,114 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char connect ();
+char connect (void);
 int
-main ()
+main (void)
 {
 connect ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9893: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:13451: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9896: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9899: \"$ac_try\"") >&5
+  echo "$as_me:13454: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:13457: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9902: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:13460: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_socket_connect=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_socket_connect=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:9913: result: $ac_cv_lib_socket_connect" >&5
+echo "$as_me:13471: result: $ac_cv_lib_socket_connect" >&5
 echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6
-if test $ac_cv_lib_socket_connect = yes; then
+if test "$ac_cv_lib_socket_connect" = yes; then
   X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
 fi
 
     fi
 
     # Guillermo Gomez says -lposix is necessary on A/UX.
-    echo "$as_me:9922: checking for remove" >&5
+    echo "$as_me:13480: checking for remove" >&5
 echo $ECHO_N "checking for remove... $ECHO_C" >&6
 if test "${ac_cv_func_remove+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 9928 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 13486 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char remove (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
+#define remove autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef remove
+
 #ifdef __cplusplus
 extern "C"
 #endif
+
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char remove ();
-char (*f) ();
+char remove (void);
 
 int
-main ()
+main (void)
 {
-/* The GNU C library defines this for functions which it implements
+
+/* The GNU C library defines stubs for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined (__stub_remove) || defined (__stub___remove)
-choke me
-#else
-f = remove; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#error found stub for remove
 #endif
 
+	return remove ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9959: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:13517: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9962: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9965: \"$ac_try\"") >&5
+  echo "$as_me:13520: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:13523: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9968: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:13526: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_func_remove=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_func_remove=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:9978: result: $ac_cv_func_remove" >&5
+echo "$as_me:13536: result: $ac_cv_func_remove" >&5
 echo "${ECHO_T}$ac_cv_func_remove" >&6
 
     if test $ac_cv_func_remove = no; then
-      echo "$as_me:9982: checking for remove in -lposix" >&5
+      echo "$as_me:13540: checking for remove in -lposix" >&5
 echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6
 if test "${ac_cv_lib_posix_remove+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lposix  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 9990 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 13548 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -9996,114 +13554,114 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char remove ();
+char remove (void);
 int
-main ()
+main (void)
 {
 remove ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10009: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:13567: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10012: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10015: \"$ac_try\"") >&5
+  echo "$as_me:13570: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:13573: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10018: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:13576: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_posix_remove=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_posix_remove=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:10029: result: $ac_cv_lib_posix_remove" >&5
+echo "$as_me:13587: result: $ac_cv_lib_posix_remove" >&5
 echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6
-if test $ac_cv_lib_posix_remove = yes; then
+if test "$ac_cv_lib_posix_remove" = yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
 fi
 
     fi
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
-    echo "$as_me:10038: checking for shmat" >&5
+    echo "$as_me:13596: checking for shmat" >&5
 echo $ECHO_N "checking for shmat... $ECHO_C" >&6
 if test "${ac_cv_func_shmat+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 10044 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 13602 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char shmat (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
+#define shmat autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef shmat
+
 #ifdef __cplusplus
 extern "C"
 #endif
+
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char shmat ();
-char (*f) ();
+char shmat (void);
 
 int
-main ()
+main (void)
 {
-/* The GNU C library defines this for functions which it implements
+
+/* The GNU C library defines stubs for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined (__stub_shmat) || defined (__stub___shmat)
-choke me
-#else
-f = shmat; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#error found stub for shmat
 #endif
 
+	return shmat ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10075: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:13633: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10078: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10081: \"$ac_try\"") >&5
+  echo "$as_me:13636: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:13639: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10084: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:13642: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_func_shmat=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_func_shmat=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:10094: result: $ac_cv_func_shmat" >&5
+echo "$as_me:13652: result: $ac_cv_func_shmat" >&5
 echo "${ECHO_T}$ac_cv_func_shmat" >&6
 
     if test $ac_cv_func_shmat = no; then
-      echo "$as_me:10098: checking for shmat in -lipc" >&5
+      echo "$as_me:13656: checking for shmat in -lipc" >&5
 echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6
 if test "${ac_cv_lib_ipc_shmat+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lipc  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 10106 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 13664 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -10112,39 +13670,39 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char shmat ();
+char shmat (void);
 int
-main ()
+main (void)
 {
 shmat ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10125: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:13683: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10128: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10131: \"$ac_try\"") >&5
+  echo "$as_me:13686: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:13689: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10134: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:13692: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_ipc_shmat=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_ipc_shmat=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:10145: result: $ac_cv_lib_ipc_shmat" >&5
+echo "$as_me:13703: result: $ac_cv_lib_ipc_shmat" >&5
 echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6
-if test $ac_cv_lib_ipc_shmat = yes; then
+if test "$ac_cv_lib_ipc_shmat" = yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"
 fi
 
@@ -10160,15 +13718,15 @@
   # These have to be linked with before -lX11, unlike the other
   # libraries we check for below, so use a different variable.
   # John Interrante, Karl Berry
-  echo "$as_me:10163: checking for IceConnectionNumber in -lICE" >&5
+  echo "$as_me:13721: checking for IceConnectionNumber in -lICE" >&5
 echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6
 if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lICE $X_EXTRA_LIBS $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 10171 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 13729 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -10177,39 +13735,39 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char IceConnectionNumber ();
+char IceConnectionNumber (void);
 int
-main ()
+main (void)
 {
 IceConnectionNumber ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10190: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:13748: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10193: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10196: \"$ac_try\"") >&5
+  echo "$as_me:13751: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:13754: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10199: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:13757: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_ICE_IceConnectionNumber=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_ICE_IceConnectionNumber=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:10210: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5
+echo "$as_me:13768: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5
 echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6
-if test $ac_cv_lib_ICE_IceConnectionNumber = yes; then
+if test "$ac_cv_lib_ICE_IceConnectionNumber" = yes; then
   X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
 fi
 
@@ -10219,7 +13777,7 @@
 
 cf_x_athena=${cf_x_athena:-Xaw}
 
-echo "$as_me:10222: checking if you want to link with Xaw 3d library" >&5
+echo "$as_me:13780: checking if you want to link with Xaw 3d library" >&5
 echo $ECHO_N "checking if you want to link with Xaw 3d library... $ECHO_C" >&6
 withval=
 
@@ -10230,14 +13788,14 @@
 fi;
 if test "$withval" = yes ; then
 	cf_x_athena=Xaw3d
-	echo "$as_me:10233: result: yes" >&5
+	echo "$as_me:13791: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 else
-	echo "$as_me:10236: result: no" >&5
+	echo "$as_me:13794: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
-echo "$as_me:10240: checking if you want to link with Xaw 3d xft library" >&5
+echo "$as_me:13798: checking if you want to link with Xaw 3d xft library" >&5
 echo $ECHO_N "checking if you want to link with Xaw 3d xft library... $ECHO_C" >&6
 withval=
 
@@ -10248,14 +13806,14 @@
 fi;
 if test "$withval" = yes ; then
 	cf_x_athena=Xaw3dxft
-	echo "$as_me:10251: result: yes" >&5
+	echo "$as_me:13809: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 else
-	echo "$as_me:10254: result: no" >&5
+	echo "$as_me:13812: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
-echo "$as_me:10258: checking if you want to link with neXT Athena library" >&5
+echo "$as_me:13816: checking if you want to link with neXT Athena library" >&5
 echo $ECHO_N "checking if you want to link with neXT Athena library... $ECHO_C" >&6
 withval=
 
@@ -10266,14 +13824,14 @@
 fi;
 if test "$withval" = yes ; then
 	cf_x_athena=neXtaw
-	echo "$as_me:10269: result: yes" >&5
+	echo "$as_me:13827: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 else
-	echo "$as_me:10272: result: no" >&5
+	echo "$as_me:13830: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
-echo "$as_me:10276: checking if you want to link with Athena-Plus library" >&5
+echo "$as_me:13834: checking if you want to link with Athena-Plus library" >&5
 echo $ECHO_N "checking if you want to link with Athena-Plus library... $ECHO_C" >&6
 withval=
 
@@ -10284,10 +13842,10 @@
 fi;
 if test "$withval" = yes ; then
 	cf_x_athena=XawPlus
-	echo "$as_me:10287: result: yes" >&5
+	echo "$as_me:13845: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 else
-	echo "$as_me:10290: result: no" >&5
+	echo "$as_me:13848: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -10304,20 +13862,20 @@
 		lib${cf_x_athena}-devel
 	do
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $cf_athena_pkg; then
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "$cf_athena_pkg"; then
 	test -n "$verbose" && echo "	found package $cf_athena_pkg" 1>&6
 
-echo "${as_me:-configure}:10310: testing found package $cf_athena_pkg ..." 1>&5
+echo "${as_me:-configure}:13868: testing found package $cf_athena_pkg ..." 1>&5
 
-	cf_pkgconfig_incs="`$PKG_CONFIG --cflags $cf_athena_pkg 2>/dev/null`"
-	cf_pkgconfig_libs="`$PKG_CONFIG --libs   $cf_athena_pkg 2>/dev/null`"
+	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "$cf_athena_pkg" 2>/dev/null`"
+	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "$cf_athena_pkg" 2>/dev/null`"
 	test -n "$verbose" && echo "	package $cf_athena_pkg CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:10316: testing package $cf_athena_pkg CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:13874: testing package $cf_athena_pkg CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
 	test -n "$verbose" && echo "	package $cf_athena_pkg LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:10320: testing package $cf_athena_pkg LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:13878: testing package $cf_athena_pkg LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -10326,23 +13884,29 @@
 
 for cf_add_cflags in $cf_pkgconfig_incs
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -10351,7 +13915,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -10361,19 +13925,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -10384,32 +13956,38 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
-cf_add_libs="$cf_pkgconfig_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_pkgconfig_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -10428,55 +14006,57 @@
 			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
 			test -n "$verbose" && echo "	..trimmed $LIBS" 1>&6
 
-echo "${as_me:-configure}:10431: testing ..trimmed $LIBS ..." 1>&5
+echo "${as_me:-configure}:14009: testing ..trimmed $LIBS ..." 1>&5
 
 			;;
 		esac
 	done
 
-echo "$as_me:10437: checking for usable $cf_x_athena/Xmu package" >&5
+echo "$as_me:14015: checking for usable $cf_x_athena/Xmu package" >&5
 echo $ECHO_N "checking for usable $cf_x_athena/Xmu package... $ECHO_C" >&6
 if test "${cf_cv_xaw_compat+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 10444 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 14022 "configure"
 #include "confdefs.h"
 
+$ac_includes_default
 #include <X11/Xmu/CharSet.h>
 
 int
-main ()
+main (void)
 {
 
-int check = XmuCompareISOLatin1("big", "small")
+int check = XmuCompareISOLatin1("big", "small");
+(void)check;
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10460: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:14040: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10463: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10466: \"$ac_try\"") >&5
+  echo "$as_me:14043: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:14046: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10469: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:14049: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_xaw_compat=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_xaw_compat=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:10479: result: $cf_cv_xaw_compat" >&5
+echo "$as_me:14059: result: $cf_cv_xaw_compat" >&5
 echo "${ECHO_T}$cf_cv_xaw_compat" >&6
 
 			if test "$cf_cv_xaw_compat" = no
@@ -10488,25 +14068,25 @@
 				(*)
 					test -n "$verbose" && echo "	work around broken package" 1>&6
 
-echo "${as_me:-configure}:10491: testing work around broken package ..." 1>&5
+echo "${as_me:-configure}:14071: testing work around broken package ..." 1>&5
 
 					cf_save_xmu="$LIBS"
 					cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^  *//' -e 's/ .*//'`
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xmu; then
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "xmu"; then
 	test -n "$verbose" && echo "	found package xmu" 1>&6
 
-echo "${as_me:-configure}:10499: testing found package xmu ..." 1>&5
+echo "${as_me:-configure}:14079: testing found package xmu ..." 1>&5
 
-	cf_pkgconfig_incs="`$PKG_CONFIG --cflags xmu 2>/dev/null`"
-	cf_pkgconfig_libs="`$PKG_CONFIG --libs   xmu 2>/dev/null`"
+	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "xmu" 2>/dev/null`"
+	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "xmu" 2>/dev/null`"
 	test -n "$verbose" && echo "	package xmu CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:10505: testing package xmu CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:14085: testing package xmu CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
 	test -n "$verbose" && echo "	package xmu LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:10509: testing package xmu LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:14089: testing package xmu LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -10515,23 +14095,29 @@
 
 for cf_add_cflags in $cf_pkgconfig_incs
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -10540,7 +14126,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -10550,19 +14136,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -10573,32 +14167,38 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
-cf_add_libs="$cf_pkgconfig_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_pkgconfig_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -10606,12 +14206,12 @@
 
 test -n "$verbose" && echo "	...before $LIBS" 1>&6
 
-echo "${as_me:-configure}:10609: testing ...before $LIBS ..." 1>&5
+echo "${as_me:-configure}:14209: testing ...before $LIBS ..." 1>&5
 
 LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%$cf_first_lib %$cf_first_lib $cf_pkgconfig_libs %" -e 's%  % %g'`
 test -n "$verbose" && echo "	...after  $LIBS" 1>&6
 
-echo "${as_me:-configure}:10614: testing ...after  $LIBS ..." 1>&5
+echo "${as_me:-configure}:14214: testing ...after  $LIBS ..." 1>&5
 
 else
 	cf_pkgconfig_incs=
@@ -10619,12 +14219,12 @@
 
 test -n "$verbose" && echo "	...before $LIBS" 1>&6
 
-echo "${as_me:-configure}:10622: testing ...before $LIBS ..." 1>&5
+echo "${as_me:-configure}:14222: testing ...before $LIBS ..." 1>&5
 
 LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%$cf_first_lib %$cf_first_lib -lXmu %" -e 's%  % %g'`
 test -n "$verbose" && echo "	...after  $LIBS" 1>&6
 
-echo "${as_me:-configure}:10627: testing ...after  $LIBS ..." 1>&5
+echo "${as_me:-configure}:14227: testing ...after  $LIBS ..." 1>&5
 
 fi
 
@@ -10635,7 +14235,7 @@
 			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
 			test -n "$verbose" && echo "	..trimmed $LIBS" 1>&6
 
-echo "${as_me:-configure}:10638: testing ..trimmed $LIBS ..." 1>&5
+echo "${as_me:-configure}:14238: testing ..trimmed $LIBS ..." 1>&5
 
 			;;
 		esac
@@ -10657,20 +14257,20 @@
 
 if test -z "$cf_x_athena_lib" ; then
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists Xext; then
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "Xext"; then
 	test -n "$verbose" && echo "	found package Xext" 1>&6
 
-echo "${as_me:-configure}:10663: testing found package Xext ..." 1>&5
+echo "${as_me:-configure}:14263: testing found package Xext ..." 1>&5
 
-	cf_pkgconfig_incs="`$PKG_CONFIG --cflags Xext 2>/dev/null`"
-	cf_pkgconfig_libs="`$PKG_CONFIG --libs   Xext 2>/dev/null`"
+	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "Xext" 2>/dev/null`"
+	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "Xext" 2>/dev/null`"
 	test -n "$verbose" && echo "	package Xext CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:10669: testing package Xext CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:14269: testing package Xext CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
 	test -n "$verbose" && echo "	package Xext LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:10673: testing package Xext LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:14273: testing package Xext LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -10679,23 +14279,29 @@
 
 for cf_add_cflags in $cf_pkgconfig_incs
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -10704,7 +14310,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -10714,19 +14320,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -10737,32 +14351,38 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
-cf_add_libs="$cf_pkgconfig_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_pkgconfig_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -10771,15 +14391,15 @@
 	cf_pkgconfig_incs=
 	cf_pkgconfig_libs=
 
-	echo "$as_me:10774: checking for XextCreateExtension in -lXext" >&5
+	echo "$as_me:14394: checking for XextCreateExtension in -lXext" >&5
 echo $ECHO_N "checking for XextCreateExtension in -lXext... $ECHO_C" >&6
 if test "${ac_cv_lib_Xext_XextCreateExtension+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lXext  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 10782 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 14402 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -10788,53 +14408,53 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char XextCreateExtension ();
+char XextCreateExtension (void);
 int
-main ()
+main (void)
 {
 XextCreateExtension ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10801: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:14421: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10804: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10807: \"$ac_try\"") >&5
+  echo "$as_me:14424: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:14427: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10810: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:14430: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_Xext_XextCreateExtension=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_Xext_XextCreateExtension=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:10821: result: $ac_cv_lib_Xext_XextCreateExtension" >&5
+echo "$as_me:14441: result: $ac_cv_lib_Xext_XextCreateExtension" >&5
 echo "${ECHO_T}$ac_cv_lib_Xext_XextCreateExtension" >&6
-if test $ac_cv_lib_Xext_XextCreateExtension = yes; then
+if test "$ac_cv_lib_Xext_XextCreateExtension" = yes; then
 
-cf_add_libs="-lXext"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -lXext; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -10842,7 +14462,7 @@
 
 fi
 
-# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new), and (and
+# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new) (and
 # in some cases has installed dummy files in the former, other cases replaced
 # it with a link to the new location).  This complicates the configure script.
 # Check for that pitfall, and recover using pkg-config
@@ -10851,20 +14471,20 @@
 if test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
 then
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists x11; then
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "x11"; then
 	test -n "$verbose" && echo "	found package x11" 1>&6
 
-echo "${as_me:-configure}:10857: testing found package x11 ..." 1>&5
+echo "${as_me:-configure}:14477: testing found package x11 ..." 1>&5
 
-	cf_pkgconfig_incs="`$PKG_CONFIG --cflags x11 2>/dev/null`"
-	cf_pkgconfig_libs="`$PKG_CONFIG --libs   x11 2>/dev/null`"
+	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "x11" 2>/dev/null`"
+	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "x11" 2>/dev/null`"
 	test -n "$verbose" && echo "	package x11 CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:10863: testing package x11 CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:14483: testing package x11 CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
 	test -n "$verbose" && echo "	package x11 LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:10867: testing package x11 LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:14487: testing package x11 LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -10873,23 +14493,29 @@
 
 for cf_add_cflags in $cf_pkgconfig_incs
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -10898,7 +14524,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -10908,19 +14534,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -10931,32 +14565,38 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
-cf_add_libs="$cf_pkgconfig_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_pkgconfig_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -10964,24 +14604,24 @@
 else
 	cf_pkgconfig_incs=
 	cf_pkgconfig_libs=
-	{ echo "$as_me:10967: WARNING: unable to find X11 library" >&5
+	{ echo "$as_me:14607: WARNING: unable to find X11 library" >&5
 echo "$as_me: WARNING: unable to find X11 library" >&2;}
 fi
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists ice; then
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "ice"; then
 	test -n "$verbose" && echo "	found package ice" 1>&6
 
-echo "${as_me:-configure}:10974: testing found package ice ..." 1>&5
+echo "${as_me:-configure}:14614: testing found package ice ..." 1>&5
 
-	cf_pkgconfig_incs="`$PKG_CONFIG --cflags ice 2>/dev/null`"
-	cf_pkgconfig_libs="`$PKG_CONFIG --libs   ice 2>/dev/null`"
+	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "ice" 2>/dev/null`"
+	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "ice" 2>/dev/null`"
 	test -n "$verbose" && echo "	package ice CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:10980: testing package ice CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:14620: testing package ice CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
 	test -n "$verbose" && echo "	package ice LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:10984: testing package ice LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:14624: testing package ice LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -10990,23 +14630,29 @@
 
 for cf_add_cflags in $cf_pkgconfig_incs
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -11015,7 +14661,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -11025,19 +14671,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -11048,32 +14702,38 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
-cf_add_libs="$cf_pkgconfig_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_pkgconfig_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -11081,24 +14741,24 @@
 else
 	cf_pkgconfig_incs=
 	cf_pkgconfig_libs=
-	{ echo "$as_me:11084: WARNING: unable to find ICE library" >&5
+	{ echo "$as_me:14744: WARNING: unable to find ICE library" >&5
 echo "$as_me: WARNING: unable to find ICE library" >&2;}
 fi
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists sm; then
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "sm"; then
 	test -n "$verbose" && echo "	found package sm" 1>&6
 
-echo "${as_me:-configure}:11091: testing found package sm ..." 1>&5
+echo "${as_me:-configure}:14751: testing found package sm ..." 1>&5
 
-	cf_pkgconfig_incs="`$PKG_CONFIG --cflags sm 2>/dev/null`"
-	cf_pkgconfig_libs="`$PKG_CONFIG --libs   sm 2>/dev/null`"
+	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "sm" 2>/dev/null`"
+	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "sm" 2>/dev/null`"
 	test -n "$verbose" && echo "	package sm CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:11097: testing package sm CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:14757: testing package sm CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
 	test -n "$verbose" && echo "	package sm LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:11101: testing package sm LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:14761: testing package sm LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -11107,23 +14767,29 @@
 
 for cf_add_cflags in $cf_pkgconfig_incs
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -11132,7 +14798,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -11142,19 +14808,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -11165,32 +14839,38 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
-cf_add_libs="$cf_pkgconfig_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_pkgconfig_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -11198,24 +14878,24 @@
 else
 	cf_pkgconfig_incs=
 	cf_pkgconfig_libs=
-	{ echo "$as_me:11201: WARNING: unable to find SM library" >&5
+	{ echo "$as_me:14881: WARNING: unable to find SM library" >&5
 echo "$as_me: WARNING: unable to find SM library" >&2;}
 fi
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xt; then
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "xt"; then
 	test -n "$verbose" && echo "	found package xt" 1>&6
 
-echo "${as_me:-configure}:11208: testing found package xt ..." 1>&5
+echo "${as_me:-configure}:14888: testing found package xt ..." 1>&5
 
-	cf_pkgconfig_incs="`$PKG_CONFIG --cflags xt 2>/dev/null`"
-	cf_pkgconfig_libs="`$PKG_CONFIG --libs   xt 2>/dev/null`"
+	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "xt" 2>/dev/null`"
+	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "xt" 2>/dev/null`"
 	test -n "$verbose" && echo "	package xt CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:11214: testing package xt CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:14894: testing package xt CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
 	test -n "$verbose" && echo "	package xt LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:11218: testing package xt LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:14898: testing package xt LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -11224,23 +14904,29 @@
 
 for cf_add_cflags in $cf_pkgconfig_incs
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -11249,7 +14935,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -11259,19 +14945,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -11282,32 +14976,38 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
-cf_add_libs="$cf_pkgconfig_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_pkgconfig_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -11315,28 +15015,30 @@
 else
 	cf_pkgconfig_incs=
 	cf_pkgconfig_libs=
-	{ echo "$as_me:11318: WARNING: unable to find Xt library" >&5
+	{ echo "$as_me:15018: WARNING: unable to find Xt library" >&5
 echo "$as_me: WARNING: unable to find Xt library" >&2;}
 fi
 
+else
+	LIBS="$X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
 fi
 
 cf_have_X_LIBS=no
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xt; then
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "xt"; then
 	test -n "$verbose" && echo "	found package xt" 1>&6
 
-echo "${as_me:-configure}:11329: testing found package xt ..." 1>&5
+echo "${as_me:-configure}:15031: testing found package xt ..." 1>&5
 
-	cf_pkgconfig_incs="`$PKG_CONFIG --cflags xt 2>/dev/null`"
-	cf_pkgconfig_libs="`$PKG_CONFIG --libs   xt 2>/dev/null`"
+	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "xt" 2>/dev/null`"
+	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "xt" 2>/dev/null`"
 	test -n "$verbose" && echo "	package xt CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:11335: testing package xt CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:15037: testing package xt CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
 	test -n "$verbose" && echo "	package xt LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:11339: testing package xt LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:15041: testing package xt LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -11345,23 +15047,29 @@
 
 for cf_add_cflags in $cf_pkgconfig_incs
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -11370,7 +15078,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -11380,19 +15088,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -11403,32 +15119,38 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
-cf_add_libs="$cf_pkgconfig_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_pkgconfig_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -11437,20 +15159,21 @@
 		;;
 	(*)
 # we have an "xt" package, but it may omit Xt's dependency on X11
-echo "$as_me:11440: checking for usable X dependency" >&5
+echo "$as_me:15162: checking for usable X dependency" >&5
 echo $ECHO_N "checking for usable X dependency... $ECHO_C" >&6
 if test "${cf_cv_xt_x11_compat+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 11447 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 15169 "configure"
 #include "confdefs.h"
 
+$ac_includes_default
 #include <X11/Xlib.h>
 
 int
-main ()
+main (void)
 {
 
 	int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
@@ -11462,50 +15185,50 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:11466: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:15189: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:11469: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:11472: \"$ac_try\"") >&5
+  echo "$as_me:15192: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:15195: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11475: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:15198: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_xt_x11_compat=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_xt_x11_compat=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:11485: result: $cf_cv_xt_x11_compat" >&5
+echo "$as_me:15208: result: $cf_cv_xt_x11_compat" >&5
 echo "${ECHO_T}$cf_cv_xt_x11_compat" >&6
 		if test "$cf_cv_xt_x11_compat" = no
 		then
 			test -n "$verbose" && echo "	work around broken X11 dependency" 1>&6
 
-echo "${as_me:-configure}:11491: testing work around broken X11 dependency ..." 1>&5
+echo "${as_me:-configure}:15214: testing work around broken X11 dependency ..." 1>&5
 
 			# 2010/11/19 - good enough until a working Xt on Xcb is delivered.
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists x11; then
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "x11"; then
 	test -n "$verbose" && echo "	found package x11" 1>&6
 
-echo "${as_me:-configure}:11498: testing found package x11 ..." 1>&5
+echo "${as_me:-configure}:15221: testing found package x11 ..." 1>&5
 
-	cf_pkgconfig_incs="`$PKG_CONFIG --cflags x11 2>/dev/null`"
-	cf_pkgconfig_libs="`$PKG_CONFIG --libs   x11 2>/dev/null`"
+	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "x11" 2>/dev/null`"
+	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "x11" 2>/dev/null`"
 	test -n "$verbose" && echo "	package x11 CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:11504: testing package x11 CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:15227: testing package x11 CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
 	test -n "$verbose" && echo "	package x11 LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:11508: testing package x11 LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:15231: testing package x11 LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -11514,23 +15237,29 @@
 
 for cf_add_cflags in $cf_pkgconfig_incs
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -11539,7 +15268,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -11549,19 +15278,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -11572,32 +15309,38 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
-cf_add_libs="$cf_pkgconfig_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_pkgconfig_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -11608,12 +15351,12 @@
 
 test -n "$verbose" && echo "	...before $LIBS" 1>&6
 
-echo "${as_me:-configure}:11611: testing ...before $LIBS ..." 1>&5
+echo "${as_me:-configure}:15354: testing ...before $LIBS ..." 1>&5
 
 LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%-lXt %-lXt -lX11 %" -e 's%  % %g'`
 test -n "$verbose" && echo "	...after  $LIBS" 1>&6
 
-echo "${as_me:-configure}:11616: testing ...after  $LIBS ..." 1>&5
+echo "${as_me:-configure}:15359: testing ...after  $LIBS ..." 1>&5
 
 fi
 
@@ -11621,48 +15364,49 @@
 		;;
 	esac
 
-echo "$as_me:11624: checking for usable X Toolkit package" >&5
+echo "$as_me:15367: checking for usable X Toolkit package" >&5
 echo $ECHO_N "checking for usable X Toolkit package... $ECHO_C" >&6
 if test "${cf_cv_xt_ice_compat+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 11631 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 15374 "configure"
 #include "confdefs.h"
 
+$ac_includes_default
 #include <X11/Shell.h>
 
 int
-main ()
+main (void)
 {
-int num = IceConnectionNumber(0)
+int num = IceConnectionNumber(0); (void) num
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:11646: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:15390: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:11649: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:11652: \"$ac_try\"") >&5
+  echo "$as_me:15393: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:15396: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11655: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:15399: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_xt_ice_compat=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_xt_ice_compat=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:11665: result: $cf_cv_xt_ice_compat" >&5
+echo "$as_me:15409: result: $cf_cv_xt_ice_compat" >&5
 echo "${ECHO_T}$cf_cv_xt_ice_compat" >&6
 
 	if test "$cf_cv_xt_ice_compat" = no
@@ -11676,22 +15420,22 @@
 			(*)
 				test -n "$verbose" && echo "	work around broken ICE dependency" 1>&6
 
-echo "${as_me:-configure}:11679: testing work around broken ICE dependency ..." 1>&5
+echo "${as_me:-configure}:15423: testing work around broken ICE dependency ..." 1>&5
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists ice; then
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "ice"; then
 	test -n "$verbose" && echo "	found package ice" 1>&6
 
-echo "${as_me:-configure}:11684: testing found package ice ..." 1>&5
+echo "${as_me:-configure}:15428: testing found package ice ..." 1>&5
 
-	cf_pkgconfig_incs="`$PKG_CONFIG --cflags ice 2>/dev/null`"
-	cf_pkgconfig_libs="`$PKG_CONFIG --libs   ice 2>/dev/null`"
+	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "ice" 2>/dev/null`"
+	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "ice" 2>/dev/null`"
 	test -n "$verbose" && echo "	package ice CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:11690: testing package ice CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:15434: testing package ice CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
 	test -n "$verbose" && echo "	package ice LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:11694: testing package ice LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:15438: testing package ice LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -11700,23 +15444,29 @@
 
 for cf_add_cflags in $cf_pkgconfig_incs
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -11725,7 +15475,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -11735,19 +15485,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -11758,49 +15516,55 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
-cf_add_libs="$cf_pkgconfig_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_pkgconfig_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
-if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists sm; then
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "sm"; then
 	test -n "$verbose" && echo "	found package sm" 1>&6
 
-echo "${as_me:-configure}:11793: testing found package sm ..." 1>&5
+echo "${as_me:-configure}:15557: testing found package sm ..." 1>&5
 
-	cf_pkgconfig_incs="`$PKG_CONFIG --cflags sm 2>/dev/null`"
-	cf_pkgconfig_libs="`$PKG_CONFIG --libs   sm 2>/dev/null`"
+	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "sm" 2>/dev/null`"
+	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "sm" 2>/dev/null`"
 	test -n "$verbose" && echo "	package sm CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:11799: testing package sm CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:15563: testing package sm CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
 	test -n "$verbose" && echo "	package sm LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:11803: testing package sm LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:15567: testing package sm LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -11809,23 +15573,29 @@
 
 for cf_add_cflags in $cf_pkgconfig_incs
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -11834,7 +15604,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -11844,19 +15614,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -11867,32 +15645,38 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
-cf_add_libs="$cf_pkgconfig_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_pkgconfig_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -11909,12 +15693,12 @@
 
 test -n "$verbose" && echo "	...before $LIBS" 1>&6
 
-echo "${as_me:-configure}:11912: testing ...before $LIBS ..." 1>&5
+echo "${as_me:-configure}:15696: testing ...before $LIBS ..." 1>&5
 
 LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%-lXt %-lXt $X_PRE_LIBS %" -e 's%  % %g'`
 test -n "$verbose" && echo "	...after  $LIBS" 1>&6
 
-echo "${as_me:-configure}:11917: testing ...after  $LIBS ..." 1>&5
+echo "${as_me:-configure}:15701: testing ...after  $LIBS ..." 1>&5
 
 fi
 
@@ -11934,7 +15718,7 @@
 
 test -n "$verbose" && echo "	checking additions to CFLAGS" 1>&6
 
-echo "${as_me:-configure}:11937: testing checking additions to CFLAGS ..." 1>&5
+echo "${as_me:-configure}:15721: testing checking additions to CFLAGS ..." 1>&5
 
 cf_check_cflags="$CFLAGS"
 cf_check_cppflags="$CPPFLAGS"
@@ -11946,23 +15730,29 @@
 
 for cf_add_cflags in $X_CFLAGS
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -11971,7 +15761,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -11981,19 +15771,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -12005,142 +15803,148 @@
 if test -n "$cf_new_cflags" ; then
 	test -n "$verbose" && echo "	add to \$CFLAGS $cf_new_cflags" 1>&6
 
-echo "${as_me:-configure}:12008: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
+echo "${as_me:-configure}:15806: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 	test -n "$verbose" && echo "	add to \$CPPFLAGS $cf_new_cppflags" 1>&6
 
-echo "${as_me:-configure}:12016: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
+echo "${as_me:-configure}:15816: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 	test -n "$verbose" && echo "	add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6
 
-echo "${as_me:-configure}:12024: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
+echo "${as_me:-configure}:15826: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
 if test "x$cf_check_cflags" != "x$CFLAGS" ; then
-cat >conftest.$ac_ext <<_ACEOF
-#line 12031 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 15835 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 printf("Hello world");
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12043: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:15847: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:12046: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12049: \"$ac_try\"") >&5
+  echo "$as_me:15850: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:15853: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12052: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:15856: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 test -n "$verbose" && echo "	test-compile failed.  Undoing change to \$CFLAGS" 1>&6
 
-echo "${as_me:-configure}:12060: testing test-compile failed.  Undoing change to \$CFLAGS ..." 1>&5
+echo "${as_me:-configure}:15864: testing test-compile failed.  Undoing change to \$CFLAGS ..." 1>&5
 
 	 if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
 		 test -n "$verbose" && echo "	but keeping change to \$CPPFLAGS" 1>&6
 
-echo "${as_me:-configure}:12065: testing but keeping change to \$CPPFLAGS ..." 1>&5
+echo "${as_me:-configure}:15869: testing but keeping change to \$CPPFLAGS ..." 1>&5
 
 	 fi
-	 CFLAGS="$cf_check_flags"
+	 CFLAGS="$cf_check_cflags"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
 
-	echo "$as_me:12073: checking for XOpenDisplay" >&5
+	echo "$as_me:15877: checking for XOpenDisplay" >&5
 echo $ECHO_N "checking for XOpenDisplay... $ECHO_C" >&6
 if test "${ac_cv_func_XOpenDisplay+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 12079 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 15883 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char XOpenDisplay (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
+#define XOpenDisplay autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef XOpenDisplay
+
 #ifdef __cplusplus
 extern "C"
 #endif
+
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char XOpenDisplay ();
-char (*f) ();
+char XOpenDisplay (void);
 
 int
-main ()
+main (void)
 {
-/* The GNU C library defines this for functions which it implements
+
+/* The GNU C library defines stubs for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined (__stub_XOpenDisplay) || defined (__stub___XOpenDisplay)
-choke me
-#else
-f = XOpenDisplay; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#error found stub for XOpenDisplay
 #endif
 
+	return XOpenDisplay ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12110: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:15914: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:12113: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12116: \"$ac_try\"") >&5
+  echo "$as_me:15917: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:15920: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12119: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:15923: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_func_XOpenDisplay=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_func_XOpenDisplay=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:12129: result: $ac_cv_func_XOpenDisplay" >&5
+echo "$as_me:15933: result: $ac_cv_func_XOpenDisplay" >&5
 echo "${ECHO_T}$ac_cv_func_XOpenDisplay" >&6
-if test $ac_cv_func_XOpenDisplay = yes; then
+if test "$ac_cv_func_XOpenDisplay" = yes; then
   :
 else
 
-	echo "$as_me:12135: checking for XOpenDisplay in -lX11" >&5
+	echo "$as_me:15939: checking for XOpenDisplay in -lX11" >&5
 echo $ECHO_N "checking for XOpenDisplay in -lX11... $ECHO_C" >&6
 if test "${ac_cv_lib_X11_XOpenDisplay+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 12143 "configure"
+LIBS="-lX11  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 15947 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -12149,53 +15953,53 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char XOpenDisplay ();
+char XOpenDisplay (void);
 int
-main ()
+main (void)
 {
 XOpenDisplay ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12162: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:15966: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:12165: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12168: \"$ac_try\"") >&5
+  echo "$as_me:15969: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:15972: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12171: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:15975: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_X11_XOpenDisplay=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_X11_XOpenDisplay=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:12182: result: $ac_cv_lib_X11_XOpenDisplay" >&5
+echo "$as_me:15986: result: $ac_cv_lib_X11_XOpenDisplay" >&5
 echo "${ECHO_T}$ac_cv_lib_X11_XOpenDisplay" >&6
-if test $ac_cv_lib_X11_XOpenDisplay = yes; then
+if test "$ac_cv_lib_X11_XOpenDisplay" = yes; then
 
-cf_add_libs="-lX11"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -lX11; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -12203,77 +16007,77 @@
 
 fi
 
-	echo "$as_me:12206: checking for XtAppInitialize" >&5
+	echo "$as_me:16010: checking for XtAppInitialize" >&5
 echo $ECHO_N "checking for XtAppInitialize... $ECHO_C" >&6
 if test "${ac_cv_func_XtAppInitialize+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 12212 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 16016 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char XtAppInitialize (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
+#define XtAppInitialize autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef XtAppInitialize
+
 #ifdef __cplusplus
 extern "C"
 #endif
+
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char XtAppInitialize ();
-char (*f) ();
+char XtAppInitialize (void);
 
 int
-main ()
+main (void)
 {
-/* The GNU C library defines this for functions which it implements
+
+/* The GNU C library defines stubs for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined (__stub_XtAppInitialize) || defined (__stub___XtAppInitialize)
-choke me
-#else
-f = XtAppInitialize; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#error found stub for XtAppInitialize
 #endif
 
+	return XtAppInitialize ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12243: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:16047: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:12246: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12249: \"$ac_try\"") >&5
+  echo "$as_me:16050: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:16053: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12252: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:16056: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_func_XtAppInitialize=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_func_XtAppInitialize=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:12262: result: $ac_cv_func_XtAppInitialize" >&5
+echo "$as_me:16066: result: $ac_cv_func_XtAppInitialize" >&5
 echo "${ECHO_T}$ac_cv_func_XtAppInitialize" >&6
-if test $ac_cv_func_XtAppInitialize = yes; then
+if test "$ac_cv_func_XtAppInitialize" = yes; then
   :
 else
 
-	echo "$as_me:12268: checking for XtAppInitialize in -lXt" >&5
+	echo "$as_me:16072: checking for XtAppInitialize in -lXt" >&5
 echo $ECHO_N "checking for XtAppInitialize in -lXt... $ECHO_C" >&6
 if test "${ac_cv_lib_Xt_XtAppInitialize+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 12276 "configure"
+LIBS="-lXt  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 16080 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -12282,54 +16086,54 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char XtAppInitialize ();
+char XtAppInitialize (void);
 int
-main ()
+main (void)
 {
 XtAppInitialize ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12295: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:16099: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:12298: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12301: \"$ac_try\"") >&5
+  echo "$as_me:16102: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:16105: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12304: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:16108: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_Xt_XtAppInitialize=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_Xt_XtAppInitialize=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:12315: result: $ac_cv_lib_Xt_XtAppInitialize" >&5
+echo "$as_me:16119: result: $ac_cv_lib_Xt_XtAppInitialize" >&5
 echo "${ECHO_T}$ac_cv_lib_Xt_XtAppInitialize" >&6
-if test $ac_cv_lib_Xt_XtAppInitialize = yes; then
+if test "$ac_cv_lib_Xt_XtAppInitialize" = yes; then
 
 cat >>confdefs.h <<\EOF
 #define HAVE_LIBXT 1
 EOF
 
 		 cf_have_X_LIBS=Xt
-		 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
+		 LIBS="-lXt $LIBS"
 fi
 
 fi
 
 fi
 
-if test $cf_have_X_LIBS = no ; then
-	{ echo "$as_me:12332: WARNING: Unable to successfully link X Toolkit library (-lXt) with
+if test "$cf_have_X_LIBS" = no ; then
+	{ echo "$as_me:16136: WARNING: Unable to successfully link X Toolkit library (-lXt) with
 test program.  You will have to check and add the proper libraries by hand
 to makefile." >&5
 echo "$as_me: WARNING: Unable to successfully link X Toolkit library (-lXt) with
@@ -12347,65 +16151,91 @@
 	/usr/local
 do
 	if test -z "$cf_x_athena_inc" ; then
-		cf_save="$CPPFLAGS"
+
+cf_save_LIBS_CF_X_ATHENA_CPPFLAGS="$LIBS"
+cf_save_CFLAGS_CF_X_ATHENA_CPPFLAGS="$CFLAGS"
+cf_save_CPPFLAGS_CF_X_ATHENA_CPPFLAGS="$CPPFLAGS"
+LIBS="$LIBS ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}"
+for cf_X_CFLAGS in $X_CFLAGS
+do
+	case "x$cf_X_CFLAGS" in
+	x-[IUD]*)
+		CPPFLAGS="$CPPFLAGS $cf_X_CFLAGS"
+		;;
+	*)
+		CFLAGS="$CFLAGS $cf_X_CFLAGS"
+		;;
+	esac
+done
+
 		cf_test=X11/$cf_x_athena_root/SimpleMenu.h
-		if test $cf_path != default ; then
-			CPPFLAGS="$cf_save -I$cf_path/include"
-			echo "$as_me:12354: checking for $cf_test in $cf_path" >&5
+		if test "$cf_path" != default ; then
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-I$cf_path/include"
+
+			echo "$as_me:16177: checking for $cf_test in $cf_path" >&5
 echo $ECHO_N "checking for $cf_test in $cf_path... $ECHO_C" >&6
 		else
-			echo "$as_me:12357: checking for $cf_test" >&5
+			echo "$as_me:16180: checking for $cf_test" >&5
 echo $ECHO_N "checking for $cf_test... $ECHO_C" >&6
 		fi
-		cat >conftest.$ac_ext <<_ACEOF
-#line 12361 "configure"
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 16184 "configure"
 #include "confdefs.h"
 
 #include <X11/Intrinsic.h>
 #include <$cf_test>
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:12375: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:16198: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:12378: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:12381: \"$ac_try\"") >&5
+  echo "$as_me:16201: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:16204: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12384: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:16207: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_result=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-		echo "$as_me:12393: result: $cf_result" >&5
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+		echo "$as_me:16216: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
+
+LIBS="$cf_save_LIBS_CF_X_ATHENA_CPPFLAGS"
+CFLAGS="$cf_save_CFLAGS_CF_X_ATHENA_CPPFLAGS"
+CPPFLAGS="$cf_save_CPPFLAGS_CF_X_ATHENA_CPPFLAGS"
+
 		if test "$cf_result" = yes ; then
-			cf_x_athena_inc=$cf_path
+			test "$cf_path"  = default && cf_x_athena_inc=default
+			test "$cf_path" != default && cf_x_athena_inc="$cf_path/include"
 			break
-		else
-			CPPFLAGS="$cf_save"
 		fi
 	fi
 done
 
 if test -z "$cf_x_athena_inc" ; then
-	{ echo "$as_me:12405: WARNING: Unable to successfully find Athena header files with test program" >&5
-echo "$as_me: WARNING: Unable to successfully find Athena header files with test program" >&2;}
+	{ echo "$as_me:16232: WARNING: Unable to find Athena header files" >&5
+echo "$as_me: WARNING: Unable to find Athena header files" >&2;}
 elif test "$cf_x_athena_inc" != default ; then
-	CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-I$cf_x_athena_inc"
+
 fi
 
 cf_x_athena_root=$cf_x_athena
@@ -12427,59 +16257,55 @@
 		"-l$cf_lib -lXpm -lXmu" \
 		"-l${cf_lib}_s -lXmu_s"
 	do
-		if test -z "$cf_x_athena_lib" ; then
-			cf_save="$LIBS"
-			cf_test=XawSimpleMenuAddGlobalActions
-			if test $cf_path != default ; then
+		test -n "$cf_x_athena_lib" && break
 
-cf_add_libs="-L$cf_path/lib $cf_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
+cf_save_LIBS_CF_X_ATHENA_LIBS="$LIBS"
+cf_save_CFLAGS_CF_X_ATHENA_LIBS="$CFLAGS"
+cf_save_CPPFLAGS_CF_X_ATHENA_LIBS="$CPPFLAGS"
+LIBS="$LIBS ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}"
+for cf_X_CFLAGS in $X_CFLAGS
 do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+	case "x$cf_X_CFLAGS" in
+	x-[IUD]*)
+		CPPFLAGS="$CPPFLAGS $cf_X_CFLAGS"
+		;;
+	*)
+		CFLAGS="$CFLAGS $cf_X_CFLAGS"
+		;;
+	esac
+done
+
+		cf_test=XawSimpleMenuAddGlobalActions
+		test "$cf_path" != default && cf_libs="-L$cf_path/lib $cf_libs"
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_libs; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
-				echo "$as_me:12451: checking for $cf_libs in $cf_path" >&5
-echo $ECHO_N "checking for $cf_libs in $cf_path... $ECHO_C" >&6
-			else
-
-cf_add_libs="$cf_libs"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
-			cf_add_1lib=
-			break
-		fi
-	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
-
-				echo "$as_me:12471: checking for $cf_test in $cf_libs" >&5
+		echo "$as_me:16297: checking for $cf_test in $cf_libs" >&5
 echo $ECHO_N "checking for $cf_test in $cf_libs... $ECHO_C" >&6
-			fi
-			cat >conftest.$ac_ext <<_ACEOF
-#line 12475 "configure"
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 16300 "configure"
 #include "confdefs.h"
 
+$ac_includes_default
 #include <X11/Intrinsic.h>
 #include <X11/$cf_x_athena_root/SimpleMenu.h>
 
 int
-main ()
+main (void)
 {
 
 $cf_test((XtAppContext) 0)
@@ -12487,32 +16313,35 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12491: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:16317: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:12494: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12497: \"$ac_try\"") >&5
+  echo "$as_me:16320: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:16323: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12500: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:16326: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_result=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-			echo "$as_me:12509: result: $cf_result" >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+		echo "$as_me:16335: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
-			if test "$cf_result" = yes ; then
-				cf_x_athena_lib="$cf_libs"
-				break
-			fi
-			LIBS="$cf_save"
+
+LIBS="$cf_save_LIBS_CF_X_ATHENA_LIBS"
+CFLAGS="$cf_save_CFLAGS_CF_X_ATHENA_LIBS"
+CPPFLAGS="$cf_save_CPPFLAGS_CF_X_ATHENA_LIBS"
+
+		if test "$cf_result" = yes ; then
+			cf_x_athena_lib="$cf_libs"
+			break
 		fi
 	done # cf_libs
 		test -n "$cf_x_athena_lib" && break
@@ -12520,11 +16349,27 @@
 done
 
 if test -z "$cf_x_athena_lib" ; then
-	{ { echo "$as_me:12523: error: Unable to successfully link Athena library (-l$cf_x_athena_root) with test program" >&5
+	{ { echo "$as_me:16352: error: Unable to successfully link Athena library (-l$cf_x_athena_root) with test program" >&5
 echo "$as_me: error: Unable to successfully link Athena library (-l$cf_x_athena_root) with test program" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in $cf_x_athena_lib; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
+			cf_add_1lib=
+			break
+		fi
+	done
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
+done
+LIBS="$cf_add_libs"
+
 cf_x_athena_LIBS=`echo "HAVE_LIB_$cf_x_athena" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
 cat >>confdefs.h <<EOF
@@ -12538,7 +16383,7 @@
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:12541: checking for $ac_word" >&5
+echo "$as_me:16386: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_XCURSES_CONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -12553,7 +16398,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_XCURSES_CONFIG="$ac_tool_prefix$ac_prog"
-echo "$as_me:12556: found $ac_dir/$ac_word" >&5
+echo "$as_me:16401: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -12561,10 +16406,10 @@
 fi
 XCURSES_CONFIG=$ac_cv_prog_XCURSES_CONFIG
 if test -n "$XCURSES_CONFIG"; then
-  echo "$as_me:12564: result: $XCURSES_CONFIG" >&5
+  echo "$as_me:16409: result: $XCURSES_CONFIG" >&5
 echo "${ECHO_T}$XCURSES_CONFIG" >&6
 else
-  echo "$as_me:12567: result: no" >&5
+  echo "$as_me:16412: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -12577,7 +16422,7 @@
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:12580: checking for $ac_word" >&5
+echo "$as_me:16425: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_XCURSES_CONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -12592,7 +16437,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_XCURSES_CONFIG="$ac_prog"
-echo "$as_me:12595: found $ac_dir/$ac_word" >&5
+echo "$as_me:16440: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -12600,10 +16445,10 @@
 fi
 ac_ct_XCURSES_CONFIG=$ac_cv_prog_ac_ct_XCURSES_CONFIG
 if test -n "$ac_ct_XCURSES_CONFIG"; then
-  echo "$as_me:12603: result: $ac_ct_XCURSES_CONFIG" >&5
+  echo "$as_me:16448: result: $ac_ct_XCURSES_CONFIG" >&5
 echo "${ECHO_T}$ac_ct_XCURSES_CONFIG" >&6
 else
-  echo "$as_me:12606: result: no" >&5
+  echo "$as_me:16451: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -12616,21 +16461,117 @@
 
 if test "$XCURSES_CONFIG" != none ; then
 
-CPPFLAGS="$CPPFLAGS `$XCURSES_CONFIG --cflags`"
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
 
-cf_add_libs="`$XCURSES_CONFIG --libs`"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
+for cf_add_cflags in `$XCURSES_CONFIG --cflags`
 do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+case "$cf_fix_cppflags" in
+(no)
+	case "$cf_add_cflags" in
+	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+		case "$cf_add_cflags" in
+		(-D*)
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+				&& test -z "${cf_tst_cflags}" \
+				&& cf_fix_cppflags=yes
+
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		(*$cf_add_cflags)
+			;;
+		(*)
+			case "$cf_add_cflags" in
+			(-D*)
+				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
+		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`
+
+				;;
+			esac
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
+			;;
+		esac
+		;;
+	(*)
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
+		;;
+	esac
+	;;
+(yes)
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
+
+	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+		&& test -z "${cf_tst_cflags}" \
+		&& cf_fix_cppflags=no
+	;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in `$XCURSES_CONFIG --libs`; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
@@ -12642,7 +16583,7 @@
 
 test -n "$verbose" && echo "	checking additions to CFLAGS" 1>&6
 
-echo "${as_me:-configure}:12645: testing checking additions to CFLAGS ..." 1>&5
+echo "${as_me:-configure}:16586: testing checking additions to CFLAGS ..." 1>&5
 
 cf_check_cflags="$CFLAGS"
 cf_check_cppflags="$CPPFLAGS"
@@ -12654,23 +16595,29 @@
 
 for cf_add_cflags in $X_CFLAGS
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -12679,7 +16626,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -12689,19 +16636,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -12713,80 +16668,86 @@
 if test -n "$cf_new_cflags" ; then
 	test -n "$verbose" && echo "	add to \$CFLAGS $cf_new_cflags" 1>&6
 
-echo "${as_me:-configure}:12716: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
+echo "${as_me:-configure}:16671: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 	test -n "$verbose" && echo "	add to \$CPPFLAGS $cf_new_cppflags" 1>&6
 
-echo "${as_me:-configure}:12724: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
+echo "${as_me:-configure}:16681: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 	test -n "$verbose" && echo "	add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6
 
-echo "${as_me:-configure}:12732: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
+echo "${as_me:-configure}:16691: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
 if test "x$cf_check_cflags" != "x$CFLAGS" ; then
-cat >conftest.$ac_ext <<_ACEOF
-#line 12739 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 16700 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 printf("Hello world");
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12751: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:16712: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:12754: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12757: \"$ac_try\"") >&5
+  echo "$as_me:16715: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:16718: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12760: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:16721: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 test -n "$verbose" && echo "	test-compile failed.  Undoing change to \$CFLAGS" 1>&6
 
-echo "${as_me:-configure}:12768: testing test-compile failed.  Undoing change to \$CFLAGS ..." 1>&5
+echo "${as_me:-configure}:16729: testing test-compile failed.  Undoing change to \$CFLAGS ..." 1>&5
 
 	 if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
 		 test -n "$verbose" && echo "	but keeping change to \$CPPFLAGS" 1>&6
 
-echo "${as_me:-configure}:12773: testing but keeping change to \$CPPFLAGS ..." 1>&5
+echo "${as_me:-configure}:16734: testing but keeping change to \$CPPFLAGS ..." 1>&5
 
 	 fi
-	 CFLAGS="$cf_check_flags"
+	 CFLAGS="$cf_check_cflags"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
 
-echo "$as_me:12781: checking for XOpenDisplay in -lX11" >&5
+echo "$as_me:16742: checking for XOpenDisplay in -lX11" >&5
 echo $ECHO_N "checking for XOpenDisplay in -lX11... $ECHO_C" >&6
 if test "${ac_cv_lib_X11_XOpenDisplay+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 12789 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 16750 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -12795,122 +16756,122 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char XOpenDisplay ();
+char XOpenDisplay (void);
 int
-main ()
+main (void)
 {
 XOpenDisplay ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12808: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:16769: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:12811: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12814: \"$ac_try\"") >&5
+  echo "$as_me:16772: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:16775: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12817: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:16778: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_X11_XOpenDisplay=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_X11_XOpenDisplay=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:12828: result: $ac_cv_lib_X11_XOpenDisplay" >&5
+echo "$as_me:16789: result: $ac_cv_lib_X11_XOpenDisplay" >&5
 echo "${ECHO_T}$ac_cv_lib_X11_XOpenDisplay" >&6
-if test $ac_cv_lib_X11_XOpenDisplay = yes; then
+if test "$ac_cv_lib_X11_XOpenDisplay" = yes; then
 
-cf_add_libs="-lX11"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -lX11; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
 fi
 
-echo "$as_me:12850: checking for XCurses library" >&5
+echo "$as_me:16811: checking for XCurses library" >&5
 echo $ECHO_N "checking for XCurses library... $ECHO_C" >&6
 if test "${cf_cv_lib_XCurses+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cf_add_libs="-lXCurses"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -lXCurses; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 12873 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 16834 "configure"
 #include "confdefs.h"
 
 #include <xcurses.h>
 char *XCursesProgramName = "test";
 
 int
-main ()
+main (void)
 {
 XCursesExit();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:12888: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:16849: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:12891: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:12894: \"$ac_try\"") >&5
+  echo "$as_me:16852: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:16855: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12897: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:16858: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_lib_XCurses=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_lib_XCurses=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:12908: result: $cf_cv_lib_XCurses" >&5
+echo "$as_me:16869: result: $cf_cv_lib_XCurses" >&5
 echo "${ECHO_T}$cf_cv_lib_XCurses" >&6
 
 fi
 
-if test $cf_cv_lib_XCurses = yes ; then
+if test "$cf_cv_lib_XCurses" = yes ; then
 
 cat >>confdefs.h <<\EOF
 #define UNIX 1
@@ -12920,24 +16881,24 @@
 #define XCURSES 1
 EOF
 
-	echo "$as_me:12923: checking for xcurses.h" >&5
+	echo "$as_me:16884: checking for xcurses.h" >&5
 echo $ECHO_N "checking for xcurses.h... $ECHO_C" >&6
 if test "${ac_cv_header_xcurses_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 12929 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 16890 "configure"
 #include "confdefs.h"
 #include <xcurses.h>
 _ACEOF
-if { (eval echo "$as_me:12933: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (eval echo "$as_me:16894: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:12939: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
+  echo "$as_me:16900: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
   else
@@ -12950,14 +16911,14 @@
   ac_cv_header_xcurses_h=yes
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat "conftest.$ac_ext" >&5
   ac_cv_header_xcurses_h=no
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:12958: result: $ac_cv_header_xcurses_h" >&5
+echo "$as_me:16919: result: $ac_cv_header_xcurses_h" >&5
 echo "${ECHO_T}$ac_cv_header_xcurses_h" >&6
-if test $ac_cv_header_xcurses_h = yes; then
+if test "$ac_cv_header_xcurses_h" = yes; then
 
 cat >>confdefs.h <<\EOF
 #define HAVE_XCURSES 1
@@ -12966,40 +16927,1075 @@
 fi
 
 else
-	{ { echo "$as_me:12969: error: Cannot link with XCurses" >&5
+	{ { echo "$as_me:16930: error: Cannot link with XCurses" >&5
 echo "$as_me: error: Cannot link with XCurses" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
 	;;
 (*)
-	{ { echo "$as_me:12976: error: unexpected screen-value: $cf_cv_screen" >&5
+	{ { echo "$as_me:16937: error: unexpected screen-value: $cf_cv_screen" >&5
 echo "$as_me: error: unexpected screen-value: $cf_cv_screen" >&2;}
    { (exit 1); exit 1; }; }
 	;;
 esac
 
+: ${cf_nculib_root:=$cf_cv_screen}
+as_ac_Lib=`echo "ac_cv_lib_$cf_nculib_root''__nc_init_pthreads" | $as_tr_sh`
+echo "$as_me:16945: checking for _nc_init_pthreads in -l$cf_nculib_root" >&5
+echo $ECHO_N "checking for _nc_init_pthreads in -l$cf_nculib_root... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Lib+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-l$cf_nculib_root  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 16953 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char _nc_init_pthreads (void);
+int
+main (void)
+{
+_nc_init_pthreads ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:16972: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:16975: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:16978: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:16981: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  eval "$as_ac_Lib=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+eval "$as_ac_Lib=no"
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:16992: result: `eval echo '${'"$as_ac_Lib"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Lib"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Lib"'}'`" = yes; then
+  cf_cv_ncurses_pthreads=yes
+else
+  cf_cv_ncurses_pthreads=no
+fi
+
+if test "$cf_cv_ncurses_pthreads" = yes
+then
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -lpthread; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
+			cf_add_1lib=
+			break
+		fi
+	done
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
+done
+LIBS="$cf_add_libs"
+
+fi
+
 case $cf_cv_screen in
 (ncurses*)
 	cf_cv_libtype=`echo "$cf_cv_screen" | sed -e 's/^ncurses//'`
 	;;
-(curses|curses_*)
+esac
 
-echo "$as_me:12988: checking for NetBSD form.h" >&5
+echo "$as_me:17027: checking for X11 rgb file" >&5
+echo $ECHO_N "checking for X11 rgb file... $ECHO_C" >&6
+
+# Check whether --with-x11-rgb or --without-x11-rgb was given.
+if test "${with_x11_rgb+set}" = set; then
+  withval="$with_x11_rgb"
+  RGB_PATH=$withval
+else
+  RGB_PATH=auto
+fi;
+
+if test "x$RGB_PATH" = xauto
+then
+	RGB_PATH='${exec_prefix}/lib/X11/rgb.txt'
+	for cf_path in \
+		/opt/local/share/X11/rgb.txt \
+		/opt/X11/share/X11/rgb.txt \
+		/usr/share/X11/rgb.txt \
+		/usr/X11/share/X11/rgb.txt \
+		/usr/X11/lib/X11/rgb.txt \
+		/usr/lib/X11/rgb.txt \
+		/etc/X11/rgb.txt \
+		/usr/pkg/lib/X11/rgb.txt \
+		/usr/X11R7/lib/X11/rgb.txt \
+		/usr/X11R6/lib/X11/rgb.txt \
+		/usr/X11R5/lib/X11/rgb.txt \
+		/usr/X11R4/lib/X11/rgb.txt \
+		/usr/local/lib/X11/rgb.txt \
+		/usr/local/share/X11/rgb.txt \
+		/usr/lib64/X11/rgb.txt
+	do
+		if test -f "$cf_path" ; then
+			RGB_PATH="$cf_path"
+			break
+		fi
+	done
+else
+	cf_path=$RGB_PATH
+
+if test "x$prefix" != xNONE; then
+	cf_path_syntax="$prefix"
+else
+	cf_path_syntax="$ac_default_prefix"
+fi
+
+case ".$cf_path" in
+(.\$\(*\)*|.\'*\'*)
+	;;
+(..|./*|.\\*)
+	;;
+(.[a-zA-Z]:[\\/]*) # OS/2 EMX
+	;;
+(.\$\{*prefix\}*|.\$\{*dir\}*)
+	eval cf_path="$cf_path"
+	case ".$cf_path" in
+	(.NONE/*)
+		cf_path=`echo "$cf_path" | sed -e s%NONE%$cf_path_syntax%`
+		;;
+	esac
+	;;
+(.no|.NONE/*)
+	cf_path=`echo "$cf_path" | sed -e s%NONE%$cf_path_syntax%`
+	;;
+(*)
+	{ { echo "$as_me:17091: error: expected a pathname, not \"$cf_path\"" >&5
+echo "$as_me: error: expected a pathname, not \"$cf_path\"" >&2;}
+   { (exit 1); exit 1; }; }
+	;;
+esac
+
+fi
+
+echo "$as_me:17099: result: $RGB_PATH" >&5
+echo "${ECHO_T}$RGB_PATH" >&6
+
+cat >>confdefs.h <<EOF
+#define RGB_PATH "$cf_path"
+EOF
+
+no_x11_rgb=
+if test "$RGB_PATH" = no
+then
+	no_x11_rgb="#"
+fi
+
+cf_curses_headers=
+
+case $cf_cv_screen in
+(pdcurses)
+	cf_default_panel=no
+	cf_default_form=no
+	cf_default_menu=no
+	cf_default_tinfo=no
+	;;
+(xcurses|bsdcurses)
+	cf_default_panel=no
+	cf_default_form=no
+	cf_default_menu=no
+	cf_default_tinfo=yes
+	;;
+(*)
+	cf_default_panel=yes
+	cf_default_form=yes
+	cf_default_menu=yes
+	cf_default_tinfo=yes
+	case $cf_cv_screen in
+	(ncurses*)
+		cf_curses_headers="nc_alloc.h nomacros.h term_entry.h"
+		;;
+	esac
+	;;
+esac
+
+echo "$as_me:17140: checking for desired basename for form library" >&5
+echo $ECHO_N "checking for desired basename for form library... $ECHO_C" >&6
+
+# Check whether --with-form-libname or --without-form-libname was given.
+if test "${with_form_libname+set}" = set; then
+  withval="$with_form_libname"
+  with_lib_basename=$withval
+else
+  with_lib_basename=form
+fi;
+FORM_NAME="$with_lib_basename"
+
+case "x$FORM_NAME" in
+(x|xno|xnone|xyes)
+	FORM_NAME=form
+	;;
+(*)
+	;;
+esac
+
+echo "$as_me:17160: result: $FORM_NAME" >&5
+echo "${ECHO_T}$FORM_NAME" >&6
+
+echo "$as_me:17163: checking for desired basename for menu library" >&5
+echo $ECHO_N "checking for desired basename for menu library... $ECHO_C" >&6
+
+# Check whether --with-menu-libname or --without-menu-libname was given.
+if test "${with_menu_libname+set}" = set; then
+  withval="$with_menu_libname"
+  with_lib_basename=$withval
+else
+  with_lib_basename=menu
+fi;
+MENU_NAME="$with_lib_basename"
+
+case "x$MENU_NAME" in
+(x|xno|xnone|xyes)
+	MENU_NAME=menu
+	;;
+(*)
+	;;
+esac
+
+echo "$as_me:17183: result: $MENU_NAME" >&5
+echo "${ECHO_T}$MENU_NAME" >&6
+
+echo "$as_me:17186: checking for desired basename for panel library" >&5
+echo $ECHO_N "checking for desired basename for panel library... $ECHO_C" >&6
+
+# Check whether --with-panel-libname or --without-panel-libname was given.
+if test "${with_panel_libname+set}" = set; then
+  withval="$with_panel_libname"
+  with_lib_basename=$withval
+else
+  with_lib_basename=panel
+fi;
+PANEL_NAME="$with_lib_basename"
+
+case "x$PANEL_NAME" in
+(x|xno|xnone|xyes)
+	PANEL_NAME=panel
+	;;
+(*)
+	;;
+esac
+
+echo "$as_me:17206: result: $PANEL_NAME" >&5
+echo "${ECHO_T}$PANEL_NAME" >&6
+
+echo "$as_me:17209: checking if you want to check for panel functions" >&5
+echo $ECHO_N "checking if you want to check for panel functions... $ECHO_C" >&6
+
+# Check whether --enable-panel or --disable-panel was given.
+if test "${enable_panel+set}" = set; then
+  enableval="$enable_panel"
+  test "$enableval" != no && enableval=yes
+	if test "$enableval" != "yes" ; then
+    cf_enable_panel=no
+	else
+		cf_enable_panel=$cf_default_panel
+	fi
+else
+  enableval=yes
+	cf_enable_panel=$cf_default_panel
+
+fi;
+echo "$as_me:17226: result: $cf_enable_panel" >&5
+echo "${ECHO_T}$cf_enable_panel" >&6
+if test $cf_enable_panel = yes
+then
+
+cf_have_curses_lib=no
+
+: ${NCURSES_CONFIG_PKG:=none}
+if test "x${NCURSES_CONFIG_PKG}" = xnone; then
+	:
+elif test "x${PKG_CONFIG:=none}" != xnone; then
+	echo "$as_me:17237: checking pkg-config for $PANEL_NAME$cf_cv_libtype" >&5
+echo $ECHO_N "checking pkg-config for $PANEL_NAME$cf_cv_libtype... $ECHO_C" >&6
+	if "$PKG_CONFIG" --exists "$PANEL_NAME$cf_cv_libtype" ; then
+		echo "$as_me:17240: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+		echo "$as_me:17243: checking if the $PANEL_NAME$cf_cv_libtype package files work" >&5
+echo $ECHO_N "checking if the $PANEL_NAME$cf_cv_libtype package files work... $ECHO_C" >&6
+
+		cf_save_CFLAGS="$CFLAGS"
+		cf_save_CPPFLAGS="$CPPFLAGS"
+		cf_save_LIBS="$LIBS"
+
+for cf_add_cflags in `$PKG_CONFIG --cflags "$PANEL_NAME$cf_cv_libtype"`
+do
+	case "x$cf_add_cflags" in
+	(x-[DU]*)
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CFLAGS" != "$cf_old_cflag" || break
+
+	CFLAGS="$cf_old_cflag"
+done
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CPPFLAGS" != "$cf_old_cflag" || break
+
+	CPPFLAGS="$cf_old_cflag"
+done
+
+		;;
+	esac
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_add_cflags
+do
+case "$cf_fix_cppflags" in
+(no)
+	case "$cf_add_cflags" in
+	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+		case "$cf_add_cflags" in
+		(-D*)
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+				&& test -z "${cf_tst_cflags}" \
+				&& cf_fix_cppflags=yes
+
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		(*$cf_add_cflags)
+			;;
+		(*)
+			case "$cf_add_cflags" in
+			(-D*)
+				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
+		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`
+
+				;;
+			esac
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
+			;;
+		esac
+		;;
+	(*)
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
+		;;
+	esac
+	;;
+(yes)
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
+
+	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+		&& test -z "${cf_tst_cflags}" \
+		&& cf_fix_cppflags=no
+	;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+done
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in `$PKG_CONFIG --libs "$PANEL_NAME$cf_cv_libtype"`; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
+			cf_add_1lib=
+			break
+		fi
+	done
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
+done
+LIBS="$cf_add_libs"
+
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 17393 "configure"
+#include "confdefs.h"
+#include <$PANEL_NAME.h>
+int
+main (void)
+{
+(void) new_panel ( 0 );
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:17405: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:17408: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:17411: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:17414: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  if test "$cross_compiling" = yes; then
+  cf_have_curses_lib=maybe
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 17420 "configure"
+#include "confdefs.h"
+#include <$PANEL_NAME.h>
+				int main(void)
+				{ (void) new_panel ( 0 ); return 0; }
+_ACEOF
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:17427: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:17430: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:17432: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:17435: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_have_curses_lib=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_have_curses_lib=no
+fi
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_have_curses_lib=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+		echo "$as_me:17452: result: $cf_have_curses_lib" >&5
+echo "${ECHO_T}$cf_have_curses_lib" >&6
+		test "$cf_have_curses_lib" = maybe && cf_have_curses_lib=yes
+		if test "$cf_have_curses_lib" = "yes"
+		then
+
+cf_upper=`echo "have_lib$PANEL_NAME" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+			cat >>confdefs.h <<EOF
+#define $cf_upper 1
+EOF
+
+		else
+			CFLAGS="$cf_save_CFLAGS"
+			CPPFLAGS="$cf_save_CPPFLAGS"
+			LIBS="$cf_save_LIBS"
+		fi
+	fi
+fi
+if test "$cf_have_curses_lib" = no; then
+	as_ac_Lib=`echo "ac_cv_lib_$PANEL_NAME$cf_cv_libtype''_new_panel" | $as_tr_sh`
+echo "$as_me:17473: checking for new_panel in -l$PANEL_NAME$cf_cv_libtype" >&5
+echo $ECHO_N "checking for new_panel in -l$PANEL_NAME$cf_cv_libtype... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Lib+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-l$PANEL_NAME$cf_cv_libtype  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 17481 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char new_panel (void);
+int
+main (void)
+{
+new_panel ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:17500: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:17503: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:17506: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:17509: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  eval "$as_ac_Lib=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+eval "$as_ac_Lib=no"
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:17520: result: `eval echo '${'"$as_ac_Lib"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Lib"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Lib"'}'`" = yes; then
+
+cf_upper=`echo "have_lib$PANEL_NAME" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -l$PANEL_NAME$cf_cv_libtype; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
+			cf_add_1lib=
+			break
+		fi
+	done
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
+done
+LIBS="$cf_add_libs"
+
+		cat >>confdefs.h <<EOF
+#define $cf_upper 1
+EOF
+
+fi
+
+fi
+
+	cf_curses_headers="$cf_curses_headers panel.h"
+fi
+
+echo "$as_me:17553: checking if you want to check for menu functions" >&5
+echo $ECHO_N "checking if you want to check for menu functions... $ECHO_C" >&6
+
+# Check whether --enable-menu or --disable-menu was given.
+if test "${enable_menu+set}" = set; then
+  enableval="$enable_menu"
+  test "$enableval" != no && enableval=yes
+	if test "$enableval" != "yes" ; then
+    cf_enable_menu=no
+	else
+		cf_enable_menu=$cf_default_menu
+	fi
+else
+  enableval=yes
+	cf_enable_menu=$cf_default_menu
+
+fi;
+echo "$as_me:17570: result: $cf_enable_menu" >&5
+echo "${ECHO_T}$cf_enable_menu" >&6
+if test $cf_enable_menu = yes
+then
+	case $cf_cv_screen in
+	(ncurses*)
+		;;
+	(curses*)
+
+echo "$as_me:17579: checking for NetBSD menu.h" >&5
+echo $ECHO_N "checking for NetBSD menu.h... $ECHO_C" >&6
+if test "${cf_cv_netbsd_menu_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 17586 "configure"
+#include "confdefs.h"
+
+#include <${cf_cv_ncurses_header:-curses.h}>
+#include <menu.h>
+
+int
+main (void)
+{
+
+	MENU *menu;
+	int y = menu->max_item_width;
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:17604: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:17607: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:17610: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:17613: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_netbsd_menu_h=yes
+
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_netbsd_menu_h=no
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+
+fi
+echo "$as_me:17625: result: $cf_cv_netbsd_menu_h" >&5
+echo "${ECHO_T}$cf_cv_netbsd_menu_h" >&6
+
+test "$cf_cv_netbsd_menu_h" = yes &&
+cat >>confdefs.h <<\EOF
+#define HAVE_NETBSD_MENU_H 1
+EOF
+
+		;;
+	esac
+
+cf_have_curses_lib=no
+
+: ${NCURSES_CONFIG_PKG:=none}
+if test "x${NCURSES_CONFIG_PKG}" = xnone; then
+	:
+elif test "x${PKG_CONFIG:=none}" != xnone; then
+	echo "$as_me:17642: checking pkg-config for $MENU_NAME$cf_cv_libtype" >&5
+echo $ECHO_N "checking pkg-config for $MENU_NAME$cf_cv_libtype... $ECHO_C" >&6
+	if "$PKG_CONFIG" --exists "$MENU_NAME$cf_cv_libtype" ; then
+		echo "$as_me:17645: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+		echo "$as_me:17648: checking if the $MENU_NAME$cf_cv_libtype package files work" >&5
+echo $ECHO_N "checking if the $MENU_NAME$cf_cv_libtype package files work... $ECHO_C" >&6
+
+		cf_save_CFLAGS="$CFLAGS"
+		cf_save_CPPFLAGS="$CPPFLAGS"
+		cf_save_LIBS="$LIBS"
+
+for cf_add_cflags in `$PKG_CONFIG --cflags "$MENU_NAME$cf_cv_libtype"`
+do
+	case "x$cf_add_cflags" in
+	(x-[DU]*)
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CFLAGS" != "$cf_old_cflag" || break
+
+	CFLAGS="$cf_old_cflag"
+done
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CPPFLAGS" != "$cf_old_cflag" || break
+
+	CPPFLAGS="$cf_old_cflag"
+done
+
+		;;
+	esac
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_add_cflags
+do
+case "$cf_fix_cppflags" in
+(no)
+	case "$cf_add_cflags" in
+	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+		case "$cf_add_cflags" in
+		(-D*)
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+				&& test -z "${cf_tst_cflags}" \
+				&& cf_fix_cppflags=yes
+
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		(*$cf_add_cflags)
+			;;
+		(*)
+			case "$cf_add_cflags" in
+			(-D*)
+				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
+		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`
+
+				;;
+			esac
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
+			;;
+		esac
+		;;
+	(*)
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
+		;;
+	esac
+	;;
+(yes)
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
+
+	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+		&& test -z "${cf_tst_cflags}" \
+		&& cf_fix_cppflags=no
+	;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+done
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in `$PKG_CONFIG --libs "$MENU_NAME$cf_cv_libtype"`; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
+			cf_add_1lib=
+			break
+		fi
+	done
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
+done
+LIBS="$cf_add_libs"
+
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 17798 "configure"
+#include "confdefs.h"
+#include <$MENU_NAME.h>
+int
+main (void)
+{
+(void) menu_driver ( 0,0 );
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:17810: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:17813: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:17816: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:17819: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  if test "$cross_compiling" = yes; then
+  cf_have_curses_lib=maybe
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 17825 "configure"
+#include "confdefs.h"
+#include <$MENU_NAME.h>
+				int main(void)
+				{ (void) menu_driver ( 0,0 ); return 0; }
+_ACEOF
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:17832: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:17835: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:17837: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:17840: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_have_curses_lib=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_have_curses_lib=no
+fi
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_have_curses_lib=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+		echo "$as_me:17857: result: $cf_have_curses_lib" >&5
+echo "${ECHO_T}$cf_have_curses_lib" >&6
+		test "$cf_have_curses_lib" = maybe && cf_have_curses_lib=yes
+		if test "$cf_have_curses_lib" = "yes"
+		then
+
+cf_upper=`echo "have_lib$MENU_NAME" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+			cat >>confdefs.h <<EOF
+#define $cf_upper 1
+EOF
+
+		else
+			CFLAGS="$cf_save_CFLAGS"
+			CPPFLAGS="$cf_save_CPPFLAGS"
+			LIBS="$cf_save_LIBS"
+		fi
+	fi
+fi
+if test "$cf_have_curses_lib" = no; then
+	as_ac_Lib=`echo "ac_cv_lib_$MENU_NAME$cf_cv_libtype''_menu_driver" | $as_tr_sh`
+echo "$as_me:17878: checking for menu_driver in -l$MENU_NAME$cf_cv_libtype" >&5
+echo $ECHO_N "checking for menu_driver in -l$MENU_NAME$cf_cv_libtype... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Lib+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-l$MENU_NAME$cf_cv_libtype  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 17886 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char menu_driver (void);
+int
+main (void)
+{
+menu_driver ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:17905: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:17908: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:17911: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:17914: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  eval "$as_ac_Lib=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+eval "$as_ac_Lib=no"
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:17925: result: `eval echo '${'"$as_ac_Lib"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Lib"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Lib"'}'`" = yes; then
+
+cf_upper=`echo "have_lib$MENU_NAME" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -l$MENU_NAME$cf_cv_libtype; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
+			cf_add_1lib=
+			break
+		fi
+	done
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
+done
+LIBS="$cf_add_libs"
+
+		cat >>confdefs.h <<EOF
+#define $cf_upper 1
+EOF
+
+fi
+
+fi
+
+	cf_curses_headers="$cf_curses_headers menu.h"
+fi
+
+echo "$as_me:17958: checking if you want to check for form functions" >&5
+echo $ECHO_N "checking if you want to check for form functions... $ECHO_C" >&6
+
+# Check whether --enable-form or --disable-form was given.
+if test "${enable_form+set}" = set; then
+  enableval="$enable_form"
+  test "$enableval" != no && enableval=yes
+	if test "$enableval" != "yes" ; then
+    cf_enable_form=no
+	else
+		cf_enable_form=$cf_default_form
+	fi
+else
+  enableval=yes
+	cf_enable_form=$cf_default_form
+
+fi;
+echo "$as_me:17975: result: $cf_enable_form" >&5
+echo "${ECHO_T}$cf_enable_form" >&6
+if test $cf_enable_form = yes
+then
+	case $cf_cv_screen in
+	(ncurses*)
+		;;
+	(curses*)
+
+echo "$as_me:17984: checking for NetBSD form.h" >&5
 echo $ECHO_N "checking for NetBSD form.h... $ECHO_C" >&6
 if test "${cf_cv_netbsd_form_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 12995 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 17991 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
 #include <form.h>
 
 int
-main ()
+main (void)
 {
 
 	FORM *form;
@@ -13010,29 +18006,29 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:13014: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:18010: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13017: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:13020: \"$ac_try\"") >&5
+  echo "$as_me:18013: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:18016: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13023: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:18019: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_netbsd_form_h=yes
 
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_netbsd_form_h=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:13035: result: $cf_cv_netbsd_form_h" >&5
+echo "$as_me:18031: result: $cf_cv_netbsd_form_h" >&5
 echo "${ECHO_T}$cf_cv_netbsd_form_h" >&6
 
 test "$cf_cv_netbsd_form_h" = yes &&
@@ -13040,231 +18036,260 @@
 #define HAVE_NETBSD_FORM_H 1
 EOF
 
-echo "$as_me:13043: checking for NetBSD menu.h" >&5
-echo $ECHO_N "checking for NetBSD menu.h... $ECHO_C" >&6
-if test "${cf_cv_netbsd_menu_h+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+		;;
+	esac
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 13050 "configure"
-#include "confdefs.h"
+cf_have_curses_lib=no
 
-#include <${cf_cv_ncurses_header:-curses.h}>
-#include <menu.h>
+: ${NCURSES_CONFIG_PKG:=none}
+if test "x${NCURSES_CONFIG_PKG}" = xnone; then
+	:
+elif test "x${PKG_CONFIG:=none}" != xnone; then
+	echo "$as_me:18048: checking pkg-config for $FORM_NAME$cf_cv_libtype" >&5
+echo $ECHO_N "checking pkg-config for $FORM_NAME$cf_cv_libtype... $ECHO_C" >&6
+	if "$PKG_CONFIG" --exists "$FORM_NAME$cf_cv_libtype" ; then
+		echo "$as_me:18051: result: yes" >&5
+echo "${ECHO_T}yes" >&6
 
-int
-main ()
-{
+		echo "$as_me:18054: checking if the $FORM_NAME$cf_cv_libtype package files work" >&5
+echo $ECHO_N "checking if the $FORM_NAME$cf_cv_libtype package files work... $ECHO_C" >&6
 
-	MENU *menu;
-	int y = menu->max_item_width;
+		cf_save_CFLAGS="$CFLAGS"
+		cf_save_CPPFLAGS="$CPPFLAGS"
+		cf_save_LIBS="$LIBS"
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:13068: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:13071: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:13074: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:13077: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_netbsd_menu_h=yes
+for cf_add_cflags in `$PKG_CONFIG --cflags "$FORM_NAME$cf_cv_libtype"`
+do
+	case "x$cf_add_cflags" in
+	(x-[DU]*)
 
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_netbsd_menu_h=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CFLAGS" != "$cf_old_cflag" || break
 
-fi
-echo "$as_me:13089: result: $cf_cv_netbsd_menu_h" >&5
-echo "${ECHO_T}$cf_cv_netbsd_menu_h" >&6
+	CFLAGS="$cf_old_cflag"
+done
 
-test "$cf_cv_netbsd_menu_h" = yes &&
-cat >>confdefs.h <<\EOF
-#define HAVE_NETBSD_MENU_H 1
-EOF
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CPPFLAGS" != "$cf_old_cflag" || break
 
+	CPPFLAGS="$cf_old_cflag"
+done
+
+		;;
+	esac
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_add_cflags
+do
+case "$cf_fix_cppflags" in
+(no)
+	case "$cf_add_cflags" in
+	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+		case "$cf_add_cflags" in
+		(-D*)
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+				&& test -z "${cf_tst_cflags}" \
+				&& cf_fix_cppflags=yes
+
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		(*$cf_add_cflags)
+			;;
+		(*)
+			case "$cf_add_cflags" in
+			(-D*)
+				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
+		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`
+
+				;;
+			esac
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
+			;;
+		esac
+		;;
+	(*)
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
+		;;
+	esac
+	;;
+(yes)
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
+
+	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
+		&& test -z "${cf_tst_cflags}" \
+		&& cf_fix_cppflags=no
 	;;
 esac
+done
 
-case $cf_cv_screen in
-(pdcurses)
-	;;
-(*)
-	# look for curses-related libraries
+if test -n "$cf_new_cflags" ; then
 
-as_ac_Lib=`echo "ac_cv_lib_panel$cf_cv_libtype''_new_panel" | $as_tr_sh`
-echo "$as_me:13107: checking for new_panel in -lpanel$cf_cv_libtype" >&5
-echo $ECHO_N "checking for new_panel in -lpanel$cf_cv_libtype... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpanel$cf_cv_libtype  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 13115 "configure"
-#include "confdefs.h"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char new_panel ();
-int
-main ()
-{
-new_panel ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:13134: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:13137: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:13140: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:13143: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-eval "$as_ac_Lib=no"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+
+if test -n "$cf_new_cppflags" ; then
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
-echo "$as_me:13154: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
 
-cf_upper=`echo "have_libpanel" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+if test -n "$cf_new_extra_cppflags" ; then
 
-cf_add_libs="-lpanel$cf_cv_libtype"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
+fi
+
+done
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in `$PKG_CONFIG --libs "$FORM_NAME$cf_cv_libtype"`; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
-cat >>confdefs.h <<EOF
-#define $cf_upper 1
-EOF
-
-fi
-
-as_ac_Lib=`echo "ac_cv_lib_menu$cf_cv_libtype''_menu_driver" | $as_tr_sh`
-echo "$as_me:13183: checking for menu_driver in -lmenu$cf_cv_libtype" >&5
-echo $ECHO_N "checking for menu_driver in -lmenu$cf_cv_libtype... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lmenu$cf_cv_libtype  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 13191 "configure"
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 18204 "configure"
 #include "confdefs.h"
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char menu_driver ();
+#include <$FORM_NAME.h>
 int
-main ()
+main (void)
 {
-menu_driver ();
+(void) form_driver ( 0,0 );
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:13210: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:18216: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:13213: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:13216: \"$ac_try\"") >&5
+  echo "$as_me:18219: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:18222: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13219: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
+  echo "$as_me:18225: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  if test "$cross_compiling" = yes; then
+  cf_have_curses_lib=maybe
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 18231 "configure"
+#include "confdefs.h"
+#include <$FORM_NAME.h>
+				int main(void)
+				{ (void) form_driver ( 0,0 ); return 0; }
+_ACEOF
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:18238: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:18241: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:18243: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:18246: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_have_curses_lib=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_have_curses_lib=no
+fi
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
+fi
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-eval "$as_ac_Lib=no"
+cat "conftest.$ac_ext" >&5
+cf_have_curses_lib=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:13230: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-
-cf_upper=`echo "have_libmenu" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
-
-cf_add_libs="-lmenu$cf_cv_libtype"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+		echo "$as_me:18263: result: $cf_have_curses_lib" >&5
+echo "${ECHO_T}$cf_have_curses_lib" >&6
+		test "$cf_have_curses_lib" = maybe && cf_have_curses_lib=yes
+		if test "$cf_have_curses_lib" = "yes"
 		then
-			cf_add_1lib=
-			break
-		fi
-	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
-done
-LIBS="$cf_add_libs"
 
-cat >>confdefs.h <<EOF
+cf_upper=`echo "have_lib$FORM_NAME" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+			cat >>confdefs.h <<EOF
 #define $cf_upper 1
 EOF
 
+		else
+			CFLAGS="$cf_save_CFLAGS"
+			CPPFLAGS="$cf_save_CPPFLAGS"
+			LIBS="$cf_save_LIBS"
+		fi
+	fi
 fi
-
-as_ac_Lib=`echo "ac_cv_lib_form$cf_cv_libtype''_form_driver" | $as_tr_sh`
-echo "$as_me:13259: checking for form_driver in -lform$cf_cv_libtype" >&5
-echo $ECHO_N "checking for form_driver in -lform$cf_cv_libtype... $ECHO_C" >&6
+if test "$cf_have_curses_lib" = no; then
+	as_ac_Lib=`echo "ac_cv_lib_$FORM_NAME$cf_cv_libtype''_form_driver" | $as_tr_sh`
+echo "$as_me:18284: checking for form_driver in -l$FORM_NAME$cf_cv_libtype" >&5
+echo $ECHO_N "checking for form_driver in -l$FORM_NAME$cf_cv_libtype... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Lib+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lform$cf_cv_libtype  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 13267 "configure"
+LIBS="-l$FORM_NAME$cf_cv_libtype  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 18292 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -13273,94 +18298,92 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char form_driver ();
+char form_driver (void);
 int
-main ()
+main (void)
 {
 form_driver ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:13286: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:18311: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:13289: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:13292: \"$ac_try\"") >&5
+  echo "$as_me:18314: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:18317: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13295: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:18320: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   eval "$as_ac_Lib=yes"
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 eval "$as_ac_Lib=no"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:13306: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
+echo "$as_me:18331: result: `eval echo '${'"$as_ac_Lib"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Lib"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Lib"'}'`" = yes; then
 
-cf_upper=`echo "have_libform" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+cf_upper=`echo "have_lib$FORM_NAME" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
-cf_add_libs="-lform$cf_cv_libtype"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -l$FORM_NAME$cf_cv_libtype; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
-cat >>confdefs.h <<EOF
+		cat >>confdefs.h <<EOF
 #define $cf_upper 1
 EOF
 
 fi
 
-	# look for curses-related headers
+fi
 
-for ac_header in \
-		nc_alloc.h \
-		nomacros.h \
-		form.h \
-		menu.h \
-		panel.h \
-		term_entry.h \
+	cf_curses_headers="$cf_curses_headers form.h"
+fi
 
+# look for curses-related headers
+
+for ac_header in $cf_curses_headers
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:13346: checking for $ac_header" >&5
+echo "$as_me:18369: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13352 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 18375 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:13356: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (eval echo "$as_me:18379: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:13362: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
+  echo "$as_me:18385: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
   else
@@ -13373,14 +18396,14 @@
   eval "$as_ac_Header=yes"
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat "conftest.$ac_ext" >&5
   eval "$as_ac_Header=no"
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:13381: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
+echo "$as_me:18404: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
 EOF
@@ -13388,161 +18411,20 @@
 fi
 done
 
-	;;
-esac
-
-echo "$as_me:13394: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
-if test "${ac_cv_header_stdc+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13400 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-_ACEOF
-if { (eval echo "$as_me:13408: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:13414: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  ac_cv_header_stdc=yes
-else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  ac_cv_header_stdc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13436 "configure"
-#include "confdefs.h"
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "memchr" >/dev/null 2>&1; then
-  :
-else
-  ac_cv_header_stdc=no
-fi
-rm -rf conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13454 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "free" >/dev/null 2>&1; then
-  :
-else
-  ac_cv_header_stdc=no
-fi
-rm -rf conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then
-  :
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13475 "configure"
-#include "confdefs.h"
-#include <ctype.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
-                     || ('j' <= (c) && (c) <= 'r') \
-                     || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-        || toupper (i) != TOUPPER (i))
-      $ac_main_return(2);
-  $ac_main_return (0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:13501: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:13504: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:13506: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:13509: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_header_stdc=no
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-fi
-echo "$as_me:13522: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6
-if test $ac_cv_header_stdc = yes; then
-
-cat >>confdefs.h <<\EOF
-#define STDC_HEADERS 1
-EOF
-
-fi
-
-echo "$as_me:13532: checking whether time.h and sys/time.h may both be included" >&5
+echo "$as_me:18414: checking whether time.h and sys/time.h may both be included" >&5
 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
 if test "${ac_cv_header_time+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13538 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 18420 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
 #include <time.h>
 
 int
-main ()
+main (void)
 {
 if ((struct tm *) 0)
 return 0;
@@ -13550,27 +18432,27 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:13554: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:18436: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13557: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:13560: \"$ac_try\"") >&5
+  echo "$as_me:18439: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:18442: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13563: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:18445: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_header_time=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_header_time=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:13573: result: $ac_cv_header_time" >&5
+echo "$as_me:18455: result: $ac_cv_header_time" >&5
 echo "${ECHO_T}$ac_cv_header_time" >&6
 if test $ac_cv_header_time = yes; then
 
@@ -13593,24 +18475,24 @@
 
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:13596: checking for $ac_header" >&5
+echo "$as_me:18478: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13602 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 18484 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:13606: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (eval echo "$as_me:18488: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:13612: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
+  echo "$as_me:18494: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
   else
@@ -13623,14 +18505,14 @@
   eval "$as_ac_Header=yes"
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat "conftest.$ac_ext" >&5
   eval "$as_ac_Header=no"
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:13631: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
+echo "$as_me:18513: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
 EOF
@@ -13641,24 +18523,24 @@
 for ac_header in unistd.h getopt.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:13644: checking for $ac_header" >&5
+echo "$as_me:18526: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13650 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 18532 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:13654: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (eval echo "$as_me:18536: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:13660: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
+  echo "$as_me:18542: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
   else
@@ -13671,14 +18553,14 @@
   eval "$as_ac_Header=yes"
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat "conftest.$ac_ext" >&5
   eval "$as_ac_Header=no"
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:13679: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
+echo "$as_me:18561: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
 EOF
@@ -13686,7 +18568,7 @@
 fi
 done
 
-echo "$as_me:13689: checking for header declaring getopt variables" >&5
+echo "$as_me:18571: checking for header declaring getopt variables" >&5
 echo $ECHO_N "checking for header declaring getopt variables... $ECHO_C" >&6
 if test "${cf_cv_getopt_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -13695,51 +18577,51 @@
 cf_cv_getopt_header=none
 for cf_header in stdio.h stdlib.h unistd.h getopt.h
 do
-cat >conftest.$ac_ext <<_ACEOF
-#line 13699 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 18581 "configure"
 #include "confdefs.h"
 
 #include <$cf_header>
 int
-main ()
+main (void)
 {
-int x = optind; char *y = optarg
+int x = optind; char *y = optarg; (void)x; (void)y
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:13712: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:18594: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13715: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:13718: \"$ac_try\"") >&5
+  echo "$as_me:18597: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:18600: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13721: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:18603: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_getopt_header=$cf_header
  break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 done
 
 fi
-echo "$as_me:13733: result: $cf_cv_getopt_header" >&5
+echo "$as_me:18615: result: $cf_cv_getopt_header" >&5
 echo "${ECHO_T}$cf_cv_getopt_header" >&6
-if test $cf_cv_getopt_header != none ; then
+if test "$cf_cv_getopt_header" != none ; then
 
 cat >>confdefs.h <<\EOF
 #define HAVE_GETOPT_HEADER 1
 EOF
 
 fi
-if test $cf_cv_getopt_header = getopt.h ; then
+if test "$cf_cv_getopt_header" = getopt.h ; then
 
 cat >>confdefs.h <<\EOF
 #define NEED_GETOPT_H 1
@@ -13747,71 +18629,267 @@
 
 fi
 
-for ac_func in \
-getopt \
-gettimeofday \
-
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:13756: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
+echo "$as_me:18632: checking for clock_gettime" >&5
+echo $ECHO_N "checking for clock_gettime... $ECHO_C" >&6
+if test "${cf_cv_func_clock_gettime+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13762 "configure"
+
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 18639 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
+#include <time.h>
+int
+main (void)
+{
+struct timespec ts;
+		int rc = clock_gettime(CLOCK_REALTIME, &ts); (void) rc; (void)ts
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:18652: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:18655: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:18658: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:18661: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_func_clock_gettime=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_func_clock_gettime=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+
+fi
+echo "$as_me:18672: result: $cf_cv_func_clock_gettime" >&5
+echo "${ECHO_T}$cf_cv_func_clock_gettime" >&6
+
+if test "$cf_cv_func_clock_gettime" = yes
+then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_CLOCK_GETTIME 1
+EOF
+
+else
+echo "$as_me:18683: checking for gettimeofday" >&5
+echo $ECHO_N "checking for gettimeofday... $ECHO_C" >&6
+if test "${ac_cv_func_gettimeofday+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 18689 "configure"
+#include "confdefs.h"
+#define gettimeofday autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef gettimeofday
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gettimeofday (void);
+
+int
+main (void)
+{
+
+/* The GNU C library defines stubs for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_gettimeofday) || defined (__stub___gettimeofday)
+#error found stub for gettimeofday
+#endif
+
+	return gettimeofday ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:18720: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:18723: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:18726: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:18729: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_func_gettimeofday=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_func_gettimeofday=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+fi
+echo "$as_me:18739: result: $ac_cv_func_gettimeofday" >&5
+echo "${ECHO_T}$ac_cv_func_gettimeofday" >&6
+if test "$ac_cv_func_gettimeofday" = yes; then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_GETTIMEOFDAY 1
+EOF
+
+else
+
+echo "$as_me:18749: checking for gettimeofday in -lbsd" >&5
+echo $ECHO_N "checking for gettimeofday in -lbsd... $ECHO_C" >&6
+if test "${ac_cv_lib_bsd_gettimeofday+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lbsd  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 18757 "configure"
+#include "confdefs.h"
+
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
 extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-char (*f) ();
-
+char gettimeofday (void);
 int
-main ()
+main (void)
 {
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
-#endif
-
+gettimeofday ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:13793: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:18776: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:13796: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:13799: \"$ac_try\"") >&5
+  echo "$as_me:18779: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:18782: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13802: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:18785: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_lib_bsd_gettimeofday=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_lib_bsd_gettimeofday=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:18796: result: $ac_cv_lib_bsd_gettimeofday" >&5
+echo "${ECHO_T}$ac_cv_lib_bsd_gettimeofday" >&6
+if test "$ac_cv_lib_bsd_gettimeofday" = yes; then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_GETTIMEOFDAY 1
+EOF
+
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -lbsd; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
+			cf_add_1lib=
+			break
+		fi
+	done
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
+done
+LIBS="$cf_add_libs"
+
+fi
+
+fi
+fi
+
+for ac_func in \
+getopt \
+snprintf \
+strdup \
+strstr \
+tsearch \
+
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:18834: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 18840 "configure"
+#include "confdefs.h"
+#define $ac_func autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef $ac_func
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func (void);
+
+int
+main (void)
+{
+
+/* The GNU C library defines stubs for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+#error found stub for $ac_func
+#endif
+
+	return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:18871: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:18874: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:18877: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:18880: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   eval "$as_ac_var=yes"
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 eval "$as_ac_var=no"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:13812: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
+echo "$as_me:18890: result: `eval echo '${'"$as_ac_var"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_var"'}'`" >&6
+if test "`eval echo '${'"$as_ac_var"'}'`" = yes; then
   cat >>confdefs.h <<EOF
 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
 EOF
@@ -13819,8 +18897,122 @@
 fi
 done
 
+# use a compile-check to work with ncurses*-config and subdirectory includes
+echo "$as_me:18901: checking if we can use termcap.h" >&5
+echo $ECHO_N "checking if we can use termcap.h... $ECHO_C" >&6
+if test "${cf_cv_have_termcap_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 18908 "configure"
+#include "confdefs.h"
+
+#include <curses.h>
+#ifdef NCURSES_VERSION
+#undef NCURSES_VERSION
+#endif
+#include <termcap.h>
+#ifndef NCURSES_VERSION
+#error wrong header
+#endif
+
+int
+main (void)
+{
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:18929: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:18932: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:18935: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:18938: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_have_termcap_h=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_have_termcap_h=no
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+echo "$as_me:18948: result: $cf_cv_have_termcap_h" >&5
+echo "${ECHO_T}$cf_cv_have_termcap_h" >&6
+if test "x$cf_cv_have_termcap_h" = xyes
+then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_TERMCAP_H 1
+EOF
+
+else
+echo "$as_me:18958: checking if we can use ncurses/termcap.h" >&5
+echo $ECHO_N "checking if we can use ncurses/termcap.h... $ECHO_C" >&6
+if test "${cf_cv_have_ncurses_termcap_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 18965 "configure"
+#include "confdefs.h"
+
+#include <ncurses/curses.h>
+#ifdef NCURSES_VERSION
+#undef NCURSES_VERSION
+#endif
+#include <ncurses/termcap.h>
+#ifndef NCURSES_VERSION
+#error wrong header
+#endif
+
+int
+main (void)
+{
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:18986: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:18989: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:18992: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:18995: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_have_ncurses_termcap_h=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_have_ncurses_termcap_h=no
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+echo "$as_me:19005: result: $cf_cv_have_ncurses_termcap_h" >&5
+echo "${ECHO_T}$cf_cv_have_ncurses_termcap_h" >&6
+test "x$cf_cv_have_ncurses_termcap_h" = xyes &&
+cat >>confdefs.h <<\EOF
+#define HAVE_NCURSES_TERMCAP_H 1
+EOF
+
+fi
+
 if test "x$ac_cv_func_getopt" = xno; then
-	{ { echo "$as_me:13823: error: getopt is required for building programs" >&5
+	{ { echo "$as_me:19015: error: getopt is required for building programs" >&5
 echo "$as_me: error: getopt is required for building programs" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -13839,65 +19031,65 @@
 
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:13842: checking for $ac_func" >&5
+echo "$as_me:19034: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 13848 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 19040 "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
+#define $ac_func autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef $ac_func
+
 #ifdef __cplusplus
 extern "C"
 #endif
+
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-char (*f) ();
+char $ac_func (void);
 
 int
-main ()
+main (void)
 {
-/* The GNU C library defines this for functions which it implements
+
+/* The GNU C library defines stubs for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
+#error found stub for $ac_func
 #endif
 
+	return $ac_func ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:13879: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:19071: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:13882: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:13885: \"$ac_try\"") >&5
+  echo "$as_me:19074: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:19077: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13888: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:19080: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   eval "$as_ac_var=yes"
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 eval "$as_ac_var=no"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:13898: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
+echo "$as_me:19090: result: `eval echo '${'"$as_ac_var"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_var"'}'`" >&6
+if test "`eval echo '${'"$as_ac_var"'}'`" = yes; then
   cat >>confdefs.h <<EOF
 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
 EOF
@@ -13907,99 +19099,128 @@
 
 fi
 
-echo "$as_me:13910: checking if we must define _XOPEN_SOURCE_EXTENDED" >&5
-echo $ECHO_N "checking if we must define _XOPEN_SOURCE_EXTENDED... $ECHO_C" >&6
+echo "$as_me:19102: checking definition to turn on extended curses functions" >&5
+echo $ECHO_N "checking definition to turn on extended curses functions... $ECHO_C" >&6
 if test "${cf_cv_need_xopen_extension+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 13917 "configure"
+cf_cv_need_xopen_extension=unknown
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 19110 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
+$ac_includes_default
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 
 #if defined(NCURSES_VERSION_PATCH)
 #if (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
-	make an error
+	#error disallow ncurses versions between 2020/04/03 and 2010/05/01
 #endif
 #endif
-	long x = winnstr(stdscr, "", 0);
-	int x1, y1;
-	getbegyx(stdscr, y1, x1)
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:13939: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:13942: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:13945: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:13948: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_need_xopen_extension=no
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cat >conftest.$ac_ext <<_ACEOF
-#line 13955 "configure"
-#include "confdefs.h"
-
-#define _XOPEN_SOURCE_EXTENDED
-#include <stdlib.h>
-#include <${cf_cv_ncurses_header:-curses.h}>
-int
-main ()
-{
-
-#ifdef NCURSES_VERSION
+#ifdef NCURSES_WIDECHAR
+#error prefer to fall-through on the second checks
+#endif
+	static char dummy[10];
 	cchar_t check;
 	int check2 = curs_set((int)sizeof(check));
-#endif
-	long x = winnstr(stdscr, "", 0);
+	long x = winnstr(stdscr, dummy, 5);
 	int x1, y1;
-	getbegyx(stdscr, y1, x1)
+	(void)check2;
+	getbegyx(stdscr, y1, x1);
+	(void)x;
+	(void)y1;
+	(void)x1;
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:13977: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:19143: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:13980: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:13983: \"$ac_try\"") >&5
+  echo "$as_me:19146: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:19149: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13986: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_need_xopen_extension=yes
+  echo "$as_me:19152: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_need_xopen_extension=none
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_need_xopen_extension=unknown
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:13998: result: $cf_cv_need_xopen_extension" >&5
-echo "${ECHO_T}$cf_cv_need_xopen_extension" >&6
-test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
+cat "conftest.$ac_ext" >&5
 
-echo "$as_me:14002: checking for term.h" >&5
+	for cf_try_xopen_extension in _XOPEN_SOURCE_EXTENDED NCURSES_WIDECHAR
+	do
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 19162 "configure"
+#include "confdefs.h"
+
+#define $cf_try_xopen_extension 1
+$ac_includes_default
+#include <${cf_cv_ncurses_header:-curses.h}>
+int
+main (void)
+{
+
+		static char dummy[10];
+		cchar_t check;
+		int check2 = curs_set((int)sizeof(check));
+		long x = winnstr(stdscr, dummy, 5);
+		int x1, y1;
+		getbegyx(stdscr, y1, x1);
+		(void)check2;
+		(void)x;
+		(void)y1;
+		(void)x1;
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:19188: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:19191: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:19194: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:19197: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_need_xopen_extension=$cf_try_xopen_extension; break
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+	done
+
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+
+fi
+echo "$as_me:19211: result: $cf_cv_need_xopen_extension" >&5
+echo "${ECHO_T}$cf_cv_need_xopen_extension" >&6
+
+case "$cf_cv_need_xopen_extension" in
+(*_*)
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-D$cf_cv_need_xopen_extension"
+
+	;;
+esac
+
+echo "$as_me:19223: checking for term.h" >&5
 echo $ECHO_N "checking for term.h... $ECHO_C" >&6
 if test "${cf_cv_term_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -14010,104 +19231,104 @@
 
 cf_header_list="term.h ncurses/term.h ncursesw/term.h"
 
-case ${cf_cv_ncurses_header:-curses.h} in
+case "${cf_cv_ncurses_header:-curses.h}" in
 (*/*)
-	cf_header_item=`echo ${cf_cv_ncurses_header:-curses.h} | sed -e 's%\..*%%' -e 's%/.*%/%'`term.h
+	cf_header_item=`echo "${cf_cv_ncurses_header:-curses.h}" | sed -e 's%\..*%%' -e 's%/.*%/%'`term.h
 	cf_header_list="$cf_header_item $cf_header_list"
 	;;
 esac
 
 for cf_header in $cf_header_list
 do
-	cat >conftest.$ac_ext <<_ACEOF
-#line 14023 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 19244 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
 #include <${cf_header}>
 int
-main ()
+main (void)
 {
-WINDOW *x
+WINDOW *x; (void)x
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14037: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:19258: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:14040: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14043: \"$ac_try\"") >&5
+  echo "$as_me:19261: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:19264: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14046: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:19267: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_term_header=$cf_header
 	 break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_term_header=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 done
 
-case $cf_cv_term_header in
+case "$cf_cv_term_header" in
 (no)
 	# If curses is ncurses, some packagers still mess it up by trying to make
 	# us use GNU termcap.  This handles the most common case.
 	for cf_header in ncurses/term.h ncursesw/term.h
 	do
-		cat >conftest.$ac_ext <<_ACEOF
-#line 14065 "configure"
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 19286 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
 #ifdef NCURSES_VERSION
 #include <${cf_header}>
 #else
-make an error
+#error expected NCURSES_VERSION to be defined
 #endif
 int
-main ()
+main (void)
 {
-WINDOW *x
+WINDOW *x; (void)x
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14083: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:19304: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:14086: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14089: \"$ac_try\"") >&5
+  echo "$as_me:19307: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:19310: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14092: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:19313: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_term_header=$cf_header
 			 break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_term_header=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 	done
 	;;
 esac
 
 fi
-echo "$as_me:14107: result: $cf_cv_term_header" >&5
+echo "$as_me:19328: result: $cf_cv_term_header" >&5
 echo "${ECHO_T}$cf_cv_term_header" >&6
 
-case $cf_cv_term_header in
+case "$cf_cv_term_header" in
 (term.h)
 
 cat >>confdefs.h <<\EOF
@@ -14131,7 +19352,7 @@
 	;;
 esac
 
-echo "$as_me:14134: checking for unctrl.h" >&5
+echo "$as_me:19355: checking for unctrl.h" >&5
 echo $ECHO_N "checking for unctrl.h... $ECHO_C" >&6
 if test "${cf_cv_unctrl_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -14142,63 +19363,63 @@
 
 cf_header_list="unctrl.h ncurses/unctrl.h ncursesw/unctrl.h"
 
-case ${cf_cv_ncurses_header:-curses.h} in
+case "${cf_cv_ncurses_header:-curses.h}" in
 (*/*)
-	cf_header_item=`echo ${cf_cv_ncurses_header:-curses.h} | sed -e 's%\..*%%' -e 's%/.*%/%'`unctrl.h
+	cf_header_item=`echo "${cf_cv_ncurses_header:-curses.h}" | sed -e 's%\..*%%' -e 's%/.*%/%'`unctrl.h
 	cf_header_list="$cf_header_item $cf_header_list"
 	;;
 esac
 
 for cf_header in $cf_header_list
 do
-	cat >conftest.$ac_ext <<_ACEOF
-#line 14155 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 19376 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
 #include <${cf_header}>
 int
-main ()
+main (void)
 {
-WINDOW *x
+WINDOW *x; (void)x
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14169: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:19390: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:14172: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14175: \"$ac_try\"") >&5
+  echo "$as_me:19393: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:19396: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14178: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:19399: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_unctrl_header=$cf_header
 	 break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_unctrl_header=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 done
 
 fi
-echo "$as_me:14191: result: $cf_cv_unctrl_header" >&5
+echo "$as_me:19412: result: $cf_cv_unctrl_header" >&5
 echo "${ECHO_T}$cf_cv_unctrl_header" >&6
 
-case $cf_cv_unctrl_header in
+case "$cf_cv_unctrl_header" in
 (no)
-	{ echo "$as_me:14196: WARNING: unctrl.h header not found" >&5
+	{ echo "$as_me:19417: WARNING: unctrl.h header not found" >&5
 echo "$as_me: WARNING: unctrl.h header not found" >&2;}
 	;;
 esac
 
-case $cf_cv_unctrl_header in
+case "$cf_cv_unctrl_header" in
 (unctrl.h)
 
 cat >>confdefs.h <<\EOF
@@ -14223,9 +19444,19 @@
 esac
 
 for cf_func in \
+_nc_tparm_analyze \
+_tracef \
+alloc_pair \
 assume_default_colors \
 chgat \
+color_content \
 color_set \
+copywin \
+curses_trace \
+delscreen \
+dupwin \
+exit_curses \
+exit_terminfo \
 filter \
 getbegx \
 getcurx \
@@ -14233,22 +19464,35 @@
 getnstr \
 getparx \
 getwin \
+halfdelay \
+init_extended_color \
+mvderwin \
 mvvline \
+mvwin \
 mvwvline \
 napms \
+newpad \
 putwin \
+reset_color_pairs \
 resize_term \
 resizeterm \
+restartterm \
 ripoffline \
 scr_dump \
 setupterm \
 slk_color \
 slk_init \
 termattrs \
+termname \
 tgetent \
 tigetnum \
 tigetstr \
+tiparm \
+tiparm_s \
+tiscan_s \
+tputs_sp \
 typeahead \
+unget_wch \
 use_default_colors \
 use_env \
 use_extended_names \
@@ -14259,6 +19503,7 @@
 vsscanf \
 vw_printw \
 wchgat \
+winsdelln \
 winsstr \
 wresize \
 wsyncdown \
@@ -14267,10 +19512,10 @@
 
 cf_tr_func=`echo "$cf_func" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
-	echo "$as_me:14270: checking for ${cf_func}" >&5
+	echo "$as_me:19515: checking for ${cf_func}" >&5
 echo $ECHO_N "checking for ${cf_func}... $ECHO_C" >&6
 
-echo "${as_me:-configure}:14273: testing ${cf_func} ..." 1>&5
+echo "${as_me:-configure}:19518: testing ${cf_func} ..." 1>&5
 
 	if eval "test \"\${cf_cv_func_$cf_func+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -14278,8 +19523,8 @@
 
 		eval cf_result='$ac_cv_func_'$cf_func
 		if test ".$cf_result" != ".no"; then
-			cat >conftest.$ac_ext <<_ACEOF
-#line 14282 "configure"
+			cat >"conftest.$ac_ext" <<_ACEOF
+#line 19527 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_XCURSES
@@ -14297,49 +19542,49 @@
 #endif
 
 int
-main ()
+main (void)
 {
 
 #ifndef ${cf_func}
 long foo = (long)(&${cf_func});
-fprintf(stderr, "testing linkage of $cf_func:%p\n", foo);
-if (foo + 1234 > 5678)
-	${cf_cv_main_return:-return}(foo);
+fprintf(stderr, "testing linkage of $cf_func:%p\\n", (void *)foo);
+if (foo + 1234L > 5678L)
+	${cf_cv_main_return:-return}(foo != 0);
 #endif
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:14315: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:19560: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14318: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:14321: \"$ac_try\"") >&5
+  echo "$as_me:19563: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:19566: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14324: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:19569: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_result=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 		fi
-		eval 'cf_cv_func_'$cf_func'=$cf_result'
+		eval 'cf_cv_func_'$cf_func'="$cf_result"'
 
 fi
 
 	# use the computed/retrieved cache-value:
 	eval 'cf_result=$cf_cv_func_'$cf_func
-	echo "$as_me:14340: result: $cf_result" >&5
+	echo "$as_me:19585: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
-	if test $cf_result != no; then
+	if test "$cf_result" != no; then
 		cat >>confdefs.h <<EOF
 #define HAVE_${cf_tr_func} 1
 EOF
@@ -14352,10 +19597,10 @@
 
 cf_tr_func=`echo "$cf_func" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
-	echo "$as_me:14355: checking for ${cf_func}" >&5
+	echo "$as_me:19600: checking for ${cf_func}" >&5
 echo $ECHO_N "checking for ${cf_func}... $ECHO_C" >&6
 
-echo "${as_me:-configure}:14358: testing ${cf_func} ..." 1>&5
+echo "${as_me:-configure}:19603: testing ${cf_func} ..." 1>&5
 
 	if eval "test \"\${cf_cv_func_$cf_func+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -14363,8 +19608,8 @@
 
 		eval cf_result='$ac_cv_func_'$cf_func
 		if test ".$cf_result" != ".no"; then
-			cat >conftest.$ac_ext <<_ACEOF
-#line 14367 "configure"
+			cat >"conftest.$ac_ext" <<_ACEOF
+#line 19612 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_XCURSES
@@ -14382,49 +19627,49 @@
 #endif
 
 int
-main ()
+main (void)
 {
 
 #ifndef ${cf_func}
 long foo = (long)(&${cf_func});
-fprintf(stderr, "testing linkage of $cf_func:%p\n", foo);
-if (foo + 1234 > 5678)
-	${cf_cv_main_return:-return}(foo);
+fprintf(stderr, "testing linkage of $cf_func:%p\\n", (void *)foo);
+if (foo + 1234L > 5678L)
+	${cf_cv_main_return:-return}(foo != 0);
 #endif
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:14400: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:19645: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14403: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:14406: \"$ac_try\"") >&5
+  echo "$as_me:19648: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:19651: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14409: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:19654: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_result=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 		fi
-		eval 'cf_cv_func_'$cf_func'=$cf_result'
+		eval 'cf_cv_func_'$cf_func'="$cf_result"'
 
 fi
 
 	# use the computed/retrieved cache-value:
 	eval 'cf_result=$cf_cv_func_'$cf_func
-	echo "$as_me:14425: result: $cf_result" >&5
+	echo "$as_me:19670: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
-	if test $cf_result != no; then
+	if test "$cf_result" != no; then
 		cat >>confdefs.h <<EOF
 #define HAVE_${cf_tr_func} 1
 EOF
@@ -14432,21 +19677,21 @@
 	fi
 done
 
-if test x$cf_cv_func_tputs = xyes
+if test "x$cf_cv_func_tputs" = xyes
 then
 	cf_done=no
 	for cf_arg in int char
 	do
 		for cf_ret in int void
 		do
-			if test $cf_ret = void
+			if test "$cf_ret" = void
 			then
 				cf_return="/* nothing */"
 			else
 				cf_return="return value"
 			fi
-			cat >conftest.$ac_ext <<_ACEOF
-#line 14449 "configure"
+			cat >"conftest.$ac_ext" <<_ACEOF
+#line 19694 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
@@ -14455,7 +19700,7 @@
 static $cf_ret outc($cf_arg value) { $cf_return; }
 
 int
-main ()
+main (void)
 {
 
 	tputs("hello", 0, outc);
@@ -14465,22 +19710,22 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14469: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:19714: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:14472: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14475: \"$ac_try\"") >&5
+  echo "$as_me:19717: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:19720: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14478: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:19723: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
 
 		test -n "$verbose" && echo "	prototype $cf_ret func($cf_arg value)" 1>&6
 
-echo "${as_me:-configure}:14483: testing prototype $cf_ret func($cf_arg value) ..." 1>&5
+echo "${as_me:-configure}:19728: testing prototype $cf_ret func($cf_arg value) ..." 1>&5
 
 		cat >>confdefs.h <<EOF
 #define TPUTS_ARG               $cf_arg
@@ -14492,27 +19737,27 @@
 
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 		done
-		test $cf_done = yes && break
+		test "$cf_done" = yes && break
 	done
 fi
 
-echo "$as_me:14503: checking for ncurses extended functions" >&5
+echo "$as_me:19748: checking for ncurses extended functions" >&5
 echo $ECHO_N "checking for ncurses extended functions... $ECHO_C" >&6
 if test "${cf_cv_ncurses_ext_funcs+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 14510 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 19755 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 
 int x = NCURSES_EXT_FUNCS
@@ -14521,30 +19766,30 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14525: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:19770: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:14528: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14531: \"$ac_try\"") >&5
+  echo "$as_me:19773: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:19776: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14534: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:19779: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_ncurses_ext_funcs=defined
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 14542 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 19787 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 
 	(void) assume_default_colors (0, 0);
@@ -14563,31 +19808,31 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:14567: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:19812: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14570: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:14573: \"$ac_try\"") >&5
+  echo "$as_me:19815: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:19818: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14576: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:19821: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_ncurses_ext_funcs=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_ncurses_ext_funcs=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:14590: result: $cf_cv_ncurses_ext_funcs" >&5
+echo "$as_me:19835: result: $cf_cv_ncurses_ext_funcs" >&5
 echo "${ECHO_T}$cf_cv_ncurses_ext_funcs" >&6
 test "$cf_cv_ncurses_ext_funcs" = yes &&
 cat >>confdefs.h <<\EOF
@@ -14601,75 +19846,75 @@
 	if test -n "$cf_cv_ncurses_version" && test "x$cf_cv_ncurses_version" != xno
 	then
 		cf_define_xpg5=no
-		echo "$as_me:14604: checking if _XPG5 should be defined to enable wide-characters" >&5
+		echo "$as_me:19849: checking if _XPG5 should be defined to enable wide-characters" >&5
 echo $ECHO_N "checking if _XPG5 should be defined to enable wide-characters... $ECHO_C" >&6
 
-		cat >conftest.$ac_ext <<_ACEOF
-#line 14608 "configure"
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 19853 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 int x = _XPG5
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14621: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:19866: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:14624: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14627: \"$ac_try\"") >&5
+  echo "$as_me:19869: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:19872: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14630: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:19875: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   :
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_save_cppflags="$CPPFLAGS"
 			 CPPFLAGS="$CPPFLAGS -D_XPG5"
-			 cat >conftest.$ac_ext <<_ACEOF
-#line 14639 "configure"
+			 cat >"conftest.$ac_ext" <<_ACEOF
+#line 19884 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 int x = _XPG5
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14652: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:19897: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:14655: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14658: \"$ac_try\"") >&5
+  echo "$as_me:19900: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:19903: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14661: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:19906: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_define_xpg5=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 			 CPPFLAGS="$cf_save_cppflags"
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-		echo "$as_me:14672: result: $cf_define_xpg5" >&5
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+		echo "$as_me:19917: result: $cf_define_xpg5" >&5
 echo "${ECHO_T}$cf_define_xpg5" >&6
 
 		if test "$cf_define_xpg5" = yes
@@ -14678,19 +19923,19 @@
 		fi
 	fi
 
-	echo "$as_me:14681: checking for wide-character functions" >&5
+	echo "$as_me:19926: checking for wide-character functions" >&5
 echo $ECHO_N "checking for wide-character functions... $ECHO_C" >&6
 if test "${cf_cv_widechar_funcs+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-	cat >conftest.$ac_ext <<_ACEOF
-#line 14688 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 19933 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 
 		static wchar_t src_wchar[2];
@@ -14701,28 +19946,28 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:14705: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:19950: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14708: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:14711: \"$ac_try\"") >&5
+  echo "$as_me:19953: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:19956: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14714: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:19959: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_widechar_funcs=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_widechar_funcs=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:14725: result: $cf_cv_widechar_funcs" >&5
+echo "$as_me:19970: result: $cf_cv_widechar_funcs" >&5
 echo "${ECHO_T}$cf_cv_widechar_funcs" >&6
 	if test "$cf_cv_widechar_funcs" != no ; then
 
@@ -14743,21 +19988,21 @@
 
 fi
 
-echo "$as_me:14746: checking if $cf_cv_screen library uses pthreads" >&5
+echo "$as_me:19991: checking if $cf_cv_screen library uses pthreads" >&5
 echo $ECHO_N "checking if $cf_cv_screen library uses pthreads... $ECHO_C" >&6
 if test "${cf_cv_use_pthreads+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 14753 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 19998 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
 extern void _nc_init_pthreads(void);
 
 int
-main ()
+main (void)
 {
 
 	initscr();
@@ -14767,41 +20012,42 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:14771: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:20016: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14774: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:14777: \"$ac_try\"") >&5
+  echo "$as_me:20019: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:20022: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14780: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20025: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_use_pthreads=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_use_pthreads=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:14791: result: $cf_cv_use_pthreads" >&5
+echo "$as_me:20036: result: $cf_cv_use_pthreads" >&5
 echo "${ECHO_T}$cf_cv_use_pthreads" >&6
-test $cf_cv_use_pthreads = yes && cat >>confdefs.h <<\EOF
+test $cf_cv_use_pthreads = yes &&
+cat >>confdefs.h <<\EOF
 #define USE_PTHREADS 1
 EOF
 
-echo "$as_me:14797: checking if sys/time.h works with sys/select.h" >&5
+echo "$as_me:20043: checking if sys/time.h works with sys/select.h" >&5
 echo $ECHO_N "checking if sys/time.h works with sys/select.h... $ECHO_C" >&6
 if test "${cf_cv_sys_time_select+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 14804 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 20050 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -14813,43 +20059,206 @@
 #endif
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:14824: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:20070: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:14827: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:14830: \"$ac_try\"") >&5
+  echo "$as_me:20073: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:20076: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14833: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20079: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_sys_time_select=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_sys_time_select=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
 
-echo "$as_me:14845: result: $cf_cv_sys_time_select" >&5
+echo "$as_me:20091: result: $cf_cv_sys_time_select" >&5
 echo "${ECHO_T}$cf_cv_sys_time_select" >&6
 test "$cf_cv_sys_time_select" = yes &&
 cat >>confdefs.h <<\EOF
 #define HAVE_SYS_TIME_SELECT 1
 EOF
 
-echo "$as_me:14852: checking for function curses_version" >&5
+# special check for test/ditto.c
+
+echo "$as_me:20100: checking for openpty in -lutil" >&5
+echo $ECHO_N "checking for openpty in -lutil... $ECHO_C" >&6
+if test "${ac_cv_lib_util_openpty+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lutil  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 20108 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char openpty (void);
+int
+main (void)
+{
+openpty ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:20127: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:20130: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:20133: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:20136: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_lib_util_openpty=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_lib_util_openpty=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:20147: result: $ac_cv_lib_util_openpty" >&5
+echo "${ECHO_T}$ac_cv_lib_util_openpty" >&6
+if test "$ac_cv_lib_util_openpty" = yes; then
+  cf_cv_lib_util=yes
+else
+  cf_cv_lib_util=no
+fi
+
+echo "$as_me:20155: checking for openpty header" >&5
+echo $ECHO_N "checking for openpty header... $ECHO_C" >&6
+if test "${cf_cv_func_openpty+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+	cf_save_LIBS="$LIBS"
+	test "$cf_cv_lib_util" = yes && {
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -lutil; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
+			cf_add_1lib=
+			break
+		fi
+	done
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
+done
+LIBS="$cf_add_libs"
+ }
+	for cf_header in pty.h libutil.h util.h
+	do
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 20182 "configure"
+#include "confdefs.h"
+
+#include <$cf_header>
+
+int
+main (void)
+{
+
+	int x = openpty((int *)0, (int *)0, (char *)0,
+				   (struct termios *)0, (struct winsize *)0);
+	(void)x;
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:20200: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:20203: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:20206: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:20209: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+
+		cf_cv_func_openpty=$cf_header
+		break
+
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+
+		cf_cv_func_openpty=no
+
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+	done
+	LIBS="$cf_save_LIBS"
+
+fi
+echo "$as_me:20227: result: $cf_cv_func_openpty" >&5
+echo "${ECHO_T}$cf_cv_func_openpty" >&6
+
+if test "$cf_cv_func_openpty" != no ; then
+
+cat >>confdefs.h <<EOF
+#define USE_OPENPTY_HEADER <$cf_cv_func_openpty>
+EOF
+
+cat >>confdefs.h <<\EOF
+#define USE_XTERM_PTY 1
+EOF
+
+	if test "x$cf_cv_lib_util" = xyes ; then
+
+cf_add_libs="$TEST_LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -lutil; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
+			cf_add_1lib=
+			break
+		fi
+	done
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
+done
+TEST_LIBS="$cf_add_libs"
+
+	fi
+fi
+
+echo "$as_me:20261: checking for function curses_version" >&5
 echo $ECHO_N "checking for function curses_version... $ECHO_C" >&6
 if test "${cf_cv_func_curses_version+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -14858,51 +20267,54 @@
 if test "$cross_compiling" = yes; then
   cf_cv_func_curses_version=unknown
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 14862 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 20271 "configure"
 #include "confdefs.h"
 
+$ac_includes_default
+
 #include <${cf_cv_ncurses_header:-curses.h}>
-int main()
+
+int main(void)
 {
 	char temp[1024];
-	sprintf(temp, "%s\n", curses_version());
+	sprintf(temp, "%.999s\\n", curses_version());
 	${cf_cv_main_return:-return}(0);
 }
 
 _ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:14875: \"$ac_link\"") >&5
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:20287: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14878: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:14880: \"$ac_try\"") >&5
+  echo "$as_me:20290: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:20292: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14883: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20295: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_func_curses_version=yes
 
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_func_curses_version=no
 
 fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 rm -f core
 fi
-echo "$as_me:14898: result: $cf_cv_func_curses_version" >&5
+echo "$as_me:20310: result: $cf_cv_func_curses_version" >&5
 echo "${ECHO_T}$cf_cv_func_curses_version" >&6
 test "$cf_cv_func_curses_version" = yes &&
 cat >>confdefs.h <<\EOF
 #define HAVE_CURSES_VERSION 1
 EOF
 
-echo "$as_me:14905: checking for alternate character set array" >&5
+echo "$as_me:20317: checking for alternate character set array" >&5
 echo $ECHO_N "checking for alternate character set array... $ECHO_C" >&6
 if test "${cf_cv_curses_acs_map+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -14911,44 +20323,44 @@
 cf_cv_curses_acs_map=unknown
 for name in acs_map _acs_map __acs_map ${NCURSES_WRAP_PREFIX}acs_map
 do
-cat >conftest.$ac_ext <<_ACEOF
-#line 14915 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 20327 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header:-curses.h}>
 
 int
-main ()
+main (void)
 {
 
-$name['k'] = ACS_PLUS
+${name}['k'] = ACS_PLUS
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:14931: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:20343: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14934: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:14937: \"$ac_try\"") >&5
+  echo "$as_me:20346: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:20349: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14940: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20352: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_curses_acs_map=$name; break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 done
 
 fi
-echo "$as_me:14951: result: $cf_cv_curses_acs_map" >&5
+echo "$as_me:20363: result: $cf_cv_curses_acs_map" >&5
 echo "${ECHO_T}$cf_cv_curses_acs_map" >&6
 
 test "$cf_cv_curses_acs_map" != unknown &&
@@ -14958,7 +20370,7 @@
 
 if test "$cf_enable_widec" = yes; then
 
-echo "$as_me:14961: checking for wide alternate character set array" >&5
+echo "$as_me:20373: checking for wide alternate character set array" >&5
 echo $ECHO_N "checking for wide alternate character set array... $ECHO_C" >&6
 if test "${cf_cv_curses_wacs_map+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -14967,8 +20379,8 @@
 	cf_cv_curses_wacs_map=unknown
 	for name in wacs_map _wacs_map __wacs_map _nc_wacs _wacs_char
 	do
-	cat >conftest.$ac_ext <<_ACEOF
-#line 14971 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 20383 "configure"
 #include "confdefs.h"
 
 #ifndef _XOPEN_SOURCE_EXTENDED
@@ -14976,35 +20388,35 @@
 #endif
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-void *foo = &($name['k'])
+void *foo = &(${name}['k']); (void)foo
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:14987: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:20399: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14990: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:14993: \"$ac_try\"") >&5
+  echo "$as_me:20402: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:20405: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14996: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20408: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_curses_wacs_map=$name
 	 break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 	done
 fi
-echo "$as_me:15007: result: $cf_cv_curses_wacs_map" >&5
+echo "$as_me:20419: result: $cf_cv_curses_wacs_map" >&5
 echo "${ECHO_T}$cf_cv_curses_wacs_map" >&6
 
 test "$cf_cv_curses_wacs_map" != unknown &&
@@ -15012,7 +20424,7 @@
 #define CURSES_WACS_ARRAY $cf_cv_curses_wacs_map
 EOF
 
-echo "$as_me:15015: checking for wide alternate character constants" >&5
+echo "$as_me:20427: checking for wide alternate character constants" >&5
 echo $ECHO_N "checking for wide alternate character constants... $ECHO_C" >&6
 if test "${cf_cv_curses_wacs_symbols+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -15021,8 +20433,8 @@
 cf_cv_curses_wacs_symbols=no
 if test "$cf_cv_curses_wacs_map" != unknown
 then
-	cat >conftest.$ac_ext <<_ACEOF
-#line 15025 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 20437 "configure"
 #include "confdefs.h"
 
 #ifndef _XOPEN_SOURCE_EXTENDED
@@ -15030,35 +20442,35 @@
 #endif
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 cchar_t *foo = WACS_PLUS;
-	 $cf_cv_curses_wacs_map['k'] = *WACS_PLUS
+	 ${cf_cv_curses_wacs_map}['k'] = *WACS_PLUS; (void)foo
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:15042: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:20454: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15045: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:15048: \"$ac_try\"") >&5
+  echo "$as_me:20457: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:20460: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15051: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20463: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_curses_wacs_symbols=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 else
-	cat >conftest.$ac_ext <<_ACEOF
-#line 15061 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 20473 "configure"
 #include "confdefs.h"
 
 #ifndef _XOPEN_SOURCE_EXTENDED
@@ -15066,35 +20478,35 @@
 #endif
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
-cchar_t *foo = WACS_PLUS
+cchar_t *foo = WACS_PLUS; (void)foo
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:15077: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:20489: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15080: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:15083: \"$ac_try\"") >&5
+  echo "$as_me:20492: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:20495: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15086: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20498: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_curses_wacs_symbols=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
 
 fi
-echo "$as_me:15097: result: $cf_cv_curses_wacs_symbols" >&5
+echo "$as_me:20509: result: $cf_cv_curses_wacs_symbols" >&5
 echo "${ECHO_T}$cf_cv_curses_wacs_symbols" >&6
 
 test "$cf_cv_curses_wacs_symbols" != no &&
@@ -15104,10 +20516,10 @@
 
 fi
 
-echo "$as_me:15107: checking for type attr_t in ${cf_cv_ncurses_header:-curses.h}" >&5
+echo "$as_me:20519: checking for type attr_t in ${cf_cv_ncurses_header:-curses.h}" >&5
 echo $ECHO_N "checking for type attr_t in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line 15110 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 20522 "configure"
 #include "confdefs.h"
 
 #ifndef _XOPEN_SOURCE_EXTENDED
@@ -15115,7 +20527,7 @@
 #endif
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 
 attr_t foo
@@ -15124,28 +20536,28 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15128: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:20540: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15131: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15134: \"$ac_try\"") >&5
+  echo "$as_me:20543: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:20546: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15137: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20549: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_result=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:15146: result: $cf_result" >&5
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+echo "$as_me:20558: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
-if test $cf_result = yes ; then
+if test "$cf_result" = yes ; then
 
 cf_result=`echo "have_type_attr_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
@@ -15164,14 +20576,14 @@
 if test "$cf_enable_widec" = yes; then
 
 # This is needed on Tru64 5.0 to declare mbstate_t
-echo "$as_me:15167: checking if we must include wchar.h to declare mbstate_t" >&5
+echo "$as_me:20579: checking if we must include wchar.h to declare mbstate_t" >&5
 echo $ECHO_N "checking if we must include wchar.h to declare mbstate_t... $ECHO_C" >&6
 if test "${cf_cv_mbstate_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 15174 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 20586 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -15181,31 +20593,31 @@
 #include <libutf8.h>
 #endif
 int
-main ()
+main (void)
 {
-mbstate_t state
+mbstate_t state; (void)state
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15192: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:20604: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15195: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15198: \"$ac_try\"") >&5
+  echo "$as_me:20607: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:20610: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15201: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20613: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_mbstate_t=no
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cat >conftest.$ac_ext <<_ACEOF
-#line 15208 "configure"
+cat "conftest.$ac_ext" >&5
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 20620 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -15216,36 +20628,36 @@
 #include <libutf8.h>
 #endif
 int
-main ()
+main (void)
 {
-mbstate_t value
+mbstate_t value; (void) value
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15227: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:20639: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15230: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15233: \"$ac_try\"") >&5
+  echo "$as_me:20642: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:20645: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15236: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20648: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_mbstate_t=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_mbstate_t=unknown
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:15248: result: $cf_cv_mbstate_t" >&5
+echo "$as_me:20660: result: $cf_cv_mbstate_t" >&5
 echo "${ECHO_T}$cf_cv_mbstate_t" >&6
 
 if test "$cf_cv_mbstate_t" = yes ; then
@@ -15268,14 +20680,14 @@
 fi
 
 # This is needed on Tru64 5.0 to declare wchar_t
-echo "$as_me:15271: checking if we must include wchar.h to declare wchar_t" >&5
+echo "$as_me:20683: checking if we must include wchar.h to declare wchar_t" >&5
 echo $ECHO_N "checking if we must include wchar.h to declare wchar_t... $ECHO_C" >&6
 if test "${cf_cv_wchar_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 15278 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 20690 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -15285,31 +20697,31 @@
 #include <libutf8.h>
 #endif
 int
-main ()
+main (void)
 {
-wchar_t state
+wchar_t state; (void)state
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15296: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:20708: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15299: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15302: \"$ac_try\"") >&5
+  echo "$as_me:20711: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:20714: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15305: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20717: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_wchar_t=no
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cat >conftest.$ac_ext <<_ACEOF
-#line 15312 "configure"
+cat "conftest.$ac_ext" >&5
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 20724 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -15320,36 +20732,36 @@
 #include <libutf8.h>
 #endif
 int
-main ()
+main (void)
 {
-wchar_t value
+wchar_t value; (void) value
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15331: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:20743: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15334: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15337: \"$ac_try\"") >&5
+  echo "$as_me:20746: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:20749: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15340: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20752: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_wchar_t=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_wchar_t=unknown
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:15352: result: $cf_cv_wchar_t" >&5
+echo "$as_me:20764: result: $cf_cv_wchar_t" >&5
 echo "${ECHO_T}$cf_cv_wchar_t" >&6
 
 if test "$cf_cv_wchar_t" = yes ; then
@@ -15372,14 +20784,14 @@
 fi
 
 # This is needed on Tru64 5.0 to declare wint_t
-echo "$as_me:15375: checking if we must include wchar.h to declare wint_t" >&5
+echo "$as_me:20787: checking if we must include wchar.h to declare wint_t" >&5
 echo $ECHO_N "checking if we must include wchar.h to declare wint_t... $ECHO_C" >&6
 if test "${cf_cv_wint_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 15382 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 20794 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -15389,31 +20801,31 @@
 #include <libutf8.h>
 #endif
 int
-main ()
+main (void)
 {
-wint_t state
+wint_t state; (void)state
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15400: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:20812: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15403: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15406: \"$ac_try\"") >&5
+  echo "$as_me:20815: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:20818: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15409: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20821: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_wint_t=no
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cat >conftest.$ac_ext <<_ACEOF
-#line 15416 "configure"
+cat "conftest.$ac_ext" >&5
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 20828 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -15424,36 +20836,36 @@
 #include <libutf8.h>
 #endif
 int
-main ()
+main (void)
 {
-wint_t value
+wint_t value; (void) value
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15435: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:20847: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15438: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15441: \"$ac_try\"") >&5
+  echo "$as_me:20850: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:20853: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15444: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20856: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_cv_wint_t=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_cv_wint_t=unknown
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:15456: result: $cf_cv_wint_t" >&5
+echo "$as_me:20868: result: $cf_cv_wint_t" >&5
 echo "${ECHO_T}$cf_cv_wint_t" >&6
 
 if test "$cf_cv_wint_t" = yes ; then
@@ -15477,10 +20889,10 @@
 
 	if test "$NCURSES_OK_MBSTATE_T" = 0 ; then
 
-echo "$as_me:15480: checking for type mbstate_t in ${cf_cv_ncurses_header:-curses.h}" >&5
+echo "$as_me:20892: checking for type mbstate_t in ${cf_cv_ncurses_header:-curses.h}" >&5
 echo $ECHO_N "checking for type mbstate_t in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line 15483 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 20895 "configure"
 #include "confdefs.h"
 
 #ifndef _XOPEN_SOURCE_EXTENDED
@@ -15488,7 +20900,7 @@
 #endif
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 
 mbstate_t foo
@@ -15497,28 +20909,28 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15501: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:20913: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15504: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15507: \"$ac_try\"") >&5
+  echo "$as_me:20916: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:20919: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15510: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20922: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_result=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:15519: result: $cf_result" >&5
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+echo "$as_me:20931: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
-if test $cf_result = yes ; then
+if test "$cf_result" = yes ; then
 
 cf_result=`echo "have_type_mbstate_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
@@ -15538,10 +20950,10 @@
 
 	if test "$NCURSES_OK_WCHAR_T" = 0 ; then
 
-echo "$as_me:15541: checking for type wchar_t in ${cf_cv_ncurses_header:-curses.h}" >&5
+echo "$as_me:20953: checking for type wchar_t in ${cf_cv_ncurses_header:-curses.h}" >&5
 echo $ECHO_N "checking for type wchar_t in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line 15544 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 20956 "configure"
 #include "confdefs.h"
 
 #ifndef _XOPEN_SOURCE_EXTENDED
@@ -15549,7 +20961,7 @@
 #endif
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 
 wchar_t foo
@@ -15558,28 +20970,28 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15562: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:20974: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15565: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15568: \"$ac_try\"") >&5
+  echo "$as_me:20977: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:20980: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15571: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:20983: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_result=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:15580: result: $cf_result" >&5
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+echo "$as_me:20992: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
-if test $cf_result = yes ; then
+if test "$cf_result" = yes ; then
 
 cf_result=`echo "have_type_wchar_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
@@ -15599,10 +21011,10 @@
 
 	if test "$NCURSES_OK_WINT_T" = 0 ; then
 
-echo "$as_me:15602: checking for type wint_t in ${cf_cv_ncurses_header:-curses.h}" >&5
+echo "$as_me:21014: checking for type wint_t in ${cf_cv_ncurses_header:-curses.h}" >&5
 echo $ECHO_N "checking for type wint_t in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line 15605 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 21017 "configure"
 #include "confdefs.h"
 
 #ifndef _XOPEN_SOURCE_EXTENDED
@@ -15610,7 +21022,7 @@
 #endif
 #include <${cf_cv_ncurses_header:-curses.h}>
 int
-main ()
+main (void)
 {
 
 wint_t foo
@@ -15619,28 +21031,28 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15623: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:21035: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15626: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15629: \"$ac_try\"") >&5
+  echo "$as_me:21038: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:21041: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15632: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:21044: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_result=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:15641: result: $cf_result" >&5
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+echo "$as_me:21053: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
-if test $cf_result = yes ; then
+if test "$cf_result" = yes ; then
 
 cf_result=`echo "have_type_wint_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
@@ -15659,11 +21071,19 @@
 	fi
 fi
 
-echo "$as_me:15662: checking for data ospeed declaration in ${cf_cv_ncurses_header:-curses.h}" >&5
-echo $ECHO_N "checking for data ospeed declaration in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
+for cf_data in \
+TABSIZE \
+curscr \
+ospeed \
+boolnames \
+boolfnames \
+ttytype
+do
+echo "$as_me:21082: checking for data $cf_data declaration in ${cf_cv_ncurses_header:-curses.h}" >&5
+echo $ECHO_N "checking for data $cf_data declaration in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 15666 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 21086 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_XCURSES
@@ -15681,54 +21101,60 @@
 #endif
 
 int
-main ()
+main (void)
 {
 
-void *foo = &(ospeed)
+#if defined($cf_data) && ((defined(NCURSES_WRAPPED_VAR) && (NCURSES_VERSION_PATCH < 20200208)) || defined(NCURSES_BROKEN_LINKER) || defined(NCURSES_REENTRANT))
+	const void *foo = (const void *)($cf_data);
+#else
+	const void *foo = &($cf_data);
+#endif
+	fprintf(stderr, "testing linkage of $cf_data:%p\\n", (const void *)foo);
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15694: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:21119: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15697: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15700: \"$ac_try\"") >&5
+  echo "$as_me:21122: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:21125: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15703: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:21128: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_result=yes
+
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_result=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:15712: result: $cf_result" >&5
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+echo "$as_me:21138: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
 
-if test $cf_result = yes ; then
+if test "$cf_result" = yes ; then
 
-cf_result=`echo "have_curses_data_ospeed" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+cf_result=`echo "have_curses_data_$cf_data" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
 	cat >>confdefs.h <<EOF
 #define $cf_result 1
 EOF
 
 else
-	echo "$as_me:15724: checking for data ospeed in library" >&5
-echo $ECHO_N "checking for data ospeed in library... $ECHO_C" >&6
+	echo "$as_me:21150: checking for data $cf_data in library" >&5
+echo $ECHO_N "checking for data $cf_data in library... $ECHO_C" >&6
 	# BSD linkers insist on making weak linkage, but resolve at runtime.
 	if test "$cross_compiling" = yes; then
 
 	# cross-compiling
-	cat >conftest.$ac_ext <<_ACEOF
-#line 15731 "configure"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 21157 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_XCURSES
@@ -15745,14 +21171,20 @@
 #endif
 #endif
 
-extern char ospeed;
+extern char $cf_data;
 int
-main ()
+main (void)
 {
 
 	do {
-		void *foo = &(ospeed);
-		fprintf(stderr, "testing linkage of ospeed:%p\n", foo);
+
+#if defined($cf_data) && ((defined(NCURSES_WRAPPED_VAR) && (NCURSES_VERSION_PATCH < 20200208)) || defined(NCURSES_BROKEN_LINKER) || defined(NCURSES_REENTRANT))
+	const void *foo = (const void *)($cf_data);
+#else
+	const void *foo = &($cf_data);
+#endif
+	fprintf(stderr, "testing linkage of $cf_data:%p\\n", (const void *)foo);
+
 		${cf_cv_main_return:-return}(foo == 0);
 	} while (0)
 
@@ -15760,29 +21192,29 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:15764: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:21196: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15767: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:15770: \"$ac_try\"") >&5
+  echo "$as_me:21199: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:21202: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15773: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:21205: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_result=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_result=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 15785 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 21217 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_XCURSES
@@ -15799,412 +21231,1292 @@
 #endif
 #endif
 
-extern char ospeed;
+extern char $cf_data;
 int main(void)
 {
-	void *foo = &(ospeed);
-	fprintf(stderr, "testing linkage of ospeed:%p\n", foo);
+
+#if defined($cf_data) && ((defined(NCURSES_WRAPPED_VAR) && (NCURSES_VERSION_PATCH < 20200208)) || defined(NCURSES_BROKEN_LINKER) || defined(NCURSES_REENTRANT))
+	const void *foo = (const void *)($cf_data);
+#else
+	const void *foo = &($cf_data);
+#endif
+	fprintf(stderr, "testing linkage of $cf_data:%p\\n", (const void *)foo);
+
 	${cf_cv_main_return:-return}(foo == 0);
 }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:15811: \"$ac_link\"") >&5
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:21249: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15814: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:15816: \"$ac_try\"") >&5
+  echo "$as_me:21252: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:21254: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15819: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:21257: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_result=yes
+
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_result=no
 fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-	echo "$as_me:15830: result: $cf_result" >&5
+	echo "$as_me:21269: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
-	if test $cf_result = yes ; then
+	if test "$cf_result" = yes ; then
 
-cf_result=`echo "decl_curses_data_ospeed" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+cf_result=`echo "decl_curses_data_$cf_data" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
 		cat >>confdefs.h <<EOF
 #define $cf_result 1
 EOF
 
+		# do not exit loop here, since we prefer system's declarations
 	fi
 fi
+done
 
-echo "$as_me:15843: checking for data boolnames declaration in ${cf_cv_ncurses_header:-curses.h}" >&5
-echo $ECHO_N "checking for data boolnames declaration in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
-
-cat >conftest.$ac_ext <<_ACEOF
-#line 15847 "configure"
-#include "confdefs.h"
-
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
-#endif
-
-int
-main ()
-{
-
-void *foo = &(boolnames)
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:15875: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:15878: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:15881: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:15884: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_result=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_result=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:15893: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-
-if test $cf_result = yes ; then
-
-cf_result=`echo "have_curses_data_boolnames" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
-
-	cat >>confdefs.h <<EOF
-#define $cf_result 1
-EOF
-
-else
-	echo "$as_me:15905: checking for data boolnames in library" >&5
-echo $ECHO_N "checking for data boolnames in library... $ECHO_C" >&6
-	# BSD linkers insist on making weak linkage, but resolve at runtime.
-	if test "$cross_compiling" = yes; then
-
-	# cross-compiling
-	cat >conftest.$ac_ext <<_ACEOF
-#line 15912 "configure"
-#include "confdefs.h"
-
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
-#endif
-
-extern char boolnames;
-int
-main ()
-{
-
-	do {
-		void *foo = &(boolnames);
-		fprintf(stderr, "testing linkage of boolnames:%p\n", foo);
-		${cf_cv_main_return:-return}(foo == 0);
-	} while (0)
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:15945: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:15948: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:15951: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:15954: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_result=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_result=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 15966 "configure"
-#include "confdefs.h"
-
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
-#endif
-
-extern char boolnames;
-int main(void)
-{
-	void *foo = &(boolnames);
-	fprintf(stderr, "testing linkage of boolnames:%p\n", foo);
-	${cf_cv_main_return:-return}(foo == 0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:15992: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:15995: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:15997: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:16000: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_result=yes
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_result=no
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-	echo "$as_me:16011: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-	if test $cf_result = yes ; then
-
-cf_result=`echo "decl_curses_data_boolnames" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
-
-		cat >>confdefs.h <<EOF
-#define $cf_result 1
-EOF
-
-	fi
-fi
-
-echo "$as_me:16024: checking for data boolfnames declaration in ${cf_cv_ncurses_header:-curses.h}" >&5
-echo $ECHO_N "checking for data boolfnames declaration in ${cf_cv_ncurses_header:-curses.h}... $ECHO_C" >&6
-
-cat >conftest.$ac_ext <<_ACEOF
-#line 16028 "configure"
-#include "confdefs.h"
-
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
-#endif
-
-int
-main ()
-{
-
-void *foo = &(boolfnames)
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:16056: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:16059: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:16062: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:16065: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_result=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_result=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:16074: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-
-if test $cf_result = yes ; then
-
-cf_result=`echo "have_curses_data_boolfnames" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
-
-	cat >>confdefs.h <<EOF
-#define $cf_result 1
-EOF
-
-else
-	echo "$as_me:16086: checking for data boolfnames in library" >&5
-echo $ECHO_N "checking for data boolfnames in library... $ECHO_C" >&6
-	# BSD linkers insist on making weak linkage, but resolve at runtime.
-	if test "$cross_compiling" = yes; then
-
-	# cross-compiling
-	cat >conftest.$ac_ext <<_ACEOF
-#line 16093 "configure"
-#include "confdefs.h"
-
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
-#endif
-
-extern char boolfnames;
-int
-main ()
-{
-
-	do {
-		void *foo = &(boolfnames);
-		fprintf(stderr, "testing linkage of boolfnames:%p\n", foo);
-		${cf_cv_main_return:-return}(foo == 0);
-	} while (0)
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:16126: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:16129: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:16132: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:16135: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_result=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_result=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 16147 "configure"
-#include "confdefs.h"
-
-#ifdef HAVE_XCURSES
-#include <xcurses.h>
-char * XCursesProgramName = "test";
-#else
-#include <${cf_cv_ncurses_header:-curses.h}>
-#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
-#include <ncursesw/term.h>
-#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
-#include <ncurses/term.h>
-#elif defined(HAVE_TERM_H)
-#include <term.h>
-#endif
-#endif
-
-extern char boolfnames;
-int main(void)
-{
-	void *foo = &(boolfnames);
-	fprintf(stderr, "testing linkage of boolfnames:%p\n", foo);
-	${cf_cv_main_return:-return}(foo == 0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:16173: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:16176: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:16178: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:16181: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_result=yes
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_result=no
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-	echo "$as_me:16192: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-	if test $cf_result = yes ; then
-
-cf_result=`echo "decl_curses_data_boolfnames" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
-
-		cat >>confdefs.h <<EOF
-#define $cf_result 1
-EOF
-
-	fi
-fi
-
-if ( test "$GCC" = yes || test "$GXX" = yes )
+if test -n "$with_screen" && test "x$with_screen" = "xpdcurses"
 then
-echo "$as_me:16207: checking if you want to turn on gcc warnings" >&5
+	echo "$as_me:21286: checking for X" >&5
+echo $ECHO_N "checking for X... $ECHO_C" >&6
+
+# Check whether --with-x or --without-x was given.
+if test "${with_x+set}" = set; then
+  withval="$with_x"
+
+fi;
+# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
+if test "x$with_x" = xno; then
+  # The user explicitly disabled X.
+  have_x=disabled
+else
+  if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
+    # Both variables are already set.
+    have_x=yes
+  else
+    if test "${ac_cv_have_x+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  # One or both of the vars are not set, and there is no cached value.
+ac_x_includes=no ac_x_libraries=no
+rm -fr conftest.dir
+if mkdir conftest.dir; then
+  cd conftest.dir
+  # Make sure to not put "make" in the Imakefile rules, since we grep it out.
+  cat >Imakefile <<'EOF'
+acfindx:
+	@echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
+EOF
+  if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
+    # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+    eval "`${MAKE-make} acfindx 2>/dev/null | grep -v make`"
+    # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
+    for ac_extension in a so sl dylib dll; do
+      if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" &&
+         test -f "$ac_im_libdir/libX11.$ac_extension"; then
+        ac_im_usrlibdir=$ac_im_libdir; break
+      fi
+    done
+    # Screen out bogus values from the imake configuration.  They are
+    # bogus both because they are the default anyway, and because
+    # using them would break gcc on systems where it needs fixed includes.
+    case $ac_im_incroot in
+	/usr/include) ;;
+	*) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
+    esac
+    case $ac_im_usrlibdir in
+	/usr/lib | /lib) ;;
+	*) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
+    esac
+  fi
+  cd ..
+  rm -fr conftest.dir
+fi
+
+# Standard set of common directories for X headers.
+# Check X11 before X11Rn because it is often a symlink to the current release.
+ac_x_header_dirs='
+/usr/X11/include
+/usr/X11R7/include
+/usr/X11R6/include
+/usr/X11R5/include
+/usr/X11R4/include
+
+/opt/local/include
+/opt/X11/include
+
+/usr/include/X11
+/usr/include/X11R7
+/usr/include/X11R6
+/usr/include/X11R5
+/usr/include/X11R4
+
+/usr/local/X11/include
+/usr/local/X11R7/include
+/usr/local/X11R6/include
+/usr/local/X11R5/include
+/usr/local/X11R4/include
+
+/usr/local/include/X11
+/usr/local/include/X11R7
+/usr/local/include/X11R6
+/usr/local/include/X11R5
+/usr/local/include/X11R4
+
+/usr/X386/include
+/usr/x386/include
+/usr/XFree86/include/X11
+
+/usr/include
+/usr/local/include
+/usr/unsupported/include
+/usr/athena/include
+/usr/local/x11r5/include
+/usr/lpp/Xamples/include
+
+/usr/openwin/include
+/usr/openwin/share/include'
+
+if test "$ac_x_includes" = no; then
+  # Guess where to find include files, by looking for Intrinsic.h.
+  # First, try using that file with no special directory specified.
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 21390 "configure"
+#include "confdefs.h"
+#include <X11/Intrinsic.h>
+_ACEOF
+if { (eval echo "$as_me:21394: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:21400: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # We can compile using X headers with no special include directory.
+ac_x_includes=
+else
+  echo "$as_me: failed program was:" >&5
+  cat "conftest.$ac_ext" >&5
+  for ac_dir in $ac_x_header_dirs; do
+  if test -r "$ac_dir/X11/Intrinsic.h"; then
+    ac_x_includes=$ac_dir
+    break
+  fi
+done
+fi
+rm -f conftest.err "conftest.$ac_ext"
+fi # $ac_x_includes = no
+
+if test "$ac_x_libraries" = no; then
+  # Check for the libraries.
+  # See if we find them without any special options.
+  # Don't add to $LIBS permanently.
+  ac_save_LIBS=$LIBS
+  LIBS="-lXt $LIBS"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 21433 "configure"
+#include "confdefs.h"
+#include <X11/Intrinsic.h>
+int
+main (void)
+{
+XtMalloc (0)
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:21445: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:21448: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:21451: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:21454: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  LIBS=$ac_save_LIBS
+# We can link X programs with no special library path.
+ac_x_libraries=
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+LIBS=$ac_save_LIBS
+for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
+do
+  # Don't even attempt the hair of trying to link an X program!
+  for ac_extension in a so sl dylib dll; do
+    if test -r "$ac_dir/libXt.$ac_extension"; then
+      ac_x_libraries=$ac_dir
+      break 2
+    fi
+  done
+done
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+fi # $ac_x_libraries = no
+
+if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then
+  # Didn't find X anywhere.  Cache the known absence of X.
+  ac_cv_have_x="have_x=no"
+else
+  # Record where we found X for the cache.
+  ac_cv_have_x="have_x=yes \
+	        ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
+fi
+fi
+
+  fi
+  eval "$ac_cv_have_x"
+fi # $with_x != no
+
+if test "$have_x" != yes; then
+  echo "$as_me:21492: result: $have_x" >&5
+echo "${ECHO_T}$have_x" >&6
+  no_x=yes
+else
+  # If each of the values was on the command line, it overrides each guess.
+  test "x$x_includes" = xNONE && x_includes=$ac_x_includes
+  test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
+  # Update the cache value to reflect the command line values.
+  ac_cv_have_x="have_x=yes \
+		ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
+  echo "$as_me:21502: result: libraries $x_libraries, headers $x_includes" >&5
+echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6
+fi
+
+	if test "$no_x" = yes; then
+  # Not all programs may use this symbol, but it does not hurt to define it.
+
+cat >>confdefs.h <<\EOF
+#define X_DISPLAY_MISSING 1
+EOF
+
+  X_CFLAGS=
+  X_PRE_LIBS=
+  X_LIBS=
+  X_EXTRA_LIBS=
+else
+  if test -n "$x_includes"; then
+    X_CFLAGS="$X_CFLAGS -I$x_includes"
+  fi
+
+  # It would also be nice to do this for all -L options, not just this one.
+  if test -n "$x_libraries"; then
+    X_LIBS="$X_LIBS -L$x_libraries"
+    # For Solaris; some versions of Sun CC require a space after -R and
+    # others require no space.  Words are not sufficient . . . .
+    case `(uname -sr) 2>/dev/null` in
+    "SunOS 5"*)
+      echo "$as_me:21529: checking whether -R must be followed by a space" >&5
+echo $ECHO_N "checking whether -R must be followed by a space... $ECHO_C" >&6
+      ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries"
+      cat >"conftest.$ac_ext" <<_ACEOF
+#line 21533 "configure"
+#include "confdefs.h"
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:21545: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:21548: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:21551: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:21554: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_R_nospace=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_R_nospace=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+      if test $ac_R_nospace = yes; then
+	echo "$as_me:21564: result: no" >&5
+echo "${ECHO_T}no" >&6
+	X_LIBS="$X_LIBS -R$x_libraries"
+      else
+	LIBS="$ac_xsave_LIBS -R $x_libraries"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 21570 "configure"
+#include "confdefs.h"
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:21582: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:21585: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:21588: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:21591: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_R_space=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_R_space=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+	if test $ac_R_space = yes; then
+	  echo "$as_me:21601: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+	  X_LIBS="$X_LIBS -R $x_libraries"
+	else
+	  echo "$as_me:21605: result: neither works" >&5
+echo "${ECHO_T}neither works" >&6
+	fi
+      fi
+      LIBS=$ac_xsave_LIBS
+    esac
+  fi
+
+  # Check for system-dependent libraries X programs must link with.
+  # Do this before checking for the system-independent R6 libraries
+  # (-lICE), since we may need -lsocket or whatever for X linking.
+
+  if test "$ISC" = yes; then
+    X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
+  else
+    # Martyn Johnson says this is needed for Ultrix, if the X
+    # libraries were built with DECnet support.  And Karl Berry says
+    # the Alpha needs dnet_stub (dnet does not exist).
+    ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
+    cat >"conftest.$ac_ext" <<_ACEOF
+#line 21625 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XOpenDisplay (void);
+int
+main (void)
+{
+XOpenDisplay ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:21644: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:21647: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:21650: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:21653: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+echo "$as_me:21659: checking for dnet_ntoa in -ldnet" >&5
+echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6
+if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldnet  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 21667 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dnet_ntoa (void);
+int
+main (void)
+{
+dnet_ntoa ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:21686: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:21689: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:21692: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:21695: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_lib_dnet_dnet_ntoa=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_lib_dnet_dnet_ntoa=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:21706: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
+echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6
+if test "$ac_cv_lib_dnet_dnet_ntoa" = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
+fi
+
+    if test $ac_cv_lib_dnet_dnet_ntoa = no; then
+      echo "$as_me:21713: checking for dnet_ntoa in -ldnet_stub" >&5
+echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6
+if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldnet_stub  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 21721 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dnet_ntoa (void);
+int
+main (void)
+{
+dnet_ntoa ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:21740: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:21743: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:21746: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:21749: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_lib_dnet_stub_dnet_ntoa=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_lib_dnet_stub_dnet_ntoa=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:21760: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5
+echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6
+if test "$ac_cv_lib_dnet_stub_dnet_ntoa" = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
+fi
+
+    fi
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+    LIBS="$ac_xsave_LIBS"
+
+    # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
+    # to get the SysV transport functions.
+    # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4)
+    # needs -lnsl.
+    # The nsl library prevents programs from opening the X display
+    # on Irix 5.2, according to T.E. Dickey.
+    # The functions gethostbyname, getservbyname, and inet_addr are
+    # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking.
+    echo "$as_me:21779: checking for gethostbyname" >&5
+echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6
+if test "${ac_cv_func_gethostbyname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 21785 "configure"
+#include "confdefs.h"
+#define gethostbyname autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef gethostbyname
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyname (void);
+
+int
+main (void)
+{
+
+/* The GNU C library defines stubs for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_gethostbyname) || defined (__stub___gethostbyname)
+#error found stub for gethostbyname
+#endif
+
+	return gethostbyname ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:21816: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:21819: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:21822: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:21825: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_func_gethostbyname=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_func_gethostbyname=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+fi
+echo "$as_me:21835: result: $ac_cv_func_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6
+
+    if test $ac_cv_func_gethostbyname = no; then
+      echo "$as_me:21839: checking for gethostbyname in -lnsl" >&5
+echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6
+if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lnsl  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 21847 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyname (void);
+int
+main (void)
+{
+gethostbyname ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:21866: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:21869: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:21872: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:21875: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_lib_nsl_gethostbyname=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_lib_nsl_gethostbyname=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:21886: result: $ac_cv_lib_nsl_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6
+if test "$ac_cv_lib_nsl_gethostbyname" = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
+fi
+
+      if test $ac_cv_lib_nsl_gethostbyname = no; then
+        echo "$as_me:21893: checking for gethostbyname in -lbsd" >&5
+echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6
+if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lbsd  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 21901 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyname (void);
+int
+main (void)
+{
+gethostbyname ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:21920: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:21923: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:21926: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:21929: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_lib_bsd_gethostbyname=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_lib_bsd_gethostbyname=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:21940: result: $ac_cv_lib_bsd_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6
+if test "$ac_cv_lib_bsd_gethostbyname" = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd"
+fi
+
+      fi
+    fi
+
+    # lieder@skyler.mavd.honeywell.com says without -lsocket,
+    # socket/setsockopt and other routines are undefined under SCO ODT
+    # 2.0.  But -lsocket is broken on IRIX 5.2 (and is not necessary
+    # on later versions), says Simon Leinen: it contains gethostby*
+    # variants that don't use the nameserver (or something).  -lsocket
+    # must be given before -lnsl if both are needed.  We assume that
+    # if connect needs -lnsl, so does gethostbyname.
+    echo "$as_me:21956: checking for connect" >&5
+echo $ECHO_N "checking for connect... $ECHO_C" >&6
+if test "${ac_cv_func_connect+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 21962 "configure"
+#include "confdefs.h"
+#define connect autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef connect
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char connect (void);
+
+int
+main (void)
+{
+
+/* The GNU C library defines stubs for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_connect) || defined (__stub___connect)
+#error found stub for connect
+#endif
+
+	return connect ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:21993: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:21996: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:21999: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:22002: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_func_connect=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_func_connect=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+fi
+echo "$as_me:22012: result: $ac_cv_func_connect" >&5
+echo "${ECHO_T}$ac_cv_func_connect" >&6
+
+    if test $ac_cv_func_connect = no; then
+      echo "$as_me:22016: checking for connect in -lsocket" >&5
+echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6
+if test "${ac_cv_lib_socket_connect+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 22024 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char connect (void);
+int
+main (void)
+{
+connect ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:22043: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:22046: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:22049: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:22052: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_lib_socket_connect=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_lib_socket_connect=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:22063: result: $ac_cv_lib_socket_connect" >&5
+echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6
+if test "$ac_cv_lib_socket_connect" = yes; then
+  X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
+fi
+
+    fi
+
+    # Guillermo Gomez says -lposix is necessary on A/UX.
+    echo "$as_me:22072: checking for remove" >&5
+echo $ECHO_N "checking for remove... $ECHO_C" >&6
+if test "${ac_cv_func_remove+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 22078 "configure"
+#include "confdefs.h"
+#define remove autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef remove
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char remove (void);
+
+int
+main (void)
+{
+
+/* The GNU C library defines stubs for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_remove) || defined (__stub___remove)
+#error found stub for remove
+#endif
+
+	return remove ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:22109: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:22112: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:22115: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:22118: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_func_remove=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_func_remove=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+fi
+echo "$as_me:22128: result: $ac_cv_func_remove" >&5
+echo "${ECHO_T}$ac_cv_func_remove" >&6
+
+    if test $ac_cv_func_remove = no; then
+      echo "$as_me:22132: checking for remove in -lposix" >&5
+echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6
+if test "${ac_cv_lib_posix_remove+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lposix  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 22140 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char remove (void);
+int
+main (void)
+{
+remove ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:22159: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:22162: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:22165: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:22168: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_lib_posix_remove=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_lib_posix_remove=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:22179: result: $ac_cv_lib_posix_remove" >&5
+echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6
+if test "$ac_cv_lib_posix_remove" = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
+fi
+
+    fi
+
+    # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
+    echo "$as_me:22188: checking for shmat" >&5
+echo $ECHO_N "checking for shmat... $ECHO_C" >&6
+if test "${ac_cv_func_shmat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 22194 "configure"
+#include "confdefs.h"
+#define shmat autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef shmat
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char shmat (void);
+
+int
+main (void)
+{
+
+/* The GNU C library defines stubs for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_shmat) || defined (__stub___shmat)
+#error found stub for shmat
+#endif
+
+	return shmat ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:22225: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:22228: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:22231: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:22234: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_func_shmat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_func_shmat=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+fi
+echo "$as_me:22244: result: $ac_cv_func_shmat" >&5
+echo "${ECHO_T}$ac_cv_func_shmat" >&6
+
+    if test $ac_cv_func_shmat = no; then
+      echo "$as_me:22248: checking for shmat in -lipc" >&5
+echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6
+if test "${ac_cv_lib_ipc_shmat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lipc  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 22256 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char shmat (void);
+int
+main (void)
+{
+shmat ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:22275: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:22278: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:22281: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:22284: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_lib_ipc_shmat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_lib_ipc_shmat=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:22295: result: $ac_cv_lib_ipc_shmat" >&5
+echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6
+if test "$ac_cv_lib_ipc_shmat" = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"
+fi
+
+    fi
+  fi
+
+  # Check for libraries that X11R6 Xt/Xaw programs need.
+  ac_save_LDFLAGS=$LDFLAGS
+  test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
+  # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
+  # check for ICE first), but we must link in the order -lSM -lICE or
+  # we get undefined symbols.  So assume we have SM if we have ICE.
+  # These have to be linked with before -lX11, unlike the other
+  # libraries we check for below, so use a different variable.
+  # John Interrante, Karl Berry
+  echo "$as_me:22313: checking for IceConnectionNumber in -lICE" >&5
+echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6
+if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lICE $X_EXTRA_LIBS $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 22321 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char IceConnectionNumber (void);
+int
+main (void)
+{
+IceConnectionNumber ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:22340: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:22343: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:22346: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:22349: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_lib_ICE_IceConnectionNumber=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_lib_ICE_IceConnectionNumber=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:22360: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5
+echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6
+if test "$ac_cv_lib_ICE_IceConnectionNumber" = yes; then
+  X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
+fi
+
+  LDFLAGS=$ac_save_LDFLAGS
+
+fi
+
+fi
+
+if test "$GCC" = yes || test "$GXX" = yes
+then
+
+if test "$GCC" = yes || test "$GXX" = yes
+then
+	case $CFLAGS in
+	(*-Werror=*)
+		cf_temp_flags=
+		for cf_temp_scan in $CFLAGS
+		do
+			case "x$cf_temp_scan" in
+			(x-Werror=format*)
+
+	test -n "$cf_temp_flags" && cf_temp_flags="$cf_temp_flags "
+	cf_temp_flags="${cf_temp_flags}$cf_temp_scan"
+
+				;;
+			(x-Werror=*)
+
+	test -n "$EXTRA_CFLAGS" && EXTRA_CFLAGS="$EXTRA_CFLAGS "
+	EXTRA_CFLAGS="${EXTRA_CFLAGS}$cf_temp_scan"
+
+				;;
+			(*)
+
+	test -n "$cf_temp_flags" && cf_temp_flags="$cf_temp_flags "
+	cf_temp_flags="${cf_temp_flags}$cf_temp_scan"
+
+				;;
+			esac
+		done
+		if test "x$CFLAGS" != "x$cf_temp_flags"
+		then
+			test -n "$verbose" && echo "	repairing CFLAGS: $CFLAGS" 1>&6
+
+echo "${as_me:-configure}:22407: testing repairing CFLAGS: $CFLAGS ..." 1>&5
+
+			CFLAGS="$cf_temp_flags"
+			test -n "$verbose" && echo "	... fixed $CFLAGS" 1>&6
+
+echo "${as_me:-configure}:22412: testing ... fixed $CFLAGS ..." 1>&5
+
+			test -n "$verbose" && echo "	... extra $EXTRA_CFLAGS" 1>&6
+
+echo "${as_me:-configure}:22416: testing ... extra $EXTRA_CFLAGS ..." 1>&5
+
+		fi
+		;;
+	esac
+fi
+
+if test "$GCC" = yes || test "$GXX" = yes
+then
+	case $CPPFLAGS in
+	(*-Werror=*)
+		cf_temp_flags=
+		for cf_temp_scan in $CPPFLAGS
+		do
+			case "x$cf_temp_scan" in
+			(x-Werror=format*)
+
+	test -n "$cf_temp_flags" && cf_temp_flags="$cf_temp_flags "
+	cf_temp_flags="${cf_temp_flags}$cf_temp_scan"
+
+				;;
+			(x-Werror=*)
+
+	test -n "$EXTRA_CFLAGS" && EXTRA_CFLAGS="$EXTRA_CFLAGS "
+	EXTRA_CFLAGS="${EXTRA_CFLAGS}$cf_temp_scan"
+
+				;;
+			(*)
+
+	test -n "$cf_temp_flags" && cf_temp_flags="$cf_temp_flags "
+	cf_temp_flags="${cf_temp_flags}$cf_temp_scan"
+
+				;;
+			esac
+		done
+		if test "x$CPPFLAGS" != "x$cf_temp_flags"
+		then
+			test -n "$verbose" && echo "	repairing CPPFLAGS: $CPPFLAGS" 1>&6
+
+echo "${as_me:-configure}:22455: testing repairing CPPFLAGS: $CPPFLAGS ..." 1>&5
+
+			CPPFLAGS="$cf_temp_flags"
+			test -n "$verbose" && echo "	... fixed $CPPFLAGS" 1>&6
+
+echo "${as_me:-configure}:22460: testing ... fixed $CPPFLAGS ..." 1>&5
+
+			test -n "$verbose" && echo "	... extra $EXTRA_CFLAGS" 1>&6
+
+echo "${as_me:-configure}:22464: testing ... extra $EXTRA_CFLAGS ..." 1>&5
+
+		fi
+		;;
+	esac
+fi
+
+if test "$GCC" = yes || test "$GXX" = yes
+then
+	case $LDFLAGS in
+	(*-Werror=*)
+		cf_temp_flags=
+		for cf_temp_scan in $LDFLAGS
+		do
+			case "x$cf_temp_scan" in
+			(x-Werror=format*)
+
+	test -n "$cf_temp_flags" && cf_temp_flags="$cf_temp_flags "
+	cf_temp_flags="${cf_temp_flags}$cf_temp_scan"
+
+				;;
+			(x-Werror=*)
+
+	test -n "$EXTRA_CFLAGS" && EXTRA_CFLAGS="$EXTRA_CFLAGS "
+	EXTRA_CFLAGS="${EXTRA_CFLAGS}$cf_temp_scan"
+
+				;;
+			(*)
+
+	test -n "$cf_temp_flags" && cf_temp_flags="$cf_temp_flags "
+	cf_temp_flags="${cf_temp_flags}$cf_temp_scan"
+
+				;;
+			esac
+		done
+		if test "x$LDFLAGS" != "x$cf_temp_flags"
+		then
+			test -n "$verbose" && echo "	repairing LDFLAGS: $LDFLAGS" 1>&6
+
+echo "${as_me:-configure}:22503: testing repairing LDFLAGS: $LDFLAGS ..." 1>&5
+
+			LDFLAGS="$cf_temp_flags"
+			test -n "$verbose" && echo "	... fixed $LDFLAGS" 1>&6
+
+echo "${as_me:-configure}:22508: testing ... fixed $LDFLAGS ..." 1>&5
+
+			test -n "$verbose" && echo "	... extra $EXTRA_CFLAGS" 1>&6
+
+echo "${as_me:-configure}:22512: testing ... extra $EXTRA_CFLAGS ..." 1>&5
+
+		fi
+		;;
+	esac
+fi
+
+echo "$as_me:22519: checking if you want to turn on gcc warnings" >&5
 echo $ECHO_N "checking if you want to turn on gcc warnings... $ECHO_C" >&6
 
 # Check whether --enable-warnings or --disable-warnings was given.
@@ -16212,21 +22524,21 @@
   enableval="$enable_warnings"
   test "$enableval" != yes && enableval=no
 	if test "$enableval" != "no" ; then
-    with_warnings=yes
+    enable_warnings=yes
 	else
-		with_warnings=no
+		enable_warnings=no
 	fi
 else
   enableval=no
-	with_warnings=no
+	enable_warnings=no
 
 fi;
-echo "$as_me:16224: result: $with_warnings" >&5
-echo "${ECHO_T}$with_warnings" >&6
-if test "$with_warnings" = "yes"
+echo "$as_me:22536: result: $enable_warnings" >&5
+echo "${ECHO_T}$enable_warnings" >&6
+if test "$enable_warnings" = "yes"
 then
 
-if test "$GCC" = yes
+if test "$GCC" = yes || test "$GXX" = yes
 then
 cat > conftest.i <<EOF
 #ifndef GCC_PRINTF
@@ -16244,10 +22556,11 @@
 EOF
 if test "$GCC" = yes
 then
-	{ echo "$as_me:16247: checking for $CC __attribute__ directives..." >&5
+	{ echo "$as_me:22559: checking for $CC __attribute__ directives..." >&5
 echo "$as_me: checking for $CC __attribute__ directives..." >&6;}
-cat > conftest.$ac_ext <<EOF
-#line 16250 "${as_me:-configure}"
+cat > "conftest.$ac_ext" <<EOF
+#line 22562 "${as_me:-configure}"
+#include <stdio.h>
 #include "confdefs.h"
 #include "conftest.h"
 #include "conftest.i"
@@ -16262,9 +22575,9 @@
 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
 #endif
 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
-extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
-extern void foo(void) GCC_NORETURN;
-int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; }
+extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2);
+extern GCC_NORETURN void foo(void);
+int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
 EOF
 	cf_printf_attribute=no
 	cf_scanf_attribute=no
@@ -16276,7 +22589,7 @@
 		cf_directive="__attribute__(($cf_attribute))"
 		echo "checking for $CC $cf_directive" 1>&5
 
-		case $cf_attribute in
+		case "$cf_attribute" in
 		(printf)
 			cf_printf_attribute=yes
 			cat >conftest.h <<EOF
@@ -16296,15 +22609,15 @@
 			;;
 		esac
 
-		if { (eval echo "$as_me:16299: \"$ac_compile\"") >&5
+		if { (eval echo "$as_me:22612: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16302: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-			test -n "$verbose" && echo "$as_me:16304: result: ... $cf_attribute" >&5
+  echo "$as_me:22615: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; then
+			test -n "$verbose" && echo "$as_me:22617: result: ... $cf_attribute" >&5
 echo "${ECHO_T}... $cf_attribute" >&6
 			cat conftest.h >>confdefs.h
-			case $cf_attribute in
+			case "$cf_attribute" in
 			(noreturn)
 
 cat >>confdefs.h <<EOF
@@ -16355,118 +22668,138 @@
 		fi
 	done
 else
-	fgrep define conftest.i >>confdefs.h
+	${FGREP-fgrep} define conftest.i >>confdefs.h
 fi
-rm -rf conftest*
+rm -rf ./conftest*
 fi
 
-INTEL_COMPILER=no
+if test "x$have_x" = xyes; then
 
-if test "$GCC" = yes ; then
-	case $host_os in
-	(linux*|gnu*)
-		echo "$as_me:16368: checking if this is really Intel C compiler" >&5
-echo $ECHO_N "checking if this is really Intel C compiler... $ECHO_C" >&6
-		cf_save_CFLAGS="$CFLAGS"
-		CFLAGS="$CFLAGS -no-gcc"
-		cat >conftest.$ac_ext <<_ACEOF
-#line 16373 "configure"
-#include "confdefs.h"
-
-int
-main ()
-{
-
-#ifdef __INTEL_COMPILER
-#else
-make an error
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:16390: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:16393: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:16396: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:16399: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  INTEL_COMPILER=yes
-cf_save_CFLAGS="$cf_save_CFLAGS -we147"
-
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-		CFLAGS="$cf_save_CFLAGS"
-		echo "$as_me:16410: result: $INTEL_COMPILER" >&5
-echo "${ECHO_T}$INTEL_COMPILER" >&6
+cf_save_LIBS_CF_CONST_X_STRING="$LIBS"
+cf_save_CFLAGS_CF_CONST_X_STRING="$CFLAGS"
+cf_save_CPPFLAGS_CF_CONST_X_STRING="$CPPFLAGS"
+LIBS="$LIBS ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}"
+for cf_X_CFLAGS in $X_CFLAGS
+do
+	case "x$cf_X_CFLAGS" in
+	x-[IUD]*)
+		CPPFLAGS="$CPPFLAGS $cf_X_CFLAGS"
+		;;
+	*)
+		CFLAGS="$CFLAGS $cf_X_CFLAGS"
 		;;
 	esac
-fi
+done
 
-CLANG_COMPILER=no
-
-if test "$GCC" = yes ; then
-	echo "$as_me:16419: checking if this is really Clang C compiler" >&5
-echo $ECHO_N "checking if this is really Clang C compiler... $ECHO_C" >&6
-	cf_save_CFLAGS="$CFLAGS"
-	CFLAGS="$CFLAGS -Qunused-arguments"
-	cat >conftest.$ac_ext <<_ACEOF
-#line 16424 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 22695 "configure"
 #include "confdefs.h"
 
+#include <stdlib.h>
+#include <X11/Intrinsic.h>
+
 int
-main ()
+main (void)
 {
-
-#ifdef __clang__
-#else
-make an error
-#endif
-
+String foo = malloc(1); free((void*)foo)
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:16441: \"$ac_compile\"") >&5
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:22710: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16444: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:16447: \"$ac_try\"") >&5
+  echo "$as_me:22713: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:22716: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16450: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  CLANG_COMPILER=yes
-cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
+  echo "$as_me:22719: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+
+echo "$as_me:22722: checking for X11/Xt const-feature" >&5
+echo $ECHO_N "checking for X11/Xt const-feature... $ECHO_C" >&6
+if test "${cf_cv_const_x_string+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 22729 "configure"
+#include "confdefs.h"
+
+#undef  _CONST_X_STRING
+#define _CONST_X_STRING	/* X11R7.8 (perhaps) */
+#undef  XTSTRINGDEFINES	/* X11R5 and later */
+#include <stdlib.h>
+#include <X11/Intrinsic.h>
+
+int
+main (void)
+{
+String foo = malloc(1); *foo = 0
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:22747: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:22750: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:22753: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:22756: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+
+			cf_cv_const_x_string=no
 
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-	CFLAGS="$cf_save_CFLAGS"
-	echo "$as_me:16461: result: $CLANG_COMPILER" >&5
-echo "${ECHO_T}$CLANG_COMPILER" >&6
-fi
+cat "conftest.$ac_ext" >&5
 
-cat > conftest.$ac_ext <<EOF
-#line 16466 "${as_me:-configure}"
+			cf_cv_const_x_string=yes
+
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+
+fi
+echo "$as_me:22771: result: $cf_cv_const_x_string" >&5
+echo "${ECHO_T}$cf_cv_const_x_string" >&6
+
+LIBS="$cf_save_LIBS_CF_CONST_X_STRING"
+CFLAGS="$cf_save_CFLAGS_CF_CONST_X_STRING"
+CPPFLAGS="$cf_save_CPPFLAGS_CF_CONST_X_STRING"
+
+case "$cf_cv_const_x_string" in
+(no)
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-DXTSTRINGDEFINES"
+
+	;;
+(*)
+
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}-D_CONST_X_STRING"
+
+	;;
+esac
+
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+ fi
+cat > "conftest.$ac_ext" <<EOF
+#line 22800 "${as_me:-configure}"
 int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
 EOF
-
 if test "$INTEL_COMPILER" = yes
 then
 # The "-wdXXX" options suppress warnings:
@@ -16480,10 +22813,10 @@
 # remark #981: operands are evaluated in unspecified order
 # warning #279: controlling expression is constant
 
-	{ echo "$as_me:16483: checking for $CC warning options..." >&5
+	{ echo "$as_me:22816: checking for $CC warning options..." >&5
 echo "$as_me: checking for $CC warning options..." >&6;}
 	cf_save_CFLAGS="$CFLAGS"
-	EXTRA_CFLAGS="-Wall"
+	EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
 	for cf_opt in \
 		wd1419 \
 		wd1683 \
@@ -16496,24 +22829,22 @@
 		wd981
 	do
 		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
-		if { (eval echo "$as_me:16499: \"$ac_compile\"") >&5
+		if { (eval echo "$as_me:22832: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16502: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-			test -n "$verbose" && echo "$as_me:16504: result: ... -$cf_opt" >&5
+  echo "$as_me:22835: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; then
+			test -n "$verbose" && echo "$as_me:22837: result: ... -$cf_opt" >&5
 echo "${ECHO_T}... -$cf_opt" >&6
 			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
 		fi
 	done
 	CFLAGS="$cf_save_CFLAGS"
-
-elif test "$GCC" = yes
+elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
 then
-	{ echo "$as_me:16513: checking for $CC warning options..." >&5
+	{ echo "$as_me:22845: checking for $CC warning options..." >&5
 echo "$as_me: checking for $CC warning options..." >&6;}
 	cf_save_CFLAGS="$CFLAGS"
-	EXTRA_CFLAGS=
 	cf_warn_CONST=""
 	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
 	cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
@@ -16531,36 +22862,33 @@
 		Wpointer-arith \
 		Wshadow \
 		Wstrict-prototypes \
-		Wundef $cf_gcc_warnings $cf_warn_CONST
+		Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST Wno-unknown-pragmas
 	do
 		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
-		if { (eval echo "$as_me:16537: \"$ac_compile\"") >&5
+		if { (eval echo "$as_me:22868: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16540: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-			test -n "$verbose" && echo "$as_me:16542: result: ... -$cf_opt" >&5
+  echo "$as_me:22871: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; then
+			test -n "$verbose" && echo "$as_me:22873: result: ... -$cf_opt" >&5
 echo "${ECHO_T}... -$cf_opt" >&6
-			case $cf_opt in
-			(Wcast-qual)
-				CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
-				;;
+			case "$cf_opt" in
 			(Winline)
-				case $GCC_VERSION in
+				case "$GCC_VERSION" in
 				([34].*)
 					test -n "$verbose" && echo "	feature is broken in gcc $GCC_VERSION" 1>&6
 
-echo "${as_me:-configure}:16553: testing feature is broken in gcc $GCC_VERSION ..." 1>&5
+echo "${as_me:-configure}:22881: testing feature is broken in gcc $GCC_VERSION ..." 1>&5
 
 					continue;;
 				esac
 				;;
 			(Wpointer-arith)
-				case $GCC_VERSION in
+				case "$GCC_VERSION" in
 				([12].*)
 					test -n "$verbose" && echo "	feature is broken in gcc $GCC_VERSION" 1>&6
 
-echo "${as_me:-configure}:16563: testing feature is broken in gcc $GCC_VERSION ..." 1>&5
+echo "${as_me:-configure}:22891: testing feature is broken in gcc $GCC_VERSION ..." 1>&5
 
 					continue;;
 				esac
@@ -16571,32 +22899,38 @@
 	done
 	CFLAGS="$cf_save_CFLAGS"
 fi
-rm -rf conftest*
+rm -rf ./conftest*
 
 fi
+
 fi
 
-echo "$as_me:16579: checking if you want to use dmalloc for testing" >&5
+echo "$as_me:22908: checking if you want to use dmalloc for testing" >&5
 echo $ECHO_N "checking if you want to use dmalloc for testing... $ECHO_C" >&6
 
 # Check whether --with-dmalloc or --without-dmalloc was given.
 if test "${with_dmalloc+set}" = set; then
   withval="$with_dmalloc"
+  case "x$withval" in
+	(x|xno) ;;
+	(*)
+		: "${with_cflags:=-g}"
+		: "${enable_leaks:=no}"
+		with_dmalloc=yes
 
 cat >>confdefs.h <<EOF
 #define USE_DMALLOC 1
 EOF
 
-	: ${with_cflags:=-g}
-	: ${with_no_leaks:=yes}
-	 with_dmalloc=yes
+		;;
+	esac
 else
   with_dmalloc=
 fi;
-echo "$as_me:16596: result: ${with_dmalloc:-no}" >&5
+echo "$as_me:22930: result: ${with_dmalloc:-no}" >&5
 echo "${ECHO_T}${with_dmalloc:-no}" >&6
 
-case .$with_cflags in
+case ".$with_cflags" in
 (.*-g*)
 	case .$CFLAGS in
 	(.*-g*)
@@ -16610,23 +22944,29 @@
 
 for cf_add_cflags in -g
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -16635,7 +22975,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -16645,19 +22985,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -16668,17 +23016,23 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
 		;;
@@ -16687,24 +23041,24 @@
 esac
 
 if test "$with_dmalloc" = yes ; then
-	echo "$as_me:16690: checking for dmalloc.h" >&5
+	echo "$as_me:23044: checking for dmalloc.h" >&5
 echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6
 if test "${ac_cv_header_dmalloc_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 16696 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 23050 "configure"
 #include "confdefs.h"
 #include <dmalloc.h>
 _ACEOF
-if { (eval echo "$as_me:16700: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (eval echo "$as_me:23054: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:16706: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
+  echo "$as_me:23060: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
   else
@@ -16717,24 +23071,24 @@
   ac_cv_header_dmalloc_h=yes
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat "conftest.$ac_ext" >&5
   ac_cv_header_dmalloc_h=no
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:16725: result: $ac_cv_header_dmalloc_h" >&5
+echo "$as_me:23079: result: $ac_cv_header_dmalloc_h" >&5
 echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6
-if test $ac_cv_header_dmalloc_h = yes; then
+if test "$ac_cv_header_dmalloc_h" = yes; then
 
-echo "$as_me:16729: checking for dmalloc_debug in -ldmalloc" >&5
+echo "$as_me:23083: checking for dmalloc_debug in -ldmalloc" >&5
 echo $ECHO_N "checking for dmalloc_debug in -ldmalloc... $ECHO_C" >&6
 if test "${ac_cv_lib_dmalloc_dmalloc_debug+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldmalloc  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 16737 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 23091 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -16743,39 +23097,39 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char dmalloc_debug ();
+char dmalloc_debug (void);
 int
-main ()
+main (void)
 {
 dmalloc_debug ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:16756: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:23110: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:16759: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:16762: \"$ac_try\"") >&5
+  echo "$as_me:23113: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:23116: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16765: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:23119: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_dmalloc_dmalloc_debug=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_dmalloc_dmalloc_debug=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:16776: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5
+echo "$as_me:23130: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5
 echo "${ECHO_T}$ac_cv_lib_dmalloc_dmalloc_debug" >&6
-if test $ac_cv_lib_dmalloc_dmalloc_debug = yes; then
+if test "$ac_cv_lib_dmalloc_dmalloc_debug" = yes; then
   cat >>confdefs.h <<EOF
 #define HAVE_LIBDMALLOC 1
 EOF
@@ -16788,27 +23142,32 @@
 
 fi
 
-echo "$as_me:16791: checking if you want to use dbmalloc for testing" >&5
+echo "$as_me:23145: checking if you want to use dbmalloc for testing" >&5
 echo $ECHO_N "checking if you want to use dbmalloc for testing... $ECHO_C" >&6
 
 # Check whether --with-dbmalloc or --without-dbmalloc was given.
 if test "${with_dbmalloc+set}" = set; then
   withval="$with_dbmalloc"
+  case "x$withval" in
+	(x|xno) ;;
+	(*)
+		: "${with_cflags:=-g}"
+		: "${enable_leaks:=no}"
+		with_dbmalloc=yes
 
 cat >>confdefs.h <<EOF
 #define USE_DBMALLOC 1
 EOF
 
-	: ${with_cflags:=-g}
-	: ${with_no_leaks:=yes}
-	 with_dbmalloc=yes
+		;;
+	esac
 else
   with_dbmalloc=
 fi;
-echo "$as_me:16808: result: ${with_dbmalloc:-no}" >&5
+echo "$as_me:23167: result: ${with_dbmalloc:-no}" >&5
 echo "${ECHO_T}${with_dbmalloc:-no}" >&6
 
-case .$with_cflags in
+case ".$with_cflags" in
 (.*-g*)
 	case .$CFLAGS in
 	(.*-g*)
@@ -16822,23 +23181,29 @@
 
 for cf_add_cflags in -g
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -16847,7 +23212,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -16857,19 +23222,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -16880,17 +23253,23 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
 		;;
@@ -16899,24 +23278,24 @@
 esac
 
 if test "$with_dbmalloc" = yes ; then
-	echo "$as_me:16902: checking for dbmalloc.h" >&5
+	echo "$as_me:23281: checking for dbmalloc.h" >&5
 echo $ECHO_N "checking for dbmalloc.h... $ECHO_C" >&6
 if test "${ac_cv_header_dbmalloc_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 16908 "configure"
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 23287 "configure"
 #include "confdefs.h"
 #include <dbmalloc.h>
 _ACEOF
-if { (eval echo "$as_me:16912: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (eval echo "$as_me:23291: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:16918: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
+  echo "$as_me:23297: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
   else
@@ -16929,24 +23308,24 @@
   ac_cv_header_dbmalloc_h=yes
 else
   echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
+  cat "conftest.$ac_ext" >&5
   ac_cv_header_dbmalloc_h=no
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:16937: result: $ac_cv_header_dbmalloc_h" >&5
+echo "$as_me:23316: result: $ac_cv_header_dbmalloc_h" >&5
 echo "${ECHO_T}$ac_cv_header_dbmalloc_h" >&6
-if test $ac_cv_header_dbmalloc_h = yes; then
+if test "$ac_cv_header_dbmalloc_h" = yes; then
 
-echo "$as_me:16941: checking for debug_malloc in -ldbmalloc" >&5
+echo "$as_me:23320: checking for debug_malloc in -ldbmalloc" >&5
 echo $ECHO_N "checking for debug_malloc in -ldbmalloc... $ECHO_C" >&6
 if test "${ac_cv_lib_dbmalloc_debug_malloc+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldbmalloc  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 16949 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 23328 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -16955,39 +23334,39 @@
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char debug_malloc ();
+char debug_malloc (void);
 int
-main ()
+main (void)
 {
 debug_malloc ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:16968: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:23347: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:16971: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:16974: \"$ac_try\"") >&5
+  echo "$as_me:23350: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:23353: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16977: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:23356: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   ac_cv_lib_dbmalloc_debug_malloc=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 ac_cv_lib_dbmalloc_debug_malloc=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:16988: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5
+echo "$as_me:23367: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5
 echo "${ECHO_T}$ac_cv_lib_dbmalloc_debug_malloc" >&6
-if test $ac_cv_lib_dbmalloc_debug_malloc = yes; then
+if test "$ac_cv_lib_dbmalloc_debug_malloc" = yes; then
   cat >>confdefs.h <<EOF
 #define HAVE_LIBDBMALLOC 1
 EOF
@@ -17000,27 +23379,32 @@
 
 fi
 
-echo "$as_me:17003: checking if you want to use valgrind for testing" >&5
+echo "$as_me:23382: checking if you want to use valgrind for testing" >&5
 echo $ECHO_N "checking if you want to use valgrind for testing... $ECHO_C" >&6
 
 # Check whether --with-valgrind or --without-valgrind was given.
 if test "${with_valgrind+set}" = set; then
   withval="$with_valgrind"
+  case "x$withval" in
+	(x|xno) ;;
+	(*)
+		: "${with_cflags:=-g}"
+		: "${enable_leaks:=no}"
+		with_valgrind=yes
 
 cat >>confdefs.h <<EOF
 #define USE_VALGRIND 1
 EOF
 
-	: ${with_cflags:=-g}
-	: ${with_no_leaks:=yes}
-	 with_valgrind=yes
+		;;
+	esac
 else
   with_valgrind=
 fi;
-echo "$as_me:17020: result: ${with_valgrind:-no}" >&5
+echo "$as_me:23404: result: ${with_valgrind:-no}" >&5
 echo "${ECHO_T}${with_valgrind:-no}" >&6
 
-case .$with_cflags in
+case ".$with_cflags" in
 (.*-g*)
 	case .$CFLAGS in
 	(.*-g*)
@@ -17034,23 +23418,29 @@
 
 for cf_add_cflags in -g
 do
-case $cf_fix_cppflags in
+case "$cf_fix_cppflags" in
 (no)
-	case $cf_add_cflags in
+	case "$cf_add_cflags" in
 	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
-		case $cf_add_cflags in
+		case "$cf_add_cflags" in
 		(-D*)
-			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
 
 			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 				&& test -z "${cf_tst_cflags}" \
 				&& cf_fix_cppflags=yes
 
-			if test $cf_fix_cppflags = yes ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+			if test "$cf_fix_cppflags" = yes ; then
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			elif test "${cf_tst_cflags}" = "\"'" ; then
-				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
 				continue
 			fi
 			;;
@@ -17059,7 +23449,7 @@
 		(*$cf_add_cflags)
 			;;
 		(*)
-			case $cf_add_cflags in
+			case "$cf_add_cflags" in
 			(-D*)
 				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
 
@@ -17069,19 +23459,27 @@
 
 				;;
 			esac
-			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+
+	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
+	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"
+
 			;;
 		esac
 		;;
 	(*)
-		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+
+	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
+	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"
+
 		;;
 	esac
 	;;
 (yes)
-	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
 
-	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
+	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"
+
+	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'`
 
 	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
 		&& test -z "${cf_tst_cflags}" \
@@ -17092,17 +23490,23 @@
 
 if test -n "$cf_new_cflags" ; then
 
-	CFLAGS="$CFLAGS $cf_new_cflags"
+	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
+	CFLAGS="${CFLAGS}$cf_new_cflags"
+
 fi
 
 if test -n "$cf_new_cppflags" ; then
 
-	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
+
 fi
 
 if test -n "$cf_new_extra_cppflags" ; then
 
-	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
+
 fi
 
 		;;
@@ -17110,20 +23514,21 @@
 	;;
 esac
 
-echo "$as_me:17113: checking if you want to perform memory-leak testing" >&5
+echo "$as_me:23517: checking if you want to perform memory-leak testing" >&5
 echo $ECHO_N "checking if you want to perform memory-leak testing... $ECHO_C" >&6
 
 # Check whether --enable-leaks or --disable-leaks was given.
 if test "${enable_leaks+set}" = set; then
   enableval="$enable_leaks"
-  if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi
+  enable_leaks=$enableval
 else
-  : ${with_no_leaks:=no}
+  enable_leaks=yes
 fi;
-echo "$as_me:17123: result: $with_no_leaks" >&5
+if test "x$enable_leaks" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi
+echo "$as_me:23528: result: $with_no_leaks" >&5
 echo "${ECHO_T}$with_no_leaks" >&6
 
-if test "$with_no_leaks" = yes ; then
+if test "$enable_leaks" = no ; then
 
 cat >>confdefs.h <<\EOF
 #define NO_LEAKS 1
@@ -17136,101 +23541,104 @@
 fi
 
 LD_RPATH_OPT=
-echo "$as_me:17139: checking for an rpath option" >&5
+if test "x$cf_cv_enable_rpath" != xno
+then
+	echo "$as_me:23546: checking for an rpath option" >&5
 echo $ECHO_N "checking for an rpath option... $ECHO_C" >&6
-case $cf_cv_system_name in
-(irix*)
-	if test "$GCC" = yes; then
+	case "$cf_cv_system_name" in
+	(irix*)
+		if test "$GCC" = yes; then
+			LD_RPATH_OPT="-Wl,-rpath,"
+		else
+			LD_RPATH_OPT="-rpath "
+		fi
+		;;
+	(linux*|gnu*|k*bsd*-gnu|freebsd*)
 		LD_RPATH_OPT="-Wl,-rpath,"
-	else
+		;;
+	(openbsd[2-9].*|mirbsd*)
+		LD_RPATH_OPT="-Wl,-rpath,"
+		;;
+	(dragonfly*)
 		LD_RPATH_OPT="-rpath "
-	fi
-	;;
-(linux*|gnu*|k*bsd*-gnu)
-	LD_RPATH_OPT="-Wl,-rpath,"
-	;;
-(openbsd[2-9].*|mirbsd*)
-	LD_RPATH_OPT="-Wl,-rpath,"
-	;;
-(dragonfly*|freebsd*)
-	LD_RPATH_OPT="-rpath "
-	;;
-(netbsd*)
-	LD_RPATH_OPT="-Wl,-rpath,"
-	;;
-(osf*|mls+*)
-	LD_RPATH_OPT="-rpath "
-	;;
-(solaris2*)
-	LD_RPATH_OPT="-R"
-	;;
-(*)
-	;;
-esac
-echo "$as_me:17170: result: $LD_RPATH_OPT" >&5
+		;;
+	(netbsd*)
+		LD_RPATH_OPT="-Wl,-rpath,"
+		;;
+	(osf*|mls+*)
+		LD_RPATH_OPT="-rpath "
+		;;
+	(solaris2*)
+		LD_RPATH_OPT="-R"
+		;;
+	(*)
+		;;
+	esac
+	echo "$as_me:23577: result: $LD_RPATH_OPT" >&5
 echo "${ECHO_T}$LD_RPATH_OPT" >&6
 
-case "x$LD_RPATH_OPT" in
-(x-R*)
-	echo "$as_me:17175: checking if we need a space after rpath option" >&5
+	case "x$LD_RPATH_OPT" in
+	(x-R*)
+		echo "$as_me:23582: checking if we need a space after rpath option" >&5
 echo $ECHO_N "checking if we need a space after rpath option... $ECHO_C" >&6
-	cf_save_LIBS="$LIBS"
+		cf_save_LIBS="$LIBS"
 
-cf_add_libs="${LD_RPATH_OPT}$libdir"
-# Filter out duplicates - this happens with badly-designed ".pc" files...
-for cf_add_1lib in $LIBS
-do
-	for cf_add_2lib in $cf_add_libs
-	do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"
-		then
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in ${LD_RPATH_OPT}$libdir; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
 			cf_add_1lib=
 			break
 		fi
 	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
 LIBS="$cf_add_libs"
 
-	cat >conftest.$ac_ext <<_ACEOF
-#line 17196 "configure"
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 23603 "configure"
 #include "confdefs.h"
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:17208: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:23615: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:17211: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:17214: \"$ac_try\"") >&5
+  echo "$as_me:23618: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:23621: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:17217: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  echo "$as_me:23624: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
   cf_rpath_space=no
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 cf_rpath_space=yes
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-	LIBS="$cf_save_LIBS"
-	echo "$as_me:17227: result: $cf_rpath_space" >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+		LIBS="$cf_save_LIBS"
+		echo "$as_me:23634: result: $cf_rpath_space" >&5
 echo "${ECHO_T}$cf_rpath_space" >&6
-	test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
-	;;
-esac
+		test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
+		;;
+	esac
+fi
 
-echo "$as_me:17233: checking if rpath-hack should be disabled" >&5
+echo "$as_me:23641: checking if rpath-hack should be disabled" >&5
 echo $ECHO_N "checking if rpath-hack should be disabled... $ECHO_C" >&6
 
 # Check whether --enable-rpath-hack or --disable-rpath-hack was given.
@@ -17238,30 +23646,32 @@
   enableval="$enable_rpath_hack"
   test "$enableval" != no && enableval=yes
 	if test "$enableval" != "yes" ; then
-    cf_disable_rpath_hack=yes
+    enable_rpath_hack=no
 	else
-		cf_disable_rpath_hack=no
+		enable_rpath_hack=yes
 	fi
 else
   enableval=yes
-	cf_disable_rpath_hack=no
+	enable_rpath_hack=yes
 
 fi;
-echo "$as_me:17250: result: $cf_disable_rpath_hack" >&5
+if test "x$enable_rpath_hack" = xno; then cf_disable_rpath_hack=yes; else cf_disable_rpath_hack=no; fi
+echo "$as_me:23659: result: $cf_disable_rpath_hack" >&5
 echo "${ECHO_T}$cf_disable_rpath_hack" >&6
-if test "$cf_disable_rpath_hack" = no ; then
 
-echo "$as_me:17254: checking for updated LDFLAGS" >&5
+if test "$enable_rpath_hack" = yes ; then
+
+echo "$as_me:23664: checking for updated LDFLAGS" >&5
 echo $ECHO_N "checking for updated LDFLAGS... $ECHO_C" >&6
 if test -n "$LD_RPATH_OPT" ; then
-	echo "$as_me:17257: result: maybe" >&5
+	echo "$as_me:23667: result: maybe" >&5
 echo "${ECHO_T}maybe" >&6
 
 	for ac_prog in ldd
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:17264: checking for $ac_word" >&5
+echo "$as_me:23674: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_cf_ldd_prog+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -17276,7 +23686,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_cf_ldd_prog="$ac_prog"
-echo "$as_me:17279: found $ac_dir/$ac_word" >&5
+echo "$as_me:23689: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -17284,10 +23694,10 @@
 fi
 cf_ldd_prog=$ac_cv_prog_cf_ldd_prog
 if test -n "$cf_ldd_prog"; then
-  echo "$as_me:17287: result: $cf_ldd_prog" >&5
+  echo "$as_me:23697: result: $cf_ldd_prog" >&5
 echo "${ECHO_T}$cf_ldd_prog" >&6
 else
-  echo "$as_me:17290: result: no" >&5
+  echo "$as_me:23700: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -17300,37 +23710,37 @@
 	then
 		cf_rpath_oops=
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 17304 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 23714 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 printf("Hello");
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:17316: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:23726: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:17319: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:17322: \"$ac_try\"") >&5
+  echo "$as_me:23729: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:23732: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:17325: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
-		 cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[ 	]/%/%' -e 's%/[^/][^/]*$%%' |sort | uniq`
+  echo "$as_me:23735: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_rpath_oops=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
+		 cf_rpath_list=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} / | sed -e 's%^.*[ 	]/%/%' -e 's%/[^/][^/]*$%%' |sort | uniq`
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+cat "conftest.$ac_ext" >&5
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 		# If we passed the link-test, but get a "not found" on a given library,
 		# this could be due to inept reconfiguration of gcc to make it only
@@ -17346,11 +23756,11 @@
 					/usr/pkg \
 					/opt/sfw
 				do
-					if test -f $cf_rpath_dir/lib/$cf_rpath_src
+					if test -f "$cf_rpath_dir/lib/$cf_rpath_src"
 					then
 						test -n "$verbose" && echo "	...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src" 1>&6
 
-echo "${as_me:-configure}:17353: testing ...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src ..." 1>&5
+echo "${as_me:-configure}:23763: testing ...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src ..." 1>&5
 
 						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
 						break
@@ -17362,16 +23772,16 @@
 
 	test -n "$verbose" && echo "	...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS" 1>&6
 
-echo "${as_me:-configure}:17365: testing ...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5
+echo "${as_me:-configure}:23775: testing ...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5
 
 test -n "$verbose" && echo "	...checking LDFLAGS $LDFLAGS" 1>&6
 
-echo "${as_me:-configure}:17369: testing ...checking LDFLAGS $LDFLAGS ..." 1>&5
+echo "${as_me:-configure}:23779: testing ...checking LDFLAGS $LDFLAGS ..." 1>&5
 
 cf_rpath_dst=
 for cf_rpath_src in $LDFLAGS
 do
-	case $cf_rpath_src in
+	case "$cf_rpath_src" in
 	(-L*)
 
 		# check if this refers to a directory which we will ignore
@@ -17403,7 +23813,7 @@
 			then
 				test -n "$verbose" && echo "	...Filter $cf_rpath_src ->$cf_rpath_tmp" 1>&6
 
-echo "${as_me:-configure}:17406: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5
+echo "${as_me:-configure}:23816: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5
 
 				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
 			fi
@@ -17416,16 +23826,16 @@
 
 test -n "$verbose" && echo "	...checked LDFLAGS $LDFLAGS" 1>&6
 
-echo "${as_me:-configure}:17419: testing ...checked LDFLAGS $LDFLAGS ..." 1>&5
+echo "${as_me:-configure}:23829: testing ...checked LDFLAGS $LDFLAGS ..." 1>&5
 
 test -n "$verbose" && echo "	...checking LIBS $LIBS" 1>&6
 
-echo "${as_me:-configure}:17423: testing ...checking LIBS $LIBS ..." 1>&5
+echo "${as_me:-configure}:23833: testing ...checking LIBS $LIBS ..." 1>&5
 
 cf_rpath_dst=
 for cf_rpath_src in $LIBS
 do
-	case $cf_rpath_src in
+	case "$cf_rpath_src" in
 	(-L*)
 
 		# check if this refers to a directory which we will ignore
@@ -17457,7 +23867,7 @@
 			then
 				test -n "$verbose" && echo "	...Filter $cf_rpath_src ->$cf_rpath_tmp" 1>&6
 
-echo "${as_me:-configure}:17460: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5
+echo "${as_me:-configure}:23870: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5
 
 				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
 			fi
@@ -17470,14 +23880,14 @@
 
 test -n "$verbose" && echo "	...checked LIBS $LIBS" 1>&6
 
-echo "${as_me:-configure}:17473: testing ...checked LIBS $LIBS ..." 1>&5
+echo "${as_me:-configure}:23883: testing ...checked LIBS $LIBS ..." 1>&5
 
 	test -n "$verbose" && echo "	...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS" 1>&6
 
-echo "${as_me:-configure}:17477: testing ...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5
+echo "${as_me:-configure}:23887: testing ...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5
 
 else
-	echo "$as_me:17480: result: no" >&5
+	echo "$as_me:23890: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -17498,7 +23908,7 @@
 # config.status only pays attention to the cache file if you give it
 # the --recheck option to rerun configure.
 #
-# `ac_cv_env_foo' variables (set or unset) will be overriden when
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
 # loading this file, other *unset* `ac_cv_foo' will be assigned the
 # following values.
 
@@ -17564,25 +23974,29 @@
 
 DEFS=-DHAVE_CONFIG_H
 
-: ${CONFIG_STATUS=./config.status}
+: "${CONFIG_STATUS=./config.status}"
 ac_clean_files_save=$ac_clean_files
 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:17570: creating $CONFIG_STATUS" >&5
+{ echo "$as_me:23980: creating $CONFIG_STATUS" >&5
 echo "$as_me: creating $CONFIG_STATUS" >&6;}
-cat >$CONFIG_STATUS <<_ACEOF
+cat >"$CONFIG_STATUS" <<_ACEOF
 #! $SHELL
 # Generated automatically by configure.
 # Run this file to recreate the current configuration.
 # Compiler output produced by configure, useful for debugging
 # configure, is in config.log if it exists.
 
+me=\`echo "\$0" | sed -e 's,.*\\/,,'\`
+
 debug=false
 SHELL=\${CONFIG_SHELL-$SHELL}
 ac_cs_invocation="\$0 \$@"
 
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
 _ACEOF
 
-cat >>$CONFIG_STATUS <<\_ACEOF
+cat >>"$CONFIG_STATUS" <<\_ACEOF
 # Be Bourne compatible
 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
   emulate sh
@@ -17595,9 +24009,9 @@
 as_me=`echo "$0" |sed 's,.*[\\/],,'`
 
 if expr a : '\(a\)' >/dev/null 2>&1; then
-  as_expr=expr
+  as_expr="expr"
 else
-  as_expr=false
+  as_expr="false"
 fi
 
 rm -f conf$$ conf$$.exe conf$$.file
@@ -17612,7 +24026,7 @@
     as_ln_s='ln -s'
   fi
 elif ln conf$$.file conf$$ 2>/dev/null; then
-  as_ln_s=ln
+  as_ln_s='ln'
 else
   as_ln_s='cp -p'
 fi
@@ -17622,9 +24036,9 @@
 
 # Support unset when possible.
 if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
-  as_unset=unset
+  as_unset="unset"
 else
-  as_unset=false
+  as_unset="false"
 fi
 
 # NLS nuisances.
@@ -17652,22 +24066,22 @@
 
 # Files that config.status was made for.
 if test -n "$ac_config_files"; then
-  echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
+  echo "config_files=\"$ac_config_files\"" >>"$CONFIG_STATUS"
 fi
 
 if test -n "$ac_config_headers"; then
-  echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
+  echo "config_headers=\"$ac_config_headers\"" >>"$CONFIG_STATUS"
 fi
 
 if test -n "$ac_config_links"; then
-  echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
+  echo "config_links=\"$ac_config_links\"" >>"$CONFIG_STATUS"
 fi
 
 if test -n "$ac_config_commands"; then
-  echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
+  echo "config_commands=\"$ac_config_commands\"" >>"$CONFIG_STATUS"
 fi
 
-cat >>$CONFIG_STATUS <<\EOF
+cat >>"$CONFIG_STATUS" <<\EOF
 
 ac_cs_usage="\
 \`$as_me' instantiates files from templates according to the
@@ -17696,21 +24110,22 @@
 Report bugs to <dickey@invisible-island.net>."
 EOF
 
-cat >>$CONFIG_STATUS <<EOF
+cat >>"$CONFIG_STATUS" <<EOF
 ac_cs_version="\\
 config.status
-configured by $0, generated by GNU Autoconf 2.52.20141204,
+configured by $0, generated by GNU Autoconf 2.52.20231210,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
+Copyright 2003-2022,2023	Thomas E. Dickey
 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
-srcdir=$srcdir
+srcdir="$srcdir"
 INSTALL="$INSTALL"
 EOF
 
-cat >>$CONFIG_STATUS <<\EOF
+cat >>"$CONFIG_STATUS" <<\EOF
 # If no file are specified by the user, then we need to provide default
 # value.  By we need to know if files were specified by the user.
 ac_need_defaults=:
@@ -17733,17 +24148,17 @@
   case $1 in
   # Handling of the options.
 EOF
-cat >>$CONFIG_STATUS <<EOF
+cat >>"$CONFIG_STATUS" <<EOF
   -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
     echo "running $SHELL $0 " $ac_configure_args " --no-create --no-recursion"
     exec $SHELL $0 $ac_configure_args --no-create --no-recursion ;;
 EOF
-cat >>$CONFIG_STATUS <<\EOF
+cat >>"$CONFIG_STATUS" <<\EOF
   --version | --vers* | -V )
     echo "$ac_cs_version"; exit 0 ;;
   --he | --h)
     # Conflict between --help and --header
-    { { echo "$as_me:17746: error: ambiguous option: $1
+    { { echo "$as_me:24161: error: ambiguous option: $1
 Try \`$0 --help' for more information." >&5
 echo "$as_me: error: ambiguous option: $1
 Try \`$0 --help' for more information." >&2;}
@@ -17762,7 +24177,7 @@
     ac_need_defaults=false;;
 
   # This is an error.
-  -*) { { echo "$as_me:17765: error: unrecognized option: $1
+  -*) { { echo "$as_me:24180: error: unrecognized option: $1
 Try \`$0 --help' for more information." >&5
 echo "$as_me: error: unrecognized option: $1
 Try \`$0 --help' for more information." >&2;}
@@ -17781,18 +24196,18 @@
 ## Running config.status.  ##
 ## ----------------------- ##
 
-This file was extended by $as_me 2.52.20141204, executed with
+This file was extended by $as_me 2.52.20231210, executed with
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
   CONFIG_LINKS    = $CONFIG_LINKS
   CONFIG_COMMANDS = $CONFIG_COMMANDS
-  > $ac_cs_invocation
+  > "$ac_cs_invocation"
 on `(hostname || uname -n) 2>/dev/null | sed 1q`
 
 _ACEOF
 EOF
 
-cat >>$CONFIG_STATUS <<EOF
+cat >>"$CONFIG_STATUS" <<EOF
 #
 # INIT-COMMANDS section.
 #
@@ -17804,7 +24219,7 @@
 
 EOF
 
-cat >>$CONFIG_STATUS <<\EOF
+cat >>"$CONFIG_STATUS" <<\EOF
 for ac_config_target in $ac_config_targets
 do
   case "$ac_config_target" in
@@ -17812,7 +24227,7 @@
   "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
   "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
   "ncurses_cfg.h" ) CONFIG_HEADERS="$CONFIG_HEADERS ncurses_cfg.h:ncurses_tst.hin" ;;
-  *) { { echo "$as_me:17815: error: invalid argument: $ac_config_target" >&5
+  *) { { echo "$as_me:24230: error: invalid argument: $ac_config_target" >&5
 echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
    { (exit 1); exit 1; }; };;
   esac
@@ -17822,7 +24237,7 @@
 # then the envvar interface is used.  Set only those that are not.
 # We use the long form for the default assignment because of an extremely
 # bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
+if "$ac_need_defaults"; then
   test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
   test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
   test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
@@ -17836,14 +24251,14 @@
 }
 
 # Create a (secure) tmp directory for tmp files.
-: ${TMPDIR=/tmp}
+: "${TMPDIR=/tmp}"
 {
   tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` &&
   test -n "$tmp" && test -d "$tmp"
 }  ||
 {
   tmp=$TMPDIR/cs$$-$RANDOM
-  (umask 077 && mkdir $tmp)
+  (umask 077 && mkdir "$tmp")
 } ||
 {
    echo "$me: cannot create a temporary directory in $TMPDIR" >&2
@@ -17852,7 +24267,7 @@
 
 EOF
 
-cat >>$CONFIG_STATUS <<EOF
+cat >>"$CONFIG_STATUS" <<EOF
 
 #
 # CONFIG_FILES section.
@@ -17863,7 +24278,7 @@
 if test -n "\$CONFIG_FILES"; then
   # Protect against being on the right side of a sed subst in config.status.
   sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
-   s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
+   s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >"\$tmp"/subs.sed <<\\CEOF
 s,@SHELL@,$SHELL,;t t
 s,@exec_prefix@,$exec_prefix,;t t
 s,@prefix@,$prefix,;t t
@@ -17876,6 +24291,7 @@
 s,@sysconfdir@,$sysconfdir,;t t
 s,@sharedstatedir@,$sharedstatedir,;t t
 s,@localstatedir@,$localstatedir,;t t
+s,@runstatedir@,$runstatedir,;t t
 s,@libdir@,$libdir,;t t
 s,@includedir@,$includedir,;t t
 s,@oldincludedir@,$oldincludedir,;t t
@@ -17913,12 +24329,19 @@
 s,@OBJEXT@,$OBJEXT,;t t
 s,@EXTRA_CPPFLAGS@,$EXTRA_CPPFLAGS,;t t
 s,@CPP@,$CPP,;t t
+s,@GREP@,$GREP,;t t
+s,@EGREP@,$EGREP,;t t
 s,@AWK@,$AWK,;t t
 s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
 s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
 s,@INSTALL_DATA@,$INSTALL_DATA,;t t
+s,@INSTALL_OPT_S@,$INSTALL_OPT_S,;t t
+s,@INSTALL_OPT_O@,$INSTALL_OPT_O,;t t
 s,@LINT@,$LINT,;t t
 s,@LINT_OPTS@,$LINT_OPTS,;t t
+s,@LINT_LIBS@,$LINT_LIBS,;t t
+s,@MAKE_NO_PHONY@,$MAKE_NO_PHONY,;t t
+s,@MAKE_PHONY@,$MAKE_PHONY,;t t
 s,@CTAGS@,$CTAGS,;t t
 s,@ETAGS@,$ETAGS,;t t
 s,@MAKE_LOWER_TAGS@,$MAKE_LOWER_TAGS,;t t
@@ -17952,6 +24375,9 @@
 s,@cf_cv_abi_version@,$cf_cv_abi_version,;t t
 s,@cf_cv_rel_version@,$cf_cv_rel_version,;t t
 s,@includesubdir@,$includesubdir,;t t
+s,@FGREP@,$FGREP,;t t
+s,@HAVE_STDNORETURN_H@,$HAVE_STDNORETURN_H,;t t
+s,@STDC_NORETURN@,$STDC_NORETURN,;t t
 s,@PKG_CONFIG@,$PKG_CONFIG,;t t
 s,@ac_pt_PKG_CONFIG@,$ac_pt_PKG_CONFIG,;t t
 s,@ECHO_LT@,$ECHO_LT,;t t
@@ -17968,6 +24394,12 @@
 s,@X_EXTRA_LIBS@,$X_EXTRA_LIBS,;t t
 s,@XCURSES_CONFIG@,$XCURSES_CONFIG,;t t
 s,@ac_ct_XCURSES_CONFIG@,$ac_ct_XCURSES_CONFIG,;t t
+s,@cf_cv_screen@,$cf_cv_screen,;t t
+s,@RGB_PATH@,$RGB_PATH,;t t
+s,@no_x11_rgb@,$no_x11_rgb,;t t
+s,@FORM_NAME@,$FORM_NAME,;t t
+s,@MENU_NAME@,$MENU_NAME,;t t
+s,@PANEL_NAME@,$PANEL_NAME,;t t
 s,@EXTRA_CFLAGS@,$EXTRA_CFLAGS,;t t
 s,@cf_ldd_prog@,$cf_ldd_prog,;t t
 s,@EXTRA_LDFLAGS@,$EXTRA_LDFLAGS,;t t
@@ -17975,7 +24407,7 @@
 
 EOF
 
-  cat >>$CONFIG_STATUS <<\EOF
+  cat >>"$CONFIG_STATUS" <<\EOF
   # Split the substitutions into bite-sized pieces for seds with
   # small command number limits, like on Digital OSF/1 and HP-UX.
   ac_max_sed_lines=48
@@ -17984,13 +24416,13 @@
   ac_end=$ac_max_sed_lines # Line after last line for current file.
   ac_more_lines=:
   ac_sed_cmds=
-  while $ac_more_lines; do
-    if test $ac_beg -gt 1; then
-      sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+  while "$ac_more_lines"; do
+    if test "$ac_beg" -gt 1; then
+      sed "1,${ac_beg}d; ${ac_end}q" "$tmp"/subs.sed >"$tmp"/subs.frag
     else
-      sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+      sed "${ac_end}q" "$tmp"/subs.sed >"$tmp"/subs.frag
     fi
-    if test ! -s $tmp/subs.frag; then
+    if test ! -s "$tmp"/subs.frag; then
       ac_more_lines=false
     else
       # The purpose of the label and of the branching condition is to
@@ -17998,29 +24430,47 @@
       # is no need to browse any of the substitutions).
       # These are the two extra sed commands mentioned above.
       (echo ':t
-  /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
-      if test -z "$ac_sed_cmds"; then
-  	ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
-      else
-  	ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
+  /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat "$tmp"/subs.frag) >"$tmp"/subs-$ac_sed_frag.sed
+      # It is possible to make a multiline substitution using escaped newlines.
+      # Ensure that we do not split the substitution between script fragments.
+      ac_BEG=$ac_end
+      ac_END=`expr "$ac_end" + "$ac_max_sed_lines"`
+      sed "1,${ac_BEG}d; ${ac_END}p; q" "$tmp"/subs.sed >"$tmp"/subs.next
+      if test -s "$tmp"/subs.next; then
+        grep '^s,@[^@,][^@,]*@,.*\\$' "$tmp"/subs.next >"$tmp"/subs.edit
+        if test ! -s "$tmp"/subs.edit; then
+          grep "^s,@[^@,][^@,]*@,.*,;t t$" "$tmp"/subs.next >"$tmp"/subs.edit
+          if test ! -s "$tmp"/subs.edit; then
+            if test "$ac_beg" -gt 1; then
+              ac_end=`expr "$ac_end" - 1`
+              continue
+            fi
+          fi
+        fi
       fi
-      ac_sed_frag=`expr $ac_sed_frag + 1`
+
+      if test -z "$ac_sed_cmds"; then
+        ac_sed_cmds="sed -f \"$tmp\"/subs-$ac_sed_frag.sed"
+      else
+        ac_sed_cmds="$ac_sed_cmds | sed -f \"$tmp\"/subs-$ac_sed_frag.sed"
+      fi
+      ac_sed_frag=`expr "$ac_sed_frag" + 1`
       ac_beg=$ac_end
-      ac_end=`expr $ac_end + $ac_max_sed_lines`
+      ac_end=`expr "$ac_end" + "$ac_max_sed_lines"`
     fi
   done
   if test -z "$ac_sed_cmds"; then
-    ac_sed_cmds=cat
+    ac_sed_cmds="cat"
   fi
 fi # test -n "$CONFIG_FILES"
 
 EOF
-cat >>$CONFIG_STATUS <<\EOF
+cat >>"$CONFIG_STATUS" <<\EOF
 for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
   # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
-  case $ac_file in
+  case "$ac_file" in
   - | *:- | *:-:* ) # input from stdin
-        cat >$tmp/stdin
+        cat >"$tmp"/stdin
         ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
         ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
   *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
@@ -18057,26 +24507,26 @@
   esac
 done; }
 
-    ac_dir_suffix="/`echo $ac_dir|sed 's,^\./,,'`"
+    ac_dir_suffix="/`echo "$ac_dir"|sed 's,^\./,,'`"
     # A "../" for each directory in $ac_dir_suffix.
     ac_dots=`echo "$ac_dir_suffix" | sed 's,/[^/]*,../,g'`
   else
     ac_dir_suffix= ac_dots=
   fi
 
-  case $srcdir in
+  case "$srcdir" in
   .)  ac_srcdir=.
       if test -z "$ac_dots"; then
          ac_top_srcdir=.
       else
-         ac_top_srcdir=`echo $ac_dots | sed 's,/$,,'`
+         ac_top_srcdir=`echo "$ac_dots" | sed 's,/$,,'`
       fi ;;
   [\\/]* | ?:[\\/]* )
-      ac_srcdir=$srcdir$ac_dir_suffix;
-      ac_top_srcdir=$srcdir ;;
+      ac_srcdir="$srcdir$ac_dir_suffix";
+      ac_top_srcdir="$srcdir" ;;
   *) # Relative path.
-    ac_srcdir=$ac_dots$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_dots$srcdir ;;
+    ac_srcdir="$ac_dots$srcdir$ac_dir_suffix"
+    ac_top_srcdir="$ac_dots$srcdir" ;;
   esac
 
   case $INSTALL in
@@ -18085,7 +24535,7 @@
   esac
 
   if test x"$ac_file" != x-; then
-    { echo "$as_me:18088: creating $ac_file" >&5
+    { echo "$as_me:24538: creating $ac_file" >&5
 echo "$as_me: creating $ac_file" >&6;}
     rm -f "$ac_file"
   fi
@@ -18100,48 +24550,48 @@
   ac_file_inputs=`IFS=:
     for f in $ac_file_in; do
       case $f in
-      -) echo $tmp/stdin ;;
+      -) echo "$tmp"/stdin ;;
       [\\/$]*)
          # Absolute (can't be DOS-style, as IFS=:)
-         test -f "$f" || { { echo "$as_me:18106: error: cannot find input file: $f" >&5
+         test -f "$f" || { { echo "$as_me:24556: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
-         echo $f;;
+         echo "$f";;
       *) # Relative
          if test -f "$f"; then
            # Build tree
-           echo $f
+           echo "$f"
          elif test -f "$srcdir/$f"; then
            # Source tree
-           echo $srcdir/$f
+           echo "$srcdir/$f"
          else
            # /dev/null tree
-           { { echo "$as_me:18119: error: cannot find input file: $f" >&5
+           { { echo "$as_me:24569: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          fi;;
       esac
     done` || { (exit 1); exit 1; }
 EOF
-cat >>$CONFIG_STATUS <<\EOF
+cat >>"$CONFIG_STATUS" <<\EOF
   ac_warn_datarootdir=no
   if test x"$ac_file" != x-; then
     for ac_item in $ac_file_inputs
     do
-      ac_seen=`grep '@\(datadir\|mandir\|infodir\)@' $ac_item`
+      ac_seen=`grep '@\(datadir\|mandir\|infodir\)@' "$ac_item"`
       if test -n "$ac_seen"; then
-        ac_used=`grep '@datarootdir@' $ac_item`
+        ac_used=`grep '@datarootdir@' "$ac_item"`
         if test -z "$ac_used"; then
-          { echo "$as_me:18135: WARNING: datarootdir was used implicitly but not set:
+          { echo "$as_me:24585: WARNING: datarootdir was used implicitly but not set:
 $ac_seen" >&5
 echo "$as_me: WARNING: datarootdir was used implicitly but not set:
 $ac_seen" >&2;}
           ac_warn_datarootdir=yes
         fi
       fi
-      ac_seen=`grep '${datarootdir}' $ac_item`
+      ac_seen=`grep '${datarootdir}' "$ac_item"`
       if test -n "$ac_seen"; then
-        { echo "$as_me:18144: WARNING: datarootdir was used explicitly but not set:
+        { echo "$as_me:24594: WARNING: datarootdir was used explicitly but not set:
 $ac_seen" >&5
 echo "$as_me: WARNING: datarootdir was used explicitly but not set:
 $ac_seen" >&2;}
@@ -18155,53 +24605,61 @@
 fi
 
 EOF
-cat >>$CONFIG_STATUS <<EOF
+cat >>"$CONFIG_STATUS" <<EOF
   sed "$ac_vpsub
 $extrasub
 EOF
-cat >>$CONFIG_STATUS <<\EOF
+cat >>"$CONFIG_STATUS" <<\EOF
 :t
 /@[a-zA-Z_][a-zA-Z_0-9]*@/!b
 s,@configure_input@,$configure_input,;t t
 s,@srcdir@,$ac_srcdir,;t t
 s,@top_srcdir@,$ac_top_srcdir,;t t
 s,@INSTALL@,$ac_INSTALL,;t t
-" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
-  rm -f $tmp/stdin
+" $ac_file_inputs | (eval "$ac_sed_cmds") >"$tmp"/out
+  rm -f "$tmp"/stdin
+EOF
+test -n "${FGREP}" || FGREP="grep -F"
+test -n "${EGREP}" || EGREP="grep -E"
+cat >>"$CONFIG_STATUS" <<EOF
+  test -n "\${FGREP}" || FGREP="$FGREP"
+  test -n "\${EGREP}" || EGREP="$EGREP"
+EOF
+cat >>"$CONFIG_STATUS" <<\EOF
   if test x"$ac_file" != x-; then
-    cp $tmp/out $ac_file
+    cp "$tmp/out" "$ac_file"
 
     for ac_name in prefix exec_prefix datarootdir
     do
-        ac_seen=`fgrep -n '${'$ac_name'[:=].*}' $ac_file`
+        ac_seen=`$FGREP -n '${'$ac_name'[:=].*}' "$ac_file"`
         if test -n "$ac_seen"; then
-            ac_init=`egrep '[ 	]*'$ac_name'[ 	]*=' $ac_file`
+            ac_init=`$EGREP '[ 	]*'$ac_name'[ 	]*=' "$ac_file"`
             if test -z "$ac_init"; then
-              ac_seen=`echo "$ac_seen" |sed -e 's,^,'$ac_file':,'`
-              { echo "$as_me:18181: WARNING: Variable $ac_name is used but was not set:
+              ac_seen=`echo "$ac_seen" |sed -e 's,^,'"$ac_file"':,'`
+              { echo "$as_me:24639: WARNING: Variable $ac_name is used but was not set:
 $ac_seen" >&5
 echo "$as_me: WARNING: Variable $ac_name is used but was not set:
 $ac_seen" >&2;}
             fi
         fi
     done
-    egrep -n '@[a-z_][a-z_0-9]+@' $ac_file >$tmp/out
-    egrep -n '@[A-Z_][A-Z_0-9]+@' $ac_file >>$tmp/out
-    if test -s $tmp/out; then
-      ac_seen=`sed -e 's,^,'$ac_file':,' < $tmp/out`
-      { echo "$as_me:18192: WARNING: Some variables may not be substituted:
+    $EGREP -n '@[a-z_][a-z_0-9]+@' "$ac_file" >"$tmp"/out
+    $EGREP -n '@[A-Z_][A-Z_0-9]+@' "$ac_file" >>"$tmp"/out
+    if test -s "$tmp"/out; then
+      ac_seen=`sed -e 's,^,'"$ac_file"':,' < "$tmp"/out`
+      { echo "$as_me:24650: WARNING: Some variables may not be substituted:
 $ac_seen" >&5
 echo "$as_me: WARNING: Some variables may not be substituted:
 $ac_seen" >&2;}
     fi
   else
-    cat $tmp/out
+    cat "$tmp"/out
   fi
-  rm -f $tmp/out
+  rm -f "$tmp"/out
 
 done
 EOF
-cat >>$CONFIG_STATUS <<\EOF
+cat >>"$CONFIG_STATUS" <<\EOF
 
 #
 # CONFIG_HEADER section.
@@ -18228,9 +24686,9 @@
 
 for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
   # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
-  case $ac_file in
+  case "$ac_file" in
   - | *:- | *:-:* ) # input from stdin
-        cat >$tmp/stdin
+        cat >"$tmp"/stdin
         ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
         ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
   *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
@@ -18238,7 +24696,7 @@
   * )   ac_file_in=$ac_file.in ;;
   esac
 
-  test x"$ac_file" != x- && { echo "$as_me:18241: creating $ac_file" >&5
+  test x"$ac_file" != x- && { echo "$as_me:24699: creating $ac_file" >&5
 echo "$as_me: creating $ac_file" >&6;}
 
   # First look for the input files in the build tree, otherwise in the
@@ -18246,10 +24704,10 @@
   ac_file_inputs=`IFS=:
     for f in $ac_file_in; do
       case $f in
-      -) echo $tmp/stdin ;;
+      -) echo "$tmp"/stdin ;;
       [\\/$]*)
          # Absolute (can't be DOS-style, as IFS=:)
-         test -f "$f" || { { echo "$as_me:18252: error: cannot find input file: $f" >&5
+         test -f "$f" || { { echo "$as_me:24710: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          echo $f;;
@@ -18259,17 +24717,17 @@
            echo $f
          elif test -f "$srcdir/$f"; then
            # Source tree
-           echo $srcdir/$f
+           echo "$srcdir/$f"
          else
            # /dev/null tree
-           { { echo "$as_me:18265: error: cannot find input file: $f" >&5
+           { { echo "$as_me:24723: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          fi;;
       esac
     done` || { (exit 1); exit 1; }
   # Remove the trailing spaces.
-  sed 's/[ 	]*$//' $ac_file_inputs >$tmp/in
+  sed 's/[ 	]*$//' $ac_file_inputs >"$tmp"/in
 
 EOF
 
@@ -18282,14 +24740,14 @@
 # the size of here documents, and old seds have small limits too.
 
 rm -f conftest.tail
-echo '  rm -f conftest.frag' >> $CONFIG_STATUS
+echo '  rm -f conftest.frag' >> "$CONFIG_STATUS"
 while grep . conftest.vals >/dev/null
 do
   # Write chunks of a limited-size here document to conftest.frag.
-  echo '  cat >> conftest.frag <<CEOF' >> $CONFIG_STATUS
-  sed ${ac_max_here_lines}q conftest.vals | sed -e 's/#ifdef.*/#if 0/' >> $CONFIG_STATUS
-  echo 'CEOF' >> $CONFIG_STATUS
-  sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+  echo '  cat >> conftest.frag <<CEOF' >> "$CONFIG_STATUS"
+  sed "${ac_max_here_lines}q" conftest.vals | sed -e 's/#ifdef.*/#if 0/' >> "$CONFIG_STATUS"
+  echo 'CEOF' >> "$CONFIG_STATUS"
+  sed "1,${ac_max_here_lines}d" conftest.vals > conftest.tail
   rm -f conftest.vals
   mv conftest.tail conftest.vals
 done
@@ -18301,26 +24759,26 @@
 /@DEFS@/r conftest.frag
 /@DEFS@/d
 CEOF
-sed -f conftest.edit $tmp/in > $tmp/out
-rm -f $tmp/in
-mv $tmp/out $tmp/in
+sed -f conftest.edit "$tmp"/in > "$tmp"/out
+rm -f "$tmp"/in
+mv "$tmp"/out "$tmp"/in
 rm -f conftest.edit conftest.frag
-' >> $CONFIG_STATUS
+' >> "$CONFIG_STATUS"
 
-cat >>$CONFIG_STATUS <<\EOF
+cat >>"$CONFIG_STATUS" <<\EOF
   # Let's still pretend it is `configure' which instantiates (i.e., don't
   # use $as_me), people would be surprised to read:
   #    /* config.h.  Generated automatically by config.status.  */
   if test x"$ac_file" = x-; then
-    echo "/* Generated automatically by configure.  */" >$tmp/config.h
+    echo "/* Generated automatically by configure.  */" >"$tmp"/config.h
   else
-    echo "/* $ac_file.  Generated automatically by configure.  */" >$tmp/config.h
+    echo "/* $ac_file.  Generated automatically by configure.  */" >"$tmp"/config.h
   fi
-  cat $tmp/in >>$tmp/config.h
-  rm -f $tmp/in
+  cat "$tmp"/in >>"$tmp"/config.h
+  rm -f "$tmp"/in
   if test x"$ac_file" != x-; then
-    if cmp -s $ac_file $tmp/config.h 2>/dev/null; then
-      { echo "$as_me:18323: $ac_file is unchanged" >&5
+    if cmp -s "$ac_file" "$tmp/config.h" 2>/dev/null; then
+      { echo "$as_me:24781: $ac_file is unchanged" >&5
 echo "$as_me: $ac_file is unchanged" >&6;}
     else
       ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
@@ -18352,16 +24810,16 @@
 done; }
 
       fi
-      rm -f $ac_file
-      mv $tmp/config.h $ac_file
+      rm -f "$ac_file"
+      mv "$tmp/config.h" "$ac_file"
     fi
   else
-    cat $tmp/config.h
-    rm -f $tmp/config.h
+    cat "$tmp"/config.h
+    rm -f "$tmp"/config.h
   fi
 done
 EOF
-cat >>$CONFIG_STATUS <<\EOF
+cat >>"$CONFIG_STATUS" <<\EOF
 #
 # CONFIG_COMMANDS section.
 #
@@ -18369,15 +24827,15 @@
   ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
   ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
 
-  case $ac_dest in
+  case "$ac_dest" in
     default )
 
 for cf_dir in .
 do
-	if test ! -d $srcdir/$cf_dir; then
+	if test ! -d "$srcdir/$cf_dir" ; then
 		continue
-	elif test -f $srcdir/$cf_dir/programs; then
-		$AWK -f $srcdir/mk-test.awk INSTALL=yes ECHO_LINK="$ECHO_LD" $srcdir/$cf_dir/programs >>$cf_dir/Makefile
+	elif test -f "$srcdir/$cf_dir/programs" ; then
+		$AWK -f $srcdir/mk-test.awk INSTALL=yes ECHO_LINK="$ECHO_LD" "$srcdir/$cf_dir/programs" >>$cf_dir/Makefile
 	fi
 done
 
@@ -18397,7 +24855,7 @@
 	\$(srcdir)/test.priv.h \\
 	ncurses_cfg.h
 	$SHOW_CC
-	$ECHO_CC\$(CC) -c \$(CFLAGS_DEFAULT) \$(srcdir)/$N.c
+	$ECHO_CC\$(CC) -c \$(CFLAGS_DEFAULT) -DMODULE_NAME="$N" \$(srcdir)/$N.c
 TEST_EOF
 done
 
@@ -18415,11 +24873,11 @@
 done
 EOF
 
-cat >>$CONFIG_STATUS <<\EOF
+cat >>"$CONFIG_STATUS" <<\EOF
 
 { (exit 0); exit 0; }
 EOF
-chmod +x $CONFIG_STATUS
+chmod +x "$CONFIG_STATUS"
 ac_clean_files=$ac_clean_files_save
 
 # configure is writing to config.log, and then calls config.status.
@@ -18433,10 +24891,10 @@
 if test "$no_create" != yes; then
   ac_cs_success=:
   exec 5>/dev/null
-  $SHELL $CONFIG_STATUS || ac_cs_success=false
+  $SHELL "$CONFIG_STATUS" || ac_cs_success=false
   exec 5>>config.log
   # Use ||, not &&, to avoid exiting from the if with $? = 1, which
   # would make configure fail if this is the last instruction.
-  $ac_cs_success || { (exit 1); exit 1; }
+  "$ac_cs_success" || { (exit 1); exit 1; }
 fi
 
diff --git a/test/configure.in b/test/configure.in
index 8a12523..4df1c11 100644
--- a/test/configure.in
+++ b/test/configure.in
@@ -1,5 +1,6 @@
 dnl***************************************************************************
-dnl Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
+dnl Copyright 2018-2023,2024 Thomas E. Dickey                                *
+dnl Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
 dnl                                                                          *
 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
 dnl copy of this software and associated documentation files (the            *
@@ -26,9 +27,9 @@
 dnl authorization.                                                           *
 dnl***************************************************************************
 dnl
-dnl Author: Thomas E. Dickey 1996, etc.
+dnl Author: Thomas E. Dickey 1996-on
 dnl
-dnl $Id: configure.in,v 1.124 2015/08/08 20:24:49 tom Exp $
+dnl $Id: configure.in,v 1.174 2024/03/30 14:31:11 tom Exp $
 dnl This is a simple configuration-script for the ncurses test programs that
 dnl allows the test-directory to be separately configured against a reference
 dnl system (i.e., sysvr4 curses)
@@ -36,9 +37,12 @@
 dnl If you're configuring ncurses, you shouldn't need to use this script.
 dnl It's only for testing purposes.
 dnl
-dnl See http://invisible-island.net/autoconf/ for additional information.
+dnl For additional information, see
+dnl		https://invisible-island.net/autoconf/
+dnl		https://invisible-island.net/autoconf/my-autoconf.html
+dnl		https://invisible-island.net/ncurses/ncurses-examples.html
 dnl ---------------------------------------------------------------------------
-AC_PREREQ(2.52.20030208)
+AC_PREREQ(2.52.20210509)
 AC_INIT(ncurses.c)
 AC_CONFIG_HEADER(ncurses_cfg.h:ncurses_tst.hin)
 
@@ -48,12 +52,17 @@
 
 AC_ARG_PROGRAM
 
+CF_HELP_MESSAGE(General Options:)
+
 AC_PROG_MAKE_SET
 CF_PROG_CC
+AC_C_INLINE
 AC_PROG_CPP
 AC_PROG_AWK
 CF_PROG_INSTALL
+CF_INSTALL_OPTS
 CF_PROG_LINT
+CF_MAKE_PHONY
 CF_MAKE_TAGS
 
 CF_MATH_LIB(MATH_LIB,pow(sin(x),x))
@@ -97,11 +106,18 @@
 AC_OBJEXT
 
 CF_GCC_ATTRIBUTES
-CF_XOPEN_SOURCE
+CF_ENABLE_STRING_HACKS
+CF_XOPEN_SOURCE(600)
+AC_CHECK_DECL(exit)
 CF_SIG_ATOMIC_T
 
+# Work around breakage on OS X
+CF_SIGWINCH
+
+# Checks for CODESET support.
+AM_LANGINFO_CODESET
+
 dnl ---------------------------------------------------------------------------
-CF_HELP_MESSAGE(General Options:)
 CF_PKG_CONFIG
 CF_DISABLE_ECHO
 
@@ -125,39 +141,103 @@
 (ncurses*)
 	cf_cv_libtype=`echo "$cf_cv_screen" | sed -e 's/^ncurses//'`
 	;;
-(curses|curses_*)
-	CF_NETBSD_FORM_H
-	CF_NETBSD_MENU_H
-	;;
 esac
 
+CF_WITH_X11_RGB
+
 dnl If we've not specified a library, assume we're using sysvr4 libraries
 dnl installed conventionally (e.g., SunOS 5.x - solaris).
 
 dnl Autoconf builds up the $LIBS in reverse order
 
+cf_curses_headers=
+
 case $cf_cv_screen in
 (pdcurses)
+	cf_default_panel=no
+	cf_default_form=no
+	cf_default_menu=no
+	cf_default_tinfo=no
+	;;
+(xcurses|bsdcurses)
+	cf_default_panel=no
+	cf_default_form=no
+	cf_default_menu=no
+	cf_default_tinfo=yes
 	;;
 (*)
-	# look for curses-related libraries
-	CF_CHECK_CURSES_LIB(panel,$cf_cv_libtype,new_panel)
-	CF_CHECK_CURSES_LIB(menu,$cf_cv_libtype,menu_driver)
-	CF_CHECK_CURSES_LIB(form,$cf_cv_libtype,form_driver)
-
-	# look for curses-related headers
-	AC_CHECK_HEADERS( \
-		nc_alloc.h \
-		nomacros.h \
-		form.h \
-		menu.h \
-		panel.h \
-		term_entry.h \
-		)
+	cf_default_panel=yes
+	cf_default_form=yes
+	cf_default_menu=yes
+	cf_default_tinfo=yes
+	case $cf_cv_screen in
+	(ncurses*)
+		cf_curses_headers="nc_alloc.h nomacros.h term_entry.h"
+		;;
+	esac
 	;;
 esac
 
-AC_STDC_HEADERS
+CF_WITH_LIB_BASENAME(FORM_NAME,form)
+CF_WITH_LIB_BASENAME(MENU_NAME,menu)
+CF_WITH_LIB_BASENAME(PANEL_NAME,panel)
+
+AC_MSG_CHECKING(if you want to check for panel functions)
+CF_ARG_DISABLE(panel,
+	[  --disable-panel         disable checks for panel functions],
+	cf_enable_panel=no,
+	cf_enable_panel=$cf_default_panel,
+	yes)
+AC_MSG_RESULT($cf_enable_panel)
+if test $cf_enable_panel = yes
+then
+	CF_CHECK_CURSES_LIB($PANEL_NAME,$cf_cv_libtype,new_panel,0)
+	cf_curses_headers="$cf_curses_headers panel.h"
+fi
+
+AC_MSG_CHECKING(if you want to check for menu functions)
+CF_ARG_DISABLE(menu,
+	[  --disable-menu          disable checks for menu functions],
+	cf_enable_menu=no,
+	cf_enable_menu=$cf_default_menu,
+	yes)
+AC_MSG_RESULT($cf_enable_menu)
+if test $cf_enable_menu = yes
+then
+	case $cf_cv_screen in
+	(ncurses*)
+		;;
+	(curses*)
+		CF_NETBSD_MENU_H
+		;;
+	esac
+	CF_CHECK_CURSES_LIB($MENU_NAME,$cf_cv_libtype,menu_driver,[0,0])
+	cf_curses_headers="$cf_curses_headers menu.h"
+fi
+
+AC_MSG_CHECKING(if you want to check for form functions)
+CF_ARG_DISABLE(form,
+	[  --disable-form          disable checks for form functions],
+	cf_enable_form=no,
+	cf_enable_form=$cf_default_form,
+	yes)
+AC_MSG_RESULT($cf_enable_form)
+if test $cf_enable_form = yes
+then
+	case $cf_cv_screen in
+	(ncurses*)
+		;;
+	(curses*)
+		CF_NETBSD_FORM_H
+		;;
+	esac
+	CF_CHECK_CURSES_LIB($FORM_NAME,$cf_cv_libtype,form_driver,[0,0])
+	cf_curses_headers="$cf_curses_headers form.h"
+fi
+
+# look for curses-related headers
+AC_CHECK_HEADERS( $cf_curses_headers )
+
 AC_HEADER_TIME
 AC_CHECK_HEADERS( \
 getopt.h \
@@ -172,12 +252,52 @@
 )
 
 CF_GETOPT_HEADER
+CF_FUNC_GETTIME
 
 AC_CHECK_FUNCS( \
 getopt \
-gettimeofday \
+snprintf \
+strdup \
+strstr \
+tsearch \
 )
 
+# use a compile-check to work with ncurses*-config and subdirectory includes
+AC_CACHE_CHECK(if we can use termcap.h,cf_cv_have_termcap_h,[
+	AC_TRY_COMPILE([
+#include <curses.h>
+#ifdef NCURSES_VERSION
+#undef NCURSES_VERSION
+#endif
+#include <termcap.h>
+#ifndef NCURSES_VERSION
+#error wrong header
+#endif
+],
+	[return 0;],
+	[cf_cv_have_termcap_h=yes],
+	[cf_cv_have_termcap_h=no])])
+if test "x$cf_cv_have_termcap_h" = xyes
+then
+	AC_DEFINE(HAVE_TERMCAP_H,1,[Define to 1 if we can use termcap.h])
+else
+AC_CACHE_CHECK(if we can use ncurses/termcap.h,cf_cv_have_ncurses_termcap_h,[
+	AC_TRY_COMPILE([
+#include <ncurses/curses.h>
+#ifdef NCURSES_VERSION
+#undef NCURSES_VERSION
+#endif
+#include <ncurses/termcap.h>
+#ifndef NCURSES_VERSION
+#error wrong header
+#endif
+],
+	[return 0;],
+	[cf_cv_have_ncurses_termcap_h=yes],
+	[cf_cv_have_ncurses_termcap_h=no])])
+test "x$cf_cv_have_ncurses_termcap_h" = xyes && AC_DEFINE(HAVE_NCURSES_TERMCAP_H,1,[Define to 1 if we can use ncurses/termcap.h])
+fi
+
 if test "x$ac_cv_func_getopt" = xno; then
 	AC_MSG_ERROR(getopt is required for building programs)
 fi
@@ -196,9 +316,19 @@
 fi
 
 CF_CURSES_FUNCS( \
+_nc_tparm_analyze \
+_tracef \
+alloc_pair \
 assume_default_colors \
 chgat \
+color_content \
 color_set \
+copywin \
+curses_trace \
+delscreen \
+dupwin \
+exit_curses \
+exit_terminfo \
 filter \
 getbegx \
 getcurx \
@@ -206,22 +336,35 @@
 getnstr \
 getparx \
 getwin \
+halfdelay \
+init_extended_color \
+mvderwin \
 mvvline \
+mvwin \
 mvwvline \
 napms \
+newpad \
 putwin \
+reset_color_pairs \
 resize_term \
 resizeterm \
+restartterm \
 ripoffline \
 scr_dump \
 setupterm \
 slk_color \
 slk_init \
 termattrs \
+termname \
 tgetent \
 tigetnum \
 tigetstr \
+tiparm \
+tiparm_s \
+tiscan_s \
+tputs_sp \
 typeahead \
+unget_wch \
 use_default_colors \
 use_env \
 use_extended_names \
@@ -232,6 +375,7 @@
 vsscanf \
 vw_printw \
 wchgat \
+winsdelln \
 winsstr \
 wresize \
 wsyncdown \
@@ -299,9 +443,20 @@
 	[cf_cv_use_pthreads=yes],
 	[cf_cv_use_pthreads=no])
 ])
-test $cf_cv_use_pthreads = yes && AC_DEFINE(USE_PTHREADS)
+test $cf_cv_use_pthreads = yes && AC_DEFINE(USE_PTHREADS,1,[Define to 1 if $cf_cv_screen library uses pthreads])
 
 CF_SYS_TIME_SELECT
+
+# special check for test/ditto.c
+CF_FUNC_OPENPTY
+if test "$cf_cv_func_openpty" != no ; then
+	AC_DEFINE_UNQUOTED(USE_OPENPTY_HEADER,<$cf_cv_func_openpty>,[Define to actual header for openpty function])
+	AC_DEFINE(USE_XTERM_PTY,1,[Define to 1 if we should assume xterm pseudoterminal interface])
+	if test "x$cf_cv_lib_util" = xyes ; then
+		CF_ADD_LIB(util,TEST_LIBS)
+	fi
+fi
+
 CF_FUNC_CURSES_VERSION
 
 CF_CURSES_ACS_MAP
@@ -330,13 +485,18 @@
 	fi
 fi
 
-CF_CURSES_CHECK_DATA(ospeed)
-CF_CURSES_CHECK_DATA(boolnames)
-CF_CURSES_CHECK_DATA(boolfnames)
+CF_CURSES_CHECK_DATA(\
+TABSIZE \
+curscr \
+ospeed \
+boolnames \
+boolfnames \
+ttytype)
 
 dnl ---------------------------------------------------------------------------
 CF_HELP_MESSAGE(Testing/development Options:)
-CF_ENABLE_WARNINGS
+CF_WITH_SCREEN_PDCURSES
+CF_ENABLE_WARNINGS(Wno-unknown-pragmas)
 CF_DISABLE_LEAKS
 CF_DISABLE_RPATH_HACK
 
@@ -363,7 +523,7 @@
 	\$(srcdir)/test.priv.h \\
 	ncurses_cfg.h
 	$SHOW_CC
-	$ECHO_CC\$(CC) -c \$(CFLAGS_DEFAULT) \$(srcdir)/$N.c
+	$ECHO_CC\$(CC) -c \$(CFLAGS_DEFAULT) -DMODULE_NAME="$N" \$(srcdir)/$N.c
 TEST_EOF
 done
 
diff --git a/test/demo_altkeys.c b/test/demo_altkeys.c
index f2b07b1..ea6a7e6 100644
--- a/test/demo_altkeys.c
+++ b/test/demo_altkeys.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2005-2006,2008 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2005-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            *
@@ -26,27 +27,17 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_altkeys.c,v 1.9 2010/11/14 00:59:26 tom Exp $
+ * $Id: demo_altkeys.c,v 1.17 2023/02/25 18:08:02 tom Exp $
  *
  * Demonstrate the define_key() function.
  * Thomas Dickey - 2005/10/22
  */
 
+#define NEED_TIME_H
 #include <test.priv.h>
 
 #if defined(NCURSES_VERSION) && NCURSES_EXT_FUNCS
 
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
 #define MY_LOGFILE "demo_altkeys.log"
 #define MY_KEYS (KEY_MAX + 1)
 
@@ -57,11 +48,12 @@
 log_last_line(WINDOW *win)
 {
     FILE *fp;
-    int y, x, n;
-    char temp[256];
 
     if ((fp = fopen(MY_LOGFILE, "a")) != 0) {
+	char temp[256];
+	int y, x, n;
 	int need = sizeof(temp) - 1;
+
 	if (need > COLS)
 	    need = COLS;
 	getyx(win, y, x);
@@ -79,19 +71,53 @@
     }
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: demo_altkeys [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     int n;
     int ch;
-#if HAVE_GETTIMEOFDAY
-    int secs, msecs;
-    struct timeval current, previous;
-#endif
+    TimeType previous;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
 
     unlink(MY_LOGFILE);
 
-    newterm(0, stdout, stdin);
+    setlocale(LC_ALL, "");
+    if (newterm(0, stdout, stdin) == 0) {
+	fprintf(stderr, "Cannot initialize terminal\n");
+	ExitProgram(EXIT_FAILURE);
+    }
     (void) cbreak();		/* take input chars one at a time, no wait for \n */
     (void) noecho();		/* don't echo input */
 
@@ -104,43 +130,31 @@
      */
     for (n = 0; n < 255; ++n) {
 	char temp[10];
-	sprintf(temp, "\033%c", n);
+	_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "\033%c", n);
 	define_key(temp, n + MY_KEYS);
     }
     for (n = KEY_MIN; n < KEY_MAX; ++n) {
 	char *value;
 	if ((value = keybound(n, 0)) != 0) {
-	    char *temp = typeMalloc(char, strlen(value) + 2);
-	    sprintf(temp, "\033%s", value);
+	    size_t need = strlen(value) + 2;
+	    char *temp = typeMalloc(char, need);
+	    _nc_SPRINTF(temp, _nc_SLIMIT(need) "\033%s", value);
 	    define_key(temp, n + MY_KEYS);
 	    free(temp);
 	    free(value);
 	}
     }
 
-#if HAVE_GETTIMEOFDAY
-    gettimeofday(&previous, 0);
-#endif
+    GetClockTime(&previous);
 
     while ((ch = getch()) != ERR) {
 	bool escaped = (ch >= MY_KEYS);
 	const char *name = keyname(escaped ? (ch - MY_KEYS) : ch);
+	TimeType current;
 
-#if HAVE_GETTIMEOFDAY
-	gettimeofday(&current, 0);
-	secs = (int) (current.tv_sec - previous.tv_sec);
-	msecs = (int) ((current.tv_usec - previous.tv_usec) / 1000);
-	if (msecs < 0) {
-	    msecs += 1000;
-	    --secs;
-	}
-	if (msecs >= 1000) {
-	    secs += msecs / 1000;
-	    msecs %= 1000;
-	}
-	printw("%6d.%03d ", secs, msecs);
+	GetClockTime(&current);
+	printw("%6.03f ", ElapsedSeconds(&previous, &current));
 	previous = current;
-#endif
 	printw("Keycode %d, name %s%s\n",
 	       ch,
 	       escaped ? "ESC-" : "",
diff --git a/test/demo_defkey.c b/test/demo_defkey.c
index 045c2c7..4416672 100644
--- a/test/demo_defkey.c
+++ b/test/demo_defkey.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018-2023,2024 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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_defkey.c,v 1.22 2013/09/28 22:02:17 tom Exp $
+ * $Id: demo_defkey.c,v 1.35 2024/01/20 20:46:12 tom Exp $
  *
  * Demonstrate the define_key() function.
  * Thomas Dickey - 2002/11/23
@@ -45,10 +46,10 @@
 log_last_line(WINDOW *win)
 {
     FILE *fp;
-    int y, x, n;
-    char temp[256];
 
     if ((fp = fopen(MY_LOGFILE, "a")) != 0) {
+	char temp[256];
+	int y, x, n;
 	int need = sizeof(temp) - 1;
 	if (need > COLS)
 	    need = COLS;
@@ -73,20 +74,20 @@
 static char *
 visichar(int ch)
 {
-    static char temp[10];
+    static char temp[20];
 
     ch = UChar(ch);
     assert(ch >= 0 && ch < 256);
     if (ch == '\\') {
-	strcpy(temp, "\\\\");
+	_nc_STRCPY(temp, "\\\\", sizeof(temp));
     } else if (ch == '\033') {
-	strcpy(temp, "\\E");
+	_nc_STRCPY(temp, "\\E", sizeof(temp));
     } else if (ch < ' ') {
-	sprintf(temp, "\\%03o", ch);
+	_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "\\%03o", ch);
     } else if (ch >= 127) {
-	sprintf(temp, "\\%03o", ch);
+	_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "\\%03o", ch);
     } else {
-	sprintf(temp, "%c", ch);
+	_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "%c", ch);
     }
     return temp;
 }
@@ -98,19 +99,21 @@
 visible(const char *string)
 {
     char *result = 0;
-    size_t need = 1;
-    int pass;
-    int n;
 
-    if (string != 0 && *string != '\0') {
+    if (VALID_STRING(string) && *string != '\0') {
+	int pass;
+	int n;
+	size_t need = 1;
+
 	for (pass = 0; pass < 2; ++pass) {
 	    for (n = 0; string[n] != '\0'; ++n) {
 		char temp[80];
-		strncpy(temp, visichar(string[n]), sizeof(temp) - 2);
-		if (pass)
-		    strcat(result, temp);
-		else
+		_nc_STRNCPY(temp, visichar(string[n]), sizeof(temp) - 2);
+		if (pass) {
+		    _nc_STRCAT(result, temp, need);
+		} else {
 		    need += strlen(temp);
+		}
 	    }
 	    if (!pass)
 		result = typeCalloc(char, need);
@@ -131,7 +134,7 @@
     char temp[80];
 
     if (code_name == 0) {
-	sprintf(temp, "Keycode %d", code);
+	_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "Keycode %d", code);
 	code_name = temp;
     }
 
@@ -145,11 +148,7 @@
     }
     log_last_line(win);
 
-    if (vis_string != 0) {
-	free(vis_string);
-	vis_string = 0;
-    }
-
+    free(vis_string);
     vis_string = visible(new_string);
     if ((rc = key_defined(new_string)) > 0) {
 	wprintw(win, "%s was bound to %s\n", vis_string, keyname(rc));
@@ -182,17 +181,18 @@
 {
     char *value = tigetstr(name);
 
-    if (value != 0) {
+    if (VALID_STRING(value)) {
 	const char *prefix = 0;
-	char temp[BUFSIZ];
 
-	if (!strncmp(value, "\033[", (size_t) 2)) {
+	if (!(strncmp) (value, "\033[", (size_t) 2)) {
 	    prefix = "\033O";
-	} else if (!strncmp(value, "\033O", (size_t) 2)) {
+	} else if (!(strncmp) (value, "\033O", (size_t) 2)) {
 	    prefix = "\033[";
 	}
 	if (prefix != 0) {
-	    sprintf(temp, "%s%s", prefix, value + 2);
+	    char temp[BUFSIZ];
+	    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+			"%s%s", prefix, value + 2);
 	    really_define_key(win, temp, code);
 	}
     }
@@ -210,16 +210,50 @@
     really_define_key(win, 0, code);
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: demo_defkey [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     char *fkeys[12];
     int n;
     int ch;
     WINDOW *win;
 
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
     unlink(MY_LOGFILE);
 
+    setlocale(LC_ALL, "");
     initscr();
     (void) cbreak();		/* take input chars one at a time, no wait for \n */
     (void) noecho();		/* don't echo input */
@@ -238,8 +272,8 @@
      * keypad() initializes the corresponding data.
      */
     for (n = 0; n < 12; ++n) {
-	char name[10];
-	sprintf(name, "kf%d", n + 1);
+	char name[20];
+	_nc_SPRINTF(name, _nc_SLIMIT(sizeof(name)) "kf%d", n + 1);
 	fkeys[n] = tigetstr(name);
     }
     for (n = 0; n < 12; ++n) {
@@ -270,7 +304,7 @@
 	    break;
     }
     endwin();
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(EXIT_SUCCESS);
 }
 #else
 int
diff --git a/test/demo_forms.c b/test/demo_forms.c
index 97125e3..62e8c64 100644
--- a/test/demo_forms.c
+++ b/test/demo_forms.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2003-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2003-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            *
@@ -26,43 +27,11 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_forms.c,v 1.50 2014/10/10 00:38:00 tom Exp $
+ * $Id: demo_forms.c,v 1.63 2023/11/11 00:29:53 tom Exp $
  *
  * Demonstrate a variety of functions from the form library.
  * Thomas Dickey - 2003/4/26
  */
-/*
-TYPE_ENUM			-
-TYPE_REGEXP			-
-dup_field			-
-field_init			-
-field_just			-
-field_term			-
-form_init			-
-form_opts			-
-form_opts_off			-
-form_opts_on			-
-form_request_by_name		-
-form_term			-
-form_userptr			-
-free_fieldtype			-
-link_field			-
-link_fieldtype			-
-move_field			-
-new_page			-
-pos_form_cursor			-
-set_field_init			-
-set_field_term			-
-set_fieldtype_arg		-
-set_fieldtype_choice		-
-set_form_fields			-
-set_form_init			-
-set_form_opts			-
-set_form_page			-
-set_form_term			-
-set_form_userptr		-
-set_max_field			-
-*/
 
 #include <test.priv.h>
 
@@ -149,8 +118,8 @@
 		    char *value = typeRealloc(char, need, prior);
 		    if (value == 0)
 			failed("realloc");
-		    strcat(value, "\n");
-		    strcat(value, buffer);
+		    _nc_STRCAT(value, "\n", need);
+		    _nc_STRCAT(value, buffer, need);
 		    my_data[more - 1].value = value;
 		} else {
 		    more = 0;
@@ -185,7 +154,7 @@
 
     if (f) {
 	set_field_buffer(f, 0, label);
-	set_field_opts(f, (int) ((unsigned) field_opts(f) & ~O_ACTIVE));
+	set_field_opts(f, (int) ((unsigned) field_opts(f) & (unsigned) ~O_ACTIVE));
     }
     return (f);
 }
@@ -227,7 +196,7 @@
 }
 
 static void
-display_form(FORM * f)
+display_form(FORM *f)
 {
     WINDOW *w;
     int rows, cols;
@@ -250,7 +219,7 @@
 }
 
 static void
-erase_form(FORM * f)
+erase_form(FORM *f)
 {
     WINDOW *w = form_win(f);
     WINDOW *s = form_sub(f);
@@ -273,7 +242,7 @@
 #define O_SELECTABLE (O_ACTIVE | O_VISIBLE)
 
 static FIELD *
-another_field(FORM * form, FIELD * field)
+another_field(FORM *form, const FIELD *const field)
 {
     FIELD **f = form_fields(form);
     FIELD *result = 0;
@@ -290,7 +259,7 @@
 }
 
 static int
-my_form_driver(FORM * form, int c)
+my_form_driver(FORM *form, int c)
 {
     static bool insert_mode = TRUE;
     FIELD *field;
@@ -337,12 +306,9 @@
 }
 
 static void
-show_current_field(WINDOW *win, FORM * form)
+show_current_field(WINDOW *win, FORM *form)
 {
     FIELD *field;
-    FIELDTYPE *type;
-    char *buffer;
-    int nbuf;
     int field_rows, field_cols, field_max;
     int currow, curcol;
 
@@ -357,7 +323,11 @@
     if (data_behind(form))
 	waddstr(win, " behind");
     waddch(win, '\n');
+
     if ((field = current_field(form)) != 0) {
+	FIELDTYPE *type;
+	int nbuf;
+
 	wprintw(win, "Page %d%s, Field %d/%d%s:",
 		form_page(form),
 		new_page(field) ? "*" : "",
@@ -413,6 +383,7 @@
 
 	waddstr(win, "\n");
 	for (nbuf = 0; nbuf <= 2; ++nbuf) {
+	    char *buffer;
 	    if ((buffer = field_buffer(field, nbuf)) != 0) {
 		wprintw(win, "buffer %d:", nbuf);
 		(void) wattrset(win, A_REVERSE);
@@ -432,14 +403,14 @@
 static void
 demo_forms(void)
 {
-    WINDOW *w;
     FORM *form;
     FIELD *f[100];		/* will memset to zero */
-    int finished = 0, c;
+    int c;
     unsigned n = 0;
     int pg;
-    WINDOW *also;
     const char *fname;
+    static const char *my_enum[] =
+    {"first", "second", "third", 0};
 
 #ifdef NCURSES_MOUSE_VERSION
     mousemask(ALL_MOUSE_EVENTS, (mmask_t *) 0);
@@ -456,7 +427,8 @@
     memset(f, 0, sizeof(f));
     for (pg = 0; pg < 4; ++pg) {
 	char label[80];
-	sprintf(label, "Sample Form Page %d", pg + 1);
+	_nc_SPRINTF(label, _nc_SLIMIT(sizeof(label))
+		    "Sample Form Page %d", pg + 1);
 	f[n++] = make_label(label, 0, 15);
 	set_new_page(f[n - 1], TRUE);
 
@@ -477,23 +449,30 @@
 	    f[n++] = make_field(fname, 3, 34, 1, 12);
 	    set_field_type(f[n - 1], TYPE_ALPHA, 1);
 	    break;
+
 	case 1:
 	    fname = "Last Name";
 	    f[n++] = make_label(fname, 2, 0);
-	    f[n++] = make_field(fname, 3, 0, 1, 18);
+	    f[n++] = make_field(fname, 3, 0, 1, 12);
 	    set_field_type(f[n - 1], TYPE_ALPHA, 1);
 
 	    fname = "First Name";
-	    f[n++] = make_label(fname, 2, 20);
-	    f[n++] = make_field(fname, 3, 20, 1, 12);
+	    f[n++] = make_label(fname, 2, 14);
+	    f[n++] = make_field(fname, 3, 14, 1, 12);
 	    set_field_type(f[n - 1], TYPE_ALPHA, 1);
 
 	    fname = "MI";
-	    f[n++] = make_label(fname, 2, 34);
-	    f[n++] = make_field(fname, 3, 34, 1, 1);
+	    f[n++] = make_label(fname, 2, 28);
+	    f[n++] = make_field(fname, 3, 28, 1, 1);
 	    set_field_pad(f[n - 1], '?');
 	    set_field_type(f[n - 1], TYPE_ALPHA, 1);
+
+	    fname = "First/Second/Third";
+	    f[n++] = make_label(fname, 2, 32);
+	    f[n++] = make_field(fname, 3, 32, 1, 12);
+	    set_field_type(f[n - 1], TYPE_ENUM, my_enum, 0, 0);
 	    break;
+
 	case 2:
 	    fname = "Host Name";
 	    f[n++] = make_label(fname, 2, 0);
@@ -506,20 +485,24 @@
 	    f[n++] = make_field(fname, 3, 26, 1, 16);
 	    set_field_type(f[n - 1], TYPE_IPV4, 1);
 #endif
-
 	    break;
 
 	case 3:
 	    fname = "Four digits";
 	    f[n++] = make_label(fname, 2, 0);
-	    f[n++] = make_field(fname, 3, 0, 1, 18);
+	    f[n++] = make_field(fname, 3, 0, 1, 10);
 	    set_field_type(f[n - 1], TYPE_INTEGER, 4, 0, 0);
 
 	    fname = "Numeric";
-	    f[n++] = make_label(fname, 2, 20);
-	    f[n++] = make_field(fname, 3, 20, 1, 12);
+	    f[n++] = make_label(fname, 2, 13);
+	    f[n++] = make_field(fname, 3, 13, 1, 12);
 	    set_field_type(f[n - 1], TYPE_NUMERIC, 3, -10000.0, 100000000.0);
 
+	    fname = "Phone number";
+	    f[n++] = make_label(fname, 2, 27);
+	    f[n++] = make_field(fname, 3, 27, 1, 16);
+	    set_field_type(f[n - 1], TYPE_REGEXP,
+			   "^([0-9]-)?[0-9]{3}-[0-9]{3}-[0-9]{4} *$");;
 	    break;
 	}
 
@@ -532,6 +515,9 @@
     f[n] = (FIELD *) 0;
 
     if ((form = new_form(f)) != 0) {
+	WINDOW *w;
+	WINDOW *also;
+	int finished = 0;
 
 	display_form(form);
 
@@ -558,8 +544,7 @@
 	free_form(form);
     }
     for (c = 0; f[c] != 0; c++) {
-	void *ptr = field_userptr(f[c]);
-	free(ptr);
+	free_edit_field(f[c]);
 	free_field(f[c]);
     }
     noraw();
@@ -571,23 +556,28 @@
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *tbl[] =
     {
 	"Usage: demo_forms [options] [data file]"
 	,""
-	," -d        make fields dynamic"
-	," -j value  justify (1=left, 2=center, 3=right)"
-	," -m value  set maximum size of dynamic fields"
-	," -o value  specify number of offscreen rows in new_field()"
-	," -t value  specify text to fill fields initially"
+	,USAGE_COMMON
+	,"Options:"
+	," -d       make fields dynamic"
+	," -j NUM   justify (1=left, 2=center, 3=right)"
+	," -m NUM   set maximum size of dynamic fields"
+	," -o NUM   specify number of offscreen rows in new_field()"
+	," -t NUM   specify text to fill fields initially"
     };
     unsigned int j;
     for (j = 0; j < SIZEOF(tbl); ++j)
 	fprintf(stderr, "%s\n", tbl[j]);
-    exit(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
@@ -596,7 +586,7 @@
 
     setlocale(LC_ALL, "");
 
-    while ((ch = getopt(argc, argv, "dj:m:o:t:")) != -1) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "dj:m:o:t:")) != -1) {
 	switch (ch) {
 	case 'd':
 	    d_option = TRUE;
@@ -605,7 +595,7 @@
 	    j_value = atoi(optarg);
 	    if (j_value < NO_JUSTIFICATION
 		|| j_value > JUSTIFY_RIGHT)
-		usage();
+		usage(FALSE);
 	    break;
 	case 'm':
 	    m_value = atoi(optarg);
@@ -616,9 +606,12 @@
 	case 't':
 	    t_value = optarg;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
-
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
     while (optind < argc) {
diff --git a/test/demo_keyok.c b/test/demo_keyok.c
index 8724d98..8f4ae90 100644
--- a/test/demo_keyok.c
+++ b/test/demo_keyok.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2003,2006 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 2002-2006,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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_keyok.c,v 1.5 2006/11/04 20:09:51 tom Exp $
+ * $Id: demo_keyok.c,v 1.9 2022/12/10 23:31:31 tom Exp $
  *
  * Demonstrate the keyok() function.
  * Thomas Dickey - 2002/11/23
@@ -35,13 +36,48 @@
 #include <test.priv.h>
 
 #if defined(NCURSES_VERSION) && NCURSES_EXT_FUNCS
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: demo_keyok [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     int lastch = ERR;
+    int prior = ERR;
     int ch;
     WINDOW *win;
 
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
+    setlocale(LC_ALL, "");
     initscr();
     (void) cbreak();		/* take input chars one at a time, no wait for \n */
     (void) noecho();		/* don't echo input */
@@ -57,6 +93,9 @@
 
     while ((ch = wgetch(win)) != ERR) {
 	const char *name = keyname(ch);
+	if (ch == ESCAPE && prior == ch)
+	    break;
+	prior = ch;
 	wprintw(win, "Keycode %d, name %s\n",
 		ch,
 		name != 0 ? name : "<null>");
diff --git a/test/demo_menus.c b/test/demo_menus.c
index ccd48b0..7b0bf30 100644
--- a/test/demo_menus.c
+++ b/test/demo_menus.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2005-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2003-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_menus.c,v 1.54 2014/09/05 08:34:06 tom Exp $
+ * $Id: demo_menus.c,v 1.80 2023/05/27 20:13:10 tom Exp $
  *
  * Demonstrate a variety of functions from the menu library.
  * Thomas Dickey - 2005/4/9
@@ -75,11 +76,8 @@
 #ifdef NCURSES_VERSION
 #ifdef TRACE
 static unsigned save_trace = TRACE_ORDINARY | TRACE_CALLS;
-extern unsigned _nc_tracing;
 static MENU *mpTrace;
 #endif
-#else
-#undef TRACE
 #endif
 
 typedef enum {
@@ -114,6 +112,18 @@
 
 static char empty[1];
 
+#ifdef TRACE
+static GCC_NORETURN void failed(const char *s);
+
+static void
+failed(const char *s)
+{
+    perror(s);
+    endwin();
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
+
 /* Common function to allow ^T to toggle trace-mode in the middle of a test
  * so that trace-files can be made smaller.
  */
@@ -130,7 +140,7 @@
 	} else {
 	    _nc_tracing = save_trace;
 	}
-	trace(_nc_tracing);
+	curses_trace(_nc_tracing);
 	if (_nc_tracing)
 	    Trace(("TOGGLE-TRACING ON"));
     }
@@ -186,9 +196,9 @@
     int result = 0;
 
     if (okMenuNo(number)) {
-	int spc_desc, spc_rows, spc_cols;
-
+	int spc_rows;
 #ifdef NCURSES_VERSION
+	int spc_desc, spc_cols;
 	menu_spacing(mpBanner, &spc_desc, &spc_rows, &spc_cols);
 #else
 	spc_rows = 0;
@@ -270,13 +280,6 @@
     if (mcols + (2 * margin + x) >= COLS)
 	mcols = COLS - (2 * margin + x);
 
-#ifdef TRACE
-    if (number == eTrace)
-	menu_opts_off(result, O_ONEVALUE);
-    else
-	menu_opts_on(result, O_ONEVALUE);
-#endif
-
     menuwin = newwin(mrows + (2 * margin), mcols + (2 * margin), y, x);
     set_menu_win(result, menuwin);
     keypad(menuwin, TRUE);
@@ -285,6 +288,16 @@
 
     set_menu_sub(result, derwin(menuwin, mrows, mcols, margin, margin));
 
+#ifdef TRACE
+    if (number == eTrace)
+	menu_opts_off(result, O_ONEVALUE);
+    else
+	menu_opts_on(result, O_ONEVALUE);
+#endif
+#if defined(NCURSES_MOUSE_VERSION) && defined(O_MOUSE_MENU)
+    menu_opts_on(result, O_MOUSE_MENU);
+#endif
+
     post_menu(result);
 
     set_menu_init(result, my_menu_init);
@@ -295,14 +308,13 @@
 }
 
 static void
-menu_destroy(MENU * m)
+menu_destroy(MENU * m, int itemsToo)
 {
-    int count;
-
     Trace(("menu_destroy %p", (void *) m));
     if (m != 0) {
 	ITEM **items = menu_items(m);
 	const char *blob = 0;
+	int count;
 
 	count = item_count(m);
 	Trace(("menu_destroy %p count %d", (void *) m, count));
@@ -319,18 +331,18 @@
 		Trace(("freeing blob %p", blob));
 		free((void *) blob);
 	    }
-	    free(items);
-	    items = 0;
 	}
-#ifdef TRACE
-	if ((count > 0) && (m == mpTrace)) {
-	    ITEM **ip = items;
-	    if (ip != 0) {
-		while (*ip)
-		    free(*ip++);
+	if (count > 0 && itemsToo) {
+	    if (itemsToo & 1) {
+		ITEM **ip = items;
+		if (ip != 0) {
+		    while (*ip)
+			free_item(*ip++);
+		}
 	    }
+	    if (itemsToo & 2)
+		free(items);
 	}
-#endif
     }
 }
 
@@ -417,7 +429,6 @@
 	    && (sb.st_mode & S_IFMT) == S_IFREG
 	    && sb.st_size != 0) {
 	    size_t size = (size_t) sb.st_size;
-	    unsigned j, k;
 	    char *blob = typeMalloc(char, size + 1);
 	    MENU_DATA *list = typeCalloc(MENU_DATA, size + 1);
 
@@ -430,6 +441,7 @@
 		if (fp != 0) {
 		    if (fread(blob, sizeof(char), size, fp) == size) {
 			bool mark = TRUE;
+			unsigned j, k;
 			for (j = k = 0; j < size; ++j) {
 			    if (mark) {
 				list[k++].name = blob + j;
@@ -541,27 +553,31 @@
 tracetrace(unsigned tlevel)
 {
     static char *buf;
+    static size_t need = 12;
     int n;
 
     if (buf == 0) {
-	size_t need = 12;
 	for (n = 0; t_tbl[n].name != 0; n++)
 	    need += strlen(t_tbl[n].name) + 2;
 	buf = typeMalloc(char, need);
+	if (!buf)
+	    failed("tracetrace");
     }
-    sprintf(buf, "0x%02x = {", tlevel);
+    _nc_SPRINTF(buf, _nc_SLIMIT(need) "0x%02x = {", tlevel);
     if (tlevel == 0) {
-	sprintf(buf + strlen(buf), "%s, ", t_tbl[0].name);
+	_nc_STRCAT(buf, t_tbl[0].name ? t_tbl[0].name : "", need);
+	_nc_STRCAT(buf, ", ", need);
     } else {
 	for (n = 1; t_tbl[n].name != 0; n++)
 	    if ((tlevel & t_tbl[n].mask) == t_tbl[n].mask) {
-		strcat(buf, t_tbl[n].name);
-		strcat(buf, ", ");
+		_nc_STRCAT(buf, t_tbl[n].name, need);
+		_nc_STRCAT(buf, ", ", need);
 	    }
     }
     if (buf[strlen(buf) - 2] == ',')
 	buf[strlen(buf) - 2] = '\0';
-    return (strcat(buf, "}"));
+    _nc_STRCAT(buf, "}", need);
+    return buf;
 }
 
 /* fake a dynamically reconfigurable menu using the 0th entry to deselect
@@ -571,13 +587,14 @@
 update_trace_menu(MENU * m)
 {
     ITEM **items;
-    ITEM *i, **p;
+    ITEM *i;
     bool changed = FALSE;
 
     items = menu_items(m);
     i = current_item(m);
     if (i == items[0]) {
 	if (item_value(i)) {
+	    ITEM **p;
 	    for (p = items + 1; *p != 0; p++)
 		if (item_value(*p)) {
 		    set_item_value(*p, FALSE);
@@ -593,7 +610,6 @@
 /* interactively set the trace level */
 {
     ITEM **ip;
-    unsigned newtrace;
     int result;
 
     for (ip = menu_items(mpTrace); *ip; ip++) {
@@ -609,14 +625,14 @@
 
     if (result == E_OK) {
 	if (update_trace_menu(mpTrace) || cmd == REQ_TOGGLE_ITEM) {
-	    newtrace = 0;
+	    unsigned newtrace = 0;
 	    for (ip = menu_items(mpTrace); *ip; ip++) {
 		if (item_value(*ip)) {
 		    MENU_DATA *td = (MENU_DATA *) item_userptr(*ip);
 		    newtrace |= td->mask;
 		}
 	    }
-	    trace(newtrace);
+	    curses_trace(newtrace);
 	    Trace(("trace level interactively set to %s", tracetrace(_nc_tracing)));
 
 	    MvWPrintw(status, 1, 0,
@@ -751,6 +767,36 @@
     }
 }
 
+#if defined(KEY_RESIZE) && NCURSES_EXT_FUNCS
+static void
+resize_menu(MENU ** menu)
+{
+#if 0
+    WINDOW *win = menu_win(*menu);
+    WINDOW *sub = menu_sub(*menu);
+#endif
+    (void) menu;
+}
+
+static void
+resize_menus(MENU * current)
+{
+    (void) current;
+
+    werase(status);
+    wnoutrefresh(status);
+    wresize(status, 1, COLS);
+    mvwin(status, LINES - 1, 0);
+
+    resize_menu(&mpBanner);
+    resize_menu(&mpFile);
+    resize_menu(&mpSelect);
+#ifdef TRACE
+    resize_menu(&mpTrace);
+#endif
+}
+#endif /* defined(KEY_RESIZE) && NCURSES_EXT_FUNCS */
+
 static void
 show_status(int ch, MENU * menu)
 {
@@ -774,7 +820,7 @@
     int ch = ERR;
 
 #ifdef NCURSES_MOUSE_VERSION
-    mousemask(ALL_MOUSE_EVENTS, (mmask_t *) 0);
+    mousemask(BUTTON1_CLICKED, (mmask_t *) 0);
 #endif
 
     menu_display(last_menu);
@@ -803,6 +849,11 @@
 	case KEY_SRIGHT:
 	    move_menus(last_menu, 0, 1);
 	    continue;
+#if defined(KEY_RESIZE) && NCURSES_EXT_FUNCS
+	case KEY_RESIZE:
+	    resize_menus(last_menu);
+	    continue;
+#endif
 	}
 	cmd = menu_virtualize(ch);
 
@@ -836,9 +887,17 @@
 #endif
 	    }
 
+#if defined(NCURSES_MOUSE_VERSION) && defined(O_MOUSE_MENU)
 	    if ((code == E_REQUEST_DENIED) && (cmd == KEY_MOUSE)) {
+		(void) menu_getc(mpBanner);
 		code = menu_driver(mpBanner, cmd);
+		if (code == E_REQUEST_DENIED) {
+		    MEVENT event;
+		    if (menu_getc(mpBanner) == KEY_MOUSE)
+			getmouse(&event);	/* give up */
+		}
 	    }
+#endif
 
 	    break;
 	}
@@ -866,23 +925,18 @@
 	}
 	if (code == E_REQUEST_DENIED)
 	    beep();
-	continue;
     }
-
-#ifdef NCURSES_MOUSE_VERSION
-    mousemask(0, (mmask_t *) 0);
-#endif
 }
 
 static void
 destroy_menus(void)
 {
-    menu_destroy(mpFile);
-    menu_destroy(mpSelect);
+    menu_destroy(mpFile, 1);
+    menu_destroy(mpSelect, 3);
 #ifdef TRACE
-    menu_destroy(mpTrace);
+    menu_destroy(mpTrace, 1);
 #endif
-    menu_destroy(mpBanner);
+    menu_destroy(mpBanner, 1);
 }
 
 #if HAVE_RIPOFFLINE
@@ -922,51 +976,60 @@
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *const tbl[] =
     {
 	"Usage: demo_menus [options] [menu-file]"
 	,""
+	,USAGE_COMMON
 	,"Options:"
 #if HAVE_RIPOFFLINE
-	,"  -f       rip-off footer line (can repeat)"
-	,"  -h       rip-off header line (can repeat)"
+	," -F       rip-off footer line (can repeat)"
+	," -H       rip-off header line (can repeat)"
 #endif
 #ifdef TRACE
-	,"  -t mask  specify default trace-level (may toggle with ^T)"
+	," -t mask  specify default trace-level (may toggle with ^T)"
 #endif
     };
     size_t n;
     for (n = 0; n < SIZEOF(tbl); n++)
 	fprintf(stderr, "%s\n", tbl[n]);
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
 {
-    int c;
+    int ch;
 
     setlocale(LC_ALL, "");
+    START_TRACE();
 
-    while ((c = getopt(argc, argv, "a:de:fhmp:s:t:")) != -1) {
-	switch (c) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "FHt:")) != -1) {
+	switch (ch) {
 #if HAVE_RIPOFFLINE
-	case 'f':
+	case 'F':
 	    ripoffline(-1, rip_footer);
 	    break;
-	case 'h':
+	case 'H':
 	    ripoffline(1, rip_header);
 	    break;
 #endif /* HAVE_RIPOFFLINE */
 #ifdef TRACE
 	case 't':
-	    trace((unsigned) strtoul(optarg, 0, 0));
+	    curses_trace((unsigned) strtoul(optarg, 0, 0));
 	    break;
 #endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
 
diff --git a/test/demo_new_pair.c b/test/demo_new_pair.c
new file mode 100644
index 0000000..bc41d44
--- /dev/null
+++ b/test/demo_new_pair.c
@@ -0,0 +1,401 @@
+/****************************************************************************
+ * Copyright 2018-2021,2022 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.                                                           *
+ ****************************************************************************/
+/*
+ * $Id: demo_new_pair.c,v 1.27 2022/12/04 00:40:11 tom Exp $
+ *
+ * Demonstrate the alloc_pair() function.
+ */
+
+#include <test.priv.h>
+#include <time.h>
+#include <popup_msg.h>
+
+#if HAVE_ALLOC_PAIR && USE_WIDEC_SUPPORT
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#define MAX_BITS 8		/* all but A_ALTCHARSET */
+#define MAX_ATTR ((1<<MAX_BITS)-1)
+
+static bool
+valid_cap(NCURSES_CONST char *name)
+{
+    char *value = tigetstr(name);
+    return (value != 0 && value != (char *) -1) ? TRUE : FALSE;
+}
+
+static attr_t
+next_attr(int now)
+{
+    static bool init = FALSE;
+    static attr_t table[MAX_BITS * MAX_BITS];
+    static int limit = 0;
+
+    if (!init) {
+	int j, k;
+	attr_t bits[MAX_BITS];
+
+	init = TRUE;
+	bits[limit++] = WA_NORMAL;
+	if (valid_cap("smso"))
+	    bits[limit++] = WA_STANDOUT;
+	if (valid_cap("smul"))
+	    bits[limit++] = WA_UNDERLINE;
+	if (valid_cap("rev"))
+	    bits[limit++] = WA_REVERSE;
+	if (valid_cap("blink"))
+	    bits[limit++] = WA_BLINK;
+	if (valid_cap("dim"))
+	    bits[limit++] = WA_DIM;
+	if (valid_cap("bold"))
+	    bits[limit++] = WA_BOLD;
+	for (j = 0; j < limit; ++j) {
+	    for (k = 0; k < limit; ++k) {
+		table[j * limit + k] = bits[j] | bits[k];
+	    }
+	}
+    }
+    return table[now % limit];
+}
+
+static void
+our_content(int pair, int *fg, int *bg)
+{
+    pair %= COLOR_PAIRS;
+    *fg = (pair / COLORS) % COLORS;
+    *bg = (pair % COLORS);
+}
+
+static int
+make_color(int now)
+{
+    int fg, bg;
+    our_content(now, &fg, &bg);
+    return alloc_pair(fg, bg);
+}
+
+static int
+next_color(int now)
+{
+    int result = 0;
+    if ((short) now > 0) {
+	if (now < COLOR_PAIRS) {
+	    int fg, bg;
+	    our_content(now, &fg, &bg);
+	    if (init_pair((short) now, (short) fg, (short) bg) != OK)
+		now = ERR;
+	} else {
+	    now %= COLOR_PAIRS;
+	}
+	result = now;
+    }
+    return result;
+}
+
+static time_t
+now(void)
+{
+    return time((time_t *) 0);
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: demo_new_pair [options]"
+	,""
+	,"Repeatedly print using all possible color combinations."
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -g       use getcchar to check setcchar"
+	," -i       use init_pair rather than alloc_pair"
+	," -p       start in paged-mode"
+	," -s       start in single-step mode"
+	," -w       print a wide-character cell"
+    };
+    unsigned n;
+    for (n = 0; n < SIZEOF(msg); ++n) {
+	fprintf(stderr, "%s\n", msg[n]);
+    }
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+
+#define use_pages() \
+	paged_mode = TRUE, single_mode = TRUE
+
+#define use_single() \
+	paged_mode = FALSE, single_mode = TRUE
+
+#define update_modes() \
+	    scrollok(stdscr, !paged_mode); \
+	    nodelay(stdscr, !single_mode || paged_mode)
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    static const char *help[] =
+    {
+	"This program iterates over the possible color combinations,",
+	"allocating or initializing color pairs.  For best results,",
+	"choose screen-width dividing evenly into the number of colors,",
+	"e.g.,",
+	"",
+	"  32x64,32x128  256 colors",
+	"  24x44,24x88   88 colors",
+	"  32x64,24x128  16 colors",
+	"",
+	"Keys:",
+	"  c      toggle between coloring and de-coloring cells",
+	"  p      show one page at a time",
+	"  s      show one character at a time",
+	" <space> display char/page without pausing",
+	"  v/V    cycle through video attributes",
+	"  w      toggle between \"#\" and a double-width equivalent",
+	"  ?      print this screen (exit on any character).",
+	"",
+	"To exit this program, press ^Q, ^[ or \"q\".",
+	0
+    };
+
+    bool done = FALSE;
+    bool check_set = FALSE;
+    bool clobber = FALSE;
+    bool hascolor = FALSE;
+    bool use_init = FALSE;
+    bool use_wide = FALSE;
+    bool paged_mode = FALSE;
+    bool single_mode = FALSE;
+    int video_mode = 0;
+    int current;
+    int ch;
+    wchar_t wch[2];
+    time_t start = now();
+    long total_cells = 0;
+    FILE *output = 0;
+
+    setlocale(LC_ALL, "");
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "gipsw")) != -1) {
+	switch (ch) {
+	case 'g':
+	    check_set = TRUE;
+	    break;
+	case 'i':
+	    use_init = TRUE;
+	    break;
+	case 'p':
+	    use_pages();
+	    break;
+	case 's':
+	    use_single();
+	    break;
+	case 'w':
+	    use_wide = TRUE;
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+
+    if (isatty(fileno(stderr))) {
+	output = stderr;
+    } else if ((ch = open("/dev/tty", O_WRONLY)) >= 0) {
+	output = fdopen(ch, "w");
+    } else {
+	fprintf(stderr, "cannot open terminal for output\n");
+	ExitProgram(EXIT_FAILURE);
+    }
+    if (newterm(NULL, output, stdin) == 0) {
+	fprintf(stderr, "Cannot initialize terminal\n");
+	fclose(output);
+	ExitProgram(EXIT_FAILURE);
+    }
+    (void) cbreak();		/* read chars without wait for \n */
+    (void) noecho();		/* don't echo input */
+    update_modes();
+    curs_set(0);
+
+    keypad(stdscr, TRUE);
+
+    if ((hascolor = has_colors())) {
+	start_color();
+	current = 1;
+    } else {
+	current = 0;
+    }
+
+    /*
+     * Repeatedly cycle through all colors, initializing pairs as needed.
+     * Provide for single-stepping, or page-at-a-time, as well as quitting.
+     */
+    while (!done) {
+	cchar_t temp;
+	attr_t my_attrs;
+	int my_pair;
+
+	switch (getch()) {
+	case HELP_KEY_1:
+	    popup_msg(stdscr, help);
+	    break;
+	case 'p':
+	    /* step-by-page */
+	    use_pages();
+	    update_modes();
+	    break;
+	case 's':
+	    /* step-by-char */
+	    use_single();
+	    update_modes();
+	    break;
+	case ' ':
+	    single_mode = FALSE;
+	    update_modes();
+	    break;
+	case QUIT:
+	case ESCAPE:
+	case 'q':
+	    done = TRUE;
+	    continue;
+	case 'c':
+	    clobber = !clobber;
+	    continue;
+	case 'v':
+	    if (--video_mode < 0)
+		video_mode = MAX_ATTR;
+	    continue;
+	case 'V':
+	    if (video_mode > MAX_ATTR)
+		video_mode = 0;
+	    continue;
+	case 'w':
+	    use_wide = !use_wide;
+	    continue;
+	case ERR:
+	    break;
+	default:
+	    beep();
+	    break;
+	}
+	if (hascolor) {
+	    my_attrs = next_attr(video_mode);
+	    if (clobber) {
+		int fg, bg;
+		our_content(current, &fg, &bg);
+		my_pair = find_pair(fg, bg);
+		if (my_pair > 0) {
+		    free_pair(my_pair);
+		}
+		my_pair = 0;
+	    } else {
+		my_pair = (use_init
+			   ? next_color(current)
+			   : make_color(current));
+	    }
+	} else {
+	    my_attrs = next_attr(current);
+	    my_pair = 0;
+	}
+	if (my_pair < 0)
+	    break;
+	wch[0] = use_wide ? 0xff03 : '#';
+	wch[1] = 0;
+	setcchar(&temp, wch, my_attrs,
+		 (short) my_pair,
+		 (use_init ? NULL : (void *) &my_pair));
+
+	if (check_set) {
+	    int problem = 0;
+	    wchar_t chk_wch[2];
+	    attr_t chk_attrs = 0;
+	    short chk_pair = 0;
+	    int chk_pair2 = 0;
+
+#define AllButColor(a) ((a) & (A_ATTRIBUTES & ~A_COLOR))
+
+	    if (getcchar(&temp, NULL, &chk_attrs, &chk_pair,
+			 (use_init ? NULL : (void *) &chk_pair2)) != 2) {
+		problem = 1;
+	    } else if (getcchar(&temp, chk_wch, &chk_attrs, &chk_pair,
+				(use_init ? NULL : (void *) &chk_pair2)) != OK) {
+		problem = 2;
+	    } else if (chk_wch[0] != wch[0]) {
+		problem = 3;
+	    } else if (AllButColor(my_attrs) != AllButColor(chk_attrs)) {
+		problem = 4;
+	    } else if (my_pair != chk_pair) {
+		problem = 4;
+	    } else if (!use_init && (my_pair != chk_pair2)) {
+		problem = 5;
+	    }
+	    if (problem) {
+		wch[0] = (wchar_t) (problem + '0');
+		setcchar(&temp, wch, my_attrs,
+			 (short) my_pair,
+			 (use_init ? NULL : (void *) &my_pair));
+	    }
+	}
+
+	/*
+	 * At the end of a page, move the cursor to the home position.
+	 */
+	if ((add_wch(&temp) == ERR) && paged_mode) {
+	    nodelay(stdscr, !single_mode);
+	    move(0, 0);
+	}
+	total_cells += 1 + (use_wide ? 1 : 0);
+	++current;
+    }
+    stop_curses();
+    fclose(output);
+
+    printf("%.1f cells/second\n",
+	   (double) (total_cells) / (double) (now() - start));
+
+    ExitProgram(EXIT_SUCCESS);
+}
+
+#else
+int
+main(void)
+{
+    printf("This program requires the ncurses alloc_pair function\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
diff --git a/test/demo_panels.c b/test/demo_panels.c
index 041b5bb..6c82589 100644
--- a/test/demo_panels.c
+++ b/test/demo_panels.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007-2010,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2020,2022 Thomas E. Dickey                                *
+ * Copyright 2003-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_panels.c,v 1.38 2014/08/02 17:24:07 tom Exp $
+ * $Id: demo_panels.c,v 1.48 2022/12/04 00:40:11 tom Exp $
  *
  * Demonstrate a variety of functions from the panel library.
  */
@@ -204,7 +205,7 @@
 {
     WINDOW *win;
     PANEL *pan = 0;
-    char *userdata = typeMalloc(char, 3);
+    char *userdata = typeMalloc(char, 6);
 
     if ((win = newwin(rows, cols, tly, tlx)) != 0) {
 	keypad(win, TRUE);
@@ -222,13 +223,13 @@
 	    wbkgdset(win, A_BOLD | ' ');
 	}
     }
-    sprintf(userdata, "p%d", color % 8);
+    _nc_SPRINTF(userdata, _nc_SLIMIT(4) "p%d", color % 8);
     set_panel_userptr(pan, (NCURSES_CONST void *) userdata);
     return pan;
 }
 
 static void
-my_remove_panel(PANEL ** pans, int which)
+my_remove_panel(PANEL **pans, int which)
 {
     if (pans[which] != 0) {
 	PANEL *pan = pans[which];
@@ -248,9 +249,8 @@
 #define ABS(a)   ((a) < 0 ? -(a) : (a))
 
 static void
-my_create_panel(PANEL ** pans, int which, FillPanel myFill)
+my_create_panel(PANEL **pans, int which, FillPanel myFill)
 {
-    PANEL *pan = 0;
     int code;
     short pair = (short) which;
     short fg = (short) ((pair == COLOR_BLUE) ? COLOR_WHITE : COLOR_BLACK);
@@ -271,7 +271,7 @@
 
     if (code > 0) {
 	char also[80];
-	sprintf(also, " (first %d,%d)", y0, x0);
+	_nc_SPRINTF(also, _nc_SLIMIT(sizeof(also)) " (first %d,%d)", y0, x0);
 	/* get the position of the opposite corner */
 	while ((code = get_position("Opposite corner",
 				    also, which, &x1, &y1)) == 0) {
@@ -281,7 +281,10 @@
 	if (code > 0) {
 	    int tly = MIN(y0, y1);
 	    int tlx = MIN(x0, x1);
-	    pan = mkpanel(pair, ABS(y1 - y0) + 1, ABS(x1 - x0) + 1, tly, tlx);
+	    PANEL *pan = mkpanel(pair,
+				 ABS(y1 - y0) + 1,
+				 ABS(x1 - x0) + 1,
+				 tly, tlx);
 	    /* finish */
 	    myFill(pan);
 	    pans[which] = pan;
@@ -292,7 +295,7 @@
 }
 
 static void
-my_move_panel(PANEL ** pans, int which, bool continuous)
+my_move_panel(PANEL **pans, int which, bool continuous)
 {
     if (pans[which] != 0) {
 	int code;
@@ -302,7 +305,7 @@
 	char also[80];
 
 	getbegyx(win, y0, x0);
-	sprintf(also, " (start %d,%d)", y0, x0);
+	_nc_SPRINTF(also, _nc_SLIMIT(sizeof(also)) " (start %d,%d)", y0, x0);
 	wmove(stdscr, y0, x0);
 	while ((code = get_position("Move panel", also, which, &x1, &y1)) == 0) {
 	    if (continuous) {
@@ -317,7 +320,7 @@
 }
 
 static void
-my_resize_panel(PANEL ** pans, int which, FillPanel myFill)
+my_resize_panel(PANEL **pans, int which, FillPanel myFill)
 {
     if (pans[which] != 0) {
 	int code;
@@ -327,7 +330,7 @@
 	char also[80];
 
 	getbegyx(win, y0, x0);
-	sprintf(also, " (start %d,%d)", y0, x0);
+	_nc_SPRINTF(also, _nc_SLIMIT(sizeof(also)) " (start %d,%d)", y0, x0);
 	wmove(stdscr, y0, x0);
 	while ((code = get_position("Resize panel",
 				    also, which, &x1, &y1)) == 0) {
@@ -365,7 +368,7 @@
 }
 
 static void
-fill_panel(PANEL * pan)
+fill_panel(PANEL *pan)
 {
     WINDOW *win = panel_window(pan);
     const char *userptr = (const char *) panel_userptr(pan);
@@ -385,7 +388,7 @@
 }
 
 static void
-fill_unboxed(PANEL * pan)
+fill_unboxed(PANEL *pan)
 {
     WINDOW *win = panel_window(pan);
     const char *userptr = (const char *) panel_userptr(pan);
@@ -428,7 +431,7 @@
 }
 
 static void
-fill_wide_panel(PANEL * pan)
+fill_wide_panel(PANEL *pan)
 {
     WINDOW *win = panel_window(pan);
     int num = ((const char *) panel_userptr(pan))[1];
@@ -450,7 +453,7 @@
 #define MAX_PANELS 5
 
 static int
-which_panel(PANEL * px[MAX_PANELS + 1], PANEL * pan)
+which_panel(PANEL *px[MAX_PANELS + 1], PANEL *pan)
 {
     int result = 0;
     int j;
@@ -465,7 +468,7 @@
 }
 
 static void
-show_panels(PANEL * px[MAX_PANELS + 1])
+show_help(WINDOW *win)
 {
     static const char *help[] =
     {
@@ -479,9 +482,19 @@
 	"  m - move the panel (M for continuous move)",
 	"  r - resize the panel",
 	"  s - show the panel",
-	"  b - put the panel on the top of the stack"
+	"  t - put the panel on the top of the stack"
     };
+    int j;
 
+    for (j = 0; j < (int) SIZEOF(help); ++j) {
+	if (wprintw(win, "%s\n", help[j]) == ERR)
+	    break;
+    }
+}
+
+static void
+show_panels(PANEL *px[MAX_PANELS + 1])
+{
     struct {
 	bool valid;
 	bool hidden;
@@ -490,7 +503,6 @@
     } table[MAX_PANELS + 1];
 
     WINDOW *win;
-    PANEL *pan;
     int j;
 
     memset(table, 0, sizeof(table));
@@ -504,6 +516,8 @@
     }
 
     if ((win = newwin(LINES - 1, COLS, 0, 0)) != 0) {
+	PANEL *pan;
+
 	keypad(win, TRUE);
 	if ((pan = new_panel(win)) != 0) {
 	    werase(win);
@@ -527,10 +541,7 @@
 		    waddch(win, '\n');
 		}
 	    }
-	    for (j = 0; j < (int) SIZEOF(help); ++j) {
-		if (wprintw(win, "%s\n", help[j]) == ERR)
-		    break;
-	    }
+	    show_help(win);
 	    wgetch(win);
 	    del_panel(pan);
 	    pflush();
@@ -556,7 +567,7 @@
 /* *INDENT-ON* */
 
 static void
-do_panel(PANEL * px[MAX_PANELS + 1],
+do_panel(PANEL *px[MAX_PANELS + 1],
 	 NCURSES_CONST char *cmd,
 	 FillPanel myFill)
 {
@@ -622,11 +633,10 @@
  * End the command with a newline.  Reject other characters.
  */
 static bool
-get_command(PANEL * px[MAX_PANELS + 1], char *buffer, int limit)
+get_command(PANEL *px[MAX_PANELS + 1], char *buffer, int limit)
 {
     int length = 0;
     int y0, x0;
-    int c0, ch;
     WINDOW *win;
 
     getyx(stdscr, y0, x0);
@@ -645,9 +655,9 @@
 	}
 	(void) wgetch(win);
     } else {
-	c0 = 0;
+	int c0 = 0;
 	for (;;) {
-	    ch = wgetch(win);
+	    int ch = wgetch(win);
 	    if (ch == ERR || ch == QUIT || ch == ESCAPE) {
 		buffer[0] = '\0';
 		break;
@@ -655,7 +665,7 @@
 		wrefresh(curscr);
 	    } else if (ch == '\n' || ch == KEY_ENTER) {
 		break;
-	    } else if (ch == '?') {
+	    } else if (ch == HELP_KEY_1) {
 		show_panels(px);
 	    } else if (length + 3 < limit) {
 		if (ch >= KEY_MIN) {
@@ -731,39 +741,43 @@
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *const tbl[] =
     {
 	"Usage: demo_panels [options]"
 	,""
+	,USAGE_COMMON
 	,"Options:"
-	,"  -i file  read commands from file"
-	,"  -o file  record commands in file"
-	,"  -m       do not use colors"
+	," -i file  read commands from file"
+	," -o file  record commands in file"
+	," -m       do not use colors"
 #if USE_WIDEC_SUPPORT
-	,"  -w       use wide-characters in panels and background"
+	," -w       use wide-characters in panels and background"
 #endif
-	,"  -x       do not enclose panels in boxes"
+	," -x       do not enclose panels in boxes"
     };
     size_t n;
     for (n = 0; n < SIZEOF(tbl); n++)
 	fprintf(stderr, "%s\n", tbl[n]);
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
 {
-    int c;
+    int ch;
     bool monochrome = FALSE;
     InitPanel myInit = init_panel;
     FillPanel myFill = fill_panel;
 
     setlocale(LC_ALL, "");
 
-    while ((c = getopt(argc, argv, "i:o:mwx")) != -1) {
-	switch (c) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "i:o:mwx")) != -1) {
+	switch (ch) {
 	case 'i':
 	    log_in = fopen(optarg, "r");
 	    break;
@@ -782,8 +796,12 @@
 	case 'x':
 	    unboxed = TRUE;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
     if (unboxed)
diff --git a/test/demo_tabs.c b/test/demo_tabs.c
new file mode 100644
index 0000000..16c1ad5
--- /dev/null
+++ b/test/demo_tabs.c
@@ -0,0 +1,127 @@
+/****************************************************************************
+ * Copyright 2019-2020,2022 Thomas E. Dickey                                *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/*
+ * Author: Thomas E. Dickey
+ *
+ * $Id: demo_tabs.c,v 1.10 2022/12/04 00:40:11 tom Exp $
+ *
+ * A simple demo of tabs in curses.
+ */
+#define USE_CURSES
+#define USE_TINFO
+#include <test.priv.h>
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: demo_tabs [options]"
+	,""
+	,"Print a grid to test tab-stops with the curses interface"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -l COUNT total number of lines to show"
+	," -t NUM   set TABSIZE variable to the given value"
+    };
+    unsigned n;
+    for (n = 0; n < SIZEOF(msg); ++n) {
+	fprintf(stderr, "%s\n", msg[n]);
+    }
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int tabstop;
+    int ch, col, row, step;
+    int line_limit = -1;
+    int curses_stops = -1;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "l:t:")) != -1) {
+	switch (ch) {
+	case 'l':
+	    line_limit = atoi(optarg);
+	    break;
+	case 't':
+	    curses_stops = atoi(optarg);
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+
+    initscr();
+    noecho();
+    cbreak();
+    if (curses_stops > 0)
+	set_tabsize(curses_stops);
+#if HAVE_TIGETNUM
+    tabstop = tigetnum("it");
+    if (tabstop <= 0)
+#endif
+	tabstop = 8;
+    for (row = 0; row < LINES; ++row) {
+	move(row, 0);
+	for (col = step = 0; col < COLS - 1; ++col) {
+	    if (row == 0) {
+		chtype ct = '-';
+		if ((col % tabstop) == 0)
+		    ct = '+';
+		addch(ct);
+	    } else if (col + 1 < row) {
+		addch('*');
+	    } else {
+		printw("%x", step);
+		col = (row + (tabstop * ++step));
+		col /= tabstop;
+		col *= tabstop;
+		col -= 1;
+		if ((col + tabstop) < COLS)
+		    addch('\t');
+		refresh();
+	    }
+	}
+	addch('\n');
+	if (line_limit > 0 && row >= line_limit)
+	    break;
+    }
+    getch();
+    endwin();
+    ExitProgram(EXIT_SUCCESS);
+}
diff --git a/test/demo_termcap.c b/test/demo_termcap.c
index 65c2d13..6e2aba7 100644
--- a/test/demo_termcap.c
+++ b/test/demo_termcap.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2005-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2005-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: Thomas E. Dickey
  *
- * $Id: demo_termcap.c,v 1.48 2015/08/08 20:25:39 tom Exp $
+ * $Id: demo_termcap.c,v 1.65 2023/05/27 20:13:10 tom Exp $
  *
  * A simple demo of the termcap interface.
  */
@@ -46,9 +47,15 @@
 #endif
 #endif
 
-#ifdef NCURSES_VERSION
+#if defined(NCURSES_VERSION)
+#if HAVE_NCURSES_TERMCAP_H
+#include <ncurses/termcap.h>
+#elif HAVE_TERMCAP_H
 #include <termcap.h>
 #endif
+#endif
+
+static GCC_NORETURN void failed(const char *);
 
 static void
 failed(const char *msg)
@@ -72,8 +79,10 @@
 static bool n_opt = FALSE;
 static bool s_opt = FALSE;
 static bool q_opt = FALSE;
+#ifdef NCURSES_VERSION
 static bool x_opt = FALSE;
 static bool y_opt = FALSE;
+#endif
 
 static char *d_opt;
 static char *e_opt;
@@ -96,10 +105,11 @@
 #define EachCapName(n) n = 33; n < 127; ++n
 
 static char *
-make_dbitem(char *p, char *q)
+make_dbitem(const char *const p, const char *const q)
 {
-    char *result = malloc(strlen(e_opt) + 2 + (size_t) (p - q));
-    sprintf(result, "%s=%.*s", e_opt, (int) (p - q), q);
+    size_t need = strlen(e_opt) + 2 + (size_t) (p - q);
+    char *result = malloc(need);
+    _nc_SPRINTF(result, _nc_SLIMIT(need) "%s=%.*s", e_opt, (int) (p - q), q);
     return result;
 }
 
@@ -150,10 +160,12 @@
 	    db_item++;
 	}
     }
-    printf("** %s\n", result);
+    if (result != 0)
+	printf("** %s\n", result);
     return result;
 }
 
+#if NO_LEAKS
 static void
 free_dblist(void)
 {
@@ -165,6 +177,7 @@
 	db_list = 0;
     }
 }
+#endif /* NO_LEAKS */
 
 static void
 show_string(const char *name, const char *value)
@@ -316,8 +329,6 @@
 static void
 demo_termcap(NCURSES_CONST char *name)
 {
-    unsigned n;
-    NCURSES_CONST char *cap;
     char buffer[1024];
 
     if (db_list) {
@@ -326,6 +337,8 @@
     if (!q_opt)
 	printf("Terminal type \"%s\"\n", name);
     if (tgetent(buffer, name) >= 0) {
+	NCURSES_CONST char *cap;
+	unsigned n;
 
 	if (b_opt) {
 	    for (n = 0;; ++n) {
@@ -356,7 +369,7 @@
 #ifdef NCURSES_VERSION
 	if (x_opt && (my_blob == 0) && y_opt) {
 #if NCURSES_XNAMES
-	    TERMTYPE *term = &(cur_term->type);
+	    TERMTYPE *term = (TERMTYPE *) cur_term;
 	    if (term != 0
 		&& ((NUM_BOOLEANS(term) != BOOLCOUNT)
 		    || (NUM_NUMBERS(term) != NUMCOUNT)
@@ -391,7 +404,8 @@
 static void
 parse_description(const char *input_name)
 {
-    static char empty[1];
+    static char empty[1] =
+    {0};
 
     FILE *fp;
     struct stat sb;
@@ -424,11 +438,13 @@
 	failed("cannot allocate memory for input-file");
     }
 
-    if ((fp = fopen(input_name, "r")) == 0)
+    if ((fp = fopen(input_name, "r")) == 0) {
 	failed("cannot open input-file");
-    len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp);
-    my_blob[sb.st_size] = '\0';
-    fclose(fp);
+    } else {
+	len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp);
+	my_blob[sb.st_size] = '\0';
+	fclose(fp);
+    }
 
     /*
      * First, get rid of comments and escaped newlines, as well as repeated
@@ -687,7 +703,6 @@
     size_t count;
     size_t length = 1;
     char **result = 0;
-    char *blob = 0;
     char *unused = 0;
 
     for (pass = 0; pass < 2; ++pass) {
@@ -697,12 +712,12 @@
 		length += chunk;
 	    } else {
 		result[count] = unused;
-		strcpy(unused, list[count]);
+		_nc_STRCPY(unused, list[count], length);
 		unused += chunk;
 	    }
 	}
 	if (pass == 0) {
-	    blob = malloc(length);
+	    char *blob = malloc(length);
 	    result = typeCalloc(char *, count + 1);
 	    unused = blob;
 	    if (blob == 0 || result == 0)
@@ -712,54 +727,72 @@
 
     return result;
 }
-#endif
+
+#if NO_LEAKS
+static void
+free_code_list(char **list)
+{
+    if (list) {
+	free(list[0]);
+	free(list);
+    }
+}
+#endif /* NO_LEAKS */
+#endif /* USE_CODE_LISTS */
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *msg[] =
     {
-	"Usage: demo_termcap [options] [terminal]",
-	"",
-	"If no options are given, print all (boolean, numeric, string)",
-	"capabilities for the given terminal, using short names.",
-	"",
-	"Options:",
-	" -a       try all names, print capabilities found",
-	" -b       print boolean-capabilities",
-	" -d LIST  colon-separated list of databases to use",
-	" -e NAME  environment variable to set with -d option",
-	" -i NAME  terminal description to use as names for \"-a\" option, etc.",
-	" -n       print numeric-capabilities",
-	" -q       quiet (prints only counts)",
-	" -r COUNT repeat for given count",
-	" -s       print string-capabilities",
-	" -v       print termcap-variables",
+	"Usage: demo_termcap [options] [terminal]"
+	,""
+	,"If no options are given, print all (boolean, numeric, string)"
+	,"capabilities for the given terminal, using short names."
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -a       try all names, print capabilities found"
+	," -b       print boolean-capabilities"
+	," -d LIST  colon-separated list of databases to use"
+	," -e NAME  environment variable to set with -d option"
+	," -i NAME  terminal description to use as names for \"-a\" option, etc."
+	," -n       print numeric-capabilities"
+	," -q       quiet (prints only counts)"
+	," -r COUNT repeat for given count"
+	," -s       print string-capabilities"
+	," -v       print termcap-variables"
 #ifdef NCURSES_VERSION
-	" -x       print extended capabilities",
+	," -x       print extended capabilities"
 #endif
     };
     unsigned n;
     for (n = 0; n < SIZEOF(msg); ++n) {
 	fprintf(stderr, "%s\n", msg[n]);
     }
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
 {
+    int ch;
     int n;
     char *name;
     bool a_opt = FALSE;
+#if defined(NCURSES_VERSION) || defined(HAVE_CURSES_DATA_OSPEED)
     bool v_opt = FALSE;
+#endif
     char *input_name = 0;
 
     int repeat;
     int r_opt = 1;
 
-    while ((n = getopt(argc, argv, "abd:e:i:nqr:svxy")) != -1) {
-	switch (n) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "abd:e:i:nqr:svxy")) != -1) {
+	switch (ch) {
 	case 'a':
 	    a_opt = TRUE;
 	    break;
@@ -783,14 +816,17 @@
 	    break;
 	case 'r':
 	    if ((r_opt = atoi(optarg)) <= 0)
-		usage();
+		usage(FALSE);
 	    break;
 	case 's':
 	    s_opt = TRUE;
 	    break;
+#if defined(NCURSES_VERSION) || defined(HAVE_CURSES_DATA_OSPEED)
 	case 'v':
 	    v_opt = TRUE;
 	    break;
+#endif
+#ifdef NCURSES_VERSION
 #if NCURSES_XNAMES
 	case 'x':
 	    x_opt = TRUE;
@@ -800,9 +836,13 @@
 	    x_opt = TRUE;
 	    break;
 #endif
+#endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
-	    break;
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
 
@@ -868,19 +908,25 @@
 	show_number("PC", PC);
 	show_string("UP", UP);
 	show_string("BC", BC);
-	show_number("ospeed", ospeed);
+	show_number("ospeed", (int) ospeed);
     }
 #endif
 
+#if NO_LEAKS
     free_dblist();
+#if USE_CODE_LISTS
+    free_code_list(my_boolcodes);
+    free_code_list(my_numcodes);
+    free_code_list(my_strcodes);
+#endif
+#endif /* NO_LEAKS */
 
     ExitProgram(EXIT_SUCCESS);
 }
 
 #else
 int
-main(int argc GCC_UNUSED,
-     char *argv[]GCC_UNUSED)
+main(void)
 {
     failed("This program requires termcap");
 }
diff --git a/test/demo_terminfo.c b/test/demo_terminfo.c
index 8e6ae1c..5e78015 100644
--- a/test/demo_terminfo.c
+++ b/test/demo_terminfo.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2009-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright 2019-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            *
@@ -29,7 +30,7 @@
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: demo_terminfo.c,v 1.39 2015/07/10 23:45:44 tom Exp $
+ * $Id: demo_terminfo.c,v 1.57 2023/05/27 20:13:10 tom Exp $
  *
  * A simple demo of the terminfo interface.
  */
@@ -46,6 +47,8 @@
 #endif
 #endif
 
+static GCC_NORETURN void failed(const char *);
+
 static void
 failed(const char *msg)
 {
@@ -67,8 +70,10 @@
 static bool n_opt = FALSE;
 static bool q_opt = FALSE;
 static bool s_opt = FALSE;
+#ifdef NCURSES_VERSION
 static bool x_opt = FALSE;
 static bool y_opt = FALSE;
+#endif
 
 static char *d_opt;
 static char *e_opt;
@@ -88,13 +93,14 @@
 static long total_s_values;
 
 #define FCOLS 8
-#define FNAME(type) "%s %-*s = ", #type, FCOLS
+#define FNAME(type) "%s %-*s = ", #type, f_opt ? 24 : FCOLS
 
 static char *
-make_dbitem(char *p, char *q)
+make_dbitem(const char *const p, const char *const q)
 {
-    char *result = malloc(strlen(e_opt) + 2 + (size_t) (p - q));
-    sprintf(result, "%s=%.*s", e_opt, (int) (p - q), q);
+    size_t need = strlen(e_opt) + 2 + (size_t) (p - q);
+    char *result = malloc(need);
+    _nc_SPRINTF(result, _nc_SLIMIT(need) "%s=%.*s", e_opt, (int) (p - q), q);
     return result;
 }
 
@@ -145,11 +151,12 @@
 	    db_item++;
 	}
     }
-    printf("** %s\n", result);
+    if (result != 0)
+	printf("** %s\n", result);
     return result;
 }
 
-#ifdef NO_LEAKS
+#if NO_LEAKS
 static void
 free_dblist(void)
 {
@@ -164,7 +171,7 @@
 #endif
 
 static void
-dumpit(NCURSES_CONST char *cap)
+dumpit(NCURSES_CONST char *cap, const char *show)
 {
     const char *str;
     int num;
@@ -173,7 +180,7 @@
 	total_values++;
 	total_s_values++;
 	if (!q_opt) {
-	    printf(FNAME(str), cap);
+	    printf(FNAME(str), show ? show : cap);
 	    while (*str != 0) {
 		int ch = UChar(*str++);
 		switch (ch) {
@@ -226,14 +233,14 @@
 	total_values++;
 	total_n_values++;
 	if (!q_opt) {
-	    printf(FNAME(num), cap);
+	    printf(FNAME(num), show ? show : cap);
 	    printf(" %d\n", num);
 	}
     } else if ((num = tigetflag(cap)) >= 0) {
 	total_values++;
 	total_b_values++;
 	if (!q_opt) {
-	    printf(FNAME(flg), cap);
+	    printf(FNAME(flg), show ? show : cap);
 	    printf("%s\n", num ? "true" : "false");
 	}
     }
@@ -284,7 +291,7 @@
 		cap[j] = legal[item[j]];
 	    }
 	    cap[length] = '\0';
-	    dumpit(cap);
+	    dumpit(cap, NULL);
 
 	    k = length - 1;
 	    do {
@@ -311,9 +318,9 @@
 }
 
 #if USE_CODE_LISTS
-#define fullname(type,n) f_opt ? type##fnames[n] : my_##type##codes[n]
+#define fullname(type,n) f_opt ? type##fnames[n] : cap
 #else
-#define fullname(type,n) my_##type##codes[n]
+#define fullname(type,n) cap
 #endif
 
 static void
@@ -331,48 +338,47 @@
 
     if (b_opt) {
 	for (n = 0;; ++n) {
-	    cap = fullname(bool, n);
+	    cap = my_boolcodes[n];
 	    if (cap == 0)
 		break;
-	    dumpit(cap);
+	    dumpit(cap, fullname(bool, n));
 	}
     }
 
     if (n_opt) {
 	for (n = 0;; ++n) {
-	    cap = fullname(num, n);
+	    cap = my_numcodes[n];
 	    if (cap == 0)
 		break;
-	    dumpit(cap);
+	    dumpit(cap, fullname(num, n));
 	}
     }
 
     if (s_opt) {
 	for (n = 0;; ++n) {
-	    cap = fullname(str, n);
+	    cap = my_strcodes[n];
 	    if (cap == 0)
 		break;
-	    dumpit(cap);
+	    dumpit(cap, fullname(str, n));
 	}
     }
 #ifdef NCURSES_VERSION
     if (x_opt && (my_blob == 0)) {
-	int mod;
 	if (y_opt) {
 #if NCURSES_XNAMES
-	    TERMTYPE *term = &(cur_term->type);
+	    TERMTYPE *term = (TERMTYPE *) cur_term;
 	    if (term != 0
 		&& ((NUM_BOOLEANS(term) != BOOLCOUNT)
 		    || (NUM_NUMBERS(term) != NUMCOUNT)
 		    || (NUM_STRINGS(term) != STRCOUNT))) {
 		for (n = BOOLCOUNT; n < NUM_BOOLEANS(term); ++n) {
-		    dumpit(ExtBoolname(term, (int) n, boolnames));
+		    dumpit(ExtBoolname(term, (int) n, boolnames), NULL);
 		}
 		for (n = NUMCOUNT; n < NUM_NUMBERS(term); ++n) {
-		    dumpit(ExtNumname(term, (int) n, numnames));
+		    dumpit(ExtNumname(term, (int) n, numnames), NULL);
 		}
 		for (n = STRCOUNT; n < NUM_STRINGS(term); ++n) {
-		    dumpit(ExtStrname(term, (int) n, strnames));
+		    dumpit(ExtStrname(term, (int) n, strnames), NULL);
 		}
 	    }
 #endif
@@ -384,6 +390,7 @@
 		"kLFT", "kNXT", "kPRV", "kRIT", "kUP",
 	    };
 	    for (n = 0; n < SIZEOF(xterm_keys); ++n) {
+		int mod;
 		for (mod = 0; mod < 8; ++mod) {
 		    if (mod == 0) {
 			/* these happen to be standard - avoid duplicates */
@@ -394,11 +401,13 @@
 			    !strcmp(xterm_keys[n], "kRIT")) {
 			    continue;
 			}
-			sprintf(temp, "%.*s", 8, xterm_keys[n]);
+			_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+				    "%.*s", 8, xterm_keys[n]);
 		    } else {
-			sprintf(temp, "%.*s%d", 8, xterm_keys[n], mod);
+			_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+				    "%.*s%d", 8, xterm_keys[n], mod);
 		    }
-		    dumpit(temp);
+		    dumpit(temp, NULL);
 		}
 	    }
 	}
@@ -421,7 +430,8 @@
 static void
 parse_description(const char *input_name)
 {
-    static char empty[1];
+    static char empty[1] =
+    {0};
 
     FILE *fp;
     struct stat sb;
@@ -454,11 +464,13 @@
 	failed("cannot allocate memory for input-file");
     }
 
-    if ((fp = fopen(input_name, "r")) == 0)
+    if ((fp = fopen(input_name, "r")) == 0) {
 	failed("cannot open input-file");
-    len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp);
-    my_blob[sb.st_size] = '\0';
-    fclose(fp);
+    } else {
+	len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp);
+	my_blob[sb.st_size] = '\0';
+	fclose(fp);
+    }
 
     /*
      * First, get rid of comments and escaped newlines, as well as repeated
@@ -721,7 +733,6 @@
     size_t count;
     size_t length = 1;
     char **result = 0;
-    char *blob = 0;
     char *unused = 0;
 
     for (pass = 0; pass < 2; ++pass) {
@@ -731,12 +742,12 @@
 		length += chunk;
 	    } else {
 		result[count] = unused;
-		strcpy(unused, list[count]);
+		_nc_STRCPY(unused, list[count], length);
 		unused += chunk;
 	    }
 	}
 	if (pass == 0) {
-	    blob = malloc(length);
+	    char *blob = malloc(length);
 	    result = typeCalloc(char *, count + 1);
 	    unused = blob;
 	    if (blob == 0 || result == 0)
@@ -746,52 +757,68 @@
 
     return result;
 }
+
+#if NO_LEAKS
+static void
+free_code_list(char **list)
+{
+    if (list) {
+	free(list[0]);
+	free(list);
+    }
+}
 #endif
+#endif /* USE_CODE_LISTS */
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *msg[] =
     {
-	"Usage: demo_terminfo [options] [terminal]",
-	"",
-	"If no options are given, print all (boolean, numeric, string)",
-	"capabilities for the given terminal, using short names.",
-	"",
-	"Options:",
-	" -a       try all names, print capabilities found",
-	" -b       print boolean-capabilities",
-	" -d LIST  colon-separated list of databases to use",
-	" -e NAME  environment variable to set with -d option",
-	" -f       print full names",
-	" -i NAME  terminal description to use as names for \"-a\" option",
-	" -n       print numeric-capabilities",
-	" -q       quiet (prints only counts)",
-	" -r COUNT repeat for given count",
-	" -s       print string-capabilities",
+	"Usage: demo_terminfo [options] [terminal]"
+	,""
+	,"If no options are given, print all (boolean, numeric, string)"
+	,"capabilities for the given terminal, using short names."
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -a       try all names, print capabilities found"
+	," -b       print boolean-capabilities"
+	," -d LIST  colon-separated list of databases to use"
+	," -e NAME  environment variable to set with -d option"
+	," -f       print full names"
+	," -i NAME  terminal description to use as names for \"-a\" option"
+	," -n       print numeric-capabilities"
+	," -q       quiet (prints only counts)"
+	," -r COUNT repeat for given count"
+	," -s       print string-capabilities"
 #ifdef NCURSES_VERSION
-	" -x       print extended capabilities",
-	" -y       direct-lookup names of extended capabilities",
+	," -x       print extended capabilities"
+	," -y       direct-lookup names of extended capabilities"
 #endif
     };
     unsigned n;
     for (n = 0; n < SIZEOF(msg); ++n) {
 	fprintf(stderr, "%s\n", msg[n]);
     }
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
 {
+    int ch;
     int n;
     int repeat;
     char *name;
     int r_opt = 1;
     char *input_name = 0;
 
-    while ((n = getopt(argc, argv, "abd:e:fi:nqr:sxy")) != -1) {
-	switch (n) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "abd:e:fi:nqr:sxy")) != -1) {
+	switch (ch) {
 	case 'a':
 	    a_opt = TRUE;
 	    break;
@@ -818,23 +845,28 @@
 	    break;
 	case 'r':
 	    if ((r_opt = atoi(optarg)) <= 0)
-		usage();
+		usage(FALSE);
 	    break;
 	case 's':
 	    s_opt = TRUE;
 	    break;
-#ifdef NCURSES_VERSION
 	case 'x':
+#ifdef NCURSES_VERSION
 	    x_opt = TRUE;
+#endif
 	    break;
+#ifdef NCURSES_VERSION
 	case 'y':
 	    y_opt = TRUE;
 	    x_opt = TRUE;
 	    break;
 #endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
-	    break;
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
 
@@ -892,29 +924,42 @@
 	}
     }
 
-    printf("%ld values (%ld booleans, %ld numbers, %ld strings)\n",
-	   total_values, total_b_values, total_n_values, total_s_values);
+#define PLURAL(n) n, (n != 1) ? "s" : ""
+    printf("%ld value%s (%ld boolean%s, %ld number%s, %ld string%s)\n",
+	   PLURAL(total_values),
+	   PLURAL(total_b_values),
+	   PLURAL(total_n_values),
+	   PLURAL(total_s_values));
 
-#ifdef NO_LEAKS
+#if NO_LEAKS
     free_dblist();
-    if (my_blob != 0) {
-	free(my_blob);
-	free(my_boolcodes);
-	free(my_numcodes);
-	free(my_numvalues);
-	free(my_strcodes);
-	free(my_strvalues);
+    if (input_name != 0) {
+	if (my_blob != 0) {
+	    free(my_blob);
+	    free(my_boolcodes);
+	    free(my_numcodes);
+	    free(my_numvalues);
+	    free(my_strcodes);
+	    free(my_strvalues);
+	}
+    }
+#if USE_CODE_LISTS
+    else {
+	free_code_list(my_boolcodes);
+	free_code_list(my_numcodes);
+	free_code_list(my_strcodes);
     }
 #endif
+#endif /* NO_LEAKS */
 
     ExitProgram(EXIT_SUCCESS);
 }
 
 #else /* !HAVE_TIGETSTR */
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(void)
 {
-    printf("This program requires the terminfo functions such as tigetstr\n");
+    failed("This program requires the terminfo functions such as tigetstr");
     ExitProgram(EXIT_FAILURE);
 }
 #endif /* HAVE_TIGETSTR */
diff --git a/test/ditto.c b/test/ditto.c
index 921f216..acac837 100644
--- a/test/ditto.c
+++ b/test/ditto.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            *
@@ -29,7 +30,7 @@
 /*
  * Author: Thomas E. Dickey (1998-on)
  *
- * $Id: ditto.c,v 1.42 2012/11/24 20:16:18 tom Exp $
+ * $Id: ditto.c,v 1.59 2023/09/23 17:08:43 tom Exp $
  *
  * The program illustrates how to set up multiple screens from a single
  * program.
@@ -44,6 +45,8 @@
 #include <test.priv.h>
 #include <sys/stat.h>
 
+#if HAVE_DELSCREEN
+
 #ifdef USE_PTHREADS
 #include <pthread.h>
 #endif
@@ -89,6 +92,15 @@
 #endif
 } DITTO;
 
+#ifdef USE_PTHREADS
+#define LockIt()                pthread_mutex_lock(&pending_mutex)
+#define UnlockIt()              pthread_mutex_unlock(&pending_mutex)
+pthread_mutex_t pending_mutex;
+#else
+#define LockIt()		/* nothing */
+#define UnlockIt()		/* nothing */
+#endif
+
 /*
  * Structure used to pass multiple parameters via the use_screen()
  * single-parameter interface.
@@ -99,9 +111,6 @@
     DITTO *ditto;		/* data for all screens */
 } DDATA;
 
-static void failed(const char *) GCC_NORETURN;
-static void usage(void) GCC_NORETURN;
-
 static void
 failed(const char *s)
 {
@@ -109,13 +118,6 @@
     ExitProgram(EXIT_FAILURE);
 }
 
-static void
-usage(void)
-{
-    fprintf(stderr, "usage: ditto [terminal1 ...]\n");
-    ExitProgram(EXIT_FAILURE);
-}
-
 /* Add to the head of the fifo, checking for overflow. */
 static void
 put_fifo(FIFO * fifo, int value)
@@ -155,6 +157,10 @@
     int aslave;
     char slave_name[1024];
     char s_option[sizeof(slave_name) + 80];
+    const char *xterm_prog = 0;
+
+    if ((xterm_prog = getenv("XTERM_PROG")) == 0)
+	xterm_prog = "xterm";
 
     if (openpty(&amaster, &aslave, slave_name, 0, 0) != 0
 	|| strlen(slave_name) > sizeof(slave_name) - 1)
@@ -163,9 +169,10 @@
 	errno = EISDIR;
 	failed(slave_name);
     }
-    sprintf(s_option, "-S%s/%d", slave_name, aslave);
+    _nc_SPRINTF(s_option, _nc_SLIMIT(sizeof(s_option))
+		"-S%s/%d", slave_name, aslave);
     if (fork()) {
-	execlp("xterm", "xterm", s_option, "-title", path, (char *) 0);
+	execlp(xterm_prog, xterm_prog, s_option, "-title", path, (char *) 0);
 	_exit(0);
     }
     fp = fdopen(amaster, "r+");
@@ -174,7 +181,7 @@
 #else
     struct stat sb;
 
-    if (stat(path, &sb) < 0)
+    if (stat(path, &sb) == -1)
 	failed(path);
     if ((sb.st_mode & S_IFMT) != S_IFCHR) {
 	errno = ENOTTY;
@@ -189,7 +196,7 @@
     return fp;
 }
 
-static void
+static int
 init_screen(
 #if HAVE_USE_WINDOW
 	       SCREEN *sp GCC_UNUSED,
@@ -229,6 +236,15 @@
 	target->windows[k] = inner;
     }
     doupdate();
+    return TRUE;
+}
+
+static void
+free_screen(DITTO * target)
+{
+    free(target->parents);
+    free(target->windows);
+    free(target->peeks);
 }
 
 static void
@@ -344,7 +360,6 @@
 handle_screen(void *arg)
 {
     DDATA ddata;
-    int ch;
 
     memset(&ddata, 0, sizeof(ddata));
     ddata.ditto = (DITTO *) arg;
@@ -352,7 +367,7 @@
     ddata.ditto -= ddata.source;	/* -> base of array */
 
     for (;;) {
-	ch = read_screen(ddata.ditto->screen, &ddata);
+	int ch = read_screen(ddata.ditto->screen, &ddata);
 	if (ch == CTRL('D')) {
 	    int later = (ddata.source ? ddata.source : -1);
 	    int j;
@@ -373,17 +388,46 @@
 }
 #endif
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: ditto [terminal [terminal2 ...]]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
 main(int argc, char *argv[])
 {
     int j;
+    int ch;
     DITTO *data;
 #ifndef USE_PTHREADS
     int count;
 #endif
 
-    if (argc <= 1)
-	usage();
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
 
     if ((data = typeCalloc(DITTO, (size_t) argc)) == 0)
 	failed("calloc data");
@@ -395,13 +439,15 @@
     }
 
 #ifdef USE_PTHREADS
+    pthread_mutex_init(&pending_mutex, NULL);
     /*
      * For multi-threaded operation, set up a reader for each of the screens.
      * That uses blocking I/O rather than polling for input, so no calls to
      * napms() are needed.
      */
     for (j = 0; j < argc; j++) {
-	(void) pthread_create(&(data[j].thread), NULL, handle_screen, &data[j]);
+	(void) pthread_create(&(data[j].thread), NULL, handle_screen,
+			      &data[j]);
     }
     pthread_join(data[1].thread, NULL);
 #else
@@ -411,7 +457,6 @@
      */
     for (count = 0;; ++count) {
 	DDATA ddata;
-	int ch;
 	int which = (count % argc);
 
 	napms(20);
@@ -432,6 +477,7 @@
      * Cleanup and exit
      */
     for (j = argc - 1; j >= 0; j--) {
+	LockIt();
 	USING_SCREEN(data[j].screen, close_screen, 0);
 	fprintf(data[j].output, "**Closed\r\n");
 
@@ -442,6 +488,17 @@
 	fflush(data[j].output);
 	fclose(data[j].output);
 	delscreen(data[j].screen);
+	free_screen(&data[j]);
+	UnlockIt();
     }
+    free(data);
     ExitProgram(EXIT_SUCCESS);
 }
+#else
+int
+main(void)
+{
+    printf("This program requires the curses delscreen function\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
diff --git a/test/dots.c b/test/dots.c
index 474d880..05aa854 100644
--- a/test/dots.c
+++ b/test/dots.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1999-2011,2013 Free Software Foundation, Inc.              *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1999-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            *
@@ -29,7 +30,7 @@
 /*
  * Author: Thomas E. Dickey <dickey@clark.net> 1999
  *
- * $Id: dots.c,v 1.25 2013/09/28 22:12:09 tom Exp $
+ * $Id: dots.c,v 1.45 2023/01/07 17:21:48 tom Exp $
  *
  * A simple demo of the terminfo interface.
  */
@@ -40,8 +41,6 @@
 
 #include <time.h>
 
-#define valid(s) ((s != 0) && s != (char *)-1)
-
 static bool interrupted = FALSE;
 static long total_chars = 0;
 static time_t started;
@@ -64,7 +63,7 @@
 static bool
 outs(const char *s)
 {
-    if (valid(s)) {
+    if (VALID_STRING(s)) {
 	tputs(s, 1, outc);
 	return TRUE;
     }
@@ -80,9 +79,10 @@
     outs(clear_screen);
     outs(cursor_normal);
 
-    printf("\n\n%ld total chars, rate %.2f/sec\n",
-	   total_chars,
-	   ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
+    fflush(stdout);
+    fprintf(stderr, "\n\n%ld total cells, rate %.2f/sec\n",
+	    total_chars,
+	    ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
 }
 
 static void
@@ -98,54 +98,140 @@
     return ((double) r / 32768.);
 }
 
-int
-main(int argc GCC_UNUSED,
-     char *argv[]GCC_UNUSED)
+static int
+get_number(NCURSES_CONST char *cap, int map)
 {
-    int x, y, z, p;
+    int result = map;
+    if (cap != 0) {
+	int check = tigetnum(cap);
+	if (check > 0)
+	    result = check;
+    }
+    return result;
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: dots [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -T TERM  override $TERM"
+#if HAVE_USE_ENV
+	," -e       allow environment $LINES / $COLUMNS"
+#endif
+	," -f       use tigetnum rather than <term.h> mapping"
+	," -m SIZE  set margin (default: 2)"
+	," -r SECS  self-interrupt/exit after specified number of seconds"
+	," -s MSECS delay 1% of the time (default: 1 msecs)"
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
     double r;
     double c;
     int my_colors;
+    int f_option = 0;
+    int m_option = 2;
+    int r_option = 0;
+    int s_option = 1;
+    size_t need;
+    char *my_env;
 
-    CATCHALL(onsig);
+    while ((ch = getopt(argc, argv, OPTS_COMMON "T:efm:r:s:")) != -1) {
+	switch (ch) {
+	case 'T':
+	    need = 6 + strlen(optarg);
+	    if ((my_env = malloc(need)) != NULL) {
+		_nc_SPRINTF(my_env, _nc_SLIMIT(need) "TERM=%s", optarg);
+		putenv(my_env);
+	    }
+	    break;
+#if HAVE_USE_ENV
+	case 'e':
+	    use_env(TRUE);
+	    break;
+#endif
+	case 'f':
+	    f_option = 1;
+	    break;
+	case 'm':
+	    m_option = atoi(optarg);
+	    break;
+	case 'r':
+	    r_option = atoi(optarg);
+	    break;
+	case 's':
+	    s_option = atoi(optarg);
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+
+    SetupAlarm(r_option);
+    InitAndCatch(setupterm((char *) 0, 1, (int *) 0), onsig);
 
     srand((unsigned) time(0));
-    setupterm((char *) 0, 1, (int *) 0);
+
     outs(clear_screen);
     outs(cursor_invisible);
-    my_colors = max_colors;
+
+#define GetNumber(ln,sn) get_number(f_option ? #sn : 0, ln)
+    my_colors = GetNumber(max_colors, colors);
     if (my_colors > 1) {
-	if (!valid(set_a_foreground)
-	    || !valid(set_a_background)
-	    || (!valid(orig_colors) && !valid(orig_pair)))
+	if (!VALID_STRING(set_a_foreground)
+	    || !VALID_STRING(set_a_background)
+	    || (!VALID_STRING(orig_colors) && !VALID_STRING(orig_pair)))
 	    my_colors = -1;
     }
 
-    r = (double) (lines - 4);
-    c = (double) (columns - 4);
+    r = (double) (GetNumber(lines, lines) - (m_option * 2));
+    c = (double) (GetNumber(columns, cols) - (m_option * 2));
     started = time((time_t *) 0);
 
     while (!interrupted) {
-	x = (int) (c * ranf()) + 2;
-	y = (int) (r * ranf()) + 2;
-	p = (ranf() > 0.9) ? '*' : ' ';
+	int x = (int) (c * ranf()) + m_option;
+	int y = (int) (r * ranf()) + m_option;
+	int p = (ranf() > 0.9) ? '*' : ' ';
 
 	tputs(tparm3(cursor_address, y, x), 1, outc);
 	if (my_colors > 0) {
-	    z = (int) (ranf() * my_colors);
+	    int z = (int) (ranf() * my_colors);
 	    if (ranf() > 0.01) {
 		tputs(tparm2(set_a_foreground, z), 1, outc);
 	    } else {
 		tputs(tparm2(set_a_background, z), 1, outc);
-		napms(1);
+		if (s_option)
+		    napms(s_option);
 	    }
-	} else if (valid(exit_attribute_mode)
-		   && valid(enter_reverse_mode)) {
+	} else if (VALID_STRING(exit_attribute_mode)
+		   && VALID_STRING(enter_reverse_mode)) {
 	    if (ranf() <= 0.01) {
 		outs((ranf() > 0.6)
 		     ? enter_reverse_mode
 		     : exit_attribute_mode);
-		napms(1);
+		if (s_option)
+		    napms(s_option);
 	    }
 	}
 	outc(p);
@@ -157,8 +243,7 @@
 }
 #else
 int
-main(int argc GCC_UNUSED,
-     char *argv[]GCC_UNUSED)
+main(void)
 {
     fprintf(stderr, "This program requires terminfo\n");
     exit(EXIT_FAILURE);
diff --git a/test/dots_curses.c b/test/dots_curses.c
index c344280..1a55321 100644
--- a/test/dots_curses.c
+++ b/test/dots_curses.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2014 Free Software Foundation, Inc.                        *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 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            *
@@ -29,20 +30,18 @@
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: dots_curses.c,v 1.3 2014/08/09 22:28:42 tom Exp $
+ * $Id: dots_curses.c,v 1.25 2023/01/07 17:21:48 tom Exp $
  *
  * A simple demo of the curses interface used for comparison with termcap.
  */
 #include <test.priv.h>
 
-#if !defined(__MINGW32__)
+#if !defined(_NC_WINDOWS)
 #include <sys/time.h>
 #endif
 
 #include <time.h>
 
-#define valid(s) ((s != 0) && s != (char *)-1)
-
 static bool interrupted = FALSE;
 static long total_chars = 0;
 static time_t started;
@@ -52,9 +51,10 @@
 {
     endwin();
 
-    printf("\n\n%ld total chars, rate %.2f/sec\n",
-	   total_chars,
-	   ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
+    fflush(stdout);
+    fprintf(stderr, "\n\n%ld total cells, rate %.2f/sec\n",
+	    total_chars,
+	    ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
 }
 
 static void
@@ -86,51 +86,136 @@
     }
 }
 
-int
-main(int argc GCC_UNUSED,
-     char *argv[]GCC_UNUSED)
+static void
+usage(int ok)
 {
-    int x, y, z, p;
+    static const char *msg[] =
+    {
+	"Usage: dots_curses [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -T TERM  override $TERM"
+#if HAVE_USE_DEFAULT_COLORS
+	," -d       invoke use_default_colors()"
+#endif
+#if HAVE_USE_ENV
+	," -e       allow environment $LINES / $COLUMNS"
+#endif
+	," -m SIZE  set margin (default: 2)"
+	," -r SECS  self-interrupt/exit after specified number of seconds"
+	," -s MSECS delay 1% of the time (default: 1 msecs)"
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
     int fg, bg;
     double r;
     double c;
+#if HAVE_USE_DEFAULT_COLORS
+    bool d_option = FALSE;
+#endif
+    int m_option = 2;
+    int r_option = 0;
+    int s_option = 1;
+    size_t need;
+    char *my_env;
 
-    CATCHALL(onsig);
+    while ((ch = getopt(argc, argv, OPTS_COMMON "T:dem:r:s:")) != -1) {
+	switch (ch) {
+	case 'T':
+	    need = 6 + strlen(optarg);
+	    if ((my_env = malloc(need)) != NULL) {
+		_nc_SPRINTF(my_env, _nc_SLIMIT(need) "TERM=%s", optarg);
+		putenv(my_env);
+	    }
+	    break;
+#if HAVE_USE_DEFAULT_COLORS
+	case 'd':
+	    d_option = TRUE;
+	    break;
+#endif
+#if HAVE_USE_ENV
+	case 'e':
+	    use_env(TRUE);
+	    break;
+#endif
+	case 'm':
+	    m_option = atoi(optarg);
+	    break;
+	case 'r':
+	    r_option = atoi(optarg);
+	    break;
+	case 's':
+	    s_option = atoi(optarg);
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
 
     srand((unsigned) time(0));
 
-    initscr();
+    SetupAlarm(r_option);
+    InitAndCatch(initscr(), onsig);
+
     if (has_colors()) {
 	start_color();
+#if HAVE_USE_DEFAULT_COLORS
+	if (d_option)
+	    use_default_colors();
+#endif
 	for (fg = 0; fg < COLORS; fg++) {
 	    for (bg = 0; bg < COLORS; bg++) {
-		int pair = mypair(fg, bg);
+		int pair;
+		if (interrupted) {
+		    cleanup();
+		    ExitProgram(EXIT_FAILURE);
+		}
+		pair = mypair(fg, bg);
 		if (pair > 0)
 		    init_pair((short) pair, (short) fg, (short) bg);
 	    }
 	}
     }
 
-    r = (double) (LINES - 4);
-    c = (double) (COLS - 4);
+    r = (double) (LINES - (m_option * 2));
+    c = (double) (COLS - (m_option * 2));
     started = time((time_t *) 0);
 
     fg = COLOR_WHITE;
     bg = COLOR_BLACK;
     while (!interrupted) {
-	x = (int) (c * ranf()) + 2;
-	y = (int) (r * ranf()) + 2;
-	p = (ranf() > 0.9) ? '*' : ' ';
+	int x = (int) (c * ranf()) + m_option;
+	int y = (int) (r * ranf()) + m_option;
+	int p = (ranf() > 0.9) ? '*' : ' ';
 
 	move(y, x);
 	if (has_colors()) {
-	    z = (int) (ranf() * COLORS);
+	    int z = (int) (ranf() * COLORS);
 	    if (ranf() > 0.01) {
 		set_colors(fg = z, bg);
 		attron(COLOR_PAIR(mypair(fg, bg)));
 	    } else {
 		set_colors(fg, bg = z);
-		napms(1);
+		if (s_option)
+		    napms(s_option);
 	    }
 	} else {
 	    if (ranf() <= 0.01) {
@@ -139,10 +224,11 @@
 		} else {
 		    attroff(A_REVERSE);
 		}
-		napms(1);
+		if (s_option)
+		    napms(s_option);
 	    }
 	}
-	addch((chtype) p);
+	AddCh(p);
 	refresh();
 	++total_chars;
     }
diff --git a/test/dots_mvcur.c b/test/dots_mvcur.c
index 90b9c4e..a611923 100644
--- a/test/dots_mvcur.c
+++ b/test/dots_mvcur.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007-2009,2013 Free Software Foundation, Inc.              *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2007-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            *
@@ -29,7 +30,7 @@
 /*
  * Author: Thomas E. Dickey - 2007
  *
- * $Id: dots_mvcur.c,v 1.10 2013/09/28 22:44:18 tom Exp $
+ * $Id: dots_mvcur.c,v 1.31 2023/01/07 17:21:48 tom Exp $
  *
  * A simple demo of the terminfo interface, and mvcur.
  */
@@ -40,8 +41,6 @@
 
 #include <time.h>
 
-#define valid(s) ((s != 0) && s != (char *)-1)
-
 static bool interrupted = FALSE;
 static long total_chars = 0;
 static time_t started;
@@ -65,7 +64,7 @@
 static bool
 outs(const char *s)
 {
-    if (valid(s)) {
+    if (VALID_STRING(s)) {
 	tputs(s, 1, outc);
 	return TRUE;
     }
@@ -81,9 +80,10 @@
     outs(clear_screen);
     outs(cursor_normal);
 
-    printf("\n\n%ld total chars, rate %.2f/sec\n",
-	   total_chars,
-	   ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
+    fflush(stdout);
+    fprintf(stderr, "\n\n%ld total cells, rate %.2f/sec\n",
+	    total_chars,
+	    ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
 }
 
 static void
@@ -99,40 +99,130 @@
     return ((double) r / 32768.);
 }
 
+static int
+get_number(NCURSES_CONST char *cap, int map)
+{
+    int result = map;
+    if (cap != 0) {
+	int check = tigetnum(cap);
+	if (check > 0)
+	    result = check;
+    }
+    return result;
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: dots_termcap [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -T TERM  override $TERM"
+#if HAVE_USE_ENV
+	," -e       allow environment $LINES / $COLUMNS"
+#endif
+	," -f       use tigetnum rather than <term.h> mapping"
+	," -m SIZE  set margin (default: 2)"
+	," -r SECS  self-interrupt/exit after specified number of seconds"
+	," -s MSECS delay 1% of the time (default: 1 msecs)"
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
-main(int argc GCC_UNUSED,
-     char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     int x0 = 1, y0 = 1;
-    int x, y, z, p;
+    int ch;
     double r;
     double c;
     SCREEN *sp;
     int my_colors;
+    int f_option = 0;
+    int m_option = 2;
+    int r_option = 0;
+    int s_option = 1;
+    size_t need;
+    char *my_env;
 
-    CATCHALL(onsig);
+    while ((ch = getopt(argc, argv, OPTS_COMMON "T:efm:r:s:")) != -1) {
+	switch (ch) {
+	case 'T':
+	    need = 6 + strlen(optarg);
+	    if ((my_env = malloc(need)) != NULL) {
+		_nc_SPRINTF(my_env, _nc_SLIMIT(need) "TERM=%s", optarg);
+		putenv(my_env);
+	    }
+	    break;
+#if HAVE_USE_ENV
+	case 'e':
+	    use_env(TRUE);
+	    break;
+#endif
+	case 'f':
+	    f_option = 1;
+	    break;
+	case 'm':
+	    m_option = atoi(optarg);
+	    break;
+	case 'r':
+	    r_option = atoi(optarg);
+	    break;
+	case 's':
+	    s_option = atoi(optarg);
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+
+    SetupAlarm(r_option);
+    InitAndCatch((sp = newterm((char *) 0, stdout, stdin)), onsig);
+    refresh();			/* needed with Solaris curses to cancel endwin */
+
+    if (sp == 0) {
+	fprintf(stderr, "Cannot initialize terminal\n");
+	ExitProgram(EXIT_FAILURE);
+    }
 
     srand((unsigned) time(0));
-    sp = newterm((char *) 0, stdout, stdin);
+
     outs(clear_screen);
     outs(cursor_home);
     outs(cursor_invisible);
-    my_colors = max_colors;
+
+#define GetNumber(ln,sn) get_number(f_option ? #sn : 0, ln)
+    my_colors = GetNumber(max_colors, colors);
     if (my_colors > 1) {
-	if (!valid(set_a_foreground)
-	    || !valid(set_a_background)
-	    || (!valid(orig_colors) && !valid(orig_pair)))
+	if (!VALID_STRING(set_a_foreground)
+	    || !VALID_STRING(set_a_background)
+	    || (!VALID_STRING(orig_colors) && !VALID_STRING(orig_pair)))
 	    my_colors = -1;
     }
 
-    r = (double) (lines - 4);
-    c = (double) (columns - 4);
+    r = (double) (GetNumber(lines, lines) - (m_option * 2));
+    c = (double) (GetNumber(columns, cols) - (m_option * 2));
     started = time((time_t *) 0);
 
     while (!interrupted) {
-	x = (int) (c * ranf()) + 2;
-	y = (int) (r * ranf()) + 2;
-	p = (ranf() > 0.9) ? '*' : ' ';
+	int x = (int) (c * ranf()) + m_option;
+	int y = (int) (r * ranf()) + m_option;
+	int p = (ranf() > 0.9) ? '*' : ' ';
 
 	if (mvcur(y0, x0, y, x) != ERR) {
 	    x0 = x;
@@ -140,20 +230,22 @@
 	}
 
 	if (my_colors > 0) {
-	    z = (int) (ranf() * my_colors);
+	    int z = (int) (ranf() * my_colors);
 	    if (ranf() > 0.01) {
 		tputs(tparm2(set_a_foreground, z), 1, outc);
 	    } else {
 		tputs(tparm2(set_a_background, z), 1, outc);
-		napms(1);
+		if (s_option)
+		    napms(s_option);
 	    }
-	} else if (valid(exit_attribute_mode)
-		   && valid(enter_reverse_mode)) {
+	} else if (VALID_STRING(exit_attribute_mode)
+		   && VALID_STRING(enter_reverse_mode)) {
 	    if (ranf() <= 0.01) {
 		outs((ranf() > 0.6)
 		     ? enter_reverse_mode
 		     : exit_attribute_mode);
-		napms(1);
+		if (s_option)
+		    napms(s_option);
 	    }
 	}
 	outc(p);
@@ -168,8 +260,7 @@
 }
 #else
 int
-main(int argc GCC_UNUSED,
-     char *argv[]GCC_UNUSED)
+main(void)
 {
     fprintf(stderr, "This program requires terminfo\n");
     exit(EXIT_FAILURE);
diff --git a/test/dots_termcap.c b/test/dots_termcap.c
index 9918e36..65786c4 100644
--- a/test/dots_termcap.c
+++ b/test/dots_termcap.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2013 Free Software Foundation, Inc.                        *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2013-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            *
@@ -29,14 +30,14 @@
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: dots_termcap.c,v 1.8 2014/09/25 09:00:56 tom Exp $
+ * $Id: dots_termcap.c,v 1.32 2023/02/25 18:11:21 tom Exp $
  *
  * A simple demo of the termcap interface.
  */
 #define USE_TINFO
 #include <test.priv.h>
 
-#if !defined(__MINGW32__)
+#if !defined(_NC_WINDOWS)
 #include <sys/time.h>
 #endif
 
@@ -44,8 +45,6 @@
 
 #include <time.h>
 
-#define valid(s) ((s != 0) && s != (char *)-1)
-
 static bool interrupted = FALSE;
 static long total_chars = 0;
 static time_t started;
@@ -62,7 +61,7 @@
 static char *t_vi;
 
 static struct {
-    const char *name;
+    NCURSES_CONST char *name;
     char **value;
 } my_caps[] = {
 
@@ -116,7 +115,7 @@
 static bool
 outs(char *s)
 {
-    if (valid(s)) {
+    if (VALID_STRING(s)) {
 	tputs(s, 1, outc);
 	return TRUE;
     }
@@ -132,9 +131,10 @@
     outs(t_cl);
     outs(t_ve);
 
-    printf("\n\n%ld total chars, rate %.2f/sec\n",
-	   total_chars,
-	   ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
+    fflush(stdout);
+    fprintf(stderr, "\n\n%ld total cells, rate %.2f/sec\n",
+	    total_chars,
+	    ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
 }
 
 static void
@@ -150,41 +150,129 @@
     return ((double) r / 32768.);
 }
 
+/*
+ * napms is a curses function which happens to be usable without initializing
+ * the screen, but if this program happened to be build with a "real" termcap
+ * library, there is nothing like napms. 
+ */
+#if HAVE_NAPMS
+#define my_napms(ms) napms(ms)
+#else
 static void
 my_napms(int ms)
 {
-#if defined(__MINGW32__) || !HAVE_GETTIMEOFDAY
-    Sleep((DWORD) ms);
+    if (ms > 0) {
+#if defined(_NC_WINDOWS)
+	Sleep((unsigned int) ms);
 #else
-    struct timeval data;
-    data.tv_sec = 0;
-    data.tv_usec = ms * 1000;
-    select(0, NULL, NULL, NULL, &data);
+	struct timeval data;
+	data.tv_sec = 0;
+	data.tv_usec = ms * 1000;
+	select(0, NULL, NULL, NULL, &data);
 #endif
+    }
+}
+#endif
+
+static int
+get_number(NCURSES_CONST char *cap, const char *env)
+{
+    int result = tgetnum(cap);
+    char *value = env ? getenv(env) : 0;
+    if (value != 0 && *value != 0) {
+	char *next = 0;
+	long check = strtol(value, &next, 10);
+	if (check > 0 && *next == '\0')
+	    result = (int) check;
+    }
+    return result;
 }
 
-int
-main(int argc GCC_UNUSED,
-     char *argv[]GCC_UNUSED)
+static void
+usage(int ok)
 {
-    int x, y, z, p;
+    static const char *msg[] =
+    {
+	"Usage: dots_termcap [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -T TERM  override $TERM"
+	," -e       allow environment $LINES / $COLUMNS"
+	," -m SIZE  set margin (default: 2)"
+	," -r SECS  self-interrupt/exit after specified number of seconds"
+	," -s MSECS delay 1% of the time (default: 1 msecs)"
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
     int num_colors;
     int num_lines;
     int num_columns;
+    int e_option = 0;
+    int m_option = 2;
+    int r_option = 0;
+    int s_option = 1;
     double r;
     double c;
     char buffer[1024];
     char area[1024];
     char *name;
+    size_t need;
+    char *my_env;
 
-    CATCHALL(onsig);
-
-    srand((unsigned) time(0));
+    while ((ch = getopt(argc, argv, OPTS_COMMON "T:em:r:s:")) != -1) {
+	switch (ch) {
+	case 'T':
+	    need = 6 + strlen(optarg);
+	    if ((my_env = malloc(need)) != NULL) {
+		_nc_SPRINTF(my_env, _nc_SLIMIT(need) "TERM=%s", optarg);
+		putenv(my_env);
+	    }
+	    break;
+	case 'e':
+	    e_option = 1;
+	    break;
+	case 'm':
+	    m_option = atoi(optarg);
+	    break;
+	case 'r':
+	    r_option = atoi(optarg);
+	    break;
+	case 's':
+	    s_option = atoi(optarg);
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
 
     if ((name = getenv("TERM")) == 0) {
 	fprintf(stderr, "TERM is not set\n");
 	ExitProgram(EXIT_FAILURE);
-    } else if (tgetent(buffer, name) < 0) {
+    }
+
+    srand((unsigned) time(0));
+
+    SetupAlarm((unsigned) r_option);
+    InitAndCatch(ch = tgetent(buffer, name), onsig);
+    if (ch < 0) {
 	fprintf(stderr, "terminal description not found\n");
 	ExitProgram(EXIT_FAILURE);
     } else {
@@ -197,43 +285,46 @@
     }
 
     num_colors = tgetnum("Co");
-    num_lines = tgetnum("li");
-    num_columns = tgetnum("co");
+#define GetNumber(cap,env) get_number(cap, e_option ? env : 0)
+    num_lines = GetNumber("li", "LINES");
+    num_columns = GetNumber("co", "COLUMNS");
 
     outs(t_cl);
     outs(t_vi);
     if (num_colors > 1) {
-	if (!valid(t_AF)
-	    || !valid(t_AB)
-	    || (!valid(t_oc) && !valid(t_op)))
+	if (!VALID_STRING(t_AF)
+	    || !VALID_STRING(t_AB)
+	    || (!VALID_STRING(t_oc) && !VALID_STRING(t_op)))
 	    num_colors = -1;
     }
 
-    r = (double) (num_lines - 4);
-    c = (double) (num_columns - 4);
+    r = (double) (num_lines - (2 * m_option));
+    c = (double) (num_columns - (2 * m_option));
     started = time((time_t *) 0);
 
     while (!interrupted) {
-	x = (int) (c * ranf()) + 2;
-	y = (int) (r * ranf()) + 2;
-	p = (ranf() > 0.9) ? '*' : ' ';
+	int x = (int) (c * ranf()) + m_option;
+	int y = (int) (r * ranf()) + m_option;
+	int p = (ranf() > 0.9) ? '*' : ' ';
 
 	tputs(tgoto(t_cm, x, y), 1, outc);
 	if (num_colors > 0) {
-	    z = (int) (ranf() * num_colors);
+	    int z = (int) (ranf() * num_colors);
 	    if (ranf() > 0.01) {
 		tputs(tgoto(t_AF, 0, z), 1, outc);
 	    } else {
 		tputs(tgoto(t_AB, 0, z), 1, outc);
-		my_napms(1);
+		if (s_option)
+		    my_napms(s_option);
 	    }
-	} else if (valid(t_me)
-		   && valid(t_mr)) {
+	} else if (VALID_STRING(t_me)
+		   && VALID_STRING(t_mr)) {
 	    if (ranf() <= 0.01) {
 		outs((ranf() > 0.6)
 		     ? t_mr
 		     : t_me);
-		my_napms(1);
+		if (s_option)
+		    my_napms(s_option);
 	    }
 	}
 	outc(p);
@@ -245,8 +336,7 @@
 }
 #else
 int
-main(int argc GCC_UNUSED,
-     char *argv[]GCC_UNUSED)
+main(void)
 {
     fprintf(stderr, "This program requires termcap\n");
     exit(EXIT_FAILURE);
diff --git a/test/dots_xcurses.c b/test/dots_xcurses.c
new file mode 100644
index 0000000..b4b5219
--- /dev/null
+++ b/test/dots_xcurses.c
@@ -0,0 +1,286 @@
+/****************************************************************************
+ * Copyright 2018-2022,2023 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
+ *
+ * $Id: dots_xcurses.c,v 1.29 2023/01/07 17:21:48 tom Exp $
+ *
+ * A simple demo of the wide-curses interface used for comparison with termcap.
+ */
+#include <test.priv.h>
+
+#if !defined(_NC_WINDOWS)
+#include <sys/time.h>
+#endif
+
+#include <time.h>
+
+#if USE_WIDEC_SUPPORT
+
+#if HAVE_ALLOC_PAIR
+#define NewPair(n) x_option ? ((void *)&(n)) : NULL
+#else
+#define NewPair(n) NULL
+#endif
+
+#define InitPair(p,fg,bg) init_pair((short) (p), (short) (fg), (short) (bg))
+
+static bool interrupted = FALSE;
+static long total_chars = 0;
+static time_t started;
+
+#if HAVE_ALLOC_PAIR
+static bool x_option = FALSE;
+#endif
+
+static void
+cleanup(void)
+{
+    endwin();
+
+    fflush(stdout);
+    fprintf(stderr, "\n\n%ld total cells, rate %.2f/sec\n",
+	    total_chars,
+	    ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
+}
+
+static void
+onsig(int n GCC_UNUSED)
+{
+    interrupted = TRUE;
+}
+
+static double
+ranf(void)
+{
+    long r = (rand() & 077777);
+    return ((double) r / 32768.);
+}
+
+static int
+mypair(int fg, int bg)
+{
+    int result;
+#if HAVE_ALLOC_PAIR
+    if (x_option) {
+	result = alloc_pair(fg, bg);
+    } else
+#endif
+    {
+	int pair = (fg * COLORS) + bg;
+	result = (pair >= COLOR_PAIRS) ? -1 : pair;
+    }
+    return result;
+}
+
+static void
+set_colors(int fg, int bg)
+{
+    int pair = mypair(fg, bg);
+    if (pair > 0) {
+	(void) color_set((short) pair, NewPair(pair));
+    }
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: dots_xcurses [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -T TERM  override $TERM"
+#if HAVE_USE_DEFAULT_COLORS
+	," -d       invoke use_default_colors()"
+#endif
+#if HAVE_USE_ENV
+	," -e       allow environment $LINES / $COLUMNS"
+#endif
+	," -m SIZE  set margin (default: 2)"
+	," -r SECS  self-interrupt/exit after specified number of seconds"
+	," -s MSECS delay 1% of the time (default: 1 msecs)"
+#if HAVE_ALLOC_PAIR
+	," -x       use alloc_pair() rather than init_pair()"
+#endif
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int fg, bg, ch;
+    wchar_t wch[2];
+    double r;
+    double c;
+#if HAVE_USE_DEFAULT_COLORS
+    bool d_option = FALSE;
+#endif
+    int m_option = 2;
+    int r_option = 0;
+    int s_option = 1;
+    size_t need;
+    char *my_env;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "T:dem:r:s:x")) != -1) {
+	switch (ch) {
+	case 'T':
+	    need = 6 + strlen(optarg);
+	    if ((my_env = malloc(need)) != NULL) {
+		_nc_SPRINTF(my_env, _nc_SLIMIT(need) "TERM=%s", optarg);
+		putenv(my_env);
+	    }
+	    break;
+#if HAVE_USE_DEFAULT_COLORS
+	case 'd':
+	    d_option = TRUE;
+	    break;
+#endif
+#if HAVE_USE_ENV
+	case 'e':
+	    use_env(TRUE);
+	    break;
+#endif
+	case 'm':
+	    m_option = atoi(optarg);
+	    break;
+	case 'r':
+	    r_option = atoi(optarg);
+	    break;
+	case 's':
+	    s_option = atoi(optarg);
+	    break;
+#if HAVE_ALLOC_PAIR
+	case 'x':
+	    x_option = TRUE;
+	    break;
+#endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+
+    setlocale(LC_ALL, "");
+    srand((unsigned) time(0));
+
+    SetupAlarm(r_option);
+    InitAndCatch(initscr(), onsig);
+    if (has_colors()) {
+	start_color();
+#if HAVE_USE_DEFAULT_COLORS
+	if (d_option)
+	    use_default_colors();
+#endif
+#if HAVE_ALLOC_PAIR
+	if (x_option) {
+	    ;			/* nothing */
+	} else
+#endif
+	{
+	    for (fg = 0; fg < COLORS; fg++) {
+		for (bg = 0; bg < COLORS; bg++) {
+		    int pair;
+		    if (interrupted) {
+			cleanup();
+			ExitProgram(EXIT_FAILURE);
+		    }
+		    pair = mypair(fg, bg);
+		    if (pair > 0) {
+			InitPair(pair, fg, bg);
+		    }
+		}
+	    }
+	}
+    }
+
+    r = (double) (LINES - (2 * m_option));
+    c = (double) (COLS - (2 * m_option));
+    started = time((time_t *) 0);
+
+    fg = COLOR_WHITE;
+    bg = COLOR_BLACK;
+    wch[1] = 0;
+    while (!interrupted) {
+	int x = (int) (c * ranf()) + m_option;
+	int y = (int) (r * ranf()) + m_option;
+	int p = (ranf() > 0.9) ? '*' : ' ';
+
+	move(y, x);
+	if (has_colors()) {
+	    int z = (int) (ranf() * COLORS);
+	    if (ranf() > 0.01) {
+		set_colors(fg = z, bg);
+	    } else {
+		set_colors(fg, bg = z);
+		if (s_option)
+		    napms(s_option);
+	    }
+	} else {
+	    if (ranf() <= 0.01) {
+		if (ranf() > 0.6) {
+		    attr_on(WA_REVERSE, NULL);
+		} else {
+		    attr_off(WA_REVERSE, NULL);
+		}
+		if (s_option)
+		    napms(s_option);
+	    }
+	}
+	wch[0] = (wchar_t) p;
+	addnwstr(wch, 1);
+	refresh();
+	++total_chars;
+    }
+    cleanup();
+    ExitProgram(EXIT_SUCCESS);
+}
+
+#else
+int
+main(void)
+{
+    printf("This program requires the wide-ncurses library\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
diff --git a/test/dump_window.c b/test/dump_window.c
new file mode 100644
index 0000000..eed4dbc
--- /dev/null
+++ b/test/dump_window.c
@@ -0,0 +1,179 @@
+/****************************************************************************
+ * Copyright 2018-2020,2023 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: dump_window.c,v 1.5 2023/11/11 00:30:50 tom Exp $
+ */
+#include <dump_window.h>
+
+static FILE *dumpfp;
+
+int
+open_dump(const char *fn)
+{
+    int result = 0;
+    close_dump();
+    if ((dumpfp = fopen(fn, "a")) != 0)
+	result = 1;
+    return result;
+}
+
+void
+close_dump(void)
+{
+    if (dumpfp != 0) {
+	fclose(dumpfp);
+	dumpfp = 0;
+    }
+}
+
+void
+dump_window(WINDOW *w)
+{
+    wgetch(w);
+    if (dumpfp != 0) {
+	int y, x;
+	int oldy, oldx;
+	int maxy, maxx;
+	int pass;
+	char *cvec = 0;
+	char *avec = 0;
+	char *pvec = 0;
+	int ccnt = 0;
+	int acnt = 0;
+	int pcnt = 0;
+	int endy = -1;
+	int endx = -1;
+
+	fprintf(dumpfp, "Window %p\n", (void *) w);
+
+	getyx(w, oldy, oldx);
+	getmaxyx(w, maxy, maxx);
+	fprintf(dumpfp, "size     (%dx%d)\n", maxy, maxx);
+	getbegyx(w, y, x);
+	fprintf(dumpfp, "begin    (%dx%d)\n", maxy, maxx);
+	getyx(w, y, x);
+	fprintf(dumpfp, "position (%d,%d)\n", y, x);
+
+	if (maxy > 0 && maxx > 0) {
+	    for (pass = 0; pass < 2; ++pass) {
+		for (y = 0; y < maxy; ++y) {
+
+		    if (cvec)
+			memset(cvec, 0, (size_t) maxx + 1);
+		    if (avec)
+			memset(avec, 0, (size_t) maxx + 1);
+		    if (pvec)
+			memset(pvec, 0, (size_t) maxx + 1);
+
+		    for (x = 0; x < maxx; ++x) {
+			chtype data = mvwinch(w, y, x);
+			chtype temp;
+			char cc = (char) ((data & 0xff) ? (data & 0xff) : ' ');
+			char aa;
+			char pp;
+
+			temp = ((data & A_ATTRIBUTES) & (chtype) (~A_COLOR));
+			if (temp) {
+			    if (temp & A_ALTCHARSET) {
+				aa = (temp & A_BOLD) ? 'A' : 'a';
+			    } else if (temp & A_STANDOUT) {
+				aa = (temp & A_BOLD) ? 'S' : 's';
+			    } else if (temp & A_REVERSE) {
+				aa = (temp & A_BOLD) ? 'R' : 'r';
+			    } else if (temp & A_UNDERLINE) {
+				aa = (temp & A_BOLD) ? 'U' : 'u';
+			    } else {
+				aa = (temp & A_BOLD) ? 'b' : '?';
+			    }
+			} else {
+			    aa = ' ';
+			}
+			if (data & A_COLOR) {
+			    if (PAIR_NUMBER((int) data) < 8) {
+				pp = (char) ('0' + PAIR_NUMBER((int) data));
+			    } else {
+				pp = '*';
+			    }
+			} else {
+			    pp = ' ';
+			}
+
+			if (pass) {
+			    if (cvec)
+				cvec[x] = cc;
+			    if (avec)
+				avec[x] = aa;
+			    if (pvec)
+				pvec[x] = pp;
+			} else {
+			    if (cc != ' ' || aa != ' ' || pp != ' ') {
+				if (endx < x)
+				    endx = x;
+				if (endy < y)
+				    endy = y;
+			    }
+			    ccnt += (cc != ' ');
+			    acnt += (aa != ' ');
+			    pcnt += (pp != ' ');
+			}
+		    }
+		    if (pass) {
+			fprintf(dumpfp, "%3d", y + 1);
+			if (cvec)
+			    fprintf(dumpfp, "\tc|%.*s|\n", maxx, cvec);
+			if (avec)
+			    fprintf(dumpfp, "\ta|%.*s|\n", maxx, avec);
+			if (pvec)
+			    fprintf(dumpfp, "\tp|%.*s|\n", maxx, pvec);
+		    }
+		}
+		if (pass) {
+		    free(cvec);
+		    free(avec);
+		    free(pvec);
+		} else {
+		    fprintf(dumpfp, "%d cells with characters\n", ccnt);
+		    fprintf(dumpfp, "%d cells with video-attributes\n", acnt);
+		    fprintf(dumpfp, "%d cells with color-attributes\n", pcnt);
+		    if (endy < 0 || endx < 0)
+			break;
+		    /* reduce the dump a little, ignore really blank cells */
+		    maxx = endx + 1;
+		    maxy = endy + 1;
+		    if (ccnt)
+			cvec = malloc((size_t) maxx + 1);
+		    if (acnt)
+			avec = malloc((size_t) maxx + 1);
+		    if (pcnt)
+			pvec = malloc((size_t) maxx + 1);
+		}
+	    }
+	}
+	wmove(w, oldy, oldx);
+    }
+}
diff --git a/test/dump_window.h b/test/dump_window.h
new file mode 100644
index 0000000..865249e
--- /dev/null
+++ b/test/dump_window.h
@@ -0,0 +1,40 @@
+/****************************************************************************
+ * Copyright 2018,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: dump_window.h,v 1.2 2020/02/02 23:34:34 tom Exp $
+ */
+#ifndef DUMP_WINDOW_H_incl
+#define DUMP_WINDOW_H_incl 1
+
+#include <test.priv.h>
+
+extern int open_dump(const char *fn);
+extern void close_dump(void);
+extern void dump_window(WINDOW *w);
+
+#endif /* DUMP_WINDOW_H_incl */
diff --git a/test/dup_field.c b/test/dup_field.c
new file mode 100644
index 0000000..68198ed
--- /dev/null
+++ b/test/dup_field.c
@@ -0,0 +1,450 @@
+/****************************************************************************
+ * Copyright 2020-2022,2023 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: dup_field.c,v 1.8 2023/11/11 00:29:10 tom Exp $
+ *
+ * Demonstrate dup_field().
+ */
+
+#include <test.priv.h>
+
+#if USE_LIBFORM
+
+#include <edit_field.h>
+#include <popup_msg.h>
+
+#define DO_DEMO	CTRL('F')	/* actual key for toggling demo-mode */
+#define MY_DEMO	EDIT_FIELD('f')	/* internal request-code */
+
+static char empty[] = "";
+static FIELD *all_fields[100];
+/* *INDENT-OFF* */
+static struct {
+    int code;
+    int result;
+    const char *help;
+} commands[] = {
+    { CTRL('A'),     REQ_BEG_FIELD,   "go to beginning of field" },
+    { CTRL('D'),     REQ_DOWN_FIELD,  "move downward to field" },
+    { CTRL('E'),     REQ_END_FIELD,   "go to end of field" },
+    { CTRL('H'),     REQ_DEL_PREV,    "delete previous character" },
+    { CTRL('I'),     REQ_NEXT_FIELD,  "go to next field" },
+    { CTRL('K'),     REQ_CLR_EOF,     "clear to end of field" },
+    { CTRL('N'),     REQ_NEXT_FIELD,  "go to next field" },
+    { CTRL('P'),     REQ_PREV_FIELD,  "go to previous field" },
+    { CTRL('Q'),     MY_QUIT,         "exit form" },
+    { CTRL('U'),     REQ_UP_FIELD,    "move upward to field" },
+    { CTRL('W'),     REQ_NEXT_WORD,   "go to next word" },
+    { CTRL('X'),     REQ_CLR_FIELD,   "clear field" },
+    { CTRL('['),     MY_QUIT,         "exit form" },
+    { KEY_F(1),      MY_HELP,         "show this screen", },
+    { KEY_BACKSPACE, REQ_DEL_PREV,    "delete previous character" },
+    { KEY_BTAB,      REQ_PREV_FIELD,  "go to previous field" },
+    { KEY_DOWN,      REQ_DOWN_CHAR,   "move down 1 character" },
+    { KEY_END,       REQ_LAST_FIELD,  "go to last field" },
+    { KEY_HOME,      REQ_FIRST_FIELD, "go to first field" },
+    { KEY_LEFT,      REQ_LEFT_CHAR,   "move left 1 character" },
+    { KEY_NEXT,      REQ_NEXT_FIELD,  "go to next field" },
+    { KEY_PREVIOUS,  REQ_PREV_FIELD,  "go to previous field" },
+    { KEY_RIGHT,     REQ_RIGHT_CHAR,  "move right 1 character" },
+    { KEY_UP,        REQ_UP_CHAR,     "move up 1 character" },
+    { DO_DEMO,       MY_DEMO,         "duplicate current field" }
+};
+/* *INDENT-ON* */
+
+static void
+my_help_edit_field(void)
+{
+    int used = 0;
+    unsigned n;
+    char **msgs = typeCalloc(char *, 3 + SIZEOF(commands));
+
+    msgs[used++] = strdup("Defined form edit/traversal keys:");
+    for (n = 0; n < SIZEOF(commands); ++n) {
+	char *msg;
+	const char *name;
+	const char *code = keyname(commands[n].code);
+	size_t need = 5;
+#ifdef NCURSES_VERSION
+	if ((name = form_request_name(commands[n].result)) == 0)
+#endif
+	    name = commands[n].help;
+	need = 5 + strlen(code) + strlen(name);
+	msg = typeMalloc(char, need);
+	_nc_SPRINTF(msg, _nc_SLIMIT(need) "%s -- %s", code, name);
+	msgs[used++] = msg;
+    }
+    msgs[used++] =
+	strdup("Arrow keys move within a field as you would expect.");
+    msgs[used] = 0;
+    popup_msg2(stdscr, msgs);
+    for (n = 0; msgs[n] != 0; ++n) {
+	free(msgs[n]);
+    }
+    free(msgs);
+}
+
+static FIELD *
+make_label(const char *label, int frow, int fcol)
+{
+    FIELD *f = new_field(1, (int) strlen(label), frow, fcol, 0, 0);
+
+    if (f) {
+	set_field_buffer(f, 0, label);
+	set_field_opts(f, (int) ((unsigned) field_opts(f) & (unsigned) ~O_ACTIVE));
+    }
+    return (f);
+}
+
+static FIELD *
+make_field(int frow, int fcol, int rows, int cols)
+{
+    FIELD *f = new_field(rows, cols, frow, fcol, 0, 1);
+
+    if (f) {
+	set_field_back(f, A_UNDERLINE);
+	init_edit_field(f, empty);
+    }
+    return (f);
+}
+
+static void
+erase_form(FORM *f)
+{
+    WINDOW *w = form_win(f);
+    WINDOW *s = form_sub(f);
+
+    unpost_form(f);
+    werase(w);
+    wrefresh(w);
+    delwin(s);
+}
+
+static FieldAttrs *
+my_field_attrs(FIELD *f)
+{
+    return (FieldAttrs *) field_userptr(f);
+}
+
+static int
+buffer_length(FIELD *f)
+{
+    return my_field_attrs(f)->row_lengths[0];
+}
+
+static void
+set_buffer_length(FIELD *f, int length)
+{
+    my_field_attrs(f)->row_lengths[0] = length;
+}
+
+static int
+offset_in_field(FORM *form)
+{
+    FIELD *field = current_field(form);
+    int currow, curcol;
+
+    form_getyx(form, currow, curcol);
+    return curcol + currow * (int) field->dcols;
+}
+
+static void
+inactive_field(FIELD *f)
+{
+    set_field_back(f, my_field_attrs(f)->background);
+}
+
+static int
+my_edit_field(FORM *form, int *result)
+{
+    int ch = wgetch(form_win(form));
+    int status;
+    FIELD *before;
+    unsigned n;
+    int before_row;
+    int before_col;
+    int before_off = offset_in_field(form);
+
+    form_getyx(form, before_row, before_col);
+    before = current_field(form);
+    set_field_back(before, A_NORMAL);
+    if (ch <= KEY_MAX) {
+	set_field_back(before, A_REVERSE);
+    } else if (ch <= MAX_FORM_COMMAND) {
+	inactive_field(before);
+    }
+
+    *result = ch;
+    for (n = 0; n < SIZEOF(commands); ++n) {
+	if (commands[n].code == ch) {
+	    *result = commands[n].result;
+	    break;
+	}
+    }
+
+    status = form_driver(form, *result);
+
+    if (status == E_OK) {
+	bool modified = TRUE;
+	int length = buffer_length(before);
+
+	if (length < before_off)
+	    length = before_off;
+	switch (*result) {
+	case REQ_CLR_EOF:
+	    length = before_off;
+	    break;
+	case REQ_CLR_EOL:
+	    if ((int) (before_row + 1) == (int) (before->rows))
+		length = before_off;
+	    break;
+	case REQ_CLR_FIELD:
+	    length = 0;
+	    break;
+	case REQ_DEL_CHAR:
+	    if (length > before_off)
+		--length;
+	    break;
+	case REQ_DEL_PREV:
+	    if (length > 0) {
+		if (before_col > 0) {
+		    --length;
+		} else if (before_row > 0) {
+		    length -= (int) before->cols + before_col;
+		}
+	    }
+	    break;
+	case REQ_NEW_LINE:
+	    length += (int) before->cols;
+	    break;
+
+	default:
+	    modified = (ch < MIN_FORM_COMMAND
+			&& isprint(ch));
+	    break;
+	}
+
+	/*
+	 * If we do not force a re-validation, then field_buffer 0 will
+	 * be lagging by one character.
+	 */
+	if (modified && form_driver(form, REQ_VALIDATION) == E_OK && *result
+	    < MIN_FORM_COMMAND)
+	    ++length;
+
+	set_buffer_length(before, length);
+    }
+
+    if (current_field(form) != before)
+	inactive_field(before);
+    return status;
+}
+
+static FIELD **
+copy_fields(FIELD **source, FIELD *extra, size_t length)
+{
+    FIELD **target = typeCalloc(FIELD *, length + 1);
+    memcpy(target, source, length * sizeof(FIELD *));
+    target[length] = extra;
+    return target;
+}
+
+static void
+do_demo(FORM *form)
+{
+    int count = field_count(form);
+    FIELD *my_field = current_field(form);
+    FIELD **old_fields = form_fields(form);
+
+    if (count > 0 && old_fields != NULL && my_field != NULL) {
+	FIELD **new_fields = copy_fields(old_fields,
+					 dup_field(my_field,
+						   form_field_row(my_field)
+						   + 1,
+						   form_field_col(my_field)),
+					 (size_t) count);
+	if (new_fields != NULL)
+	    set_form_fields(form, new_fields);
+    }
+}
+
+static int
+my_form_driver(FORM *form, int c)
+{
+    switch (c) {
+    case MY_QUIT:
+	if (form_driver(form, REQ_VALIDATION) == E_OK)
+	    return (TRUE);
+	break;
+    case MY_HELP:
+	my_help_edit_field();
+	break;
+    case MY_DEMO:
+	do_demo(form);
+	break;
+    default:
+	beep();
+	break;
+    }
+    return (FALSE);
+}
+
+static void
+demo_forms(void)
+{
+    FORM *form;
+    int c;
+    unsigned n = 0;
+    const char *fname;
+
+    /* describe the form */
+    all_fields[n++] = make_label("Sample Form", 0, 15);
+
+    fname = "Last Name";
+    all_fields[n++] = make_label(fname, 2, 0);
+    all_fields[n++] = make_field(3, 0, 1, 18);
+    set_field_type(all_fields[n - 1], TYPE_ALPHA, 1);
+
+    fname = "First Name";
+    all_fields[n++] = make_label(fname, 2, 20);
+    all_fields[n++] = make_field(3, 20, 1, 12);
+    set_field_type(all_fields[n - 1], TYPE_ALPHA, 1);
+
+    fname = "Middle Name";
+    all_fields[n++] = make_label(fname, 2, 34);
+    all_fields[n++] = make_field(3, 34, 1, 12);
+    set_field_type(all_fields[n - 1], TYPE_ALPHA, 1);
+
+    fname = "Comments";
+    all_fields[n++] = make_label(fname, 5, 0);
+    all_fields[n++] = make_field(6, 0, 4, 46);
+    init_edit_field(all_fields[n - 1], empty);
+
+    all_fields[n] = (FIELD *) 0;
+
+    if ((form = new_form(all_fields)) != 0) {
+	int finished = 0;
+
+	post_form(form);
+
+	while (!finished) {
+	    switch (my_edit_field(form, &c)) {
+	    case E_OK:
+		break;
+	    case E_UNKNOWN_COMMAND:
+		finished = my_form_driver(form, c);
+		break;
+	    default:
+		beep();
+		break;
+	    }
+	}
+
+	erase_form(form);
+
+	free_form(form);
+    }
+    for (c = 0; all_fields[c] != 0; c++) {
+	free_edit_field(all_fields[c]);
+	free_field(all_fields[c]);
+    }
+    noraw();
+    nl();
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: dup_field [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
+    setlocale(LC_ALL, "");
+
+    initscr();
+    cbreak();
+    noecho();
+    raw();
+    nonl();			/* lets us read ^M's */
+    intrflush(stdscr, FALSE);
+    keypad(stdscr, TRUE);
+
+    if (has_colors()) {
+	start_color();
+	init_pair(1, COLOR_WHITE, COLOR_BLUE);
+	init_pair(2, COLOR_GREEN, COLOR_BLACK);
+	init_pair(3, COLOR_CYAN, COLOR_BLACK);
+	bkgd((chtype) COLOR_PAIR(1));
+	refresh();
+    }
+
+    demo_forms();
+
+    endwin();
+    ExitProgram(EXIT_SUCCESS);
+}
+
+#else
+int
+main(void)
+{
+    printf("This program requires the curses form library\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
diff --git a/test/echochar.c b/test/echochar.c
index c9ac29a..0849706 100644
--- a/test/echochar.c
+++ b/test/echochar.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2006-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2006-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: echochar.c,v 1.10 2014/08/09 22:35:51 tom Exp $
+ * $Id: echochar.c,v 1.26 2023/05/27 20:13:10 tom Exp $
  *
  * Demonstrate the echochar function (compare to dots.c).
  * Thomas Dickey - 2006/11/4
@@ -36,8 +37,6 @@
 
 #include <time.h>
 
-#define valid(s) ((s != 0) && s != (char *)-1)
-
 static bool interrupted = FALSE;
 static long total_chars = 0;
 static time_t started;
@@ -45,9 +44,9 @@
 static void
 cleanup(void)
 {
-    endwin();
+    stop_curses();
 
-    printf("\n\n%ld total chars, rate %.2f/sec\n",
+    printf("\n\n%ld total cells, rate %.2f/sec\n",
 	   total_chars,
 	   ((double) (total_chars) / (double) (time((time_t *) 0) - started)));
 }
@@ -66,22 +65,45 @@
 }
 
 static void
-set_color(char *my_pairs, int fg, int bg)
+set_color(const char *const my_pairs, int fg, int bg)
 {
     int pair = (fg * COLORS) + bg;
-    if (!my_pairs[pair]) {
-	init_pair((short) pair,
-		  (short) fg,
-		  (short) bg);
+    if (pair < COLOR_PAIRS) {
+	if (!my_pairs[pair]) {
+	    init_pair((short) pair,
+		      (short) fg,
+		      (short) bg);
+	}
+	attron(COLOR_PAIR(pair));
     }
-    attron(COLOR_PAIR(pair));
 }
 
-int
-main(int argc GCC_UNUSED,
-     char *argv[]GCC_UNUSED)
+static void
+usage(int ok)
 {
-    int ch, x, y, z, p;
+    static const char *msg[] =
+    {
+	"Usage: echochar"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -r       use addch/refresh rather than echochar()"
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
     double r;
     double c;
     bool use_colors;
@@ -90,19 +112,21 @@
     int last_fg = 0;
     int last_bg = 0;
 
-    while ((ch = getopt(argc, argv, "r")) != -1) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "r")) != -1) {
 	switch (ch) {
 	case 'r':
 	    opt_r = TRUE;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    fprintf(stderr, "usage: echochar [-r]\n");
-	    ExitProgram(EXIT_FAILURE);
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
 
-    CATCHALL(onsig);
-    initscr();
+    InitAndCatch(initscr(), onsig);
 
     use_colors = has_colors();
     if (use_colors) {
@@ -122,13 +146,13 @@
     started = time((time_t *) 0);
 
     while (!interrupted) {
-	x = (int) (c * ranf()) + 2;
-	y = (int) (r * ranf()) + 2;
-	p = (ranf() > 0.9) ? '*' : ' ';
+	int x = (int) (c * ranf()) + 2;
+	int y = (int) (r * ranf()) + 2;
+	int p = (ranf() > 0.9) ? '*' : ' ';
 
 	move(y, x);
 	if (use_colors > 0) {
-	    z = (int) (ranf() * COLORS);
+	    int z = (int) (ranf() * COLORS);
 	    if (ranf() > 0.01) {
 		set_color(my_pairs, z, last_bg);
 		last_fg = z;
@@ -147,7 +171,7 @@
 	    }
 	}
 	if (opt_r) {
-	    addch(UChar(p));
+	    AddCh(UChar(p));
 	    refresh();
 	} else {
 	    echochar(UChar(p));
@@ -155,5 +179,6 @@
 	++total_chars;
     }
     cleanup();
+    free(my_pairs);
     ExitProgram(EXIT_SUCCESS);
 }
diff --git a/test/edit_field.c b/test/edit_field.c
index 8c58cd6..b2b2084 100644
--- a/test/edit_field.c
+++ b/test/edit_field.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2003-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2003-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: edit_field.c,v 1.24 2014/09/05 08:39:52 tom Exp $
+ * $Id: edit_field.c,v 1.31 2020/02/02 23:34:34 tom Exp $
  *
  * A wrapper for form_driver() which keeps track of the user's editing changes
  * for each field, and makes the resulting length available as a
@@ -40,6 +41,7 @@
 #if USE_LIBFORM
 
 #include <edit_field.h>
+#include <popup_msg.h>
 
 static struct {
     int code;
@@ -169,151 +171,71 @@
     }
 };
 
-static WINDOW *old_window;
-
-static void
-begin_popup(void)
-{
-    doupdate();
-    old_window = dupwin(curscr);
-}
-
-static void
-end_popup(void)
-{
-    touchwin(old_window);
-    wnoutrefresh(old_window);
-    doupdate();
-    delwin(old_window);
-}
-
 /*
  * Display a temporary window listing the keystroke-commands we recognize.
  */
 void
 help_edit_field(void)
 {
-    int x0 = 4;
-    int y0 = 2;
-    int y1 = 0;
-    int y2 = 0;
-    int wide = COLS - ((x0 + 1) * 2);
-    int high = LINES - ((y0 + 1) * 2);
-    WINDOW *help = newwin(high, wide, y0, x0);
-    WINDOW *data = newpad(2 + SIZEOF(commands), wide - 4);
+    int used = 0;
     unsigned n;
-    int ch = ERR;
+    char **msgs = typeCalloc(char *, 3 + SIZEOF(commands));
 
-    begin_popup();
-
-    keypad(help, TRUE);
-    keypad(data, TRUE);
-    waddstr(data, "Defined form edit/traversal keys:\n");
+    msgs[used++] = strdup("Defined form edit/traversal keys:");
     for (n = 0; n < SIZEOF(commands); ++n) {
+	char *msg;
 	const char *name;
+	const char *code = keyname(commands[n].code);
+	size_t need = 5;
 #ifdef NCURSES_VERSION
 	if ((name = form_request_name(commands[n].result)) == 0)
 #endif
 	    name = commands[n].help;
-	wprintw(data, "%s -- %s\n",
-		keyname(commands[n].code),
-		name != 0 ? name : commands[n].help);
+	need = 5 + strlen(code) + strlen(name);
+	msg = typeMalloc(char, need);
+	_nc_SPRINTF(msg, _nc_SLIMIT(need) "%s -- %s", code, name);
+	msgs[used++] = msg;
     }
-    waddstr(data, "Arrow keys move within a field as you would expect.");
-    y2 = getcury(data);
-
-    do {
-	switch (ch) {
-	case KEY_HOME:
-	    y1 = 0;
-	    break;
-	case KEY_END:
-	    y1 = y2;
-	    break;
-	case KEY_PREVIOUS:
-	case KEY_PPAGE:
-	    if (y1 > 0) {
-		y1 -= high / 2;
-		if (y1 < 0)
-		    y1 = 0;
-	    } else {
-		beep();
-	    }
-	    break;
-	case KEY_NEXT:
-	case KEY_NPAGE:
-	    if (y1 < y2) {
-		y1 += high / 2;
-		if (y1 >= y2)
-		    y1 = y2;
-	    } else {
-		beep();
-	    }
-	    break;
-	case CTRL('P'):
-	case KEY_UP:
-	    if (y1 > 0)
-		--y1;
-	    else
-		beep();
-	    break;
-	case CTRL('N'):
-	case KEY_DOWN:
-	    if (y1 < y2)
-		++y1;
-	    else
-		beep();
-	    break;
-	default:
-	    beep();
-	    break;
-	case ERR:
-	    break;
-	}
-	werase(help);
-	box(help, 0, 0);
-	wnoutrefresh(help);
-	pnoutrefresh(data, y1, 0, y0 + 1, x0 + 1, high, wide);
-	doupdate();
-    } while ((ch = wgetch(data)) != ERR && ch != QUIT && ch != ESCAPE);
-    werase(help);
-    wrefresh(help);
-    delwin(help);
-    delwin(data);
-
-    end_popup();
+    msgs[used++] =
+	strdup("Arrow keys move within a field as you would expect.");
+    msgs[used] = 0;
+    popup_msg2(stdscr, msgs);
+    for (n = 0; msgs[n] != 0; ++n) {
+	free(msgs[n]);
+    }
+    free(msgs);
 }
 
 static int
-offset_in_field(FORM * form)
+offset_in_field(FORM *form)
 {
     FIELD *field = current_field(form);
     int currow, curcol;
 
     form_getyx(form, currow, curcol);
-    return curcol + currow * field->dcols;
+    return curcol + currow * (int) field->dcols;
 }
 
 static void
-inactive_field(FIELD * f)
+inactive_field(FIELD *f)
 {
     set_field_back(f, field_attrs(f)->background);
 }
 
 FieldAttrs *
-field_attrs(FIELD * f)
+field_attrs(FIELD *f)
 {
     return (FieldAttrs *) field_userptr(f);
 }
 
 static int
-buffer_length(FIELD * f)
+buffer_length(FIELD *f)
 {
     return field_attrs(f)->row_lengths[0];
 }
 
 static void
-set_buffer_length(FIELD * f, int length)
+set_buffer_length(FIELD *f, int length)
 {
     field_attrs(f)->row_lengths[0] = length;
 }
@@ -323,7 +245,7 @@
  * keeping track of the actual lengths of lines in a multiline field.
  */
 void
-init_edit_field(FIELD * f, char *value)
+init_edit_field(FIELD *f, char *value)
 {
     char empty[1];
     FieldAttrs *ptr = field_attrs(f);
@@ -348,7 +270,7 @@
 }
 
 int
-edit_field(FORM * form, int *result)
+edit_field(FORM *form, int *result)
 {
     int ch = wgetch(form_win(form));
     int status;
@@ -404,12 +326,12 @@
 		if (before_col > 0) {
 		    --length;
 		} else if (before_row > 0) {
-		    length -= before->cols + before_col;
+		    length -= (int) before->cols + before_col;
 		}
 	    }
 	    break;
 	case REQ_NEW_LINE:
-	    length += before->cols;
+	    length += (int) before->cols;
 	    break;
 #if 0
 	    /* FIXME: finish these */
@@ -494,6 +416,16 @@
 	inactive_field(before);
     return status;
 }
+
+void
+free_edit_field(FIELD *f)
+{
+    FieldAttrs *ptr = field_attrs(f);
+    if (ptr != 0) {
+	free(ptr->row_lengths);
+	free(ptr);
+    }
+}
 #else
 
 extern void no_edit_field(void);
diff --git a/test/edit_field.h b/test/edit_field.h
index 3c5b80e..ad9e6a5 100644
--- a/test/edit_field.h
+++ b/test/edit_field.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2003-2008,2013 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2003-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: edit_field.h,v 1.9 2013/06/08 15:46:01 tom Exp $
+ * $Id: edit_field.h,v 1.11 2020/02/02 23:34:34 tom Exp $
  *
  * Interface of edit_field.c
  */
@@ -49,9 +50,10 @@
     int *row_lengths;
 } FieldAttrs;
 
-extern FieldAttrs *field_attrs(FIELD * field);
-extern void init_edit_field(FIELD * field, char *value);
+extern FieldAttrs *field_attrs(FIELD *field);
+extern void init_edit_field(FIELD *field, char *value);
 extern void help_edit_field(void);
-extern int edit_field(FORM * form, int *result);
+extern int edit_field(FORM *form, int *result);
+extern void free_edit_field(FIELD *field);
 
 #endif /* EDIT_FORM_H_incl */
diff --git a/test/escherknot.xbm b/test/escherknot.xbm
new file mode 100644
index 0000000..80bc471
--- /dev/null
+++ b/test/escherknot.xbm
@@ -0,0 +1,473 @@
+#define escherknot_width 216
+#define escherknot_height 208
+
+static char escherknot_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x5f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf0, 0x6f, 0xf6, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0xff, 0x3a, 0x13, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0d, 0x02, 0x51, 0x71, 0x0e, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x2f, 0x20, 0xd9, 0x88,
+ 0x9b, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x82,
+ 0xac, 0x44, 0x4e, 0x1c, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x1e, 0x40, 0x02, 0x44, 0x60, 0xe2, 0xfc, 0x06, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x25, 0x09, 0x90, 0x22, 0x13, 0xb7, 0x9a, 0x1e,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x40, 0x10, 0x89,
+ 0x18, 0xe3, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x04, 0x08,
+ 0x01, 0x10, 0xc8, 0xa8, 0xd5, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x83, 0x80, 0x20, 0x40, 0x82, 0x00, 0x66, 0x9c, 0xec, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x08, 0x08, 0x24, 0x12, 0x93, 0x5b,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x12, 0x80, 0x04, 0x01, 0x00, 0x80,
+ 0x19, 0x33, 0xfa, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x80, 0x80, 0x00,
+ 0x20, 0x08, 0x12, 0xc4, 0x68, 0x26, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
+ 0x02, 0x04, 0x24, 0x00, 0x01, 0x40, 0x24, 0x8c, 0xcd, 0x3f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
+ 0x00, 0x80, 0x49, 0x10, 0x90, 0x00, 0x21, 0x20, 0x08, 0x11, 0x43, 0xd9,
+ 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe8,
+ 0xff, 0xff, 0x0b, 0x00, 0x60, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x30, 0xb9, 0xf2, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc0, 0x97, 0x04, 0x08, 0xfe, 0x05, 0x30, 0x10, 0x12, 0x20, 0x20,
+ 0x04, 0x00, 0x80, 0x48, 0x0c, 0xa3, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x3e, 0x92, 0x20, 0x49, 0x40, 0x3e, 0x0e, 0x82,
+ 0x00, 0x84, 0x25, 0x01, 0x80, 0x00, 0x80, 0xc8, 0x34, 0xed, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x25, 0x01, 0x04, 0x01, 0x08,
+ 0xd0, 0x17, 0x00, 0x80, 0x25, 0x01, 0xad, 0x04, 0x12, 0x20, 0x23, 0x4c,
+ 0x6a, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x02, 0x48,
+ 0x92, 0x20, 0x41, 0x92, 0x9e, 0x80, 0x24, 0x24, 0x29, 0x00, 0x04, 0x00,
+ 0x10, 0x98, 0xcc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0x4f, 0x10, 0x01, 0x90, 0x24, 0x40, 0x12, 0xf0, 0x00, 0x24, 0x41, 0x0b,
+ 0xa9, 0x10, 0x00, 0x00, 0x04, 0xd9, 0x96, 0x0e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0x00, 0x92, 0x48, 0x02, 0x04, 0x09, 0xc0, 0x84, 0x8f,
+ 0x29, 0x2d, 0xf8, 0xa9, 0x02, 0x00, 0x00, 0x20, 0x90, 0xf4, 0x1e, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x24, 0x91, 0x04, 0x50, 0x22, 0x24,
+ 0x1b, 0x12, 0x7a, 0x48, 0xca, 0x03, 0x21, 0x10, 0x00, 0x00, 0x48, 0x93,
+ 0xff, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9e, 0x24, 0x92, 0x20,
+ 0x81, 0xda, 0x24, 0xc8, 0x16, 0xd0, 0xe7, 0x50, 0xd2, 0xbf, 0x03, 0x00,
+ 0x80, 0x00, 0x30, 0x29, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03,
+ 0x20, 0x80, 0x24, 0x41, 0x12, 0x2a, 0x41, 0xb2, 0x80, 0x33, 0x0e, 0x7e,
+ 0x88, 0x1c, 0x01, 0x00, 0xa0, 0x24, 0x69, 0x75, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0x82, 0x44, 0x11, 0x24, 0x09, 0x90, 0xa4, 0x4d, 0xd2, 0x92,
+ 0x9e, 0xd3, 0x83, 0x6b, 0x62, 0x00, 0x00, 0x10, 0x22, 0xff, 0x7f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x30, 0x42, 0x04, 0x92, 0x24, 0x6b, 0x53, 0x32,
+ 0x59, 0x90, 0x16, 0xfa, 0xb4, 0xf4, 0xff, 0x0f, 0x01, 0x00, 0x90, 0x68,
+ 0x4a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x90, 0x24, 0x11, 0x24,
+ 0x49, 0xda, 0x82, 0xc5, 0x92, 0xd2, 0xd0, 0x9e, 0x1e, 0x00, 0x78, 0x0a,
+ 0x00, 0x00, 0x05, 0xd2, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x02,
+ 0x44, 0xb2, 0x65, 0xea, 0x49, 0x9e, 0x2c, 0x4b, 0x1a, 0xd2, 0xeb, 0xe3,
+ 0xff, 0xc7, 0x09, 0x00, 0x20, 0x68, 0xff, 0xd6, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x0b, 0x90, 0x40, 0x92, 0x24, 0x09, 0x5f, 0xd2, 0x64, 0x59, 0x72,
+ 0x56, 0x7f, 0xfd, 0xdf, 0x1f, 0x12, 0x00, 0x20, 0x49, 0x92, 0xde, 0x01,
+ 0x00, 0x00, 0x00, 0x80, 0x41, 0x92, 0x4c, 0x92, 0x24, 0x25, 0xc9, 0x8b,
+ 0x2e, 0xcb, 0x92, 0x4b, 0x5a, 0x2f, 0x75, 0xf4, 0x04, 0x00, 0x00, 0x41,
+ 0xf6, 0x74, 0x01, 0x00, 0x00, 0x00, 0x40, 0x49, 0x02, 0x00, 0xba, 0xb6,
+ 0xfd, 0x49, 0xf8, 0x74, 0x6d, 0x4b, 0x72, 0xed, 0xdb, 0xff, 0xcf, 0x53,
+ 0x00, 0x00, 0x48, 0xb6, 0xd7, 0x03, 0x00, 0x00, 0x00, 0x60, 0x48, 0x10,
+ 0xc9, 0x93, 0x24, 0x00, 0x7b, 0xc3, 0xa6, 0x69, 0x58, 0x5a, 0xfb, 0xfa,
+ 0xa5, 0xbe, 0x16, 0x00, 0x00, 0x92, 0xa4, 0xfd, 0x03, 0x00, 0x00, 0x00,
+ 0x30, 0x01, 0x20, 0x5d, 0xa2, 0xfe, 0x7f, 0x01, 0x4f, 0x1a, 0xcd, 0x6b,
+ 0x6a, 0xa9, 0x5f, 0xff, 0xf3, 0x24, 0x01, 0x40, 0xc0, 0xb4, 0xf4, 0x03,
+ 0x00, 0x00, 0x00, 0x2c, 0x88, 0x84, 0x89, 0xb6, 0x00, 0x24, 0x7d, 0x69,
+ 0xf2, 0x34, 0xad, 0x99, 0x2d, 0xf7, 0xff, 0x9f, 0x4b, 0x00, 0x00, 0x92,
+ 0xa6, 0xad, 0x07, 0x00, 0x00, 0x00, 0x06, 0x91, 0x24, 0xe9, 0xa4, 0xfd,
+ 0xa5, 0xa9, 0x4b, 0x93, 0xe7, 0x34, 0x63, 0xf9, 0xfc, 0xd5, 0xef, 0x16,
+ 0x00, 0x40, 0x90, 0xb4, 0xbd, 0x07, 0x00, 0x00, 0x00, 0x6a, 0x80, 0x4c,
+ 0x96, 0xbe, 0x2d, 0xfd, 0x2f, 0x7c, 0x5e, 0x9c, 0x67, 0xad, 0xa5, 0xfd,
+ 0xff, 0xbf, 0x29, 0x00, 0x00, 0x92, 0x76, 0xed, 0x06, 0x00, 0x00, 0x00,
+ 0x05, 0x12, 0x48, 0x53, 0x25, 0x65, 0x25, 0xf4, 0xe5, 0xd3, 0x72, 0x9c,
+ 0x35, 0xdf, 0xf6, 0x7f, 0xf5, 0x56, 0x00, 0x00, 0x92, 0xa4, 0xed, 0x0f,
+ 0x00, 0x00, 0x80, 0x49, 0x20, 0x59, 0x38, 0xec, 0xff, 0xff, 0xad, 0x2f,
+ 0x5d, 0xd3, 0x33, 0xe6, 0x24, 0xed, 0xff, 0xdf, 0x2d, 0x01, 0x40, 0x80,
+ 0x24, 0xbd, 0x07, 0x00, 0x00, 0xc0, 0x48, 0x24, 0x49, 0x87, 0x37, 0x21,
+ 0xa0, 0xbd, 0xf4, 0x79, 0x4f, 0xc7, 0x9c, 0xde, 0xf6, 0xff, 0xff, 0x5b,
+ 0x08, 0x00, 0x92, 0xfc, 0xe9, 0x0e, 0x00, 0x00, 0x20, 0x89, 0x40, 0xd3,
+ 0xf4, 0x49, 0xff, 0xff, 0xe7, 0x2f, 0xcf, 0x79, 0x9c, 0x53, 0xb2, 0x35,
+ 0xff, 0xff, 0x37, 0x00, 0x40, 0x90, 0x24, 0xef, 0x0e, 0x00, 0x00, 0x30,
+ 0x91, 0x49, 0x32, 0x2d, 0xff, 0x6b, 0xb7, 0xbd, 0xbc, 0x3c, 0xef, 0x79,
+ 0xce, 0xde, 0xd6, 0xfd, 0xff, 0x9f, 0x00, 0x00, 0x92, 0xa6, 0xad, 0x0b,
+ 0x00, 0x00, 0x30, 0x11, 0x89, 0x8c, 0xcb, 0x5b, 0xba, 0xaf, 0xf6, 0xd7,
+ 0xe7, 0x35, 0xe7, 0x59, 0xb3, 0xfb, 0xff, 0xff, 0x7f, 0x04, 0x40, 0x80,
+ 0xe4, 0xb9, 0x1f, 0x00, 0x00, 0x48, 0x22, 0x91, 0x66, 0x79, 0xeb, 0xff,
+ 0xff, 0xdf, 0xbe, 0xbe, 0xe7, 0x8c, 0x75, 0x6b, 0x4a, 0xfa, 0xbf, 0x7f,
+ 0x00, 0x00, 0x82, 0x24, 0xef, 0x0e, 0x00, 0x00, 0x4c, 0x22, 0xb2, 0x79,
+ 0x5e, 0xfa, 0x5b, 0xa9, 0xfd, 0xeb, 0xf5, 0x9c, 0x3d, 0xc6, 0xcc, 0xee,
+ 0xed, 0x01, 0xf8, 0x00, 0x40, 0x82, 0xb6, 0xa9, 0x1b, 0x00, 0x00, 0x94,
+ 0x64, 0x66, 0x8e, 0xd3, 0x97, 0xfe, 0xff, 0xd7, 0xdf, 0x9f, 0x7b, 0xf3,
+ 0x3c, 0x35, 0x59, 0x6b, 0x00, 0x70, 0x00, 0x00, 0x40, 0xe4, 0xed, 0x1e,
+ 0x00, 0x00, 0x92, 0xc4, 0x34, 0xf3, 0xfc, 0xfd, 0x5f, 0xad, 0x7d, 0xfa,
+ 0x7a, 0xce, 0x8e, 0xb3, 0x76, 0x2f, 0xfd, 0x00, 0xe0, 0x04, 0x00, 0x9a,
+ 0x26, 0xaf, 0x1e, 0x00, 0x00, 0x13, 0x88, 0xcc, 0xb5, 0x3f, 0xbf, 0xff,
+ 0xff, 0xd7, 0xef, 0xef, 0xbd, 0x79, 0x6a, 0xde, 0xec, 0xab, 0x01, 0xc0,
+ 0x00, 0x00, 0x40, 0xb6, 0xbd, 0x1b, 0x00, 0x00, 0x05, 0x91, 0xeb, 0x5c,
+ 0xeb, 0xeb, 0xff, 0xff, 0xff, 0x7e, 0xef, 0x6b, 0xef, 0xcd, 0x99, 0xb3,
+ 0xe4, 0x07, 0x80, 0x00, 0x40, 0x49, 0xb2, 0xe5, 0x1a, 0x00, 0x80, 0x20,
+ 0x32, 0xb1, 0xe7, 0x79, 0x7f, 0xf7, 0xff, 0xfd, 0xeb, 0xbd, 0xfe, 0x2c,
+ 0x3d, 0x6b, 0xb6, 0xaf, 0x06, 0x80, 0x00, 0x00, 0x41, 0x96, 0xfe, 0x1e,
+ 0x00, 0x80, 0x44, 0xb2, 0x9b, 0xf9, 0xde, 0xff, 0xff, 0xff, 0x7f, 0xbf,
+ 0xf7, 0xbb, 0xb3, 0x77, 0xce, 0xce, 0xb6, 0x0d, 0x80, 0x01, 0x00, 0x49,
+ 0xf2, 0x94, 0x1f, 0x00, 0x40, 0x49, 0x44, 0xe6, 0x9e, 0x77, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xbf, 0xf7, 0x7e, 0xd6, 0xbc, 0xd9, 0xba, 0x3b, 0x80,
+ 0x00, 0x00, 0x64, 0x93, 0xf7, 0x1b, 0x00, 0x40, 0x89, 0xec, 0x7e, 0x67,
+ 0xbd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xce, 0xdb, 0x99, 0x33, 0x37,
+ 0xd3, 0x36, 0x80, 0x01, 0x80, 0x24, 0xda, 0xd6, 0x1e, 0x00, 0x20, 0x90,
+ 0x99, 0x99, 0x7b, 0xef, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbd, 0x37,
+ 0x63, 0xf3, 0x66, 0xdb, 0x7a, 0x80, 0x00, 0x00, 0x24, 0x59, 0xde, 0x1f,
+ 0x00, 0x60, 0x12, 0xb3, 0xf7, 0xdd, 0xfb, 0xfe, 0xff, 0xff, 0xff, 0xff,
+ 0xbf, 0xf7, 0xfe, 0x6e, 0xce, 0xdd, 0x6d, 0xd7, 0x80, 0x00, 0x80, 0x20,
+ 0xcb, 0xfb, 0x1f, 0x00, 0x10, 0x20, 0x6e, 0x66, 0x76, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xef, 0xde, 0xdb, 0x9b, 0x99, 0xb3, 0x5d, 0x6b, 0x81,
+ 0x00, 0x40, 0x96, 0x59, 0x6a, 0x1f, 0x00, 0x98, 0xc4, 0xe4, 0xdf, 0xff,
+ 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7b, 0x6f, 0x7b, 0x37, 0x7f,
+ 0xb3, 0xdd, 0x83, 0x00, 0x00, 0xb0, 0xed, 0xef, 0x1d, 0x00, 0x10, 0x88,
+ 0x9e, 0xdd, 0xcd, 0xbd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xed,
+ 0x6c, 0xe6, 0xcc, 0x76, 0x6d, 0xc1, 0x00, 0x40, 0x91, 0x24, 0x7b, 0x1f,
+ 0x00, 0x08, 0xd1, 0xf1, 0x66, 0x76, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xdf, 0xbd, 0xbf, 0xd9, 0xdd, 0xdd, 0xb6, 0x47, 0x00, 0x00, 0xd8,
+ 0xb4, 0xad, 0x1f, 0x00, 0x24, 0x24, 0x6f, 0xf6, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0xb7, 0x9d, 0x33, 0xd9, 0x96, 0x4e,
+ 0x00, 0x20, 0x49, 0xf7, 0xfd, 0x1e, 0x00, 0x48, 0xe4, 0xac, 0xb9, 0xdd,
+ 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xdd, 0x76, 0xb6,
+ 0xb7, 0xfd, 0x7a, 0x00, 0x00, 0x44, 0x96, 0xb7, 0x1f, 0x00, 0x02, 0x9a,
+ 0xbe, 0x6f, 0x77, 0xff, 0xff, 0x7f, 0x61, 0xd9, 0xff, 0xff, 0xff, 0xfd,
+ 0xdd, 0x66, 0xed, 0x66, 0x5b, 0x37, 0x00, 0x90, 0x64, 0xb9, 0xf6, 0x1f,
+ 0x00, 0x02, 0xc9, 0xf3, 0xee, 0xfd, 0xff, 0xff, 0x2f, 0x24, 0x4f, 0xfe,
+ 0xff, 0xff, 0x7f, 0x37, 0xdb, 0xcd, 0x7c, 0xff, 0x3a, 0x00, 0x88, 0x24,
+ 0xdb, 0xde, 0x1a, 0x00, 0x13, 0x31, 0x6f, 0xbb, 0xdf, 0xff, 0xff, 0x21,
+ 0xa0, 0x64, 0xf3, 0xff, 0xff, 0xe7, 0xff, 0x96, 0xbb, 0x9b, 0xa5, 0x1d,
+ 0x00, 0x60, 0x32, 0xe9, 0xdb, 0x0f, 0x00, 0x65, 0xe6, 0x3c, 0xfb, 0xf6,
+ 0xff, 0x7f, 0x10, 0xa4, 0xb5, 0x9d, 0xfe, 0xdf, 0xdf, 0xdd, 0x6d, 0x32,
+ 0xb3, 0x7d, 0x0d, 0x00, 0x0b, 0x93, 0x7c, 0x7b, 0x0f, 0x00, 0x89, 0xdc,
+ 0xb3, 0xed, 0xfb, 0xff, 0x1f, 0x10, 0x90, 0x92, 0xd9, 0xfe, 0x7f, 0xff,
+ 0x77, 0xdb, 0xee, 0x6e, 0xdb, 0x0e, 0x00, 0x20, 0xdd, 0x66, 0x6f, 0x0f,
+ 0x80, 0x91, 0x5a, 0xfb, 0xbe, 0xef, 0xff, 0x0f, 0x10, 0xda, 0x92, 0xee,
+ 0xff, 0xff, 0xff, 0xf7, 0xb7, 0xcd, 0xee, 0xde, 0x07, 0x00, 0x24, 0x49,
+ 0xb6, 0xed, 0x0f, 0x00, 0x12, 0x6b, 0xcd, 0xf3, 0xbe, 0xff, 0x07, 0x08,
+ 0x48, 0xda, 0x76, 0xb7, 0xff, 0xff, 0xdd, 0x6e, 0xba, 0x99, 0x65, 0x03,
+ 0x40, 0x92, 0xe4, 0xba, 0xbd, 0x0e, 0x80, 0x62, 0xed, 0x7d, 0x5f, 0xf7,
+ 0xff, 0x01, 0x08, 0x28, 0xc9, 0x26, 0xbb, 0xff, 0xff, 0xff, 0x99, 0xb7,
+ 0xbb, 0x7d, 0x03, 0x00, 0x89, 0x64, 0xdb, 0xf6, 0x07, 0x40, 0x0c, 0x35,
+ 0xe7, 0x79, 0xdd, 0xff, 0x01, 0x84, 0xa5, 0x7d, 0xba, 0xdd, 0xfe, 0x7f,
+ 0xbf, 0xbf, 0x6d, 0x76, 0xdb, 0x01, 0x00, 0x48, 0x36, 0xdb, 0xd6, 0x07,
+ 0xc0, 0x88, 0xb4, 0xb6, 0xbf, 0xff, 0x7f, 0x00, 0x0c, 0x24, 0x44, 0xdb,
+ 0xed, 0xff, 0xdf, 0xef, 0x6e, 0xdb, 0x6e, 0xb7, 0x00, 0x80, 0x44, 0x93,
+ 0xed, 0x5b, 0x07, 0x40, 0x91, 0xd2, 0xfa, 0xfc, 0xf6, 0x7f, 0x00, 0x02,
+ 0xb4, 0x35, 0xd9, 0xef, 0xff, 0xff, 0xfb, 0xef, 0xb6, 0xc9, 0xe4, 0x00,
+ 0x10, 0x24, 0xd9, 0x6d, 0xfb, 0x03, 0x00, 0x27, 0xfe, 0xd3, 0xd6, 0xdb,
+ 0x3f, 0x00, 0xa2, 0x94, 0xb4, 0xdb, 0x7c, 0xff, 0xff, 0xbf, 0xd9, 0xad,
+ 0xdb, 0x7d, 0x00, 0x40, 0x32, 0xd9, 0xb6, 0xef, 0x03, 0x60, 0xe4, 0x5a,
+ 0x5f, 0x5f, 0xff, 0x1f, 0x00, 0x02, 0x52, 0x92, 0xec, 0xb6, 0xff, 0xff,
+ 0xef, 0xff, 0x6d, 0xb6, 0x3b, 0x00, 0x28, 0x90, 0xcc, 0xbe, 0xfd, 0x03,
+ 0xa0, 0x88, 0xeb, 0xf9, 0xfd, 0xf5, 0x1f, 0x00, 0x82, 0x53, 0xbb, 0x6d,
+ 0xf7, 0xff, 0xf9, 0xff, 0x6f, 0xdb, 0x6d, 0x1b, 0x00, 0x04, 0xc9, 0x66,
+ 0xdb, 0x57, 0x03, 0xa0, 0x52, 0xaf, 0xa7, 0x97, 0xff, 0x0f, 0x00, 0x51,
+ 0x48, 0xda, 0x66, 0xdb, 0xff, 0xf8, 0xdf, 0xed, 0xbe, 0xed, 0x0e, 0x00,
+ 0x92, 0x64, 0x32, 0xeb, 0xf6, 0x01, 0x20, 0x63, 0xbd, 0xbc, 0xfc, 0xfa,
+ 0x0f, 0x00, 0x09, 0x20, 0x89, 0x3e, 0xff, 0xff, 0xe0, 0x7f, 0xdf, 0x6f,
+ 0xdb, 0x07, 0x00, 0x01, 0x24, 0xbb, 0xed, 0xfe, 0x01, 0xa0, 0xce, 0xf5,
+ 0xf6, 0xdb, 0xdf, 0x07, 0x00, 0x41, 0xad, 0x5f, 0xf2, 0xed, 0xff, 0xc0,
+ 0xff, 0xbf, 0xdd, 0x92, 0x03, 0x00, 0x44, 0xb2, 0xd9, 0x7d, 0xfb, 0x01,
+ 0xe0, 0xaa, 0xdf, 0x9b, 0x7f, 0xfb, 0x07, 0x80, 0x28, 0x21, 0x64, 0xbb,
+ 0x7f, 0x7f, 0x80, 0xff, 0xf6, 0xbb, 0xee, 0x03, 0x80, 0x22, 0x99, 0xed,
+ 0xb6, 0xff, 0x00, 0x90, 0xb8, 0x5e, 0x5b, 0x6b, 0xed, 0x03, 0x00, 0x01,
+ 0xa6, 0x6d, 0xdb, 0xf6, 0x7f, 0x00, 0xff, 0xff, 0xf6, 0xcd, 0x00, 0x40,
+ 0x10, 0xc9, 0x6c, 0xff, 0xf7, 0x00, 0xa0, 0xe3, 0x72, 0xeb, 0xef, 0xff,
+ 0x03, 0x80, 0xe0, 0x90, 0x24, 0xdb, 0xbd, 0x3f, 0x00, 0xfe, 0xdb, 0x6f,
+ 0xfb, 0x00, 0x00, 0x89, 0x4c, 0xb6, 0xd9, 0x7e, 0x00, 0x70, 0xaf, 0xaf,
+ 0x6f, 0xb5, 0xde, 0x03, 0x80, 0x94, 0x92, 0xb6, 0xf9, 0xf6, 0x3f, 0x00,
+ 0xfc, 0xbf, 0xdd, 0x7b, 0x00, 0x10, 0x48, 0x26, 0xb3, 0xdf, 0x7f, 0x00,
+ 0x70, 0xd8, 0xae, 0xfd, 0xff, 0xf7, 0x03, 0x80, 0x00, 0xd2, 0x36, 0xcf,
+ 0xdf, 0x3f, 0x00, 0xb8, 0x6d, 0xdf, 0x16, 0x00, 0x48, 0x44, 0xb2, 0xfb,
+ 0x6c, 0x3f, 0x00, 0x50, 0x75, 0xfd, 0xa5, 0xd5, 0xfe, 0x01, 0x40, 0xd1,
+ 0x12, 0xa2, 0x7d, 0xfb, 0x1f, 0x00, 0xf0, 0xff, 0xbf, 0x0d, 0x00, 0x20,
+ 0x12, 0x9b, 0xcd, 0xf6, 0x3f, 0x00, 0x90, 0xd5, 0xa7, 0xfd, 0x77, 0xab,
+ 0x03, 0x40, 0x1c, 0xc8, 0xbe, 0x6d, 0xfb, 0x1f, 0x00, 0xe0, 0xff, 0xee,
+ 0x07, 0x00, 0x04, 0x91, 0xc9, 0x7e, 0xbf, 0x1f, 0x00, 0x30, 0x57, 0xbf,
+ 0xa6, 0xde, 0xfd, 0x01, 0x40, 0x40, 0x6b, 0xd3, 0x6e, 0xef, 0x0f, 0x00,
+ 0xc0, 0xeb, 0x7d, 0x03, 0x00, 0x90, 0xc8, 0x6c, 0x76, 0xfb, 0x0f, 0x00,
+ 0x70, 0x5c, 0xe5, 0xf7, 0xfa, 0xeb, 0x01, 0x40, 0x50, 0x49, 0x92, 0xf4,
+ 0xfd, 0x0f, 0x00, 0xc0, 0xff, 0xdb, 0x01, 0x80, 0x44, 0x44, 0x66, 0xbb,
+ 0x6f, 0x0f, 0x00, 0xd0, 0xf1, 0x95, 0xf6, 0x6f, 0xad, 0x01, 0x40, 0x08,
+ 0x78, 0xdb, 0xb6, 0xef, 0x0f, 0x00, 0x00, 0xdf, 0xd6, 0x00, 0x00, 0x20,
+ 0x32, 0xb3, 0xdb, 0xfd, 0x0f, 0x00, 0x10, 0xd7, 0xf7, 0xb6, 0xd8, 0xeb,
+ 0x03, 0x20, 0x43, 0x27, 0xd9, 0xb6, 0xfd, 0x0f, 0x00, 0x00, 0xff, 0x7e,
+ 0x00, 0x40, 0x12, 0x93, 0xd9, 0xec, 0xb6, 0x07, 0x00, 0x70, 0x55, 0xdd,
+ 0xf6, 0x6f, 0xbb, 0x01, 0x40, 0x28, 0xa1, 0x6f, 0xb6, 0xb7, 0x0f, 0x00,
+ 0x00, 0xde, 0x1f, 0x00, 0x80, 0x88, 0xd8, 0xcc, 0x66, 0xff, 0x03, 0x00,
+ 0x70, 0xf4, 0xf5, 0xdb, 0xaa, 0xee, 0x01, 0x60, 0x28, 0x2d, 0x49, 0xf7,
+ 0xf6, 0x07, 0x00, 0x00, 0x7c, 0x0f, 0x00, 0x08, 0x48, 0x66, 0x6e, 0xfb,
+ 0xef, 0x03, 0x00, 0xd0, 0xd5, 0xdf, 0x52, 0xff, 0xda, 0x03, 0x20, 0xa3,
+ 0xa5, 0xd9, 0xb2, 0xff, 0x07, 0x00, 0x00, 0xf8, 0x07, 0x00, 0x20, 0x22,
+ 0x33, 0x37, 0xbf, 0xfd, 0x01, 0x00, 0x70, 0x5f, 0xf7, 0xfe, 0xab, 0x6b,
+ 0x02, 0xa0, 0xa8, 0xb4, 0x6d, 0xdf, 0xf6, 0x07, 0x00, 0x00, 0xf8, 0x01,
+ 0x00, 0x12, 0x33, 0x11, 0xd9, 0xdd, 0xff, 0x01, 0x00, 0x70, 0x75, 0xd5,
+ 0x52, 0xea, 0x8a, 0x03, 0x20, 0x84, 0x36, 0x69, 0xba, 0xdb, 0x07, 0x00,
+ 0x00, 0xf0, 0x01, 0x00, 0x81, 0xc8, 0xcc, 0xdd, 0xed, 0xff, 0x00, 0x00,
+ 0x60, 0xd5, 0xdf, 0xf6, 0xae, 0x6b, 0x03, 0x00, 0xa1, 0xa4, 0x6d, 0xdf,
+ 0xfe, 0x07, 0x00, 0x00, 0x60, 0x00, 0x40, 0x44, 0xc6, 0xcc, 0x64, 0xb7,
+ 0xfd, 0x00, 0x00, 0xe0, 0x55, 0xf7, 0xd6, 0xea, 0xba, 0x07, 0x20, 0x94,
+ 0x94, 0x6d, 0xfb, 0xdb, 0x07, 0x00, 0x00, 0x20, 0x00, 0x20, 0x20, 0x32,
+ 0x76, 0x77, 0xff, 0x7f, 0x00, 0x00, 0x60, 0x7d, 0xd5, 0xb6, 0x3f, 0xaf,
+ 0x06, 0xa0, 0xa4, 0x95, 0x6c, 0x9b, 0xee, 0x07, 0x00, 0x00, 0x18, 0x00,
+ 0x10, 0x92, 0x15, 0x73, 0xbb, 0xd9, 0x3f, 0x00, 0x00, 0xe0, 0xf5, 0xff,
+ 0xf7, 0x6a, 0xa9, 0x06, 0x80, 0xa2, 0xb4, 0x6d, 0xfb, 0xfb, 0x07, 0x00,
+ 0x00, 0x04, 0x00, 0x84, 0x88, 0xc8, 0x99, 0xdd, 0xff, 0x3f, 0x00, 0x00,
+ 0xe0, 0x8b, 0xff, 0x96, 0x6a, 0xb6, 0x0a, 0xa0, 0x94, 0x96, 0x64, 0xdb,
+ 0xee, 0x07, 0x00, 0x00, 0x03, 0x08, 0x20, 0x60, 0x66, 0xec, 0xee, 0xb6,
+ 0x1d, 0x00, 0x00, 0xc0, 0x7e, 0xa5, 0xf4, 0xab, 0x55, 0x0d, 0x20, 0xe7,
+ 0xd4, 0x6d, 0xdb, 0xfb, 0x07, 0x00, 0x80, 0x00, 0x00, 0x09, 0x12, 0x33,
+ 0x67, 0x77, 0xff, 0x0f, 0x00, 0x00, 0xc0, 0xfa, 0xff, 0xb7, 0x7a, 0x55,
+ 0x19, 0x90, 0x91, 0xd4, 0x64, 0xdb, 0xee, 0x07, 0x00, 0x40, 0x00, 0x81,
+ 0x04, 0x88, 0x91, 0x3b, 0xbb, 0xfd, 0x0f, 0x00, 0x00, 0xc0, 0xab, 0xbf,
+ 0xed, 0x4e, 0xbb, 0x32, 0x20, 0x94, 0x96, 0x6c, 0xff, 0xfa, 0x03, 0x00,
+ 0x30, 0x40, 0x20, 0x20, 0x64, 0xcc, 0xdc, 0xdd, 0xff, 0x07, 0x00, 0x00,
+ 0xc0, 0xeb, 0xea, 0xfd, 0xd5, 0xaa, 0x2a, 0x20, 0xd7, 0xb0, 0x6d, 0x93,
+ 0xef, 0x07, 0x00, 0x08, 0x00, 0x08, 0x01, 0x23, 0xee, 0xee, 0xee, 0xfb,
+ 0x03, 0x00, 0x00, 0xc0, 0xfe, 0xff, 0x2d, 0xdd, 0x6a, 0x49, 0xd0, 0x90,
+ 0x9a, 0x64, 0xdf, 0xea, 0x07, 0x00, 0x03, 0x80, 0x40, 0x8c, 0x98, 0x33,
+ 0xb3, 0xbb, 0xff, 0x01, 0x00, 0x00, 0xc0, 0xa5, 0x7b, 0x6d, 0xa7, 0x56,
+ 0xc5, 0xa0, 0x94, 0x94, 0x6f, 0xd3, 0xbb, 0x07, 0x80, 0x10, 0x0c, 0x12,
+ 0x40, 0xc6, 0xb9, 0xdb, 0xfb, 0xfd, 0x01, 0x00, 0x00, 0x80, 0x97, 0xee,
+ 0xdf, 0xba, 0x54, 0x1a, 0xa1, 0xe5, 0xd2, 0x64, 0x7e, 0xee, 0x07, 0x60,
+ 0x02, 0x80, 0x00, 0x31, 0x62, 0xcc, 0xdc, 0xee, 0x7f, 0x00, 0x00, 0x00,
+ 0x80, 0xff, 0xff, 0xdb, 0xaa, 0xb5, 0x8a, 0x86, 0x98, 0x96, 0x6d, 0x9b,
+ 0xea, 0x07, 0x98, 0x00, 0x22, 0x44, 0x88, 0x39, 0x77, 0x77, 0xff, 0x7f,
+ 0x00, 0x00, 0x00, 0x80, 0x7d, 0x77, 0xba, 0x7b, 0x2d, 0x55, 0x3c, 0xa6,
+ 0xb4, 0x6c, 0xf6, 0xaf, 0x07, 0x07, 0x90, 0x88, 0x20, 0x42, 0x9c, 0xbb,
+ 0xbb, 0xbb, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x4b, 0xbd, 0xbf, 0x55, 0x53,
+ 0xa5, 0xb2, 0xa1, 0xb4, 0xc9, 0x9f, 0xda, 0xcf, 0x28, 0x24, 0x42, 0x08,
+ 0x31, 0xe6, 0xcc, 0xdd, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xff, 0xef,
+ 0xb7, 0xbd, 0xde, 0x12, 0xd1, 0xac, 0x95, 0x4d, 0xf2, 0x56, 0x9f, 0x88,
+ 0x80, 0x10, 0xc2, 0x9c, 0x73, 0x77, 0xef, 0xfe, 0x7f, 0x00, 0x00, 0x00,
+ 0x00, 0xbf, 0xfb, 0xed, 0xeb, 0x35, 0x95, 0x72, 0xa2, 0x35, 0xcd, 0xb6,
+ 0xd6, 0x2f, 0x21, 0x24, 0x04, 0x31, 0xc6, 0x98, 0x33, 0xf7, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0xd6, 0x6a, 0x7f, 0x5b, 0xab, 0x2d, 0x28, 0x23,
+ 0x65, 0xd9, 0xb6, 0x55, 0x5f, 0x88, 0x08, 0x43, 0x0c, 0x61, 0xde, 0xdd,
+ 0xfb, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x76, 0xff, 0x4d, 0xd7, 0x4d,
+ 0x4a, 0xa5, 0x29, 0x2d, 0xdb, 0xbe, 0x55, 0x1f, 0x22, 0x42, 0x28, 0xc2,
+ 0x39, 0xe7, 0xee, 0xee, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x7f,
+ 0xfb, 0xb6, 0xb6, 0x95, 0x70, 0x2e, 0xa5, 0xd9, 0x24, 0x5d, 0x5f, 0x8a,
+ 0x28, 0x88, 0x31, 0x9e, 0x39, 0x73, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0x00, 0xec, 0xb7, 0xdf, 0x6c, 0xb5, 0x65, 0x26, 0xa3, 0x39, 0x9b, 0xfc,
+ 0x85, 0x5d, 0x21, 0x04, 0x63, 0x1c, 0xe6, 0xdd, 0xbd, 0xfb, 0xff, 0xff,
+ 0x01, 0x00, 0x00, 0x00, 0xb8, 0xfa, 0xb6, 0x6f, 0x4d, 0x9a, 0x28, 0x59,
+ 0x4d, 0xd3, 0x2f, 0xf5, 0x3f, 0x8c, 0xd1, 0x18, 0xc6, 0x31, 0xf6, 0xdd,
+ 0xfe, 0xff, 0xfe, 0x01, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xef, 0xb9, 0xb6,
+ 0x25, 0xe1, 0x4d, 0x69, 0xba, 0x6c, 0xad, 0x3c, 0x41, 0x14, 0x84, 0xe9,
+ 0x9e, 0x37, 0xf7, 0xff, 0xff, 0xfb, 0x03, 0x00, 0x00, 0x00, 0x70, 0x5d,
+ 0x3d, 0x9f, 0x3d, 0x6d, 0x26, 0x52, 0x59, 0xb6, 0x6d, 0xab, 0x7f, 0x14,
+ 0x82, 0xe1, 0x39, 0xe6, 0xdd, 0xfb, 0xff, 0xbf, 0xff, 0x01, 0x00, 0x00,
+ 0x00, 0xf0, 0xf6, 0x6f, 0x77, 0xcd, 0x92, 0xd0, 0x52, 0x4b, 0xb3, 0x49,
+ 0x0b, 0x3a, 0x41, 0x61, 0x38, 0x9e, 0x73, 0xee, 0xdc, 0xff, 0xff, 0xfd,
+ 0x03, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xd7, 0x65, 0xda, 0x66, 0x63, 0x9d,
+ 0xf2, 0x36, 0x7b, 0x6a, 0x7f, 0x14, 0x18, 0x8e, 0xe7, 0xd9, 0x7b, 0xff,
+ 0xff, 0xef, 0xff, 0x03, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xdd, 0xb6,
+ 0xc9, 0x4c, 0x46, 0x9a, 0x64, 0xcb, 0x5b, 0xed, 0x06, 0xc6, 0xe3, 0x71,
+ 0xde, 0xbd, 0xff, 0xff, 0x7f, 0xff, 0x07, 0x00, 0x00, 0x00, 0xc0, 0x7f,
+ 0x7f, 0xff, 0x59, 0x37, 0x75, 0xbb, 0x96, 0x66, 0xdb, 0x56, 0xf7, 0xe0,
+ 0xf2, 0x74, 0x9e, 0x77, 0xef, 0xfd, 0xff, 0xeb, 0xed, 0x03, 0x00, 0x00,
+ 0x00, 0xc0, 0xea, 0xdf, 0xb3, 0xdb, 0xde, 0xc6, 0x81, 0xb0, 0x6c, 0xba,
+ 0xb4, 0xf6, 0x38, 0x18, 0x3c, 0xe7, 0x9c, 0xfb, 0xff, 0x7f, 0xff, 0xff,
+ 0x07, 0x00, 0x00, 0x00, 0x80, 0xff, 0xf7, 0x6e, 0x66, 0xd9, 0x99, 0xac,
+ 0xa4, 0xcd, 0x96, 0xa5, 0xea, 0x03, 0xa7, 0xcf, 0x79, 0xef, 0xfd, 0xff,
+ 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfd, 0xef, 0xdf,
+ 0x6f, 0xef, 0x72, 0x65, 0xd9, 0xb6, 0xad, 0xe8, 0xc1, 0xe1, 0xf1, 0xbe,
+ 0x7b, 0xef, 0xff, 0xdf, 0x7a, 0xfb, 0x07, 0x00, 0x00, 0x00, 0x00, 0xfe,
+ 0x5f, 0xdd, 0x9d, 0xac, 0x99, 0x84, 0x29, 0xcd, 0x3c, 0x4f, 0x9d, 0x7d,
+ 0x3c, 0x9e, 0xe7, 0xbe, 0xff, 0xff, 0xff, 0xff, 0xef, 0x0f, 0x00, 0x00,
+ 0x00, 0x00, 0xfe, 0xff, 0x77, 0x7b, 0x33, 0xe7, 0x5a, 0x49, 0x9b, 0x65,
+ 0x59, 0x75, 0x07, 0x97, 0xf7, 0xbb, 0xef, 0xff, 0xff, 0xdb, 0xfe, 0xff,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xf7, 0x3f, 0xe7, 0xcf, 0x9c, 0x51,
+ 0x4d, 0xb0, 0x6d, 0x4b, 0xc9, 0xd3, 0xf5, 0x79, 0xfe, 0xfb, 0xff, 0xff,
+ 0xdb, 0xda, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xef, 0xde,
+ 0xdd, 0xf3, 0x4d, 0x52, 0x36, 0xcb, 0xd2, 0x3a, 0x7e, 0x3c, 0xde, 0xe7,
+ 0xbe, 0xff, 0x7f, 0xda, 0xff, 0xdf, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf8,
+ 0xff, 0xfb, 0xdd, 0x73, 0x8f, 0xa5, 0x9a, 0xe6, 0xd9, 0xb6, 0xe2, 0x4e,
+ 0xc7, 0xf7, 0xfd, 0xff, 0xff, 0xff, 0xf7, 0xf6, 0xff, 0x0f, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0xff, 0xff, 0x7f, 0xee, 0x79, 0xb2, 0xb2, 0x2c, 0x9f,
+ 0xb6, 0x54, 0xfe, 0xfb, 0x79, 0xbf, 0xff, 0xff, 0x5f, 0xda, 0xff, 0xfa,
+ 0x0f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xf7, 0xbf, 0xe7, 0x4b,
+ 0xb4, 0x69, 0xd3, 0x2c, 0x25, 0xbd, 0xbc, 0xcf, 0xf7, 0xfd, 0xff, 0xd7,
+ 0xf6, 0xfe, 0xdf, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xbf, 0x9d,
+ 0xf1, 0x3e, 0x57, 0x25, 0xcb, 0xb6, 0x6d, 0xa9, 0xb5, 0xef, 0xfb, 0xff,
+ 0xff, 0xff, 0xd5, 0xda, 0xd6, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0xff, 0xff, 0xfb, 0xcf, 0xf5, 0x25, 0x65, 0xd9, 0x66, 0x5b, 0x4a, 0xfa,
+ 0xf9, 0x7e, 0xff, 0xff, 0xff, 0xf6, 0xd6, 0xdf, 0xfa, 0x0f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xfe, 0xff, 0xef, 0x3e, 0xf7, 0x9f, 0x5b, 0x92, 0x6c,
+ 0xdb, 0x52, 0xe5, 0xbe, 0xdf, 0xff, 0xff, 0xbf, 0x51, 0xda, 0xfa, 0x7f,
+ 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7b, 0x9f, 0xe7,
+ 0x4c, 0xb3, 0x4d, 0xd3, 0x54, 0xd9, 0xe7, 0xfb, 0xff, 0xff, 0x5f, 0xdc,
+ 0xfa, 0xdf, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x7f,
+ 0xe7, 0xf9, 0x3a, 0xd3, 0xa6, 0xe9, 0xb6, 0xa5, 0xca, 0xf9, 0xfd, 0xff,
+ 0xff, 0x83, 0x42, 0xd2, 0xff, 0xfb, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf0, 0xff, 0xfd, 0xbf, 0xef, 0x4f, 0xd5, 0x64, 0xdb, 0x26, 0x4d, 0x30,
+ 0x7f, 0xff, 0xff, 0xff, 0x91, 0xda, 0xdb, 0xda, 0xdf, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0xff, 0xbf, 0xff, 0x7d, 0xbe, 0xb5, 0x6d, 0x97,
+ 0x6d, 0x93, 0x56, 0xdf, 0xff, 0xff, 0x7f, 0x81, 0x4a, 0xda, 0x7f, 0xff,
+ 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xef, 0xeb, 0xbb,
+ 0xa6, 0x4d, 0x73, 0xcd, 0x92, 0xaa, 0xfe, 0xff, 0xff, 0x1f, 0x01, 0x6a,
+ 0x5b, 0xfb, 0xfb, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
+ 0xfd, 0xbf, 0x5f, 0x3b, 0xdb, 0x36, 0xbb, 0x26, 0x4c, 0xf9, 0xff, 0xff,
+ 0x0f, 0xa3, 0x2a, 0xe9, 0x7f, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xee, 0xff, 0xff, 0xfe, 0xfe, 0xcc, 0x91, 0xec, 0x93, 0x6d, 0x93,
+ 0xf2, 0xff, 0xff, 0x03, 0x00, 0x6a, 0x6d, 0x6f, 0xff, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xf7, 0x6f, 0x76, 0xb6, 0xcd,
+ 0x76, 0xc9, 0x2a, 0xe9, 0xff, 0xff, 0x00, 0x02, 0x24, 0xed, 0xf9, 0xed,
+ 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xdf, 0xff,
+ 0xd9, 0x66, 0x9b, 0x6c, 0x93, 0x54, 0xc5, 0xff, 0x3f, 0x00, 0x01, 0x95,
+ 0xb5, 0xaf, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
+ 0xff, 0xff, 0xfd, 0xae, 0x7d, 0xde, 0x6d, 0xf6, 0xa1, 0x8a, 0xff, 0x0f,
+ 0x00, 0x81, 0x90, 0xb4, 0xfd, 0xfd, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xcd, 0xb2, 0xdb, 0x2c, 0xcb,
+ 0x54, 0xfe, 0x01, 0x00, 0x01, 0xd2, 0xb6, 0xb7, 0xff, 0x0f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x39, 0xdb, 0x76,
+ 0xb3, 0x4b, 0xb6, 0x0a, 0xfe, 0x00, 0x00, 0x01, 0x48, 0xda, 0xfe, 0xff,
+ 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff,
+ 0xcf, 0xb9, 0x6d, 0xb6, 0xd9, 0xa5, 0x75, 0x1c, 0x00, 0x80, 0x80, 0x20,
+ 0xdb, 0xda, 0xbe, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
+ 0xff, 0xff, 0xff, 0x77, 0x96, 0xd9, 0x26, 0xb3, 0x4d, 0x82, 0x11, 0x00,
+ 0x80, 0x80, 0x24, 0x6d, 0xff, 0xf7, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xbb, 0x67, 0xdb, 0xdd, 0x36, 0xd9,
+ 0x54, 0x60, 0x00, 0xc0, 0x00, 0x92, 0x65, 0x6b, 0xff, 0x0f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x4f, 0x7d, 0x96,
+ 0xd9, 0x6c, 0x36, 0xad, 0xc2, 0x00, 0x60, 0x00, 0xc8, 0xb6, 0x6d, 0xff,
+ 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff,
+ 0xff, 0xc8, 0x76, 0xbb, 0xcb, 0x64, 0x52, 0x02, 0x03, 0x10, 0x00, 0x64,
+ 0xda, 0xff, 0xfb, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0xff, 0xff, 0x5f, 0xd7, 0x4d, 0x33, 0x99, 0xdd, 0x96, 0x04, 0x2c,
+ 0x1c, 0x40, 0x22, 0xdb, 0xb6, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xdf, 0xb5, 0xed, 0xe6, 0x36, 0x9b,
+ 0x6c, 0x29, 0xf0, 0x03, 0x00, 0x99, 0x6c, 0xfb, 0xfd, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x7f, 0x35, 0xbb,
+ 0xec, 0x76, 0x33, 0x91, 0x02, 0x00, 0x00, 0x00, 0x64, 0x67, 0xdf, 0xff,
+ 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
+ 0xbf, 0x6f, 0x9b, 0x9d, 0xc9, 0xce, 0x36, 0x49, 0x00, 0x00, 0x00, 0x93,
+ 0xb1, 0xdd, 0xfe, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x40, 0xff, 0x6a, 0x76, 0xbb, 0xdd, 0xd9, 0x64, 0x12, 0x01,
+ 0x00, 0x40, 0x98, 0xdd, 0x6d, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xdf, 0x66, 0x73, 0x33, 0xbb,
+ 0x9d, 0x4d, 0x00, 0x00, 0x00, 0x63, 0xe6, 0xf6, 0xff, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xed, 0xfd,
+ 0xee, 0xee, 0x36, 0x73, 0x2b, 0x04, 0x00, 0xa0, 0x38, 0x75, 0xbf, 0xff,
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x7f, 0xd9, 0xec, 0xce, 0x66, 0x66, 0x66, 0x22, 0x04, 0x00, 0xc6,
+ 0x99, 0xbb, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x5e, 0xb3, 0xdb, 0xb9, 0xcd, 0xc9, 0x88, 0x89,
+ 0x00, 0x68, 0x31, 0xee, 0xdd, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xbe, 0xbb, 0x9b, 0x3f,
+ 0xbb, 0x33, 0x23, 0x04, 0x00, 0x8c, 0xf3, 0xee, 0xff, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbc, 0x67,
+ 0x76, 0x77, 0xb2, 0x66, 0xce, 0x0c, 0xd1, 0xd6, 0xe3, 0x79, 0xf7, 0xff,
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf8, 0xfd, 0xef, 0xe6, 0xee, 0xce, 0x9c, 0x31, 0x16, 0x00, 0x3c,
+ 0x9e, 0xfb, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x78, 0x9f, 0xdb, 0xdc, 0x9d, 0x99, 0x33, 0xc6,
+ 0xc1, 0xff, 0x8f, 0xe7, 0xbb, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf7, 0xbd, 0xbb, 0x33,
+ 0x7b, 0xee, 0x18, 0x1e, 0x50, 0xf0, 0xf9, 0xfe, 0xff, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x7b,
+ 0xf7, 0x77, 0xf7, 0xe6, 0x9c, 0xe3, 0xf0, 0x4d, 0xff, 0x7c, 0xef, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc0, 0xdf, 0x76, 0x7f, 0xcf, 0x9e, 0x73, 0x8f, 0x07, 0xff, 0x0b,
+ 0xdf, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0xee, 0xcd, 0xdd, 0x9d, 0x7b, 0xf7, 0x7c,
+ 0x7a, 0x00, 0xf0, 0xe7, 0xfd, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x7f, 0xbf, 0xdd, 0x7b,
+ 0x6b, 0x9e, 0xf3, 0xe1, 0xff, 0xff, 0x7d, 0xff, 0x7f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xee,
+ 0xb7, 0xbb, 0x7b, 0xee, 0x79, 0x8f, 0x0f, 0xfa, 0x2f, 0xff, 0xf7, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7e, 0xff, 0x77, 0xef, 0xdd, 0x77, 0x7c, 0xfe, 0x02, 0xe8,
+ 0xcf, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xef, 0xee, 0xdd, 0xb3, 0xcf, 0xf3,
+ 0xf1, 0xff, 0xff, 0xf9, 0xfe, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfb, 0xff, 0xbf,
+ 0xef, 0xbe, 0xcf, 0x8f, 0xfe, 0x5f, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
+ 0xbf, 0xbb, 0xf7, 0xde, 0x79, 0x3e, 0xff, 0x52, 0xd2, 0xdf, 0xff, 0x0f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0xef, 0xef, 0xef, 0x3c, 0xef, 0xf9, 0xf8, 0xff, 0xff,
+ 0xf7, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xee, 0xdc, 0xf7, 0xfe, 0xe7,
+ 0x97, 0xfe, 0xff, 0xfe, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbf,
+ 0xef, 0xbf, 0x3e, 0xff, 0xda, 0xf6, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xfe, 0xbf, 0xf7, 0xfe, 0xf7, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xfe, 0xff, 0xde, 0xbd, 0xef, 0xfb, 0xd7, 0xff, 0xbf,
+ 0xfd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xf7, 0x7d, 0xbf,
+ 0xff, 0xd2, 0xf6, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xbf,
+ 0xef, 0xfb, 0xfd, 0xfd, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0xff, 0xef, 0xbe, 0xf7, 0xef, 0xef, 0xff, 0xff, 0xff, 0x3f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfb, 0xdf, 0xbf, 0xff, 0xff, 0xff,
+ 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff,
+ 0xfe, 0xff, 0xfb, 0xf7, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf0, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xfd, 0xff, 0xff, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xfc, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
+ 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
diff --git a/test/extended_color.c b/test/extended_color.c
new file mode 100644
index 0000000..746c035
--- /dev/null
+++ b/test/extended_color.c
@@ -0,0 +1,260 @@
+/****************************************************************************
+ * Copyright 2018-2020,2022 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.                                                           *
+ ****************************************************************************/
+/*
+ * $Id: extended_color.c,v 1.20 2022/12/10 22:28:50 tom Exp $
+ */
+
+#include <test.priv.h>
+
+#if USE_EXTENDED_COLOR
+
+#define SHOW(n) ((n) == ERR ? "ERR" : "OK")
+
+#if USE_SP_FUNCS
+static bool opt_s = FALSE;
+#define if_opt_s(a,b) (opt_s ? (a) : (b))
+#else
+#define if_opt_s(a,b) (b)
+#endif
+
+static void
+failed(const char *name)
+{
+    printw("...%s failed", name);
+    getch();
+    endwin();
+    ExitProgram(EXIT_FAILURE);
+}
+
+static void
+do_pair_content(SCREEN *sp, int pair)
+{
+    int i, f, b;
+
+    (void) sp;
+    i = if_opt_s(extended_pair_content_sp(sp, pair, &f, &b),
+		 extended_pair_content(0, &f, &b));
+    if (i != OK)
+	failed("pair_content");
+    printw("pair %d contains (%d,%d)\n", pair, f, b);
+    getch();
+}
+
+static void
+do_init_pair(SCREEN *sp, int pair, int fg, int bg)
+{
+    int i;
+
+    (void) sp;
+    i = if_opt_s(init_extended_pair_sp(sp, pair, fg, bg),
+		 init_extended_pair(pair, fg, bg));
+    if (i != OK)
+	failed("init_pair");
+}
+
+static void
+do_init_color(SCREEN *sp, int color, int adjust)
+{
+    int r, g, b;
+    int i;
+
+    (void) sp;
+    i = if_opt_s(extended_color_content_sp(sp, color, &r, &g, &b),
+		 extended_color_content(color, &r, &g, &b));
+    if (i != OK)
+	failed("color_content");
+
+    r = (adjust + 1000 + r) % 1000;
+    g = (adjust + 1000 + g) % 1000;
+    b = (adjust + 1000 + b) % 1000;
+
+    i = if_opt_s(init_extended_color_sp(sp, color, r, g, b),
+		 init_extended_color(color, r, g, b));
+    if (i != OK)
+	failed("init_color");
+}
+
+static void
+do_color_set(const char *expected, int pair)
+{
+    int i = color_set((short) pair, (void *) &pair);
+    printw("%s (%s)\n", expected, SHOW(i));
+    if (i != OK)
+	failed("color_set");
+    getch();
+}
+
+static void
+show_1_rgb(SCREEN *sp, const char *name, int color, int y, int x)
+{
+    int r, g, b;
+    int i;
+
+    (void) sp;
+    i = if_opt_s(extended_color_content_sp(sp, color, &r, &g, &b),
+		 extended_color_content(color, &r, &g, &b));
+    wmove(stdscr, y, x);
+    if (i == OK) {
+	printw("%-8s %3d/%3d/%3d", name, r, g, b);
+    } else {
+	printw("%-8s %s", name, SHOW(i));
+    }
+}
+
+static void
+show_rgb(SCREEN *sp)
+{
+    int y, x;
+    getyx(stdscr, y, x);
+    show_1_rgb(sp, "RED", COLOR_RED, y + 1, x);
+    show_1_rgb(sp, "GREEN", COLOR_GREEN, y + 2, x);
+    show_1_rgb(sp, "BLUE", COLOR_BLUE, y + 3, x);
+    wmove(stdscr, y, x);
+}
+
+static void
+usage(int ok)
+{
+    static const char *tbl[] =
+    {
+	"Usage: extended_color"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -s       use sp-funcs"
+    };
+    size_t n;
+    for (n = 0; n < SIZEOF(tbl); ++n) {
+	fprintf(stderr, "%s\n", tbl[n]);
+    }
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+    int i;
+    SCREEN *sp;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "s")) != -1) {
+	switch (ch) {
+#if USE_SP_FUNCS
+	case 's':
+	    opt_s = TRUE;
+	    break;
+#endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+
+    setlocale(LC_ALL, "");
+    slk_init(1);
+    sp = newterm(NULL, stdout, stdin);
+    cbreak();
+    noecho();
+
+    if (!has_colors()) {
+	endwin();
+	fprintf(stderr, "This demo requires a color terminal\n");
+	ExitProgram(EXIT_FAILURE);
+    }
+
+    start_color();
+
+    do_pair_content(sp, 0);
+
+    printw("Initializing pair 1 to red/black\n");
+    do_init_pair(sp, 1, COLOR_RED, COLOR_BLACK);
+    do_color_set("RED/BLACK", 1);
+
+    printw("Initializing pair 2 to white/blue\n");
+    do_init_pair(sp, 2, COLOR_WHITE, COLOR_BLUE);
+    do_color_set("WHITE/BLUE", 2);
+
+    printw("Initializing pair 3 to green/black\n");
+    do_init_pair(sp, 3, COLOR_GREEN, COLOR_BLACK);
+    do_color_set("GREEN/BLACK", 3);
+
+    printw("Resetting colors to pair 0\n");
+    do_color_set("Default Colors", 0);
+
+    printw("Resetting colors to pair 1\n");
+    do_color_set("RED/BLACK", 1);
+
+    printw("Drawing soft-key tabs with pair 2\n");
+    slk_attrset(A_BOLD);	/* reverse-video is hard to see */
+    (void) if_opt_s(extended_slk_color_sp(sp, 2),
+		    extended_slk_color(2));
+    for (i = 1; i <= 8; ++i) {
+	char temp[80];
+	_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "(SLK-%d)", i);
+	slk_set(i, temp, 0);
+    }
+    slk_touch();
+    slk_noutrefresh();
+
+    i = if_opt_s(can_change_color_sp(sp),
+		 can_change_color());
+    if (i) {
+	do_color_set("Default Colors", 0);
+	printw("Press any key to stop...\n");
+	nodelay(stdscr, TRUE);
+	while (getch() == ERR) {
+	    show_rgb(sp);
+	    do_init_color(sp, COLOR_RED, 1);
+	    do_init_color(sp, COLOR_BLUE, -1);
+	    napms(50);
+	}
+	printw("...done");
+	nodelay(stdscr, FALSE);
+	getch();
+    }
+
+    endwin();
+
+    ExitProgram(EXIT_SUCCESS);
+}
+
+#else
+int
+main(void)
+{
+    printf("This program requires the ncurses extended color/pair functions\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
diff --git a/test/filter.c b/test/filter.c
index ab2d856..b744456 100644
--- a/test/filter.c
+++ b/test/filter.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019-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            *
@@ -27,15 +28,10 @@
  ****************************************************************************/
 
 /*
- * Author:  Thomas E. Dickey <dickey@clark.net> 1998
+ * Author:  Thomas E. Dickey 1998
  *
- * $Id: filter.c,v 1.16 2014/08/09 22:35:51 tom Exp $
- */
-#include <test.priv.h>
-
-#if HAVE_FILTER
-
-/*
+ * $Id: filter.c,v 1.38 2022/12/04 00:40:11 tom Exp $
+ *
  * An example of the 'filter()' function in ncurses, this program prompts
  * for commands and executes them (like a command shell).  It illustrates
  * how ncurses can be used to implement programs that are not full-screen.
@@ -46,53 +42,289 @@
  * reset_shell_mode() and reset_prog_mode() functions, we could invoke endwin()
  * and refresh(), but that does not work any better.
  */
+#define NEED_KEY_EVENT
+#include <test.priv.h>
+
+#if HAVE_FILTER
+
+#include <time.h>
 
 static int
-new_command(char *buffer, int length, int underline)
+show_prompt(int underline, bool clocked)
 {
-    int code;
+    int limit = COLS;
 
-    attron(A_BOLD);
-    printw("Command: ");
+    move(0, 0);
+    attrset(A_NORMAL);
+    clrtoeol();
+    attrset(A_BOLD);
+    addstr("Command: ");
+
+    limit -= getcurx(stdscr);
+
+    if (clocked) {
+	if (limit >= 3) {
+	    time_t now = time((time_t *) 0);
+	    struct tm *my = localtime(&now);
+	    char buffer[80];
+	    int skip, y, x;
+	    int margin;
+
+	    _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) "%02d:%02d:%02d",
+			my->tm_hour,
+			my->tm_min,
+			my->tm_sec);
+
+	    if (limit > 9) {
+		skip = 0;
+	    } else if (limit > 6) {
+		skip = 3;
+	    } else {
+		skip = 6;
+	    }
+	    /*
+	     * Write the clock message on the right-margin so we can show the
+	     * results of resizing the screen.
+	     */
+	    getyx(stdscr, y, x);
+	    margin = (int) strlen(buffer) - skip;
+	    limit -= margin;
+	    move(0, COLS - margin);
+	    addstr(buffer);
+	    move(y, x);
+	}
+    }
     attron(underline);
-    code = getnstr(buffer, length);
-    /*
-     * If this returns anything except ERR/OK, it would be one of ncurses's
-     * extensions.  Fill the buffer with something harmless that the shell
-     * will execute as a comment.
-     */
+    return limit;
+}
+
+static int
+new_command(char *buffer, int length, int underline, bool clocked, bool polled)
+{
+    int code = OK;
+
+    if (polled) {
+	bool done = FALSE;
+	bool first = TRUE;
+	int y = 0, x = 0;
+	int n;
+	int mark = 0;
+	int used = 0;
+	const int gap = 2;
+
+	timeout(20);		/* no one types 50CPS... */
+	while (!done) {
+	    int limit;
+	    int ch = getch();
+
+	    buffer[used] = '\0';
+
+	    limit = show_prompt(underline, clocked);
+	    if (first) {
+		getyx(stdscr, y, x);
+		first = FALSE;
+	    } else {
+		int left = 0;
+
+		/*
+		 * if the screen is too narrow to show the whole buffer,
+		 * shift the editing point left/right as needed.
+		 */
+		move(y, x);
+		if ((used + gap) > limit) {
+		    while ((mark - left + gap) > limit) {
+			left += limit / 2;
+		    }
+		}
+		printw("%.*s", limit, buffer + left);
+		move(y, x + mark - left);
+	    }
+
+	    switch (ch) {
+	    case ERR:
+		continue;
+	    case '\004':
+		code = ERR;
+		done = TRUE;
+		break;
+	    case KEY_ENTER:
+	    case '\n':
+		done = TRUE;
+		break;
+	    case KEY_BACKSPACE:
+	    case '\b':
+		if (used) {
+		    if (mark < used) {
+			/* getnstr does not do this */
+			if (mark > 0) {
+			    --mark;
+			    for (n = mark; n < used; ++n) {
+				buffer[n] = buffer[n + 1];
+			    }
+			} else {
+			    flash();
+			}
+		    } else {
+			/* getnstr does this */
+			mark = --used;
+			buffer[used] = '\0';
+		    }
+		} else {
+		    flash();
+		}
+		break;
+		/*
+		 * Unlike getnstr, this function can move the cursor into the
+		 * middle of the buffer and insert/delete at that point.
+		 */
+	    case KEY_HOME:
+		mark = 0;
+		break;
+	    case KEY_END:
+		mark = used;
+		break;
+	    case KEY_LEFT:
+		if (mark > 0) {
+		    mark--;
+		} else {
+		    flash();
+		}
+		break;
+	    case KEY_RIGHT:
+		if (mark < used) {
+		    mark++;
+		} else {
+		    flash();
+		}
+		break;
 #ifdef KEY_EVENT
-    if (code == KEY_EVENT)
-	strcpy(buffer, "# event!");
+	    case KEY_EVENT:
+		continue;
 #endif
 #ifdef KEY_RESIZE
-    if (code == KEY_RESIZE) {
-	strcpy(buffer, "# resize!");
-	getch();
-    }
+	    case KEY_RESIZE:
+		/*
+		 * Unlike getnstr, this function "knows" what the whole screen
+		 * is supposed to look like, and can handle resize events.
+		 */
+		continue;
 #endif
+	    case '\t':
+		ch = ' ';
+		/* FALLTHRU */
+	    default:
+		if (ch >= KEY_MIN) {
+		    flash();
+		    continue;
+		}
+		if (mark < used) {
+		    /* getnstr does not do this... */
+		    for (n = used + 1; n > mark; --n) {
+			buffer[n] = buffer[n - 1];
+		    }
+		    buffer[mark] = (char) ch;
+		    used++;
+		    mark++;
+		} else {
+		    /* getnstr does this part */
+		    buffer[used] = (char) ch;
+		    mark = ++used;
+		}
+		break;
+	    }
+	}
+    } else {
+	show_prompt(underline, clocked);
+
+	code = getnstr(buffer, length);
+	/*
+	 * If this returns anything except ERR/OK, it would be one of ncurses's
+	 * extensions.  Fill the buffer with something harmless that the shell
+	 * will execute as a comment.
+	 */
+#ifdef KEY_EVENT
+	if (code == KEY_EVENT)
+	    _nc_STRCPY(buffer, "# event!", length);
+#endif
+#ifdef KEY_RESIZE
+	if (code == KEY_RESIZE) {
+	    _nc_STRCPY(buffer, "# resize!", length);
+	    getch();
+	}
+#endif
+    }
     attroff(underline);
     attroff(A_BOLD);
-    printw("\n");
+    refresh();
 
     return code;
 }
 
+#ifdef NCURSES_VERSION
+/*
+ * Cancel xterm's alternate-screen mode (from dialog -TD)
+ */
+#define isprivate(s) ((s) != 0 && strstr(s, "\033[?") != 0)
 static void
-usage(void)
+cancel_altscreen(void)
+{
+    if (isatty(fileno(stdout))
+	&& key_mouse != 0	/* xterm and kindred */
+	&& isprivate(enter_ca_mode)
+	&& isprivate(exit_ca_mode)) {
+	/*
+	 * initscr() or newterm() already wrote enter_ca_mode as a side effect
+	 * of initializing the screen.  It would be nice to not even do that,
+	 * but we do not really have access to the correct copy of the
+	 * terminfo description until those functions have been invoked.
+	 */
+	(void) refresh();
+	(void) putp(exit_ca_mode);
+	(void) fflush(stdout);
+	/*
+	 * Prevent ncurses from switching "back" to the normal screen when
+	 * exiting from this program.  That would move the cursor to the
+	 * original location saved in xterm.  Normally curses sets the cursor
+	 * position to the first line after the display, but the alternate
+	 * screen switching is done after that point.
+	 *
+	 * Cancelling the strings altogether also works around the buggy
+	 * implementation of alternate-screen in rxvt, etc., which clear more
+	 * of the display than they should.
+	 */
+	enter_ca_mode = 0;
+	exit_ca_mode = 0;
+    }
+}
+#endif
+
+static void
+usage(int ok)
 {
     static const char *msg[] =
     {
 	"Usage: filter [options]"
 	,""
+	,USAGE_COMMON
 	,"Options:"
-	,"  -i   use initscr() rather than newterm()"
+#ifdef NCURSES_VERSION
+	," -a       suppress xterm alternate-screen by amending smcup/rmcup"
+#endif
+	," -c       show current time on prompt line with \"Command\""
+#if HAVE_USE_DEFAULT_COLORS
+	," -d       invoke use_default_colors"
+#endif
+	," -i       use initscr() rather than newterm()"
+	," -p       poll for individual characters rather than using getnstr"
     };
     unsigned n;
     for (n = 0; n < SIZEOF(msg); n++)
 	fprintf(stderr, "%s\n", msg[n]);
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
@@ -100,17 +332,45 @@
     int ch;
     char buffer[80];
     int underline;
+#ifdef NCURSES_VERSION
+    bool a_option = FALSE;
+#endif
+    bool c_option = FALSE;
+#if HAVE_USE_DEFAULT_COLORS
+    bool d_option = FALSE;
+#endif
     bool i_option = FALSE;
+    bool p_option = FALSE;
 
     setlocale(LC_ALL, "");
 
-    while ((ch = getopt(argc, argv, "i")) != -1) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "adcip")) != -1) {
 	switch (ch) {
+#ifdef NCURSES_VERSION
+	case 'a':
+	    a_option = TRUE;
+	    break;
+#endif
+	case 'c':
+	    c_option = TRUE;
+	    break;
+#if HAVE_USE_DEFAULT_COLORS
+	case 'd':
+	    d_option = TRUE;
+	    break;
+#endif
 	case 'i':
 	    i_option = TRUE;
 	    break;
+	case 'p':
+	    p_option = TRUE;
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
 
@@ -120,8 +380,16 @@
     if (i_option) {
 	initscr();
     } else {
-	(void) newterm((char *) 0, stdout, stdin);
+	if (newterm((char *) 0, stdout, stdin) == 0) {
+	    fprintf(stderr, "cannot initialize terminal\n");
+	    ExitProgram(EXIT_FAILURE);
+	}
     }
+#ifdef NCURSES_VERSION
+    if (a_option) {
+	cancel_altscreen();
+    }
+#endif
     cbreak();
     keypad(stdscr, TRUE);
 
@@ -129,7 +397,7 @@
 	int background = COLOR_BLACK;
 	start_color();
 #if HAVE_USE_DEFAULT_COLORS
-	if (use_default_colors() != ERR)
+	if (d_option && (use_default_colors() != ERR))
 	    background = -1;
 #endif
 	init_pair(1, COLOR_CYAN, (short) background);
@@ -138,8 +406,11 @@
 	underline = A_UNDERLINE;
     }
 
-    while (new_command(buffer, sizeof(buffer) - 1, underline) != ERR
-	   && strlen(buffer) != 0) {
+    for (;;) {
+	int code = new_command(buffer, sizeof(buffer) - 1,
+			       underline, c_option, p_option);
+	if (code == ERR || *buffer == '\0')
+	    break;
 	reset_shell_mode();
 	printf("\n");
 	fflush(stdout);
@@ -149,7 +420,7 @@
 	erase();
 	refresh();
     }
-    printw("done");
+    clear();
     refresh();
     endwin();
     ExitProgram(EXIT_SUCCESS);
diff --git a/test/firework.c b/test/firework.c
index 6d35d50..54e4036 100644
--- a/test/firework.c
+++ b/test/firework.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2022 Thomas E. Dickey                                *
+ * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: firework.c,v 1.30 2014/08/02 17:24:07 tom Exp $
+ * $Id: firework.c,v 1.40 2022/12/04 00:40:11 tom Exp $
  */
 #include <test.priv.h>
 
@@ -37,8 +38,7 @@
 static void
 cleanup(void)
 {
-    curs_set(1);
-    endwin();
+    stop_curses();
 }
 
 static void
@@ -137,17 +137,62 @@
     showit();
 }
 
-int
-main(
-	int argc GCC_UNUSED,
-	char *argv[]GCC_UNUSED)
+static void
+usage(int ok)
 {
-    int start, end, row, diff, flag = 0, direction;
+    static const char *msg[] =
+    {
+	"Usage: firework [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+#if HAVE_USE_DEFAULT_COLORS
+	," -d       invoke use_default_colors, repeat to use in init_pair"
+#endif
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+    int start, end;
+    int row, diff;
+    int flag = 0;
+    int direction;
     unsigned seed;
+#if HAVE_USE_DEFAULT_COLORS
+    bool d_option = FALSE;
+#endif
 
-    CATCHALL(onsig);
+    while ((ch = getopt(argc, argv, OPTS_COMMON "d")) != -1) {
+	switch (ch) {
+#if HAVE_USE_DEFAULT_COLORS
+	case 'd':
+	    d_option = TRUE;
+	    break;
+#endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
 
-    initscr();
+    InitAndCatch(initscr(), onsig);
     noecho();
     cbreak();
     keypad(stdscr, TRUE);
@@ -156,7 +201,7 @@
     if (has_colors()) {
 	start_color();
 #if HAVE_USE_DEFAULT_COLORS
-	if (use_default_colors() == OK)
+	if (d_option && (use_default_colors() == OK))
 	    my_bg = -1;
 #endif
     }
@@ -174,7 +219,7 @@
 	    diff = abs(start - end);
 	} while (diff < 2 || diff >= LINES - 2);
 	(void) attrset(AttrArg(0, A_NORMAL));
-	for (row = 0; row < diff; row++) {
+	for (row = 1; row < diff; row++) {
 	    MvPrintw(LINES - row, start + (row * direction),
 		     (direction < 0) ? "\\" : "/");
 	    if (flag++) {
diff --git a/test/firstlast.c b/test/firstlast.c
index f5328c7..c66c2b8 100644
--- a/test/firstlast.c
+++ b/test/firstlast.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 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            *
@@ -29,7 +30,7 @@
  * This test was written by Alexander V. Lukyanov to demonstrate difference
  * between ncurses 4.1 and SVR4 curses
  *
- * $Id: firstlast.c,v 1.7 2010/05/01 19:11:55 tom Exp $
+ * $Id: firstlast.c,v 1.10 2022/12/10 23:31:31 tom Exp $
  */
 
 #include <test.priv.h>
@@ -40,6 +41,11 @@
     const char *s;
     int x0 = -1, y0 = -1;
     int x1, y1;
+    int maxx, maxy, limit;
+
+    getmaxyx(w, maxy, maxx);
+    wmove(w, 0, 0);
+    limit = maxy * maxx;
 
     for (;;) {
 	for (s = str; *s; s++) {
@@ -49,17 +55,61 @@
 		wmove(w, 0, 0);
 		return;
 	    }
+	    /* waddch() should return ERR at the lower-right corner */
+	    if (--limit < 0) {
+		beep();
+		if (*str == '?')
+		    return;
+		napms(500);
+		wmove(w, maxy - 1, 0);
+		str = "?";
+		limit = maxx + 1;
+	    }
 	    x0 = x1;
 	    y0 = y1;
 	}
     }
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: firstlast [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
-main(int argc GCC_UNUSED,
-     char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     WINDOW *large, *small;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
     initscr();
     noecho();
 
diff --git a/test/foldkeys.c b/test/foldkeys.c
index a5e25e3..bb3801e 100644
--- a/test/foldkeys.c
+++ b/test/foldkeys.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2006 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            *
@@ -29,7 +30,7 @@
 /*
  * Author: Thomas E. Dickey, 2006
  *
- * $Id: foldkeys.c,v 1.4 2010/11/14 01:00:53 tom Exp $
+ * $Id: foldkeys.c,v 1.12 2023/02/25 16:51:01 tom Exp $
  *
  * Demonstrate a method for altering key definitions at runtime.
  *
@@ -38,21 +39,11 @@
  * merging only for the keys which are defined in the terminal description.
  */
 
+#define NEED_TIME_H
 #include <test.priv.h>
 
 #if defined(NCURSES_VERSION) && NCURSES_EXT_FUNCS
 
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
 #define MY_LOGFILE "demo_foldkeys.log"
 #define MY_KEYS (KEY_MAX + 1)
 
@@ -63,10 +54,10 @@
 log_last_line(WINDOW *win)
 {
     FILE *fp;
-    int y, x, n;
-    char temp[256];
 
     if ((fp = fopen(MY_LOGFILE, "a")) != 0) {
+	char temp[256];
+	int y, x, n;
 	int need = sizeof(temp) - 1;
 	if (need > COLS)
 	    need = COLS;
@@ -155,6 +146,8 @@
 	int first, second;
 	char final[2];
 	char *value;
+	size_t need;
+
 	if (info[j].state == 0
 	    && sscanf(info[j].value,
 		      "\033[%d;%d%c",
@@ -162,8 +155,10 @@
 		      &second,
 		      final) == 3
 	    && *final != ';'
+	    && (need = strlen(info[j].value)) != 0
 	    && (value = strdup(info[j].value)) != 0) {
-	    sprintf(value, "\033[%d%c", first, *final);
+	    (void) need;	/* _nc_SLIMIT is normally nothing  */
+	    _nc_SPRINTF(value, _nc_SLIMIT(need) "\033[%d%c", first, *final);
 	    for (k = 0; k < info_len; ++k) {
 		if (info[k].state == 0
 		    && !strcmp(info[k].value, value)) {
@@ -172,7 +167,7 @@
 		}
 	    }
 	    if (info[j].state == 0) {
-		sprintf(value, "\033O%c", *final);
+		_nc_SPRINTF(value, _nc_SLIMIT(need) "\033O%c", *final);
 		for (k = 0; k < info_len; ++k) {
 		    if (info[k].state == 0
 			&& !strcmp(info[k].value, value)) {
@@ -198,18 +193,52 @@
     printw("Merged to %d key definitions\n", info_len - merged);
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: foldkeys [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     int ch;
-#if HAVE_GETTIMEOFDAY
-    int secs, msecs;
-    struct timeval current, previous;
-#endif
+    TimeType previous;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
+    if (newterm(0, stdout, stdin) == 0) {
+	fprintf(stderr, "Cannot initialize terminal\n");
+	ExitProgram(EXIT_FAILURE);
+    }
 
     unlink(MY_LOGFILE);
 
-    newterm(0, stdout, stdin);
     (void) cbreak();		/* take input chars one at a time, no wait for \n */
     (void) noecho();		/* don't echo input */
 
@@ -219,29 +248,17 @@
 
     demo_foldkeys();
 
-#if HAVE_GETTIMEOFDAY
-    gettimeofday(&previous, 0);
-#endif
+    GetClockTime(&previous);
 
     while ((ch = getch()) != ERR) {
 	bool escaped = (ch >= MY_KEYS);
 	const char *name = keyname(escaped ? (ch - MY_KEYS) : ch);
+	TimeType current;
 
-#if HAVE_GETTIMEOFDAY
-	gettimeofday(&current, 0);
-	secs = (int) (current.tv_sec - previous.tv_sec);
-	msecs = (int) ((current.tv_usec - previous.tv_usec) / 1000);
-	if (msecs < 0) {
-	    msecs += 1000;
-	    --secs;
-	}
-	if (msecs >= 1000) {
-	    secs += msecs / 1000;
-	    msecs %= 1000;
-	}
-	printw("%6d.%03d ", secs, msecs);
+	GetClockTime(&current);
+	printw("%6.03f ", ElapsedSeconds(&previous, &current));
 	previous = current;
-#endif
+
 	printw("Keycode %d, name %s%s\n",
 	       ch,
 	       escaped ? "ESC-" : "",
diff --git a/test/form_driver_w.c b/test/form_driver_w.c
index 3e928af..544060d 100644
--- a/test/form_driver_w.c
+++ b/test/form_driver_w.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2013,2014 Free Software Foundation, Inc.                   *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 2013-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            *
@@ -31,26 +32,72 @@
  ****************************************************************************/
 
 /*
- * $Id: form_driver_w.c,v 1.13 2014/08/02 17:24:55 tom Exp $
+ * $Id: form_driver_w.c,v 1.17 2022/12/10 23:31:31 tom Exp $
  *
  * Test form_driver_w (int, int, wchar_t), a wide char aware
  * replacement of form_driver.
  */
 
-#include <locale.h>
-
 #include <test.priv.h>
+#include <popup_msg.h>
 
 #if USE_WIDEC_SUPPORT && USE_LIBFORM && (defined(NCURSES_VERSION_PATCH) && NCURSES_VERSION_PATCH >= 20131207)
 
 #include <form.h>
 
-int
-main(void)
+static void
+usage(int ok)
 {
-    FIELD *field[3];
+    static const char *msg[] =
+    {
+	"Usage: form_driver_w [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    static const char *help[] =
+    {
+	"Commands:",
+	"  ^D,^Q,ESC           - quit program",
+	"  <Tab>,<Down>        - move to next field",
+	"  <BackTab>,<Up>      - move to previous field",
+	0
+    };
+
+#define NUM_FIELDS 3
+#define MyRow(n) (4 + (n) * 2)
+#define MyCol(n) 10
+    FIELD *field[NUM_FIELDS + 1];
     FORM *my_form;
     bool done = FALSE;
+    int n;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
 
     setlocale(LC_ALL, "");
 
@@ -61,32 +108,34 @@
     keypad(stdscr, TRUE);
 
     /* Initialize the fields */
-    field[0] = new_field(1, 10, 4, 18, 0, 0);
-    field[1] = new_field(1, 10, 6, 18, 0, 0);
-    field[2] = NULL;
-
-    /* Set field options */
-    set_field_back(field[0], A_UNDERLINE);	/* Print a line for the option  */
-    field_opts_off(field[0], O_AUTOSKIP);	/* Don't go to next field when this */
-    /* Field is filled up           */
-    set_field_back(field[1], A_UNDERLINE);
-    field_opts_off(field[1], O_AUTOSKIP);
+    for (n = 0; n < NUM_FIELDS; ++n) {
+	field[n] = new_field(1, 10, MyRow(n), 18, 0, 0);
+	set_field_back(field[n], A_UNDERLINE);
+	/* Print a line for the option  */
+	field_opts_off(field[n], O_AUTOSKIP);
+	/* Don't go to next field when this is filled */
+    }
+    field[n] = NULL;
 
     /* Create the form and post it */
     my_form = new_form(field);
     post_form(my_form);
     refresh();
 
-    mvprintw(4, 10, "Value 1:");
-    mvprintw(6, 10, "Value 2:");
-    refresh();
+    for (n = 0; n < NUM_FIELDS; ++n) {
+	mvprintw(MyRow(n), MyCol(n), "Value %d:", n + 1);
+    }
 
     /* Loop through to get user requests */
     while (!done) {
-	wint_t ch;
-	int ret = get_wch(&ch);
+	wint_t c2;
+	int ret = get_wch(&c2);
 
-	mvprintw(8, 10, "Got %d (%#x), type: %s", (int) ch, (int) ch,
+	mvprintw(MyRow(NUM_FIELDS),
+		 MyCol(NUM_FIELDS),
+		 "Got %d (%#x), type: %s",
+		 (int) c2,
+		 (int) c2,
 		 (ret == KEY_CODE_YES)
 		 ? "KEY_CODE_YES"
 		 : ((ret == OK)
@@ -98,7 +147,7 @@
 
 	switch (ret) {
 	case KEY_CODE_YES:
-	    switch (ch) {
+	    switch (c2) {
 	    case KEY_DOWN:
 		/* Go to next field */
 		form_driver_w(my_form, KEY_CODE_YES, REQ_NEXT_FIELD);
@@ -106,6 +155,7 @@
 		/* Leaves nicely at the last character */
 		form_driver_w(my_form, KEY_CODE_YES, REQ_END_LINE);
 		break;
+	    case KEY_BTAB:
 	    case KEY_UP:
 		/* Go to previous field */
 		form_driver_w(my_form, KEY_CODE_YES, REQ_PREV_FIELD);
@@ -116,14 +166,21 @@
 	    }
 	    break;
 	case OK:
-	    switch (ch) {
+	    switch (c2) {
 	    case CTRL('D'):
 	    case QUIT:
 	    case ESCAPE:
 		done = TRUE;
 		break;
+	    case '\t':
+		form_driver_w(my_form, KEY_CODE_YES, REQ_NEXT_FIELD);
+		form_driver_w(my_form, KEY_CODE_YES, REQ_END_LINE);
+		break;
+	    case HELP_KEY_1:
+		popup_msg(form_win(my_form), help);
+		break;
 	    default:
-		form_driver_w(my_form, OK, (wchar_t) ch);
+		form_driver_w(my_form, OK, (wchar_t) c2);
 		break;
 	    }
 	    break;
@@ -133,8 +190,9 @@
     /* Un post form and free the memory */
     unpost_form(my_form);
     free_form(my_form);
-    free_field(field[0]);
-    free_field(field[1]);
+    for (n = 0; n < NUM_FIELDS; ++n) {
+	free_field(field[n]);
+    }
 
     endwin();
     ExitProgram(EXIT_SUCCESS);
diff --git a/test/gdc.6 b/test/gdc.6
index ed3a4f1..bf90b26 100644
--- a/test/gdc.6
+++ b/test/gdc.6
@@ -1,5 +1,6 @@
 .\"***************************************************************************
-.\" Copyright (c) 1998-2003,2006 Free Software Foundation, Inc.              *
+.\" Copyright 2020 Thomas E. Dickey                                          *
+.\" Copyright 1998-2006,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            *
@@ -26,16 +27,12 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: gdc.6,v 1.3 2006/04/22 23:02:15 tom Exp $
-.TH GDC 6
+.\" $Id: gdc.6,v 1.6 2020/02/02 23:34:34 tom Exp $
+.TH GDC 6 2020-02-02 ncurses-examples Games
 .SH NAME
 gdc \- grand digital clock (curses)
 .SH SYNOPSIS
-.B gdc
-[-n] [
-[-s] [
-.I n
-]
+.B gdc \fP[\fIoptions\fP] [\fIn\fP]
 .SH DESCRIPTION
 .I Gdc
 runs a digital clock made of reverse-video blanks on a terminal screen.
@@ -44,14 +41,20 @@
 ``s'' or space, respectively.
 .SH OPTIONS
 .TP
-.B -n
+.B \-d
+use terminal's default colors for the background.
+.TP
+.B \-n
 redirects input to /dev/null, making it ignore the stop/pause commands.
 You can still stop it by pressing the interrupt key.
 .TP
-.B -s
+.B \-s
 makes digits scroll as they change.
 When running on a fast display, the program breaks up the scrolling into
 subsecond repaints, making the operation appear smooth.
+.TP
+.B \-t \fIhh:mm:ss\fP
+specify starting time (default is ``now'').
 .PP
 With an optional numeric argument
 .I num
@@ -61,4 +64,5 @@
 Normally it runs "forever" (counting down from 2 billion seconds).
 .SH AUTHOR
 Amos Shapir, modified for curses by John Lupien.
+.br
 Improvements for ncurses by Thomas Dickey.
diff --git a/test/gdc.c b/test/gdc.c
index 81de6c8..7243c10 100644
--- a/test/gdc.c
+++ b/test/gdc.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright 2019-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            *
@@ -33,7 +34,7 @@
  * modified 10-18-89 for curses (jrl)
  * 10-18-89 added signal handling
  *
- * $Id: gdc.c,v 1.44 2015/07/04 21:28:28 tom Exp $
+ * $Id: gdc.c,v 1.57 2022/12/04 00:40:11 tom Exp $
  */
 
 #include <test.priv.h>
@@ -66,7 +67,7 @@
     signal(signo, sighndl);
     sigtermed = signo;
     if (redirected) {
-	endwin();
+	stop_curses();
 	ExitProgram(EXIT_FAILURE);
     }
 }
@@ -76,7 +77,7 @@
 {
     if (sigtermed) {
 	(void) standend();
-	endwin();
+	stop_curses();
 	fprintf(stderr, "gdc terminated by signal %d\n", sigtermed);
 	ExitProgram(EXIT_FAILURE);
     }
@@ -86,7 +87,6 @@
 drawbox(bool scrolling)
 {
     chtype bottom[XLENGTH + 1];
-    int n;
 
     if (hascolor)
 	(void) attrset(AttrArg(COLOR_PAIR(PAIR_FRAMES), 0));
@@ -97,6 +97,7 @@
 
     MvAddCh(YBASE + YDEPTH, XBASE - 1, ACS_LLCORNER);
     if ((mvinchnstr(YBASE + YDEPTH, XBASE, bottom, XLENGTH)) != ERR) {
+	int n;
 	for (n = 0; n < XLENGTH; n++) {
 	    if (!scrolling)
 		bottom[n] &= ~A_COLOR;
@@ -149,23 +150,27 @@
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *msg[] =
     {
 	"Usage: gdc [options] [count]"
 	,""
+	,USAGE_COMMON
 	,"Options:"
-	,"  -n  redirect input to /dev/null"
-	,"  -s  scroll each number into place, rather than flipping"
-	,"  -t hh:mm:ss specify starting time (default is ``now'')"
+#if HAVE_USE_DEFAULT_COLORS
+	," -d       invoke use_default_colors"
+#endif
+	," -n       redirect input to /dev/null"
+	," -s       scroll each number into place, rather than flipping"
+	," -t TIME  specify starting time as hh:mm:ss (default is ``now'')"
 	,""
 	,"If you specify a count, gdc runs for that number of seconds"
     };
     unsigned j;
     for (j = 0; j < SIZEOF(msg); j++)
 	fprintf(stderr, "%s\n", msg[j]);
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
 
 static time_t
@@ -179,14 +184,14 @@
 
     if (sscanf(value, "%d:%d:%d%c", &hh, &mm, &ss, &c) != 3) {
 	if (sscanf(value, "%02d%02d%02d%c", &hh, &mm, &ss, &c) != 3) {
-	    usage();
+	    usage(FALSE);
 	}
     }
 
     if ((hh < 0) || (hh >= 24) ||
 	(mm < 0) || (mm >= 60) ||
 	(ss < 0) || (ss >= 60)) {
-	usage();
+	usage(FALSE);
     }
 
     /* adjust so that the localtime in the main loop will give usable time */
@@ -200,10 +205,13 @@
 
     if (tm->tm_hour != hh) {
 	fprintf(stderr, "Cannot find local time for %s!\n", value);
-	usage();
+	usage(FALSE);
     }
     return result;
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
@@ -211,20 +219,26 @@
     time_t now;
     struct tm *tm;
     long t, a;
-    int i, j, s, k;
+    int i, j, s, k, ch;
     int count = 0;
     FILE *ofp = stdout;
     FILE *ifp = stdin;
     bool smooth = FALSE;
     bool stages = FALSE;
     time_t starts = 0;
+#if HAVE_USE_DEFAULT_COLORS
+    bool d_option = FALSE;
+#endif
 
     setlocale(LC_ALL, "");
 
-    CATCHALL(sighndl);
-
-    while ((k = getopt(argc, argv, "nst:")) != -1) {
-	switch (k) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "dnst:")) != -1) {
+	switch (ch) {
+#if HAVE_USE_DEFAULT_COLORS
+	case 'd':
+	    d_option = TRUE;
+	    break;
+#endif
 	case 'n':
 	    ifp = fopen("/dev/null", "r");
 	    redirected = TRUE;
@@ -235,28 +249,35 @@
 	case 't':
 	    starts = parse_time(optarg);
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
     if (optind < argc) {
 	count = atoi(argv[optind++]);
 	assert(count >= 0);
+	if (optind < argc)
+	    usage(FALSE);
     }
-    if (optind < argc)
-	usage();
 
-    if (redirected) {
-	char *name = getenv("TERM");
-	if (name == 0
-	    || newterm(name, ofp, ifp) == 0) {
-	    fprintf(stderr, "cannot open terminal\n");
-	    ExitProgram(EXIT_FAILURE);
+    InitAndCatch({
+	if (redirected) {
+	    char *name = getenv("TERM");
+	    if (name == 0
+		|| newterm(name, ofp, ifp) == 0) {
+		fprintf(stderr, "cannot open terminal\n");
+		ExitProgram(EXIT_FAILURE);
+	    }
+	} else {
+	    initscr();
 	}
-
-    } else {
-	initscr();
     }
+    ,sighndl);
+
     cbreak();
     noecho();
     nodelay(stdscr, 1);
@@ -268,7 +289,7 @@
 	short bg = COLOR_BLACK;
 	start_color();
 #if HAVE_USE_DEFAULT_COLORS
-	if (use_default_colors() == OK)
+	if (d_option && (use_default_colors() == OK))
 	    bg = -1;
 #endif
 	init_pair(PAIR_DIGITS, COLOR_BLACK, COLOR_RED);
@@ -379,7 +400,7 @@
 	}
 
 	/* this depends on the detailed format of ctime(3) */
-	(void) strncpy(buf, ctime(&now), (size_t) 30);
+	_nc_STRNCPY(buf, ctime(&now), (size_t) 30);
 	{
 	    char *d2 = buf + 10;
 	    char *s2 = buf + 19;
@@ -435,6 +456,6 @@
 	}
     } while (--count);
     (void) standend();
-    endwin();
+    stop_curses();
     ExitProgram(EXIT_SUCCESS);
 }
diff --git a/test/hanoi.c b/test/hanoi.c
index 7447ae2..6d92332 100644
--- a/test/hanoi.c
+++ b/test/hanoi.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019-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            *
@@ -41,7 +42,7 @@
  *
  *	Date: 05.Nov.90
  *
- * $Id: hanoi.c,v 1.36 2014/08/02 17:24:07 tom Exp $
+ * $Id: hanoi.c,v 1.47 2022/12/04 00:40:11 tom Exp $
  */
 
 #include <test.priv.h>
@@ -89,104 +90,6 @@
 static int NMoves = 0;
 static bool AutoFlag = FALSE;
 
-static void InitTiles(void);
-static void DisplayTiles(void);
-static void MakeMove(int From, int To);
-static void AutoMove(int From, int To, int Num);
-static void Usage(void);
-static int Solved(int NumTiles);
-static int GetMove(int *From, int *To);
-static int InvalidMove(int From, int To);
-
-int
-main(int argc, char **argv)
-{
-    int FromCol, ToCol;
-
-    setlocale(LC_ALL, "");
-
-    switch (argc) {
-    case 1:
-	NTiles = DEFAULTTILES;
-	break;
-    case 2:
-	NTiles = atoi(argv[1]);
-	if (NTiles > MAXTILES || NTiles < MINTILES) {
-	    fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES);
-	    ExitProgram(EXIT_FAILURE);
-	}
-	break;
-    case 3:
-	if (strcmp(argv[2], "a")) {
-	    Usage();
-	    ExitProgram(EXIT_FAILURE);
-	}
-	NTiles = atoi(argv[1]);
-	if (NTiles > MAXTILES || NTiles < MINTILES) {
-	    fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES);
-	    ExitProgram(EXIT_FAILURE);
-	}
-	AutoFlag = TRUE;
-	break;
-    default:
-	Usage();
-	ExitProgram(EXIT_FAILURE);
-    }
-    initscr();
-    if (has_colors()) {
-	int i;
-	short bg = COLOR_BLACK;
-	start_color();
-#if HAVE_USE_DEFAULT_COLORS
-	if (use_default_colors() == OK)
-	    bg = -1;
-#endif
-	for (i = 0; i < 9; i++)
-	    init_pair((short) (i + 1), bg, TileColour[i]);
-    }
-    cbreak();
-    if (LINES < 24) {
-	endwin();
-	fprintf(stderr, "Min screen length 24 lines\n");
-	ExitProgram(EXIT_FAILURE);
-    }
-    if (AutoFlag) {
-	curs_set(0);
-	leaveok(stdscr, TRUE);	/* Attempt to remove cursor */
-    }
-    InitTiles();
-    DisplayTiles();
-    if (AutoFlag) {
-	do {
-	    noecho();
-	    AutoMove(0, 2, NTiles);
-	} while (!Solved(NTiles));
-	sleep(2);
-    } else {
-	echo();
-	for (;;) {
-	    if (GetMove(&FromCol, &ToCol))
-		break;
-	    if (InvalidMove(FromCol, ToCol)) {
-		MvAddStr(STATUSLINE, 0, "Invalid Move !!");
-		refresh();
-		beep();
-		continue;
-	    }
-	    MakeMove(FromCol, ToCol);
-	    if (Solved(NTiles)) {
-		MvPrintw(STATUSLINE, 0,
-			 "Well Done !! You did it in %d moves", NMoves);
-		refresh();
-		sleep(5);
-		break;
-	    }
-	}
-    }
-    endwin();
-    ExitProgram(EXIT_SUCCESS);
-}
-
 static int
 InvalidMove(int From, int To)
 {
@@ -222,6 +125,15 @@
     Pegs[2].Count = 0;
 }
 
+static int
+two2n(int n)
+{
+    int result = 1;
+    while (n-- > 0)
+	result *= 2;
+    return result;
+}
+
 static void
 DisplayTiles(void)
 {
@@ -231,7 +143,7 @@
     erase();
     MvAddStr(1, 24, "T O W E R S   O F   H A N O I");
     MvAddStr(3, 34, "SJR 1990");
-    MvPrintw(19, 5, "Moves : %d of %.0f", NMoves, pow(2.0, (float) NTiles) - 1);
+    MvPrintw(19, 5, "Moves : %d of %d", NMoves, two2n(NTiles) - 1);
     (void) attrset(A_REVERSE);
     MvAddStr(BASELINE, 8,
 	     "                                                               ");
@@ -329,9 +241,136 @@
 }
 
 static void
-Usage(void)
+usage(int ok)
 {
-    fprintf(stderr, "Usage: hanoi [<No Of Tiles>] [a]\n");
-    fprintf(stderr,
-	    "The 'a' option causes the tower to be solved automatically\n");
+    static const char *msg[] =
+    {
+	"Usage: hanoi [options] [[<No Of Tiles>] [a]]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+#if HAVE_USE_DEFAULT_COLORS
+	," -d       invoke use_default_colors"
+#endif
+	," -n NUM   set number of tiles (positional param is deprecated)"
+	," -X       solve automatically (positional \"a\" is deprecated)"
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char **argv)
+{
+    int ch, FromCol, ToCol;
+
+#if HAVE_USE_DEFAULT_COLORS
+    bool d_option = FALSE;
+#endif
+
+    NTiles = DEFAULTTILES;
+    while ((ch = getopt(argc, argv, OPTS_COMMON "dn:X")) != -1) {
+	switch (ch) {
+#if HAVE_USE_DEFAULT_COLORS
+	case 'd':
+	    d_option = TRUE;
+	    break;
+#endif
+	case 'n':
+	    NTiles = atoi(optarg);
+	    break;
+	case 'X':
+	    AutoFlag = TRUE;
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    setlocale(LC_ALL, "");
+
+    switch (argc - optind) {
+    case 2:
+	if (strcmp(argv[optind + 1], "a")) {
+	    usage(FALSE);
+	}
+	AutoFlag = TRUE;
+	/* FALLTHRU */
+    case 1:
+	NTiles = atoi(argv[optind]);
+	/* FALLTHRU */
+    case 0:
+	break;
+    default:
+	usage(FALSE);
+    }
+
+    if (NTiles > MAXTILES || NTiles < MINTILES) {
+	fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES);
+	usage(FALSE);
+    }
+
+    initscr();
+    if (has_colors()) {
+	int i;
+	short bg = COLOR_BLACK;
+	start_color();
+#if HAVE_USE_DEFAULT_COLORS
+	if (d_option && (use_default_colors() == OK))
+	    bg = -1;
+#endif
+	for (i = 0; i < 9; i++)
+	    init_pair((short) (i + 1), bg, TileColour[i]);
+    }
+    cbreak();
+    if (LINES < 24) {
+	endwin();
+	fprintf(stderr, "Min screen length 24 lines\n");
+	ExitProgram(EXIT_FAILURE);
+    }
+    if (AutoFlag) {
+	curs_set(0);
+	leaveok(stdscr, TRUE);	/* Attempt to remove cursor */
+    }
+    InitTiles();
+    DisplayTiles();
+    if (AutoFlag) {
+	do {
+	    noecho();
+	    AutoMove(0, 2, NTiles);
+	} while (!Solved(NTiles));
+	sleep(2);
+    } else {
+	echo();
+	for (;;) {
+	    if (GetMove(&FromCol, &ToCol))
+		break;
+	    if (InvalidMove(FromCol, ToCol)) {
+		MvAddStr(STATUSLINE, 0, "Invalid Move !!");
+		refresh();
+		beep();
+		continue;
+	    }
+	    MakeMove(FromCol, ToCol);
+	    if (Solved(NTiles)) {
+		MvPrintw(STATUSLINE, 0,
+			 "Well Done !! You did it in %d moves", NMoves);
+		refresh();
+		sleep(5);
+		break;
+	    }
+	}
+    }
+    stop_curses();
+    ExitProgram(EXIT_SUCCESS);
 }
diff --git a/test/hashtest.c b/test/hashtest.c
index 8499221..be79c0e 100644
--- a/test/hashtest.c
+++ b/test/hashtest.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2013 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2022 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            *
@@ -30,7 +31,7 @@
  *
  * Generate timing statistics for vertical-motion optimization.
  *
- * $Id: hashtest.c,v 1.32 2013/04/27 19:50:17 tom Exp $
+ * $Id: hashtest.c,v 1.39 2022/12/04 00:40:11 tom Exp $
  */
 
 #include <test.priv.h>
@@ -82,7 +83,7 @@
     move(0, 0);
     for (i = 0; i < head_lines; i++)
 	for (j = 0; j < COLS; j++)
-	    addch(UChar((j % 8 == 0) ? ('A' + j / 8) : '-'));
+	    AddCh(UChar((j % 8 == 0) ? ('A' + j / 8) : '-'));
 
     move(head_lines, 0);
     for (i = head_lines; i < LINES - foot_lines; i++) {
@@ -90,13 +91,13 @@
 			     + LO_CHAR);
 	int hi = (extend_corner || (i < LINES - 1)) ? COLS : COLS - 1;
 	for (j = 0; j < hi; j++)
-	    addch(c);
+	    AddCh(c);
     }
 
     for (i = LINES - foot_lines; i < LINES; i++) {
 	move(i, 0);
 	for (j = 0; j < (extend_corner ? COLS : COLS - 1); j++)
-	    addch(UChar((j % 8 == 0) ? ('A' + j / 8) : '-'));
+	    AddCh(UChar((j % 8 == 0) ? ('A' + j / 8) : '-'));
     }
 
     scrollok(stdscr, TRUE);
@@ -149,49 +150,53 @@
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *const tbl[] =
     {
 	"Usage: hashtest [options]"
 	,""
+	,USAGE_COMMON
 	,"Options:"
-	,"  -c      continuous (don't reset between refresh's)"
-	,"  -f num  leave 'num' lines constant for footer"
-	,"  -h num  leave 'num' lines constant for header"
-	,"  -l num  repeat test 'num' times"
-	,"  -n      test the normal optimizer"
-	,"  -o      test the hashed optimizer"
-	,"  -r      reverse the loops"
-	,"  -s      single-step"
-	,"  -x      assume lower-right corner extension"
+	," -c       continuous (don't reset between refresh's)"
+	," -F num   leave 'num' lines constant for footer"
+	," -H num   leave 'num' lines constant for header"
+	," -l num   repeat test 'num' times"
+	," -n       test the normal optimizer"
+	," -o       test the hashed optimizer"
+	," -r       reverse the loops"
+	," -s       single-step"
+	," -x       assume lower-right corner extension"
     };
     size_t n;
 
     for (n = 0; n < SIZEOF(tbl); n++)
 	fprintf(stderr, "%s\n", tbl[n]);
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
 {
-    int c;
+    int ch;
     int test_loops = 1;
     int test_normal = FALSE;
     int test_optimize = FALSE;
 
     setlocale(LC_ALL, "");
 
-    while ((c = getopt(argc, argv, "cf:h:l:norsx")) != -1) {
-	switch (c) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "cF:H:l:norsx")) != -1) {
+	switch (ch) {
 	case 'c':
 	    continuous = TRUE;
 	    break;
-	case 'f':
+	case 'F':
 	    foot_lines = atoi(optarg);
 	    break;
-	case 'h':
+	case 'H':
 	    head_lines = atoi(optarg);
 	    break;
 	case 'l':
@@ -213,8 +218,12 @@
 	case 'x':
 	    extend_corner = TRUE;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
     if (!test_normal && !test_optimize) {
@@ -222,12 +231,10 @@
 	test_optimize = TRUE;
     }
 #if USE_TRACE
-    trace(TRACE_TIMES);
+    curses_trace(TRACE_TIMES);
 #endif
 
-    CATCHALL(finish);		/* arrange interrupts to terminate */
-
-    (void) initscr();		/* initialize the curses library */
+    InitAndCatch(initscr(), finish);
     keypad(stdscr, TRUE);	/* enable keyboard mapping */
     (void) nonl();		/* tell curses not to do NL->CR/NL on output */
     (void) cbreak();		/* take input chars one at a time, no wait for \n */
diff --git a/test/inch_wide.c b/test/inch_wide.c
index 3d31f17..7b838d1 100644
--- a/test/inch_wide.c
+++ b/test/inch_wide.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007,2010 Free Software Foundation, Inc.                   *
+ * Copyright 2019-2020,2022 Thomas E. Dickey                                *
+ * Copyright 2007-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: inch_wide.c,v 1.7 2010/05/01 19:13:46 tom Exp $
+ * $Id: inch_wide.c,v 1.13 2022/12/10 23:55:34 tom Exp $
  */
 /*
        int in_wch(cchar_t *wcval);
@@ -44,6 +45,7 @@
 */
 
 #include <test.priv.h>
+#include <popup_msg.h>
 
 #if USE_WIDEC_SUPPORT
 
@@ -59,13 +61,24 @@
 static int
 test_inchs(int level, char **argv, WINDOW *chrwin, WINDOW *strwin)
 {
+    static const char *help[] =
+    {
+	"Test input from screen using inch(), etc., in a moveable viewport.",
+	"",
+	"Commands:",
+	" ESC/^Q                   - quit",
+	" h,j,k,l (and arrow-keys) - move viewport",
+	" w                        - recur to new window",
+	"                            for next input file",
+	0
+    };
+
     WINDOW *txtbox = 0;
     WINDOW *txtwin = 0;
     FILE *fp;
     int j;
     int txt_x = 0, txt_y = 0;
     int base_y;
-    int limit;
     cchar_t ch;
     cchar_t text[MAX_COLS];
 
@@ -109,6 +122,8 @@
     }
 
     while (!Quit(j = mvwgetch(txtwin, txt_y, txt_x))) {
+	int limit;
+
 	switch (j) {
 	case KEY_DOWN:
 	case 'j':
@@ -148,6 +163,9 @@
 		wnoutrefresh(txtwin);
 	    }
 	    break;
+	case HELP_KEY_1:
+	    popup_msg(txtwin, help);
+	    break;
 	default:
 	    beep();
 	    break;
@@ -241,19 +259,49 @@
     return TRUE;
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: inch_wide [options] [file1 [...]]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
 main(int argc, char *argv[])
 {
     WINDOW *chrbox;
     WINDOW *chrwin;
     WINDOW *strwin;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
 
     setlocale(LC_ALL, "");
 
-    if (argc < 2) {
-	fprintf(stderr, "usage: %s file\n", argv[0]);
-	return EXIT_FAILURE;
-    }
+    if (optind + 1 > argc)
+	usage(FALSE);
 
     initscr();
 
@@ -264,7 +312,7 @@
     chrwin = derwin(chrbox, 1, COLS - 2, 1, 1);
     strwin = derwin(chrbox, 4, COLS - 2, 2, 1);
 
-    test_inchs(1, argv, chrwin, strwin);
+    test_inchs(optind, argv, chrwin, strwin);
 
     endwin();
     ExitProgram(EXIT_SUCCESS);
diff --git a/test/inchs.c b/test/inchs.c
index be3aab8..b5922dd 100644
--- a/test/inchs.c
+++ b/test/inchs.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007-2010,2012 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2022 Thomas E. Dickey                                *
+ * Copyright 2007-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: inchs.c,v 1.12 2012/11/18 01:58:15 tom Exp $
+ * $Id: inchs.c,v 1.19 2022/12/11 00:01:39 tom Exp $
  *
  * Author: Thomas E Dickey
  */
@@ -46,6 +47,7 @@
 */
 
 #include <test.priv.h>
+#include <popup_msg.h>
 
 #define BASE_Y 7
 #define MAX_COLS 1024
@@ -69,13 +71,23 @@
 static int
 test_inchs(int level, char **argv, WINDOW *chrwin, WINDOW *strwin)
 {
+    static const char *help[] =
+    {
+	"Test input from screen using inch(), etc., in a moveable viewport.",
+	"",
+	"Commands:",
+	" ESC/^Q                   - quit",
+	" h,j,k,l (and arrow-keys) - move viewport",
+	" w                        - recur to new window",
+	"                            for next input file",
+	0
+    };
     WINDOW *txtbox = 0;
     WINDOW *txtwin = 0;
     FILE *fp;
     int ch, j;
     int txt_x = 0, txt_y = 0;
     int base_y;
-    int limit;
     chtype text[MAX_COLS];
 
     if (argv[level] == 0) {
@@ -120,6 +132,8 @@
     }
 
     while (!Quit(j = mvwgetch(txtwin, txt_y, txt_x))) {
+	int limit;
+
 	switch (j) {
 	case KEY_DOWN:
 	case 'j':
@@ -159,6 +173,9 @@
 		wnoutrefresh(txtwin);
 	    }
 	    break;
+	case HELP_KEY_1:
+	    popup_msg(txtwin, help);
+	    break;
 	default:
 	    beep();
 	    break;
@@ -254,19 +271,49 @@
     return TRUE;
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: inchs [options] file1 [file2 [...]]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
 main(int argc, char *argv[])
 {
     WINDOW *chrbox;
     WINDOW *chrwin;
     WINDOW *strwin;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
 
     setlocale(LC_ALL, "");
 
-    if (argc < 2) {
-	fprintf(stderr, "usage: %s file\n", argv[0]);
-	return EXIT_FAILURE;
-    }
+    if (optind + 1 > argc)
+	usage(FALSE);
 
     initscr();
 
@@ -277,7 +324,7 @@
     chrwin = derwin(chrbox, 1, COLS - 2, 1, 1);
     strwin = derwin(chrbox, 4, COLS - 2, 2, 1);
 
-    test_inchs(1, argv, chrwin, strwin);
+    test_inchs(optind, argv, chrwin, strwin);
 
     endwin();
     ExitProgram(EXIT_SUCCESS);
diff --git a/test/ins_wide.c b/test/ins_wide.c
index 8e7c123..a732449 100644
--- a/test/ins_wide.c
+++ b/test/ins_wide.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: ins_wide.c,v 1.21 2014/08/02 17:24:55 tom Exp $
+ * $Id: ins_wide.c,v 1.30 2022/12/10 22:28:50 tom Exp $
  *
  * Demonstrate the wins_wstr() and wins_wch functions.
  * Thomas Dickey - 2002/11/23
@@ -105,7 +106,7 @@
 }
 
 static int
-ColOf(wchar_t *buffer, int length, int margin)
+ColOf(const wchar_t *buffer, int length, int margin)
 {
     int n;
     int result;
@@ -236,7 +237,8 @@
 	static char cmd[80];
 	setlocale(LC_ALL, "");
 
-	putenv(strcpy(cmd, "TABSIZE=8"));
+	_nc_STRCPY(cmd, "TABSIZE=8", sizeof(cmd));
+	putenv(cmd);
 
 	initscr();
 	(void) cbreak();	/* take input chars one at a time, no wait for \n */
@@ -390,6 +392,8 @@
 	    }
 	    break;
 	default:
+	    if (length >= BUFSIZ - 2)
+		break;
 	    buffer[length++] = (wchar_t) ch;
 	    buffer[length] = '\0';
 
@@ -451,32 +455,36 @@
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *tbl[] =
     {
-	"Usage: inserts [options]"
+	"Usage: ins_wide [options]"
 	,""
+	,USAGE_COMMON
 	,"Options:"
-	,"  -f FILE read data from given file"
-	,"  -n NUM  limit string-inserts to NUM bytes on ^N replay"
-	,"  -m      perform wmove/move separately from insert-functions"
-	,"  -w      use window-parameter even when stdscr would be implied"
+	," -f FILE  read data from given file"
+	," -n NUM   limit string-inserts to NUM bytes on ^N replay"
+	," -m       perform wmove/move separately from insert-functions"
+	," -w       use window-parameter even when stdscr would be implied"
     };
     unsigned n;
     for (n = 0; n < SIZEOF(tbl); ++n)
 	fprintf(stderr, "%s\n", tbl[n]);
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     int ch;
 
     setlocale(LC_ALL, "");
 
-    while ((ch = getopt(argc, argv, "f:mn:w")) != -1) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "f:mn:w")) != -1) {
 	switch (ch) {
 	case 'f':
 	    init_linedata(optarg);
@@ -492,13 +500,16 @@
 	case 'w':
 	    w_opt = TRUE;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
-	    break;
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
     if (optind < argc)
-	usage();
+	usage(FALSE);
 
     test_inserts(0);
     endwin();
diff --git a/test/insdelln.c b/test/insdelln.c
index 34fb388..52ccfb6 100644
--- a/test/insdelln.c
+++ b/test/insdelln.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2008-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2022 Thomas E. Dickey                                *
+ * Copyright 2008-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            *
@@ -26,13 +27,17 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: insdelln.c,v 1.9 2014/08/02 23:09:32 tom Exp $
+ * $Id: insdelln.c,v 1.15 2022/12/10 23:31:31 tom Exp $
  *
  * test-driver for deleteln, wdeleteln, insdelln, winsdelln, insertln, winsertln
  */
 
 #include <test.priv.h>
 
+#if HAVE_WINSDELLN
+
+#include <popup_msg.h>
+
 #define SHOW(n) ((n) == ERR ? "ERR" : "OK")
 #define COLOR_DEFAULT (-1)
 
@@ -66,10 +71,10 @@
     };
     /* *INDENT-ON* */
 
-    static bool first = TRUE;
     const char *result = 0;
 
     if (has_colors()) {
+	static bool first = TRUE;
 	if (first) {
 	    unsigned n;
 
@@ -217,19 +222,10 @@
 	,"q     quit"
 	,"=     resets count to zero."
 	,"?     shows this help-window"
-	,""
-	,""
+	,0
     };
 
-    int y_max, x_max;
-    int row;
-
-    getmaxyx(win, y_max, x_max);
-    for (row = 0; row < (int) SIZEOF(table) && row < y_max; ++row) {
-	MvWPrintw(win, row, 0, "%.*s", x_max, table[row]);
-    }
-    while (wgetch(win) != 'q')
-	beep();
+    popup_msg(win, table);
 }
 
 static void
@@ -279,8 +275,8 @@
 	sp->count = 0;
 	show_status(win, sp);
 	break;
-    case '?':
-	do_subwindow(win, sp, show_help);
+    case HELP_KEY_1:
+	show_help(win);
 	break;
     default:
 	if (isdigit(sp->ch)) {
@@ -375,9 +371,44 @@
     } while ((st.ch = getch()) != ERR);
 }
 
-int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+static void
+usage(int ok)
 {
+    static const char *msg[] =
+    {
+	"Usage: insdelln [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
     initscr();
     cbreak();
     noecho();
@@ -387,3 +418,12 @@
 
     ExitProgram(EXIT_SUCCESS);
 }
+
+#else
+int
+main(void)
+{
+    printf("This program requires the curses winsdelln function\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
diff --git a/test/inserts.c b/test/inserts.c
index ae38fa2..b106ffc 100644
--- a/test/inserts.c
+++ b/test/inserts.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2002-2010,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: inserts.c,v 1.27 2012/12/16 00:35:27 tom Exp $
+ * $Id: inserts.c,v 1.34 2022/12/10 22:28:50 tom Exp $
  *
  * Demonstrate the winsstr() and winsch functions.
  * Thomas Dickey - 2002/10/19
@@ -161,7 +162,8 @@
 	static char cmd[80];
 	setlocale(LC_ALL, "");
 
-	putenv(strcpy(cmd, "TABSIZE=8"));
+	_nc_STRCPY(cmd, "TABSIZE=8", sizeof(cmd));
+	putenv(cmd);
 
 	initscr();
 	(void) cbreak();	/* take input chars one at a time, no wait for \n */
@@ -319,6 +321,8 @@
 		beep();
 		break;
 	    }
+	    if (length >= BUFSIZ - 2)
+		break;
 	    buffer[length++] = (char) ch;
 	    buffer[length] = '\0';
 
@@ -380,32 +384,36 @@
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *tbl[] =
     {
 	"Usage: inserts [options]"
 	,""
+	,USAGE_COMMON
 	,"Options:"
-	,"  -f FILE read data from given file"
-	,"  -n NUM  limit string-inserts to NUM bytes on ^N replay"
-	,"  -m      perform wmove/move separately from insert-functions"
-	,"  -w      use window-parameter even when stdscr would be implied"
+	," -f FILE  read data from given file"
+	," -n NUM   limit string-inserts to NUM bytes on ^N replay"
+	," -m       perform wmove/move separately from insert-functions"
+	," -w       use window-parameter even when stdscr would be implied"
     };
     unsigned n;
     for (n = 0; n < SIZEOF(tbl); ++n)
 	fprintf(stderr, "%s\n", tbl[n]);
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     int ch;
 
     setlocale(LC_ALL, "");
 
-    while ((ch = getopt(argc, argv, "f:mn:w")) != -1) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "f:mn:w")) != -1) {
 	switch (ch) {
 	case 'f':
 	    init_linedata(optarg);
@@ -421,13 +429,16 @@
 	case 'w':
 	    w_opt = TRUE;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
-	    break;
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
     if (optind < argc)
-	usage();
+	usage(FALSE);
 
     test_inserts(0);
     endwin();
diff --git a/test/key_names.c b/test/key_names.c
index 579f02f..fa7fdba 100644
--- a/test/key_names.c
+++ b/test/key_names.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007-2008,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 2007-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: key_names.c,v 1.5 2014/08/02 17:24:55 tom Exp $
+ * $Id: key_names.c,v 1.11 2022/12/04 00:40:11 tom Exp $
  */
 
 #include <test.priv.h>
@@ -34,15 +35,32 @@
 #if USE_WIDEC_SUPPORT
 
 static void
-usage(void)
+usage(int ok)
 {
-    fprintf(stderr, "Usage: key_names [-m] [-s]\n");
-    ExitProgram(EXIT_FAILURE);
+    static const char *msg[] =
+    {
+	"Usage: key_names"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -m       call meta(TRUE) in initialization"
+	," -s       call newterm, etc., to complete initialization"
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
 {
+    int ch;
     int n;
 
     bool do_setup = FALSE;
@@ -50,16 +68,19 @@
 
     setlocale(LC_ALL, "");
 
-    while ((n = getopt(argc, argv, "ms")) != -1) {
-	switch (n) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "ms")) != -1) {
+	switch (ch) {
 	case 'm':
 	    do_meta = TRUE;
 	    break;
 	case 's':
 	    do_setup = TRUE;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
+	    usage(ch == OPTS_USAGE);
 	    /* NOTREACHED */
 	}
     }
@@ -77,7 +98,8 @@
 	endwin();
     }
     for (n = -1; n < KEY_MAX + 512; n++) {
-	const char *result = key_name((wchar_t) n);
+	int check = wcwidth((wchar_t) n);
+	const char *result = check >= 0 ? key_name((wchar_t) n) : "?";
 	if (result != 0)
 	    printf("%d(%5o):%s\n", n, n, result);
     }
diff --git a/test/keynames.c b/test/keynames.c
index 26cfa87..cae260f 100644
--- a/test/keynames.c
+++ b/test/keynames.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 1998-2006,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            *
@@ -26,37 +27,57 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: keynames.c,v 1.9 2008/10/11 20:22:37 tom Exp $
+ * $Id: keynames.c,v 1.13 2022/12/04 00:40:11 tom Exp $
  */
 
 #include <test.priv.h>
 
 static void
-usage(void)
+usage(int ok)
 {
-    fprintf(stderr, "Usage: keynames [-m] [-s]\n");
-    ExitProgram(EXIT_FAILURE);
+    static const char *msg[] =
+    {
+	"Usage: keynames"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -m       call meta(TRUE) in initialization"
+	," -s       call newterm, etc., to complete initialization"
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
 {
+    int ch;
     int n;
     bool do_setup = FALSE;
     bool do_meta = FALSE;
 
     setlocale(LC_ALL, "");
 
-    while ((n = getopt(argc, argv, "ms")) != -1) {
-	switch (n) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "ms")) != -1) {
+	switch (ch) {
 	case 'm':
 	    do_meta = TRUE;
 	    break;
 	case 's':
 	    do_setup = TRUE;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
+	    usage(ch == OPTS_USAGE);
 	    /* NOTREACHED */
 	}
     }
diff --git a/test/knight.c b/test/knight.c
index ae9d223..b15c4d2 100644
--- a/test/knight.c
+++ b/test/knight.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018-2021,2022 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            *
@@ -33,25 +34,26 @@
  * Eric S. Raymond <esr@snark.thyrsus.com> July 22 1995.  Mouse support
  * added September 20th 1995.
  *
- * $Id: knight.c,v 1.36 2013/02/16 19:53:08 tom Exp $
+ * $Id: knight.c,v 1.52 2022/12/04 00:40:11 tom Exp $
  */
 
 #include <test.priv.h>
 
 /* board size */
-#define BDEPTH	8
-#define BWIDTH	8
+#define YLIMIT		8
+#define XLIMIT		8
+#define MAXMOVES	(ylimit * xlimit)
 
 /* where to start the instructions */
-#define INSTRY	2
-#define INSTRX	35
+#define INSTRY		2
+#define INSTRX		35
 
 /* corner of board */
-#define BOARDY	2
-#define BOARDX	0
+#define BOARDY		2
+#define BOARDX		0
 
 /* notification line */
-#define NOTIFYY	21
+#define NOTIFYY		21
 
 /* virtual color values */
 #define TRAIL_COLOR	1
@@ -65,20 +67,30 @@
 #define CYINV(y)	(((y) - 2) / 2)
 
 typedef struct {
-    short x, y;
-} cell;
+    int x, y;
+} HISTORY;
+
+typedef int SQUARES[YLIMIT][XLIMIT];
 
 static WINDOW *boardwin;	/* the board window */
 static WINDOW *helpwin;		/* the help window */
 static WINDOW *msgwin;		/* the message window */
-static cell history[BDEPTH * BWIDTH + 1];	/* choice history */
+
+#if HAVE_USE_DEFAULT_COLORS
+static bool d_option;
+#endif
+
 static chtype minus = '-';	/* possible-move character */
 static chtype oldch;
 static chtype plus = '+';	/* cursor hot-spot character */
 static chtype trail = '#';	/* trail character */
-static int movecount;		/* count of moves so far */
-static int trialcount;		/* count of trials so far */
-static short board[BDEPTH][BWIDTH];	/* the squares */
+
+static int ylimit = YLIMIT;
+static int xlimit = XLIMIT;
+static int maxmoves = (YLIMIT * XLIMIT);
+
+static int count_tries;		/* count of trials so far */
+static int test_test;		/* FIXME */
 /* *INDENT-OFF* */
 static const struct {
     int y;
@@ -93,6 +105,7 @@
     {  1, -2 },
     {  2, -1 },
 };
+#define MAX_OFFSET	(unsigned)SIZEOF(offsets)
 /* *INDENT-ON* */
 
 static void
@@ -104,9 +117,12 @@
     initscr();
     cbreak();			/* immediate char return */
     noecho();			/* no immediate echo */
-    boardwin = newwin(BDEPTH * 2 + 1, BWIDTH * 4 + 1, BOARDY, BOARDX);
+
+    maxmoves = MAXMOVES;
+    boardwin = newwin(ylimit * 2 + 1, xlimit * 4 + 1, BOARDY, BOARDX);
     helpwin = newwin(0, 0, INSTRY, INSTRX);
     msgwin = newwin(1, INSTRX - 1, NOTIFYY, 0);
+
     scrollok(msgwin, TRUE);
     keypad(boardwin, TRUE);
 
@@ -115,7 +131,7 @@
 
 	start_color();
 #if HAVE_USE_DEFAULT_COLORS
-	if (use_default_colors() == OK)
+	if (d_option && (use_default_colors() == OK))
 	    bg = -1;
 #endif
 
@@ -178,7 +194,11 @@
     (void) waddstr(helpwin, "r -- redraw screen       \\|/      \\|/ \n");
     (void) waddstr(helpwin, "bksp -- undo move       h-+-l    4-+-6\n");
     (void) waddstr(helpwin, "a -- autojump            /|\\      /|\\ \n");
-    (void) waddstr(helpwin, "                        b j n    1 2 3\n");
+    if (ylimit <= 6) {
+	(void) waddstr(helpwin, "R -- solve (slow)       b j n    1 2 3\n");
+    } else {
+	(void) waddstr(helpwin, "                        b j n    1 2 3\n");
+    }
 
     (void) waddstr(helpwin, "\nYou can place your knight on the selected\n");
     (void) waddstr(helpwin, "square with spacebar, Enter, or the keypad\n");
@@ -202,30 +222,33 @@
     wrefresh(helpwin);
 }
 
-static bool
-chksqr(int r1, int c1)
+static inline bool
+isValidYX(int y, int x)
 {
-    if ((r1 < 0) || (r1 > BDEPTH - 1))
-	return (FALSE);
-    if ((c1 < 0) || (c1 > BWIDTH - 1))
-	return (FALSE);
-    return ((!board[r1][c1]) ? TRUE : FALSE);
+    return (y >= 0 && y < ylimit && x >= 0 && x < xlimit) ? TRUE : FALSE;
+}
+
+static inline bool
+isUnusedYX(SQUARES squares, int y, int x)
+{
+    return (isValidYX(y, x) && (!squares[y][x]) ? TRUE : FALSE);
 }
 
 static bool
-chkmoves(int rw, int col)
-/* check to see if valid moves are available */
+boardIsFilled(SQUARES squares, int y, int x)
 {
     unsigned n;
 
-    for (n = 0; n < SIZEOF(offsets); n++)
-	if (chksqr(rw + offsets[n].y, col + offsets[n].x))
-	    return (TRUE);
-    return (FALSE);
+    for (n = 0; n < MAX_OFFSET; n++) {
+	if (isUnusedYX(squares, y + offsets[n].y, x + offsets[n].x)) {
+	    return FALSE;
+	}
+    }
+    return TRUE;
 }
 
 static void
-dosquares(void)
+drawBoard(void)
 {
     int i, j;
 
@@ -233,7 +256,7 @@
 
     move(BOARDY, BOARDX);
     waddch(boardwin, ACS_ULCORNER);
-    for (j = 0; j < 7; j++) {
+    for (j = 0; j < (ylimit - 1); j++) {
 	waddch(boardwin, ACS_HLINE);
 	waddch(boardwin, ACS_HLINE);
 	waddch(boardwin, ACS_HLINE);
@@ -244,10 +267,10 @@
     waddch(boardwin, ACS_HLINE);
     waddch(boardwin, ACS_URCORNER);
 
-    for (i = 1; i < BDEPTH; i++) {
+    for (i = 1; i < ylimit; i++) {
 	move(BOARDY + i * 2 - 1, BOARDX);
 	waddch(boardwin, ACS_VLINE);
-	for (j = 0; j < BWIDTH; j++) {
+	for (j = 0; j < xlimit; j++) {
 	    waddch(boardwin, ' ');
 	    waddch(boardwin, ' ');
 	    waddch(boardwin, ' ');
@@ -255,7 +278,7 @@
 	}
 	move(BOARDY + i * 2, BOARDX);
 	waddch(boardwin, ACS_LTEE);
-	for (j = 0; j < BWIDTH - 1; j++) {
+	for (j = 0; j < xlimit - 1; j++) {
 	    waddch(boardwin, ACS_HLINE);
 	    waddch(boardwin, ACS_HLINE);
 	    waddch(boardwin, ACS_HLINE);
@@ -269,7 +292,7 @@
 
     move(BOARDY + i * 2 - 1, BOARDX);
     waddch(boardwin, ACS_VLINE);
-    for (j = 0; j < BWIDTH; j++) {
+    for (j = 0; j < xlimit; j++) {
 	waddch(boardwin, ' ');
 	waddch(boardwin, ' ');
 	waddch(boardwin, ' ');
@@ -278,7 +301,7 @@
 
     move(BOARDY + i * 2, BOARDX);
     waddch(boardwin, ACS_LLCORNER);
-    for (j = 0; j < BWIDTH - 1; j++) {
+    for (j = 0; j < xlimit - 1; j++) {
 	waddch(boardwin, ACS_HLINE);
 	waddch(boardwin, ACS_HLINE);
 	waddch(boardwin, ACS_HLINE);
@@ -291,37 +314,36 @@
 }
 
 static void
-mark_possibles(int prow, int pcol, chtype mark)
+mark_possibles(SQUARES squares, int y, int x, chtype mark)
 {
     unsigned n;
 
-    for (n = 0; n < SIZEOF(offsets); n++) {
-	if (chksqr(prow + offsets[n].y, pcol + offsets[n].x)) {
-	    cellmove(prow + offsets[n].y, pcol + offsets[n].x);
+    for (n = 0; n < MAX_OFFSET; n++) {
+	if (isUnusedYX(squares, y + offsets[n].y, x + offsets[n].x)) {
+	    cellmove(y + offsets[n].y, x + offsets[n].x);
 	    waddch(boardwin, mark);
 	}
     }
 }
 
 static bool
-find_next_move(int *y, int *x)
+find_next_move(SQUARES squares, HISTORY * doneData, int doneSize, int *y, int *x)
 {
-    unsigned j, k;
-    int found = -1;
-    int first = -1;
-    int next = -1;
-    int oldy, oldx;
-    int newy, newx;
     bool result = FALSE;
 
-    if (movecount > 1) {
-	oldy = history[movecount - 1].y;
-	oldx = history[movecount - 1].x;
-	for (j = 0; j < SIZEOF(offsets) * 2; j++) {
-	    k = j % SIZEOF(offsets);
-	    newy = oldy + offsets[k].y;
-	    newx = oldx + offsets[k].x;
-	    if (chksqr(newy, newx)) {
+    if (doneSize > 1) {
+	unsigned j;
+	int oldy = doneData[doneSize - 1].y;
+	int oldx = doneData[doneSize - 1].x;
+	int found = -1;
+	int first = -1;
+	int next = -1;
+
+	for (j = 0; j < MAX_OFFSET * 2; j++) {
+	    unsigned k = j % MAX_OFFSET;
+	    int newy = oldy + offsets[k].y;
+	    int newx = oldx + offsets[k].x;
+	    if (isUnusedYX(squares, newy, newx)) {
 		if (first < 0)
 		    first = (int) k;
 		if (newy == *y
@@ -345,16 +367,16 @@
 }
 
 static void
-count_next_moves(int y, int x)
+count_next_moves(SQUARES squares, int count_moves, int y, int x)
 {
     int count = 0;
     unsigned j;
 
-    wprintw(msgwin, "\nMove %d", movecount);
-    for (j = 0; j < SIZEOF(offsets); j++) {
+    wprintw(msgwin, "\nMove %d", count_moves);
+    for (j = 0; j < MAX_OFFSET; j++) {
 	int newy = y + offsets[j].y;
 	int newx = x + offsets[j].x;
-	if (chksqr(newy, newx)) {
+	if (isUnusedYX(squares, newy, newx)) {
 	    ++count;
 	}
     }
@@ -383,37 +405,38 @@
 }
 
 static void
-drawmove(chtype tchar, int oldy, int oldx, int row, int column)
+drawMove(SQUARES squares, int count_moves, chtype tchar, int oldy, int oldx, int
+	 row, int column)
 /* place the stars, update board & currents */
 {
-    if (movecount <= 1) {
+    if (count_moves <= 1) {
 	int i, j;
 
-	for (i = 0; i < BDEPTH; i++) {
-	    for (j = 0; j < BWIDTH; j++) {
-		if (movecount == 0) {
+	for (i = 0; i < ylimit; i++) {
+	    for (j = 0; j < xlimit; j++) {
+		if (count_moves == 0) {
 		    unmarkcell(i, j);
 		} else {
 		    cellmove(i, j);
 		    if (winch(boardwin) == minus)
-			waddch(boardwin, movecount ? ' ' : minus);
+			waddch(boardwin, ' ');
 		}
 	    }
 	}
     } else {
 	markcell(tchar, oldy, oldx);
-	mark_possibles(oldy, oldx, ' ');
+	mark_possibles(squares, oldy, oldx, ' ');
     }
 
     if (row >= 0 && column >= 0) {
 	markcell(trail, row, column);
-	mark_possibles(row, column, minus);
-	board[row][column] = TRUE;
+	mark_possibles(squares, row, column, minus);
+	squares[row][column] = TRUE;
     }
 
-    wprintw(msgwin, "\nMove %d", movecount);
-    if (trialcount != movecount)
-	wprintw(msgwin, " (%d tries)", trialcount);
+    wprintw(msgwin, "\nMove %d", count_moves);
+    if (count_tries != count_moves)
+	wprintw(msgwin, " (%d tries)", count_tries);
     wclrtoeol(msgwin);
 }
 
@@ -427,17 +450,16 @@
 }
 
 static bool
-evalmove(int row, int column)
-/* evaluate move */
+evaluate_move(SQUARES squares, HISTORY * doneData, int doneSize, int row, int column)
 {
-    if (movecount == 1)
+    if (doneSize <= 1)
 	return (TRUE);
-    else if (board[row][column] == TRUE) {
+    else if (squares[row][column] == TRUE) {
 	waddstr(msgwin, "\nYou've already been there.");
 	return (FALSE);
     } else {
-	int rdif = iabs(row - history[movecount - 1].y);
-	int cdif = iabs(column - history[movecount - 1].x);
+	int rdif = iabs(row - doneData[doneSize - 1].y);
+	int cdif = iabs(column - doneData[doneSize - 1].x);
 
 	if (!((rdif == 1) && (cdif == 2)) && !((rdif == 2) && (cdif == 1))) {
 	    waddstr(msgwin, "\nThat's not a legal knight's move.");
@@ -449,15 +471,18 @@
 }
 
 static int
-completed(void)
+completed(SQUARES squares)
 {
     int i, j, count = 0;
 
-    for (i = 0; i < BDEPTH; i++)
-	for (j = 0; j < BWIDTH; j++)
-	    if (board[i][j] != 0)
+    for (i = 0; i < ylimit; i++) {
+	for (j = 0; j < xlimit; j++) {
+	    if (squares[i][j] != 0) {
 		count += 1;
-    return (count == (BWIDTH * BDEPTH) ? -1 : count);
+	    }
+	}
+    }
+    return ((count == maxmoves) ? -1 : count);
 }
 
 static void
@@ -467,24 +492,126 @@
     beep();
 }
 
+/* Recursively try all possible moves, starting from (y,x) */
+static int
+recurBack(SQUARES squares, int y, int x, int total)
+{
+    int longest = total;
+    int best_x = x;
+    int best_y = y;
+    int result;
+
+    if (total < maxmoves) {
+	unsigned k;
+
+	for (k = 0; k < MAX_OFFSET; k++) {
+	    int try_x = x + offsets[k].x;
+	    int try_y = y + offsets[k].y;
+	    if (isUnusedYX(squares, try_y, try_x)) {
+		++test_test;
+		squares[try_y][try_x] = total + 1;
+		result = recurBack(squares, try_y, try_x, total + 1);
+		if (result > longest) {
+		    longest = result;
+		    best_x = try_x;
+		    best_y = try_y;
+		}
+		if (result >= maxmoves)
+		    break;
+		squares[try_y][try_x] = 0;	/* allow retry... */
+	    }
+	}
+    }
+
+    result = total;
+    if (longest > total) {
+	result = longest;
+	squares[best_y][best_x] = total + 1;
+	(void) recurBack(squares, best_y, best_x, total + 1);
+	if (result < maxmoves)
+	    squares[best_y][best_x] = 0;
+    }
+
+    return result;
+}
+
+/*
+ * Solve the Knight Tour problem using backtracking, returning the length of
+ * the resulting solution.  If this is invoked from a point where the remaining
+ * choices cannot complete the tour, the result will fall short.
+ */
+static int
+useBacktracking(SQUARES result, HISTORY * doneData, int doneSize)
+{
+    int y = 0, x = 0, n;
+    SQUARES squares;
+    int total;
+    int actual = doneSize - 1;
+
+    memset(squares, 0, sizeof(squares));
+    for (n = 1; n <= actual; ++n) {
+	y = doneData[n].y;
+	x = doneData[n].x;
+	squares[y][x] = n;
+    }
+
+    total = recurBack(squares, y, x, actual);
+    if (total > actual) {
+	for (y = 0; y < ylimit; ++y) {
+	    for (x = 0; x < xlimit; ++x) {
+		result[y][x] = squares[y][x];
+		if ((n = squares[y][x]) != 0) {
+		    doneData[n].y = y;
+		    doneData[n].x = x;
+		}
+	    }
+	}
+    }
+    return total;
+}
+
+static int
+reviewHistory(HISTORY * history, int count_moves, int review, int *ny, int *nx)
+{
+    if (review < 0) {
+	beep();
+	review = 0;
+    } else if (review > count_moves - 2) {
+	beep();
+	review = count_moves - 2;
+    } else {
+	*ny = history[count_moves - review - 1].y;
+	*nx = history[count_moves - review - 1].x;
+	wprintw(msgwin, "\nReview %d:%d.", count_moves - review - 1,
+		count_moves - 1);
+	wrefresh(msgwin);
+    }
+    return review;
+}
+
 static void
 play(void)
 /* play the game */
 {
     bool keyhelp;		/* TRUE if keystroke help is up */
     int i, j, count;
-    int lastcol = 0;		/* last location visited */
-    int lastrow = 0;
+    int lastcol;		/* last location visited */
+    int lastrow;
     int ny = 0, nx = 0;
     int review = 0;		/* review history */
+    int test_size;
     int rw = 0, col = 0;	/* current row and column */
 
     do {
+	SQUARES squares;
+	HISTORY history[(YLIMIT * XLIMIT) + 1];
+	int count_moves = 0;	/* count of moves so far */
+
 	/* clear screen and draw board */
 	werase(boardwin);
 	werase(helpwin);
 	werase(msgwin);
-	dosquares();
+	drawBoard();
 	help1();
 	wnoutrefresh(stdscr);
 	wnoutrefresh(helpwin);
@@ -492,19 +619,18 @@
 	wnoutrefresh(boardwin);
 	doupdate();
 
-	movecount = 0;
-	for (i = 0; i < BDEPTH; i++) {
-	    for (j = 0; j < BWIDTH; j++) {
-		board[i][j] = FALSE;
+	for (i = 0; i < ylimit; i++) {
+	    for (j = 0; j < xlimit; j++) {
 		unmarkcell(i, j);
 	    }
 	}
+	memset(squares, 0, sizeof(squares));
 	memset(history, 0, sizeof(history));
 	history[0].y = history[0].x = -1;
 	history[1].y = history[1].x = -1;
 	lastrow = lastcol = -2;
-	movecount = 1;
-	trialcount = 1;
+	count_moves = 1;
+	count_tries = 1;
 	keyhelp = FALSE;
 	show_help(&keyhelp);
 
@@ -512,7 +638,7 @@
 	    if (rw != lastrow || col != lastcol) {
 		if (lastrow >= 0 && lastcol >= 0) {
 		    cellmove(lastrow, lastcol);
-		    if (board[lastrow][lastcol])
+		    if (squares[lastrow][lastcol])
 			waddch(boardwin, trail);
 		    else
 			waddch(boardwin, oldch);
@@ -534,7 +660,7 @@
 	    case 'k':
 	    case '8':
 	    case KEY_UP:
-		ny = rw + BDEPTH - 1;
+		ny = rw + ylimit - 1;
 		nx = col;
 		break;
 	    case 'j':
@@ -547,7 +673,7 @@
 	    case '4':
 	    case KEY_LEFT:
 		ny = rw;
-		nx = col + BWIDTH - 1;
+		nx = col + xlimit - 1;
 		break;
 	    case 'l':
 	    case '6':
@@ -558,19 +684,19 @@
 	    case 'y':
 	    case '7':
 	    case KEY_A1:
-		ny = rw + BDEPTH - 1;
-		nx = col + BWIDTH - 1;
+		ny = rw + ylimit - 1;
+		nx = col + xlimit - 1;
 		break;
 	    case 'b':
 	    case '1':
 	    case KEY_C1:
 		ny = rw + 1;
-		nx = col + BWIDTH - 1;
+		nx = col + xlimit - 1;
 		break;
 	    case 'u':
 	    case '9':
 	    case KEY_A3:
-		ny = rw + BDEPTH - 1;
+		ny = rw + ylimit - 1;
 		nx = col + 1;
 		break;
 	    case 'n':
@@ -587,8 +713,8 @@
 		    MEVENT myevent;
 
 		    getmouse(&myevent);
-		    if (myevent.y >= CY(0) && myevent.y <= CY(BDEPTH)
-			&& myevent.x >= CX(0) && myevent.x <= CX(BWIDTH)) {
+		    if (myevent.y >= CY(0) && myevent.y <= CY(ylimit)
+			&& myevent.x >= CX(0) && myevent.x <= CX(xlimit)) {
 			nx = CXINV(myevent.x);
 			ny = CYINV(myevent.y);
 			ungetch('\n');
@@ -605,8 +731,8 @@
 		    request_mouse_pos();
 		    test_y = MOUSE_Y_POS + 0;
 		    test_x = MOUSE_X_POS + 1;
-		    if (test_y >= CY(0) && test_y <= CY(BDEPTH)
-			&& test_x >= CX(0) && test_x <= CX(BWIDTH)) {
+		    if (test_y >= CY(0) && test_y <= CY(ylimit)
+			&& test_x >= CX(0) && test_x <= CX(xlimit)) {
 			ny = CYINV(test_y);
 			nx = CXINV(test_x);
 			wmove(helpwin, 0, 0);
@@ -622,18 +748,20 @@
 	    case '\n':
 	    case ' ':
 		review = 0;
-		if (evalmove(rw, col)) {
-		    drawmove(trail,
-			     history[movecount - 1].y,
-			     history[movecount - 1].x,
+		if (evaluate_move(squares, history, count_moves, rw, col)) {
+		    drawMove(squares,
+			     count_moves,
+			     trail,
+			     history[count_moves - 1].y,
+			     history[count_moves - 1].x,
 			     rw, col);
-		    history[movecount].y = (short) rw;
-		    history[movecount].x = (short) col;
-		    movecount++;
-		    trialcount++;
+		    history[count_moves].y = (short) rw;
+		    history[count_moves].x = (short) col;
+		    count_moves++;
+		    count_tries++;
 
-		    if (!chkmoves(rw, col)) {
-			if (completed() < 0) {
+		    if (boardIsFilled(squares, rw, col)) {
+			if (completed(squares) < 0) {
 			    waddstr(msgwin, "\nYou won.");
 			} else {
 			    waddstr(msgwin,
@@ -649,40 +777,40 @@
 	    case KEY_BACKSPACE:
 	    case '\b':
 		review = 0;
-		if (movecount <= 0) {
+		if (count_moves <= 0) {
 		    no_previous_move();
-		} else if (movecount <= 1) {
-		    ny = history[movecount].y;
-		    nx = history[movecount].x;
+		} else if (count_moves <= 1) {
+		    ny = history[count_moves].y;
+		    nx = history[count_moves].x;
 		    if (nx < 0 || ny < 0) {
 			ny = (lastrow >= 0) ? lastrow : 0;
 			nx = (lastcol >= 0) ? lastcol : 0;
 		    }
-		    movecount = 0;
-		    board[ny][nx] = FALSE;
+		    count_moves = 0;
+		    squares[ny][nx] = FALSE;
 		    oldch = minus;
-		    drawmove(' ', ny, nx, -1, -1);
-		    movecount = 1;
-		    trialcount = 1;
+		    drawMove(squares, count_moves, ' ', ny, nx, -1, -1);
+		    count_moves = 1;
+		    count_tries = 1;
 		    no_previous_move();
 		} else {
-		    int oldy = history[movecount - 1].y;
-		    int oldx = history[movecount - 1].x;
+		    int oldy = history[count_moves - 1].y;
+		    int oldx = history[count_moves - 1].x;
 
-		    if (!board[rw][col]) {
+		    if (!squares[rw][col]) {
 			cellmove(rw, col);
 			waddch(boardwin, ' ');
 		    }
 
-		    board[oldy][oldx] = FALSE;
-		    --movecount;
-		    ny = history[movecount - 1].y;
-		    nx = history[movecount - 1].x;
+		    squares[oldy][oldx] = FALSE;
+		    --count_moves;
+		    ny = history[count_moves - 1].y;
+		    nx = history[count_moves - 1].x;
 		    if (nx < 0 || ny < 0) {
 			ny = oldy;
 			nx = oldx;
 		    }
-		    drawmove(' ', oldy, oldx, ny, nx);
+		    drawMove(squares, count_moves, ' ', oldy, oldx, ny, nx);
 
 		    /* avoid problems if we just changed the current cell */
 		    cellmove(lastrow, lastcol);
@@ -693,32 +821,44 @@
 	    case 'a':
 		nx = col;
 		ny = rw;
-		if (find_next_move(&ny, &nx))
-		    count_next_moves(ny, nx);
+		if (find_next_move(squares, history, count_moves, &ny, &nx))
+		    count_next_moves(squares, count_moves, ny, nx);
 		else
 		    beep();
 		break;
 
 	    case 'F':
-		if (review > 0) {
-		    review--;
-		    ny = history[movecount - review - 1].y;
-		    nx = history[movecount - review - 1].x;
-		} else {
-		    beep();
-		}
+		review = reviewHistory(history, count_moves, review - 1,
+				       &ny, &nx);
 		break;
 
 	    case 'B':
-		if (review < movecount - 2) {
-		    review++;
-		    ny = history[movecount - review - 1].y;
-		    nx = history[movecount - review - 1].x;
-		} else {
-		    beep();
-		}
+		review = reviewHistory(history, count_moves, review + 1,
+				       &ny, &nx);
 		break;
 
+	    case 'R':
+		if (ylimit <= 6) {
+		    wprintw(msgwin, "\nworking...");
+		    wrefresh(msgwin);
+		    test_test = 0;
+		    test_size = useBacktracking(squares, history, count_moves);
+		    wprintw(msgwin, "\nOk %d:%d (%d tests)",
+			    test_size, maxmoves, test_test);
+		    review = 0;
+		    while (count_moves <= test_size) {
+			markcell(trail,
+				 ny = history[count_moves].y,
+				 nx = history[count_moves].x);
+			count_moves++;
+		    }
+		} else {
+		    wprintw(msgwin, "\nBoard is too large.");
+		}
+		wrefresh(msgwin);
+		break;
+
+#if HAVE_CURSCR
 	    case KEY_REDO:
 	    case '\f':
 	    case 'r':
@@ -729,12 +869,13 @@
 		wnoutrefresh(helpwin);
 		doupdate();
 		break;
+#endif
 
 	    case 'q':
 	    case 'x':
 		goto dropout;
 
-	    case '?':
+	    case HELP_KEY_1:
 		show_help(&keyhelp);
 		break;
 
@@ -743,12 +884,12 @@
 		break;
 	    }
 
-	    col = nx % BWIDTH;
-	    rw = ny % BDEPTH;
+	    col = nx % xlimit;
+	    rw = ny % ylimit;
 	}
 
       dropout:
-	if ((count = completed()) < 0)
+	if ((count = completed(squares)) < 0)
 	    wprintw(msgwin, "\nYou won.  Care to try again? ");
 	else
 	    wprintw(msgwin, "\n%d squares filled.  Try again? ", count);
@@ -757,9 +898,62 @@
 	(tolower(wgetch(msgwin)) == 'y');
 }
 
-int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+static void
+usage(int ok)
 {
+    static const char *msg[] =
+    {
+	"Usage: knight [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+#if HAVE_USE_DEFAULT_COLORS
+	," -d       invoke use_default_colors"
+#endif
+	," -n NUM   set board-size to NUM*NUM (default 8x8)"
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "dn:")) != -1) {
+	switch (ch) {
+#if HAVE_USE_DEFAULT_COLORS
+	case 'd':
+	    d_option = TRUE;
+	    break;
+#endif
+	case 'n':
+	    ch = atoi(optarg);
+	    if (ch < 3 || ch > 8) {
+		fprintf(stderr, "board size %d is outside [3..8]\n", ch);
+		usage(FALSE);
+	    }
+	    xlimit = ylimit = ch;
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
     init_program();
 
     play();
@@ -767,5 +961,3 @@
     endwin();
     ExitProgram(EXIT_SUCCESS);
 }
-
-/* knight.c ends here */
diff --git a/test/linedata.h b/test/linedata.h
index 751bc6b..f042ab4 100644
--- a/test/linedata.h
+++ b/test/linedata.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2009-2010,2012 Free Software Foundation, Inc.              *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2009-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            *
@@ -26,6 +27,16 @@
  * authorization.                                                           *
  ****************************************************************************/
 
+/*
+ * $Id: linedata.h,v 1.8 2020/02/02 23:34:34 tom Exp $
+ *
+ * Utility functions for reading a line of text from a file.
+ */
+#ifndef LINEDATA_H_incl
+#define LINEDATA_H_incl 1
+
+#include <test.priv.h>
+
 #define isQUIT(c)     ((c) == QUIT || (c) == ESCAPE)
 
 #define key_RECUR     CTRL('W')
@@ -96,3 +107,5 @@
     }
     return result;
 }
+
+#endif /* LINEDATA_H_incl */
diff --git a/test/linux-color.dat b/test/linux-color.dat
index 528b3f0..ef922eb 100644
--- a/test/linux-color.dat
+++ b/test/linux-color.dat
@@ -1,5 +1,6 @@
 ##############################################################################
-# Copyright (c) 2004,2006 Free Software Foundation, Inc.                     #
+# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2004,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 "Software"), #
@@ -25,7 +26,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: linux-color.dat,v 1.2 2006/04/22 21:40:00 tom Exp $
+# $Id: linux-color.dat,v 1.3 2020/02/08 21:38:22 tom Exp $
 # These values are derived from linux/drivers/char/vt.c (default_red[],
 # default_grn[] and default_blu[]), commented
 /* the default colour table, for VGA+ colour systems */
diff --git a/test/list_keys.c b/test/list_keys.c
new file mode 100644
index 0000000..b616919
--- /dev/null
+++ b/test/list_keys.c
@@ -0,0 +1,533 @@
+/****************************************************************************
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 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.                                                           *
+ ****************************************************************************/
+/*
+ * $Id: list_keys.c,v 1.33 2023/11/11 00:35:05 tom Exp $
+ *
+ * Author: Thomas E Dickey
+ *
+ * List function keys for one or more terminals.
+ */
+
+#define USE_TINFO
+#include <test.priv.h>
+
+#if NCURSES_XNAMES
+#if HAVE_TERM_ENTRY_H
+#include <term_entry.h>
+#else
+#undef NCURSES_XNAMES
+#define NCURSES_XNAMES 0
+#endif
+#endif
+
+#if HAVE_TIGETSTR
+#if defined(HAVE_CURSES_DATA_BOOLNAMES) || defined(DECL_CURSES_DATA_BOOLNAMES)
+
+static bool f_opt = FALSE;
+static bool m_opt = FALSE;
+static bool t_opt = FALSE;
+
+#if NCURSES_XNAMES || HAVE_USE_EXTENDED_NAMES
+static bool x_opt = FALSE;
+#endif
+
+typedef enum {
+    ktCursor
+    ,ktFunction
+    ,ktOther
+#if HAVE_USE_EXTENDED_NAMES
+    ,ktExtended
+#endif
+} KEYTYPE;
+
+typedef struct {
+    KEYTYPE type;
+    const char *name;
+} KEYNAMES;
+
+#define Type(n) list[n].type
+#define Name(n) list[n].name
+
+static void
+failed(const char *msg)
+{
+    perror(msg);
+    ExitProgram(EXIT_FAILURE);
+}
+
+static const char *
+full_name(const char *name)
+{
+    const char *result = name;
+    int n;
+    for (n = 0; strnames[n] != 0; ++n) {
+	if (!strcmp(name, strnames[n])) {
+	    result = strfnames[n];
+	    break;
+	}
+    }
+    return result;
+}
+
+static int
+show_key(const char *name, bool show)
+{
+    int width = 0;
+    NCURSES_CONST char *value = tigetstr((NCURSES_CONST char *) name);
+
+    if (show && t_opt)
+	fputc('"', stdout);
+
+    if (value != 0 && value != (char *) -1) {
+	while (*value != 0) {
+	    char buffer[10];
+	    int ch = UChar(*value++);
+	    switch (ch) {
+	    case '\177':
+		_nc_STRCPY(buffer, "^?", sizeof(buffer));
+		break;
+	    case '\033':
+		_nc_STRCPY(buffer, "\\E", sizeof(buffer));
+		break;
+	    case '\b':
+		_nc_STRCPY(buffer, "\\b", sizeof(buffer));
+		break;
+	    case '\f':
+		_nc_STRCPY(buffer, "\\f", sizeof(buffer));
+		break;
+	    case '\n':
+		_nc_STRCPY(buffer, "\\n", sizeof(buffer));
+		break;
+	    case '\r':
+		_nc_STRCPY(buffer, "\\r", sizeof(buffer));
+		break;
+	    case ' ':
+		_nc_STRCPY(buffer, "\\s", sizeof(buffer));
+		break;
+	    case '\t':
+		_nc_STRCPY(buffer, "\\t", sizeof(buffer));
+		break;
+	    case '^':
+		_nc_STRCPY(buffer, "\\^", sizeof(buffer));
+		break;
+	    case ':':
+		_nc_STRCPY(buffer, "\\072", sizeof(buffer));
+		break;
+	    case '\\':
+		_nc_STRCPY(buffer, "\\\\", sizeof(buffer));
+		break;
+	    default:
+		if (t_opt && ch == '"') {
+		    _nc_STRCPY(buffer, "\"\"", sizeof(buffer));
+		} else if (isgraph(ch)) {
+		    _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer))
+				"%c", ch);
+		} else if (ch < 32) {
+		    _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer))
+				"^%c", ch + '@');
+		} else {
+		    _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer))
+				"\\%03o", ch);
+		}
+		break;
+	    }
+	    width += (int) strlen(buffer);
+	    if (show)
+		fputs(buffer, stdout);
+	}
+    }
+
+    if (show && t_opt)
+	fputc('"', stdout);
+
+    return width;
+}
+
+static bool
+valid_key(const char *name, TERMINAL **terms, int count)
+{
+    bool result = FALSE;
+    if (*name == 'k') {
+	int k;
+	for (k = 0; k < count; ++k) {
+	    set_curterm(terms[k]);
+	    if (show_key(name, FALSE)) {
+		result = TRUE;
+		break;
+	    }
+	}
+    }
+    return result;
+}
+
+static int
+compare_keys(const void *a, const void *b)
+{
+    const KEYNAMES *p = (const KEYNAMES *) a;
+    const KEYNAMES *q = (const KEYNAMES *) b;
+    int result = (int) (p->type - q->type);
+    int pn, qn;
+    if (result == 0) {
+	if (p->type == ktFunction &&
+	    sscanf(p->name, "kf%d", &pn) == 1 &&
+	    sscanf(q->name, "kf%d", &qn) == 1) {
+	    result = (pn - qn);
+	} else {
+	    result = strcmp(p->name, q->name);
+	}
+    }
+    return result;
+}
+
+static void
+draw_line(int width)
+{
+    if (!t_opt) {
+	int j;
+	for (j = 0; j < width; ++j) {
+	    printf("-");
+	}
+	printf("\n");
+    }
+}
+
+static const char *
+modified_key(const char *name)
+{
+    static char result[100];
+    char buffer[sizeof(result) - 10];
+    int value;
+    char chr;
+    static const char *modifiers[][2] =
+    {
+	{"", ""},
+	{"s-", "shift-"},
+	{"a-", "alt-"},
+	{"as-", "alt-shift-"},
+	{"c-", "ctrl-"},
+	{"sc-", "ctrl-shift-"},
+	{"ac-", "alt-ctrl-"},
+	{"acs-" "alt-ctrl-shift-"},
+    };
+
+    if (strlen(name) > (sizeof(result) - 3)) {
+	*result = '\0';
+    } else if (sscanf(name, "kf%d%c", &value, &chr) == 1 &&
+	       value >= 1 &&
+	       value <= 63) {
+	/* map 1,2,3,4,5,6,7 to 1,2,5,... */
+	int map = ((value - 1) / 12);
+	int key = ((value - 1) % 12);
+	int bit1 = (map & 2);
+	int bit2 = (map & 4);
+	map &= ~6;
+	map |= (bit1 << 1) | (bit2 >> 1);
+	_nc_SPRINTF(result, _nc_SLIMIT(sizeof(result))
+		    "%sF%d", modifiers[map][(unsigned) f_opt], 1 + key);
+    } else if (sscanf(name, "k%80[A-Z]%d%c", buffer, &value, &chr) == 2 &&
+	       (value > 1 &&
+		value <= 8) &&
+	       (!strcmp(buffer, "UP") ||
+		!strcmp(buffer, "DN") ||
+		!strcmp(buffer, "LFT") ||
+		!strcmp(buffer, "RIT") ||
+		!strcmp(buffer, "IC") ||
+		!strcmp(buffer, "DC") ||
+		!strcmp(buffer, "HOM") ||
+		!strcmp(buffer, "END") ||
+		!strcmp(buffer, "NXT") ||
+		!strcmp(buffer, "PRV"))) {
+	_nc_SPRINTF(result, _nc_SLIMIT(sizeof(result))
+		    "%sk%s", modifiers[value - 1][(unsigned) f_opt], buffer);
+    } else if (sscanf(name, "k%80[A-Z]%c", buffer, &chr) == 1 &&
+	       (!strcmp(buffer, "UP") ||
+		!strcmp(buffer, "DN"))) {
+	_nc_SPRINTF(result, _nc_SLIMIT(sizeof(result))
+		    "%sk%s", modifiers[1][(unsigned) f_opt], buffer);
+    } else {
+	*result = '\0';
+    }
+    return result;
+}
+
+static void
+list_keys(TERMINAL **terms, int count)
+{
+    int j, k;
+    int widths0 = 0;
+    int widths1 = 0;
+    int widths2 = 0;
+    int widthsx;
+    int check;
+    size_t total = 0;
+    size_t actual = 0;
+    const char *name = f_opt ? "strfname" : "strname";
+    const char *modifier = "extended";
+    KEYNAMES *list;
+
+    for (total = 0; strnames[total]; ++total) {
+	;
+    }
+#if NCURSES_XNAMES
+    if (x_opt) {
+	for (k = 0; k < count; ++k) {
+	    TERMTYPE *term;
+	    set_curterm(terms[k]);
+	    term = (TERMTYPE *) cur_term;
+	    total += (size_t) (NUM_STRINGS(term) - STRCOUNT);
+	}
+    }
+#endif
+    list = typeCalloc(KEYNAMES, total + 1);
+    for (j = 0; strnames[j]; ++j) {
+	Type(j) = ktOther;
+	if (sscanf(strnames[j], "kf%d", &k) == 1) {
+	    Type(j) = ktFunction;
+	} else if (!(strncmp) (strnames[j], "kcu", 3)) {
+	    Type(j) = ktCursor;
+	}
+	Name(j) = strnames[j];
+    }
+#if NCURSES_XNAMES
+    if (x_opt) {
+	int m, n;
+
+	for (k = 0; k < count; ++k) {
+	    TERMTYPE *term;
+
+	    set_curterm(terms[k]);
+	    term = (TERMTYPE *) cur_term;
+	    for (n = STRCOUNT; n < NUM_STRINGS(term); ++n) {
+		bool found = FALSE;
+		const char *estr = ExtStrname(term, (int) n, strnames);
+		for (m = STRCOUNT; m < j; ++m) {
+		    if (!strcmp(estr, Name(m))) {
+			found = TRUE;
+			break;
+		    }
+		}
+		if (!found) {
+		    Type(j) = ktExtended;
+		    Name(j++) = estr;
+		}
+	    }
+	}
+    }
+#endif
+    actual = (size_t) j;
+    qsort(list, actual, sizeof(KEYNAMES), compare_keys);
+
+    widths0 = (int) strlen(name);
+    if (m_opt)
+	widths1 = (int) strlen(modifier);
+
+    for (k = 0; k < count; ++k) {
+	char *value;
+	set_curterm(terms[k]);
+	if ((value = termname()) == NULL)
+	    failed("termname");
+	check = (int) strlen(value);
+	if (widths2 < check)
+	    widths2 = check;
+    }
+    for (j = 0; Name(j) != 0; ++j) {
+	if (valid_key(Name(j), terms, count)) {
+	    const char *label = f_opt ? full_name(Name(j)) : Name(j);
+	    check = (int) strlen(label);
+	    if (widths0 < check)
+		widths0 = check;
+	    for (k = 0; k < count; ++k) {
+		set_curterm(terms[k]);
+		check = show_key(Name(j), FALSE) + 1;
+		if (widths2 < check)
+		    widths2 = check;
+		if (m_opt) {
+		    check = (int) strlen(modified_key(Name(j)));
+		    if (widths1 < check)
+			widths1 = check;
+		}
+	    }
+	}
+    }
+
+    if (t_opt) {
+	printf("\"%s\"", name);
+	if (m_opt)
+	    printf(",\"%s\"", modifier);
+    } else {
+	printf("%-*s", widths0, name);
+	if (m_opt)
+	    printf(" %-*s", widths1, modifier);
+    }
+    for (k = 0; k < count; ++k) {
+	set_curterm(terms[k]);
+	if (t_opt) {
+	    printf(",\"%s\"", termname());
+	} else if (k + 1 >= count) {
+	    printf(" %s", termname());
+	} else {
+	    printf(" %-*s", widths2, termname());
+	}
+    }
+    printf("\n");
+
+    widthsx = widths0 + ((count + 1) * widths2);
+
+    for (j = 0; Name(j) != 0; ++j) {
+	if (j == 0 || (Type(j) != Type(j - 1)))
+	    draw_line(widthsx);
+	if (valid_key(Name(j), terms, count)) {
+	    const char *label = f_opt ? full_name(Name(j)) : Name(j);
+	    if (t_opt) {
+		printf("\"%s\"", label);
+		if (m_opt)
+		    printf(",\"%s\"", modified_key(Name(j)));
+	    } else {
+		printf("%-*s", widths0, label);
+		if (m_opt)
+		    printf(" %-*s", widths1, modified_key(Name(j)));
+	    }
+	    for (k = 0; k < count; ++k) {
+		printf(t_opt ? "," : " ");
+		set_curterm(terms[k]);
+		check = show_key(Name(j), TRUE);
+		if (!t_opt) {
+		    if (k + 1 < count) {
+			printf("%*s", widths2 - check, " ");
+		    }
+		}
+	    }
+	    printf("\n");
+	}
+    }
+    free(list);
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: list_keys [options] [terminal [terminal2 [...]]]"
+	,""
+	,"Print capabilities for terminal special keys."
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -f       print full names"
+	," -m       print modifier-column for shift/control keys"
+	," -t       print result as CSV table"
+#ifdef NCURSES_VERSION
+	," -x       print extended capabilities"
+#endif
+    };
+    unsigned n;
+    for (n = 0; n < SIZEOF(msg); ++n) {
+	fprintf(stderr, "%s\n", msg[n]);
+    }
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+    TERMINAL **terms = typeCalloc(TERMINAL *, argc + 1);
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "fmtx")) != -1) {
+	switch (ch) {
+	case 'f':
+	    f_opt = TRUE;
+	    break;
+	case 'm':
+	    m_opt = TRUE;
+	    break;
+	case 't':
+	    t_opt = TRUE;
+	    break;
+#if NCURSES_XNAMES || HAVE_USE_EXTENDED_NAMES
+	case 'x':
+	    x_opt = TRUE;
+	    break;
+#endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+
+#if HAVE_USE_EXTENDED_NAMES
+    use_extended_names(x_opt);
+#endif
+
+    if (optind < argc) {
+	int found = 0;
+	int status;
+	int n;
+	for (n = optind; n < argc; ++n) {
+	    setupterm((NCURSES_CONST char *) argv[n], 1, &status);
+	    if (status > 0 && cur_term != 0) {
+		terms[found++] = cur_term;
+	    }
+	}
+	if (found)
+	    list_keys(terms, found);
+    } else {
+	setupterm(NULL, 1, (int *) 0);
+	terms[0] = cur_term;
+	list_keys(terms, 1);
+    }
+
+    free(terms);
+
+    ExitProgram(EXIT_SUCCESS);
+}
+
+#else
+int
+main(void)
+{
+    printf("This program requires the terminfo arrays\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
+#else /* !HAVE_TIGETSTR */
+int
+main(void)
+{
+    printf("This program requires the terminfo functions such as tigetstr\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif /* HAVE_TIGETSTR */
diff --git a/test/listused.sh b/test/listused.sh
index 1c3fe0a..45653eb 100755
--- a/test/listused.sh
+++ b/test/listused.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 ##############################################################################
-# Copyright (c) 2003-2006,2010 Free Software Foundation, Inc.                #
+# Copyright 2020-2021,2022 Thomas E. Dickey                                  #
+# Copyright 2003-2006,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"), #
@@ -26,14 +27,16 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: listused.sh,v 1.8 2010/09/18 15:15:15 tom Exp $
+# $Id: listused.sh,v 1.12 2022/07/16 16:33:38 tom Exp $
 # A very simple script to list all entrypoints that are used by either a test
 # program, or within the libraries.  This relies on the output format of 'nm',
 # and assumes that the libraries are configured with TRACE defined, and using
 # these options:
 #	--disable-macros
+#	--enable-opaque-curses
 #	--enable-sp-funcs
 #	--enable-widec
+#	--without-gpm
 # Static libraries are used, to provide some filtering based on internal usage
 # of the different symbols.
 
@@ -64,7 +67,7 @@
 		;;
 	*)
 		NAME=../objects/${name}.o
-		if test -f $NAME
+		if test -f "$NAME"
 		then
 			PROGS="$PROGS $NAME"
 		fi
@@ -75,19 +78,19 @@
 # For each library -
 for lib in ../lib/*.a
 do
-	LIB=`basename $lib .a`
+	LIB=`basename "$lib" .a`
 	case $LIB in
 	*_*|*+*)
 		continue
 		;;
 	esac
 
-	tmp=`echo $LIB|sed -e 's/w$//'`
+	tmp=`echo "$LIB"|sed -e 's/w$//'`
 	echo
 	echo "${tmp}:"
-	echo $tmp |sed -e 's/./-/g'
+	echo "$tmp" |sed -e 's/./-/g'
 	# Construct a list of public externals provided by the library.
-	WANT=`nm $NM_OPTS $lib |\
+	WANT=`nm $NM_OPTS "$lib" |\
 		sed	-e 's/^[^ ]*//' \
 			-e 's/^ *//' \
 			-e '/^[ a-z] /d' \
@@ -110,7 +113,7 @@
 				tags=$prog
 				;;
 			*)
-				TEST=`nm $NM_OPTS $prog |\
+				TEST=`nm $NM_OPTS "$prog" |\
 					sed	-e 's/^[^ ]*//' \
 						-e 's/^ *//' \
 						-e '/^[ a-z] /d' \
@@ -122,7 +125,7 @@
 						-e '/^[^_]/d'`
 				if test -n "$TEST"
 				then
-					have=`basename $prog .o`
+					have=`basename "$prog" .o`
 					if test -n "$HAVE"
 					then
 						if test "$last" = "$tags"
@@ -144,13 +147,13 @@
 		if test -z "$HAVE"
 		then
 			for tmp in ../lib/*.a
-			do 
+			do
 				case $tmp in
 				*_*|*+*)
 					continue
 					;;
 				esac
-				TEST=`nm $NM_OPTS $tmp |\
+				TEST=`nm $NM_OPTS "$tmp" |\
 					sed	-e 's/^[^ ]*//' \
 						-e 's/^ *//' \
 						-e '/^[ a-z] /d' \
@@ -163,20 +166,20 @@
 						-e '/^[^_]/d'`
 				if test -n "$TEST"
 				then
-					tmp=`basename $tmp .a |sed -e 's/w$//'`
-					HAVE=`echo $tmp | sed -e 's/lib/lib: /'`
+					tmp=`basename "$tmp" .a |sed -e 's/w$//'`
+					HAVE=`echo "$tmp" | sed -e 's/lib/lib: /'`
 					break
 				fi
 			done
 		fi
 		test -z "$HAVE" && HAVE="-"
-		lenn=`expr 39 - length $name`
-		lenn=`expr $lenn / 8`
+		lenn=`expr 39 - length "$name"`
+		lenn=`expr "$lenn" / 8`
 		tabs=
-		while test $lenn != 0
+		while test "$lenn" != 0
 		do
 			tabs="${tabs}	"
-			lenn=`expr $lenn - 1`
+			lenn=`expr "$lenn" - 1`
 		done
 		echo "${name}${tabs}${HAVE}"
 	done
diff --git a/test/lrtest.c b/test/lrtest.c
index da12034..0e609d0 100644
--- a/test/lrtest.c
+++ b/test/lrtest.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2005,2010 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2022 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            *
@@ -34,7 +35,7 @@
  * This can't be part of the ncurses test-program, because ncurses rips off the
  * bottom line to do labels.
  *
- * $Id: lrtest.c,v 1.22 2010/05/01 19:11:55 tom Exp $
+ * $Id: lrtest.c,v 1.29 2022/12/10 23:44:18 tom Exp $
  */
 
 #include <test.priv.h>
@@ -81,10 +82,28 @@
     }
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: lrtest [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
-main(
-	int argc GCC_UNUSED,
-	char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     static MARK marks[] =
     {
@@ -96,6 +115,20 @@
 	{1, 0, 1, 1, 1, '*' | A_REVERSE},
 	{2, 0, 1, 1, 1, '*' | A_REVERSE}
     };
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
 
     setlocale(LC_ALL, "");
 
@@ -131,7 +164,7 @@
     }
 
     for (;;) {
-	int ch;
+	int c2;
 	unsigned n;
 
 	box(stdscr, 0, 0);
@@ -139,21 +172,21 @@
 	    show(&marks[n]);
 	}
 
-	if ((ch = getch()) > 0) {
-	    if (ch == 'q')
+	if ((c2 = getch()) > 0) {
+	    if (c2 == 'q')
 		break;
-	    else if (ch == 's')
+	    else if (c2 == 's')
 		nodelay(stdscr, FALSE);
-	    else if (ch == ' ')
+	    else if (c2 == ' ')
 		nodelay(stdscr, TRUE);
 #ifdef TRACE
-	    else if (ch == 'T')
-		trace(0);
-	    else if (ch == 't')
-		trace(TRACE_CALLS | TRACE_ICALLS | TRACE_UPDATE);
+	    else if (c2 == 'T')
+		curses_trace(0);
+	    else if (c2 == 't')
+		curses_trace(TRACE_CALLS | TRACE_ICALLS | TRACE_UPDATE);
 #endif
 #ifdef KEY_RESIZE
-	    else if (ch == KEY_RESIZE) {
+	    else if (c2 == KEY_RESIZE) {
 		for (n = 0; n < SIZEOF(marks); n++) {
 		    if (marks[n].mode == 0) {	/* moving along x-direction */
 			if (marks[n].y)
@@ -174,8 +207,7 @@
 	refresh();
     }
 
-    curs_set(1);
-    endwin();
+    stop_curses();
     ExitProgram(EXIT_SUCCESS);
 }
 
diff --git a/test/make-tar.sh b/test/make-tar.sh
index 9371ac9..df4b66a 100755
--- a/test/make-tar.sh
+++ b/test/make-tar.sh
@@ -1,7 +1,8 @@
 #!/bin/sh
-# $Id: make-tar.sh,v 1.13 2015/05/16 17:12:45 tom Exp $
+# $Id: make-tar.sh,v 1.21 2022/11/05 19:41:33 tom Exp $
 ##############################################################################
-# Copyright (c) 2010-2013,2015 Free Software Foundation, Inc.                #
+# Copyright 2019-2021,2022 Thomas E. Dickey                                  #
+# Copyright 2010-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"), #
@@ -36,14 +37,20 @@
 
 TARGET=`pwd`
 
-: ${PKG_NAME:=ncurses-examples}
-: ${ROOTNAME:=ncurses-test}
-: ${DESTDIR:=$TARGET}
-: ${TMPDIR:=/tmp}
+: "${PKG_NAME:=ncurses-examples}"
+: "${ROOTNAME:=ncurses-test}"
+: "${DESTDIR:=$TARGET}"
+: "${TMPDIR:=/tmp}"
+
+# make timestamps of generated files predictable
+same_timestamp() {
+	[ -f ../NEWS ] || echo "OOPS $1"
+	touch -r ../NEWS "$1"
+}
 
 grep_assign() {
-	grep_assign=`egrep "^$2\>" "$1" | sed -e "s/^$2[ 	]*=[ 	]*//" -e 's/"//g'`
-	eval $2=\"$grep_assign\"
+	grep_assign=`grep -E "^$2\>" "$1" | sed -e "s/^$2[ 	]*=[ 	]*//" -e 's/"//g'`
+	eval "$2"=\""$grep_assign"\"
 }
 
 grep_patchdate() {
@@ -58,29 +65,35 @@
 	sed \
 		-e "s/\\<MAJOR\\>/$NCURSES_MAJOR/g" \
 		-e "s/\\<MINOR\\>/$NCURSES_MINOR/g" \
-		-e "s/\\<YYYYMMDD\\>/$NCURSES_PATCH/g" $1 >$1.new
-	chmod u+w $1
-	mv $1.new $1
+		-e "s/\\<YYYYMMDD\\>/$NCURSES_PATCH/g" "$1" >"$1.new"
+	chmod u+w "$1"
+	mv "$1.new" "$1"
+	same_timestamp "$1"
 }
 
 make_changelog() {
-	test -f $1 && chmod u+w $1
-	cat >$1 <<EOF
-`echo $PKG_NAME|tr '[A-Z]' '[a-z]'` ($NCURSES_MAJOR.$NCURSES_MINOR+$NCURSES_PATCH) unstable; urgency=low
+	[ -f "$1" ] && chmod u+w "$1"
+	cat >"$1" <<EOF
+`echo $PKG_NAME|tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` ($NCURSES_MAJOR.$NCURSES_MINOR+$NCURSES_PATCH) unstable; urgency=low
 
   * snapshot of ncurses subpackage for $PKG_NAME.
 
- -- `head -n 1 $HOME/.signature`  `date -R`
+ -- `head -n 1 "$HOME"/.signature`  `date -R`
 EOF
+	same_timestamp "$1"
 }
 
 # This can be run from either the subdirectory, or from the top-level
 # source directory.  We will put the tar file in the original directory.
-test -d ./test && cd ./test
+if [ -d ./test ]
+then
+	cd ./test || exit
+fi
 SOURCE=`cd ..;pwd`
 
 BUILD=$TMPDIR/make-tar$$
-trap "cd /; rm -rf $BUILD; exit 0" 0 1 2 5 15
+trap "cd /; rm -rf $BUILD; exit 1" 1 2 3 15
+trap "cd /; rm -rf $BUILD; exit 0" 0
 
 umask 077
 if ! ( mkdir $BUILD )
@@ -91,36 +104,37 @@
 umask 022
 mkdir $BUILD/$ROOTNAME
 
-cp -p -r * $BUILD/$ROOTNAME/ || exit
+cp -p -r ./* $BUILD/$ROOTNAME/ || exit
 
 # Add the config.* utility scripts from the top-level directory.
 for i in . ..
 do
-	for j in config.guess config.sub install-sh tar-copy.sh
+	for j in COPYING config.guess config.sub install-sh tar-copy.sh
 	do
-		test -f $i/$j && cp -p $i/$j $BUILD/$ROOTNAME/
+		[ -f $i/$j ] && cp -p $i/$j $BUILD/$ROOTNAME/
 	done
 done
 
 # Make rpm and dpkg scripts for test-builds
 grep_patchdate
-for spec in $BUILD/$ROOTNAME/package/*.spec
+for spec in "$BUILD/$ROOTNAME"/package/*.spec
 do
-	edit_specfile $spec
+	edit_specfile "$spec"
 done
-for spec in $BUILD/$ROOTNAME/package/debian*
+for spec in "$BUILD/$ROOTNAME"/package/debian*
 do
-	make_changelog $spec/changelog
+	make_changelog "$spec"/changelog
 done
 
-cp -p $SOURCE/NEWS $BUILD/$ROOTNAME
+cp -p "$SOURCE/NEWS" "$BUILD/$ROOTNAME"
 
 # cleanup empty directories (an artifact of ncurses source archives)
 
-touch $BUILD/$ROOTNAME/MANIFEST 
-( cd $BUILD/$ROOTNAME && find . -type f -print |$SOURCE/misc/csort >MANIFEST )
+touch $BUILD/$ROOTNAME/MANIFEST
+( cd $BUILD/$ROOTNAME && find . -type f -print | "$SOURCE/misc/csort" >MANIFEST )
+same_timestamp $BUILD/$ROOTNAME/MANIFEST
 
-cd $BUILD || exit 
+cd $BUILD || exit
 
 # Remove build-artifacts.
 find . -name RCS -exec rm -rf {} \;
@@ -137,8 +151,11 @@
 # Make the files writable...
 chmod -R u+w .
 
-tar cf - $ROOTNAME | gzip >$DESTDIR/$ROOTNAME.tar.gz
-cd $DESTDIR
+# Cleanup timestamps
+[ -n "$TOUCH_DIRS" ] && "$TOUCH_DIRS" "$ROOTNAME"
+
+tar cf - $TAR_OPTIONS $ROOTNAME | gzip >"$DESTDIR/$ROOTNAME.tar.gz"
+cd "$DESTDIR" || exit
 
 pwd
 ls -l $ROOTNAME.tar.gz
diff --git a/test/mensetmanus.xbm b/test/mensetmanus.xbm
new file mode 100644
index 0000000..095b8ec
--- /dev/null
+++ b/test/mensetmanus.xbm
@@ -0,0 +1,258 @@
+#define mensetmanus_width 161
+#define mensetmanus_height 145
+
+static char mensetmanus_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x3f, 0xdb, 0x0f, 0x00, 0x00, 0x00, 0x80, 0x07,
+ 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf7, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x80, 0x61, 0x00, 0x00, 0xc6,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc3, 0xff,
+ 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xe1, 0xff, 0xff, 0x87, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc3, 0xf6, 0x1f, 0x00, 0x00,
+ 0x00, 0xc0, 0xc0, 0xff, 0xff, 0x87, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x9f, 0x65, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0x00,
+ 0x07, 0x80, 0x87, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x9f, 0x6d, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xff, 0xff, 0xc7,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x89, 0x6d,
+ 0x1b, 0x00, 0x00, 0x00, 0xc0, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x81, 0x6d, 0x1b, 0x00, 0x00,
+ 0x00, 0xc0, 0xe1, 0x5b, 0xdb, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xc0, 0x81, 0x6d, 0x1b, 0x00, 0x00, 0x00, 0x80, 0x83,
+ 0x5b, 0xdb, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0x81, 0x6d, 0x1b, 0x00, 0x00, 0x00, 0x00, 0xcf, 0x5b, 0x1b, 0x0c,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x80, 0x6d,
+ 0x1b, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x5b, 0x1b, 0x0c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x80, 0x6d, 0x1b, 0x00, 0x00,
+ 0x00, 0x00, 0xf8, 0x5b, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0x83, 0x6d, 0x19, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0x5b, 0x0b, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xe0, 0x83, 0x6d, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x80, 0x5b, 0x0f, 0x0e,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0x6d,
+ 0x1b, 0x00, 0x00, 0x00, 0x00, 0x80, 0x4b, 0x0f, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0x79, 0x1b, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0x6b, 0xbf, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0xfb, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0x6d, 0xb7, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x03, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xed, 0xf7, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0xfe,
+ 0x7f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xed, 0xd7, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0xf8, 0xff, 0x07, 0x00,
+ 0x00, 0x00, 0xe0, 0xfe, 0xd7, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0xff, 0x7f, 0xe0, 0xff, 0x3f, 0x00, 0x00, 0x00, 0xf0,
+ 0xff, 0xd6, 0xfe, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
+ 0xbf, 0x73, 0x80, 0x3b, 0x7c, 0x00, 0x00, 0x00, 0xf8, 0xe7, 0xd6, 0xef,
+ 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xb9, 0x73, 0xc0,
+ 0x3b, 0xf0, 0x01, 0x00, 0x00, 0xff, 0xc3, 0xbf, 0xe7, 0x3f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xb8, 0x7f, 0xe0, 0x3b, 0xc0, 0x03,
+ 0x00, 0xc0, 0xbf, 0xc7, 0xbf, 0xe7, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x1c, 0xb8, 0xff, 0xf8, 0x3b, 0x80, 0x07, 0x00, 0xe0, 0x61,
+ 0x87, 0xfd, 0xe7, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e,
+ 0xb8, 0xf3, 0xff, 0x3b, 0x00, 0x0f, 0x00, 0x78, 0x60, 0x8e, 0xf1, 0x67,
+ 0xc7, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xb8, 0xc3, 0x8f,
+ 0x7b, 0x00, 0x0e, 0x00, 0x38, 0xe0, 0x8c, 0x03, 0x66, 0x87, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0xb8, 0x03, 0x83, 0x7b, 0x00, 0x1e,
+ 0x00, 0x1c, 0xe0, 0x1d, 0x03, 0x76, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc0, 0x07, 0xb8, 0xe3, 0x8f, 0xbb, 0x01, 0x39, 0x00, 0x1e, 0xe0,
+ 0x3b, 0x03, 0xf6, 0x87, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x0f,
+ 0xb8, 0xe3, 0x8f, 0x3b, 0xc6, 0x38, 0x00, 0x17, 0xe0, 0x73, 0x07, 0xfe,
+ 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0b, 0xb8, 0xe7, 0x8e,
+ 0x3b, 0x38, 0x78, 0x00, 0x13, 0xe0, 0x77, 0x06, 0xfe, 0xff, 0xff, 0xff,
+ 0x0f, 0x00, 0x00, 0x00, 0xe0, 0x12, 0x3c, 0xff, 0xce, 0x3b, 0x00, 0x78,
+ 0x80, 0x13, 0x60, 0xef, 0x0e, 0xfe, 0x00, 0x00, 0x60, 0x08, 0x00, 0x00,
+ 0x00, 0x70, 0x22, 0x3e, 0xfc, 0xfe, 0x39, 0x00, 0xe8, 0x80, 0x61, 0x60,
+ 0xce, 0x0f, 0xfe, 0x00, 0x00, 0x60, 0xf8, 0x00, 0x00, 0x00, 0x70, 0xc2,
+ 0x39, 0xf8, 0x7e, 0x38, 0x00, 0xc8, 0xc0, 0x81, 0x71, 0xde, 0x0f, 0xfe,
+ 0x00, 0x00, 0x60, 0x88, 0x00, 0x00, 0x00, 0x70, 0x04, 0x38, 0xe0, 0x0e,
+ 0x38, 0x00, 0xc4, 0xc0, 0x01, 0x7e, 0xbc, 0x1f, 0xfe, 0x00, 0x00, 0x60,
+ 0x88, 0x00, 0x00, 0x00, 0x78, 0x04, 0x38, 0xe0, 0x0e, 0x38, 0x00, 0xc4,
+ 0xc1, 0x01, 0x60, 0x3c, 0x1f, 0xfe, 0x00, 0x00, 0x60, 0x84, 0x0f, 0x00,
+ 0x00, 0x78, 0x08, 0x38, 0xe0, 0x0f, 0x38, 0x00, 0x82, 0xe1, 0x01, 0x60,
+ 0x74, 0x3e, 0xfe, 0x00, 0x00, 0x60, 0x44, 0x08, 0x00, 0x00, 0xb8, 0x10,
+ 0x38, 0xe0, 0x0f, 0x38, 0x00, 0x81, 0xe1, 0x00, 0x60, 0xe4, 0x3e, 0xfe,
+ 0x00, 0x00, 0x60, 0x44, 0x08, 0x00, 0x00, 0x98, 0x20, 0x38, 0xf8, 0x3f,
+ 0x38, 0x80, 0x80, 0xe1, 0x01, 0x60, 0xc4, 0x3c, 0xfe, 0x00, 0x00, 0x60,
+ 0x24, 0x0c, 0x00, 0x00, 0x1c, 0xc1, 0x39, 0x3c, 0x78, 0x38, 0x40, 0x80,
+ 0x61, 0x01, 0x60, 0xc4, 0x79, 0xfe, 0x00, 0x00, 0x60, 0x22, 0x32, 0x00,
+ 0x00, 0x1c, 0x01, 0x3e, 0x1c, 0xf0, 0x38, 0xf0, 0x9f, 0x61, 0x01, 0x60,
+ 0x84, 0x7b, 0xee, 0x00, 0x00, 0x60, 0x12, 0x21, 0x00, 0x00, 0x1c, 0x02,
+ 0x38, 0x0e, 0xe7, 0xf8, 0x3f, 0xe0, 0x61, 0x00, 0x60, 0x04, 0xf7, 0xce,
+ 0x00, 0x00, 0x60, 0x92, 0x10, 0x00, 0x00, 0x1c, 0x04, 0x38, 0x06, 0xff,
+ 0x38, 0x40, 0x80, 0x61, 0x02, 0x60, 0x04, 0xe7, 0xcf, 0x00, 0x00, 0x60,
+ 0x8a, 0x18, 0x00, 0x00, 0x1c, 0x18, 0x38, 0x07, 0xf0, 0x38, 0x00, 0x81,
+ 0x61, 0x02, 0x60, 0x04, 0xee, 0xcf, 0xff, 0x03, 0x60, 0x49, 0xe4, 0x00,
+ 0x00, 0x1c, 0x70, 0x38, 0x07, 0xe7, 0x38, 0x00, 0x82, 0x61, 0x04, 0x60,
+ 0x04, 0xdc, 0xcf, 0x01, 0x04, 0x60, 0x25, 0x42, 0x00, 0x00, 0x1c, 0xfe,
+ 0x3f, 0x03, 0xff, 0x38, 0x00, 0x84, 0x61, 0x08, 0x60, 0x04, 0xfc, 0xcf,
+ 0xf8, 0xff, 0x60, 0x95, 0x31, 0x00, 0x00, 0xfc, 0x01, 0xff, 0x03, 0xf0,
+ 0xf8, 0x1f, 0x88, 0x61, 0x10, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0xe1,
+ 0x53, 0x0c, 0x00, 0x00, 0x38, 0xf0, 0xff, 0x03, 0xef, 0xf8, 0x7f, 0x90,
+ 0x61, 0x40, 0xe0, 0xff, 0xff, 0xff, 0x00, 0xff, 0xe3, 0x2b, 0xfe, 0x00,
+ 0x00, 0x18, 0xf8, 0xff, 0x03, 0xff, 0x7c, 0xf0, 0x90, 0x61, 0x00, 0x3e,
+ 0x36, 0xe3, 0xe1, 0x00, 0x00, 0xe3, 0x9f, 0x60, 0x00, 0x00, 0x38, 0x3c,
+ 0x00, 0x03, 0xf0, 0x1f, 0xe0, 0xa0, 0xe1, 0x00, 0x30, 0x22, 0xe2, 0xc0,
+ 0x00, 0xff, 0xe3, 0x7f, 0x18, 0x00, 0x00, 0x38, 0x0e, 0x00, 0x07, 0xe7,
+ 0x07, 0xc0, 0xe1, 0xc1, 0x00, 0x18, 0x22, 0xe2, 0xc0, 0x00, 0x00, 0xe1,
+ 0x1f, 0x07, 0x00, 0x00, 0x38, 0x06, 0x00, 0x07, 0xef, 0x01, 0xc0, 0xc1,
+ 0xc1, 0x01, 0x16, 0x24, 0xe2, 0xc0, 0x01, 0xff, 0xe1, 0xff, 0x00, 0x00,
+ 0x00, 0x70, 0x07, 0x00, 0x0e, 0xf8, 0x00, 0x80, 0xc3, 0xc0, 0xf1, 0x11,
+ 0x24, 0xe4, 0xc0, 0x03, 0xe0, 0xe1, 0x7f, 0x00, 0x00, 0x00, 0x70, 0x07,
+ 0x00, 0x1e, 0x3c, 0x00, 0x80, 0xe3, 0x80, 0x0f, 0x10, 0x24, 0xe4, 0xc0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xe0, 0x03, 0x00, 0xfc, 0x0f,
+ 0x00, 0x00, 0x63, 0x80, 0x01, 0x08, 0x44, 0xe4, 0xc0, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x01, 0x00, 0xe0, 0x03, 0x00, 0xf8, 0x07, 0x00, 0x00, 0x73,
+ 0x80, 0x03, 0x08, 0x44, 0xe4, 0xc0, 0xfc, 0x00, 0x07, 0x0e, 0x00, 0x00,
+ 0x00, 0xc0, 0x03, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x33, 0x00, 0x03, 0x08,
+ 0x44, 0xe4, 0xe0, 0xcc, 0x00, 0x07, 0x0e, 0x00, 0x00, 0x00, 0xc0, 0x03,
+ 0x00, 0x78, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x07, 0x04, 0x44, 0xe8, 0x70,
+ 0xcc, 0x01, 0x87, 0x0f, 0x00, 0x00, 0x00, 0x80, 0x07, 0x00, 0x3e, 0x00,
+ 0x00, 0x80, 0x1f, 0x00, 0x0e, 0x04, 0x44, 0xe8, 0x38, 0xcc, 0x81, 0xe7,
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x0f, 0x00, 0x00, 0x80, 0x0f,
+ 0x00, 0x1c, 0x02, 0x44, 0xf8, 0x1e, 0xcc, 0xe1, 0xff, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0f, 0xc0, 0x23, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x38, 0x01,
+ 0x42, 0xfc, 0x0f, 0xcc, 0xf1, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e,
+ 0xf0, 0x39, 0x00, 0x00, 0xe0, 0x03, 0x00, 0xf0, 0x00, 0xc2, 0xff, 0x07,
+ 0xcc, 0x7f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7c, 0x0e, 0x00,
+ 0x00, 0xf0, 0x01, 0x00, 0xe0, 0x03, 0xe2, 0xe7, 0x07, 0xcc, 0x1f, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xbf, 0x23, 0xe0, 0xff, 0xff, 0x00,
+ 0x00, 0xc0, 0x1f, 0xff, 0x64, 0x06, 0xcc, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0xff, 0x3c, 0xf0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xff,
+ 0x7f, 0x64, 0x06, 0xcc, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70,
+ 0xf8, 0x1f, 0x78, 0x7c, 0x7f, 0x00, 0x00, 0x00, 0xfc, 0x20, 0x64, 0x06,
+ 0xcc, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xf8, 0x33, 0x1c,
+ 0x38, 0x66, 0x00, 0x00, 0x00, 0x0c, 0x20, 0x6c, 0x06, 0xcc, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x78, 0x3e, 0x0e, 0x38, 0x76, 0x00,
+ 0x00, 0x00, 0x0c, 0x20, 0x68, 0x06, 0xcc, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x38, 0xf8, 0x87, 0x0f, 0x38, 0x76, 0x00, 0x00, 0x00, 0x0c,
+ 0x20, 0x68, 0x06, 0xcc, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38,
+ 0x78, 0xf8, 0x0f, 0x38, 0x76, 0x00, 0x00, 0x00, 0x0c, 0x10, 0x68, 0x06,
+ 0xcc, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xf8, 0xff, 0x0f,
+ 0x38, 0x76, 0x00, 0x00, 0x00, 0x0c, 0x10, 0x68, 0x06, 0xcc, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0xf8, 0xff, 0x0e, 0x38, 0x76, 0x00,
+ 0x00, 0x00, 0x0c, 0x10, 0x68, 0x06, 0xcc, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x1c, 0xf8, 0xe1, 0x0e, 0x38, 0x3e, 0x00, 0x00, 0x00, 0x0c,
+ 0x08, 0x68, 0x06, 0xcc, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c,
+ 0x38, 0xe0, 0x0e, 0x38, 0x3e, 0x00, 0x00, 0x00, 0x0c, 0x08, 0x68, 0x06,
+ 0xcc, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x38, 0xe0, 0x0e,
+ 0x38, 0x3e, 0x00, 0x00, 0x00, 0x0c, 0x04, 0x68, 0x06, 0xcc, 0x0e, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x38, 0xe0, 0x0e, 0x38, 0x3e, 0x00,
+ 0x00, 0x00, 0x1c, 0x04, 0x68, 0x06, 0xcc, 0x0e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x06, 0x38, 0xe0, 0x0e, 0x38, 0x3e, 0x00, 0x00, 0x00, 0x1c,
+ 0x02, 0x68, 0x06, 0xcc, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
+ 0x38, 0xe0, 0x0e, 0x38, 0x3e, 0x00, 0x00, 0x00, 0x1c, 0x02, 0x68, 0x06,
+ 0xcc, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x38, 0xe0, 0x0e,
+ 0x38, 0x3e, 0x00, 0x00, 0x00, 0x1c, 0x01, 0x68, 0x06, 0xcc, 0x1c, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x38, 0xe0, 0x0e, 0x38, 0x3e, 0x00,
+ 0x00, 0x00, 0x18, 0x01, 0x68, 0x06, 0xcc, 0x1c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x03, 0x38, 0xe0, 0x0e, 0x38, 0x3e, 0x00, 0x00, 0x00, 0x98,
+ 0x00, 0x68, 0x06, 0xcc, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03,
+ 0x38, 0xe0, 0x0e, 0x38, 0x3e, 0x00, 0x00, 0x00, 0x98, 0x00, 0x68, 0x06,
+ 0xcc, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x38, 0xe0, 0x0e,
+ 0x38, 0x1e, 0x00, 0x00, 0x00, 0x58, 0x00, 0x6c, 0x0e, 0xcc, 0x18, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x30, 0xe0, 0x0e, 0x38, 0x1e, 0x00,
+ 0x00, 0x00, 0x38, 0x00, 0x64, 0x0e, 0xcc, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc0, 0x01, 0x70, 0xe0, 0x0e, 0x1c, 0x1e, 0x00, 0x00, 0x00, 0x18,
+ 0x00, 0x64, 0x1e, 0xcc, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
+ 0xe0, 0xe1, 0x0e, 0x0f, 0x1e, 0x00, 0x00, 0x00, 0x18, 0x00, 0x64, 0x3e,
+ 0xcc, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0xef, 0xce,
+ 0x07, 0x1e, 0x00, 0x00, 0x00, 0x18, 0x00, 0x64, 0x3e, 0xcc, 0x30, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0xff, 0xfe, 0x03, 0x1e, 0x00,
+ 0x00, 0x00, 0x18, 0x00, 0x64, 0x7e, 0xcc, 0x30, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0x00, 0x00, 0xfc, 0xfe, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x18,
+ 0x00, 0x64, 0x66, 0xcc, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00,
+ 0x00, 0xe0, 0x1e, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x18, 0x00, 0x66, 0xe6,
+ 0xcc, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0xe0, 0x0e,
+ 0x00, 0x1e, 0x00, 0x00, 0x00, 0x18, 0x00, 0x62, 0xc6, 0xcd, 0x70, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x1e, 0x00,
+ 0x00, 0x00, 0x18, 0x00, 0x62, 0xc6, 0xcd, 0x70, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x70, 0x00, 0xc0, 0xff, 0xff, 0x0f, 0x0e, 0x00, 0x00, 0x00, 0x38,
+ 0x00, 0x62, 0x86, 0xcf, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
+ 0xf0, 0xff, 0xff, 0x0f, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x61, 0x86,
+ 0xcf, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0xfc, 0x00, 0x00,
+ 0x0e, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x61, 0x8e, 0xcf, 0xe0, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x78, 0x00, 0x00, 0x0e, 0x0e, 0x00,
+ 0x00, 0x00, 0xf8, 0xff, 0x7f, 0xfe, 0xdf, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x18, 0x00, 0xf0, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00, 0x00, 0xf0,
+ 0xff, 0x3f, 0xff, 0xdf, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
+ 0xe0, 0x01, 0x00, 0x0e, 0x0e, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x8f, 0x07,
+ 0x9e, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0xe0, 0x07, 0x00,
+ 0x0e, 0x0f, 0x00, 0x00, 0x00, 0x30, 0x00, 0xc0, 0xff, 0x3f, 0xc0, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x0f, 0x00,
+ 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x1c, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0xf0,
+ 0xff, 0xff, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff,
+ 0x3f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x38, 0x00,
+ 0x38, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x7f, 0x00, 0x00,
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x38, 0x00, 0x38, 0xe0, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x06, 0x00,
+ 0x00, 0x00, 0x00, 0x06, 0x18, 0x00, 0x38, 0xe0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00,
+ 0x06, 0x18, 0x00, 0x38, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00,
+ 0xdc, 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x1c, 0x00,
+ 0x38, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x9c, 0x03, 0x00,
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x1c, 0x00, 0x18, 0x70, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x1c, 0x07, 0x00, 0x00, 0x06, 0x00,
+ 0x00, 0x00, 0x00, 0x07, 0x0c, 0x00, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0x00, 0x1c, 0xfe, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x07, 0x0c, 0x00, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00,
+ 0x1c, 0xfc, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0c, 0x00,
+ 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x1c, 0x1c, 0x00,
+ 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0e, 0x00, 0x18, 0x70, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x1c, 0x1c, 0x00, 0x80, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x07, 0x0e, 0x00, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0x00, 0x1c, 0x1c, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x07, 0x0e, 0x00, 0x18, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00,
+ 0x1c, 0x1c, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0e, 0x00,
+ 0x18, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x1c, 0x1c, 0x00,
+ 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x07, 0x06, 0x00, 0x18, 0x38, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x07, 0x06, 0x00, 0x18, 0x38, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x07, 0x0e, 0x00, 0x18, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00,
+ 0x1c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0e, 0x00,
+ 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x1c, 0x00, 0x00,
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0e, 0x00, 0x18, 0x30, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x06, 0x00,
+ 0x00, 0x00, 0x00, 0x07, 0x0e, 0x00, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00,
+ 0x07, 0x0e, 0x00, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00,
+ 0x1e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x00,
+ 0x38, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x1e, 0x00, 0x00,
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x1c, 0x00, 0x38, 0x70, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x06, 0x00,
+ 0x00, 0x00, 0x00, 0x06, 0x1c, 0x00, 0x38, 0xe0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00,
+ 0x06, 0x18, 0x00, 0x38, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00,
+ 0x1e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x18, 0x00,
+ 0x30, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x1e, 0x00, 0x00,
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x38, 0x00, 0x30, 0xe0, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x1f, 0x00, 0x00, 0x00, 0x06, 0x00,
+ 0x00, 0x00, 0x00, 0x0c, 0x3c, 0x00, 0x30, 0xf0, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0xf8, 0x03, 0x1f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00,
+ 0x0c, 0x7e, 0x00, 0x70, 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x0f,
+ 0x1f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x0c, 0xe7, 0x00,
+ 0x70, 0xbc, 0x03, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x1e, 0x1f, 0x00, 0x00,
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0xdc, 0xe3, 0x00, 0x60, 0x1e, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x0f, 0xfc, 0x1f, 0x00, 0x00, 0x00, 0x06, 0x00,
+ 0x00, 0x00, 0x00, 0xfc, 0xc1, 0x01, 0xe0, 0x0f, 0x0f, 0x00, 0x00, 0x00,
+ 0x80, 0x07, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00,
+ 0xf8, 0x80, 0x03, 0xe0, 0x03, 0x1e, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xe0,
+ 0x1b, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x78, 0x80, 0x07,
+ 0xe0, 0x01, 0x1c, 0x00, 0x00, 0x00, 0xe0, 0x01, 0xc0, 0x1b, 0x00, 0x00,
+ 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x0f, 0xe0, 0x01, 0x38,
+ 0x00, 0x00, 0x00, 0xf0, 0x00, 0xc0, 0x19, 0x00, 0x00, 0x00, 0x06, 0x00,
+ 0x00, 0x00, 0x00, 0x30, 0x0e, 0x1e, 0xc0, 0x71, 0xf8, 0x00, 0x00, 0x00,
+ 0x78, 0x00, 0xdc, 0x19, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00,
+ 0x30, 0x1f, 0x1e, 0xc0, 0xf9, 0xf8, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
diff --git a/test/mini.xterm_48x48.xpm b/test/mini.xterm_48x48.xpm
new file mode 100644
index 0000000..c4738f8
--- /dev/null
+++ b/test/mini.xterm_48x48.xpm
@@ -0,0 +1,264 @@
+/* XPM */
+static char * mini_xterm_48x48_xpm[] = {
+"48 48 213 2",
+"  	c None",
+". 	c #FF0000",
+"+ 	c #FF5300",
+"@ 	c #FF5E00",
+"# 	c #FF4800",
+"$ 	c #FF4200",
+"% 	c #FF4000",
+"& 	c #FF4B00",
+"* 	c #FF5200",
+"= 	c #FF5400",
+"- 	c #FF3500",
+"; 	c #FF5100",
+"> 	c #FF5C00",
+", 	c #FF3000",
+"' 	c #FF4500",
+") 	c #FF2000",
+"! 	c #FF0300",
+"~ 	c #FF1600",
+"{ 	c #FF5D00",
+"] 	c #FF3800",
+"^ 	c #FF0200",
+"/ 	c #FF0900",
+"( 	c #FF2B00",
+"_ 	c #FF3300",
+": 	c #FF1A00",
+"< 	c #FF1300",
+"[ 	c #FF1200",
+"} 	c #FF5700",
+"| 	c #4577BA",
+"1 	c #874E78",
+"2 	c #887577",
+"3 	c #887E77",
+"4 	c #887977",
+"5 	c #875078",
+"6 	c #566CA9",
+"7 	c #5E70A1",
+"8 	c #884E77",
+"9 	c #887677",
+"0 	c #7C5B83",
+"a 	c #795686",
+"b 	c #008DFE",
+"c 	c #0012F3",
+"d 	c #000BF2",
+"e 	c #008FFE",
+"f 	c #006CFA",
+"g 	c #0000F1",
+"h 	c #0001F1",
+"i 	c #0020F4",
+"j 	c #0040F6",
+"k 	c #0959F0",
+"l 	c #1158E8",
+"m 	c #1159E8",
+"n 	c #0058F9",
+"o 	c #001DF4",
+"p 	c #0023F4",
+"q 	c #005BFA",
+"r 	c #0060FA",
+"s 	c #0E58EB",
+"t 	c #0651F3",
+"u 	c #0033F5",
+"v 	c #000EF2",
+"w 	c #006EFA",
+"x 	c #0092FF",
+"y 	c #001FF4",
+"z 	c #000FF2",
+"A 	c #0C51EC",
+"B 	c #326AC9",
+"C 	c #7A6583",
+"D 	c #CA6234",
+"E 	c #FC5F03",
+"F 	c #FF5800",
+"G 	c #FF0800",
+"H 	c #F4060B",
+"I 	c #007CFB",
+"J 	c #0013F3",
+"K 	c #007EFB",
+"L 	c #FF1800",
+"M 	c #F3590C",
+"N 	c #AB6152",
+"O 	c #4F4EAD",
+"P 	c #175CE4",
+"Q 	c #0036F5",
+"R 	c #0022F4",
+"S 	c #0095FD",
+"T 	c #0084FD",
+"U 	c #0004F1",
+"V 	c #0051F8",
+"W 	c #345AC7",
+"X 	c #E61519",
+"Y 	c #FF5900",
+"Z 	c #FF4600",
+"` 	c #FF0100",
+" .	c #446EB9",
+"..	c #0034F6",
+"+.	c #0032F5",
+"@.	c #FF2200",
+"#.	c #006FFA",
+"$.	c #002DF5",
+"%.	c #0086FD",
+"&.	c #0046F7",
+"*.	c #0015F3",
+"=.	c #0076FC",
+"-.	c #FF0400",
+";.	c #FF2300",
+">.	c #FF2900",
+",.	c #9E3E61",
+"'.	c #0039F6",
+").	c #FF2A00",
+"!.	c #FF4300",
+"~.	c #0071FB",
+"{.	c #005EF9",
+"].	c #004DF7",
+"^.	c #008CFE",
+"/.	c #0008F2",
+"(.	c #001DF3",
+"_.	c #007DFB",
+":.	c #FF4100",
+"<.	c #FF5B00",
+"[.	c #A3425C",
+"}.	c #994C66",
+"|.	c #FF1100",
+"1.	c #0072FB",
+"2.	c #000AF2",
+"3.	c #006EFC",
+"4.	c #0017F3",
+"5.	c #007FFB",
+"6.	c #FF0600",
+"7.	c #FF5600",
+"8.	c #A56A5A",
+"9.	c #A53B5A",
+"0.	c #FF4F00",
+"a.	c #0076FB",
+"b.	c #0076FA",
+"c.	c #0093FF",
+"d.	c #007DFC",
+"e.	c #FF1C00",
+"f.	c #A5765A",
+"g.	c #A55D5A",
+"h.	c #006FFB",
+"i.	c #002CF5",
+"j.	c #008AFD",
+"k.	c #006BF9",
+"l.	c #FF3A00",
+"m.	c #FF5000",
+"n.	c #007BFB",
+"o.	c #008BFD",
+"p.	c #A5755A",
+"q.	c #9A5565",
+"r.	c #A43A5B",
+"s.	c #FF4D00",
+"t.	c #80507F",
+"u.	c #FF0F00",
+"v.	c #7A5485",
+"w.	c #A5555A",
+"x.	c #FF0A00",
+"y.	c #A53D5A",
+"z.	c #A4515B",
+"A.	c #A5685A",
+"B.	c #A5735A",
+"C.	c #FF0700",
+"D.	c #FF2E00",
+"E.	c #FF1500",
+"F.	c #A3705C",
+"G.	c #FF0500",
+"H.	c #9A4965",
+"I.	c #FF0E00",
+"J.	c #FF3B00",
+"K.	c #FF2D00",
+"L.	c #A13C5E",
+"M.	c #FF4C00",
+"N.	c #62649D",
+"O.	c #FF0B00",
+"P.	c #FF4700",
+"Q.	c #FF1D00",
+"R.	c #A56D5A",
+"S.	c #FF2C00",
+"T.	c #A4465B",
+"U.	c #FF1400",
+"V.	c #A03E61",
+"W.	c #FF3100",
+"X.	c #FF1B00",
+"Y.	c #FF1000",
+"Z.	c #0029F5",
+"`.	c #0027F4",
+" +	c #4571BA",
+".+	c #FF3900",
+"++	c #FF3200",
+"@+	c #008EFD",
+"#+	c #0019F3",
+"$+	c #0090FD",
+"%+	c #FF0D00",
+"&+	c #FF1E00",
+"*+	c #FF4E00",
+"=+	c #0088FC",
+"-+	c #0087FC",
+";+	c #FF1900",
+">+	c #0036F6",
+",+	c #FF2100",
+"'+	c #0073FB",
+")+	c #0062FA",
+"!+	c #001AF3",
+"~+	c #2463D8",
+"{+	c #3E58BE",
+"]+	c #2A7FD3",
+"^+	c #807B7F",
+"/+	c #008EFB",
+"(+	c #006AFA",
+"_+	c #004CF8",
+":+	c #717B8D",
+"<+	c #EE0B11",
+"[+	c #F73E08",
+"}+	c #FF1F00",
+"|+	c #FF5500",
+"                                                                                                ",
+"                                                                                                ",
+"    . . . . . . . . . . . . . . . . . .                 . . . . . . . . . . . . . . . .         ",
+"    . + @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ .                 . # @ @ @ @ @ @ @ @ @ @ @ @ $ .         ",
+"    . % & & & * @ @ @ @ @ = & & & & & .                 . - & & & & & ; @ > & & & & , .         ",
+"    . . . . . . * @ @ @ @ ; . . . . . .                 . . . . . . . ' @ ) . . . . . .         ",
+"              ! ~ { @ @ @ @ ] ^                                   / ( @ $ .                     ",
+"                ^ _ @ @ @ @ @ : !                               < [ > } ^ .                     ",
+"                | 1 2 3 3 3 3 4 5 6                           7 8 9 3 0 a                       ",
+"            b c d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d c e             ",
+"            f g g g g g g h i j k l m n o g g g g g g p q r s t u v g g g g g g g w             ",
+"          x y g g g g z A B C D E F G H I c g g g g J K   L / M N O P Q h g g g g R S           ",
+"          T g g g U V W X Y @ @ @ @ Z `  ...g g g g +.    ` ' @ @..     #.$.g g g g %.          ",
+"          &.g g *.=.    -.;.@ @ @ @ @ >.,.'.g g g g '.  / ).@ !..         ~.{.U g g ].          ",
+"        ^./.g (._.        ` :.@ @ @ @ <.[.'.g g g g '.}.|.<.} ^ .             1.2.g d e         ",
+"        3.g 4.5.            6.7.@ @ @ @ 8.'.g g g g '.9.0.@ [ .                 a./.g b.        ",
+"      c.R /.d.              -.e.@ @ @ @ f.'.g g g g '.g.@ - .                     h.h i.        ",
+"      j.k.%.                  ^ l.@ @ @ f.'.g g g g '.f.m.`                         n.f o.      ",
+"                                ! * @ @ f.'.g g g g '.p.G .                                     ",
+"                                ! ~ { @ f.'.g g g g '.q..                                       ",
+"                                  ^ _ @ f.'.g g g g '.r.                                        ",
+"                                    ^ s.f.'.g g g g '.t.                                        ",
+"                                    ^ u.p.'.g g g g '.v.                                        ",
+"                                      ^ w.'.g g g g '.r.                                        ",
+"                                      x.y.'.g g g g '.z.^                                       ",
+"                                      ` A.'.g g g g '.B.x..                                     ",
+"                                    C.D.f.'.g g g g '.f.# `                                     ",
+"                                  < E.{ F.'.g g g g '.f.@ ( ^                                   ",
+"                                : G.; @ H.'.g g g g '.f.@ <.I.^                                 ",
+"                                -.J.@ K.L.'.g g g g '.f.@ @ s.`                                 ",
+"                              I.) @ M.. N.'.g g g g '.f.@ @ @ _ ^                               ",
+"                            L O.F <.6..   '.g g g g '.f.@ @ @ { E.!                             ",
+"                            ^ P.@ Q..     '.g g g g '.R.@ @ @ @ * !                             ",
+"                          G S.@ % .       '.g g g g '.T.{ @ @ @ @ l.^                           ",
+"                        < U.> 7.^         ..g g g g u V.W.@ @ @ @ @ e.!                         ",
+"                      X.-.m.@ Y..         Z.g g g g `. +` M.@ @ @ @ 7.6.                        ",
+"                      -..+@ ++.         @+#+g g g g #+$+^ %+<.@ @ @ @ :.`                       ",
+"                    I.&+@ *+.           =+h g g g g h -+  ! >.@ @ @ @ @ ;.^                     ",
+"                  ;+x.} > C..           >+g g g g g g >+    ` Z @ @ @ @ Y / .                   ",
+"                  ` ' @ ,+.   %.1.'+)+!+g g g g g g g g #+)+~+{+]+^+@ @ @ P.`                   ",
+"                / ).@ !..   /+(+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+(+:+@ @ @ @ ).^                 ",
+"              I.[ > F . .                                       <+[+@ @ @ @ <.I.`               ",
+"    . . . . . . 0.@ }+. . . . . .                     . . . . . . . |+@ @ @ @ s.. . . . . .     ",
+"    O.@ @ @ @ @ @ @ @ @ @ @ @ @ ^                     ! $ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ $ .     ",
+"    . & & & & & & & & & & & & & .                     . , & & & & & & & & & & & & & & & , .     ",
+"    . . . . . . . . . . . . . . .                     . . . . . . . . . . . . . . . . . . .     ",
+"                                                                                                ",
+"                                                                                                "};
diff --git a/test/mk-test.awk b/test/mk-test.awk
index 8149176..a194a5d 100644
--- a/test/mk-test.awk
+++ b/test/mk-test.awk
@@ -1,6 +1,7 @@
-# $Id: mk-test.awk,v 1.13 2015/05/01 00:47:26 tom Exp $
+# $Id: mk-test.awk,v 1.30 2021/12/19 16:54:36 tom Exp $
 ##############################################################################
-# Copyright (c) 2006-2010,2015 Free Software Foundation, Inc.                #
+# Copyright 2019-2020,2021 Thomas E. Dickey                                  #
+# Copyright 2006-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"), #
@@ -67,11 +68,21 @@
 		}
 		print "";
 	}
+	print	"SCRIPTS = \\"
+	print	"	$(srcdir)/savescreen.sh \\"
+	print	"	$(srcdir)/tput-colorcube \\"
+	print	"	$(srcdir)/tput-initc \\"
+	print	"	$(srcdir)/tracemunch"
+	print	"DATAFILES = \\"
+	print	"	$(srcdir)/*.x* \\"
+	print	"	$(srcdir)/*.dat"
 	print	""
-	print	"all: $(TESTS)"
+	print	"all:: $(TESTS)"
 	print	""
 	print	"sources:"
 	print	""
+	print	"check::"
+	print	"	@ echo The test-programs are interactive"
 	print	"tags:"
 	print	"	$(CTAGS) *.[ch]"
 	print	""
@@ -82,18 +93,64 @@
 	print	""
 	if (INSTALL == "yes") {
 		print	"# we might install the test-programs"
+		print	"$(PACKAGE) :"
+		print	"	@echo \"creating $(PACKAGE) script\""
+		print	"	@$(SHELL) -c '\\"
+		print	"	L=$(real_bindir);                            \\"
+		print	"	rm -f $@;                                    \\"
+		print	"	echo \"#!$(SHELL)\" >                     $@;\\"
+		print	"	echo \"PATH=\\\"$$L\\\":\\$$PATH\"      >>$@;\\"
+		print	"	echo \"export PATH\"                    >>$@;\\"
+		print	"	echo \"if test \\$$# != 0; then\"       >>$@;\\"
+		print	"	echo \"  exec \\\"\\$$@\\\"\"           >>$@;\\"
+		print	"	echo \"elif test -t 1; then\"           >>$@;\\"
+		print	"	echo \"  cd \\\"$$L\\\" || exit\"       >>$@;\\"
+		print	"	echo \"  ls -l | \\$${PAGER:-less}\"    >>$@;\\"
+		print	"	echo \"fi\"                             >>$@;\\"
+		print	"	echo \"echo \\\"usage: $@ [program]\\\"\" >>$@'"
+		print	""
 		print	"install \\"
-		print	"install.test: $(BINDIR) $(TESTS)"
-		print	"	$(SHELL) -c 'for src in $(TESTS); do \\"
+		print	"install.test: $(PACKAGE) $(BINDIR) $(REAL_BINDIR) $(DATADIR) $(TESTS)"
+
+		print	"	@echo \"installing $(PACKAGE) -> $(BINDIR)/\""
+		print	"	@$(INSTALL_SCRIPT) $(PACKAGE) $(BINDIR)"
+
+		print	"	@$(SHELL) -c 'for src in $(TESTS); do \\"
 		print	"	dst=`echo $$src | $(TRANSFORM)`; \\"
-		print	"	$(INSTALL_PROG) $$src $(BINDIR)/$$dst; \\"
+		print	"	echo \"installing $$src -> $(REAL_BINDIR)/$$dst\"; \\"
+		print	"	$(INSTALL_PROG) $$src $(REAL_BINDIR)/$$dst; \\"
+		print	"	done'"
+
+		print	"	@$(SHELL) -c 'for src in $(SCRIPTS); do \\"
+		print	"	dst=`echo $$src | sed -e 's,^.*/,,' | $(TRANSFORM)`; \\"
+		print	"	echo \"installing $$src -> $(REAL_BINDIR)/$$dst\"; \\"
+		print	"	$(INSTALL_SCRIPT) $$src $(REAL_BINDIR)/$$dst; \\"
+		print	"	done'"
+
+		print	"	@$(SHELL) -c 'for src in $(DATAFILES); do \\"
+		print	"	dst=`echo $$src | sed -e 's,^.*/,,'`; \\"
+		print	"	echo \"installing $$src -> $(DATADIR)/$$dst\"; \\"
+		print	"	$(INSTALL_DATA) $$src $(DATADIR)/$$dst; \\"
 		print	"	done'"
 		print	""
 		print	"uninstall \\"
 		print	"uninstall.test:"
-		print	"	$(SHELL) -c 'for src in $(TESTS); do \\"
+
+		print	"	-rm -f $(BINDIR)/$(PACKAGE)"
+
+		print	"	@$(SHELL) -c 'for src in $(TESTS); do \\"
 		print	"	dst=`echo $$src | $(TRANSFORM)`; \\"
-		print	"	rm -f $(BINDIR)/$$dst; \\"
+		print	"	rm -f $(REAL_BINDIR)/$$dst; \\"
+		print	"	done'"
+
+		print	"	@$(SHELL) -c 'for src in $(SCRIPTS); do \\"
+		print	"	dst=`echo $$src | sed -e 's,^.*/,,' | $(TRANSFORM)`; \\"
+		print	"	rm -f $(REAL_BINDIR)/$$dst; \\"
+		print	"	done'"
+
+		print	"	@$(SHELL) -c 'for src in $(DATAFILES); do \\"
+		print	"	dst=`echo $$src | sed -e 's,^.*/,,'`; \\"
+		print	"	rm -f $(DATADIR)/$$dst; \\"
 		print	"	done'"
 	} else {
 		print	"install \\"
@@ -108,6 +165,7 @@
 	print	"clean :: mostlyclean"
 	print	"	-$(SHELL) -c \"if test -n '$x' ; then $(MAKE) clean x=''; fi\""
 	print	"	-rm -rf *$o screendump *.lis $(TESTS) .libs *.dSYM"
+	print	"	-rm -f $(PACKAGE)"
 	print	""
 	print	"distclean :: clean"
 	print	"	-rm -f Makefile ncurses_cfg.h config.status config.log"
@@ -116,7 +174,7 @@
 	print	""
 	print	"lint:"
 	print	"	$(SHELL) -c 'for N in $(TESTS); do echo LINT:$$N; $(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/$$N.c $(LINT_LIBS); done'"
-	print	"$(BINDIR) :"
+	print	"$(BINDIR) $(REAL_BINDIR) $(DATADIR) :"
 	print	"	mkdir -p $@"
 
 
diff --git a/test/modules b/test/modules
index e255c28..fb97d02 100644
--- a/test/modules
+++ b/test/modules
@@ -1,6 +1,7 @@
-# $Id: modules,v 1.52 2015/06/27 10:40:27 tom Exp $
+# $Id: modules,v 1.79 2023/11/10 11:48:20 tom Exp $
 ##############################################################################
-# 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 "Software"), #
@@ -32,19 +33,24 @@
 # Test-Program modules
 
 @ base
+back_ground	progs		$(srcdir)	$(HEADER_DEPS)
 background	progs		$(srcdir)	$(HEADER_DEPS)
 blue		progs		$(srcdir)	$(HEADER_DEPS)
 bs		progs		$(srcdir)	$(HEADER_DEPS)
-cardfile	progs		$(srcdir)	$(HEADER_DEPS)	../include/panel.h ../include/form.h
-chgat		progs		$(srcdir)	$(HEADER_DEPS)
-clip_printw	progs		$(srcdir)	$(HEADER_DEPS)
+cardfile	progs		$(srcdir)	$(HEADER_DEPS)	$(incdir)/panel.h $(incdir)/form.h
+chgat		progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
+clip_printw	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
+color_content	progs		$(srcdir)	$(HEADER_DEPS)
 color_set	progs		$(srcdir)	$(HEADER_DEPS)
+combine		progs		$(srcdir)	$(HEADER_DEPS)
 demo_altkeys	progs		$(srcdir)	$(HEADER_DEPS)
 demo_defkey	progs		$(srcdir)	$(HEADER_DEPS)
 demo_forms	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/edit_field.h
 demo_keyok	progs		$(srcdir)	$(HEADER_DEPS)
-demo_menus	progs		$(srcdir)	$(HEADER_DEPS)	../include/menu.h
-demo_panels	progs		$(srcdir)	$(HEADER_DEPS)	../include/panel.h
+demo_menus	progs		$(srcdir)	$(HEADER_DEPS)	$(incdir)/menu.h
+demo_new_pair	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
+demo_panels	progs		$(srcdir)	$(HEADER_DEPS)	$(incdir)/panel.h
+demo_tabs	progs		$(srcdir)	$(HEADER_DEPS)
 demo_termcap	progs		$(srcdir)	$(HEADER_DEPS)
 demo_terminfo	progs		$(srcdir)	$(HEADER_DEPS)
 ditto		progs		$(srcdir)	$(HEADER_DEPS)
@@ -52,50 +58,68 @@
 dots_curses	progs		$(srcdir)	$(HEADER_DEPS)
 dots_mvcur	progs		$(srcdir)	$(HEADER_DEPS)
 dots_termcap	progs		$(srcdir)	$(HEADER_DEPS)
+dots_xcurses	progs		$(srcdir)	$(HEADER_DEPS)
+dump_window	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/dump_window.h
+dup_field	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/edit_field.h
 echochar	progs		$(srcdir)	$(HEADER_DEPS)
-edit_field	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/edit_field.h
+edit_field	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/edit_field.h	$(srcdir)/popup_msg.h
+extended_color	progs		$(srcdir)	$(HEADER_DEPS)
 filter		progs		$(srcdir)	$(HEADER_DEPS)
 firework	progs		$(srcdir)	$(HEADER_DEPS)
 firstlast	progs		$(srcdir)	$(HEADER_DEPS)
 foldkeys	progs		$(srcdir)	$(HEADER_DEPS)
-form_driver_w	progs		$(srcdir)	$(HEADER_DEPS)
+form_driver_w	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
 gdc		progs		$(srcdir)	$(HEADER_DEPS)
 hanoi		progs		$(srcdir)	$(HEADER_DEPS)
 hashtest	progs		$(srcdir)	$(HEADER_DEPS)
-inch_wide	progs		$(srcdir)	$(HEADER_DEPS)
-inchs		progs		$(srcdir)	$(HEADER_DEPS)
+inch_wide	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
+inchs		progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
 ins_wide	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/linedata.h
-insdelln	progs		$(srcdir)	$(HEADER_DEPS)
+insdelln	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
 inserts		progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/linedata.h
 key_names	progs		$(srcdir)	$(HEADER_DEPS)
 keynames	progs		$(srcdir)	$(HEADER_DEPS)
 knight		progs		$(srcdir)	$(HEADER_DEPS)
+list_keys	progs		$(srcdir)	$(HEADER_DEPS)
 lrtest		progs		$(srcdir)	$(HEADER_DEPS)
-movewindow	progs		$(srcdir)	$(HEADER_DEPS)
-ncurses		progs		$(srcdir)	$(HEADER_DEPS)	../include/panel.h ../include/menu.h ../include/form.h
+move_field	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/edit_field.h
+movewindow	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
+ncurses		progs		$(srcdir)	$(HEADER_DEPS)	$(incdir)/panel.h $(incdir)/menu.h $(incdir)/form.h
 newdemo		progs		$(srcdir)	$(HEADER_DEPS)
+padview		progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/widechars.h	$(srcdir)/popup_msg.h
+pair_content	progs		$(srcdir)	$(HEADER_DEPS)
+picsmap		progs		$(srcdir)	$(HEADER_DEPS)
+popup_msg	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
 railroad	progs		$(srcdir)	$(HEADER_DEPS)
-rain		progs		$(srcdir)	$(HEADER_DEPS)
-redraw		progs		$(srcdir)	$(HEADER_DEPS)
-savescreen	progs		$(srcdir)	$(HEADER_DEPS)
+rain		progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
+redraw		progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h
+savescreen	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/popup_msg.h $(srcdir)/parse_rgb.h
+sp_tinfo	progs		$(srcdir)	$(HEADER_DEPS)
 tclock		progs		$(srcdir)	$(HEADER_DEPS)
 test_add_wchstr	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/linedata.h
 test_addchstr	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/linedata.h
 test_addstr	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/linedata.h
 test_addwstr	progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/linedata.h
 test_arrays	progs		$(srcdir)	$(HEADER_DEPS)
+test_delwin	progs		$(srcdir)	$(HEADER_DEPS)
+test_endwin	progs		$(srcdir)	$(HEADER_DEPS)
 test_get_wstr	progs		$(srcdir)	$(HEADER_DEPS)
 test_getstr	progs		$(srcdir)	$(HEADER_DEPS)
 test_instr	progs		$(srcdir)	$(HEADER_DEPS)
 test_inwstr	progs		$(srcdir)	$(HEADER_DEPS)
+test_mouse	progs		$(srcdir)	$(HEADER_DEPS)
 test_opaque	progs		$(srcdir)	$(HEADER_DEPS)
 test_setupterm	progs		$(srcdir)	$(HEADER_DEPS)
+test_sgr	progs		$(srcdir)	$(HEADER_DEPS)
+test_termattrs	progs		$(srcdir)	$(HEADER_DEPS)
+test_tparm	progs		$(srcdir)	$(HEADER_DEPS)
+test_unget_wch	progs		$(srcdir)	$(HEADER_DEPS)
 test_vid_puts	progs		$(srcdir)	$(HEADER_DEPS)
 test_vidputs	progs		$(srcdir)	$(HEADER_DEPS)
 testaddch	progs		$(srcdir)	$(HEADER_DEPS)
 testcurs	progs		$(srcdir)	$(HEADER_DEPS)
 testscanw	progs		$(srcdir)	$(HEADER_DEPS)
-view		progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/widechars.h
+view		progs		$(srcdir)	$(HEADER_DEPS)	$(srcdir)/widechars.h	$(srcdir)/popup_msg.h
 worm		progs		$(srcdir)	$(HEADER_DEPS)
 xmas		progs		$(srcdir)	$(HEADER_DEPS)
 
diff --git a/test/move_field.c b/test/move_field.c
new file mode 100644
index 0000000..84bac3f
--- /dev/null
+++ b/test/move_field.c
@@ -0,0 +1,547 @@
+/****************************************************************************
+ * Copyright 2020-2022,2023 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: move_field.c,v 1.15 2023/11/11 00:28:19 tom Exp $
+ *
+ * Demonstrate move_field().
+ */
+
+#include <test.priv.h>
+
+#if USE_LIBFORM
+
+#include <edit_field.h>
+#include <popup_msg.h>
+
+#define DO_DEMO	CTRL('F')	/* actual key for toggling demo-mode */
+#define MY_DEMO	EDIT_FIELD('f')	/* internal request-code */
+
+static char empty[] = "";
+static FIELD *all_fields[100];
+/* *INDENT-OFF* */
+static struct {
+    int code;
+    int result;
+    const char *help;
+} commands[] = {
+    { CTRL('A'),     REQ_BEG_FIELD,   "go to beginning of field" },
+    { CTRL('D'),     REQ_DOWN_FIELD,  "move downward to field" },
+    { CTRL('E'),     REQ_END_FIELD,   "go to end of field" },
+    { CTRL('H'),     REQ_DEL_PREV,    "delete previous character" },
+    { CTRL('I'),     REQ_NEXT_FIELD,  "go to next field" },
+    { CTRL('K'),     REQ_CLR_EOF,     "clear to end of field" },
+    { CTRL('N'),     REQ_NEXT_FIELD,  "go to next field" },
+    { CTRL('P'),     REQ_PREV_FIELD,  "go to previous field" },
+    { CTRL('Q'),     MY_QUIT,         "exit form" },
+    { CTRL('U'),     REQ_UP_FIELD,    "move upward to field" },
+    { CTRL('W'),     REQ_NEXT_WORD,   "go to next word" },
+    { CTRL('X'),     REQ_CLR_FIELD,   "clear field" },
+    { CTRL('['),     MY_QUIT,         "exit form" },
+    { KEY_F(1),      MY_HELP,         "show this screen", },
+    { KEY_BACKSPACE, REQ_DEL_PREV,    "delete previous character" },
+    { KEY_BTAB,      REQ_PREV_FIELD,  "go to previous field" },
+    { KEY_DOWN,      REQ_DOWN_CHAR,   "move down 1 character" },
+    { KEY_END,       REQ_LAST_FIELD,  "go to last field" },
+    { KEY_HOME,      REQ_FIRST_FIELD, "go to first field" },
+    { KEY_LEFT,      REQ_LEFT_CHAR,   "move left 1 character" },
+    { KEY_NEXT,      REQ_NEXT_FIELD,  "go to next field" },
+    { KEY_PREVIOUS,  REQ_PREV_FIELD,  "go to previous field" },
+    { KEY_RIGHT,     REQ_RIGHT_CHAR,  "move right 1 character" },
+    { KEY_UP,        REQ_UP_CHAR,     "move up 1 character" },
+    { DO_DEMO,       MY_DEMO,         "move current field with cursor keys" }
+};
+/* *INDENT-ON* */
+
+static void
+my_help_edit_field(void)
+{
+    int used = 0;
+    unsigned n;
+    char **msgs = typeCalloc(char *, 3 + SIZEOF(commands));
+
+    msgs[used++] = strdup("Defined form edit/traversal keys:");
+    for (n = 0; n < SIZEOF(commands); ++n) {
+	char *msg;
+	const char *name;
+	const char *code = keyname(commands[n].code);
+	size_t need = 5;
+#ifdef NCURSES_VERSION
+	if ((name = form_request_name(commands[n].result)) == 0)
+#endif
+	    name = commands[n].help;
+	need = 5 + strlen(code) + strlen(name);
+	msg = typeMalloc(char, need);
+	_nc_SPRINTF(msg, _nc_SLIMIT(need) "%s -- %s", code, name);
+	msgs[used++] = msg;
+    }
+    msgs[used++] =
+	strdup("Arrow keys move within a field as you would expect.");
+    msgs[used] = 0;
+    popup_msg2(stdscr, msgs);
+    for (n = 0; msgs[n] != 0; ++n) {
+	free(msgs[n]);
+    }
+    free(msgs);
+}
+
+static FIELD *
+make_label(const char *label, int frow, int fcol)
+{
+    FIELD *f = new_field(1, (int) strlen(label), frow, fcol, 0, 0);
+
+    if (f) {
+	set_field_buffer(f, 0, label);
+	set_field_opts(f, (int) ((unsigned) field_opts(f) & (unsigned) ~O_ACTIVE));
+    }
+    return (f);
+}
+
+static FIELD *
+make_field(int frow, int fcol, int rows, int cols)
+{
+    FIELD *f = new_field(rows, cols, frow, fcol, 0, 1);
+
+    if (f) {
+	set_field_back(f, A_UNDERLINE);
+	init_edit_field(f, empty);
+    }
+    return (f);
+}
+
+static void
+erase_form(FORM *f)
+{
+    WINDOW *w = form_win(f);
+    WINDOW *s = form_sub(f);
+
+    unpost_form(f);
+    werase(w);
+    wrefresh(w);
+    delwin(s);
+}
+
+static FieldAttrs *
+my_field_attrs(FIELD *f)
+{
+    return (FieldAttrs *) field_userptr(f);
+}
+
+static int
+buffer_length(FIELD *f)
+{
+    return my_field_attrs(f)->row_lengths[0];
+}
+
+static void
+set_buffer_length(FIELD *f, int length)
+{
+    my_field_attrs(f)->row_lengths[0] = length;
+}
+
+static int
+offset_in_field(FORM *form)
+{
+    FIELD *field = current_field(form);
+    int currow, curcol;
+
+    form_getyx(form, currow, curcol);
+    return curcol + currow * (int) field->dcols;
+}
+
+static void
+inactive_field(FIELD *f)
+{
+    set_field_back(f, my_field_attrs(f)->background);
+}
+
+static int
+my_edit_field(FORM *form, int *result)
+{
+    int ch = wgetch(form_win(form));
+    int status;
+    FIELD *before;
+    unsigned n;
+    int before_row;
+    int before_col;
+    int before_off = offset_in_field(form);
+
+    form_getyx(form, before_row, before_col);
+    before = current_field(form);
+    set_field_back(before, A_NORMAL);
+    if (ch <= KEY_MAX) {
+	set_field_back(before, A_REVERSE);
+    } else if (ch <= MAX_FORM_COMMAND) {
+	inactive_field(before);
+    }
+
+    *result = ch;
+    for (n = 0; n < SIZEOF(commands); ++n) {
+	if (commands[n].code == ch) {
+	    *result = commands[n].result;
+	    break;
+	}
+    }
+
+    status = form_driver(form, *result);
+
+    if (status == E_OK) {
+	bool modified = TRUE;
+	int length = buffer_length(before);
+
+	if (length < before_off)
+	    length = before_off;
+	switch (*result) {
+	case REQ_CLR_EOF:
+	    length = before_off;
+	    break;
+	case REQ_CLR_EOL:
+	    if ((int) (before_row + 1) == (int) (before->rows))
+		length = before_off;
+	    break;
+	case REQ_CLR_FIELD:
+	    length = 0;
+	    break;
+	case REQ_DEL_CHAR:
+	    if (length > before_off)
+		--length;
+	    break;
+	case REQ_DEL_PREV:
+	    if (length > 0) {
+		if (before_col > 0) {
+		    --length;
+		} else if (before_row > 0) {
+		    length -= (int) before->cols + before_col;
+		}
+	    }
+	    break;
+	case REQ_NEW_LINE:
+	    length += (int) before->cols;
+	    break;
+
+	default:
+	    modified = (ch < MIN_FORM_COMMAND
+			&& isprint(ch));
+	    break;
+	}
+
+	/*
+	 * If we do not force a re-validation, then field_buffer 0 will
+	 * be lagging by one character.
+	 */
+	if (modified && form_driver(form, REQ_VALIDATION) == E_OK && *result
+	    < MIN_FORM_COMMAND)
+	    ++length;
+
+	set_buffer_length(before, length);
+    }
+
+    if (current_field(form) != before)
+	inactive_field(before);
+    return status;
+}
+
+static FIELD **
+copy_fields(FIELD **source, size_t length)
+{
+    FIELD **target = typeCalloc(FIELD *, length + 1);
+    memcpy(target, source, length * sizeof(FIELD *));
+    return target;
+}
+
+/* display a status message to show what's happening */
+static void
+show_status(FORM *form, FIELD *field)
+{
+    WINDOW *sub = form_sub(form);
+    int currow, curcol;
+
+    getyx(stdscr, currow, curcol);
+    mvprintw(LINES - 1, 0,
+	     "Field at [%d,%d].  Press %s to quit moving.",
+	     getbegy(sub) + form_field_row(field),
+	     getbegx(sub) + form_field_col(field),
+	     keyname(DO_DEMO));
+    clrtobot();
+    move(currow, curcol);
+    refresh();
+}
+
+/*
+ * Move the current label+field in response to cursor-keys (or h,j,k,l) until
+ * a control/F is read.
+ */
+static void
+do_demo(FORM *form)
+{
+    int count = field_count(form);
+    FIELD *my_field = current_field(form);
+    FIELD **old_fields = form_fields(form);
+
+    if (count > 0 && old_fields != NULL && my_field != NULL) {
+	size_t needed = (size_t) count;
+	FIELD **new_fields = copy_fields(old_fields, needed);
+
+	if (new_fields != NULL) {
+	    bool found = FALSE;
+	    int ch;
+
+	    /* TODO: move the label too, in parallel with the editing field */
+
+	    /* remove the current field from the newer list */
+	    for (ch = 0; ch <= count; ++ch) {
+		if (found) {
+		    new_fields[ch - 1] = new_fields[ch];
+		} else if (new_fields[ch] == my_field) {
+		    found = TRUE;
+		}
+	    }
+
+	    if (found) {
+		int currow, curcol;
+
+		getyx(stdscr, currow, curcol);
+
+		show_status(form, my_field);
+		while ((ch = wgetch(form_win(form))) != DO_DEMO) {
+		    int field_y = form_field_row(my_field);
+		    int field_x = form_field_col(my_field);
+
+		    switch (ch) {
+		    case 'h':
+		    case KEY_LEFT:
+			if (field_x > 0)
+			    field_x--;
+			break;
+		    case 'j':
+		    case KEY_DOWN:
+			field_y++;
+			break;
+		    case 'k':
+		    case KEY_UP:
+			if (field_y > 0)
+			    field_y--;
+			break;
+		    case 'l':
+		    case KEY_RIGHT:
+			field_x++;
+			break;
+		    case CTRL('Q'):
+		    case CTRL('['):
+			ch = DO_DEMO;
+			/* FALLTHRU */
+		    case DO_DEMO:
+			break;
+		    default:
+			continue;
+		    }
+
+		    if (ch == DO_DEMO)
+			break;
+
+		    /* alter connected fields temporarily to move the field */
+		    unpost_form(form);
+		    set_form_fields(form, new_fields);
+		    post_form(form);
+
+		    /* TODO: update screen position on success */
+		    move_field(my_field, field_y, field_x);
+
+		    /* restore the form's list of fields */
+		    unpost_form(form);
+		    set_form_fields(form, old_fields);
+		    post_form(form);
+
+		    show_status(form, my_field);
+		}
+
+		/* cleanup */
+		move(LINES - 1, 0);
+		clrtobot();
+		move(currow, curcol);
+		refresh();
+	    }
+	}
+	free(new_fields);
+    }
+}
+
+static int
+my_form_driver(FORM *form, int c)
+{
+    switch (c) {
+    case MY_QUIT:
+	if (form_driver(form, REQ_VALIDATION) == E_OK)
+	    return (TRUE);
+	break;
+    case MY_HELP:
+	my_help_edit_field();
+	break;
+    case MY_DEMO:
+	do_demo(form);
+	break;
+    default:
+	beep();
+	break;
+    }
+    return (FALSE);
+}
+
+static void
+demo_forms(void)
+{
+    FORM *form;
+    int c;
+    unsigned n = 0;
+    const char *fname;
+
+    /* describe the form */
+    all_fields[n++] = make_label("Sample Form", 0, 15);
+
+    fname = "Last Name";
+    all_fields[n++] = make_label(fname, 2, 0);
+    all_fields[n++] = make_field(3, 0, 1, 18);
+    set_field_type(all_fields[n - 1], TYPE_ALPHA, 1);
+
+    fname = "First Name";
+    all_fields[n++] = make_label(fname, 2, 20);
+    all_fields[n++] = make_field(3, 20, 1, 12);
+    set_field_type(all_fields[n - 1], TYPE_ALPHA, 1);
+
+    fname = "Middle Name";
+    all_fields[n++] = make_label(fname, 2, 34);
+    all_fields[n++] = make_field(3, 34, 1, 12);
+    set_field_type(all_fields[n - 1], TYPE_ALPHA, 1);
+
+    fname = "Comments";
+    all_fields[n++] = make_label(fname, 5, 0);
+    all_fields[n++] = make_field(6, 0, 4, 46);
+    init_edit_field(all_fields[n - 1], empty);
+
+    all_fields[n] = (FIELD *) 0;
+
+    if ((form = new_form(all_fields)) != 0) {
+	int finished = 0;
+
+	post_form(form);
+
+	while (!finished) {
+	    switch (my_edit_field(form, &c)) {
+	    case E_OK:
+		break;
+	    case E_UNKNOWN_COMMAND:
+		finished = my_form_driver(form, c);
+		break;
+	    default:
+		beep();
+		break;
+	    }
+	}
+
+	erase_form(form);
+
+	free_form(form);
+    }
+    for (c = 0; all_fields[c] != 0; c++) {
+	free_edit_field(all_fields[c]);
+	free_field(all_fields[c]);
+    }
+    noraw();
+    nl();
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: move_field [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
+    setlocale(LC_ALL, "");
+
+    initscr();
+    cbreak();
+    noecho();
+    raw();
+    nonl();			/* lets us read ^M's */
+    intrflush(stdscr, FALSE);
+    keypad(stdscr, TRUE);
+
+    if (has_colors()) {
+	start_color();
+	init_pair(1, COLOR_WHITE, COLOR_BLUE);
+	init_pair(2, COLOR_GREEN, COLOR_BLACK);
+	init_pair(3, COLOR_CYAN, COLOR_BLACK);
+	bkgd((chtype) COLOR_PAIR(1));
+	refresh();
+    }
+
+    demo_forms();
+
+    endwin();
+    ExitProgram(EXIT_SUCCESS);
+}
+
+#else
+int
+main(void)
+{
+    printf("This program requires the curses form library\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
diff --git a/test/movewindow.c b/test/movewindow.c
index 9effda4..07797ca 100644
--- a/test/movewindow.c
+++ b/test/movewindow.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2006-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2006-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: movewindow.c,v 1.39 2013/05/04 19:41:02 tom Exp $
+ * $Id: movewindow.c,v 1.54 2023/05/27 20:13:10 tom Exp $
  *
  * Demonstrate move functions for windows and derived windows from the curses
  * library.
@@ -45,18 +46,15 @@
  */
 
 #include <test.priv.h>
-#include <stdarg.h>
+
+#if HAVE_MVDERWIN && HAVE_MVWIN
+
+#include <popup_msg.h>
 
 #ifdef HAVE_XCURSES
 #undef derwin
 #endif
 
-#ifdef NCURSES_VERSION
-#define CONST_FMT const
-#else
-#define CONST_FMT		/* nothing */
-#endif
-
 #undef LINE_MAX
 
 #define LINE_MIN	2
@@ -73,8 +71,8 @@
     WINDOW *child;		/* the actual value */
 } FRAME;
 
-static void head_line(CONST_FMT char *fmt,...) GCC_PRINTFLIKE(1, 2);
-static void tail_line(CONST_FMT char *fmt,...) GCC_PRINTFLIKE(1, 2);
+static void head_line(CONST_FMT char *fmt, ...) GCC_PRINTFLIKE(1, 2);
+static void tail_line(CONST_FMT char *fmt, ...) GCC_PRINTFLIKE(1, 2);
 
 static unsigned num_windows;
 static FRAME *all_windows;
@@ -102,6 +100,8 @@
 	vsprintf(buffer, fmt, argp);
 	addstr(buffer);
     }
+#elif defined(HAVE_VW_PRINTW)
+    vw_printw(stdscr, fmt, argp);
 #else
     vwprintw(stdscr, fmt, argp);
 #endif
@@ -111,7 +111,7 @@
 }
 
 static void
-head_line(CONST_FMT char *fmt,...)
+head_line(CONST_FMT char *fmt, ...)
 {
     va_list argp;
 
@@ -121,7 +121,7 @@
 }
 
 static void
-tail_line(CONST_FMT char *fmt,...)
+tail_line(CONST_FMT char *fmt, ...)
 {
     va_list argp;
 
@@ -190,6 +190,7 @@
 	    moved = TRUE;
 	    break;
 	case QUIT:
+	    /* FALLTHRU */
 	case ESCAPE:
 	    return ((PAIR *) 0);
 #ifdef NCURSES_MOUSE_VERSION
@@ -211,8 +212,8 @@
 		    break;
 		}
 	    }
-	    /* FALLTHRU */
 #endif
+	    /* FALLTHRU */
 	default:
 	    res.y = uli + i;
 	    res.x = ulj + j;
@@ -323,6 +324,7 @@
 	all_windows = typeRealloc(FRAME, need, all_windows);
 	if (!all_windows)
 	    failed("add_window");
+	have = need;
     }
     all_windows[num_windows].parent = parent;
     all_windows[num_windows].child = child;
@@ -330,7 +332,7 @@
 }
 
 static int
-window2num(WINDOW *win)
+window2num(const WINDOW *const win)
 {
     int n;
     int result = -1;
@@ -406,7 +408,7 @@
 }
 
 static void
-recur_move_window(WINDOW *parent, int dy, int dx)
+recur_move_window(const WINDOW *const parent, int dy, int dx)
 {
     unsigned n;
 
@@ -637,7 +639,7 @@
 	int	key;
 	CONST_FMT char * msg;
     } help[] = {
-	{ '?',		"Show this screen" },
+	{ HELP_KEY_1,	"Show this screen" },
 	{ 'b',		"Draw a box inside the current window" },
 	{ 'c',		"Create a new window" },
 	{ 'd',		"Create a new derived window" },
@@ -654,29 +656,62 @@
     };
     /* *INDENT-ON* */
 
-    WINDOW *mywin = newwin(LINES, COLS, 0, 0);
-    int row;
+    char **msgs = typeCalloc(char *, SIZEOF(help) + 1);
+    size_t n;
 
-    for (row = 0; row < LINES - 2 && row < (int) SIZEOF(help); ++row) {
-	wmove(mywin, row + 1, 1);
-	wprintw(mywin, "%s", keyname(help[row].key));
-	wmove(mywin, row + 1, 20);
-	wprintw(mywin, "%s", help[row].msg);
+    for (n = 0; n < SIZEOF(help); ++n) {
+	size_t need = (21 + strlen(help[n].msg));
+	msgs[n] = typeMalloc(char, need);
+	_nc_SPRINTF(msgs[n], _nc_SLIMIT(need)
+		    "%-20s%s", keyname(help[n].key), help[n].msg);
     }
-    box_inside(mywin);
-    wmove(mywin, 1, 1);
-    wgetch(mywin);
-    delwin(mywin);
-    refresh_all(current);
+    popup_msg2(current, msgs);
+    for (n = 0; n < SIZEOF(help); ++n) {
+	free(msgs[n]);
+    }
+    free(msgs);
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: movewindow [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     WINDOW *current_win;
     int ch;
     bool done = FALSE;
 
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
     initscr();
     cbreak();
     noecho();
@@ -695,7 +730,7 @@
 	getyx(current_win, y, x);
 
 	switch (ch) {
-	case '?':
+	case HELP_KEY_1:
 	    show_help(current_win);
 	    break;
 	case 'b':
@@ -762,5 +797,16 @@
 	wmove(current_win, 0, 0);
     }
     endwin();
+#if NO_LEAKS
+    free(all_windows);
+#endif
     ExitProgram(EXIT_SUCCESS);
 }
+#else
+int
+main(void)
+{
+    printf("This program requires the curses mvderwin and mvwin functions\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
diff --git a/test/ncurses.c b/test/ncurses.c
index 59a88c4..a272d14 100644
--- a/test/ncurses.c
+++ b/test/ncurses.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            *
@@ -40,24 +41,24 @@
    Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
            Thomas E. Dickey (beginning revision 1.27 in 1996).
 
-$Id: ncurses.c,v 1.420 2015/05/23 23:41:25 tom Exp $
+$Id: ncurses.c,v 1.538 2023/11/11 01:23:59 tom Exp $
 
 ***************************************************************************/
 
+#define NEED_TIME_H 1
 #include <test.priv.h>
 
 #ifdef __hpux
 #undef mvwdelch			/* HPUX 11.23 macro will not compile */
 #endif
 
-#if HAVE_GETTIMEOFDAY
 #if HAVE_SYS_TIME_H && HAVE_SYS_TIME_SELECT
 #include <sys/time.h>
 #endif
+
 #if HAVE_SYS_SELECT_H
 #include <sys/select.h>
 #endif
-#endif
 
 #if USE_LIBPANEL
 #include <panel.h>
@@ -77,7 +78,6 @@
 
 #ifdef TRACE
 static unsigned save_trace = TRACE_ORDINARY | TRACE_ICALLS | TRACE_CALLS;
-extern unsigned _nc_tracing;
 #endif
 
 #else
@@ -142,20 +142,20 @@
 #define state_unused
 #endif
 
-#define ToggleAcs(temp,real) temp = ((temp == real) ? 0 : real)
+#define ToggleAcs(temp,real) temp = ((temp == real) ? NULL : real)
 
 #define P(string)	printw("%s\n", string)
 
 #define BLANK		' '	/* this is the background character */
 
-#undef max_colors
-static int max_colors;		/* the actual number of colors we'll use */
-static int min_colors;		/* the minimum color code */
-static bool use_colors;		/* true if we use colors */
+static int MaxColors;		/* the actual number of colors we'll use */
+static int MinColors;		/* the minimum color code */
+static bool UseColors;		/* true if we use colors */
 
 #undef max_pairs
 static int max_pairs;		/* ...and the number of color pairs */
 
+#if HAVE_COLOR_CONTENT
 typedef struct {
     NCURSES_COLOR_T red;
     NCURSES_COLOR_T green;
@@ -163,8 +163,10 @@
 } RGB_DATA;
 
 static RGB_DATA *all_colors;
+#endif
 
 static void main_menu(bool);
+static GCC_NORETURN void failed(const char *s);
 
 static void
 failed(const char *s)
@@ -174,35 +176,22 @@
     ExitProgram(EXIT_FAILURE);
 }
 
-/* The behavior of mvhline, mvvline for negative/zero length is unspecified,
- * though we can rely on negative x/y values to stop the macro.
- */
-static void
-do_h_line(int y, int x, chtype c, int to)
-{
-    if ((to) > (x))
-	MvHLine(y, x, c, (to) - (x));
-}
-
-static void
-do_v_line(int y, int x, chtype c, int to)
-{
-    if ((to) > (y))
-	MvVLine(y, x, c, (to) - (y));
-}
-
 static void
 Repaint(void)
 {
     touchwin(stdscr);
+#if HAVE_CURSCR
     touchwin(curscr);
     wrefresh(curscr);
+#else
+    wrefresh(stdscr);
+#endif
 }
 
 static bool
-isQuit(int c)
+isQuit(int c, bool escape)
 {
-    return ((c) == QUIT || (c) == ESCAPE);
+    return ((c) == QUIT || (escape && ((c) == ESCAPE)));
 }
 #define case_QUIT	QUIT: case ESCAPE
 
@@ -222,7 +211,7 @@
 	} else {
 	    _nc_tracing = save_trace;
 	}
-	trace(_nc_tracing);
+	curses_trace(_nc_tracing);
 	if (_nc_tracing)
 	    Trace(("TOGGLE-TRACING ON"));
     }
@@ -233,11 +222,12 @@
 }
 #define Getchar() wGetchar(stdscr)
 
+#if USE_SOFTKEYS
 /* replaces wgetnstr(), since we want to be able to edit values */
 static void
 wGetstring(WINDOW *win, char *buffer, int limit)
 {
-    int y0, x0, x, ch;
+    int y0, x0, x;
     bool done = FALSE;
 
     echo();
@@ -246,6 +236,7 @@
 
     x = (int) strlen(buffer);
     while (!done) {
+	int ch;
 	if (x > (int) strlen(buffer))
 	    x = (int) strlen(buffer);
 	wmove(win, y0, x0);
@@ -300,6 +291,7 @@
     wmove(win, y0, x0);
     noecho();
 }
+#endif
 
 #if USE_WIDEC_SUPPORT
 static wchar_t
@@ -353,7 +345,7 @@
 	} else {
 	    _nc_tracing = save_trace;
 	}
-	trace(_nc_tracing);
+	curses_trace(_nc_tracing);
 	if (_nc_tracing)
 	    Trace(("TOGGLE-TRACING ON"));
     }
@@ -365,6 +357,7 @@
 #define Get_wchar(result) wGet_wchar(stdscr, result)
 
 /* replaces wgetn_wstr(), since we want to be able to edit values */
+#if USE_SOFTKEYS
 static void
 wGet_wstring(WINDOW *win, wchar_t *buffer, int limit)
 {
@@ -470,8 +463,9 @@
     wmove(win, y0, x0);
     noecho();
 }
+#endif /* USE_SOFTKEYS */
 
-#endif
+#endif /* USE_WIDEC_SUPPORT */
 
 static void
 Pause(void)
@@ -486,6 +480,7 @@
 {
     printw("\nThis %s terminal %s\n\n", getenv("TERM"), what);
     Pause();
+    endwin();
 }
 
 static void
@@ -495,7 +490,7 @@
 	addstr("Shelling out...");
     def_prog_mode();
     endwin();
-#ifdef __MINGW32__
+#ifdef _NC_WINDOWS
     system("cmd.exe");
 #else
     IGNORE_RC(system("sh"));
@@ -515,10 +510,15 @@
 {
     static char buf[80 + (5 * 10) + (32 * 15)];
 
-    (void) sprintf(buf, "id %2d at (%2d, %2d, %d) state %4lx = {",
-		   ep->id, ep->x, ep->y, ep->z, (unsigned long) ep->bstate);
+    (void) _nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf))
+		       "id %2d at (%2d, %2d, %d) state %4lx = {",
+		       ep->id, ep->x, ep->y, ep->z, (unsigned long) ep->bstate);
 
-#define SHOW(m, s) if ((ep->bstate & m)==m) {strcat(buf,s); strcat(buf, ", ");}
+#define SHOW(m, s) \
+	if ((ep->bstate & m)==m) { \
+		_nc_STRCAT(buf, s, sizeof(buf)); \
+		_nc_STRCAT(buf, ", ", sizeof(buf)); \
+	}
 
     SHOW(BUTTON1_RELEASED, "release-1");
     SHOW(BUTTON1_PRESSED, "press-1");
@@ -574,14 +574,13 @@
 
     if (buf[strlen(buf) - 1] == ' ')
 	buf[strlen(buf) - 2] = '\0';
-    (void) strcat(buf, "}");
+    _nc_STRCAT(buf, "}", sizeof(buf));
     return (buf);
 }
 
 static void
 show_mouse(WINDOW *win)
 {
-    int y, x;
     MEVENT event;
     bool outside;
     bool show_loc;
@@ -604,6 +603,7 @@
     show_loc = wmouse_trafo(win, &event.y, &event.x, FALSE);
 
     if (show_loc) {
+	int y, x;
 	getyx(win, y, x);
 	wmove(win, event.y, event.x);
 	waddch(win, '*');
@@ -636,15 +636,24 @@
 }
 
 static void
-init_getch(WINDOW *win, GetchFlags flags)
+init_getch(WINDOW *win, GetchFlags flags, int delay)
 {
     memset(flags, FALSE, NUM_GETCH_FLAGS);
     flags[UChar('k')] = (win == stdscr);
     flags[UChar('m')] = TRUE;
+    flags[UChar('t')] = (delay != 0);
 
     setup_getch(win, flags);
 }
 
+static bool
+blocking_getch(GetchFlags flags, int delay)
+{
+    return ((delay < 0) && flags['t']);
+}
+
+#define ExitOnEscape() (flags[UChar('k')] && flags[UChar('t')])
+
 static void
 wgetch_help(WINDOW *win, GetchFlags flags)
 {
@@ -655,7 +664,8 @@
 	,"k  -- toggle keypad/literal mode"
 	,"m  -- toggle meta (7-bit/8-bit) mode"
 	,"^q -- quit"
-	,"s  -- shell out\n"
+	,"s  -- shell out"
+	,"t  -- toggle timeout"
 	,"w  -- create a new window"
 #ifdef SIGTSTP
 	,"z  -- suspend this process"
@@ -670,13 +680,16 @@
     printw("Type any key to see its %s value.  Also:\n",
 	   flags['k'] ? "keypad" : "literal");
     for (n = 0; n < SIZEOF(help); ++n) {
+	const char *msg = help[n];
 	int row = 1 + (int) (n % chk);
 	int col = (n >= chk) ? COLS / 2 : 0;
-	int flg = ((strstr(help[n], "toggle") != 0)
-		   && (flags[UChar(*help[n])] != FALSE));
+	int flg = ((strstr(msg, "toggle") != 0)
+		   && (flags[UChar(*msg)] != FALSE));
+	if (*msg == '^' && ExitOnEscape())
+	    msg = "^[,^q -- quit";
 	if (flg)
 	    (void) standout();
-	MvPrintw(row, col, "%s", help[n]);
+	MvPrintw(row, col, "%s", msg);
 	if (col == 0)
 	    clrtoeol();
 	if (flg)
@@ -757,7 +770,7 @@
  * Resize both and paint the box in the parent.
  */
 static void
-resize_boxes(unsigned level, WINDOW *win)
+resize_boxes(unsigned level, const WINDOW *const win)
 {
     unsigned n;
     int base = 5;
@@ -807,12 +820,11 @@
 {
     char buf[BUFSIZ];
     int first_y, first_x;
-    int c;
     int incount = 0;
     GetchFlags flags;
-    bool blocking = (delay < 0);
 
-    init_getch(win, flags);
+    init_getch(win, flags, delay);
+    notimeout(win, FALSE);
     wtimeout(win, delay);
     getyx(win, first_y, first_x);
 
@@ -821,9 +833,11 @@
     scrollok(win, TRUE);
 
     for (;;) {
+	int c;
+
 	while ((c = wGetchar(win)) == ERR) {
 	    incount++;
-	    if (blocking) {
+	    if (blocking_getch(flags, delay)) {
 		(void) wprintw(win, "%05d: input error", incount);
 		break;
 	    } else {
@@ -831,17 +845,17 @@
 	    }
 	    wgetch_wrap(win, first_y);
 	}
-	if (c == ERR && blocking) {
+	if (c == ERR && blocking_getch(flags, delay)) {
 	    wprintw(win, "ERR");
 	    wgetch_wrap(win, first_y);
-	} else if (isQuit(c)) {
+	} else if (isQuit(c, ExitOnEscape())) {
 	    break;
 	} else if (c == 'e') {
 	    flags[UChar('e')] = !flags[UChar('e')];
 	    setup_getch(win, flags);
 	    wgetch_help(win, flags);
 	} else if (c == 'g') {
-	    waddstr(win, "getstr test: ");
+	    waddstr(win, "wgetnstr test: ");
 	    echo();
 	    c = wgetnstr(win, buf, sizeof(buf) - 1);
 	    noecho();
@@ -860,6 +874,10 @@
 	    wgetch_help(win, flags);
 	} else if (c == 's') {
 	    ShellOut(TRUE);
+	} else if (c == 't') {
+	    notimeout(win, flags[UChar('t')]);
+	    flags[UChar('t')] = !flags[UChar('t')];
+	    wgetch_help(win, flags);
 	} else if (c == 'w') {
 	    int high = getmaxy(win) - 1 - first_y + 1;
 	    int wide = getmaxx(win) - first_x;
@@ -931,7 +949,7 @@
     wtimeout(win, -1);
 
     if (!level)
-	init_getch(win, flags);
+	init_getch(win, flags, delay);
 }
 
 static int
@@ -958,7 +976,7 @@
 	delay = -1;
     }
     raw();
-    move(5, 0);
+    move(6, 0);
     return delay;
 }
 
@@ -974,8 +992,8 @@
     endwin();
 }
 
-static void
-getch_test(void)
+static int
+getch_test(bool recur GCC_UNUSED)
 {
     int delay = begin_getch_test();
 
@@ -984,6 +1002,7 @@
     forget_boxes();
     finish_getch_test();
     slk_clear();
+    return OK;
 }
 
 #if USE_WIDEC_SUPPORT
@@ -993,7 +1012,7 @@
  */
 #if defined(KEY_RESIZE) && HAVE_WRESIZE
 static void
-resize_wide_boxes(unsigned level, WINDOW *win)
+resize_wide_boxes(unsigned level, const WINDOW *const win)
 {
     unsigned n;
     int base = 5;
@@ -1060,11 +1079,10 @@
     wint_t c;
     int incount = 0;
     GetchFlags flags;
-    bool blocking = (delay < 0);
-    int code;
     char *temp;
 
-    init_getch(win, flags);
+    init_getch(win, flags, delay);
+    notimeout(win, FALSE);
     wtimeout(win, delay);
     getyx(win, first_y, first_x);
 
@@ -1073,9 +1091,11 @@
     scrollok(win, TRUE);
 
     for (;;) {
+	int code;
+
 	while ((code = wGet_wchar(win, &c)) == ERR) {
 	    incount++;
-	    if (blocking) {
+	    if (blocking_getch(flags, delay)) {
 		(void) wprintw(win, "%05d: input error", incount);
 		break;
 	    } else {
@@ -1083,17 +1103,17 @@
 	    }
 	    wgetch_wrap(win, first_y);
 	}
-	if (code == ERR && blocking) {
+	if (code == ERR && blocking_getch(flags, delay)) {
 	    wprintw(win, "ERR");
 	    wgetch_wrap(win, first_y);
-	} else if (isQuit((int) c)) {
+	} else if (isQuit((int) c, ExitOnEscape())) {
 	    break;
 	} else if (c == 'e') {
 	    flags[UChar('e')] = !flags[UChar('e')];
 	    setup_getch(win, flags);
 	    wgetch_help(win, flags);
 	} else if (c == 'g') {
-	    waddstr(win, "getstr test: ");
+	    waddstr(win, "wgetn_str test: ");
 	    echo();
 	    code = wgetn_wstr(win, wint_buf, BUFSIZ - 1);
 	    noecho();
@@ -1125,6 +1145,10 @@
 	    wgetch_help(win, flags);
 	} else if (c == 's') {
 	    ShellOut(TRUE);
+	} else if (c == 't') {
+	    notimeout(win, flags[UChar('t')]);
+	    flags[UChar('t')] = !flags[UChar('t')];
+	    wgetch_help(win, flags);
 	} else if (c == 'w') {
 	    int high = getmaxy(win) - 1 - first_y + 1;
 	    int wide = getmaxx(win) - first_x;
@@ -1184,11 +1208,11 @@
     wtimeout(win, -1);
 
     if (!level)
-	init_getch(win, flags);
+	init_getch(win, flags, delay);
 }
 
-static void
-get_wch_test(void)
+static int
+x_getch_test(bool recur GCC_UNUSED)
 {
     int delay = begin_getch_test();
 
@@ -1197,6 +1221,7 @@
     forget_boxes();
     finish_getch_test();
     slk_clear();
+    return OK;
 }
 #endif
 
@@ -1255,9 +1280,10 @@
 #define ATTRSTRING_1ST 32	/* ' ' */
 #define ATTRSTRING_END 126	/* '~' */
 
-#define COL_ATTRSTRING 25
-#define MARGIN_4_ATTRS (COL_ATTRSTRING + 8)
-#define LEN_ATTRSTRING (COLS - MARGIN_4_ATTRS)
+#define COLS_PRE_ATTRS 5
+#define COLS_AFT_ATTRS 15
+#define COL_ATTRSTRING (COLS_PRE_ATTRS + 17)
+#define LEN_ATTRSTRING (COLS - (COL_ATTRSTRING + COLS_AFT_ATTRS))
 #define MAX_ATTRSTRING (ATTRSTRING_END + 1 - ATTRSTRING_1ST)
 
 static char attr_test_string[MAX_ATTRSTRING + 1];
@@ -1282,9 +1308,9 @@
     ++row;
     MvWPrintw(helpwin, row++, col,
 	      "Toggles:");
-    if (use_colors) {
+    if (UseColors) {
 	MvWPrintw(helpwin, row++, col,
-		  "  f/F/b/F toggle foreground/background background color");
+		  "  f/F/b/B toggle foreground/background background color");
 	MvWPrintw(helpwin, row++, col,
 		  "  t/T     toggle text/background color attribute");
     }
@@ -1301,7 +1327,7 @@
 static void
 show_color_attr(int fg, int bg, int tx)
 {
-    if (use_colors) {
+    if (UseColors) {
 	printw("  Colors (fg %d, bg %d", fg, bg);
 	if (tx >= 0)
 	    printw(", text %d", tx);
@@ -1314,7 +1340,7 @@
 {
     bool error = FALSE;
 
-    if (use_colors) {
+    if (UseColors) {
 	switch (ch) {
 	case 'f':
 	    *fg = (NCURSES_COLOR_T) (*fg + 1);
@@ -1340,12 +1366,12 @@
 	    break;
 	}
 	if (*fg >= COLORS)
-	    *fg = (NCURSES_COLOR_T) min_colors;
-	if (*fg < min_colors)
+	    *fg = (NCURSES_COLOR_T) MinColors;
+	if (*fg < MinColors)
 	    *fg = (NCURSES_COLOR_T) (COLORS - 1);
 	if (*bg >= COLORS)
-	    *bg = (NCURSES_COLOR_T) min_colors;
-	if (*bg < min_colors)
+	    *bg = (NCURSES_COLOR_T) MinColors;
+	if (*bg < MinColors)
 	    *bg = (NCURSES_COLOR_T) (COLORS - 1);
 	if (*tx >= COLORS)
 	    *tx = -1;
@@ -1363,9 +1389,10 @@
 {
     char save = attr_test_string[0];
     int first = ((int) UChar(save)) + adjust;
-    int j, k;
 
     if (first >= ATTRSTRING_1ST) {
+	int j, k;
+
 	for (j = 0, k = first; j < MAX_ATTRSTRING; ++j, ++k) {
 	    if (k > ATTRSTRING_END)
 		break;
@@ -1412,11 +1439,11 @@
 show_attr(WINDOW *win, int row, int skip, bool arrow, chtype attr, const char *name)
 {
     int ncv = get_ncv();
-    chtype test = attr & (chtype) (~A_ALTCHARSET);
+    chtype test = attr & (chtype) (~(A_ALTCHARSET | A_CHARTEXT));
 
     if (arrow)
-	MvPrintw(row, 5, "-->");
-    MvPrintw(row, 8, "%s mode:", name);
+	MvPrintw(row, COLS_PRE_ATTRS - 3, "-->");
+    MvPrintw(row, COLS_PRE_ATTRS, "%s mode:", name);
     MvPrintw(row, COL_ATTRSTRING - 1, "|");
     if (skip)
 	printw("%*s", skip, " ");
@@ -1429,10 +1456,9 @@
     werase(win);
     if (attr & A_ALTCHARSET) {
 	const char *s;
-	chtype ch;
 
 	for (s = attr_test_string; *s != '\0'; ++s) {
-	    ch = UChar(*s);
+	    chtype ch = UChar(*s);
 	    (void) waddch(win, ch | attr);
 	}
     } else {
@@ -1477,15 +1503,16 @@
 		if (found)
 		    printw(" (NCV)");
 	    }
-	    if ((termattrs() & test) != test)
+	    if ((termattrs() & test) != test) {
 		printw(" (Part)");
+	    }
 	}
     }
     return row + 2;
 }
 
 typedef struct {
-    attr_t attr;
+    chtype attr;
     NCURSES_CONST char *name;
 } ATTR_TBL;
 /* *INDENT-OFF* */
@@ -1522,6 +1549,46 @@
     return result;
 }
 
+#if USE_WIDEC_SUPPORT
+typedef struct {
+    attr_t attr;
+    NCURSES_CONST char *name;
+} W_ATTR_TBL;
+/* *INDENT-OFF* */
+static const W_ATTR_TBL w_attrs_to_test[] = {
+    { WA_STANDOUT,	"STANDOUT" },
+    { WA_REVERSE,	"REVERSE" },
+    { WA_BOLD,		"BOLD" },
+    { WA_UNDERLINE,	"UNDERLINE" },
+    { WA_DIM,		"DIM" },
+    { WA_BLINK,		"BLINK" },
+    { WA_PROTECT,	"PROTECT" },
+#ifdef WA_INVIS
+    { WA_INVIS,		"INVISIBLE" },
+#endif
+#ifdef WA_ITALIC
+    { WA_ITALIC,	"ITALIC" },
+#endif
+    { WA_NORMAL,	"NORMAL" },
+};
+/* *INDENT-ON* */
+
+static unsigned
+init_w_attr_list(W_ATTR_TBL * target, attr_t attrs)
+{
+    unsigned result = 0;
+    size_t n;
+
+    for (n = 0; n < SIZEOF(w_attrs_to_test); ++n) {
+	attr_t test = w_attrs_to_test[n].attr;
+	if (test == WA_NORMAL || (test & attrs) != 0) {
+	    target[result++] = w_attrs_to_test[n];
+	}
+    }
+    return result;
+}
+#endif
+
 static bool
 attr_getc(int *skip,
 	  NCURSES_COLOR_T *fg,
@@ -1546,7 +1613,7 @@
 	    case CTRL('L'):
 		Repaint();
 		break;
-	    case '?':
+	    case HELP_KEY_1:
 		if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
 		    box(helpwin, 0, 0);
 		    attr_legend(helpwin);
@@ -1589,8 +1656,8 @@
     return result;
 }
 
-static void
-attr_test(void)
+static int
+attr_test(bool recur GCC_UNUSED)
 /* test text attributes */
 {
     int n;
@@ -1599,12 +1666,13 @@
     NCURSES_COLOR_T bg = COLOR_BLACK;
     NCURSES_COLOR_T tx = -1;
     int ac = 0;
-    unsigned j, k;
     WINDOW *my_wins[SIZEOF(attrs_to_test)];
     ATTR_TBL my_list[SIZEOF(attrs_to_test)];
     unsigned my_size = init_attr_list(my_list, termattrs());
 
     if (my_size > 1) {
+	unsigned j, k;
+
 	for (j = 0; j < my_size; ++j) {
 	    my_wins[j] = subwin(stdscr,
 				1, LEN_ATTRSTRING,
@@ -1624,7 +1692,7 @@
 	    chtype normal = A_NORMAL | BLANK;
 	    chtype extras = (chtype) ac;
 
-	    if (use_colors) {
+	    if (UseColors) {
 		NCURSES_PAIRS_T pair = 0;
 		if ((fg != COLOR_BLACK) || (bg != COLOR_BLACK)) {
 		    pair = 1;
@@ -1661,10 +1729,10 @@
 				my_list[j].name);
 	    }
 
-	    MvPrintw(row, 8,
+	    MvPrintw(row, COLS_PRE_ATTRS,
 		     "This terminal does %shave the magic-cookie glitch",
 		     get_xmc() > -1 ? "" : "not ");
-	    MvPrintw(row + 1, 8, "Enter '?' for help.");
+	    MvPrintw(row + 1, COLS_PRE_ATTRS, "Enter '?' for help.");
 	    show_color_attr(fg, bg, tx);
 	    printw("  ACS (%d)", ac != 0);
 
@@ -1674,8 +1742,10 @@
 	bkgdset(A_NORMAL | BLANK);
 	erase();
 	endwin();
+	return OK;
     } else {
 	Cannot("does not support video attributes.");
+	return ERR;
     }
 }
 
@@ -1726,9 +1796,10 @@
 {
     wchar_t save = wide_attr_test_string[0];
     int first = ((int) normal_wchar(save)) + adjust;
-    int j, k;
 
     if (first >= ATTRSTRING_1ST) {
+	int j, k;
+
 	for (j = 0, k = first; j < MAX_ATTRSTRING; ++j, ++k) {
 	    if (k > ATTRSTRING_END)
 		break;
@@ -1774,14 +1845,15 @@
 static attr_t
 get_wide_background(void)
 {
-    attr_t result = A_NORMAL;
+    attr_t result = WA_NORMAL;
     attr_t attr;
     cchar_t ch;
     NCURSES_PAIRS_T pair;
-    wchar_t wch[10];
 
     memset(&ch, 0, sizeof(ch));
     if (getbkgrnd(&ch) != ERR) {
+	wchar_t wch[CCHARW_MAX];
+
 	if (getcchar(&ch, wch, &attr, &pair, 0) != ERR) {
 	    result = attr;
 	}
@@ -1794,16 +1866,16 @@
 	       int row,
 	       int skip,
 	       bool arrow,
-	       chtype attr,
+	       attr_t attr,
 	       NCURSES_PAIRS_T pair,
 	       const char *name)
 {
     int ncv = get_ncv();
-    chtype test = attr & ~WA_ALTCHARSET;
+    attr_t test = attr & ~WA_ALTCHARSET;
 
     if (arrow)
-	MvPrintw(row, 5, "-->");
-    MvPrintw(row, 8, "%s mode:", name);
+	MvPrintw(row, COLS_PRE_ATTRS - 3, "-->");
+    MvPrintw(row, COLS_PRE_ATTRS, "%s mode:", name);
     MvPrintw(row, COL_ATTRSTRING - 1, "|");
     if (skip)
 	printw("%*s", skip, " ");
@@ -1867,8 +1939,9 @@
 		if (found)
 		    printw(" (NCV)");
 	    }
-	    if ((term_attrs() & test) != test)
+	    if ((term_attrs() & test) != test) {
 		printw(" (Part)");
+	    }
 	}
     }
     return row + 2;
@@ -1895,7 +1968,7 @@
 	    case CTRL('L'):
 		Repaint();
 		break;
-	    case '?':
+	    case HELP_KEY_1:
 		if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
 		    box_set(helpwin, 0, 0);
 		    attr_legend(helpwin);
@@ -1946,8 +2019,8 @@
     return result;
 }
 
-static void
-wide_attr_test(void)
+static int
+x_attr_test(bool recur GCC_UNUSED)
 /* test text attributes using wide-character calls */
 {
     int n;
@@ -1956,12 +2029,13 @@
     NCURSES_COLOR_T bg = COLOR_BLACK;
     NCURSES_COLOR_T tx = -1;
     int ac = 0;
-    unsigned j, k;
-    ATTR_TBL my_list[SIZEOF(attrs_to_test)];
-    WINDOW *my_wins[SIZEOF(attrs_to_test)];
-    unsigned my_size = init_attr_list(my_list, term_attrs());
+    W_ATTR_TBL my_list[SIZEOF(w_attrs_to_test)];
+    WINDOW *my_wins[SIZEOF(w_attrs_to_test)];
+    unsigned my_size = init_w_attr_list(my_list, term_attrs());
 
     if (my_size > 1) {
+	unsigned j, k;
+
 	for (j = 0; j < my_size; ++j) {
 	    my_wins[j] = subwin(stdscr,
 				1, LEN_ATTRSTRING,
@@ -1981,7 +2055,7 @@
 	    NCURSES_PAIRS_T pair = 0;
 	    NCURSES_PAIRS_T extras = 0;
 
-	    if (use_colors) {
+	    if (UseColors) {
 		pair = (NCURSES_PAIRS_T) (fg != COLOR_BLACK || bg != COLOR_BLACK);
 		if (pair != 0) {
 		    pair = 1;
@@ -2012,10 +2086,10 @@
 				     my_list[j].name);
 	    }
 
-	    MvPrintw(row, 8,
+	    MvPrintw(row, COLS_PRE_ATTRS,
 		     "This terminal does %shave the magic-cookie glitch",
 		     get_xmc() > -1 ? "" : "not ");
-	    MvPrintw(row + 1, 8, "Enter '?' for help.");
+	    MvPrintw(row + 1, COLS_PRE_ATTRS, "Enter '?' for help.");
 	    show_color_attr(fg, bg, tx);
 	    printw("  ACS (%d)", ac != 0);
 
@@ -2025,8 +2099,10 @@
 	set_wide_background(0);
 	erase();
 	endwin();
+	return OK;
     } else {
 	Cannot("does not support extended video attributes.");
+	return ERR;
     }
 }
 #endif
@@ -2058,21 +2134,32 @@
 };
 
 static void
-show_color_name(int y, int x, int color, bool wide)
+show_color_name(int y, int x, int color, bool wide, int zoom)
 {
     if (move(y, x) != ERR) {
 	char temp[80];
 	int width = 8;
 
-	if (wide) {
-	    sprintf(temp, "%02d", color);
-	    width = 4;
+	if (wide || zoom) {
+	    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+			"%02d", color);
+	    if (wide)
+		width = 4;
+	    if ((int) strlen(temp) >= width) {
+		int pwr2 = 0;
+		while ((1 << pwr2) < color)
+		    ++pwr2;
+		_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+			    width > 4 ? "2^%d" : "^%d", pwr2);
+	    }
 	} else if (color >= 8) {
-	    sprintf(temp, "[%02d]", color);
+	    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+			"[%02d]", color);
 	} else if (color < 0) {
-	    strcpy(temp, "default");
+	    _nc_STRCPY(temp, "default", sizeof(temp));
 	} else {
-	    sprintf(temp, "%.*s", 16, the_color_names[color]);
+	    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+			"%.*s", 16, the_color_names[color]);
 	}
 	printw("%-*.*s", width, width, temp);
     }
@@ -2111,7 +2198,9 @@
     MvWPrintw(helpwin, row++, col,
 	      "  r/R     toggle reverse on/off");
     MvWPrintw(helpwin, row++, col,
-	      "  w/W     toggle width between 8/16 colors");
+	      "  w/W     switch width between 4/8 columns");
+    MvWPrintw(helpwin, row++, col,
+	      "  z/Z     zoom out (or in)");
 #if USE_WIDEC_SUPPORT
     if (wide) {
 	MvWPrintw(helpwin, row++, col,
@@ -2156,8 +2245,8 @@
 }
 
 /* generate a color test pattern */
-static void
-color_test(void)
+static int
+color_test(bool recur GCC_UNUSED)
 {
     NCURSES_PAIRS_T i;
     int top = 0, width;
@@ -2166,9 +2255,10 @@
     int page_size = (LINES - grid_top);
     int pairs_max;
     int colors_max = COLORS;
+    int col_limit;
     int row_limit;
     int per_row;
-    char numbered[80];
+    char *numbered = 0;
     const char *hello;
     bool done = FALSE;
     bool opt_acsc = FALSE;
@@ -2176,42 +2266,64 @@
     bool opt_revs = FALSE;
     bool opt_nums = FALSE;
     bool opt_wide = FALSE;
+    int opt_zoom = 0;
     WINDOW *helpwin;
 
+    if (!UseColors) {
+	Cannot("does not support color.");
+	return ERR;
+    }
+
+    numbered = typeCalloc(char, COLS + 1);
+    done = ((COLS < 16) || (numbered == 0));
+
+    /*
+     * Because the number of colors is usually a power of two, we also use
+     * a power of two for the number of colors shown per line (to be tidy).
+     */
+    for (col_limit = 1; col_limit * 2 < COLS; col_limit *= 2) ;
+
+  reloop:
     while (!done) {
 	int shown = 0;
+	int zoom_size = (1 << opt_zoom);
+	int colors_max1 = colors_max / zoom_size;
+	double colors_max2 = (double) colors_max1 * (double) colors_max1;
 
 	pairs_max = PAIR_NUMBER(A_COLOR) + 1;
-	if (colors_max * colors_max <= COLOR_PAIRS) {
-	    int limit = (colors_max - min_colors) * (colors_max - min_colors);
+	if (colors_max2 <= COLOR_PAIRS) {
+	    int limit = (colors_max1 - MinColors) * (colors_max1 - MinColors);
 	    if (pairs_max > limit)
 		pairs_max = limit;
-	} else {
-	    if (pairs_max > COLOR_PAIRS)
-		pairs_max = COLOR_PAIRS;
 	}
+	if (pairs_max > COLOR_PAIRS)
+	    pairs_max = COLOR_PAIRS;
+	if (pairs_max < colors_max1)
+	    pairs_max = colors_max1;
 
 	/* this assumes an 80-column line */
 	if (opt_wide) {
 	    width = 4;
 	    hello = "Test";
-	    per_row = (colors_max > 8) ? 16 : 8;
+	    per_row = (col_limit / ((colors_max1 > 8) ? width : 8));
 	} else {
 	    width = 8;
 	    hello = "Hello";
-	    per_row = 8;
+	    per_row = (col_limit / width);
 	}
-	per_row -= min_colors;
+	per_row -= MinColors;
 
 	row_limit = (pairs_max + per_row - 1) / per_row;
 
 	move(0, 0);
 	(void) printw("There are %d color pairs and %d colors",
 		      pairs_max, COLORS);
-	if (colors_max != COLORS)
-	    (void) printw(" (using %d colors)", colors_max);
-	if (min_colors)
+	if (colors_max1 != COLORS)
+	    (void) printw(" (using %d colors)", colors_max1);
+	if (MinColors)
 	    (void) addstr(" besides 'default'");
+	if (opt_zoom)
+	    (void) printw(" zoom:%d", opt_zoom);
 
 	clrtobot();
 	MvPrintw(top + 1, 0,
@@ -2221,8 +2333,13 @@
 		 opt_bold ? "on" : "off");
 
 	/* show color names/numbers across the top */
-	for (i = 0; i < per_row; i++)
-	    show_color_name(top + 2, (i + 1) * width, i + min_colors, opt_wide);
+	for (i = 0; i < per_row; i++) {
+	    show_color_name(top + 2,
+			    (i + 1) * width,
+			    (int) i * zoom_size + MinColors,
+			    opt_wide,
+			    opt_zoom);
+	}
 
 	/* show a grid of colors, with color names/ numbers on the left */
 	for (i = (NCURSES_PAIRS_T) (base_row * per_row); i < pairs_max; i++) {
@@ -2230,11 +2347,14 @@
 	    int col = (i % per_row + 1) * width;
 	    NCURSES_PAIRS_T pair = i;
 
-#define InxToFG(i) (NCURSES_COLOR_T) ((i % (colors_max - min_colors)) + min_colors)
-#define InxToBG(i) (NCURSES_COLOR_T) ((i / (colors_max - min_colors)) + min_colors)
+	    if ((i / per_row) > row_limit)
+		break;
+
+#define InxToFG(i) (int)((((unsigned long)(i) * (unsigned long)zoom_size) % (unsigned long)(colors_max1 - MinColors)) + (unsigned long)MinColors)
+#define InxToBG(i) (int)((((unsigned long)(i) * (unsigned long)zoom_size) / (unsigned long)(colors_max1 - MinColors)) + (unsigned long)MinColors)
 	    if (row >= 0 && move(row, col) != ERR) {
-		NCURSES_COLOR_T fg = InxToFG(i);
-		NCURSES_COLOR_T bg = InxToBG(i);
+		NCURSES_COLOR_T fg = (NCURSES_COLOR_T) InxToFG(i);
+		NCURSES_COLOR_T bg = (NCURSES_COLOR_T) InxToBG(i);
 
 		init_pair(pair, fg, bg);
 		attron(COLOR_PAIR(pair));
@@ -2246,14 +2366,18 @@
 		    attron(A_REVERSE);
 
 		if (opt_nums) {
-		    sprintf(numbered, "{%02X}", (int) i);
+		    _nc_SPRINTF(numbered, _nc_SLIMIT((size_t) (COLS + 1))
+				"{%02X}", (int) i);
 		    hello = numbered;
 		}
 		printw("%-*.*s", width, width, hello);
 		(void) attrset(A_NORMAL);
 
-		if ((i % per_row) == 0 && InxToFG(i) == min_colors) {
-		    show_color_name(row, 0, InxToBG(i), opt_wide);
+		if ((i % per_row) == 0 && InxToFG(i) == MinColors) {
+		    show_color_name(row, 0,
+				    InxToBG(i),
+				    opt_wide,
+				    opt_zoom);
 		}
 		++shown;
 	    } else if (shown) {
@@ -2301,6 +2425,22 @@
 	case 'W':
 	    set_color_test(opt_wide, TRUE);
 	    break;
+	case 'z':
+	    if (opt_zoom <= 0) {
+		beep();
+	    } else {
+		--opt_zoom;
+		goto reloop;
+	    }
+	    break;
+	case 'Z':
+	    if ((1 << opt_zoom) >= colors_max) {
+		beep();
+	    } else {
+		++opt_zoom;
+		goto reloop;
+	    }
+	    break;
 	case CTRL('p'):
 	case KEY_UP:
 	    if (base_row <= 0) {
@@ -2340,7 +2480,7 @@
 		}
 	    }
 	    break;
-	case '?':
+	case HELP_KEY_1:
 	    if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
 		box(helpwin, 0, 0);
 		color_legend(helpwin, FALSE);
@@ -2356,23 +2496,38 @@
 
     erase();
     endwin();
+
+    free(numbered);
+    return OK;
 }
 
 #if USE_WIDEC_SUPPORT
+
+#if USE_EXTENDED_COLOR
+#define InitExtendedPair(p,f,g) init_extended_pair((p),(f),(g))
+#define ExtendedColorSet(p)     color_set((NCURSES_PAIRS_T) (p), &(p))
+#define EXTENDED_PAIRS_T int
+#else
+#define InitExtendedPair(p,f,g) init_pair((NCURSES_PAIRS_T) (p),(NCURSES_COLOR_T)(f),(NCURSES_COLOR_T)(g))
+#define ExtendedColorSet(p)     color_set((NCURSES_PAIRS_T) (p), NULL)
+#define EXTENDED_PAIRS_T NCURSES_PAIRS_T
+#endif
+
 /* generate a color test pattern */
-static void
-wide_color_test(void)
+static int
+x_color_test(bool recur GCC_UNUSED)
 {
-    int i;
+    long i;
     int top = 0, width;
     int base_row = 0;
     int grid_top = top + 3;
     int page_size = (LINES - grid_top);
-    int pairs_max = (unsigned short) (-1);
+    int pairs_max;
     int colors_max = COLORS;
+    int col_limit;
     int row_limit;
     int per_row;
-    char numbered[80];
+    char *numbered = 0;
     const char *hello;
     bool done = FALSE;
     bool opt_acsc = FALSE;
@@ -2381,33 +2536,52 @@
     bool opt_wide = FALSE;
     bool opt_nums = FALSE;
     bool opt_xchr = FALSE;
-    wchar_t buffer[80];
+    int opt_zoom = 0;
+    wchar_t *buffer = 0;
     WINDOW *helpwin;
 
+    if (!UseColors) {
+	Cannot("does not support color.");
+	return ERR;
+    }
+    numbered = typeCalloc(char, COLS + 1);
+    buffer = typeCalloc(wchar_t, COLS + 1);
+    done = ((COLS < 16) || (numbered == 0) || (buffer == 0));
+
+    /*
+     * Because the number of colors is usually a power of two, we also use
+     * a power of two for the number of colors shown per line (to be tidy).
+     */
+    for (col_limit = 1; col_limit * 2 < COLS; col_limit *= 2) ;
+
+  reloop:
     while (!done) {
 	int shown = 0;
+	int zoom_size = (1 << opt_zoom);
+	int colors_max1 = colors_max / zoom_size;
+	double colors_max2 = (double) colors_max1 * (double) colors_max1;
 
-	pairs_max = (unsigned short) (-1);
-	if (colors_max * colors_max <= COLOR_PAIRS) {
-	    int limit = (colors_max - min_colors) * (colors_max - min_colors);
+	pairs_max = ((unsigned) (-1)) / 2;
+	if (colors_max2 <= COLOR_PAIRS) {
+	    int limit = (colors_max1 - MinColors) * (colors_max1 - MinColors);
 	    if (pairs_max > limit)
 		pairs_max = limit;
-	} else {
-	    if (pairs_max > COLOR_PAIRS)
-		pairs_max = COLOR_PAIRS;
 	}
+	if (pairs_max > COLOR_PAIRS)
+	    pairs_max = COLOR_PAIRS;
+	if (pairs_max < colors_max1)
+	    pairs_max = colors_max1;
 
-	/* this assumes an 80-column line */
 	if (opt_wide) {
 	    width = 4;
 	    hello = "Test";
-	    per_row = (colors_max > 8) ? 16 : 8;
+	    per_row = (col_limit / ((colors_max1 > 8) ? width : 8));
 	} else {
 	    width = 8;
 	    hello = "Hello";
-	    per_row = 8;
+	    per_row = (col_limit / width);
 	}
-	per_row -= min_colors;
+	per_row -= MinColors;
 
 	if (opt_xchr) {
 	    make_fullwidth_text(buffer, hello);
@@ -2422,10 +2596,12 @@
 	move(0, 0);
 	(void) printw("There are %d color pairs and %d colors",
 		      pairs_max, COLORS);
-	if (colors_max != COLORS)
-	    (void) printw(" (using %d colors)", colors_max);
-	if (min_colors)
+	if (colors_max1 != COLORS)
+	    (void) printw(" (using %d colors)", colors_max1);
+	if (MinColors)
 	    (void) addstr(" besides 'default'");
+	if (opt_zoom)
+	    (void) printw(" zoom:%d", opt_zoom);
 
 	clrtobot();
 	MvPrintw(top + 1, 0,
@@ -2435,27 +2611,37 @@
 		 opt_bold ? "on" : "off");
 
 	/* show color names/numbers across the top */
-	for (i = 0; i < per_row; i++)
-	    show_color_name(top + 2, (i + 1) * width, i + min_colors, opt_wide);
+	for (i = 0; i < per_row; i++) {
+	    show_color_name(top + 2,
+			    ((int) i + 1) * width,
+			    (int) i * zoom_size + MinColors,
+			    opt_wide,
+			    opt_zoom);
+	}
 
 	/* show a grid of colors, with color names/ numbers on the left */
 	for (i = (base_row * per_row); i < pairs_max; i++) {
-	    int row = grid_top + (i / per_row) - base_row;
-	    int col = (i % per_row + 1) * width;
-	    NCURSES_PAIRS_T pair = (NCURSES_PAIRS_T) i;
+	    int row = grid_top + ((int) i / per_row) - base_row;
+	    int col = ((int) i % per_row + 1) * width;
+	    int pair = (int) i;
+
+	    if ((i / per_row) > row_limit)
+		break;
 
 	    if (row >= 0 && move(row, col) != ERR) {
-		init_pair(pair, InxToFG(i), InxToBG(i));
-		(void) color_set(pair, NULL);
+		InitExtendedPair(pair, InxToFG(i), InxToBG(i));
+		(void) ExtendedColorSet(pair);
 		if (opt_acsc)
-		    attr_on(A_ALTCHARSET, NULL);
+		    attr_on(WA_ALTCHARSET, NULL);
 		if (opt_bold)
-		    attr_on(A_BOLD, NULL);
+		    attr_on(WA_BOLD, NULL);
 		if (opt_revs)
-		    attr_on(A_REVERSE, NULL);
+		    attr_on(WA_REVERSE, NULL);
 
 		if (opt_nums) {
-		    sprintf(numbered, "{%02X}", i);
+		    _nc_SPRINTF(numbered,
+				_nc_SLIMIT((size_t) (COLS + 1) * sizeof(wchar_t))
+				"{%02X}", (unsigned) i);
 		    if (opt_xchr) {
 			make_fullwidth_text(buffer, numbered);
 		    } else {
@@ -2465,8 +2651,11 @@
 		addnwstr(buffer, width);
 		(void) attr_set(A_NORMAL, 0, NULL);
 
-		if ((i % per_row) == 0 && InxToFG(i) == min_colors) {
-		    show_color_name(row, 0, InxToBG(i), opt_wide);
+		if ((i % per_row) == 0 && InxToFG(i) == MinColors) {
+		    show_color_name(row, 0,
+				    InxToBG(i),
+				    opt_wide,
+				    opt_zoom);
 		}
 		++shown;
 	    } else if (shown) {
@@ -2520,6 +2709,22 @@
 	case 'X':
 	    opt_xchr = TRUE;
 	    break;
+	case 'z':
+	    if (opt_zoom <= 0) {
+		beep();
+	    } else {
+		--opt_zoom;
+		goto reloop;
+	    }
+	    break;
+	case 'Z':
+	    if ((1 << opt_zoom) >= colors_max) {
+		beep();
+	    } else {
+		++opt_zoom;
+		goto reloop;
+	    }
+	    break;
 	case CTRL('p'):
 	case KEY_UP:
 	    if (base_row <= 0) {
@@ -2559,7 +2764,7 @@
 		}
 	    }
 	    break;
-	case '?':
+	case HELP_KEY_1:
 	    if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
 		box(helpwin, 0, 0);
 		color_legend(helpwin, TRUE);
@@ -2575,9 +2780,14 @@
 
     erase();
     endwin();
+
+    free(numbered);
+    free(buffer);
+    return OK;
 }
 #endif /* USE_WIDEC_SUPPORT */
 
+#if HAVE_COLOR_CONTENT
 static void
 change_color(NCURSES_PAIRS_T current, int field, int value, int usebase)
 {
@@ -2602,7 +2812,7 @@
 }
 
 static void
-init_all_colors(void)
+reset_all_colors(void)
 {
     NCURSES_PAIRS_T c;
 
@@ -2613,23 +2823,126 @@
 		   all_colors[c].blue);
 }
 
-#define scaled_rgb(n) ((255 * (n)) / 1000)
+#define okCOLOR(n) ((n) >= 0 && (n) < MaxColors)
+#define okRGB(n)   ((n) >= 0 && (n) <= 1000)
+#define DecodeRGB(n) (NCURSES_COLOR_T) ((n * 1000) / 0xffff)
 
 static void
-color_edit(void)
+init_all_colors(bool xterm_colors, char *palette_file)
+{
+    NCURSES_PAIRS_T cp;
+    all_colors = typeMalloc(RGB_DATA, (unsigned) MaxColors);
+    if (!all_colors)
+	failed("all_colors");
+    for (cp = 0; cp < MaxColors; ++cp) {
+	color_content(cp,
+		      &all_colors[cp].red,
+		      &all_colors[cp].green,
+		      &all_colors[cp].blue);
+    }
+    /* xterm and compatible terminals can read results of an OSC string
+     * asking for the current color palette.
+     */
+    if (xterm_colors) {
+	int n;
+	char result[BUFSIZ];
+	int check_n;
+	unsigned check_r, check_g, check_b;
+
+	raw();
+	noecho();
+
+	for (n = 0; n < MaxColors; ++n) {
+	    int got;
+
+	    fprintf(stderr, "\033]4;%d;?\007", n);
+	    got = (int) read(0, result, sizeof(result) - 1);
+	    if (got < 0)
+		break;
+	    result[got] = '\0';
+	    if (sscanf(result, "\033]4;%d;rgb:%x/%x/%x\007",
+		       &check_n,
+		       &check_r,
+		       &check_g,
+		       &check_b) == 4 &&
+		check_n == n) {
+		all_colors[n].red = DecodeRGB(check_r);
+		all_colors[n].green = DecodeRGB(check_g);
+		all_colors[n].blue = DecodeRGB(check_b);
+	    } else {
+		break;
+	    }
+	}
+	reset_prog_mode();
+    }
+    if (palette_file != 0) {
+	FILE *fp = fopen(palette_file, "r");
+	if (fp != 0) {
+	    char buffer[BUFSIZ];
+	    int red, green, blue;
+	    int scale = 1000;
+	    int c;
+	    while (fgets(buffer, sizeof(buffer), fp) != 0) {
+		if (sscanf(buffer, "scale:%d", &c) == 1) {
+		    scale = c;
+		    if (scale < 100)
+			scale = 100;
+		    if (scale > 1000)
+			scale = 1000;
+		} else if (sscanf(buffer, "%d:%d %d %d",
+				  &c,
+				  &red,
+				  &green,
+				  &blue) == 4
+			   && okCOLOR(c)
+			   && okRGB(red)
+			   && okRGB(green)
+			   && okRGB(blue)) {
+#define Scaled(n) (NCURSES_COLOR_T) (((n) * 1000) / scale)
+		    all_colors[c].red = Scaled(red);
+		    all_colors[c].green = Scaled(green);
+		    all_colors[c].blue = Scaled(blue);
+		}
+	    }
+	    fclose(fp);
+	}
+    }
+}
+
+#define scaled_rgb(n) ((255 * (n)) / 1000)
+
+static int
+color_edit(bool recur GCC_UNUSED)
 /* display the color test pattern, without trying to edit colors */
 {
     int i;
-    int current = 0;
-    int this_c = 0, value = 0, field = 0;
+    int current;
+    int this_c, value, field;
     int last_c;
-    int top_color = 0;
-    int page_size = (LINES - 6);
+    int top_color;
+    int page_size;
 
-    init_all_colors();
-    refresh();
+    if (!UseColors) {
+	Cannot("does not support color.");
+	return ERR;
+    } else if (!can_change_color()) {
+	Cannot("has hardwired color values.");
+	return ERR;
+    }
 
-    for (i = 0; i < max_colors; i++)
+    reset_all_colors();
+#ifdef KEY_RESIZE
+  retry:
+#endif
+    current = 0;
+    this_c = 0;
+    value = 0;
+    field = 0;
+    top_color = 0;
+    page_size = (LINES - 6);
+    erase();
+
+    for (i = 0; i < MaxColors; i++)
 	init_pair((NCURSES_PAIRS_T) i,
 		  (NCURSES_COLOR_T) COLOR_WHITE,
 		  (NCURSES_COLOR_T) i);
@@ -2645,10 +2958,10 @@
 
 	for (i = (NCURSES_COLOR_T) top_color;
 	     (i - top_color < page_size)
-	     && (i < max_colors); i++) {
+	     && (i < MaxColors); i++) {
 	    char numeric[80];
 
-	    sprintf(numeric, "[%d]", i);
+	    _nc_SPRINTF(numeric, _nc_SLIMIT(sizeof(numeric)) "[%d]", i);
 	    MvPrintw(2 + i - top_color, 0, "%c %-8s:",
 		     (i == current ? '>' : ' '),
 		     (i < (int) SIZEOF(the_color_names)
@@ -2696,6 +3009,21 @@
 	    value = 0;
 
 	switch (this_c) {
+#ifdef KEY_RESIZE
+	case KEY_RESIZE:
+	    move(0, 0);
+	    goto retry;
+#endif
+	case '!':
+	    ShellOut(FALSE);
+	    /* FALLTHRU */
+	case CTRL('r'):
+	    endwin();
+	    refresh();
+	    break;
+	case CTRL('l'):
+	    refresh();
+	    break;
 	case CTRL('b'):
 	case KEY_PPAGE:
 	    if (current > 0)
@@ -2706,7 +3034,7 @@
 
 	case CTRL('f'):
 	case KEY_NPAGE:
-	    if (current < (max_colors - 1))
+	    if (current < (MaxColors - 1))
 		current += (page_size - 1);
 	    else
 		beep();
@@ -2714,18 +3042,20 @@
 
 	case CTRL('p'):
 	case KEY_UP:
-	    current = (current == 0 ? (max_colors - 1) : current - 1);
+	    current = (current == 0 ? (MaxColors - 1) : current - 1);
 	    break;
 
 	case CTRL('n'):
 	case KEY_DOWN:
-	    current = (current == (max_colors - 1) ? 0 : current + 1);
+	    current = (current == (MaxColors - 1) ? 0 : current + 1);
 	    break;
 
+	case '\t':
 	case KEY_RIGHT:
 	    field = (field == 2 ? 0 : field + 1);
 	    break;
 
+	case KEY_BTAB:
 	case KEY_LEFT:
 	    field = (field == 0 ? 2 : field - 1);
 	    break;
@@ -2755,7 +3085,7 @@
 	    change_color((NCURSES_PAIRS_T) current, field, value, 0);
 	    break;
 
-	case '?':
+	case HELP_KEY_1:
 	    erase();
 	    P("                      RGB Value Editing Help");
 	    P("");
@@ -2768,6 +3098,8 @@
 	    P("To increment or decrement a value, use the same procedure, but finish");
 	    P("with a `+' or `-'.");
 	    P("");
+	    P("Use `!' to shell-out, ^R or ^L to repaint the screen.");
+	    P("");
 	    P("Press 'm' to invoke the top-level menu with the current color settings.");
 	    P("To quit, do ESC");
 
@@ -2778,7 +3110,7 @@
 	case 'm':
 	    endwin();
 	    main_menu(FALSE);
-	    for (i = 0; i < max_colors; i++)
+	    for (i = 0; i < MaxColors; i++)
 		init_pair((NCURSES_PAIRS_T) i,
 			  (NCURSES_COLOR_T) COLOR_WHITE,
 			  (NCURSES_COLOR_T) i);
@@ -2795,8 +3127,8 @@
 
 	if (current < 0)
 	    current = 0;
-	if (current >= max_colors)
-	    current = max_colors - 1;
+	if (current >= MaxColors)
+	    current = MaxColors - 1;
 	if (current < top_color)
 	    top_color = current;
 	if (current - top_color >= page_size)
@@ -2805,17 +3137,19 @@
 	MvPrintw(LINES - 1, 0, "Number: %d", value);
 	clrtoeol();
     } while
-	(!isQuit(this_c));
+	(!isQuit(this_c, TRUE));
 
     erase();
 
     /*
      * ncurses does not reset each color individually when calling endwin().
      */
-    init_all_colors();
+    reset_all_colors();
 
     endwin();
+    return OK;
 }
+#endif /* HAVE_COLOR_CONTENT */
 
 /****************************************************************************
  *
@@ -2823,7 +3157,7 @@
  *
  ****************************************************************************/
 static bool
-cycle_attr(int ch, unsigned *at_code, chtype *attr, ATTR_TBL * list, unsigned limit)
+cycle_attr(int ch, unsigned *at_code, attr_t *attr, ATTR_TBL * list, unsigned limit)
 {
     bool result = TRUE;
 
@@ -2847,12 +3181,39 @@
     return result;
 }
 
+#if USE_WIDEC_SUPPORT
+static bool
+cycle_w_attr(int ch, unsigned *at_code, attr_t *attr, W_ATTR_TBL * list, unsigned limit)
+{
+    bool result = TRUE;
+
+    switch (ch) {
+    case 'v':
+	if ((*at_code += 1) >= limit)
+	    *at_code = 0;
+	break;
+    case 'V':
+	if (*at_code == 0)
+	    *at_code = limit - 1;
+	else
+	    *at_code -= 1;
+	break;
+    default:
+	result = FALSE;
+	break;
+    }
+    if (result)
+	*attr = list[*at_code].attr;
+    return result;
+}
+#endif
+
 static bool
 cycle_colors(int ch, int *fg, int *bg, NCURSES_PAIRS_T *pair)
 {
     bool result = FALSE;
 
-    if (use_colors) {
+    if (UseColors) {
 	result = TRUE;
 	switch (ch) {
 	case 'F':
@@ -2950,14 +3311,14 @@
 }
 #endif
 
-static void
-slk_test(void)
+static int
+slk_test(bool recur GCC_UNUSED)
 /* exercise the soft keys */
 {
     int c, fmt = 1;
     char buf[9];
     char *s;
-    chtype attr = A_NORMAL;
+    attr_t attr = A_NORMAL;
     unsigned at_code = 0;
 #if HAVE_SLK_COLOR
     int fg = COLOR_BLACK;
@@ -2969,7 +3330,7 @@
 
     c = CTRL('l');
 #if HAVE_SLK_COLOR
-    if (use_colors) {
+    if (UseColors) {
 	call_slk_color(fg, bg);
     }
 #endif
@@ -2997,7 +3358,7 @@
 	case 's':
 	    MvPrintw(SLK_WORK, 0, "Press Q to stop the scrolling-test: ");
 	    while ((c = Getchar()) != 'Q' && (c != ERR))
-		addch((chtype) c);
+		AddCh(c);
 	    break;
 
 	case 'd':
@@ -3025,9 +3386,9 @@
 	case '7':
 	case '8':
 	    MvAddStr(SLK_WORK, 0, "Please enter the label value: ");
-	    strcpy(buf, "");
+	    _nc_STRCPY(buf, "", sizeof(buf));
 	    if ((s = slk_label(c - '0')) != 0) {
-		strncpy(buf, s, (size_t) 8);
+		_nc_STRNCPY(buf, s, (size_t) 8);
 	    }
 	    wGetstring(stdscr, buf, 8);
 	    slk_set((c - '0'), buf, fmt);
@@ -3047,14 +3408,14 @@
 
 	default:
 	    if (cycle_attr(c, &at_code, &attr, my_list, my_size)) {
-		slk_attrset(attr);
+		slk_attrset((chtype) attr);
 		slk_touch();
 		slk_noutrefresh();
 		break;
 	    }
 #if HAVE_SLK_COLOR
 	    if (cycle_colors(c, &fg, &bg, &pair)) {
-		if (use_colors) {
+		if (UseColors) {
 		    call_slk_color(fg, bg);
 		} else {
 		    beep();
@@ -3065,33 +3426,34 @@
 	    beep();
 	    break;
 	}
-    } while (!isQuit(c = Getchar()));
+    } while (!isQuit(c = Getchar(), TRUE));
 
   done:
     slk_clear();
     erase();
     endwin();
+    return OK;
 }
 
 #if USE_WIDEC_SUPPORT
 #define SLKLEN 8
-static void
-wide_slk_test(void)
+static int
+x_slk_test(bool recur GCC_UNUSED)
 /* exercise the soft keys */
 {
     int c, fmt = 1;
     wchar_t buf[SLKLEN + 1];
     char *s;
-    chtype attr = A_NORMAL;
+    attr_t attr = WA_NORMAL;
     unsigned at_code = 0;
     int fg = COLOR_BLACK;
     int bg = COLOR_WHITE;
     NCURSES_PAIRS_T pair = 0;
-    ATTR_TBL my_list[SIZEOF(attrs_to_test)];
-    unsigned my_size = init_attr_list(my_list, term_attrs());
+    W_ATTR_TBL my_list[SIZEOF(w_attrs_to_test)];
+    unsigned my_size = init_w_attr_list(my_list, term_attrs());
 
     c = CTRL('l');
-    if (use_colors) {
+    if (UseColors) {
 	call_slk_color(fg, bg);
     }
     do {
@@ -3117,7 +3479,7 @@
 	case 's':
 	    MvPrintw(SLK_WORK, 0, "Press Q to stop the scrolling-test: ");
 	    while ((c = Getchar()) != 'Q' && (c != ERR))
-		addch((chtype) c);
+		AddCh(c);
 	    break;
 
 	case 'd':
@@ -3150,14 +3512,15 @@
 		char *temp = strdup(s);
 		size_t used = strlen(temp);
 		size_t want = SLKLEN;
-		size_t test;
 #ifndef state_unused
 		mbstate_t state;
 #endif
 
 		buf[0] = L'\0';
 		while (want > 0 && used != 0) {
+		    size_t test;
 		    const char *base = s;
+
 		    reset_mbytes(state);
 		    test = count_mbytes(base, 0, &state);
 		    if (test == (size_t) -1) {
@@ -3183,13 +3546,13 @@
 	    goto done;
 
 	case 'F':
-	    if (use_colors) {
+	    if (UseColors) {
 		fg = (NCURSES_COLOR_T) ((fg + 1) % COLORS);
 		call_slk_color(fg, bg);
 	    }
 	    break;
 	case 'B':
-	    if (use_colors) {
+	    if (UseColors) {
 		bg = (NCURSES_COLOR_T) ((bg + 1) % COLORS);
 		call_slk_color(fg, bg);
 	    }
@@ -3200,7 +3563,7 @@
 	    break;
 #endif
 	default:
-	    if (cycle_attr(c, &at_code, &attr, my_list, my_size)) {
+	    if (cycle_w_attr(c, &at_code, &attr, my_list, my_size)) {
 		slk_attr_set(attr, (NCURSES_COLOR_T) (fg || bg), NULL);
 		slk_touch();
 		slk_noutrefresh();
@@ -3208,7 +3571,7 @@
 	    }
 #if HAVE_SLK_COLOR
 	    if (cycle_colors(c, &fg, &bg, &pair)) {
-		if (use_colors) {
+		if (UseColors) {
 		    call_slk_color(fg, bg);
 		} else {
 		    beep();
@@ -3219,12 +3582,13 @@
 	    beep();
 	    break;
 	}
-    } while (!isQuit(c = Getchar()));
+    } while (!isQuit(c = Getchar(), TRUE));
 
   done:
     slk_clear();
     erase();
     endwin();
+    return OK;
 }
 #endif
 #endif /* SLK_INIT */
@@ -3249,7 +3613,7 @@
 	int col = (int) (5 * (code % 16));
 	IGNORE_RC(mvaddch(row, col, colored_chtype(code, attr, pair)));
 	for (count = 1; count < repeat; ++count) {
-	    addch(colored_chtype(code, attr, pair));
+	    AddCh(colored_chtype(code, attr, pair));
 	}
     }
 
@@ -3283,7 +3647,7 @@
 	int row = 2 + ((int) (code - first) % (pagesize / 2));
 	int col = ((int) (code - first) / (pagesize / 2)) * COLS / 2;
 	char tmp[80];
-	sprintf(tmp, "%3u (0x%x)", code, code);
+	_nc_SPRINTF(tmp, _nc_SLIMIT(sizeof(tmp)) "%3u (0x%x)", code, code);
 	MvPrintw(row, col, "%*s: ", COLS / 4, tmp);
 
 	do {
@@ -3293,7 +3657,7 @@
 	    if (C1) {
 		/* (yes, this _is_ crude) */
 		while ((reply = Getchar()) != ERR) {
-		    addch(UChar(reply));
+		    AddCh(UChar(reply));
 		    napms(10);
 		}
 		nodelay(stdscr, FALSE);
@@ -3338,7 +3702,7 @@
 		 */
 		break;
 	    default:
-		addch(colored_chtype(code, A_ALTCHARSET | attr, pair));
+		AddCh(colored_chtype(code, A_ALTCHARSET | attr, pair));
 		break;
 	    }
 	} while (--count > 0);
@@ -3375,7 +3739,6 @@
     MvAddCh(LINES / 2, 0,        colored_chtype(ACS_LTEE,  attr, pair));
     MvAddCh(LINES / 2, COLS - 1, colored_chtype(ACS_RTEE,  attr, pair));
     /* *INDENT-ON* */
-
 }
 
 static int
@@ -3387,7 +3750,7 @@
 
     MvPrintw(row, col, "%*s : ", COLS / 4, name);
     do {
-	addch(code);
+	AddCh(code);
     } while (--repeat > 0);
     return n + 1;
 }
@@ -3449,10 +3812,11 @@
     n = show_1_acs(n, repeat, BOTH(ACS_S7));
     (void) show_1_acs(n, repeat, BOTH(ACS_S9));
 #endif
+#undef BOTH
 }
 
-static void
-acs_display(void)
+static int
+acs_test(bool recur GCC_UNUSED)
 {
     int c = 'a';
     int pagesize = 32;
@@ -3460,7 +3824,7 @@
     const char *pch_kludge = ((term != 0 && strstr(term, "linux"))
 			      ? "p=PC, "
 			      : "");
-    chtype attr = A_NORMAL;
+    attr_t attr = A_NORMAL;
     int digit = 0;
     int repeat = 1;
     int fg = COLOR_BLACK;
@@ -3548,7 +3912,7 @@
 	MvPrintw(LINES - 2, 0,
 		 "Select: a=ACS, w=all x=box, %s0=C1, 1-3,+/- non-ASCII, </> repeat, ESC=quit",
 		 pch_kludge);
-	if (use_colors) {
+	if (UseColors) {
 	    MvPrintw(LINES - 1, 0,
 		     "v/V, f/F, b/B cycle through video attributes (%s) and color %d/%d.",
 		     my_list[at_code].name,
@@ -3559,26 +3923,26 @@
 		     my_list[at_code].name);
 	}
 	refresh();
-    } while (!isQuit(c = Getchar()));
+    } while (!isQuit(c = Getchar(), TRUE));
 
     Pause();
     erase();
     endwin();
+    return OK;
 }
 
 #if USE_WIDEC_SUPPORT
 static cchar_t *
 merge_wide_attr(cchar_t *dst, const cchar_t *src, attr_t attr, NCURSES_PAIRS_T pair)
 {
-    int count;
 
     *dst = *src;
     do {
+	int count;
 	TEST_CCHAR(src, count, {
 	    attr |= (test_attrs & A_ALTCHARSET);
 	    setcchar(dst, test_wch, attr, pair, NULL);
-	}
-	, {
+	}, {
 	    ;
 	});
     } while (0);
@@ -3592,15 +3956,15 @@
  * into account, use 256 characters for the page.
  */
 static void
-show_paged_widechars(int base,
-		     int pagesize,
+show_paged_widechars(unsigned base,
+		     unsigned pagesize,
 		     int repeat,
 		     int space,
 		     attr_t attr,
 		     NCURSES_PAIRS_T pair)
 {
-    int first = base * pagesize;
-    int last = first + pagesize - 1;
+    unsigned first = base * pagesize;
+    unsigned last = first + pagesize - 1;
     int per_line = 16;
     cchar_t temp;
     wchar_t code;
@@ -3611,8 +3975,8 @@
     MvPrintw(0, 20, "Display of Character Codes %#x to %#x", first, last);
     attroff(A_BOLD);
 
-    for (code = (wchar_t) first; (int) code <= last; code++) {
-	int row = (2 + ((int) code - first) / per_line);
+    for (code = (wchar_t) first; code <= (wchar_t) last; code++) {
+	int row = (2 + (int) (code - (wchar_t) first) / per_line);
 	int col = 5 * ((int) code % per_line);
 	int count;
 
@@ -3621,7 +3985,7 @@
 	setcchar(&temp, codes, attr, pair, 0);
 	move(row, col);
 	if (wcwidth(code) == 0 && code != 0) {
-	    addch((chtype) space |
+	    AddCh((chtype) space |
 		  (A_REVERSE ^ attr) |
 		  (attr_t) COLOR_PAIR(pair));
 	}
@@ -3633,26 +3997,26 @@
 }
 
 static void
-show_upper_widechars(int first, int repeat, int space, attr_t attr, NCURSES_PAIRS_T pair)
+show_upper_widechars(unsigned first, int repeat, int space, attr_t attr, NCURSES_PAIRS_T pair)
 {
     cchar_t temp;
     wchar_t code;
-    int last = first + 31;
+    unsigned last = first + 31;
 
     erase();
     attron(A_BOLD);
     MvPrintw(0, 20, "Display of Character Codes %d to %d", first, last);
     attroff(A_BOLD);
 
-    for (code = (wchar_t) first; (int) code <= last; code++) {
-	int row = 2 + ((code - first) % 16);
-	int col = ((code - first) / 16) * COLS / 2;
+    for (code = (wchar_t) first; code <= (wchar_t) last; code++) {
+	int row = 2 + ((int) (code - (wchar_t) first) % 16);
+	int col = ((int) (code - (wchar_t) first) / 16) * COLS / 2;
 	wchar_t codes[10];
 	char tmp[80];
 	int count = repeat;
-	int y, x;
 
-	sprintf(tmp, "%3ld (0x%lx)", (long) code, (long) code);
+	_nc_SPRINTF(tmp, _nc_SLIMIT(sizeof(tmp))
+		    "%3ld (0x%lx)", (long) code, (long) code);
 	MvPrintw(row, col, "%*s: ", COLS / 4, tmp);
 
 	memset(&codes, 0, sizeof(codes));
@@ -3660,6 +4024,8 @@
 	setcchar(&temp, codes, attr, pair, 0);
 
 	do {
+	    int y, x;
+
 	    /*
 	     * Give non-spacing characters something to combine with.  If we
 	     * don't, they'll bunch up in a heap on the space after the ":".
@@ -3667,7 +4033,7 @@
 	     * the display.
 	     */
 	    if (wcwidth(code) == 0) {
-		addch((chtype) space |
+		AddCh((chtype) space |
 		      (A_REVERSE ^ attr) |
 		      (attr_t) COLOR_PAIR(pair));
 	    }
@@ -3808,7 +4174,7 @@
     n = show_1_wacs(n, repeat, BOTH2(WACS_DEGREE));
     n = show_1_wacs(n, repeat, BOTH2(WACS_DIAMOND));
     n = show_1_wacs(n, repeat, BOTH2(WACS_PLMINUS));
-    n = show_1_wacs(n, repeat, BOTH2(WACS_PLUS));
+    n = show_1_wacs(n, repeat, BOTH2(WACS_D_PLUS));
 
 #ifdef CURSES_WACS_ARRAY
     n = show_1_wacs(n, repeat, BOTH2(WACS_GEQUAL));
@@ -3869,7 +4235,7 @@
     n = show_1_wacs(n, repeat, BOTH2(WACS_DEGREE));
     n = show_1_wacs(n, repeat, BOTH2(WACS_DIAMOND));
     n = show_1_wacs(n, repeat, BOTH2(WACS_PLMINUS));
-    n = show_1_wacs(n, repeat, BOTH2(WACS_PLUS));
+    n = show_1_wacs(n, repeat, BOTH2(WACS_T_PLUS));
 
 #ifdef CURSES_WACS_ARRAY
     n = show_1_wacs(n, repeat, BOTH2(WACS_GEQUAL));
@@ -3920,7 +4286,6 @@
     (void) mvadd_wch(LINES / 2,   0,        MERGE_ATTR(0, WACS_LTEE));
     (void) mvadd_wch(LINES / 2,   COLS - 1, MERGE_ATTR(0, WACS_RTEE));
     /* *INDENT-ON* */
-
 }
 
 #undef MERGE_ATTR
@@ -3935,7 +4300,8 @@
 
     MvPrintw(row, col, "%*s : ", COLS / 4, name);
     (void) attr_set(attr, pair, 0);
-    addstr(strncpy(temp, code, 20));
+    _nc_STRNCPY(temp, code, 20);
+    addstr(temp);
     (void) attr_set(A_NORMAL, 0, 0);
     return n + 1;
 }
@@ -3992,27 +4358,29 @@
     n = SHOW_UTF8(n, "WACS_S7",		"\342\216\274");
     (void) SHOW_UTF8(n, "WACS_S9",	"\342\216\275");
     /* *INDENT-ON* */
-
 }
 
 /* display the wide-ACS character set */
-static void
-wide_acs_display(void)
+static int
+x_acs_test(bool recur GCC_UNUSED)
 {
     int c = 'a';
-    int digit = 0;
+    unsigned digit = 0;
     int repeat = 1;
     int space = ' ';
-    int pagesize = 32;
-    chtype attr = A_NORMAL;
+    unsigned pagesize = 32;
+    attr_t attr = WA_NORMAL;
     int fg = COLOR_BLACK;
     int bg = COLOR_BLACK;
     unsigned at_code = 0;
     NCURSES_PAIRS_T pair = 0;
     void (*last_show_wacs) (int, attr_t, NCURSES_PAIRS_T) = 0;
-    ATTR_TBL my_list[SIZEOF(attrs_to_test)];
-    unsigned my_size = init_attr_list(my_list, term_attrs());
+    W_ATTR_TBL my_list[SIZEOF(w_attrs_to_test)];
+    unsigned my_size = init_w_attr_list(my_list, term_attrs());
+    char at_page[20];
+    bool pending_code = FALSE;
 
+    at_page[0] = '\0';
     do {
 	switch (c) {
 	case CTRL('L'):
@@ -4044,15 +4412,40 @@
 	case 'u':
 	    ToggleAcs(last_show_wacs, show_utf8_chars);
 	    break;
+	case '@':
+	    pending_code = !pending_code;
+	    if (pending_code) {
+		_nc_SPRINTF(at_page, _nc_SLIMIT(sizeof(at_page)) "%02x", digit);
+	    } else if (at_page[0] != '\0') {
+		sscanf(at_page, "%x", &digit);
+	    }
+	    break;
 	default:
-	    if (c < 256 && isdigit(c)) {
-		digit = (c - '0');
+	    if (pending_code && isxdigit(c)) {
+		size_t len = strlen(at_page);
+		if (len && at_page[0] == '0') {
+		    memmove(at_page, at_page + 1, len--);
+		}
+		if (len < sizeof(at_page) - 1) {
+		    at_page[len++] = (char) c;
+		    at_page[len] = '\0';
+		}
+	    } else if (pending_code
+		       && (c == '\b' || c == KEY_BACKSPACE || c == KEY_DC)) {
+		size_t len = strlen(at_page);
+		if (len)
+		    at_page[--len] = '\0';
+	    } else if (c < 256 && isdigit(c)) {
+		digit = (unsigned) (c - '0');
 		last_show_wacs = 0;
 	    } else if (c == '+') {
 		++digit;
+		_nc_SPRINTF(at_page, _nc_SLIMIT(sizeof(at_page)) "%02x", digit);
 		last_show_wacs = 0;
 	    } else if (c == '-' && digit > 0) {
 		--digit;
+		_nc_SPRINTF(at_page, _nc_SLIMIT(sizeof(at_page)) "%02x",
+			    UChar(digit));
 		last_show_wacs = 0;
 	    } else if (c == '>' && repeat < (COLS / 4)) {
 		++repeat;
@@ -4061,7 +4454,7 @@
 	    } else if (c == '_') {
 		space = (space == ' ') ? '_' : ' ';
 		last_show_wacs = 0;
-	    } else if (cycle_attr(c, &at_code, &attr, my_list, my_size)
+	    } else if (cycle_w_attr(c, &at_code, &attr, my_list, my_size)
 		       || cycle_colors(c, &fg, &bg, &pair)) {
 		if (last_show_wacs != 0)
 		    break;
@@ -4080,10 +4473,14 @@
 	}
 
 	MvPrintw(LINES - 4, 0,
-		 "Select: a/d/t WACS, w=all x=box, u UTF-8, ^L repaint");
+		 "Select: a/d/t WACS, w=%d/page, @",
+		 pagesize);
+	printw("%s",
+	       pending_code ? at_page : "page");
+	addstr(", x=box, u UTF-8, ^L repaint");
 	MvPrintw(LINES - 3, 2,
 		 "0-9,+/- non-ASCII, </> repeat, _ space, ESC=quit");
-	if (use_colors) {
+	if (UseColors) {
 	    MvPrintw(LINES - 2, 2,
 		     "v/V, f/F, b/B cycle through video attributes (%s) and color %d/%d.",
 		     my_list[at_code].name,
@@ -4094,11 +4491,12 @@
 		     my_list[at_code].name);
 	}
 	refresh();
-    } while (!isQuit(c = Getchar()));
+    } while (!isQuit(c = Getchar(), TRUE));
 
     Pause();
     erase();
     endwin();
+    return OK;
 }
 
 #endif
@@ -4106,8 +4504,8 @@
 /*
  * Graphic-rendition test (adapted from vttest)
  */
-static void
-test_sgr_attributes(void)
+static int
+sgr_attr_test(bool recur GCC_UNUSED)
 {
     int pass;
 
@@ -4115,7 +4513,7 @@
 	chtype normal = ((pass == 0 ? A_NORMAL : A_REVERSE)) | BLANK;
 
 	/* Use non-default colors if possible to exercise bce a little */
-	if (use_colors) {
+	if (UseColors) {
 	    init_pair(1, COLOR_WHITE, COLOR_BLUE);
 	    normal |= (chtype) COLOR_PAIR(1);
 	}
@@ -4181,6 +4579,7 @@
     bkgdset(A_NORMAL | BLANK);
     erase();
     endwin();
+    return OK;
 }
 
 /****************************************************************************
@@ -4204,13 +4603,10 @@
     WINDOW *wind;
 };
 
-#if defined(NCURSES_VERSION)
-#if (NCURSES_VERSION_PATCH < 20070331) && NCURSES_EXT_FUNCS
+#if defined(NCURSES_VERSION) && NCURSES_EXT_FUNCS
+#if (NCURSES_VERSION_PATCH < 20070331)
 #define is_keypad(win)   (win)->_use_keypad
 #define is_scrollok(win) (win)->_scroll
-#elif !defined(is_keypad)
-#define is_keypad(win)   FALSE
-#define is_scrollok(win) FALSE
 #endif
 #else
 #define is_keypad(win)   FALSE
@@ -4246,66 +4642,51 @@
 static void
 newwin_legend(FRAME * curp)
 {
+#define DATA(num, name) { name, num }
     static const struct {
 	const char *msg;
 	int code;
     } legend[] = {
-	{
-	    "^C = create window", 0
-	},
-	{
-	    "^N = next window", 0
-	},
-	{
-	    "^P = previous window", 0
-	},
-	{
-	    "^F = scroll forward", 0
-	},
-	{
-	    "^B = scroll backward", 0
-	},
-	{
-	    "^K = keypad(%s)", 1
-	},
-	{
-	    "^S = scrollok(%s)", 2
-	},
-	{
-	    "^W = save window to file", 0
-	},
-	{
-	    "^R = restore window", 0
-	},
+	DATA(0, "^C = create window"),
+	    DATA(0, "^N = next window"),
+	    DATA(0, "^P = previous window"),
+	    DATA(0, "^F = scroll forward"),
+	    DATA(0, "^B = scroll backward"),
+	    DATA(1, "^K = keypad(%s)"),
+	    DATA(2, "^S = scrollok(%s)"),
+	    DATA(0, "^W = save window"),
+	    DATA(0, "^R = restore window"),
 #if HAVE_WRESIZE
-	{
-	    "^X = resize", 0
-	},
+	    DATA(0, "^X = resize"),
 #endif
-	{
-	    "^Q%s = exit", 3
-	}
+	    DATA(3, "^Q%s = exit")
     };
+#undef DATA
     size_t n;
-    int x;
     bool do_keypad = HaveKeypad(curp);
     bool do_scroll = HaveScroll(curp);
     char buf[BUFSIZ];
 
     move(LINES - 4, 0);
+
     for (n = 0; n < SIZEOF(legend); n++) {
+	int x;
+
 	switch (legend[n].code) {
 	default:
-	    strcpy(buf, legend[n].msg);
+	    _nc_STRCPY(buf, legend[n].msg, sizeof(buf));
 	    break;
 	case 1:
-	    sprintf(buf, legend[n].msg, do_keypad ? "yes" : "no");
+	    _nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf))
+			legend[n].msg, do_keypad ? "yes" : "no");
 	    break;
 	case 2:
-	    sprintf(buf, legend[n].msg, do_scroll ? "yes" : "no");
+	    _nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf))
+			legend[n].msg, do_scroll ? "yes" : "no");
 	    break;
 	case 3:
-	    sprintf(buf, legend[n].msg, do_keypad ? "/ESC" : "");
+	    _nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf))
+			legend[n].msg, do_keypad ? "/ESC" : "");
 	    break;
 	}
 	x = getcurx(stdscr);
@@ -4394,8 +4775,8 @@
 		    break;
 		}
 	    }
-	    /* FALLTHRU */
 #endif
+	    /* FALLTHRU */
 	default:
 	    res.y = uli + i;
 	    res.x = ulj + j;
@@ -4496,14 +4877,14 @@
 	}
 	delwin(fp->wind);
 
-	np = (fp == fp->next) ? 0 : fp->next;
+	np = (fp == fp->next) ? NULL : fp->next;
 	free(fp);
     }
     return np;
 }
 
-static void
-acs_and_scroll(void)
+static int
+scroll_test(bool recur GCC_UNUSED)
 /* Demonstrate windows */
 {
     int c;
@@ -4525,11 +4906,11 @@
 	switch (c) {
 	case CTRL('C'):
 	    if ((neww = typeCalloc(FRAME, (size_t) 1)) == 0) {
-		failed("acs_and_scroll");
+		failed("scroll_test");
 		goto breakout;
 	    }
 	    if ((neww->wind = getwindow()) == (WINDOW *) 0) {
-		failed("acs_and_scroll");
+		failed("scroll_test");
 		free(neww);
 		goto breakout;
 	    }
@@ -4595,10 +4976,14 @@
 	    } else if ((fp = fopen(DUMPFILE, "w")) == (FILE *) 0) {
 		transient(current, "Can't open screen dump file");
 	    } else {
-		(void) putwin(frame_win(current), fp);
+		int rc = putwin(frame_win(current), fp);
 		(void) fclose(fp);
 
-		current = delete_framed(current, TRUE);
+		if (rc == OK) {
+		    current = delete_framed(current, TRUE);
+		} else {
+		    transient(current, "Can't write screen dump file");
+		}
 	    }
 	    break;
 
@@ -4619,7 +5004,7 @@
 
 		    wrefresh(neww->wind);
 		} else {
-		    failed("acs_and_scroll");
+		    failed("scroll_test");
 		}
 		(void) fclose(fp);
 	    }
@@ -4630,7 +5015,7 @@
 	case CTRL('X'):	/* resize window */
 	    if (current) {
 		pair *tmp, ul, lr;
-		int i, mx, my;
+		int mx, my;
 
 		move(0, 0);
 		clrtoeol();
@@ -4659,11 +5044,13 @@
 		    wclrtobot(current->wind);
 		    wmove(current->wind, lr.y, lr.x);
 		}
-		if (mx > tmp->x - ul.x)
+		if (mx > tmp->x - ul.x) {
+		    int i;
 		    for (i = 0; i < my; i++) {
 			wmove(current->wind, i, tmp->x - ul.x + 1);
 			wclrtoeol(current->wind);
 		    }
+		}
 		wnoutrefresh(current->wind);
 
 		memcpy(&lr, tmp, sizeof(pair));
@@ -4684,12 +5071,6 @@
 	    break;
 #endif /* HAVE_WRESIZE */
 
-	case KEY_F(10):	/* undocumented --- use this to test area clears */
-	    selectcell(0, 0, LINES - 1, COLS - 1);
-	    clrtobot();
-	    refresh();
-	    break;
-
 	case KEY_UP:
 	    newwin_move(current, -1, 0);
 	    break;
@@ -4733,7 +5114,7 @@
 	usescr = frame_win(current);
 	wrefresh(usescr);
     } while
-	(!isQuit(c = wGetchar(usescr))
+	(!isQuit(c = wGetchar(usescr), TRUE)
 	 && (c != ERR));
 
   breakout:
@@ -4747,6 +5128,7 @@
     noraw();
     erase();
     endwin();
+    return OK;
 }
 
 /****************************************************************************
@@ -4816,7 +5198,7 @@
     if ((win = newwin(rows, cols, tly, tlx)) != 0) {
 	if ((pan = new_panel(win)) == 0) {
 	    delwin(win);
-	} else if (use_colors) {
+	} else if (UseColors) {
 	    NCURSES_COLOR_T fg = (NCURSES_COLOR_T) ((color == COLOR_BLUE)
 						    ? COLOR_WHITE
 						    : COLOR_BLACK);
@@ -4835,7 +5217,7 @@
 	rmpanel(pan)
 --------------------------------------------------------------------------*/
 static void
-rmpanel(PANEL * pan)
+rmpanel(PANEL *pan)
 {
     WINDOW *win = panel_window(pan);
     del_panel(pan);
@@ -4867,7 +5249,7 @@
 }
 
 static void
-fill_panel(PANEL * pan)
+fill_panel(PANEL *pan)
 {
     WINDOW *win = panel_window(pan);
     const char *userptr = (const char *) panel_userptr(pan);
@@ -4904,7 +5286,7 @@
 }
 
 static void
-fill_wide_panel(PANEL * pan)
+fill_wide_panel(PANEL *pan)
 {
     WINDOW *win = panel_window(pan);
     const char *userptr = (const char *) panel_userptr(pan);
@@ -4927,7 +5309,7 @@
 #define MAX_PANELS 5
 
 static void
-canned_panel(PANEL * px[MAX_PANELS + 1], NCURSES_CONST char *cmd)
+canned_panel(PANEL *px[MAX_PANELS + 1], NCURSES_CONST char *cmd)
 {
     int which = cmd[1] - '0';
 
@@ -4953,7 +5335,7 @@
     wait_a_while(nap_msec);
 }
 
-static void
+static int
 demo_panels(void (*InitPanel) (WINDOW *), void (*FillPanel) (PANEL *))
 {
     int count;
@@ -5092,7 +5474,24 @@
 
     erase();
     endwin();
+    return OK;
 }
+
+#if USE_LIBPANEL
+static int
+panel_test(bool recur GCC_UNUSED)
+{
+    return demo_panels(init_panel, fill_panel);
+}
+#endif
+
+#if USE_WIDEC_SUPPORT && USE_LIBPANEL
+static int
+x_panel_test(bool recur GCC_UNUSED)
+{
+    return demo_panels(init_wide_panel, fill_wide_panel);
+}
+#endif
 #endif /* USE_LIBPANEL */
 
 /****************************************************************************
@@ -5101,6 +5500,25 @@
  *
  ****************************************************************************/
 
+#if HAVE_NEWPAD
+
+/* The behavior of mvhline, mvvline for negative/zero length is unspecified,
+ * though we can rely on negative x/y values to stop the macro.
+ */
+static void
+do_h_line(int y, int x, chtype c, int to)
+{
+    if ((to) > (x))
+	MvHLine(y, x, c, (to) - (x));
+}
+
+static void
+do_v_line(int y, int x, chtype c, int to)
+{
+    if ((to) > (y))
+	MvVLine(y, x, c, (to) - (y));
+}
+
 #define GRIDSIZE	3
 
 static bool pending_pan = FALSE;
@@ -5117,7 +5535,7 @@
 	"Number repeats.  Toggle legend:? filler:a timer:t scrollmark:s."
     };
     int n = ((int) SIZEOF(legend) - (LINES - line));
-    if (n >= 0) {
+    if (n >= 0 && n < (int) SIZEOF(legend)) {
 	if (move(line, 0) != ERR) {
 	    if (show_panner_legend)
 		printw("%s", legend[n]);
@@ -5182,10 +5600,8 @@
        int (*pgetc) (WINDOW *),
        bool colored)
 {
-#if HAVE_GETTIMEOFDAY
-    struct timeval before, after;
+    TimeType before, after;
     bool timing = TRUE;
-#endif
     bool pan_lines = FALSE;
     bool scrollers = TRUE;
     int basex = 0;
@@ -5217,8 +5633,8 @@
 	    erase();
 
 	    /* FALLTHRU */
-	case '?':
-	    if (c == '?')
+	case HELP_KEY_1:
+	    if (c == HELP_KEY_1)
 		show_panner_legend = !show_panner_legend;
 	    panner_legend(LINES - 4);
 	    panner_legend(LINES - 3);
@@ -5231,13 +5647,11 @@
 	    pending_pan = FALSE;
 	    break;
 
-#if HAVE_GETTIMEOFDAY
 	case 't':
 	    timing = !timing;
 	    if (!timing)
 		panner_legend(LINES - 1);
 	    break;
-#endif
 	case 's':
 	    scrollers = !scrollers;
 	    break;
@@ -5410,9 +5824,7 @@
 	MvAddCh(porty - 1, portx - 1, ACS_LRCORNER);
 
 	if (!pending_pan) {
-#if HAVE_GETTIMEOFDAY
-	    gettimeofday(&before, 0);
-#endif
+	    GetClockTime(&before);
 	    wnoutrefresh(stdscr);
 
 	    pnoutrefresh(pad,
@@ -5422,17 +5834,12 @@
 			 portx - (pymax > porty) - 1);
 
 	    doupdate();
-#if HAVE_GETTIMEOFDAY
-#define TIMEVAL2S(data) ((double) data.tv_sec + ((double) data.tv_usec / 1.0e6))
 	    if (timing) {
-		double elapsed;
-		gettimeofday(&after, 0);
-		elapsed = (TIMEVAL2S(after) - TIMEVAL2S(before));
+		GetClockTime(&after);
 		move(LINES - 1, COLS - 12);
-		printw("Secs: %2.03f", elapsed);
+		printw("Secs: %6.03f", ElapsedSeconds(&before, &after));
 		refresh();
 	    }
-#endif
 	}
 
     } while
@@ -5446,13 +5853,13 @@
 {
     static int count;
     static int last;
-    int c;
 
     if ((pending_pan = (count > 0)) != FALSE) {
 	count--;
 	pending_pan = (count != 0);
     } else {
 	for (;;) {
+	    int c;
 	    switch (c = wGetchar(win)) {
 	    case '!':
 		ShellOut(FALSE);
@@ -5513,25 +5920,24 @@
 #define PAD_HIGH 200
 #define PAD_WIDE 200
 
-static void
-demo_pad(bool colored)
+static int
+pad_test(bool recur GCC_UNUSED)
 /* Demonstrate pads. */
 {
     WINDOW *panpad = newpad(PAD_HIGH, PAD_WIDE);
 
     if (panpad == 0) {
 	Cannot("cannot create requested pad");
-	return;
+	return ERR;
     }
-
 #ifdef A_COLOR
-    if (colored && use_colors) {
+    if (UseColors) {
 	init_pair(1, COLOR_BLACK, COLOR_GREEN);
 	init_pair(2, COLOR_CYAN, COLOR_BLUE);
 	wbkgd(panpad, (chtype) (COLOR_PAIR(2) | ' '));
     }
 #endif
-    fill_pad(panpad, FALSE, colored);
+    fill_pad(panpad, FALSE, TRUE);
 
     panner_legend(LINES - 4);
     panner_legend(LINES - 3);
@@ -5544,12 +5950,14 @@
      * We'll still be able to widen it during a test, since that's required
      * for testing boundaries.
      */
-    panner(panpad, 2, 2, LINES - 5, COLS - 15, padgetch, colored);
+    panner(panpad, 2, 2, LINES - 5, COLS - 15, padgetch, TRUE);
 
     delwin(panpad);
     endwin();
     erase();
+    return OK;
 }
+#endif /* HAVE_NEWPAD */
 
 /****************************************************************************
  *
@@ -5567,10 +5975,11 @@
     wGetchar(win);
 }
 
-static void
-flushinp_test(WINDOW *win)
+static int
+flushinp_test(bool recur GCC_UNUSED)
 /* Input test, adapted from John Burnell's PDCurses tester */
 {
+    WINDOW *win = stdscr;
     int w, h, bx, by, sw, sh, i;
 
     WINDOW *subWin;
@@ -5581,10 +5990,10 @@
     sw = w / 3;
     sh = h / 3;
     if ((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2)) == 0)
-	return;
+	return ERR;
 
 #ifdef A_COLOR
-    if (use_colors) {
+    if (UseColors) {
 	init_pair(2, COLOR_CYAN, COLOR_BLUE);
 	wbkgd(subWin, (chtype) (COLOR_PAIR(2) | ' '));
     }
@@ -5648,6 +6057,7 @@
     Continue(win);
 
     cbreak();
+    return OK;
 }
 
 /****************************************************************************
@@ -5705,8 +6115,8 @@
     (char *) 0
 };
 
-static void
-menu_test(void)
+static int
+menu_test(bool recur GCC_UNUSED)
 {
     MENU *m;
     ITEM *items[SIZEOF(animals)];
@@ -5751,7 +6161,6 @@
 	    break;
 	if (c == E_REQUEST_DENIED)
 	    beep();
-	continue;
     }
 
     MvPrintw(LINES - 2, 0,
@@ -5768,6 +6177,7 @@
 #ifdef NCURSES_MOUSE_VERSION
     mousemask(0, (mmask_t *) 0);
 #endif
+    return OK;
 }
 
 #ifdef TRACE
@@ -5802,29 +6212,31 @@
 tracetrace(unsigned tlevel)
 {
     static char *buf;
+    static size_t need = 12;
     int n;
 
     if (buf == 0) {
-	size_t need = 12;
 	for (n = 0; t_tbl[n].name != 0; n++)
 	    need += strlen(t_tbl[n].name) + 2;
 	buf = typeMalloc(char, need);
 	if (!buf)
 	    failed("tracetrace");
     }
-    sprintf(buf, "0x%02x = {", tlevel);
+    _nc_SPRINTF(buf, _nc_SLIMIT(need) "0x%02x = {", tlevel);
     if (tlevel == 0) {
-	sprintf(buf + strlen(buf), "%s, ", t_tbl[0].name);
+	_nc_STRCAT(buf, t_tbl[0].name ? t_tbl[0].name : "", need);
+	_nc_STRCAT(buf, ", ", need);
     } else {
 	for (n = 1; t_tbl[n].name != 0; n++)
 	    if ((tlevel & t_tbl[n].mask) == t_tbl[n].mask) {
-		strcat(buf, t_tbl[n].name);
-		strcat(buf, ", ");
+		_nc_STRCAT(buf, t_tbl[n].name, need);
+		_nc_STRCAT(buf, ", ", need);
 	    }
     }
     if (buf[strlen(buf) - 2] == ',')
 	buf[strlen(buf) - 2] = '\0';
-    return (strcat(buf, "}"));
+    _nc_STRCAT(buf, "}", need);
+    return buf;
 }
 
 /* fake a dynamically reconfigurable menu using the 0th entry to deselect
@@ -5866,8 +6278,8 @@
     }
 }
 
-static void
-trace_set(void)
+static int
+trace_set(bool recur GCC_UNUSED)
 /* interactively set the trace level */
 {
     MENU *m;
@@ -5916,14 +6328,15 @@
 	    set_item_value(*ip, TRUE);
     }
 
-    while (run_trace_menu(m))
-	continue;
+    while (run_trace_menu(m)) {
+	/* EMPTY */ ;
+    }
 
     newtrace = 0;
     for (ip = menu_items(m); *ip; ip++)
 	if (item_value(*ip))
 	    newtrace |= t_tbl[item_index(*ip)].mask;
-    trace(newtrace);
+    curses_trace(newtrace);
     Trace(("trace level interactively set to %s", tracetrace(_nc_tracing)));
 
     MvPrintw(LINES - 2, 0,
@@ -5937,6 +6350,8 @@
     free_menu(m);
     for (ip = items; *ip; ip++)
 	free_item(*ip);
+
+    return OK;
 }
 #endif /* TRACE */
 #endif /* USE_LIBMENU */
@@ -5954,7 +6369,7 @@
 
     if (f) {
 	set_field_buffer(f, 0, label);
-	set_field_opts(f, (int) ((unsigned) field_opts(f) & ~O_ACTIVE));
+	set_field_opts(f, (int) ((unsigned) field_opts(f) & (unsigned) ~O_ACTIVE));
     }
     return (f);
 }
@@ -5972,7 +6387,7 @@
 }
 
 static void
-display_form(FORM * f)
+display_form(FORM *f)
 {
     WINDOW *w;
     int rows, cols;
@@ -5990,7 +6405,7 @@
 }
 
 static void
-erase_form(FORM * f)
+erase_form(FORM *f)
 {
     WINDOW *w = form_win(f);
     WINDOW *s = form_sub(f);
@@ -6003,7 +6418,7 @@
 }
 
 static int
-edit_secure(FIELD * me, int c)
+edit_secure(FIELD *me, int c)
 {
     int rows, cols, frow, fcol, nrow, nbuf;
 
@@ -6013,10 +6428,10 @@
 	size_t have = (source ? strlen(source) : 0) + 1;
 	size_t need = 80 + have;
 	char *temp = malloc(need);
-	size_t len;
 
 	if (temp != 0) {
-	    strncpy(temp, source ? source : "", have + 1);
+	    size_t len;
+	    _nc_STRNCPY(temp, source ? source : "", have + 1);
 	    len = (size_t) (char *) field_userptr(me);
 	    if (c <= KEY_MAX) {
 		if (isgraph(c) && (len + 1) < sizeof(temp)) {
@@ -6069,7 +6484,7 @@
 }
 
 static int
-form_virtualize(FORM * f, WINDOW *w)
+form_virtualize(FORM *f, WINDOW *w)
 {
     /* *INDENT-OFF* */
     static const struct {
@@ -6118,7 +6533,6 @@
 
     static int mode = REQ_INS_MODE;
     int c = wGetchar(w);
-    unsigned n;
     FIELD *me = current_field(f);
     bool current = TRUE;
 
@@ -6130,6 +6544,7 @@
 	}
 	c = mode;
     } else {
+	unsigned n;
 	for (n = 0; n < SIZEOF(lookup); n++) {
 	    if (lookup[n].code == c) {
 		c = lookup[n].result;
@@ -6176,7 +6591,7 @@
 }
 
 static int
-my_form_driver(FORM * form, int c)
+my_form_driver(FORM *form, int c)
 {
     if (c == (MAX_FORM_COMMAND + 1)
 	&& form_driver(form, REQ_VALIDATION) == E_OK)
@@ -6261,15 +6676,14 @@
     return (isgraph(ch) ? TRUE : FALSE);
 }
 
-static void
-demo_forms(void)
+static int
+form_test(bool recur GCC_UNUSED)
 {
-    WINDOW *w;
     FORM *form;
     FIELD *f[12], *secure;
     FIELDTYPE *fty_middle = new_fieldtype(mi_field_check, mi_char_check);
     FIELDTYPE *fty_passwd = new_fieldtype(pw_field_check, pw_char_check);
-    int finished = 0, c;
+    int c;
     unsigned n = 0;
 
 #ifdef NCURSES_MOUSE_VERSION
@@ -6319,6 +6733,8 @@
     f[n] = (FIELD *) 0;
 
     if ((form = new_form(f)) != 0) {
+	WINDOW *w;
+	int finished = 0;
 
 	display_form(form);
 
@@ -6355,6 +6771,7 @@
 #ifdef NCURSES_MOUSE_VERSION
     mousemask(ALL_MOUSE_EVENTS, (mmask_t *) 0);
 #endif
+    return OK;
 }
 #endif /* USE_LIBFORM */
 
@@ -6364,6 +6781,75 @@
  *
  ****************************************************************************/
 
+#if HAVE_COPYWIN		/* ...and overlay, overwrite */
+
+static const int overlap_HEAD = 1;
+static const int overlap_FOOT = 6;
+
+static WINDOW *
+make_overlap(int n)
+{
+    WINDOW *result;
+    int y, x;
+
+    getmaxyx(stdscr, y, x);
+    if (y < 23 || x < 80) {
+	Cannot("The screen is too small for this test");
+	result = 0;
+    } else {
+	int ymax = y - (overlap_HEAD + overlap_FOOT);
+	int high = ymax / 5;	/* equal-sized parts for cross */
+	int xmax = x - 2;	/* margin */
+	int wide = (xmax / 5) & ~1;
+	int lmar, tmar;
+
+	if (high > 8)
+	    high = 8;
+
+	if (wide > 8)
+	    wide = 8;
+
+	tmar = (ymax - (5 * high)) / 2 + overlap_HEAD;
+	lmar = (xmax - (5 * wide)) / 2;
+
+	if (n == 0) {
+	    result = newwin(3 * high, 3 * wide, tmar, lmar);
+	} else {
+	    result = newwin(3 * high, 3 * wide, tmar + 2 * high, lmar + 2 * wide);
+	}
+    }
+    return result;
+}
+
+static void
+clear_overlap(void)
+{
+    int row;
+
+    for (row = overlap_HEAD; row < LINES - overlap_FOOT; ++row) {
+	move(row, 0);
+	clrtoeol();
+    }
+}
+
+static int
+move_overlap(int shift, WINDOW *win1)
+{
+    int ymax = getmaxy(stdscr) - (overlap_HEAD + overlap_FOOT);
+    int high = ymax / 5;	/* equal-sized parts for cross */
+    int tmar;
+    int xmax1 = getmaxx(win1) + 1;
+    int lmar1 = (COLS - (5 * (xmax1) / 3)) / 2;
+    int rc = ERR;
+
+    if (high > 8)
+	high = 8;
+    tmar = (ymax - (5 * high)) / 2 + overlap_HEAD;
+
+    rc = mvwin(win1, tmar, lmar1 + shift);
+    return rc;
+}
+
 static void
 fillwin(WINDOW *win, char ch)
 {
@@ -6378,24 +6864,107 @@
     }
 }
 
+#define InCross(x,y, x1,y1) \
+	    (((x > (x1 - 1) / 3) && (x <= (2 * (x1 - 1)) / 3)) \
+		|| (((y > (y1 - 1) / 3) && (y <= (2 * (y1 - 1)) / 3))))
+
 static void
 crosswin(WINDOW *win, char ch)
 {
     int y, x;
     int y1, x1;
+    int xw = 1;
 
     getmaxyx(win, y1, x1);
     for (y = 0; y < y1; y++) {
-	for (x = 0; x < x1; x++)
-	    if (((x > (x1 - 1) / 3) && (x <= (2 * (x1 - 1)) / 3))
-		|| (((y > (y1 - 1) / 3) && (y <= (2 * (y1 - 1)) / 3)))) {
+	for (x = 0; x < x1; x += xw) {
+	    if (InCross(x, y, x1, y1)) {
 		wmove(win, y, x);
 		waddch(win, UChar(ch));
 	    }
+	}
     }
 }
 
-#define OVERLAP_FLAVORS 5
+/*
+ * Match "crosswin()", but using line-drawing characters.  This could be done
+ * a little simpler using box(), but the reason for this example is to test
+ * hline/vline and addch with line-drawing vs the copy/overlay functions.
+ */
+static void
+crossbox(WINDOW *win)
+{
+    int y1, x1;
+    int ymax, xmax;
+
+    getmaxyx(win, y1, x1);
+
+    ymax = (y1 + 1);
+    xmax = (x1 + 1);
+
+    mvwhline(win, 0, (xmax / 3), ACS_HLINE, (xmax / 3));
+    mvwhline(win, ymax / 3, 0, ACS_HLINE, xmax);
+    mvwhline(win, ((2 * ymax) / 3) - 1, 0, ACS_HLINE, xmax);
+    mvwhline(win, y1 - 1, (xmax / 3), ACS_HLINE, (xmax / 3));
+
+    mvwvline(win, (ymax / 3), 0, ACS_VLINE, (ymax / 3));
+    mvwvline(win, 0, xmax / 3, ACS_VLINE, ymax);
+    mvwvline(win, 0, ((2 * xmax) / 3) - 1, ACS_VLINE, ymax);
+    mvwvline(win, (ymax / 3), x1 - 1, ACS_VLINE, (ymax / 3));
+
+    mvwaddch(win, 0, (xmax / 3), ACS_ULCORNER);
+    mvwaddch(win, 0, ((2 * xmax) / 3) - 1, ACS_URCORNER);
+    mvwaddch(win, y1 - 1, (xmax / 3), ACS_LLCORNER);
+    mvwaddch(win, y1 - 1, ((2 * xmax) / 3) - 1, ACS_LRCORNER);
+
+    mvwaddch(win, (ymax / 3), 0, ACS_ULCORNER);
+    mvwaddch(win, ((2 * ymax) / 3) - 1, 0, ACS_LLCORNER);
+    mvwaddch(win, (ymax / 3), x1 - 1, ACS_URCORNER);
+    mvwaddch(win, ((2 * ymax) / 3) - 1, x1 - 1, ACS_LRCORNER);
+
+    mvwaddch(win, (ymax / 3), (xmax / 3), ACS_PLUS);
+    mvwaddch(win, (ymax / 3), ((2 * xmax) / 3) - 1, ACS_PLUS);
+    mvwaddch(win, ((2 * ymax) / 3) - 1, ((2 * xmax) / 3) - 1, ACS_PLUS);
+    mvwaddch(win, ((2 * ymax) / 3) - 1, (xmax / 3), ACS_PLUS);
+}
+
+typedef enum {
+    otBASE_refresh = 0
+    ,otBASE_fill
+    ,otBASE_draw
+    ,otBASE_clear
+    ,otBASE_copy
+} otBASE;
+
+#define OVERLAP_FLAVORS 6
+
+typedef enum {
+    otFILL_normal = 0
+    ,otFILL_bold
+    ,otFILL_color
+    ,otFILL_bright
+} otFILL;
+
+#define LimitFILL() UseColors ? 4 : 2
+
+typedef enum {
+    otDRAW_text_cross = 0
+    ,otDRAW_line_box
+    ,otDRAW_line_cross
+    ,otDRAW_set_bg
+    ,otDRAW_reset_bg
+} otDRAW;
+
+#define LimitDRAW() UseColors ? 5 : 3
+
+typedef enum {
+    otCOPY_overwrite = 0
+    ,otCOPY_merge
+    ,otCOPY_force
+    ,otCOPY_overlay
+} otCOPY;
+
+#define LimitCOPY() 4
 
 static void
 overlap_helpitem(int state, int item, char *message)
@@ -6413,18 +6982,18 @@
 {
     NCURSES_PAIRS_T cpair = (NCURSES_PAIRS_T) (1 + (flavor * 2) + col);
 
-    switch (flavor) {
-    case 0:
+    switch ((otFILL) flavor) {
+    case otFILL_normal:
 	(void) wattrset(win, A_NORMAL);
 	break;
-    case 1:
+    case otFILL_bold:
 	(void) wattrset(win, A_BOLD);
 	break;
-    case 2:
+    case otFILL_color:
 	init_pair(cpair, COLOR_BLUE, COLOR_WHITE);
 	(void) wattrset(win, AttrArg(COLOR_PAIR(cpair), A_NORMAL));
 	break;
-    case 3:
+    case otFILL_bright:
 	init_pair(cpair, COLOR_WHITE, COLOR_BLUE);
 	(void) wattrset(win, AttrArg(COLOR_PAIR(cpair), A_BOLD));
 	break;
@@ -6436,18 +7005,21 @@
 {
     NCURSES_PAIRS_T cpair = (NCURSES_PAIRS_T) (9 + (flavor * 2) + col);
 
-    switch (flavor) {
-    case 0:
+    switch ((otDRAW) flavor) {
+    case otDRAW_text_cross:
 	/* no effect */
 	break;
-    case 1:
+    case otDRAW_line_box:
 	/* no effect */
 	break;
-    case 2:
+    case otDRAW_line_cross:
+	/* no effect */
+	break;
+    case otDRAW_set_bg:
 	init_pair(cpair, COLOR_RED, COLOR_GREEN);
 	wbkgdset(win, colored_chtype(' ', A_BLINK, cpair));
 	break;
-    case 3:
+    case otDRAW_reset_bg:
 	wbkgdset(win, ' ' | A_NORMAL);
 	break;
     }
@@ -6456,10 +7028,8 @@
 static int
 overlap_help(int state, int flavors[OVERLAP_FLAVORS])
 {
-    int row;
-    int col;
     int item;
-    const char *ths, *tht;
+    int limit[OVERLAP_FLAVORS];
     char msg[80];
 
     if (state < 0)
@@ -6468,64 +7038,76 @@
     assert(state >= 0 && state < OVERLAP_FLAVORS);
 
     for (item = 0; item < (2 * OVERLAP_FLAVORS); ++item) {
-	row = item / 2;
-	col = item % 2;
-	ths = col ? "B" : "A";
-	tht = col ? "A" : "B";
+	int row = item / 2;
+	int col = item % 2;
+	const char *ths = col ? "B" : "A";
+	const char *tht = col ? "A" : "B";
 
-	switch (row) {
-	case 0:
+	switch ((otBASE) row) {
+	case otBASE_refresh:
+	    limit[row] = 1;
 	    flavors[row] = 0;
-	    sprintf(msg, "refresh %s, then %s, then doupdate.", ths, tht);
+	    _nc_SPRINTF(msg, _nc_SLIMIT(sizeof(msg))
+			"refresh %s, then %s, then doupdate.", ths, tht);
 	    break;
-	case 1:
-	    if (use_colors) {
-		flavors[row] %= 4;
-	    } else {
-		flavors[row] %= 2;
-	    }
+	case otBASE_fill:
+	    limit[row] = LimitFILL();
+	    flavors[row] %= limit[row];
 	    overlap_test_1_attr(stdscr, flavors[row], col);
-	    sprintf(msg, "fill window %s with letter %s.", ths, ths);
+	    _nc_SPRINTF(msg, _nc_SLIMIT(sizeof(msg))
+			"fill window %s with letter %s.", ths, ths);
 	    break;
-	case 2:
-	    if (use_colors) {
-		flavors[row] %= 4;
-	    } else {
-		flavors[row] %= 2;
-	    }
-	    switch (flavors[row]) {
-	    case 0:
-		sprintf(msg, "cross pattern in window %s.", ths);
+	case otBASE_draw:
+	    limit[row] = LimitDRAW();
+	    flavors[row] %= limit[row];
+	    switch ((otDRAW) flavors[row]) {
+	    case otDRAW_text_cross:
+		_nc_SPRINTF(msg, _nc_SLIMIT(sizeof(msg))
+			    "cross text-pattern in window %s.", ths);
 		break;
-	    case 1:
-		sprintf(msg, "draw box in window %s.", ths);
+	    case otDRAW_line_box:
+		_nc_SPRINTF(msg, _nc_SLIMIT(sizeof(msg))
+			    "draw line-box in window %s.", ths);
 		break;
-	    case 2:
-		sprintf(msg, "set background of window %s.", ths);
+	    case otDRAW_line_cross:
+		_nc_SPRINTF(msg, _nc_SLIMIT(sizeof(msg))
+			    "draw line-cross in window %s.", ths);
 		break;
-	    case 3:
-		sprintf(msg, "reset background of window %s.", ths);
+	    case otDRAW_set_bg:
+		_nc_SPRINTF(msg, _nc_SLIMIT(sizeof(msg))
+			    "set background of window %s.", ths);
+		break;
+	    case otDRAW_reset_bg:
+		_nc_SPRINTF(msg, _nc_SLIMIT(sizeof(msg))
+			    "reset background of window %s.", ths);
 		break;
 	    }
 	    break;
-	case 3:
+	case otBASE_clear:
+	    limit[row] = 1;
 	    flavors[row] = 0;
-	    sprintf(msg, "clear window %s.", ths);
+	    _nc_SPRINTF(msg, _nc_SLIMIT(sizeof(msg))
+			"clear window %s.", ths);
 	    break;
-	case 4:
-	    flavors[row] %= 4;
-	    switch (flavors[row]) {
-	    case 0:
-		sprintf(msg, "overwrite %s onto %s.", ths, tht);
+	case otBASE_copy:
+	    limit[row] = LimitCOPY();
+	    flavors[row] %= limit[row];
+	    switch ((otCOPY) flavors[row]) {
+	    case otCOPY_overwrite:
+		_nc_SPRINTF(msg, _nc_SLIMIT(sizeof(msg))
+			    "overwrite %s onto %s.", ths, tht);
 		break;
-	    case 1:
-		sprintf(msg, "copywin(FALSE) %s onto %s.", ths, tht);
+	    case otCOPY_merge:
+		_nc_SPRINTF(msg, _nc_SLIMIT(sizeof(msg))
+			    "copywin(FALSE) %s onto %s.", ths, tht);
 		break;
-	    case 2:
-		sprintf(msg, "copywin(TRUE) %s onto %s.", ths, tht);
+	    case otCOPY_force:
+		_nc_SPRINTF(msg, _nc_SLIMIT(sizeof(msg))
+			    "copywin(TRUE) %s onto %s.", ths, tht);
 		break;
-	    case 3:
-		sprintf(msg, "overlay %s onto %s.", ths, tht);
+	    case otCOPY_overlay:
+		_nc_SPRINTF(msg, _nc_SLIMIT(sizeof(msg))
+			    "overlay %s onto %s.", ths, tht);
 		break;
 	    }
 	    break;
@@ -6535,8 +7117,12 @@
 	wbkgdset(stdscr, ' ' | A_NORMAL);
     }
     move(LINES - 1, 0);
-    printw("^Q/ESC = terminate test.  Up/down/space select test variations (%d %d).",
-	   state, flavors[state]);
+    printw("^Q/ESC = terminate test. </> shift. Up/down/space select (row %d",
+	   state + 1);
+    if (limit[state] > 1)
+	printw(" test %d:%d", 1 + flavors[state], limit[state]);
+    printw(").");
+    clrtoeol();
 
     return state;
 }
@@ -6563,17 +7149,20 @@
 overlap_test_2(int flavor, int col, WINDOW *a, char fill)
 {
     overlap_test_2_attr(a, flavor, col);
-    switch (flavor) {
-    case 0:
+    switch ((otDRAW) flavor) {
+    case otDRAW_text_cross:
 	crosswin(a, fill);
 	break;
-    case 1:
+    case otDRAW_line_box:
 	box(a, 0, 0);
 	break;
-    case 2:
+    case otDRAW_line_cross:
+	crossbox(a);
+	break;
+    case otDRAW_set_bg:
 	/* done in overlap_test_2_attr */
 	break;
-    case 3:
+    case otDRAW_reset_bg:
 	/* done in overlap_test_2_attr */
 	break;
     }
@@ -6589,44 +7178,48 @@
 static void
 overlap_test_4(int flavor, WINDOW *a, WINDOW *b)
 {
-    switch (flavor) {
-    case 0:
+    switch ((otCOPY) flavor) {
+    case otCOPY_overwrite:
 	overwrite(a, b);
 	break;
-    case 1:
+    case otCOPY_merge:
 	copywin(a, b, 0, 0, 0, 0, getmaxy(b), getmaxx(b), FALSE);
 	break;
-    case 2:
+    case otCOPY_force:
 	copywin(a, b, 0, 0, 0, 0, getmaxy(b), getmaxx(b), TRUE);
 	break;
-    case 3:
+    case otCOPY_overlay:
 	overlay(a, b);
 	break;
     }
 }
 
 /* test effects of overlapping windows */
-static void
-overlap_test(void)
+static int
+overlap_test(bool recur GCC_UNUSED)
 {
+    WINDOW *win1, *win2;
     int ch;
+    int shift = 0, last_refresh = -1;
     int state, flavor[OVERLAP_FLAVORS];
 
-    WINDOW *win1 = newwin(9, 20, 3, 3);
-    WINDOW *win2 = newwin(9, 20, 9, 16);
+    if ((win1 = make_overlap(0)) == 0) {
+	return ERR;
+    } else if ((win2 = make_overlap(1)) == 0) {
+	delwin(win1);
+	return ERR;
+    }
 
     curs_set(0);
     raw();
     refresh();
     move(0, 0);
-    printw("This test shows the behavior of wnoutrefresh() with respect to\n");
-    printw("the shared region of two overlapping windows A and B.  The cross\n");
-    printw("pattern in each window does not overlap the other.\n");
+    printw("Test wnoutrefresh() for two overlapping windows:");
 
     memset(flavor, 0, sizeof(flavor));
     state = overlap_help(0, flavor);
 
-    while (!isQuit(ch = Getchar()))
+    while (!isQuit(ch = Getchar(), TRUE)) {
 	switch (ch) {
 	case 'a':		/* refresh window A first, then B */
 	    overlap_test_0(win1, win2);
@@ -6636,20 +7229,20 @@
 	    overlap_test_0(win2, win1);
 	    break;
 
-	case 'c':		/* fill window A so it's visible */
-	    overlap_test_1(flavor[1], 0, win1, 'A');
+	case 'c':		/* fill window A so it is visible */
+	    overlap_test_1(flavor[otBASE_fill], 0, win1, 'A');
 	    break;
 
-	case 'd':		/* fill window B so it's visible */
-	    overlap_test_1(flavor[1], 1, win2, 'B');
+	case 'd':		/* fill window B so it is visible */
+	    overlap_test_1(flavor[otBASE_fill], 1, win2, 'B');
 	    break;
 
 	case 'e':		/* cross test pattern in window A */
-	    overlap_test_2(flavor[2], 0, win1, 'A');
+	    overlap_test_2(flavor[otBASE_draw], 0, win1, 'A');
 	    break;
 
 	case 'f':		/* cross test pattern in window A */
-	    overlap_test_2(flavor[2], 1, win2, 'B');
+	    overlap_test_2(flavor[otBASE_draw], 1, win2, 'B');
 	    break;
 
 	case 'g':		/* clear window A */
@@ -6661,11 +7254,11 @@
 	    break;
 
 	case 'i':		/* overwrite A onto B */
-	    overlap_test_4(flavor[4], win1, win2);
+	    overlap_test_4(flavor[otBASE_copy], win1, win2);
 	    break;
 
 	case 'j':		/* overwrite B onto A */
-	    overlap_test_4(flavor[4], win2, win1);
+	    overlap_test_4(flavor[otBASE_copy], win2, win1);
 	    break;
 
 	case CTRL('n'):
@@ -6683,20 +7276,349 @@
 	    state = overlap_help(state, flavor);
 	    break;
 
-	case '?':
+	case HELP_KEY_1:
 	    state = overlap_help(state, flavor);
 	    break;
 
+	case '<':
+	    /* FALLTHRU */
+	case '>':
+	    /* see below */
+	    break;
+
 	default:
 	    beep();
 	    break;
 	}
 
+	switch (ch) {
+	case 'a':
+	    /* FALLTHRU */
+	case 'b':
+	    last_refresh = ch;
+	    break;
+	case '<':
+	    shift -= 2;
+	    /* FALLTHRU */
+	case '>':
+	    shift += 1;
+	    if (move_overlap(shift, win1) != OK) {
+		flash();
+		shift += (ch == '>') ? -1 : 1;
+	    } else if (last_refresh > 0) {
+		clear_overlap();
+		wnoutrefresh(stdscr);
+		if (last_refresh == 'a')
+		    overlap_test_0(win1, win2);
+		else
+		    overlap_test_0(win2, win1);
+	    }
+	    break;
+	default:
+	    last_refresh = -1;
+	    break;
+	}
+    }
+
     delwin(win2);
     delwin(win1);
     erase();
-    curs_set(1);
-    endwin();
+    stop_curses();
+    return OK;
+}
+
+#if USE_WIDEC_SUPPORT
+static void
+x_fillwin(WINDOW *win, wchar_t ch)
+{
+    int y, x;
+    int y1, x1;
+
+    getmaxyx(win, y1, x1);
+    x1 /= 2;
+    for (y = 0; y < y1; y++) {
+	wmove(win, y, 0);
+	for (x = 0; x < x1; x++)
+	    waddnwstr(win, &ch, 1);
+    }
+}
+
+static void
+x_crosswin(WINDOW *win, wchar_t ch)
+{
+    int y, x;
+    int y1, x1;
+    int xw = 2;
+
+    getmaxyx(win, y1, x1);
+    for (y = 0; y < y1; y++) {
+	for (x = 0; x < x1; x += xw) {
+	    if (InCross(x, y, x1, y1)) {
+		wmove(win, y, x);
+		waddnwstr(win, &ch, 1);
+	    }
+	}
+    }
+}
+
+static void
+x_overlap_test_1(int flavor, int col, WINDOW *a, wchar_t fill)
+{
+    overlap_test_1_attr(a, flavor, col);
+    x_fillwin(a, fill);
+    (void) wattrset(a, A_NORMAL);
+}
+
+static void
+x_overlap_test_2(int flavor, int col, WINDOW *a, wchar_t fill)
+{
+    overlap_test_2_attr(a, flavor, col);
+    switch ((otDRAW) flavor) {
+    case otDRAW_text_cross:
+	x_crosswin(a, fill);
+	break;
+    case otDRAW_line_box:
+	box(a, 0, 0);
+	break;
+    case otDRAW_line_cross:
+	crossbox(a);
+	break;
+    case otDRAW_set_bg:
+	/* done in overlap_test_2_attr */
+	break;
+    case otDRAW_reset_bg:
+	/* done in overlap_test_2_attr */
+	break;
+    }
+}
+
+/* test effects of overlapping windows */
+static int
+x_overlap_test(bool recur GCC_UNUSED)
+{
+    const wchar_t WIDE_A = 0xff21;
+    const wchar_t WIDE_B = 0xff22;
+    WINDOW *win1, *win2;
+    int ch;
+    int shift = 0, last_refresh = -1;
+    int state, flavor[OVERLAP_FLAVORS];
+
+    if ((win1 = make_overlap(0)) == 0) {
+	return ERR;
+    } else if ((win2 = make_overlap(1)) == 0) {
+	delwin(win1);
+	return ERR;
+    }
+
+    curs_set(0);
+    raw();
+    refresh();
+    move(0, 0);
+    printw("Test wnoutrefresh() for overlapping windows with double-cell characters:");
+
+    memset(flavor, 0, sizeof(flavor));
+    state = overlap_help(0, flavor);
+
+    while (!isQuit(ch = Getchar(), TRUE)) {
+	switch (ch) {
+	case 'a':		/* refresh window A first, then B */
+	    overlap_test_0(win1, win2);
+	    break;
+
+	case 'b':		/* refresh window B first, then A */
+	    overlap_test_0(win2, win1);
+	    break;
+
+	case 'c':		/* fill window A so it is visible */
+	    x_overlap_test_1(flavor[otBASE_fill], 0, win1, WIDE_A);
+	    break;
+
+	case 'd':		/* fill window B so it is visible */
+	    x_overlap_test_1(flavor[otBASE_fill], 1, win2, WIDE_B);
+	    break;
+
+	case 'e':		/* cross test pattern in window A */
+	    x_overlap_test_2(flavor[otBASE_draw], 0, win1, WIDE_A);
+	    break;
+
+	case 'f':		/* cross test pattern in window A */
+	    x_overlap_test_2(flavor[otBASE_draw], 1, win2, WIDE_B);
+	    break;
+
+	case 'g':		/* clear window A */
+	    overlap_test_3(win1);
+	    break;
+
+	case 'h':		/* clear window B */
+	    overlap_test_3(win2);
+	    break;
+
+	case 'i':		/* overwrite A onto B */
+	    overlap_test_4(flavor[otBASE_copy], win1, win2);
+	    break;
+
+	case 'j':		/* overwrite B onto A */
+	    overlap_test_4(flavor[otBASE_copy], win2, win1);
+	    break;
+
+	case CTRL('n'):
+	case KEY_DOWN:
+	    state = overlap_help(state + 1, flavor);
+	    break;
+
+	case CTRL('p'):
+	case KEY_UP:
+	    state = overlap_help(state - 1, flavor);
+	    break;
+
+	case ' ':
+	    flavor[state] += 1;
+	    state = overlap_help(state, flavor);
+	    break;
+
+	case HELP_KEY_1:
+	    state = overlap_help(state, flavor);
+	    break;
+
+	case '<':
+	    /* FALLTHRU */
+	case '>':
+	    /* see below */
+	    break;
+
+	default:
+	    beep();
+	    break;
+	}
+
+	switch (ch) {
+	case 'a':
+	    /* FALLTHRU */
+	case 'b':
+	    last_refresh = ch;
+	    break;
+	case '<':
+	    shift -= 2;
+	    /* FALLTHRU */
+	case '>':
+	    shift += 1;
+	    if (move_overlap(shift, win1) != OK) {
+		flash();
+		shift += (ch == '>') ? -1 : 1;
+	    } else if (last_refresh > 0) {
+		clear_overlap();
+		wnoutrefresh(stdscr);
+		if (last_refresh == 'a')
+		    overlap_test_0(win1, win2);
+		else
+		    overlap_test_0(win2, win1);
+	    }
+	    break;
+	default:
+	    last_refresh = -1;
+	    break;
+	}
+    }
+
+    delwin(win2);
+    delwin(win1);
+    erase();
+    stop_curses();
+    return OK;
+}
+#endif /* USE_WIDEC_SUPPORT */
+
+#endif /* HAVE_COPYWIN */
+
+static void
+show_setting_name(const char *name)
+{
+    printw("%-25s ", name);
+}
+
+static void
+show_string_setting(const char *name, const char *value)
+{
+    show_setting_name(name);
+    if (value) {
+	printw("\"%s\"", value);
+    } else {
+	attron(A_REVERSE);
+	addstr("<NULL>");
+	attroff(A_REVERSE);
+    }
+    AddCh('\n');
+}
+
+static void
+show_number_setting(const char *name, int value)
+{
+    show_setting_name(name);
+    if (value >= 0) {
+	printw("%d", value);
+    } else {
+	attron(A_REVERSE);
+	printw("%d", value);
+	attroff(A_REVERSE);
+    }
+    AddCh('\n');
+}
+
+static void
+show_boolean_setting(const char *name, int value)
+{
+    show_setting_name(name);
+    if (value >= 0) {
+	printw("%s", value ? "TRUE" : "FALSE");
+    } else {
+	attron(A_REVERSE);
+	printw("%d", value);
+	attroff(A_REVERSE);
+    }
+    AddCh('\n');
+}
+
+static int
+settings_test(bool recur GCC_UNUSED)
+{
+#if USE_WIDEC_SUPPORT
+    wchar_t ch;
+#endif
+
+    move(0, 0);
+    show_string_setting("termname", termname());
+    show_string_setting("longname", longname());
+    show_number_setting("baudrate", baudrate());
+    if (erasechar() > 0) {
+	show_string_setting("unctrl(erasechar)", unctrl((chtype) erasechar()));
+	show_string_setting("keyname(erasechar)", keyname(erasechar()));
+    }
+    if (killchar() > 0) {
+	show_string_setting("unctrl(killchar)", unctrl((chtype) killchar()));
+	show_string_setting("keyname(killchar)", keyname(killchar()));
+    }
+#if USE_WIDEC_SUPPORT
+    if (erasewchar(&ch) == OK) {
+	show_string_setting("key_name(erasewchar)", key_name(ch));
+    }
+    if (killwchar(&ch) == OK) {
+	show_string_setting("key_name(killwchar)", key_name(ch));
+    }
+#endif
+    show_boolean_setting("has_ic", has_ic());
+    show_boolean_setting("has_il", has_il());
+    show_boolean_setting("has_colors", has_colors());
+#if HAVE_COLOR_CONTENT
+    show_boolean_setting("can_change_color", can_change_color());
+#endif
+    show_setting_name("LINES");
+    printw("%d\n", LINES);
+    show_setting_name("COLS");
+    printw("%d\n", COLS);
+    Pause();
+    erase();
+    stop_curses();
+    return OK;
 }
 
 /****************************************************************************
@@ -6705,180 +7627,50 @@
  *
  ****************************************************************************/
 
-static bool
-do_single_test(const char c)
-/* perform a single specified test */
-{
-    switch (c) {
-    case 'a':
-	getch_test();
-	break;
-
-#if USE_WIDEC_SUPPORT
-    case 'A':
-	get_wch_test();
-	break;
-#endif
-
-    case 'b':
-	attr_test();
-	break;
-
-#if USE_WIDEC_SUPPORT
-    case 'B':
-	wide_attr_test();
-	break;
-#endif
-
-    case 'c':
-	if (!use_colors)
-	    Cannot("does not support color.");
-	else
-	    color_test();
-	break;
-
-#if USE_WIDEC_SUPPORT
-    case 'C':
-	if (!use_colors)
-	    Cannot("does not support color.");
-	else
-	    wide_color_test();
-	break;
-#endif
-
-    case 'd':
-	if (!use_colors)
-	    Cannot("does not support color.");
-	else if (!can_change_color())
-	    Cannot("has hardwired color values.");
-	else
-	    color_edit();
-	break;
-
-#if USE_SOFTKEYS
-    case 'e':
-	slk_test();
-	break;
-
-#if USE_WIDEC_SUPPORT
-    case 'E':
-	wide_slk_test();
-	break;
-#endif
-#endif
-
-    case 'f':
-	acs_display();
-	break;
-
-#if USE_WIDEC_SUPPORT
-    case 'F':
-	wide_acs_display();
-	break;
-#endif
-
-#if USE_LIBPANEL
-    case 'o':
-	demo_panels(init_panel, fill_panel);
-	break;
-#endif
-
-#if USE_WIDEC_SUPPORT && USE_LIBPANEL
-    case 'O':
-	demo_panels(init_wide_panel, fill_wide_panel);
-	break;
-#endif
-
-    case 'g':
-	acs_and_scroll();
-	break;
-
-    case 'i':
-	flushinp_test(stdscr);
-	break;
-
-    case 'k':
-	test_sgr_attributes();
-	break;
-
-#if USE_LIBMENU
-    case 'm':
-	menu_test();
-	break;
-#endif
-
-    case 'p':
-	demo_pad(FALSE);
-	break;
-
-    case 'P':
-	demo_pad(TRUE);
-	break;
-
-#if USE_LIBFORM
-    case 'r':
-	demo_forms();
-	break;
-#endif
-
-    case 's':
-	overlap_test();
-	break;
-
-#if USE_LIBMENU && defined(TRACE)
-    case 't':
-	trace_set();
-	break;
-#endif
-
-    case '?':
-	break;
-
-    default:
-	return FALSE;
-    }
-
-    return TRUE;
-}
-
 static void
-usage(void)
+usage(int ok)
 {
     static const char *const tbl[] =
     {
 	"Usage: ncurses [options]"
 	,""
+	,USAGE_COMMON
 	,"Options:"
 #ifdef NCURSES_VERSION
-	,"  -a f,b   set default-colors (assumed white-on-black)"
-	,"  -d       use default-colors if terminal supports them"
+	," -a f,b   set default-colors (assumed white-on-black)"
+	," -d       use default-colors if terminal supports them"
 #endif
 #if HAVE_USE_ENV
-	,"  -E       call use_env(FALSE) to ignore $LINES and $COLUMNS"
+	," -E       call use_env(FALSE) to ignore $LINES and $COLUMNS"
 #endif
 #if USE_SOFTKEYS
-	,"  -e fmt   specify format for soft-keys test (e)"
+	," -e fmt   specify format for soft-keys test (e)"
 #endif
 #if HAVE_RIPOFFLINE
-	,"  -f       rip-off footer line (can repeat)"
-	,"  -h       rip-off header line (can repeat)"
+	," -F       rip-off footer line (can repeat)"
+	," -H       rip-off header line (can repeat)"
 #endif
-	,"  -m       do not use colors"
-	,"  -p file  rgb values to use in 'd' rather than ncurses's builtin"
+	," -m       do not use colors"
+#if HAVE_COLOR_CONTENT
+	," -p file  rgb values to use in 'd' rather than ncurses's builtin"
+#endif
 #if USE_LIBPANEL
-	,"  -s msec  specify nominal time for panel-demo (default: 1, to hold)"
+	," -s msec  specify nominal time for panel-demo (default: 1, to hold)"
 #endif
-#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20120714) && !defined(__MINGW32__)
-	,"  -T       call use_tioctl(TRUE) to allow SIGWINCH to override environment"
+#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20120714) && !defined(_NC_WINDOWS)
+	," -T       call use_tioctl(TRUE) to allow SIGWINCH to override environment"
 #endif
 #ifdef TRACE
-	,"  -t mask  specify default trace-level (may toggle with ^T)"
+	," -t mask  specify default trace-level (may toggle with ^T)"
+#endif
+#if HAVE_COLOR_CONTENT
+	," -x       use xterm-compatible control for reading color palette"
 #endif
     };
     size_t n;
     for (n = 0; n < SIZEOF(tbl); n++)
 	fprintf(stderr, "%s\n", tbl[n]);
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
 
 static void
@@ -6927,57 +7719,84 @@
 static void
 main_menu(bool top)
 {
-    char command;
-
-    do {
-	(void) puts("This is the ncurses main menu");
-	(void) puts("a = keyboard and mouse input test");
 #if USE_WIDEC_SUPPORT
-	(void) puts("A = wide-character keyboard and mouse input test");
+    typedef struct {
+	bool recur;
+	int (*narrow_func) (bool);
+	int (*wide_func) (bool);
+	int code;
+	const char *help;
+    } MyCmds;
+#define BOTH(a)   a, x_ ## a
+#define ONLY(a)   a, NULL
+#define CMDS(recur, funcs,code,help) { recur, funcs, code, help }
+#else
+    typedef struct {
+	bool recur;
+	int (*narrow_func) (bool);
+	int code;
+	const char *help;
+    } MyCmds;
+#define BOTH(a)   a
+#define ONLY(a)   a
+#define CMDS(recur, funcs,code,help) { recur, funcs, code, help }
 #endif
-	(void) puts("b = character attribute test");
-#if USE_WIDEC_SUPPORT
-	(void) puts("B = wide-character attribute test");
+    /* *INDENT-OFF* */
+    static MyCmds cmds[] =
+    {
+	CMDS(TRUE, BOTH(getch_test),	'a', "keyboard and mouse input test"),
+	CMDS(TRUE, BOTH(attr_test),	'b', "character attribute test"),
+	CMDS(TRUE, BOTH(color_test),	'c', "color test pattern"),
+#if HAVE_COLOR_CONTENT
+	CMDS(FALSE, ONLY(color_edit),	'd', "edit RGB color values"),
 #endif
-	(void) puts("c = color test pattern");
-#if USE_WIDEC_SUPPORT
-	(void) puts("C = color test pattern using wide-character calls");
-#endif
-	if (top)
-	    (void) puts("d = edit RGB color values");
 #if USE_SOFTKEYS
-	(void) puts("e = exercise soft keys");
-#if USE_WIDEC_SUPPORT
-	(void) puts("E = exercise soft keys using wide-characters");
+	CMDS(TRUE, BOTH(slk_test),	'e', "exercise soft keys"),
 #endif
-#endif
-	(void) puts("f = display ACS characters");
-#if USE_WIDEC_SUPPORT
-	(void) puts("F = display Wide-ACS characters");
-#endif
-	(void) puts("g = display windows and scrolling");
-	(void) puts("i = test of flushinp()");
-	(void) puts("k = display character attributes");
+	CMDS(TRUE, BOTH(acs_test),	'f', "display ACS characters"),
+	CMDS(TRUE, ONLY(scroll_test),   'g', "display windows and scrolling"),
+	CMDS(TRUE, ONLY(flushinp_test),	'i', "test flushinp()"),
+	CMDS(TRUE, ONLY(sgr_attr_test),	'k', "display character attributes"),
 #if USE_LIBMENU
-	(void) puts("m = menu code test");
+	CMDS(TRUE, ONLY(menu_test),	'm', "exercise menu library"),
 #endif
 #if USE_LIBPANEL
-	(void) puts("o = exercise panels library");
-#if USE_WIDEC_SUPPORT
-	(void) puts("O = exercise panels with wide-characters");
+	CMDS(TRUE, BOTH(panel_test),	'o', "exercise panel library"),
 #endif
+#if HAVE_NEWPAD
+	CMDS(TRUE, ONLY(pad_test),	'p', "exercise pad features"),
 #endif
-	(void) puts("p = exercise pad features");
-	(void) puts("P = exercise pad features, using color");
-	(void) puts("q = quit");
-#if USE_LIBFORM
-	(void) puts("r = exercise forms code");
+	CMDS(TRUE, ONLY(NULL),		'q', "quit"),
+#if USE_LIBMENU
+	CMDS(TRUE, ONLY(form_test),	'r', "exercise form library"),
 #endif
-	(void) puts("s = overlapping-refresh test");
+#if HAVE_COPYWIN
+	CMDS(TRUE, BOTH(overlap_test),	's', "overlapping-refresh test"),
+#endif
 #if USE_LIBMENU && defined(TRACE)
-	(void) puts("t = set trace level");
+	CMDS(TRUE, ONLY(trace_set),	't', "set trace level"),
 #endif
-	(void) puts("? = repeat this command summary");
+	CMDS(TRUE, ONLY(settings_test),	'v', "show terminal name and settings"),
+	CMDS(FALSE, ONLY(NULL),		'?', "repeat this command summary")
+    };
+    /* *INDENT-ON* */
+
+    int (*doit) (bool);
+    char command;
+    unsigned n;
+    do {
+	printf("This is the ncurses main menu (uppercase for wide-characters)\n");
+	for (n = 0; n < SIZEOF(cmds); ++n) {
+	    if (top || cmds[n].recur) {
+		putchar(' ');
+#if USE_WIDEC_SUPPORT
+		if (cmds[n].wide_func) {
+		    printf("%c,", toupper(cmds[n].code));
+		}
+#endif
+		printf("%c\t= %s\n", cmds[n].code, cmds[n].help);
+	    }
+	}
 
 	(void) fputs("> ", stdout);
 	(void) fflush(stdout);	/* necessary under SVr4 curses */
@@ -6991,8 +7810,14 @@
 	for (;;) {
 	    char ch = '\0';
 	    if (read(fileno(stdin), &ch, (size_t) 1) <= 0) {
-		if (command == 0)
+		int save_err = errno;
+		perror("\nOOPS");
+		if (save_err == EINTR) {
+		    clearerr(stdin);
+		    continue;
+		} else if (command == 0) {
 		    command = 'q';
+		}
 		break;
 	    } else if (command == 0 && !isspace(UChar(ch))) {
 		command = ch;
@@ -7008,9 +7833,23 @@
 	    }
 	}
 
-	if (do_single_test(command)) {
+	doit = NULL;
+	for (n = 0; n < SIZEOF(cmds); ++n) {
+	    if (cmds[n].code == command) {
+		doit = cmds[n].narrow_func;
+		break;
+	    }
+#if USE_WIDEC_SUPPORT
+	    if (toupper(cmds[n].code) == command) {
+		doit = cmds[n].wide_func;
+		break;
+	    }
+#endif
+	}
+
+	if (doit != NULL && doit(FALSE) == OK) {
 	    /*
-	     * This may be overkill; it's intended to reset everything back
+	     * This may be overkill; it is intended to reset everything back
 	     * to the initial terminal modes so that tests don't get in
 	     * each other's way.
 	     */
@@ -7038,29 +7877,38 @@
 /*+-------------------------------------------------------------------------
 	main(argc,argv)
 --------------------------------------------------------------------------*/
-
-#define okCOLOR(n) ((n) >= 0 && (n) < max_colors)
-#define okRGB(n)   ((n) >= 0 && (n) <= 1000)
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
 {
-    int c;
+    int ch;
     int my_e_param = 1;
-#ifdef NCURSES_VERSION
+#ifdef NCURSES_VERSION_PATCH
+#if HAVE_USE_DEFAULT_COLORS
     int default_fg = COLOR_WHITE;
     int default_bg = COLOR_BLACK;
-    bool assumed_colors = FALSE;
     bool default_colors = FALSE;
+#if HAVE_ASSUME_DEFAULT_COLORS
+    bool assumed_colors = FALSE;
 #endif
-    char *palette_file = 0;
+#endif
+#endif
     bool monochrome = FALSE;
+#if HAVE_COLOR_CONTENT
+    bool xterm_colors = FALSE;
+    char *palette_file = 0;
+#endif
 
     setlocale(LC_ALL, "");
 
-    while ((c = getopt(argc, argv, "a:dEe:fhmp:s:Tt:")) != -1) {
-	switch (c) {
-#ifdef NCURSES_VERSION
+    while ((ch = getopt(argc, argv, OPTS_COMMON "a:dEe:FHmp:s:Tt:x")) != -1) {
+	switch (ch) {
+#ifdef NCURSES_VERSION_PATCH
+#if HAVE_USE_DEFAULT_COLORS
+#if HAVE_ASSUME_DEFAULT_COLORS
 	case 'a':
 	    assumed_colors = TRUE;
 	    switch (sscanf(optarg, "%d,%d", &default_fg, &default_bg)) {
@@ -7072,10 +7920,12 @@
 		break;
 	    }
 	    break;
+#endif
 	case 'd':
 	    default_colors = TRUE;
 	    break;
 #endif
+#endif
 #if HAVE_USE_ENV
 	case 'E':
 	    use_env(FALSE);
@@ -7085,32 +7935,34 @@
 	    my_e_param = atoi(optarg);
 #ifdef NCURSES_VERSION
 	    if (my_e_param > 3)	/* allow extended layouts */
-		usage();
+		usage(FALSE);
 #else
 	    if (my_e_param > 1)
-		usage();
+		usage(FALSE);
 #endif
 	    break;
 #if HAVE_RIPOFFLINE
-	case 'f':
+	case 'F':
 	    ripoffline(-1, rip_footer);
 	    break;
-	case 'h':
+	case 'H':
 	    ripoffline(1, rip_header);
 	    break;
 #endif /* HAVE_RIPOFFLINE */
 	case 'm':
 	    monochrome = TRUE;
 	    break;
+#if HAVE_COLOR_CONTENT
 	case 'p':
 	    palette_file = optarg;
 	    break;
+#endif
 #if USE_LIBPANEL
 	case 's':
 	    nap_msec = (int) atol(optarg);
 	    break;
 #endif
-#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20120714) && !defined(__MINGW32__)
+#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20120714) && !defined(_NC_WINDOWS)
 	case 'T':
 	    use_tioctl(TRUE);
 	    break;
@@ -7120,8 +7972,17 @@
 	    save_trace = (unsigned) strtol(optarg, 0, 0);
 	    break;
 #endif
+#if HAVE_COLOR_CONTENT
+	case 'x':
+	    xterm_colors = TRUE;
+	    break;
+#endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
 
@@ -7133,10 +7994,10 @@
 #ifdef TRACE
     /* enable debugging */
 #if !USE_LIBMENU
-    trace(save_trace);
+    curses_trace(save_trace);
 #else
     if (!isatty(fileno(stdin)))
-	trace(save_trace);
+	curses_trace(save_trace);
 #endif /* USE_LIBMENU */
 #endif /* TRACE */
 
@@ -7154,17 +8015,20 @@
     initscr();
     bkgdset(BLANK);
 
-    /* tests, in general, will want these modes */
-    use_colors = (bool) (monochrome ? FALSE : has_colors());
+    set_terminal_modes();
+    def_prog_mode();
 
-    if (use_colors) {
+    /* tests, in general, will want these modes */
+    UseColors = (bool) (monochrome ? FALSE : has_colors());
+
+    if (UseColors) {
 	start_color();
 #ifdef NCURSES_VERSION_PATCH
-	max_colors = COLORS;	/* was > 16 ? 16 : COLORS */
+	MaxColors = COLORS;	/* was > 16 ? 16 : COLORS */
 #if HAVE_USE_DEFAULT_COLORS
 	if (default_colors) {
 	    use_default_colors();
-	    min_colors = -1;
+	    MinColors = -1;
 	}
 #if HAVE_ASSUME_DEFAULT_COLORS
 	if (assumed_colors)
@@ -7172,52 +8036,16 @@
 #endif
 #endif
 #else /* normal SVr4 curses */
-	max_colors = COLORS;	/* was > 8 ? 8 : COLORS */
+	MaxColors = COLORS;	/* was > 8 ? 8 : COLORS */
 #endif
 	max_pairs = COLOR_PAIRS;	/* was > 256 ? 256 : COLOR_PAIRS */
 
+#if HAVE_COLOR_CONTENT
 	if (can_change_color()) {
-	    NCURSES_PAIRS_T cp;
-	    all_colors = typeMalloc(RGB_DATA, (unsigned) max_colors);
-	    if (!all_colors)
-		failed("all_colors");
-	    for (cp = 0; cp < max_colors; ++cp) {
-		color_content(cp,
-			      &all_colors[cp].red,
-			      &all_colors[cp].green,
-			      &all_colors[cp].blue);
-	    }
-	    if (palette_file != 0) {
-		FILE *fp = fopen(palette_file, "r");
-		if (fp != 0) {
-		    char buffer[BUFSIZ];
-		    int red, green, blue;
-		    int scale = 1000;
-		    while (fgets(buffer, sizeof(buffer), fp) != 0) {
-			if (sscanf(buffer, "scale:%d", &c) == 1) {
-			    scale = c;
-			} else if (sscanf(buffer, "%d:%d %d %d",
-					  &c,
-					  &red,
-					  &green,
-					  &blue) == 4
-				   && okCOLOR(c)
-				   && okRGB(red)
-				   && okRGB(green)
-				   && okRGB(blue)) {
-#define Scaled(n) (NCURSES_COLOR_T) (((n) * 1000) / scale)
-			    all_colors[c].red = Scaled(red);
-			    all_colors[c].green = Scaled(green);
-			    all_colors[c].blue = Scaled(blue);
-			}
-		    }
-		    fclose(fp);
-		}
-	    }
+	    init_all_colors(xterm_colors, palette_file);
 	}
+#endif
     }
-    set_terminal_modes();
-    def_prog_mode();
 
     /*
      * Return to terminal mode, so we're guaranteed of being able to
diff --git a/test/ncurses_tst.hin b/test/ncurses_tst.hin
index 1d77cbd..238fc22 100644
--- a/test/ncurses_tst.hin
+++ b/test/ncurses_tst.hin
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc.                        *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998 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,7 +31,7 @@
  *  Author: Thomas E. Dickey <dickey@clark.net> 1998                        *
  ****************************************************************************/
 /*
- * $Id: ncurses_tst.hin,v 1.2 1998/02/11 12:14:05 tom Exp $
+ * $Id: ncurses_tst.hin,v 1.3 2020/02/02 23:34:34 tom Exp $
  *
  * This is a template-file used to generate the "ncurses_cfg.h" file.
  *
diff --git a/test/newdemo.c b/test/newdemo.c
index f9b6f82..7876153 100644
--- a/test/newdemo.c
+++ b/test/newdemo.c
@@ -2,7 +2,7 @@
  *  newdemo.c	-	A demo program using PDCurses. The program illustrate
  *  	 		the use of colours for text output.
  *
- * $Id: newdemo.c,v 1.41 2014/08/02 23:10:56 tom Exp $
+ * $Id: newdemo.c,v 1.48 2022/12/10 23:36:05 tom Exp $
  */
 
 #include <test.priv.h>
@@ -50,7 +50,7 @@
 static void
 trap(int sig GCC_UNUSED)
 {
-    endwin();
+    stop_curses();
     ExitProgram(EXIT_FAILURE);
 }
 
@@ -61,11 +61,12 @@
 WaitForUser(WINDOW *win)
 {
     time_t t;
-    chtype key;
 
     nodelay(win, TRUE);
     t = time((time_t *) 0);
+
     while (1) {
+	chtype key;
 	if ((int) (key = (chtype) wgetch(win)) != ERR) {
 	    if (key == 'q' || key == 'Q')
 		return 1;
@@ -214,25 +215,55 @@
     return 0;
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: newdemo [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 /*
  *  Main driver
  */
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     WINDOW *win;
-    int w, x, y, i, j, k;
+    int x, y, i, k;
     char buffer[SIZEOF(messages) * 80];
-    const char *message;
     int width, height;
     chtype save[80];
-    chtype c;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
 
     setlocale(LC_ALL, "");
 
-    CATCHALL(trap);
-
-    initscr();
+    InitAndCatch(initscr(), trap);
     if (has_colors())
 	start_color();
     cbreak();
@@ -241,11 +272,16 @@
     height = 14;		/* Create a drawing window */
     win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2);
     if (win == NULL) {
-	endwin();
+	stop_curses();
 	ExitProgram(EXIT_FAILURE);
     }
 
     while (1) {
+	int w;
+	int j;
+	chtype c;
+	const char *message;
+
 	set_colors(win, 1, COLOR_WHITE, COLOR_BLUE);
 	werase(win);
 
@@ -299,11 +335,11 @@
 	message = messages[j = 0];
 	i = 1;
 	w = width - 2;
-	strcpy(buffer, message);
+	_nc_STRCPY(buffer, message, sizeof(buffer));
 	while (j < NMESSAGES) {
 	    while ((int) strlen(buffer) < w) {
-		strcat(buffer, " ... ");
-		strcat(buffer, messages[++j % NMESSAGES]);
+		_nc_STRCAT(buffer, " ... ", sizeof(buffer));
+		_nc_STRCAT(buffer, messages[++j % NMESSAGES], sizeof(buffer));
 	    }
 
 	    if (i < w)
@@ -360,6 +396,6 @@
 	if (WaitForUser(win) == 1)
 	    break;
     }
-    endwin();
+    stop_curses();
     ExitProgram(EXIT_SUCCESS);
 }
diff --git a/test/package/debian-mingw/compat b/test/package/debian-mingw/compat
index 7ed6ff8..48082f7 100644
--- a/test/package/debian-mingw/compat
+++ b/test/package/debian-mingw/compat
@@ -1 +1 @@
-5
+12
diff --git a/test/package/debian-mingw/control b/test/package/debian-mingw/control
index 74bb472..116103d 100644
--- a/test/package/debian-mingw/control
+++ b/test/package/debian-mingw/control
@@ -2,14 +2,14 @@
 Maintainer: Thomas E. Dickey <dickey@invisible-island.net>
 Section: misc
 Priority: optional
-Standards-Version: 3.8.4
+Standards-Version: 4.6.1.0
 Build-Depends: debhelper (>= 5)
-Homepage: http://invisible-island.net/ncurses/ncurses-examples.html
+Homepage: https://invisible-island.net/ncurses/ncurses-examples.html
 
 Package: mingw32-ncurses-examples
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: ncurses-examples - example/test programs from ncurses
+Description: example/test programs from ncurses
  These are the example/test programs from the ncurses distribution.
  .
  This package is used for testing ABI 6 with the MinGW 32-bit port.
diff --git a/test/package/debian-mingw/copyright b/test/package/debian-mingw/copyright
index ea1fdff..7546e1c 100644
--- a/test/package/debian-mingw/copyright
+++ b/test/package/debian-mingw/copyright
@@ -1,15 +1,16 @@
-Upstream source http://invisible-island.net/ncurses/ncurses-examples.html
+Upstream source https://invisible-island.net/ncurses/ncurses-examples.html
 
 Current ncurses maintainer: Thomas Dickey <dickey@invisible-island.net>
 
 -------------------------------------------------------------------------------
 Files: *
-Copyright: 1998-2014,2015 Free Software Foundation, Inc.
-Licence: X11
+Copyright: 2017-2023,2024 Thomas E. Dickey
+Copyright: 1998-2016,2017 Free Software Foundation, Inc.
+License: X11
 
 Files: aclocal.m4 package
-Copyright: 2003-2014,2015 by Thomas E. Dickey
-Licence: X11
+Copyright: 2003-2023,2024 by Thomas E. Dickey
+License: X11
 
     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 @@
 -------------------------------------------------------------------------------
 Files: install-sh
 Copyright:  1994 X Consortium
-Licence: X11
+License: X11
 
     Permission is hereby granted, free of charge, to any person obtaining a copy
     of this software and associated documentation files (the "Software"), to
diff --git a/test/package/debian-mingw/rules b/test/package/debian-mingw/rules
index dce21a1..152cd3c 100755
--- a/test/package/debian-mingw/rules
+++ b/test/package/debian-mingw/rules
@@ -1,5 +1,5 @@
 #!/usr/bin/make -f
-# MAde with the aid of dh_make, by Craig Small
+# Made with the aid of dh_make, by Craig Small
 # Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
 # Some lines taken from debmake, by Cristoph Lameter.
 
@@ -14,6 +14,8 @@
 CC_NORMAL = -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wconversion
 CC_STRICT = $(CC_NORMAL) -W -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-declarations -Wnested-externs -Wpointer-arith -Wwrite-strings -ansi -pedantic
 
+NCURSES_PKG = ncurses-examples
+
 TARGET    = i686-w64-mingw32
 MINGW_BIN = /usr/bin
 MINGW_TOP = /usr/$(TARGET)
@@ -39,6 +41,8 @@
 		--host=$(TARGET) \
 		--target=$(TARGET) \
 		--prefix=$(MINGW_TOP) \
+		--bindir=\$${prefix}/bin/$(NCURSES_PKG) \
+		--datadir=\$${prefix}/share/$(NCURSES_PKG) \
 		--with-screen=ncursesw6 \
 		--with-pkg-config-libdir=/usr/$(TARGET)/lib/pkgconfig
 
@@ -66,7 +70,7 @@
 install-stamp: build-stamp
 	dh_testdir
 	dh_testroot
-	dh_clean -k
+	dh_prep
 	dh_installdirs
 
 	$(MAKE) install DESTDIR=$(MINGW_TMP)
diff --git a/test/package/debian-mingw/watch b/test/package/debian-mingw/watch
index 1d08098..ec075b1 100644
--- a/test/package/debian-mingw/watch
+++ b/test/package/debian-mingw/watch
@@ -1,4 +1,4 @@
 version=3
 
-opts=passive ftp://invisible-island.net/ncurses-examples/ncurses-examples-([\d.]+)\.tgz \
+opts=passive ftp://ftp.invisible-island.net/ncurses-examples/ncurses-examples-([\d.]+)\.tgz \
  debian  uupdate
diff --git a/test/package/debian-mingw64/compat b/test/package/debian-mingw64/compat
index 7ed6ff8..48082f7 100644
--- a/test/package/debian-mingw64/compat
+++ b/test/package/debian-mingw64/compat
@@ -1 +1 @@
-5
+12
diff --git a/test/package/debian-mingw64/control b/test/package/debian-mingw64/control
index e7916d0..df942b7 100644
--- a/test/package/debian-mingw64/control
+++ b/test/package/debian-mingw64/control
@@ -2,14 +2,14 @@
 Maintainer: Thomas E. Dickey <dickey@invisible-island.net>
 Section: misc
 Priority: optional
-Standards-Version: 3.8.4
+Standards-Version: 4.6.1.0
 Build-Depends: debhelper (>= 5)
-Homepage: http://invisible-island.net/ncurses/ncurses-examples.html
+Homepage: https://invisible-island.net/ncurses/ncurses-examples.html
 
 Package: mingw64-ncurses-examples
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: ncurses-examples - example/test programs from ncurses
+Description: example/test programs from ncurses
  These are the example/test programs from the ncurses distribution.
  .
  This package is used for testing ABI 6 with the MinGW 64-bit port.
diff --git a/test/package/debian-mingw64/copyright b/test/package/debian-mingw64/copyright
index ea1fdff..7546e1c 100644
--- a/test/package/debian-mingw64/copyright
+++ b/test/package/debian-mingw64/copyright
@@ -1,15 +1,16 @@
-Upstream source http://invisible-island.net/ncurses/ncurses-examples.html
+Upstream source https://invisible-island.net/ncurses/ncurses-examples.html
 
 Current ncurses maintainer: Thomas Dickey <dickey@invisible-island.net>
 
 -------------------------------------------------------------------------------
 Files: *
-Copyright: 1998-2014,2015 Free Software Foundation, Inc.
-Licence: X11
+Copyright: 2017-2023,2024 Thomas E. Dickey
+Copyright: 1998-2016,2017 Free Software Foundation, Inc.
+License: X11
 
 Files: aclocal.m4 package
-Copyright: 2003-2014,2015 by Thomas E. Dickey
-Licence: X11
+Copyright: 2003-2023,2024 by Thomas E. Dickey
+License: X11
 
     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 @@
 -------------------------------------------------------------------------------
 Files: install-sh
 Copyright:  1994 X Consortium
-Licence: X11
+License: X11
 
     Permission is hereby granted, free of charge, to any person obtaining a copy
     of this software and associated documentation files (the "Software"), to
diff --git a/test/package/debian-mingw64/rules b/test/package/debian-mingw64/rules
index d0f17cd..02175a6 100755
--- a/test/package/debian-mingw64/rules
+++ b/test/package/debian-mingw64/rules
@@ -1,5 +1,5 @@
 #!/usr/bin/make -f
-# MAde with the aid of dh_make, by Craig Small
+# Made with the aid of dh_make, by Craig Small
 # Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
 # Some lines taken from debmake, by Cristoph Lameter.
 
@@ -14,6 +14,8 @@
 CC_NORMAL = -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wconversion
 CC_STRICT = $(CC_NORMAL) -W -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-declarations -Wnested-externs -Wpointer-arith -Wwrite-strings -ansi -pedantic
 
+NCURSES_PKG = ncurses-examples
+
 TARGET    = x86_64-w64-mingw32
 MINGW_BIN = /usr/bin
 MINGW_TOP = /usr/$(TARGET)
@@ -39,6 +41,8 @@
 		--host=$(TARGET) \
 		--target=$(TARGET) \
 		--prefix=$(MINGW_TOP) \
+		--bindir=\$${prefix}/bin/$(NCURSES_PKG) \
+		--datadir=\$${prefix}/share/$(NCURSES_PKG) \
 		--with-screen=ncursesw6 \
 		--with-pkg-config-libdir=/usr/$(TARGET)/lib/pkgconfig
 
@@ -66,7 +70,7 @@
 install-stamp: build-stamp
 	dh_testdir
 	dh_testroot
-	dh_clean -k
+	dh_prep
 	dh_installdirs
 
 	$(MAKE) install DESTDIR=$(MINGW_TMP)
diff --git a/test/package/debian-mingw64/watch b/test/package/debian-mingw64/watch
index 1d08098..ec075b1 100644
--- a/test/package/debian-mingw64/watch
+++ b/test/package/debian-mingw64/watch
@@ -1,4 +1,4 @@
 version=3
 
-opts=passive ftp://invisible-island.net/ncurses-examples/ncurses-examples-([\d.]+)\.tgz \
+opts=passive ftp://ftp.invisible-island.net/ncurses-examples/ncurses-examples-([\d.]+)\.tgz \
  debian  uupdate
diff --git a/test/package/debian/compat b/test/package/debian/compat
index 7ed6ff8..48082f7 100644
--- a/test/package/debian/compat
+++ b/test/package/debian/compat
@@ -1 +1 @@
-5
+12
diff --git a/test/package/debian/control b/test/package/debian/control
index f4cc43a..89de1b8 100644
--- a/test/package/debian/control
+++ b/test/package/debian/control
@@ -2,14 +2,14 @@
 Maintainer: Thomas E. Dickey <dickey@invisible-island.net>
 Section: misc
 Priority: optional
-Standards-Version: 3.8.4
+Standards-Version: 4.6.1.0
 Build-Depends: debhelper (>= 5)
-Homepage: http://invisible-island.net/ncurses/ncurses-examples.html
+Homepage: https://invisible-island.net/ncurses/ncurses-examples.html
 
 Package: ncurses-examples
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: ncurses-examples - example/test programs from ncurses
+Description: example/test programs from ncurses
  These are the example/test programs from the ncurses distribution.
  .
  This package installs in "bin/ncurses-examples" to avoid conflict with other
@@ -18,7 +18,7 @@
 Package: ncursest-examples
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: ncurses-examples - example/test programs from ncurses
+Description: example/test programs from ncurses
  These are the example/test programs from the ncurses distribution, using
  the thread configuration.
  .
diff --git a/test/package/debian/copyright b/test/package/debian/copyright
index ea1fdff..7546e1c 100644
--- a/test/package/debian/copyright
+++ b/test/package/debian/copyright
@@ -1,15 +1,16 @@
-Upstream source http://invisible-island.net/ncurses/ncurses-examples.html
+Upstream source https://invisible-island.net/ncurses/ncurses-examples.html
 
 Current ncurses maintainer: Thomas Dickey <dickey@invisible-island.net>
 
 -------------------------------------------------------------------------------
 Files: *
-Copyright: 1998-2014,2015 Free Software Foundation, Inc.
-Licence: X11
+Copyright: 2017-2023,2024 Thomas E. Dickey
+Copyright: 1998-2016,2017 Free Software Foundation, Inc.
+License: X11
 
 Files: aclocal.m4 package
-Copyright: 2003-2014,2015 by Thomas E. Dickey
-Licence: X11
+Copyright: 2003-2023,2024 by Thomas E. Dickey
+License: X11
 
     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 @@
 -------------------------------------------------------------------------------
 Files: install-sh
 Copyright:  1994 X Consortium
-Licence: X11
+License: X11
 
     Permission is hereby granted, free of charge, to any person obtaining a copy
     of this software and associated documentation files (the "Software"), to
diff --git a/test/package/debian/rules b/test/package/debian/rules
index bed7a82..2cc34f7 100755
--- a/test/package/debian/rules
+++ b/test/package/debian/rules
@@ -1,5 +1,5 @@
 #!/usr/bin/make -f
-# MAde with the aid of dh_make, by Craig Small
+# Made with the aid of dh_make, by Craig Small
 # Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
 # Some lines taken from debmake, by Cristoph Lameter.
 
@@ -18,7 +18,9 @@
 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
 
-CFLAGS =
+CFLAGS   = $(shell dpkg-buildflags --get CFLAGS)
+CPPFLAGS = $(shell dpkg-buildflags --get CPPFLAGS)
+LDFLAGS  = $(shell dpkg-buildflags --get LDFLAGS)
 
 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
         CFLAGS += -O0
@@ -32,7 +34,9 @@
 verbose = # -v
 
 configure = \
-	CFLAGS="$(CFLAGS)" ../../configure \
+	CFLAGS="$(CFLAGS)" \
+	CPPFLAGS="$(CPPFLAGS)" \
+	LDFLAGS="$(LDFLAGS)" ../../configure \
 		--host=$(DEB_HOST_GNU_TYPE) \
 		--build=$(DEB_BUILD_GNU_TYPE) \
 		--prefix=/usr \
@@ -70,7 +74,7 @@
 	mkdir -p t/ncurses6
 
 	cd t/ncurses6; $(configure) \
-		--bindir=\$${prefix}/bin/$(NCURSES_PKG) \
+		--datadir=\$${datarootdir}/$(NCURSES_PKG) \
 		--with-screen=ncursesw6
 
 	touch $@
@@ -82,7 +86,7 @@
 	mkdir -p t/ncursest6
 
 	cd t/ncursest6; $(configure) \
-		--bindir=\$${prefix}/bin/$(NCURSEST_PKG) \
+		--datadir=\$${datarootdir}/$(NCURSEST_PKG) \
 		--with-screen=ncursestw6
 
 	touch $@
@@ -107,7 +111,9 @@
 	dh_installdirs $(verbose)
 	dh_prep        $(verbose) -p$(NCURSES_PKG)
 
-	$(MAKE) -C t/ncurses6 install DESTDIR=$(CURDIR)/debian/$(NCURSES_PKG)
+	$(MAKE) -C t/ncurses6 install \
+		PACKAGE=$(NCURSES_PKG) \
+		DESTDIR=$(CURDIR)/debian/$(NCURSES_PKG)
 
 	touch $@
 
@@ -117,7 +123,9 @@
 	dh_installdirs $(verbose)
 	dh_prep        $(verbose) -p$(NCURSEST_PKG)
 
-	$(MAKE) -C t/ncursest6 install DESTDIR=$(CURDIR)/debian/$(NCURSEST_PKG)
+	$(MAKE) -C t/ncursest6 install \
+		PACKAGE=$(NCURSEST_PKG) \
+		DESTDIR=$(CURDIR)/debian/$(NCURSEST_PKG)
 
 	touch $@
 
@@ -145,6 +153,7 @@
 	rm -f $(PACKAGES.arch:%=install-%-stamp)
 	dh_testdir
 	dh_testroot
+	dh_installdocs       $(verbose) $(PACKAGES.arch:%=-p%)
 	dh_installchangelogs $(verbose) $(PACKAGES.arch:%=-p%)  NEWS
 	dh_strip             $(verbose) $(PACKAGES.arch:%=-p%)
 	dh_compress          $(verbose) $(PACKAGES.arch:%=-p%)
diff --git a/test/package/debian/watch b/test/package/debian/watch
index 1d08098..ec075b1 100644
--- a/test/package/debian/watch
+++ b/test/package/debian/watch
@@ -1,4 +1,4 @@
 version=3
 
-opts=passive ftp://invisible-island.net/ncurses-examples/ncurses-examples-([\d.]+)\.tgz \
+opts=passive ftp://ftp.invisible-island.net/ncurses-examples/ncurses-examples-([\d.]+)\.tgz \
  debian  uupdate
diff --git a/test/package/mingw-ncurses-examples.spec b/test/package/mingw-ncurses-examples.spec
index fdc2a69..bfadd10 100644
--- a/test/package/mingw-ncurses-examples.spec
+++ b/test/package/mingw-ncurses-examples.spec
@@ -1,17 +1,17 @@
 Summary: ncurses-examples - example/test programs from ncurses
 %?mingw_package_header
 
-%define AppProgram ncurses-examples
-%define AppVersion MAJOR.MINOR
-%define AppRelease YYYYMMDD
-# $Id: mingw-ncurses-examples.spec,v 1.3 2013/10/26 23:30:21 tom Exp $
+%global AppProgram ncurses-examples
+%global AppVersion MAJOR.MINOR
+%global AppRelease YYYYMMDD
+# $Id: mingw-ncurses-examples.spec,v 1.11 2023/02/25 23:10:34 tom Exp $
 Name: mingw32-ncurses6-examples
 Version: %{AppVersion}
 Release: %{AppRelease}
 License: X11
 Group: Development/Libraries
-Source: ncurses-examples-%{release}.tgz
-# URL: http://invisible-island.net/ncurses/
+URL: https://invisible-island.net/ncurses/%{AppProgram}.html
+Source: https://invisible-island.net/archives/%{AppProgram}/%{AppProgram}-%{release}.tgz
 
 BuildRequires:  mingw32-ncurses6
 
@@ -50,13 +50,20 @@
 %prep
 
 # override location of bindir, e.g., to avoid conflict with pdcurses
-%global mingw32_bindir %{mingw32_exec_prefix}/bin/%{AppProgram} 
-%global mingw64_bindir %{mingw64_exec_prefix}/bin/%{AppProgram} 
+%global mingw32_bindir %{mingw32_exec_prefix}/bin/%{AppProgram}
+%global mingw64_bindir %{mingw64_exec_prefix}/bin/%{AppProgram}
+
+%global mingw32_datadir %{mingw32_datadir}/%{AppProgram}
+%global mingw64_datadir %{mingw64_datadir}/%{AppProgram}
+
+%global mingw32_libexec %{mingw32_libexecdir}/%{AppProgram}
+%global mingw64_libexec %{mingw64_libexecdir}/%{AppProgram}
 
 %define CFG_OPTS \\\
-	--disable-echo \\\
-	--enable-warnings \\\
-	--verbose
+        --enable-echo \\\
+        --enable-warnings \\\
+        --verbose \\\
+        --with-screen=ncursesw6
 
 %define debug_package %{nil}
 %setup -q -n ncurses-examples-%{release}
@@ -66,8 +73,9 @@
 pushd BUILD-W32
 CFLAGS="%{CC_NORMAL}" \
 CC=%{mingw32_cc} \
-%mingw32_configure %{CFG_OPTS}
-cp config.status /tmp/ming32-config.status
+NCURSES_CONFIG_SUFFIX=dev \
+%mingw32_configure %{CFG_OPTS} \
+        --datadir=%{mingw32_datadir}
 make
 popd
 
@@ -75,8 +83,8 @@
 pushd BUILD-W64
 CFLAGS="%{CC_NORMAL}" \
 CC=%{mingw64_cc} \
-%mingw64_configure %{CFG_OPTS}
-cp config.status /tmp/ming64-config.status
+%mingw64_configure %{CFG_OPTS} \
+        --datadir=%{mingw32_datadir}
 make
 popd
 
@@ -91,19 +99,26 @@
 %{mingw64_make} install DESTDIR=$RPM_BUILD_ROOT
 popd
 
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%files
-%defattr(-,root,root,-)
-
 %files -n mingw32-ncurses6-examples
+%defattr(-,root,root,-)
 %{mingw32_bindir}/*
+%{mingw32_datadir}/*
+%{mingw32_libexec}/*
 
 %files -n mingw64-ncurses6-examples
+%defattr(-,root,root,-)
 %{mingw64_bindir}/*
+%{mingw64_datadir}/*
+%{mingw64_libexec}/*
 
 %changelog
 
+* Sat Feb 25 2023 Thomas Dickey
+- use libexecdir for programs rather than subdir of bindir
+- amend URLs per rpmlint
+
+* Sat Nov 16 2019 Thomas Dickey
+- modify clean-rule to work around Fedora NFS bugs.
+
 * Sat Oct 19 2013 Thomas E. Dickey
 - initial version
diff --git a/test/package/ncurses-examples.spec b/test/package/ncurses-examples.spec
index d552b81..8f1a3cb 100644
--- a/test/package/ncurses-examples.spec
+++ b/test/package/ncurses-examples.spec
@@ -1,55 +1,115 @@
-Summary: ncurses-examples - example/test programs from ncurses
-%define AppProgram ncurses-examples
-%define AppVersion MAJOR.MINOR
-%define AppRelease YYYYMMDD
-# $Id: ncurses-examples.spec,v 1.5 2015/04/25 10:55:22 tom Exp $
+Summary: example/test programs from ncurses
+%global AppProgram ncurses-examples
+%global AltProgram ncursest-examples
+%global AppVersion MAJOR.MINOR
+%global AppRelease YYYYMMDD
+# $Id: ncurses-examples.spec,v 1.22 2023/02/25 23:10:49 tom Exp $
 Name: %{AppProgram}
 Version: %{AppVersion}
 Release: %{AppRelease}
 License: MIT
 Group: Applications/Development
-URL: ftp://invisible-island.net/%{AppProgram}
-Source0: %{AppProgram}-%{AppRelease}.tgz
-Packager: Thomas Dickey <dickey@invisible-island.net>
+URL: https://invisible-island.net/ncurses/%{AppProgram}.html
+Source: https://invisible-island.net/archives/%{AppProgram}/%{AppProgram}-%{release}.tgz
 
 %description
 These are the example/test programs from the ncurses MAJOR.MINOR distribution,
 for patch-date YYYYMMDD.
 
-This package installs in "bin/ncurses-examples" to avoid conflict with other
+This package installs in "bin/%{AppProgram}" to avoid conflict with other
 packages.
+
+%package -n %{AltProgram}
+Summary:  examples/test programs from ncurses with POSIX thread support
+
+%description -n %{AltProgram}
+These are the example/test programs from the ncurses MAJOR.MINOR distribution,
+for patch-date YYYYMMDD, using the "ncurseswt" library to demonstrate the
+use of POSIX threads, e.g., in ditto, rain, and worm.
+
+This package installs in "bin/%{AltProgram}" to avoid conflict with other
+packages.
+
 %prep
 
 %setup -q -n %{AppProgram}-%{AppRelease}
 
+%define debug_package %{nil}
+
 %build
 
+%global _configure ../configure
+%define my_srcdir ..
+
+mkdir BUILD-%{AppProgram}
+pushd BUILD-%{AppProgram}
 INSTALL_PROGRAM='${INSTALL}' \
-	./configure \
-		--target %{_target_platform} \
-		--prefix=%{_prefix} \
-		--bindir=%{_bindir}/%{AppProgram} \
-		--with-screen=ncursesw6 \
-		--disable-rpath-hack
+NCURSES_CONFIG_SUFFIX=dev \
+CONFIGURE_TOP=%{my_srcdir} \
+%configure \
+	--target %{_target_platform} \
+	--prefix=%{_prefix} \
+	--datadir=%{_datarootdir}/%{AppProgram} \
+	--with-screen=ncursesw6dev \
+	--disable-rpath-hack
 
 make
+popd
+
+mkdir BUILD-%{AltProgram}
+pushd BUILD-%{AltProgram}
+INSTALL_PROGRAM='${INSTALL}' \
+NCURSES_CONFIG_SUFFIX=dev \
+CONFIGURE_TOP=%{my_srcdir} \
+%configure \
+	--target %{_target_platform} \
+	--prefix=%{_prefix} \
+	--datadir=%{_datarootdir}/%{AltProgram} \
+	--with-screen=ncursestw6dev \
+	--disable-rpath-hack
+
+make
+popd
 
 %install
 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
 
-make install               DESTDIR=$RPM_BUILD_ROOT
+pushd BUILD-%{AppProgram}
+make install PACKAGE=%{AppProgram} DESTDIR=$RPM_BUILD_ROOT
+popd
 
-strip $RPM_BUILD_ROOT%{_bindir}/%{AppProgram}/*
+pushd BUILD-%{AltProgram}
+make install PACKAGE=%{AltProgram} DESTDIR=$RPM_BUILD_ROOT
+popd
 
-%clean
-[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
-
-%files
+%files -n %{AppProgram}
 %defattr(-,root,root)
-%{_bindir}/%{AppProgram}/*
+%{_bindir}/%{AppProgram}
+%{_libexecdir}/%{AppProgram}/*
+%{_datarootdir}/%{AppProgram}/*
+
+%files -n %{AltProgram}
+%defattr(-,root,root)
+%{_bindir}/%{AltProgram}
+%{_libexecdir}/%{AltProgram}/*
+%{_datarootdir}/%{AltProgram}/*
 
 %changelog
 # each patch should add its ChangeLog entries here
 
+* Sat Feb 25 2023 Thomas Dickey
+- amend URLs per rpmlint
+
+* Sat Dec 18 2021 Thomas Dickey
+- use libexecdir for programs rather than subdir of bindir
+
+* Sat Nov 16 2019 Thomas Dickey
+- modify clean-rule to work around Fedora NFS bugs.
+
+* Sat Nov 11 2017 Thomas Dickey
+- add example data-files
+- use rpm built-in "configure"
+- suppress debug-package
+
 * Thu Mar 25 2010 Thomas Dickey
 - initial version
diff --git a/test/padview.c b/test/padview.c
new file mode 100644
index 0000000..0defee3
--- /dev/null
+++ b/test/padview.c
@@ -0,0 +1,550 @@
+/****************************************************************************
+ * Copyright 2019-2021,2022 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.                                                           *
+ ****************************************************************************/
+/*
+ * clone of view.c, using pads
+ *
+ * $Id: padview.c,v 1.22 2022/12/04 00:40:11 tom Exp $
+ */
+
+#include <test.priv.h>
+#include <widechars.h>
+#include <popup_msg.h>
+
+#include <sys/stat.h>
+#include <time.h>
+
+#if HAVE_NEWPAD
+
+static GCC_NORETURN void finish(int sig);
+
+#define my_pair 1
+
+static WINDOW *global_pad;
+static int shift = 0;
+static bool try_color = FALSE;
+
+static char *fname;
+static int num_lines;
+
+#if USE_WIDEC_SUPPORT
+static bool n_option = FALSE;
+#endif
+
+static void
+failed(const char *msg)
+{
+    endwin();
+    fprintf(stderr, "%s\n", msg);
+    ExitProgram(EXIT_FAILURE);
+}
+
+static void
+finish(int sig)
+{
+    endwin();
+    if (global_pad != NULL)
+	delwin(global_pad);
+    ExitProgram(sig != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
+}
+
+static void
+show_all(const char *tag, WINDOW *my_pad, int my_row)
+{
+    int i;
+    int digits;
+    char temp[BUFSIZ];
+    time_t this_time;
+
+    for (digits = 1, i = num_lines; i > 0; i /= 10) {
+	++digits;
+    }
+
+    wattrset(stdscr, COLOR_PAIR(my_pair));
+    clear();
+
+    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+		"view %.*s", (int) strlen(tag), tag);
+    i = (int) strlen(temp);
+    _nc_SPRINTF(temp + i, _nc_SLIMIT(sizeof(temp) - (size_t) i)
+		" %.*s", (int) sizeof(temp) - i - 2, fname);
+    mvprintw(0, 0, "%.*s", COLS, temp);
+    this_time = time((time_t *) 0);
+    _nc_STRNCPY(temp, ctime(&this_time), (size_t) 30);
+    if ((i = (int) strlen(temp)) != 0) {
+	temp[--i] = 0;
+	mvprintw(0, COLS - i - 2, "  %s", temp);
+    }
+
+    for (i = 1; i < LINES; i++) {
+	int actual = my_row + i;
+	if (actual > num_lines) {
+	    break;
+	}
+	mvprintw(i, 0, "%*d:", digits, actual);
+    }
+    wnoutrefresh(stdscr);
+    pnoutrefresh(my_pad, my_row, shift, 1, digits + 1, LINES - 1, COLS - 1);
+    doupdate();
+}
+
+static WINDOW *
+read_file(const char *filename)
+{
+    FILE *fp;
+    int pass;
+    int k;
+    int height, width;
+    size_t j;
+    size_t len;
+    struct stat sb;
+    char *my_blob;
+    char **my_vec = 0;
+    WINDOW *my_pad;
+
+    if (stat(filename, &sb) != 0
+	|| (sb.st_mode & S_IFMT) != S_IFREG) {
+	failed("input is not a file");
+    }
+
+    if (sb.st_size == 0) {
+	failed("input is empty");
+    }
+
+    if ((fp = fopen(filename, "r")) == 0) {
+	failed("cannot open input-file");
+    }
+
+    if ((my_blob = malloc((size_t) sb.st_size + 1)) == 0) {
+	failed("cannot allocate memory for input-file");
+    }
+
+    len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp);
+    fclose(fp);
+
+    if (len > (size_t) sb.st_size)
+	len = (size_t) sb.st_size;
+    my_blob[len] = '\0';
+
+    for (pass = 0; pass < 2; ++pass) {
+	char *base = my_blob;
+	k = 0;
+	for (j = 0; j < len; ++j) {
+	    if (my_blob[j] == '\n') {
+		if (pass) {
+		    my_vec[k] = base;
+		    my_blob[j] = '\0';
+		}
+		base = my_blob + j + 1;
+		++k;
+	    }
+	}
+	if (base != (my_blob + j)) {
+	    if (pass)
+		my_vec[k] = base;
+	    ++k;
+	}
+	num_lines = k;
+	if (pass == 0) {
+	    if (((my_vec = typeCalloc(char *, (size_t) k + 2)) == 0)) {
+		failed("cannot allocate line-vector #1");
+	    }
+	} else {
+	    if (my_vec[0] == NULL)
+		my_vec[0] = my_blob;
+	}
+    }
+
+#if USE_WIDEC_SUPPORT
+    if (!memcmp("\357\273\277", my_blob, 3)) {
+	char *s = my_blob + 3;
+	char *d = my_blob;
+	Trace(("trim BOM"));
+	do {
+	} while ((*d++ = *s++) != '\0');
+    }
+#endif
+
+    height = num_lines;
+    width = (int) strlen(my_vec[0]);
+    for (k = 1; my_vec[k]; ++k) {
+	int check = (int) (my_vec[k] - my_vec[k - 1]);
+	if (width < check)
+	    width = check;
+    }
+    width = (width + 1) * 5;
+    my_pad = newpad(height, width);
+    if (my_pad == 0)
+	failed("cannot allocate pad workspace");
+    if (try_color) {
+	wattrset(my_pad, COLOR_PAIR(my_pair));
+	wbkgd(my_pad, (chtype) (' ' | COLOR_PAIR(my_pair)));
+    }
+
+    /*
+     * Use the curses library for rendering, including tab-conversion.
+     */
+    Trace(("slurp the file"));
+    for (k = 0; my_vec[k]; ++k) {
+	char *s;
+#if USE_WIDEC_SUPPORT
+	char *last = my_vec[k] + (int) strlen(my_vec[k]);
+	wchar_t wch[2];
+	size_t rc;
+#ifndef state_unused
+	mbstate_t state;
+#endif
+#endif /* USE_WIDEC_SUPPORT */
+
+	wmove(my_pad, k, 0);
+#if USE_WIDEC_SUPPORT
+	wch[1] = 0;
+	reset_mbytes(state);
+#endif
+	for (s = my_vec[k]; *s != '\0'; ++s) {
+#if USE_WIDEC_SUPPORT
+	    if (!n_option) {
+		rc = (size_t) check_mbytes(wch[0], s, (size_t) (last - s), state);
+		if ((long) rc == -1 || (long) rc == -2) {
+		    break;
+		}
+		s += rc - 1;
+		waddwstr(my_pad, wch);
+	    } else
+#endif
+		waddch(my_pad, *s & 0xff);
+	}
+    }
+
+    free(my_vec);
+    free(my_blob);
+
+    return my_pad;
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: view [options] file"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -c       use color if terminal supports it"
+	," -i       ignore INT, QUIT, TERM signals"
+#if USE_WIDEC_SUPPORT
+	," -n       use waddch (bytes) rather then wadd_wch (wide-chars)"
+#endif
+	," -s       start in single-step mode, waiting for input"
+#ifdef TRACE
+	," -t       trace screen updates"
+	," -T NUM   specify trace mask"
+#endif
+    };
+    size_t n;
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    static const char *help[] =
+    {
+	"Commands:",
+	"  q,^Q,ESC       - quit this program",
+	"",
+	"  p,<Up>         - scroll the viewport up by one row",
+	"  n,<Down>       - scroll the viewport down by one row",
+	"  l,<Left>       - scroll the viewport left by one column",
+	"  r,<Right>      - scroll the viewport right by one column",
+	"  <,>            - scroll the viewport left/right by 8 columns",
+	"",
+	"  h,<Home>       - scroll the viewport to top of file",
+	"  ^F,<PageDn>    - scroll to the next page",
+	"  ^B,<PageUp>    - scroll to the previous page",
+	"  e,<End>        - scroll the viewport to end of file",
+	"",
+	"  ^L             - repaint using redrawwin()",
+	"",
+	"  0 through 9    - enter digits for count",
+	"  s              - use entered count for halfdelay() parameter",
+	"                 - if no entered count, stop nodelay()",
+	"  <space>        - begin nodelay()",
+	0
+    };
+
+    int ch;
+    int i;
+    int my_delay = 0;
+    WINDOW *my_pad;
+    int my_row = 0;
+    int value = 0;
+    bool done = FALSE;
+    bool got_number = FALSE;
+    bool ignore_sigs = FALSE;
+    bool single_step = FALSE;
+    const char *my_label = "Input";
+
+    setlocale(LC_ALL, "");
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "cinstT:")) != -1) {
+	switch (ch) {
+	case 'c':
+	    try_color = TRUE;
+	    break;
+	case 'i':
+	    ignore_sigs = TRUE;
+	    break;
+#if USE_WIDEC_SUPPORT
+	case 'n':
+	    n_option = TRUE;
+	    break;
+#endif
+	case 's':
+	    single_step = TRUE;
+	    break;
+#ifdef TRACE
+	case 'T':
+	    {
+		char *next = 0;
+		int tvalue = (int) strtol(optarg, &next, 0);
+		if (tvalue < 0 || (next != 0 && *next != 0))
+		    usage(FALSE);
+		curses_trace((unsigned) tvalue);
+	    }
+	    break;
+	case 't':
+	    curses_trace(TRACE_CALLS);
+	    break;
+#endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind + 1 != argc)
+	usage(FALSE);
+
+    InitAndCatch(initscr(), ignore_sigs ? SIG_IGN : finish);
+    keypad(stdscr, TRUE);	/* enable keyboard mapping */
+    (void) nonl();		/* tell curses not to do NL->CR/NL on output */
+    (void) cbreak();		/* take input chars one at a time, no wait for \n */
+    (void) noecho();		/* don't echo input */
+    if (!single_step)
+	nodelay(stdscr, TRUE);
+    idlok(stdscr, TRUE);	/* allow use of insert/delete line */
+
+    if (try_color) {
+	if (has_colors()) {
+	    start_color();
+	    init_pair(my_pair, COLOR_WHITE, COLOR_BLUE);
+	    bkgd((chtype) (' ' | COLOR_PAIR(my_pair)));
+	} else {
+	    try_color = FALSE;
+	}
+    }
+
+    /*
+     * Do this after starting color, otherwise the pad's background will be
+     * uncolored after the ncurses 6.1.20181208 fixes.
+     */
+    global_pad =
+	my_pad = read_file(fname = argv[optind]);
+
+    my_row = 0;
+    while (!done) {
+	int n, c;
+
+	if (!got_number)
+	    show_all(my_label, my_pad, my_row);
+
+	for (;;) {
+	    c = getch();
+	    if ((c < 127) && isdigit(c)) {
+		if (!got_number) {
+		    MvPrintw(0, 0, "Count: ");
+		    clrtoeol();
+		}
+		addch(UChar(c));
+		value = 10 * value + (c - '0');
+		got_number = TRUE;
+	    } else
+		break;
+	}
+	if (got_number && value) {
+	    n = value;
+	} else {
+	    n = 1;
+	}
+
+	if (c != ERR)
+	    my_label = keyname(c);
+	switch (c) {
+	case KEY_DOWN:
+	case 'n':
+	    for (i = 0; i < n; i++)
+		if (my_row < (num_lines - LINES + 1))
+		    my_row++;
+		else
+		    break;
+	    break;
+
+	case KEY_UP:
+	case 'p':
+	    for (i = 0; i < n; i++)
+		if (my_row > 0)
+		    my_row--;
+		else
+		    break;
+	    break;
+
+	case 'h':
+	    /* FALLTHRU */
+	case KEY_HOME:
+	    my_row = 0;
+	    break;
+
+	case '<':
+	    if ((shift -= 8) < 0)
+		shift = 0;
+	    break;
+	case '>':
+	    shift += 8;
+	    break;
+
+	case 'e':
+	    /* FALLTHRU */
+	case KEY_END:
+	    if (num_lines > LINES)
+		my_row = (num_lines - LINES + 1);
+	    else
+		my_row = (num_lines - 2);
+	    break;
+
+	case CTRL('F'):
+	    /* FALLTHRU */
+	case KEY_NPAGE:
+	    for (i = 0; i < n; i++) {
+		if (my_row < (num_lines - 5))
+		    my_row += (LINES - 1);
+		else
+		    my_row = (num_lines - 2);
+	    }
+	    break;
+
+	case CTRL('B'):
+	    /* FALLTHRU */
+	case KEY_PPAGE:
+	    for (i = 0; i < n; i++) {
+		if (my_row >= LINES)
+		    my_row -= (LINES - 1);
+		else
+		    my_row = 0;
+	    }
+	    break;
+
+	case 'r':
+	case KEY_RIGHT:
+	    shift += n;
+	    break;
+
+	case 'l':
+	case KEY_LEFT:
+	    shift -= n;
+	    if (shift < 0) {
+		shift = 0;
+		beep();
+	    }
+	    break;
+
+	case 'q':
+	case QUIT:
+	case ESCAPE:
+	    done = TRUE;
+	    break;
+
+#ifdef KEY_RESIZE
+	case KEY_RESIZE:	/* ignore this; ncurses will repaint */
+	    break;
+#endif
+	case 's':
+#if HAVE_HALFDELAY
+	    if (got_number) {
+		halfdelay(my_delay = n);
+	    } else {
+		nodelay(stdscr, FALSE);
+		my_delay = -1;
+	    }
+#else
+	    nodelay(stdscr, FALSE);
+	    my_delay = -1;
+#endif
+	    break;
+	case ' ':
+	    nodelay(stdscr, TRUE);
+	    my_delay = 0;
+	    break;
+	case CTRL('L'):
+	    redrawwin(stdscr);
+	    break;
+	case ERR:
+	    if (!my_delay)
+		napms(50);
+	    break;
+	case HELP_KEY_1:
+	    popup_msg(stdscr, help);
+	    break;
+	default:
+	    beep();
+	    break;
+	}
+	if (c >= KEY_MIN || (c > 0 && !isdigit(c))) {
+	    got_number = FALSE;
+	    value = 0;
+	}
+    }
+
+    finish(0);			/* we're done */
+}
+#else
+int
+main(void)
+{
+    printf("This program requires the curses pad functions\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
diff --git a/test/pair_content.c b/test/pair_content.c
new file mode 100644
index 0000000..2b759a8
--- /dev/null
+++ b/test/pair_content.c
@@ -0,0 +1,316 @@
+/****************************************************************************
+ * Copyright 2018-2022,2023 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: pair_content.c,v 1.22 2023/02/25 16:43:56 tom Exp $
+ */
+
+#define NEED_TIME_H
+#include <test.priv.h>
+
+#if USE_EXTENDED_COLOR
+typedef int my_color_t;
+#else
+typedef NCURSES_COLOR_T my_color_t;
+#endif
+
+typedef struct {
+    my_color_t fg;
+    my_color_t bg;
+} MYPAIR;
+
+static int f_opt;
+static int i_opt;
+static int l_opt;
+static int n_opt;
+static int p_opt;
+static int r_opt;
+static int s_opt;
+
+#if USE_EXTENDED_COLOR
+static int x_opt;
+#endif
+
+static MYPAIR *expected;
+
+static TimeType initial_time;
+static TimeType finish_time;
+
+static GCC_NORETURN void
+finish(int code)
+{
+    free(expected);
+    ExitProgram(code);
+}
+
+static void
+failed(const char *msg)
+{
+    printw("%s", msg);
+    getch();
+    endwin();
+    finish(EXIT_FAILURE);
+}
+
+#if USE_EXTENDED_COLOR
+static int
+InitPair(int pair, int fg, int bg)
+{
+    int rc;
+    if (x_opt) {
+	rc = init_extended_pair(pair, fg, bg);
+    } else {
+	rc = init_pair((NCURSES_PAIRS_T) pair,
+		       (NCURSES_COLOR_T) fg,
+		       (NCURSES_COLOR_T) bg);
+    }
+    return rc;
+}
+
+static int
+PairContent(int pair, int *fgp, int *bgp)
+{
+    int rc;
+    if (x_opt) {
+	rc = extended_pair_content(pair, fgp, bgp);
+    } else {
+	short fg, bg;
+	if ((rc = pair_content((short) pair, &fg, &bg)) == OK) {
+	    *fgp = fg;
+	    *bgp = bg;
+	}
+    }
+    return rc;
+}
+#else
+#define InitPair(pair,fg,bg)      init_pair((NCURSES_COLOR_T)pair,(NCURSES_COLOR_T)fg,(NCURSES_COLOR_T)bg)
+#define PairContent(pair,fgp,bgp) pair_content((NCURSES_PAIRS_T)pair,fgp,bgp)
+#endif
+
+static my_color_t
+random_color(void)
+{
+    return (my_color_t) (rand() % COLORS);
+}
+
+static void
+setup_test(void)
+{
+    setlocale(LC_ALL, "");
+    initscr();
+    cbreak();
+    noecho();
+    scrollok(stdscr, TRUE);
+    if (has_colors()) {
+	start_color();
+
+	if (!f_opt)
+	    f_opt = 1;
+	if (!l_opt)
+	    l_opt = COLOR_PAIRS;
+	if (l_opt <= 1)
+	    failed("color-pair limit must be greater than one");
+
+	if (!n_opt) {
+	    int pair;
+	    size_t need = (size_t) ((l_opt > COLOR_PAIRS)
+				    ? l_opt
+				    : COLOR_PAIRS) + 1;
+
+	    expected = typeCalloc(MYPAIR, need);
+	    if (s_opt) {
+		my_color_t fg;
+		my_color_t bg;
+		pair = f_opt;
+		for (fg = 0; fg < COLORS; ++fg) {
+		    for (bg = 0; bg < COLORS; ++bg) {
+			if (pair < l_opt) {
+			    InitPair(pair, fg, bg);
+			    expected[pair].fg = (my_color_t) fg;
+			    expected[pair].bg = (my_color_t) bg;
+			    ++pair;
+			} else {
+			    break;
+			}
+		    }
+		}
+	    } else {
+		for (pair = f_opt; pair < l_opt; ++pair) {
+		    expected[pair].fg = random_color();
+		    expected[pair].bg = random_color();
+		    InitPair(pair, expected[pair].fg, expected[pair].bg);
+		}
+	    }
+	}
+    } else {
+	failed("This demo requires a color terminal");
+    }
+    GetClockTime(&initial_time);
+}
+
+static void
+run_test(void)
+{
+    int pair;
+    bool success = TRUE;
+    for (pair = 1; pair < l_opt; ++pair) {
+	my_color_t fg;
+	my_color_t bg;
+	if (PairContent(pair, &fg, &bg) == OK) {
+	    if (expected != 0) {
+		if (fg != expected[pair].fg)
+		    success = FALSE;
+		if (bg != expected[pair].bg)
+		    success = FALSE;
+	    }
+	}
+    }
+    if (i_opt) {
+	addch(success ? '.' : '?');
+	refresh();
+    }
+}
+
+static void
+finish_test(void)
+{
+    getch();
+    endwin();
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: pair_content [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -f PAIR  first color pair to test (default: 1)"
+	," -i       interactive, showing test-progress"
+	," -l PAIR  last color pair to test (default: max_pairs-1)"
+	," -n       do not initialize color pairs"
+	," -p       print data for color pairs instead of testing"
+	," -r COUNT repeat for given count"
+	," -s       initialize pairs sequentially rather than random"
+#if USE_EXTENDED_COLOR
+	," -x       use extended color pairs/values"
+#endif
+    };
+    size_t n;
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "f:il:npr:sx")) != -1) {
+	switch (ch) {
+	case 'f':
+	    if ((f_opt = atoi(optarg)) <= 0)
+		usage(FALSE);
+	    break;
+	case 'i':
+	    i_opt = 1;
+	    break;
+	case 'l':
+	    if ((l_opt = atoi(optarg)) <= 0)
+		usage(FALSE);
+	    break;
+	case 'n':
+	    n_opt = 1;
+	    break;
+	case 'p':
+	    p_opt = 1;
+	    break;
+	case 'r':
+	    if ((r_opt = atoi(optarg)) <= 0)
+		usage(FALSE);
+	    break;
+	case 's':
+	    s_opt = 1;
+	    break;
+#if USE_EXTENDED_COLOR
+	case 'x':
+	    x_opt = 1;
+	    break;
+#endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+    if (r_opt <= 0)
+	r_opt = 1;
+
+    setup_test();
+    if (p_opt) {
+	int i;
+	endwin();
+	for (i = f_opt; i < l_opt; ++i) {
+	    my_color_t fg, bg;
+	    if (PairContent(i, &fg, &bg) == OK) {
+		printf("%d: %d %d\n", i, fg, bg);
+	    } else {
+		printf("%d: ? ?\n", i);
+	    }
+	}
+    } else {
+	int repeat;
+
+	for (repeat = 0; repeat < r_opt; ++repeat) {
+	    run_test();
+	    if (i_opt) {
+		addch('.');
+		refresh();
+	    }
+	}
+
+	if (i_opt) {
+	    addch('\n');
+	}
+	printw("DONE: ");
+	GetClockTime(&finish_time);
+	printw("%.03f seconds", ElapsedSeconds(&initial_time, &finish_time));
+	finish_test();
+    }
+
+    finish(EXIT_SUCCESS);
+}
diff --git a/test/parse_rgb.h b/test/parse_rgb.h
new file mode 100644
index 0000000..df315b5
--- /dev/null
+++ b/test/parse_rgb.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+ * Copyright 2018,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: parse_rgb.h,v 1.5 2020/02/02 23:34:34 tom Exp $
+ *
+ * Sample implementation of ncurses RGB extension from user_caps(5).
+ */
+#ifndef PARSE_RBG_H_incl
+#define PARSE_RBG_H_incl 1
+
+#include <test.priv.h>
+
+#if HAVE_TIGETSTR && USE_WIDEC_SUPPORT
+static int
+parse_rgb(int *r_max, int *g_max, int *b_max)
+{
+    int colors = tigetnum("colors");
+    int result = ERR;
+
+    *r_max = *g_max = *b_max = 0;
+
+    if (colors > 0) {
+	int max_bits;
+	int bits;
+	int pwr2;
+	int r = 0, g = 0, b = 0;
+	char *data;
+	char ch;
+
+	for (max_bits = 0, pwr2 = 1;
+	     pwr2 < colors;
+	     ++max_bits, pwr2 <<= 1) {
+	    ;
+	}
+
+	if (tigetflag("RGB") > 0) {
+	    result = OK;
+	    r = g = b = (max_bits + 2) / 3;
+	} else if ((bits = tigetnum("RGB")) > 0) {
+	    result = OK;
+	    r = g = b = bits;
+	} else if ((data = tigetstr("RGB")) != ABSENT_STRING
+		   && data != CANCELLED_STRING
+		   && sscanf(data, "%d/%d/%d%c", &r, &g, &b, &ch) == 3) {
+	    result = OK;
+	}
+
+	if ((r + g + b) < max_bits) {
+	    result = ERR;
+	} else if (result == 0) {
+	    if (r > max_bits) {
+		r = max_bits;
+		g = b = 0;
+	    }
+	    *r_max = r;
+	    if (g > (max_bits -= r)) {
+		g = max_bits;
+		b = 0;
+	    }
+	    *g_max = g;
+	    if (b > (max_bits -= g)) {
+		b = max_bits;
+	    }
+	    *b_max = b;
+	}
+    }
+    return result;
+}
+#else
+#define parse_rgb(r,g,b) (ERR)
+#endif
+
+#endif /* PARSE_RBG_H_incl */
diff --git a/test/picsmap.c b/test/picsmap.c
new file mode 100644
index 0000000..b582f3a
--- /dev/null
+++ b/test/picsmap.c
@@ -0,0 +1,1835 @@
+/****************************************************************************
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 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"), 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: picsmap.c,v 1.149 2023/04/23 23:20:37 tom Exp $
+ *
+ * Author: Thomas E. Dickey
+ *
+ * A little more interesting than "dots", read a simple image into memory and
+ * measure the time taken to paint it normally vs randomly.
+ *
+ * TODO improve use of rgb-names using tsearch.
+ *
+ * TODO add option to dump picture in non-optimized mode, e.g., like tput.
+ * TODO write cells/second to stderr (or log)
+ * TODO write picture left-to-right/top-to-bottom
+ * TODO write picture randomly
+ * TODO add one-shot option vs repeat-count before exiting
+ * TODO add option "-xc" for init_color vs init_extended_color
+ * TODO add option "-xa" for init_pair vs alloc_pair
+ * TODO use pad to allow pictures larger than screen
+ * TODO add option to just use convert (which can scale) vs builtin xbm/xpm.
+ * TODO add scr_dump and scr_restore calls
+ * TODO add option for assume_default_colors
+ */
+#include <test.priv.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if HAVE_TSEARCH
+#include <search.h>
+#endif
+
+#undef CUR			/* use only the curses interface */
+
+#define  L_BLOCK '['
+#define  R_BLOCK ']'
+
+#define  L_CURLY '{'
+#define  R_CURLY '}'
+
+#define MaxSCALE	1000	/* input curses ranges 0..1000 */
+#define MaxRGB		255	/* output color ranges 0..255 */
+#define okCOLOR(n)	((n) >= 0 && (n) < COLORS)
+#define okSCALE(n)	((n) >= 0 && (n) <= MaxSCALE)
+#define Scaled256(n)	(NCURSES_COLOR_T) (int)(((double)(n) * MaxSCALE) / 255)
+#define ScaledColor(n)	(NCURSES_COLOR_T) (int)(((double)(n) * MaxSCALE) / scale)
+
+#ifndef RGB_PATH
+#define RGB_PATH "/etc/X11/rgb.txt"
+#endif
+
+#include <picsmap.h>
+
+typedef struct {
+    size_t file;
+    size_t name;
+    size_t list;
+    size_t data;
+    size_t head;
+    size_t pair;
+    size_t cell;
+} HOW_MUCH;
+
+#undef MAX
+#define MAX(a,b) ((a)>(b)?(a):(b))
+
+/*
+ * tfind will return null on failure, so we map subscripts starting at one.
+ */
+#define P2I(n) (((int)(my_intptr_t)(n)) - 1)
+#define I2P(n) (void *)(my_intptr_t)((n) + 1)
+
+#define pause_curses() if (in_curses) stop_curses()
+
+#define debugmsg if (debugging) logmsg
+#define debugmsg2 if (debugging) logmsg2
+
+static GCC_NORETURN void cleanup(int);
+static void giveup(const char *fmt, ...) GCC_PRINTFLIKE(1, 2);
+static void logmsg(const char *fmt, ...) GCC_PRINTFLIKE(1, 2);
+static void logmsg2(const char *fmt, ...) GCC_PRINTFLIKE(1, 2);
+static void warning(const char *fmt, ...) GCC_PRINTFLIKE(1, 2);
+static int gather_c_values(int);
+
+static FILE *logfp = 0;
+static double aspect_ratio = 0.6;
+static bool in_curses = FALSE;
+static bool debugging = FALSE;
+static bool quiet = FALSE;
+static int slow_time = -1;
+static RGB_NAME *rgb_table;
+static RGB_DATA *all_colors;
+static HOW_MUCH how_much;
+
+static int reading_last;
+static int reading_size;
+static FG_NODE *reading_ncols;
+
+#if HAVE_TSEARCH
+static void *reading_ntree;
+#endif
+
+#if HAVE_ALLOC_PAIR && USE_EXTENDED_COLOR
+#define USE_EXTENDED_COLORS 1
+static bool use_extended_pairs = FALSE;
+static bool use_extended_colors = FALSE;
+#else
+#define USE_EXTENDED_COLORS 0
+#endif
+
+static void
+logmsg(const char *fmt, ...)
+{
+    if (logfp != 0) {
+	va_list ap;
+	va_start(ap, fmt);
+	vfprintf(logfp, fmt, ap);
+	va_end(ap);
+	fputc('\n', logfp);
+	fflush(logfp);
+    }
+}
+
+static void
+logmsg2(const char *fmt, ...)
+{
+    if (logfp != 0) {
+	va_list ap;
+	va_start(ap, fmt);
+	vfprintf(logfp, fmt, ap);
+	va_end(ap);
+	fflush(logfp);
+    }
+}
+
+static void
+close_log(void)
+{
+    if (logfp != 0) {
+	logmsg("Allocations:");
+	logmsg("%8ld file", (long) how_much.file);
+	logmsg("%8ld name", (long) how_much.name);
+	logmsg("%8ld list", (long) how_much.list);
+	logmsg("%8ld data", (long) how_much.data);
+	logmsg("%8ld head", (long) how_much.head);
+	logmsg("%8ld pair", (long) how_much.pair);
+	logmsg("%8ld cell", (long) how_much.cell);
+	logmsg("%8ld window", LINES * COLS * (long) sizeof(NCURSES_CH_T));
+	fclose(logfp);
+	logfp = 0;
+    }
+}
+
+static void
+cleanup(int code)
+{
+    pause_curses();
+    close_log();
+    ExitProgram(code);
+    /* NOTREACHED */
+}
+
+static void
+failed(const char *msg)
+{
+    int save = errno;
+    perror(msg);
+    logmsg("failed with %s", strerror(save));
+    cleanup(EXIT_FAILURE);
+}
+
+static void
+warning(const char *fmt, ...)
+{
+    if (logfp != 0) {
+	va_list ap;
+	va_start(ap, fmt);
+	vfprintf(logfp, fmt, ap);
+	va_end(ap);
+	fputc('\n', logfp);
+	fflush(logfp);
+    } else {
+	va_list ap;
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	fputc('\n', stderr);
+	cleanup(EXIT_FAILURE);
+    }
+}
+
+static void
+free_data(char **data)
+{
+    if (data != 0) {
+	free(data[0]);
+	free(data);
+    }
+}
+
+static PICS_HEAD *
+free_pics_head(PICS_HEAD * pics)
+{
+    if (pics != 0) {
+	free(pics->fgcol);
+	free(pics->cells);
+	free(pics->name);
+	free(pics);
+	pics = 0;
+    }
+    return pics;
+}
+
+static void
+begin_c_values(int size)
+{
+    reading_last = 0;
+    reading_size = size;
+    reading_ncols = typeCalloc(FG_NODE, size + 1);
+    how_much.pair += (sizeof(FG_NODE) * (size_t) size);
+    /* black is always the first slot, to work around P2I/I2P logic */
+    gather_c_values(0);
+}
+
+#if HAVE_TSEARCH
+static int
+compare_c_values(const void *p, const void *q)
+{
+    const int a = P2I(p);
+    const int b = P2I(q);
+    return (reading_ncols[a].fgcol - reading_ncols[b].fgcol);
+}
+
+#ifdef DEBUG_TSEARCH
+static void
+check_c_values(int ln)
+{
+    static int oops = 5;
+    FG_NODE **ft;
+    int n;
+    for (n = 0; n < reading_last; ++n) {
+	ft = tfind(I2P(n), &reading_ntree, compare_c_values);
+	if (ft != 0) {
+	    int q = P2I(*ft);
+	    if (reading_ncols[q].fgcol != reading_ncols[n].fgcol) {
+		logmsg("@%d, %d:%d (%d) %d %d fgcol %06X %06X", ln, n,
+		       reading_last - 1,
+		       reading_size,
+		       q, n,
+		       reading_ncols[n].fgcol,
+		       reading_ncols[q].fgcol);
+	    }
+	} else {
+	    logmsg("@%d, %d:%d (%d) ? %d null %06X", ln, n,
+		   reading_last - 1,
+		   reading_size,
+		   n,
+		   reading_ncols[n].fgcol);
+	    if (oops-- <= 0)
+		return;
+	}
+    }
+}
+#else
+#define check_c_values(n)	/* nothing */
+#endif
+#endif
+
+static int
+gather_c_values(int fg)
+{
+    int found = -1;
+#if HAVE_TSEARCH
+    FG_NODE **ft;
+    int next = reading_last;
+
+    reading_ncols[next].fgcol = fg;
+    reading_ncols[next].count = 0;
+
+    check_c_values(__LINE__);
+    if ((ft = tfind(I2P(next), &reading_ntree, compare_c_values)) != 0) {
+	found = P2I(*ft);
+    } else {
+	if (reading_last + 2 >= reading_size) {
+	    int more = ((MAX(reading_last, reading_size) + 2) * 3) / 2;
+	    int last = reading_last + 1;
+	    FG_NODE *p = typeRealloc(FG_NODE, more, reading_ncols);
+	    if (p == 0)
+		goto done;
+
+	    reading_size = more;
+	    reading_ncols = p;
+	    memset(reading_ncols + last, 0,
+		   sizeof(FG_NODE) * (size_t) (more - last));
+	    check_c_values(__LINE__);
+	}
+	++reading_last;
+	how_much.pair += sizeof(FG_NODE);
+	if ((ft = tsearch(I2P(next), &reading_ntree, compare_c_values)) != 0) {
+	    found = P2I(*ft);
+	    if (found != next)
+		logmsg("OOPS expected slot %d, got %d", next, found);
+	    debugmsg("allocated color #%d as #%06X", next, fg);
+	    check_c_values(__LINE__);
+	}
+    }
+#else
+    int n;
+
+    for (n = 0; n < reading_last; ++n) {
+	if (reading_ncols[n].fgcol == fg) {
+	    found = n;
+	    break;
+	}
+    }
+    if (found < 0) {
+	if (reading_last + 2 >= reading_size) {
+	    int more = ((reading_last + 2) * 3) / 2;
+	    FG_NODE *p = typeRealloc(FG_NODE, more, reading_ncols);
+	    if (p == 0)
+		goto done;
+
+	    how_much.pair -= (sizeof(FG_NODE) * (size_t) reading_size);
+	    how_much.pair += (sizeof(FG_NODE) * (size_t) more);
+	    reading_size = more;
+	    reading_ncols = p;
+	    memset(reading_ncols + reading_last, 0,
+		   sizeof(FG_NODE) * (size_t) (more - reading_last));
+	}
+	reading_ncols[reading_last].fgcol = fg;
+	found = reading_last++;
+    }
+#endif
+  done:
+    return found;
+}
+
+static void
+finish_c_values(PICS_HEAD * head)
+{
+    head->colors = reading_last;
+    head->fgcol = reading_ncols;
+
+    reading_last = 0;
+    reading_size = 0;
+    reading_ncols = 0;
+}
+
+static void
+dispose_c_values(void)
+{
+#if HAVE_TSEARCH
+    if (reading_ntree != 0) {
+	int n;
+	for (n = 0; n < reading_last; ++n) {
+	    tdelete(I2P(n), &reading_ntree, compare_c_values);
+	}
+	reading_ntree = 0;
+    }
+#endif
+    if (reading_ncols != 0) {
+	free(reading_ncols);
+	reading_ncols = 0;
+    }
+    reading_last = 0;
+    reading_size = 0;
+}
+
+static int
+is_file(const char *filename, struct stat *sb)
+{
+    int result = 0;
+    if (stat(filename, sb) == 0
+	&& (sb->st_mode & S_IFMT) == S_IFREG
+	&& sb->st_size != 0) {
+	result = 1;
+    }
+    debugmsg("is_file(%s) %d", filename, result);
+    return result;
+}
+
+/*
+ * Simplify reading xbm/xpm files by first making an array of lines.  Blank
+ * lines are filtered out.
+ */
+static char **
+read_file(const char *filename)
+{
+    char **result = 0;
+    struct stat sb;
+
+    if (!quiet) {
+	pause_curses();
+	printf("** %s\n", filename);
+    }
+
+    if (is_file(filename, &sb)) {
+	size_t size = (size_t) sb.st_size;
+	char *blob = typeCalloc(char, size + 1);
+	bool binary = FALSE;
+	unsigned k = 0;
+
+	result = typeCalloc(char *, size + 1);
+	how_much.file += ((size + 1) * 2);
+
+	if (blob != 0 && result != 0) {
+	    FILE *fp = fopen(filename, "r");
+	    if (fp != 0) {
+		logmsg("opened %s", filename);
+
+		if (fread(blob, sizeof(char), size, fp) == size) {
+		    bool had_line = TRUE;
+		    unsigned j;
+
+		    for (j = 0; (size_t) j < size; ++j) {
+			if (blob[j] == '\0' ||
+			    (UChar(blob[j]) < 32 &&
+			     !isspace(UChar(blob[j]))) ||
+			    (UChar(blob[j]) >= 128 && UChar(blob[j]) < 160)) {
+			    binary = TRUE;
+			}
+			if (blob[j] == '\n') {
+			    blob[j] = '\0';
+			    if (k && !binary) {
+				debugmsg2("[%5d] %s\n", k, result[k - 1]);
+			    }
+			    had_line = TRUE;
+			} else if (had_line) {
+			    had_line = FALSE;
+			    result[k++] = blob + j;
+			}
+		    }
+		    result[k] = 0;
+		    if (k && !binary) {
+			debugmsg2("[%5d] %s\n", k, result[k - 1]);
+		    }
+		}
+		fclose(fp);
+	    } else {
+		logmsg("cannot open %s", filename);
+	    }
+	}
+	if (k == 0) {
+	    debugmsg("...file is empty");
+	    free(blob);
+	    free(result);
+	    result = 0;
+	} else if (binary) {
+	    debugmsg("...file is non-text");
+	}
+    }
+    return result;
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: picsmap [options] [imagefile [...]]"
+	,"Read/display one or more xbm/xpm files (possibly use \"convert\")"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -a ratio aspect-ratio correction for ImageMagick"
+#if HAVE_USE_DEFAULT_COLORS
+	," -d       invoke use_default_colors"
+#endif
+	," -L       add debugging information to logfile"
+	," -l FILE  write informational messages to FILE"
+	," -p FILE  color-palette file (default \"$TERM.dat\")"
+	," -q       less verbose"
+	," -r FILE  xpm uses X rgb color-names in FILE (default \"" RGB_PATH "\")"
+	," -s SECS  pause for SECS seconds after display vs getch"
+#if USE_EXTENDED_COLORS
+	," -x [pc]  use extension (p=extended-pairs, c=extended-colors)"
+	,"          Either/both extension may be given"
+#endif
+    };
+    size_t n;
+
+    pause_curses();
+
+    fflush(stdout);
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+    cleanup(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+
+static void
+giveup(const char *fmt, ...)
+{
+    va_list ap;
+
+    pause_curses();
+    fflush(stdout);
+
+    va_start(ap, fmt);
+    vfprintf(stderr, fmt, ap);
+    fputc('\n', stderr);
+    va_end(ap);
+
+    if (logfp) {
+	va_start(ap, fmt);
+	vfprintf(logfp, fmt, ap);
+	fputc('\n', logfp);
+	va_end(ap);
+	fflush(logfp);
+    }
+
+    usage(FALSE);
+}
+
+/*
+ * Palette files are named for $TERM values.  However, there are fewer palette
+ * files than $TERM's.  Although there are known problems (some cannot even get
+ * black and white correct), for the purpose of comparison, pretending that
+ * those map into "xterm" is useful.
+ */
+static char **
+read_palette(const char *filename)
+{
+    static const char *data_dir = DATA_DIR;
+    char **result = 0;
+    size_t last = strlen(filename);
+    size_t need = (strlen(data_dir) + 20 + last);
+    char *full_name = malloc(need);
+    char *s;
+    struct stat sb;
+
+    if (full_name != 0) {
+	int tries;
+	for (tries = 0; tries < 8; ++tries) {
+
+	    *(s = full_name) = '\0';
+	    if (tries & 1) {
+		if (strchr(filename, '/') == 0) {
+		    _nc_SPRINTF(full_name, _nc_SLIMIT(need) "%s/", data_dir);
+		} else {
+		    continue;
+		}
+	    }
+	    s += strlen(s);
+	    if (((size_t) (s - full_name) + last + 1) >= need)
+		continue;
+
+	    _nc_STRCAT(full_name, filename, need);
+	    if (tries & 4) {
+		char *t = s;
+		char *tc;
+		int num;
+		char chr;
+		int found = 0;
+		while (*t != '\0') {
+		    if (*t == '-') {
+			if (sscanf(t, "-%d%c", &num, &chr) == 2 &&
+			    chr == 'c' &&
+			    (tc = strchr(t, chr)) != 0 &&
+			    !(strncmp) (tc, "color", 5)) {
+			    found = 1;
+			}
+			break;
+		    }
+		    ++t;
+		}
+		if (found && (t != s)
+		    && (strncmp) (s, "xterm", (size_t) (t - s))) {
+		    _nc_SPRINTF(s, _nc_SLIMIT(need - (size_t) (s - full_name))
+				"xterm%s", filename + (t - s));
+		} else {
+		    continue;
+		}
+	    }
+
+	    if (tries & 2) {
+		int len = (int) strlen(filename);
+		if (len <= 4 || strcmp(filename + len - 4, ".dat")) {
+		    _nc_STRCAT(full_name, ".dat", need);
+		} else {
+		    continue;
+		}
+	    }
+	    if (is_file(full_name, &sb))
+		goto ok;
+	}
+	goto failed;
+      ok:
+	result = read_file(full_name);
+      failed:
+	free(full_name);
+    }
+    return result;
+}
+
+static void
+init_palette(const char *palette_file)
+{
+    if (palette_file != 0) {
+	char **data = read_palette(palette_file);
+
+	all_colors = typeMalloc(RGB_DATA, (unsigned) COLORS);
+	how_much.data += (sizeof(RGB_DATA) * (unsigned) COLORS);
+
+#if HAVE_COLOR_CONTENT
+	{
+	    int cp;
+	    for (cp = 0; cp < COLORS; ++cp) {
+		color_content((short) cp,
+			      &all_colors[cp].red,
+			      &all_colors[cp].green,
+			      &all_colors[cp].blue);
+	    }
+	}
+#else
+	memset(all_colors, 0, sizeof(RGB_DATA) * (size_t) COLORS);
+#endif
+	if (data != 0) {
+	    int n;
+	    int red, green, blue;
+	    int scale = MaxSCALE;
+	    int c;
+	    for (n = 0; data[n] != 0; ++n) {
+		if (sscanf(data[n], "scale:%d", &c) == 1) {
+		    scale = c;
+		} else if (sscanf(data[n], "%d:%d %d %d",
+				  &c,
+				  &red,
+				  &green,
+				  &blue) == 4
+			   && okCOLOR(c)
+			   && okSCALE(red)
+			   && okSCALE(green)
+			   && okSCALE(blue)) {
+		    /* *INDENT-EQLS* */
+		    all_colors[c].red   = ScaledColor(red);
+		    all_colors[c].green = ScaledColor(green);
+		    all_colors[c].blue  = ScaledColor(blue);
+		}
+	    }
+	}
+	free_data(data);
+	/* *INDENT-EQLS* */
+    } else if (COLORS > 1) {
+	int power2 = 1;
+	int shift = 0;
+
+	while (power2 < COLORS) {
+	    ++shift;
+	    power2 <<= 1;
+	}
+
+	if ((power2 != COLORS) || ((shift % 3) != 0)) {
+	    if (all_colors == 0) {
+		init_palette(getenv("TERM"));
+		if (all_colors == 0) {
+		    giveup("With %d colors, you need a palette-file", COLORS);
+		}
+	    }
+	}
+    }
+}
+
+/*
+ * Map the 24-bit RGB value to a color index if using a palette, otherwise to a
+ * direct color value.
+ */
+static int
+map_color(int value)
+{
+    int result = value;
+
+    if (result < 0) {
+	result = -1;
+    } else {
+	/* *INDENT-EQLS* */
+	int red   = (value & 0xff0000) >> 16;
+	int green = (value & 0x00ff00) >> 8;
+	int blue  = (value & 0x0000ff) >> 0;
+
+	if (all_colors != 0) {
+#define Diff2(n,m) ((m) - all_colors[n].m) * ((m) - all_colors[n].m)
+#define Diff2S(n) Diff2(n,red) + Diff2(n,green) + Diff2(n,blue)
+	    int d2 = Diff2S(0);
+	    int n;
+
+	    /* *INDENT-EQLS* */
+	    red   = Scaled256(red);
+	    green = Scaled256(green);
+	    blue  = Scaled256(blue);
+
+	    for (result = 0, n = 1; n < COLORS; ++n) {
+		int d = Diff2(n, red) + Diff2(n, green) + Diff2(n, blue);
+		if (d < d2) {
+		    d2 = d;
+		    result = n;
+		}
+	    }
+	} else {		/* direct color */
+	    int power2 = 1;
+	    int shifts = 8;
+
+	    while (power2 < COLORS) {
+		power2 <<= 3;
+		shifts--;
+	    }
+
+	    if (shifts > 0) {
+		/* TODO: round up */
+		red >>= shifts;
+		green >>= shifts;
+		blue >>= shifts;
+		result = ((red << (2 * (8 - shifts)))
+			  + (green << (8 - shifts))
+			  + blue);
+	    }
+	}
+    }
+    return result;
+}
+
+static int
+bytes_of(int value)
+{
+    if (value & 7) {
+	value |= 7;
+	value++;
+    }
+    return value;
+}
+
+static int match_c(const char *, const char *, ...) GCC_SCANFLIKE(2,3);
+
+static char *
+skip_s(char *s)
+{
+    while (isspace(UChar(*s)))
+	s++;
+    return s;
+}
+
+static const char *
+skip_cs(const char *s)
+{
+    while (isspace(UChar(*s)))
+	s++;
+    return s;
+}
+
+static char *
+skip_word(char *s)
+{
+    s = skip_s(s);
+    while (isgraph(UChar(*s)))
+	s++;
+    return s;
+}
+
+static int
+match_c(const char *source, const char *pattern, ...)
+{
+    int limit = (int) strlen(source);
+    const char *last_s = source + limit;
+    va_list ap;
+    int ch;
+    int *ip;
+    char *cp;
+    float *fp;
+    long lv;
+
+    va_start(ap, pattern);
+
+    limit = -1;
+    while (*pattern != '\0') {
+	ch = UChar(*pattern++);
+	/* blank in the pattern matches zero-or-more blanks in source */
+	if (isspace(ch)) {
+	    source = skip_cs(source);
+	    continue;
+	}
+	/* %c, %d, %s are like sscanf except for special treatment of blanks */
+	if (ch == '%' && *pattern != '\0' && strchr("%cdnfsx", *pattern)) {
+	    bool found = FALSE;
+	    ch = *pattern++;
+	    switch (ch) {
+	    case '%':
+		source++;
+		break;
+	    case 'c':
+		cp = va_arg(ap, char *);
+		do {
+		    *cp++ = *source++;
+		} while (--limit > 0);
+		break;
+	    case 'd':
+	    case 'x':
+		limit = -1;
+		ip = va_arg(ap, int *);
+		lv = strtol(source, &cp, ch == 'd' ? 10 : 16);
+		if (cp != 0 && cp != source) {
+		    *ip = (int) lv;
+		    source = cp;
+		} else {
+		    goto finish;
+		}
+		break;
+	    case 'f':
+		/* floating point for pixels... */
+		fp = va_arg(ap, float *);
+		lv = strtol(source, &cp, 10);
+		if (cp == 0 || cp == source)
+		    goto finish;
+		*fp = (float) lv;
+		source = cp;
+		if (*source == '.') {
+		    lv = strtol(++source, &cp, 10);
+		    if (cp == 0 || cp == source)
+			goto finish;
+		    {
+			float scale = 1.0f;
+			int digits = (int) (cp - source);
+			while (digits-- > 0) {
+			    scale *= 10.0f;
+			}
+			*fp += (float) lv / scale;
+		    }
+		    source = cp;
+		}
+		break;
+	    case 'n':
+		/* not really sscanf... */
+		limit = *va_arg(ap, int *);
+		break;
+	    case 's':
+		limit = -1;
+		cp = va_arg(ap, char *);
+		while (*source != '\0') {
+		    ch = UChar(*source);
+		    if (isspace(ch)) {
+			break;
+		    } else if (found && (ch == *skip_cs(pattern))) {
+			break;
+		    } else {
+			*cp++ = *source++;
+			found = TRUE;
+		    }
+		}
+		*cp = '\0';
+		break;
+	    }
+	    continue;
+	}
+	/* other characters are matched literally */
+	if (*source++ != ch) {
+	    break;
+	}
+    }
+  finish:
+
+    va_end(ap);
+    if (source > last_s)
+	source = last_s;
+    return (*source || *pattern) ? 0 : 1;
+}
+
+static int
+match_colors(const char *source, int cpp, char *arg1, char *arg2, char *arg3)
+{
+    int result = 0;
+
+    /* most files use a quasi-fixed format */
+    if (match_c(source, " \"%n%c %s %s \" , ", &cpp, arg1, arg2, arg3)) {
+	arg1[cpp] = '\0';
+	result = 1;
+    } else {
+	const char *s = skip_cs(source);
+	size_t have = strlen(source);
+
+	if (*s++ == '"' && have > ((size_t) cpp + 2)) {
+	    memcpy(arg1, s, (size_t) cpp);
+	    s += cpp;
+	    while (*s++ == '\t') {
+		char *t;
+		for (t = arg2; (*s != '\0') && strchr("\t\"", *s) == 0;) {
+		    if (*s == ' ') {
+			s = skip_cs(s);
+			break;
+		    }
+		    *t++ = *s++;
+		    *t = '\0';
+		}
+		for (t = arg3; (*s != '\0') && strchr("\t\"", *s) == 0;) {
+		    *t++ = *s++;
+		    *t = '\0';
+		}
+		if (!strcmp(arg2, "c")) {
+		    result = 1;
+		    break;
+		}
+	    }
+	}
+    }
+    return result;
+}
+
+static RGB_NAME *
+parse_rgb(char **data)
+{
+    char buf[BUFSIZ];
+    int n;
+    unsigned long r, g, b;
+    char *s, *t;
+    size_t item = 0;
+    size_t need;
+    RGB_NAME *result = 0;
+
+    for (need = 0; data[need] != 0; ++need) ;
+
+    result = typeCalloc(RGB_NAME, need + 2);
+    how_much.name += (sizeof(RGB_NAME) * (need + 2));
+
+    for (n = 0; data[n] != 0; ++n) {
+	if (strlen(t = data[n]) >= sizeof(buf) - 1)
+	    continue;
+	if (*(s = skip_s(t)) == '!')
+	    continue;
+
+	r = strtoul(s, &t, 10);
+	s = skip_s(t);
+	g = strtoul(s, &t, 10);
+	s = skip_s(t);
+	b = strtoul(s, &t, 10);
+	s = skip_s(t);
+
+	result[item].name = s;
+	t = s + strlen(s);
+	while (t-- != s && isspace(UChar(*t))) {
+	    *t = '\0';
+	}
+	result[item].value = (int) ((r & 0xff) << 16 |
+				    (g & 0xff) << 8 |
+				    (b & 0xff));
+	++item;
+    }
+
+    result[item].name = "none";
+    result[item].value = -1;
+
+    return result;
+}
+
+#define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c))
+
+static int
+CaselessCmp(const char *a, const char *b)
+{				/* strcasecmp isn't portable */
+    while (*a && *b) {
+	int cmp = LOWERCASE(*a) - LOWERCASE(*b);
+	if (cmp != 0)
+	    break;
+	a++, b++;
+    }
+    return LOWERCASE(*a) - LOWERCASE(*b);
+}
+
+static RGB_NAME *
+lookup_rgb(const char *name)
+{
+    RGB_NAME *result = 0;
+    if (rgb_table != 0) {
+	int n;
+	for (n = 0; rgb_table[n].name != 0; ++n) {
+	    if (!CaselessCmp(name, rgb_table[n].name)) {
+		result = &rgb_table[n];
+		break;
+	    }
+	}
+    }
+    return result;
+}
+
+static PICS_HEAD *
+parse_xbm(char **data)
+{
+    int n;
+    int state = 0;
+    char buf[2048];
+    int num;
+    char ch;
+    char *s;
+    char *t;
+    PICS_HEAD *result;
+    size_t which = 0;
+    size_t cells = 0;
+
+    debugmsg("called parse_xbm");
+
+    result = typeCalloc(PICS_HEAD, 1);
+    how_much.head += sizeof(PICS_HEAD);
+
+    begin_c_values(2);
+    gather_c_values(0);
+    gather_c_values(0xffffff);
+
+    for (n = 0; data[n] != 0; ++n) {
+	if (strlen(s = data[n]) >= sizeof(buf) - 1)
+	    continue;
+	switch (state) {
+	case 0:
+	case 1:
+	case 2:
+	    if (sscanf(s, "#define %1024s %d%c", buf, &num, &ch) >= 2) {
+		if ((t = strstr(buf, "_width")) != 0) {
+		    state |= 1;
+		    result->wide = (short) bytes_of(num);
+		} else if ((t = strstr(buf, "_height")) != 0) {
+		    state |= 2;
+		    result->high = (short) num;
+		} else {
+		    break;
+		}
+		*t = '\0';
+		if (result->name) {
+		    if (strcmp(result->name, buf)) {
+			goto finish;
+		    }
+		} else {
+		    result->name = strdup(buf);
+		}
+	    }
+	    break;
+	case 3:
+	    if (sscanf(s, "static char %1024[^_ ]_bits[]%c", buf, &ch) >= 1) {
+		if (strcmp(result->name, buf)) {
+		    goto finish;
+		}
+		state = 4;
+		cells = (size_t) (result->wide * result->high);
+
+		result->cells = typeCalloc(PICS_CELL, cells);
+		how_much.cell += (sizeof(PICS_CELL) * cells);
+
+		if ((s = strchr(s, L_CURLY)) == 0)
+		    break;
+		++s;
+	    } else {
+		break;
+	    }
+	case 4:
+	    while (*s != '\0') {
+		while (isspace(UChar(*s))) {
+		    ++s;
+		}
+		if (isdigit(UChar(*s))) {
+		    long value = strtol(s, &t, 0);
+		    int b;
+		    if (t != s || value > MaxRGB || value < 0) {
+			s = t;
+		    } else {
+			state = -1;
+			goto finish;
+		    }
+		    for (b = 0; b < 8; ++b) {
+			if (((1L << b) & value) != 0) {
+			    result->cells[which].ch = '*';
+			    result->cells[which].fg = 1;
+			    reading_ncols[1].count++;
+			} else {
+			    result->cells[which].ch = ' ';
+			    result->cells[which].fg = 0;
+			    reading_ncols[0].count++;
+			}
+			if (++which > cells) {
+			    state = -1;
+			    goto finish;
+			}
+		    }
+		}
+		if (*s == R_CURLY) {
+		    state = 5;
+		    goto finish;
+		} else if (*s == ',') {
+		    ++s;
+		}
+	    }
+	    break;
+	default:
+	    break;
+	}
+    }
+  finish:
+    if (state < 4) {
+	debugmsg("...state was only %d", state);
+	if (result) {
+	    result = free_pics_head(result);
+	}
+    } else {
+	finish_c_values(result);
+    }
+    return result;
+}
+
+static PICS_HEAD *
+parse_xpm(char **data)
+{
+    int state = 0;
+    PICS_HEAD *result;
+    RGB_NAME *by_name;
+    int n;
+    int cells = 0;
+    int cpp = 1;		/* chars per pixel */
+    int num[6];
+    int found;
+    int which = 0;
+    int num_colors = 0;
+    char ch;
+    const char *cs;
+    char *s;
+    char buf[BUFSIZ];
+    char arg1[BUFSIZ];
+    char arg2[BUFSIZ];
+    char arg3[BUFSIZ];
+    char **list = 0;
+
+    debugmsg("called parse_xpm");
+
+    result = typeCalloc(PICS_HEAD, 1);
+    how_much.head += sizeof(PICS_HEAD);
+
+    for (n = 0; data[n] != 0; ++n) {
+	if (strlen(s = data[n]) >= sizeof(buf) - 1)
+	    continue;
+	switch (state) {
+	case 0:
+	    if (match_c(s, " /* XPM */ ")) {
+		state = 1;
+	    }
+	    break;
+	case 1:
+	    if (match_c(s, " static char * %s [] = %c ", arg1, &ch) &&
+		ch == L_CURLY) {
+		result->name = strdup(arg1);
+		state = 2;
+	    }
+	    break;
+	case 2:
+	    if (match_c(s, " \" %d %d %d %d \" , ",
+			num + 0, num + 1, num + 2, num + 3) ||
+		match_c(s, " \" %d %d %d %d %d %d \" , ",
+			num + 0, num + 1, num + 2, num + 3, num + 4, num + 5)) {
+		result->wide = (short) num[0];
+		result->high = (short) num[1];
+		result->colors = num[2];
+
+		begin_c_values(num[2]);
+
+		cells = (result->wide * result->high);
+
+		result->cells = typeCalloc(PICS_CELL, cells);
+		how_much.cell += sizeof(PICS_CELL) * (size_t) cells;
+
+		list = typeCalloc(char *, result->colors + 1);
+		how_much.list += sizeof(char *) * (size_t) (result->colors + 1);
+
+		cpp = num[3];
+		state = 3;
+	    }
+	    break;
+	case 3:
+	    if (!match_colors(s, cpp, arg1, arg2, arg3)) {
+		break;
+	    }
+	    num_colors++;
+	    free(list[reading_last]);
+	    list[reading_last] = strdup(arg1);
+	    if ((by_name = lookup_rgb(arg3)) != 0) {
+		found = gather_c_values(by_name->value);
+	    } else if (*arg3 == '#') {
+		char *rgb = arg3 + 1;
+		unsigned long value = strtoul(rgb, &s, 16);
+		switch ((int) strlen(rgb)) {
+		case 6:
+		    break;
+		case 12:
+		    value = (((value >> 24) & 0xff0000L)
+			     | ((value >> 16) & 0xff00L)
+			     | ((value >> 8) & 0xffL));
+		    break;
+		default:
+		    warning("unexpected rgb value %s", rgb);
+		    break;
+		}
+		found = gather_c_values((int) value);
+	    } else {
+		found = gather_c_values(0);	/* actually an error */
+	    }
+	    debugmsg("  [%d:%d] %06X", num_colors, result->colors,
+		     reading_ncols[(found >= 0) ? found : 0].fgcol);
+	    if (num_colors >= result->colors) {
+		finish_c_values(result);
+		state = 4;
+		if (list[0] == 0)
+		    list[0] = strdup("\033");
+	    }
+	    break;
+	case 4:
+	    if (*(cs = skip_cs(s)) == '"') {
+		++cs;
+		while (*cs != '\0' && *cs != '"') {
+		    int c;
+
+		    /* FIXME - factor out */
+		    for (c = 0; c < result->colors; ++c) {
+			if (list[c] == 0) {
+			    /* should not happen... */
+			    continue;
+			}
+			if (!(strncmp) (cs, list[c], (size_t) cpp)) {
+			    result->cells[which].ch = list[c][0];
+			    result->cells[which].fg = c;
+			    result->fgcol[c].count++;
+			    break;
+			}
+		    }
+
+		    if (result->cells[which].ch == 0) {
+			result->cells[which].ch = '?';
+			result->cells[which].fg = 0;
+		    }
+
+		    if (++which >= cells) {
+			state = 5;
+			break;
+		    }
+		    for (c = cpp; c > 0; --c, ++cs) {
+			if (*cs == '\0')
+			    break;
+		    }
+		}
+	    }
+	    break;
+	}
+    }
+
+    if (result && list) {
+	for (n = 0; n < result->colors; ++n)
+	    free(list[n]);
+	free(list);
+    }
+
+    if (state < 5) {
+	debugmsg("...state was only %d", state);
+	result = free_pics_head(result);
+    }
+
+    if (result) {
+	debugmsg("...allocated %d colors", result->colors);
+    }
+
+    return result;
+}
+
+/*
+ * The obscurely-named "convert" is provided by ImageMagick
+ */
+static PICS_HEAD *
+parse_img(const char *filename)
+{
+    size_t need = strlen(filename) + 256;
+    char *cmd = malloc(need);
+    FILE *pp;
+    char buffer[BUFSIZ];
+    char dummy[BUFSIZ];
+    bool okay = TRUE;
+    PICS_HEAD *result;
+    int pic_x = 0;
+    int pic_y = 0;
+    int width = in_curses ? COLS : 80;
+
+    _nc_SPRINTF(cmd, _nc_SLIMIT(need) "identify \"%s\"", filename);
+    if (quiet)
+	_nc_STRCAT(cmd, " 2>/dev/null", need);
+
+    logmsg("...opening pipe to %s", cmd);
+
+    result = typeCalloc(PICS_HEAD, 1);
+    how_much.head += sizeof(PICS_HEAD);
+
+    if ((pp = popen(cmd, "r")) != 0) {
+	if (fgets(buffer, sizeof(buffer), pp) != 0) {
+	    size_t n = strlen(filename);
+	    debugmsg2("...read %s", buffer);
+	    if (strlen(buffer) > n &&
+		!(strncmp) (buffer, filename, n) &&
+		isspace(UChar(buffer[n])) &&
+		sscanf(skip_word(buffer + n), " %dx%d ", &pic_x, &pic_y) == 2) {
+		/* distort image to make it show normally on terminal */
+		pic_x = (int) ((double) pic_x / aspect_ratio);
+	    } else {
+		pic_x = pic_y = 0;
+	    }
+	}
+	pclose(pp);
+    }
+    if (pic_x <= 0 || pic_y <= 0)
+	goto finish;
+
+    _nc_SPRINTF(cmd, _nc_SLIMIT(need)
+		"convert " "-resize %dx%d\\! " "-thumbnail %dx \"%s\" "
+		"-define txt:compliance=SVG txt:-",
+		pic_x, pic_y, width, filename);
+    if (quiet)
+	_nc_STRCAT(cmd, " 2>/dev/null", need);
+
+    logmsg("...opening pipe to %s", cmd);
+    if ((pp = popen(cmd, "r")) != 0) {
+	int count = 0;
+	int col = 0;
+	int row = 0;
+	int len = 0;
+	while (fgets(buffer, sizeof(buffer), pp) != 0) {
+	    debugmsg2("[%5d] %s", count + 1, buffer);
+	    if (strlen(buffer) > 160) {		/* 80 columns would be enough */
+		okay = FALSE;
+		break;
+	    }
+	    if (count++ == 0) {
+		if (match_c(buffer,
+			    "# ImageMagick pixel enumeration: %d,%d,%d,%s ",
+			    &col, &row, &len, dummy)) {
+		    result->name = strdup(filename);
+		    result->wide = (short) col;
+		    result->high = (short) row;
+
+		    begin_c_values(256);
+
+		    result->cells = typeCalloc(PICS_CELL, (size_t) (col * row));
+		    how_much.cell += (sizeof(PICS_CELL) * (size_t) (col * row));
+		} else {
+		    okay = FALSE;
+		    break;
+		}
+	    } else {
+		/*
+		 * subsequent lines begin "col,row: (r,g,b,a) #RGB".
+		 * Those r/g/b could be integers (0..255) or float-percentages.
+		 */
+		int r, g, b, nocolor;
+		float rf, gf, bf;
+		unsigned check;
+		char *t;
+		char *s = t = strchr(buffer, '#');
+		bool matched = FALSE;
+
+		if (s != 0) {
+		    /* after the "#RGB", there are differences - just ignore */
+		    while (*s != '\0' && !isspace(UChar(*s)))
+			++s;
+		    *++s = '\0';
+		}
+
+		if (match_c(buffer,
+			    "%d,%d: (%d,%d,%d,%d) #%x ",
+			    &col, &row,
+			    &r, &g, &b, &nocolor,
+			    &check)) {
+		    matched = TRUE;
+		} else if (match_c(buffer,
+				   "%d,%d: (%f%%,%f%%,%f%%,%d) #%x ",
+				   &col, &row,
+				   &rf, &gf, &bf, &nocolor,
+				   &check) ||
+			   match_c(buffer,
+				   "%d,%d: (%f%%,%f%%,%f%%) #%x ",
+				   &col, &row,
+				   &rf, &gf, &bf,
+				   &check)) {
+		    matched = TRUE;
+
+#define fp_fix(n) (int) (MaxRGB * (((n) > 100.0 ? 100.0 : (n)) / 100.0))
+
+		    r = fp_fix(rf);
+		    g = fp_fix(gf);
+		    b = fp_fix(bf);
+		}
+		if ((s - t) > 8)	/* 6 hex digits vs 8 */
+		    check /= 256;
+		if (matched) {
+		    int which, c;
+		    int want_r = (check >> 16) & 0xff;
+		    int want_g = (check >> 8) & 0xff;
+		    int want_b = (check >> 0) & 0xff;
+
+#define fp_err(tst,ref) ((tst > MaxRGB) || ((tst - ref)*(tst - ref)) > 4)
+
+		    if (fp_err(r, want_r) ||
+			fp_err(g, want_g) ||
+			fp_err(b, want_b)) {
+			okay = FALSE;
+			break;
+		    }
+		    c = gather_c_values((int) check);
+		    which = col + (row * result->wide);
+		    result->cells[which].ch = ((in_curses ||
+						check == 0xffffff)
+					       ? ' '
+					       : '#');
+		    if (c >= 0 && c < reading_last) {
+			result->cells[which].fg = c;
+			reading_ncols[c].count++;
+		    } else {
+			result->cells[which].fg = -1;
+		    }
+		} else {
+		    okay = FALSE;
+		    break;
+		}
+	    }
+	}
+	finish_c_values(result);
+	pclose(pp);
+	if (okay) {
+	    /* FIXME - is this trimming needed? */
+	    for (len = result->colors; len > 3; len--) {
+		if (result->fgcol[len - 1].fgcol == 0) {
+		    result->colors = len - 1;
+		} else {
+		    break;
+		}
+	    }
+	}
+    }
+  finish:
+    free(cmd);
+
+    if (!okay) {
+	result = free_pics_head(result);
+    }
+
+    return result;
+}
+
+static PICS_HEAD *
+read_picture(const char *filename, char **data)
+{
+    PICS_HEAD *pics;
+    if ((pics = parse_xbm(data)) == 0) {
+	dispose_c_values();
+	if ((pics = parse_xpm(data)) == 0) {
+	    dispose_c_values();
+	    if ((pics = parse_img(filename)) == 0) {
+		dispose_c_values();
+		free_data(data);
+		warning("unexpected file-format for \"%s\"", filename);
+	    } else if (pics->high == 0 || pics->wide == 0) {
+		dispose_c_values();
+		free_data(data);
+		pics = free_pics_head(pics);
+		warning("no picture found in \"%s\"", filename);
+	    }
+	}
+    }
+    return pics;
+}
+
+#define fg_color(pics,n) (pics->fgcol[n].fgcol)
+
+static void
+dump_picture(PICS_HEAD * pics)
+{
+    int y, x;
+
+    printf("Name %s\n", pics->name);
+    printf("Size %dx%d\n", pics->high, pics->wide);
+    printf("Color\n");
+    for (y = 0; y < pics->colors; ++y) {
+	if (fg_color(pics, y) < 0) {
+	    printf(" %3d: %d\n", y, fg_color(pics, y));
+	} else {
+	    printf(" %3d: #%06x\n", y, fg_color(pics, y));
+	}
+    }
+    for (y = 0; y < pics->high; ++y) {
+	for (x = 0; x < pics->wide; ++x) {
+	    putchar(pics->cells[y * pics->wide + x].ch);
+	}
+	putchar('\n');
+    }
+}
+
+#ifndef USE_DISPLAY_DRIVER
+static void
+init_display(const char *palette_path, int opt_d)
+{
+    (void) opt_d;
+    if (isatty(fileno(stdout))) {
+	in_curses = TRUE;
+	setlocale(LC_ALL, "");
+	initscr();
+	cbreak();
+	noecho();
+	curs_set(0);
+	if (has_colors()) {
+	    start_color();
+#if HAVE_USE_DEFAULT_COLORS
+	    if (opt_d)
+		use_default_colors();
+#endif
+	    init_palette(palette_path);
+	}
+	scrollok(stdscr, FALSE);
+	stop_curses();
+    }
+}
+
+static void
+show_picture(PICS_HEAD * pics)
+{
+    int y, x;
+    int n;
+
+    debugmsg("called show_picture");
+    logmsg("...using %dx%d screen", LINES, COLS);
+#if HAVE_RESET_COLOR_PAIRS
+    reset_color_pairs();
+#elif HAVE_CURSCR
+    wclear(curscr);
+    clear();
+#endif
+    if (has_colors()) {
+	logmsg("...using %d colors", pics->colors);
+	for (n = 0; n < pics->colors; ++n) {
+	    int my_pair = (n + 1);
+	    int my_color = map_color(fg_color(pics, n));
+#if USE_EXTENDED_COLORS
+	    if (use_extended_pairs) {
+		init_extended_pair(my_pair, my_color, my_color);
+	    } else
+#endif
+	    {
+		my_pair &= 0x7fff;
+		my_color &= 0x7fff;
+		init_pair((short) my_pair, (short) my_color, (short) my_color);
+	    }
+	}
+	attrset(COLOR_PAIR(1));
+	erase();
+    }
+    for (y = 0; y < pics->high; ++y) {
+	if (y >= LINES)
+	    break;
+	move(y, 0);
+
+	for (x = 0; x < pics->wide; ++x) {
+	    int my_pair;
+
+	    if (x >= COLS)
+		break;
+	    n = (y * pics->wide + x);
+	    my_pair = pics->cells[n].fg + 1;
+#if USE_EXTENDED_COLORS
+	    if (use_extended_pairs) {
+		cchar_t temp;
+		wchar_t wch[2];
+		wch[0] = (wchar_t) pics->cells[n].ch;
+		wch[1] = 0;
+		setcchar(&temp, wch, A_NORMAL, (short) my_pair, &my_pair);
+		add_wch(&temp);
+	    } else
+#endif
+	    {
+		attrset(COLOR_PAIR(my_pair));
+		addch((chtype) pics->cells[n].ch);
+	    }
+	}
+    }
+    if (slow_time >= 0) {
+	refresh();
+	if (slow_time > 0) {
+#ifdef NCURSES_VERSION
+	    napms(1000 * slow_time);
+#else
+	    sleep((unsigned) slow_time);
+#endif
+	}
+    } else {
+	wmove(stdscr, 0, 0);
+	getch();
+    }
+    if (!quiet)
+	endwin();
+}
+#endif
+
+static int
+compare_fg_counts(const void *a, const void *b)
+{
+    const FG_NODE *p = (const FG_NODE *) a;
+    const FG_NODE *q = (const FG_NODE *) b;
+    return (q->count - p->count);
+}
+
+static void
+report_colors(PICS_HEAD * pics)
+{
+    int accum;
+    double level;
+    int j;
+    int shift;
+    int total;
+    char buffer[256];
+
+    if (logfp == 0)
+	return;
+
+    qsort(pics->fgcol, (size_t) pics->colors, sizeof(FG_NODE), compare_fg_counts);
+    /*
+     * For debugging, show a (short) list of the colors used.
+     */
+    if (debugging && (pics->colors < 1000)) {
+	int digits = 0;
+	int high;
+	int wide = 4;
+	for (j = pics->colors; j != 0; j /= 10) {
+	    ++digits;
+	    if (j < 10)
+		++digits;
+	}
+	if (digits > 8)
+	    digits = 8;
+	logmsg("These colors were used:");
+	high = (pics->colors + wide - 1) / wide;
+	for (j = 0; j < high && j < pics->colors; ++j) {
+	    int k;
+	    char *s = buffer;
+	    *s = '\0';
+	    for (k = 0; k < wide; ++k) {
+		int n = j + (k * high);
+		size_t want = (sizeof(buffer) - (size_t) (s - buffer));
+		if (want < 100 || want >= sizeof(buffer))
+		    break;
+		if (n >= pics->colors)
+		    break;
+		if (k) {
+		    *s++ = ' ';
+		    if (digits < 8) {
+			_nc_SPRINTF(s, _nc_SLIMIT(want) "%*s", 8 - digits,
+				    " ");
+			s += strlen(s);
+		    }
+		}
+		if (pics->fgcol[n].fgcol >= 0) {
+		    _nc_SPRINTF(s, _nc_SLIMIT(want) "%3d #%06X %*d", n,
+				pics->fgcol[n].fgcol,
+				digits, pics->fgcol[n].count);
+		} else {
+		    _nc_SPRINTF(s, _nc_SLIMIT(want) "%3d (empty) %*d", n,
+				digits, pics->fgcol[n].count);
+		}
+		s += strlen(s);
+		if ((s - buffer) > 100)
+		    break;
+	    }
+	    logmsg("%s", buffer);
+	}
+    }
+
+    /*
+     * Given the list of colors sorted by the number of times they are used,
+     * log a short report showing the number of colors for 90%, 99%, 99.9%,
+     * etc.
+     */
+    logmsg("Number of colors versus number of cells");
+    total = pics->high * pics->wide;
+    accum = 0;
+    level = 0.1;
+    shift = 1;
+    for (j = 0; j < pics->colors; ++j) {
+	accum += pics->fgcol[j].count;
+	if (accum >= (total * (1.0 - level))) {
+	    int after = (shift > 2) ? shift - 2 : 0;
+	    logmsg("%8d colors (%.1f%%) in %d cells (%.*f%%)",
+		   j + 1,
+		   (100.0 * (j + 1)) / pics->colors,
+		   accum,
+		   after, (100.0 * accum) / total);
+	    if (accum >= total)
+		break;
+	    level /= 10.0;
+	    shift++;
+	}
+    }
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+    int opt_d = FALSE;
+    char ignore_ch;
+    const char *palette_path = 0;
+    const char *rgb_path = RGB_PATH;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "a:dLl:p:qr:s:x:")) != -1) {
+	switch (ch) {
+	case 'a':
+	    if (sscanf(optarg, "%lf%c", &aspect_ratio, &ignore_ch) != 1
+		|| aspect_ratio < 0.1
+		|| aspect_ratio > 10.) {
+		fprintf(stderr, "Expected a number in [0.1 to 10.]: %s\n", optarg);
+		usage(FALSE);
+	    }
+	    break;
+#if HAVE_USE_DEFAULT_COLORS
+	case 'd':
+	    opt_d = TRUE;
+	    break;
+#endif
+	case 'L':
+	    debugging = TRUE;
+	    break;
+	case 'l':
+	    if ((logfp = fopen(optarg, "a")) == 0)
+		failed(optarg);
+	    break;
+	case 'p':
+	    palette_path = optarg;
+	    break;
+	case 'q':
+	    quiet = TRUE;
+	    break;
+	case 'r':
+	    rgb_path = optarg;
+	    break;
+	case 's':
+	    slow_time = atoi(optarg);
+	    break;
+#if USE_EXTENDED_COLORS
+	case 'x':
+	    {
+		char *s = optarg;
+		while (*s) {
+		    switch (*s++) {
+		    case 'p':
+			use_extended_pairs = TRUE;
+			break;
+		    case 'c':
+			use_extended_colors = TRUE;
+			break;
+		    default:
+			usage(FALSE);
+			break;
+		    }
+		}
+	    }
+	    break;
+#endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+
+    if (optind < argc) {
+	char **rgb_data = read_file(rgb_path);
+	int n;
+
+	if (rgb_data)
+	    rgb_table = parse_rgb(rgb_data);
+
+	init_display(palette_path, opt_d);
+	if (optind >= argc)
+	    giveup("expected at least one image filename");
+
+	for (n = optind; n < argc; ++n) {
+	    PICS_HEAD *pics;
+	    char **data = read_file(argv[n]);
+
+	    if (data == 0) {
+		warning("cannot read \"%s\"", argv[n]);
+		continue;
+	    }
+	    if ((pics = read_picture(argv[n], data)) != 0) {
+		if (in_curses) {
+		    show_picture(pics);
+		} else {
+		    dump_picture(pics);
+		}
+		report_colors(pics);
+		dispose_c_values();
+		free_data(data);
+		free_pics_head(pics);
+	    }
+	}
+	free_data(rgb_data);
+	free(rgb_table);
+	free(all_colors);
+    } else {
+	usage(FALSE);
+    }
+
+    cleanup(EXIT_SUCCESS);
+}
diff --git a/test/picsmap.h b/test/picsmap.h
new file mode 100644
index 0000000..fc790a9
--- /dev/null
+++ b/test/picsmap.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+ * Copyright 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                                                *
+ ****************************************************************************/
+/* $Id: picsmap.h,v 1.5 2021/04/24 23:25:17 tom Exp $ */
+
+#ifndef PICSMAP_H_INCL
+#define PICSMAP_H_INCL 1
+
+typedef int NUM_COLOR;
+typedef unsigned short NUM_COUNT;
+
+typedef struct {
+    char ch;			/* nominal character to display */
+    NUM_COLOR fg;		/* foreground color */
+} PICS_CELL;
+
+typedef struct {
+    NUM_COLOR fgcol;
+    NUM_COUNT count;
+} FG_NODE;
+
+typedef struct {
+    char *name;
+    short high;
+    short wide;
+    int colors;
+    FG_NODE *fgcol;
+    PICS_CELL *cells;
+} PICS_HEAD;
+
+typedef struct {
+    const char *name;
+    int value;
+} RGB_NAME;
+
+typedef struct {
+    short red;
+    short green;
+    short blue;
+} RGB_DATA;
+
+#endif /* PICSMAP_H_INCL */
diff --git a/test/popup_msg.c b/test/popup_msg.c
new file mode 100644
index 0000000..09eff5e
--- /dev/null
+++ b/test/popup_msg.c
@@ -0,0 +1,184 @@
+/****************************************************************************
+ * 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.                                                           *
+ ****************************************************************************/
+/*
+ * $Id: popup_msg.c,v 1.11 2021/12/18 21:19:19 tom Exp $
+ *
+ * Show a multi-line message in a window which may extend beyond the screen.
+ *
+ * Thomas Dickey - 2017/4/15.
+ */
+
+#include <test.priv.h>
+
+#include <popup_msg.h>
+
+#if HAVE_NEWPAD
+
+static WINDOW *old_window;
+
+static void
+begin_popup(void)
+{
+    doupdate();
+    old_window = dupwin(curscr);
+}
+
+static void
+end_popup(void)
+{
+    touchwin(old_window);
+    wnoutrefresh(old_window);
+    doupdate();
+    delwin(old_window);
+}
+
+/*
+ * Display a temporary window, e.g., to display a help-message.
+ */
+void
+popup_msg(WINDOW *parent, const char *const *msg)
+{
+    int x0 = 4;
+    int y0 = 2;
+    int y1 = 0;
+    int y2 = 0;
+    int wide = getmaxx(parent) - ((x0 + 1) * 2);
+    int high = getmaxy(parent) - ((y0 + 1) * 2);
+    WINDOW *help;
+    WINDOW *data;
+    int n;
+    int width = 0;
+    int length;
+    int last_y;
+    int ch = ERR;
+
+    for (n = 0; msg[n] != 0; ++n) {
+	int check = (int) strlen(msg[n]);
+	if (width < check)
+	    width = check;
+    }
+    length = n;
+
+    if ((help = newwin(high, wide, y0, x0)) == 0)
+	return;
+    if ((data = newpad(length + 1, width + 1)) == 0) {
+	delwin(help);
+	return;
+    }
+
+    begin_popup();
+
+    keypad(data, TRUE);
+
+    for (n = 0; n < length; ++n) {
+	waddstr(data, msg[n]);
+	if ((n + 1) < length) {
+	    waddch(data, '\n');
+	}
+    }
+    y2 = getcury(data);
+    last_y = (y2 - (high - 3));
+
+    do {
+	switch (ch) {
+	case KEY_HOME:
+	    y1 = 0;
+	    break;
+	case KEY_END:
+	    y1 = last_y;
+	    break;
+	case KEY_PREVIOUS:
+	case KEY_PPAGE:
+	    if (y1 > 0) {
+		y1 -= high / 2;
+		if (y1 < 0)
+		    y1 = 0;
+	    } else {
+		beep();
+	    }
+	    break;
+	case KEY_NEXT:
+	case KEY_NPAGE:
+	    if (y1 < last_y) {
+		y1 += high / 2;
+		if (y1 > last_y)
+		    y1 = last_y;
+	    } else {
+		beep();
+	    }
+	    break;
+	case CTRL('P'):
+	case KEY_UP:
+	    if (y1 > 0)
+		--y1;
+	    else
+		beep();
+	    break;
+	case CTRL('N'):
+	case KEY_DOWN:
+	    if (y1 < last_y)
+		++y1;
+	    else
+		beep();
+	    break;
+	default:
+	    beep();
+	    break;
+	case ERR:
+	    break;
+	}
+	werase(help);
+	box(help, 0, 0);
+	wnoutrefresh(help);
+	pnoutrefresh(data, y1, 0, y0 + 1, x0 + 1, high, wide);
+	doupdate();
+    } while ((ch = wgetch(data)) != ERR && ch != QUIT && ch != ESCAPE);
+    werase(help);
+    wrefresh(help);
+    delwin(help);
+    delwin(data);
+
+    end_popup();
+}
+
+void
+popup_msg2(WINDOW *parent, char **msg)
+{
+    popup_msg(parent, (const char *const *) msg);
+}
+
+#else
+void
+popup_msg(WINDOW *parent, const char *const *msg)
+{
+    (void) parent;
+    (void) msg;
+    beep();
+}
+#endif
diff --git a/test/popup_msg.h b/test/popup_msg.h
new file mode 100644
index 0000000..88dff73
--- /dev/null
+++ b/test/popup_msg.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+ * Copyright 2018,2020 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.                                                           *
+ ****************************************************************************/
+/*
+ * $Id: popup_msg.h,v 1.5 2020/02/02 23:34:34 tom Exp $
+ *
+ * Utility functions for a popup-message or help-screen.
+ */
+
+#ifndef POPUP_MSG_H_incl
+#define POPUP_MSG_H_incl 1
+
+#include <test.priv.h>
+
+extern void popup_msg(WINDOW *parent, const char *const *msg);
+extern void popup_msg2(WINDOW *parent, char **msg);
+
+#endif /* POPUP_MSG_H_incl */
diff --git a/test/programs b/test/programs
index 94765e2..16ecf81 100644
--- a/test/programs
+++ b/test/programs
@@ -1,6 +1,7 @@
-# $Id: programs,v 1.26 2015/06/27 10:40:53 tom Exp $
+# $Id: programs,v 1.57 2023/11/10 11:48:38 tom Exp $
 ##############################################################################
-# Copyright (c) 2006-2014,2015 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 "Software"), #
@@ -30,19 +31,24 @@
 # Author: Thomas E. Dickey
 #
 # programs used for ncurses tests
-background	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	background
+back_ground	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	back_ground dump_window
+background	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	background dump_window
 blue		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	blue
 bs		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	bs
 cardfile	$(LDFLAGS_DEFAULT)	$(LOCAL_LIBS)	cardfile
-chgat		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	chgat
-clip_printw	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	clip_printw
+chgat		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	chgat popup_msg
+clip_printw	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	clip_printw popup_msg
+color_content	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	color_content
 color_set	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	color_set
+combine		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	combine dump_window popup_msg
 demo_altkeys	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	demo_altkeys
 demo_defkey	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	demo_defkey
-demo_forms	$(LDFLAGS_DEFAULT)	$(LOCAL_LIBS)	demo_forms edit_field
+demo_forms	$(LDFLAGS_DEFAULT)	$(LOCAL_LIBS)	demo_forms edit_field popup_msg
 demo_keyok	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	demo_keyok
 demo_menus	$(LDFLAGS_DEFAULT)	$(LOCAL_LIBS)	demo_menus
+demo_new_pair	$(LDFLAGS_DEFAULT)	$(LOCAL_LIBS)	demo_new_pair popup_msg
 demo_panels	$(LDFLAGS_DEFAULT)	$(LOCAL_LIBS)	demo_panels
+demo_tabs	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	demo_tabs
 demo_termcap	$(LDFLAGS_TINFO)	$(LOCAL_LIBS)	demo_termcap
 demo_terminfo	$(LDFLAGS_TINFO)	$(LOCAL_LIBS)	demo_terminfo
 ditto		$(LDFLAGS_THREADS)	$(LOCAL_LIBS)	ditto
@@ -50,49 +56,65 @@
 dots_curses	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	dots_curses
 dots_mvcur	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	dots_mvcur
 dots_termcap	$(LDFLAGS_TINFO)	$(LOCAL_LIBS)	dots_termcap
+dots_xcurses	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	dots_xcurses
+dup_field	$(LDFLAGS_DEFAULT)	$(LOCAL_LIBS)	dup_field edit_field popup_msg
 echochar	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	echochar
+extended_color	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	extended_color
 filter		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	filter
 firework	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	firework
 firstlast	$(LDFLAGS_DEFAULT)	$(LOCAL_LIBS)	firstlast
 foldkeys	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	foldkeys
-form_driver_w	$(LDFLAGS_DEFAULT)	$(LOCAL_LIBS)	form_driver_w
+form_driver_w	$(LDFLAGS_DEFAULT)	$(LOCAL_LIBS)	form_driver_w popup_msg
 gdc		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	gdc
-hanoi		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	hanoi
+hanoi		$(LDFLAGS_CURSES_M)	$(LOCAL_LIBS)	hanoi
 hashtest	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	hashtest
-inch_wide	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	inch_wide
-inchs		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	inchs
+inch_wide	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	inch_wide popup_msg
+inchs		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	inchs popup_msg
 ins_wide	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	ins_wide
-insdelln	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	insdelln
+insdelln	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	insdelln popup_msg
 inserts		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	inserts
 key_names	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	key_names
 keynames	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	keynames
 knight		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	knight
+list_keys	$(LDFLAGS_TINFO)	$(LOCAL_LIBS)	list_keys
 lrtest		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	lrtest
-movewindow	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	movewindow
+move_field	$(LDFLAGS_DEFAULT)	$(LOCAL_LIBS)	move_field edit_field popup_msg
+movewindow	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	movewindow popup_msg
 ncurses		$(LDFLAGS_DEFAULT)	$(LOCAL_LIBS)	ncurses
 newdemo		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	newdemo
+padview		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	padview popup_msg
+pair_content	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	pair_content
+picsmap		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	picsmap
 railroad	$(LDFLAGS_TINFO)	$(LOCAL_LIBS)	railroad
-rain		$(LDFLAGS_THREADS)	$(LOCAL_LIBS)	rain
-redraw		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	redraw
-savescreen	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	savescreen
-tclock		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	tclock
+rain		$(LDFLAGS_THREADS)	$(LOCAL_LIBS)	rain popup_msg
+redraw		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	redraw popup_msg
+savescreen	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	savescreen popup_msg
+sp_tinfo	$(LDFLAGS_TINFO)	$(LOCAL_LIBS)	sp_tinfo
+tclock		$(LDFLAGS_CURSES_M)	$(LOCAL_LIBS)	tclock
 test_add_wchstr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_add_wchstr
 test_addchstr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_addchstr
 test_addstr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_addstr
 test_addwstr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_addwstr
 test_arrays	$(LDFLAGS_TINFO)	$(LOCAL_LIBS)	test_arrays
-test_get_wstr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_get_wstr
-test_getstr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_getstr
+test_delwin	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_delwin
+test_endwin	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_endwin
+test_get_wstr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_get_wstr popup_msg
+test_getstr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_getstr popup_msg
 test_instr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_instr
 test_inwstr	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_inwstr
+test_mouse	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_mouse
 test_opaque	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_opaque
 test_setupterm	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_setupterm
+test_sgr	$(LDFLAGS_TINFO)	$(LOCAL_LIBS)	test_sgr
+test_termattrs	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_termattrs
+test_tparm	$(LDFLAGS_TINFO)	$(LOCAL_LIBS)	test_tparm
+test_unget_wch	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_unget_wch
 test_vid_puts	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_vid_puts
 test_vidputs	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	test_vidputs
 testaddch	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	testaddch
 testcurs	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	testcurs
 testscanw	$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	testscanw
-view		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	view
+view		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	view popup_msg
 worm		$(LDFLAGS_THREADS)	$(LOCAL_LIBS)	worm
 xmas		$(LDFLAGS_CURSES)	$(LOCAL_LIBS)	xmas
 
diff --git a/test/railroad.c b/test/railroad.c
index 33dc46f..4d7c070 100644
--- a/test/railroad.c
+++ b/test/railroad.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2000-2011,2013 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2022 Thomas E. Dickey                                *
+ * Copyright 2000-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            *
@@ -29,7 +30,7 @@
 /*
  * Author: Thomas E. Dickey - 2000
  *
- * $Id: railroad.c,v 1.21 2013/09/28 22:02:17 tom Exp $
+ * $Id: railroad.c,v 1.26 2022/12/11 00:12:13 tom Exp $
  *
  * A simple demo of the termcap interface.
  */
@@ -113,7 +114,7 @@
 ShowSign(char *string)
 {
     char *base = string;
-    int ch, first, last;
+    int first, last;
 
     if (moveit != 0) {
 	tputs(tgoto(moveit, 0, height - 1), 1, outc);
@@ -121,7 +122,7 @@
     }
 
     while (*string != 0) {
-	ch = *string;
+	int ch = *string;
 	if (ch != ' ') {
 	    if (moveit != 0) {
 		for (first = length - 2; first >= (string - base); first--) {
@@ -187,10 +188,17 @@
     NCURSES_CONST char *name = getenv("TERM");
     char buffer[1024];
     char area[1024], *ap = area;
+    int z;
 
     if (name == 0)
+#ifdef EXP_WIN32_DRIVER
+	name = "ms-terminal";
+#else
 	name = "dumb";
-    if (tgetent(buffer, name) >= 0) {
+#endif
+
+    InitAndCatch(z = tgetent(buffer, name), onsig);
+    if (z >= 0) {
 
 	wipeit = tgetstr("ce", &ap);
 	height = tgetnum("li");
@@ -220,8 +228,6 @@
 
 	MyShowCursor(0);
 
-	CATCHALL(onsig);
-
 	while (*args) {
 	    ShowSign(*args++);
 	}
@@ -229,11 +235,44 @@
     }
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: railroad [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
 main(int argc, char *argv[])
 {
-    if (argc > 1) {
-	railroad(argv + 1);
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+
+    if (optind < argc) {
+	railroad(argv + optind);
     } else {
 	static char world[] = "Hello World";
 	static char *hello[] =
@@ -245,8 +284,7 @@
 
 #else
 int
-main(int argc GCC_UNUSED,
-     char *argv[]GCC_UNUSED)
+main(void)
 {
     printf("This program requires termcap\n");
     exit(EXIT_FAILURE);
diff --git a/test/rain.c b/test/rain.c
index 0f123ba..1b1d81a 100644
--- a/test/rain.c
+++ b/test/rain.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2020,2022 Thomas E. Dickey                                *
+ * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -26,9 +27,10 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: rain.c,v 1.41 2014/08/02 17:24:07 tom Exp $
+ * $Id: rain.c,v 1.57 2022/12/04 00:40:11 tom Exp $
  */
 #include <test.priv.h>
+#include <popup_msg.h>
 
 /* rain 11/3/1980 EPS/CITHEP */
 
@@ -55,6 +57,7 @@
 
 #ifdef USE_PTHREADS
 pthread_cond_t cond_next_drop;
+pthread_mutex_t mutex_drop_data;
 pthread_mutex_t mutex_next_drop;
 static int used_threads;
 
@@ -66,11 +69,18 @@
 static STATS drop_threads[MAX_THREADS];
 #endif
 
+#if HAVE_USE_WINDOW
+static int
+safe_wgetch(WINDOW *w, void *data GCC_UNUSED)
+{
+    return wgetch(w);
+}
+#endif
+
 static void
 onsig(int n GCC_UNUSED)
 {
-    curs_set(1);
-    endwin();
+    stop_curses();
     ExitProgram(EXIT_FAILURE);
 }
 
@@ -191,7 +201,7 @@
 static int
 put_next_drop(void)
 {
-    pthread_cond_signal(&cond_next_drop);
+    pthread_cond_broadcast(&cond_next_drop);
     pthread_mutex_unlock(&mutex_next_drop);
 
     return 0;
@@ -219,7 +229,7 @@
      * Find myself in the list of threads so we can count the number of loops.
      */
     for (mystats = 0; mystats < MAX_THREADS; ++mystats) {
-#if defined(__MINGW32__) && !defined(__WINPTHREADS_VERSION)
+#if defined(_NC_WINDOWS) && !defined(__WINPTHREADS_VERSION)
 	if (drop_threads[mystats].myself.p == pthread_self().p)
 #else
 	if (drop_threads[mystats].myself == pthread_self())
@@ -237,7 +247,9 @@
 	 * to the data which it uses for setting up this thread (but it has
 	 * been modified to use different coordinates).
 	 */
+	pthread_mutex_lock(&mutex_drop_data);
 	mydata = *(DATA *) arg;
+	pthread_mutex_unlock(&mutex_drop_data);
 
 	draw_part(part1, 0, &mydata);
 	draw_part(part2, 1, &mydata);
@@ -245,6 +257,7 @@
 	draw_part(part4, 3, &mydata);
 	draw_part(part5, 4, &mydata);
 	draw_part(part6, 0, &mydata);
+
     } while (get_next_drop());
 
     return NULL;
@@ -285,30 +298,83 @@
 static int
 get_input(void)
 {
-    return USING_WINDOW(stdscr, wgetch);
+    return USING_WINDOW1(stdscr, wgetch, safe_wgetch);
 }
 
-int
-main(int argc GCC_UNUSED,
-     char *argv[]GCC_UNUSED)
+static void
+usage(int ok)
 {
+    static const char *msg[] =
+    {
+	"Usage: rain [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+#if HAVE_USE_DEFAULT_COLORS
+	," -d       invoke use_default_colors"
+#endif
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    static const char *help[] =
+    {
+	"Commands:",
+	" q/Q        exit the program",
+	" s          do single-step",
+	" <space>    undo single-step",
+	"",
+	0
+    };
+
     bool done = FALSE;
     DATA drop;
 #ifndef USE_PTHREADS
     DATA last[MAX_DROP];
 #endif
     int j = 0;
+    int ch;
+#if HAVE_USE_DEFAULT_COLORS
+    bool d_option = FALSE;
+#endif
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "d")) != -1) {
+	switch (ch) {
+#if HAVE_USE_DEFAULT_COLORS
+	case 'd':
+	    d_option = TRUE;
+	    break;
+#endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
 
     setlocale(LC_ALL, "");
 
-    CATCHALL(onsig);
-
-    initscr();
+    InitAndCatch(initscr(), onsig);
     if (has_colors()) {
 	int bg = COLOR_BLACK;
 	start_color();
 #if HAVE_USE_DEFAULT_COLORS
-	if (use_default_colors() == OK)
+	if (d_option && (use_default_colors() == OK))
 	    bg = -1;
 #endif
 	init_pair(1, COLOR_BLUE, (short) bg);
@@ -319,7 +385,9 @@
     curs_set(0);
     timeout(0);
 
-#ifndef USE_PTHREADS
+#ifdef USE_PTHREADS
+    pthread_mutex_init(&mutex_drop_data, NULL);
+#else /* !USE_PTHREADS */
     for (j = MAX_DROP; --j >= 0;) {
 	last[j].x = random_x();
 	last[j].y = random_y();
@@ -328,14 +396,21 @@
 #endif
 
     while (!done) {
+#ifdef USE_PTHREADS
+	pthread_mutex_lock(&mutex_drop_data);
+
 	drop.x = random_x();
 	drop.y = random_y();
 
-#ifdef USE_PTHREADS
 	if (start_drop(&drop) != 0) {
 	    beep();
 	}
+
+	pthread_mutex_unlock(&mutex_drop_data);
 #else
+	drop.x = random_x();
+	drop.y = random_y();
+
 	/*
 	 * The non-threaded code draws parts of each drop on each loop.
 	 */
@@ -373,11 +448,17 @@
 	case (KEY_RESIZE):
 	    break;
 #endif
+	case HELP_KEY_1:
+	    popup_msg(stdscr, help);
+	    break;
+	case ERR:
+	    break;
+	default:
+	    beep();
 	}
 	napms(50);
     }
-    curs_set(1);
-    endwin();
+    stop_curses();
 #ifdef USE_PTHREADS
     printf("Counts per thread:\n");
     for (j = 0; j < MAX_THREADS; ++j)
diff --git a/test/redraw.c b/test/redraw.c
index 9cb0de9..749f790 100644
--- a/test/redraw.c
+++ b/test/redraw.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2006-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020-2021,2022 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            *
@@ -26,13 +27,14 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: redraw.c,v 1.8 2012/12/08 20:46:02 tom Exp $
+ * $Id: redraw.c,v 1.17 2022/12/10 22:28:50 tom Exp $
  *
  * Demonstrate the redrawwin() and wredrawln() functions.
  * Thomas Dickey - 2006/11/4
  */
 
 #include <test.priv.h>
+#include <popup_msg.h>
 
 static void
 trash(int beg_x, int max_x, int cur_x)
@@ -53,15 +55,33 @@
     for (x = max_x; x > cur_x; --x) {
 	putchar('\b');
     }
+    fflush(stdout);
 }
 
 static void
 test_redraw(WINDOW *win)
 {
+    static const char *help[] =
+    {
+	"Commands:",
+	"  ^Q/ESC/q   - quit",
+	"  w          - recur in a new window",
+	"  !          - overwrite current line using stdio outside curses.",
+#ifdef NCURSES_VERSION
+	"  @          - run \"date\" command, to put its output on screen.",
+#endif
+	"  ^L         - call redrawwin() for current window.",
+	"  ^W         - call wredrawln() for current line/current window.",
+	"  arrow-keys - move cursor on the screen",
+	"",
+	"Other control characters are added to the screen in printable form.",
+	"Other printable characters are added to the screen as is.",
+	0
+    };
+
     WINDOW *win1;
     WINDOW *win2;
     bool done = FALSE;
-    int ch, y, x;
     int max_y, max_x;
     int beg_y, beg_x;
 
@@ -71,12 +91,16 @@
     keypad(win, TRUE);
     getmaxyx(win, max_y, max_x);
     getbegyx(win, beg_y, beg_x);
+
     while (!done) {
-	ch = wgetch(win);
+	int ch = wgetch(win);
+	int y, x;
+
 	getyx(win, y, x);
 	switch (ch) {
 	case 'q':
 	    /* FALLTHRU */
+	case QUIT:
 	case ESCAPE:
 	    done = TRUE;
 	    break;
@@ -111,7 +135,7 @@
 	    /*
 	     * For a shell command, we can work around the problem noted above
 	     * using mvcur().  It is ifdef'd for NCURSES, since X/Open does
-	     * not define the case where the old location is unknown. 
+	     * not define the case where the old location is unknown.
 	     */
 	    IGNORE_RC(system("date"));
 	    mvcur(-1, -1, y, x);
@@ -146,9 +170,14 @@
 		wmove(win, y, x + 1);
 	    break;
 
+	case HELP_KEY_1:
+	    popup_msg(win, help);
+	    break;
+
 	default:
 	    if (ch > KEY_MIN) {
 		waddstr(win, keyname(ch));
+		waddch(win, '\n');
 	    } else {
 		waddstr(win, unctrl(UChar(ch)));
 	    }
@@ -159,10 +188,59 @@
     }
 }
 
-int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+static void
+usage(int ok)
 {
-    initscr();
+    static const char *tbl[] =
+    {
+	"Usage: redraw [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -e       use stderr (default stdout)"
+	," -n       do not initialize terminal"
+    };
+    unsigned n;
+    for (n = 0; n < SIZEOF(tbl); ++n)
+	fprintf(stderr, "%s\n", tbl[n]);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+    bool no_init = FALSE;
+    FILE *my_fp = stdout;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "en")) != -1) {
+	switch (ch) {
+	case 'e':
+	    my_fp = stderr;
+	    break;
+	case 'n':
+	    no_init = TRUE;
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
+    if (no_init) {
+	START_TRACE();
+    } else {
+	newterm((char *) 0, my_fp, stdin);
+    }
+
     raw();
     noecho();
     test_redraw(stdscr);
diff --git a/test/savescreen.c b/test/savescreen.c
index 01bfe06..3ea6193 100644
--- a/test/savescreen.c
+++ b/test/savescreen.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007-2011,2015 Free Software Foundation, Inc.              *
+ * Copyright 2018-2021,2022 Thomas E. Dickey                                *
+ * Copyright 2006-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            *
@@ -26,33 +27,48 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: savescreen.c,v 1.27 2015/03/28 23:21:28 tom Exp $
+ * $Id: savescreen.c,v 1.62 2022/12/10 23:23:27 tom Exp $
  *
  * Demonstrate save/restore functions from the curses library.
  * Thomas Dickey - 2007/7/14
  */
 
+#define NEED_TIME_H
 #include <test.priv.h>
+#include <popup_msg.h>
+#include <parse_rgb.h>
 
 #if HAVE_SCR_DUMP
 
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
+#if defined(__hpux)
+#define MyMarker 'X'
 #else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
+#define MyMarker ACS_DIAMOND
 #endif
 
+#define MAX_ANSI 8
+
 static bool use_init = FALSE;
 static bool keep_dumps = FALSE;
 
+#if USE_WIDEC_SUPPORT
+/* In HPUX curses, cchar_t is opaque; other implementations are not */
+static wchar_t
+BaseChar(cchar_t data)
+{
+    wchar_t my_wchar[CCHARW_MAX];
+    wchar_t result = 0;
+    attr_t my_attr;
+    short my_pair;
+    if (getcchar(&data, my_wchar, &my_attr, &my_pair, NULL) == OK)
+	result = my_wchar[0];
+    return result;
+}
+#endif
+
 static int
 fexists(const char *name)
 {
@@ -70,9 +86,9 @@
 static void
 cleanup(char *files[])
 {
-    int n;
-
     if (!keep_dumps) {
+	int n;
+
 	for (n = 0; files[n] != 0; ++n) {
 	    unlink(files[n]);
 	}
@@ -106,7 +122,7 @@
 }
 
 static void
-show_what(int which, int last)
+show_what(int color, int which, int last)
 {
     int y, x, n;
     time_t now;
@@ -115,7 +131,7 @@
     getyx(stdscr, y, x);
 
     move(0, 0);
-    printw("Saved %d of %d (? for help)", which, last + 1);
+    printw("Color %d.  Saved %d of %d (? for help)", color, which, last + 1);
 
     now = time((time_t *) 0);
     mytime = ctime(&now);
@@ -134,36 +150,67 @@
 }
 
 static int
-get_command(int which, int last)
+get_command(int color, int which, int last)
 {
     int ch;
 
     timeout(50);
 
     do {
-	show_what(which, last);
+	show_what(color, which, last);
 	ch = getch();
     } while (ch == ERR);
 
     return ch;
 }
 
-static void
-show_help(const char **help)
+static int
+dump_screen(char **files, int color, int which, int last, bool use_colors)
 {
-    WINDOW *mywin = newwin(LINES, COLS, 0, 0);
-    int n;
+#if USE_WIDEC_SUPPORT
+    cchar_t mycc;
+#endif
+    char *filename = files[which];
+    bool dumped = FALSE;
 
-    box(mywin, 0, 0);
-    wmove(mywin, 1, 1);
-    for (n = 0; help[n] != 0; ++n) {
-	wmove(mywin, 1 + n, 2);
-	wprintw(mywin, "%.*s", COLS - 4, help[n]);
+    if (filename != 0) {
+	dumped = TRUE;
+	show_what(color, ++which, last);
+	if (scr_dump(filename) == ERR) {
+	    endwin();
+	    printf("Cannot write screen-dump %s\n", filename);
+	    cleanup(files);
+	    ExitProgram(EXIT_SUCCESS);
+	}
+	if (use_colors) {
+	    int cx, cy;
+	    int pair = 1 + (which % MAX_ANSI);
+	    /*
+	     * Change the background color, to make it more obvious.  But that
+	     * changes the existing text-color.  Copy the old values from the
+	     * currently displayed screen.
+	     */
+	    bkgd((chtype) COLOR_PAIR(pair));
+	    for (cy = 1; cy < LINES; ++cy) {
+		for (cx = 0; cx < COLS; ++cx) {
+		    wmove(curscr, cy, cx);
+		    wmove(stdscr, cy, cx);
+#if USE_WIDEC_SUPPORT
+		    if (win_wch(curscr, &mycc) != ERR) {
+			int myxx = wcwidth(BaseChar(mycc));
+			if (myxx > 0) {
+			    wadd_wchnstr(stdscr, &mycc, 1);
+			    cx += (myxx - 1);
+			}
+		    }
+#else
+		    waddch(stdscr, winch(curscr));
+#endif
+		}
+	    }
+	}
     }
-    wgetch(mywin);
-    delwin(mywin);
-    touchwin(stdscr);
-    refresh();
+    return dumped;
 }
 
 static void
@@ -183,8 +230,9 @@
 	"   a           toggle between '#' and graphic symbol for drawing",
 	"   c           change color drawn by line to next in palette",
 	"   h,j,k,l or arrows to move around the screen, drawing",
+	0
     };
-    show_help(msgs);
+    popup_msg(stdscr, msgs);
 }
 
 static void
@@ -199,29 +247,34 @@
 	"   q           quit",
 	"   <space>     load the next screen",
 	"   <backspace> load the previous screen",
+	0
     };
-    show_help(msgs);
+    popup_msg(stdscr, msgs);
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *msg[] =
     {
-	"Usage: savescreen [-r] files",
-	"",
-	"Options:",
-	" -f file  fill/initialize screen using text from this file",
-	" -i       use scr_init/scr_restore rather than scr_set",
-	" -k       keep the restored dump-files rather than removing them",
-	" -r       replay the screen-dump files"
+	"Usage: savescreen [-r] files"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -f file  fill/initialize screen using text from this file"
+	," -i       use scr_init/scr_restore rather than scr_set"
+	," -k       keep the restored dump-files rather than removing them"
+	," -r       replay the screen-dump files"
     };
     unsigned n;
     for (n = 0; n < SIZEOF(msg); ++n) {
 	fprintf(stderr, "%s\n", msg[n]);
     }
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
@@ -229,18 +282,20 @@
     int ch;
     int which = 0;
     int last;
+    bool use_colors = FALSE;
     bool replaying = FALSE;
     bool done = FALSE;
     char **files;
     char *fill_by = 0;
 #if USE_WIDEC_SUPPORT
     cchar_t mycc;
-    int myxx;
+    static const wchar_t mywc[2] =
+    {L'#', 0};
 #endif
 
     setlocale(LC_ALL, "");
 
-    while ((ch = getopt(argc, argv, "f:ikr")) != -1) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "f:ikr")) != -1) {
 	switch (ch) {
 	case 'f':
 	    fill_by = optarg;
@@ -254,9 +309,12 @@
 	case 'r':
 	    replaying = TRUE;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
-	    break;
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
 
@@ -273,20 +331,156 @@
     noecho();
     keypad(stdscr, TRUE);
     curs_set(0);
-    if (has_colors()) {
-	short pair;
-	short color;
 
-	start_color();
+    if (has_colors() && (start_color() == OK) && COLORS >= MAX_ANSI) {
+#if USE_WIDEC_SUPPORT
+	bool using_rgb = FALSE;
+#endif
+	static const struct {
+	    int fg, bg;
+	} table[MAX_ANSI] = {
+#define DATA(fg,bg) { COLOR_##fg, COLOR_##bg }
+	    DATA(RED, WHITE),
+		DATA(GREEN, WHITE),
+		DATA(YELLOW, BLACK),
+		DATA(BLUE, WHITE),
+		DATA(MAGENTA, WHITE),
+		DATA(MAGENTA, BLACK),
+		DATA(CYAN, WHITE),
+		DATA(CYAN, BLACK),
+#undef DATA
+	};
+	int n;
+	int pair = 1;
+
+	use_colors = TRUE;
 	/*
-	 * Assume pairs is the square of colors, and assign pairs going down
-	 * so that there is minimal conflict with the background color (which
-	 * counts up).  The intent is just to show how color pair values are
-	 * saved and restored.
+	 * Discounting color-pair 0 (no color), make the next 8 color pairs
+	 * useful for leaving a visually distinct trail of characters on the
+	 * screen.
 	 */
-	for (pair = 0; pair < COLOR_PAIRS; ++pair) {
-	    color = (short) (pair % (COLORS - 1));
-	    init_pair(pair, (short) (COLOR_WHITE - color), color);
+	for (n = 0; n < MAX_ANSI; ++n) {
+	    init_pair((short) pair++, (short) table[n].fg, (short) table[n].bg);
+	}
+	/*
+	 * After that, use color pairs for constructing a test-pattern, e.g.,
+	 * imitating xterm's scripts.
+	 */
+	if (fill_by == 0) {
+	    if (COLORS <= 256) {
+		for (n = 0; n < COLORS; ++n)
+		    init_pair((short) (n + MAX_ANSI), (short) n, (short) n);
+	    }
+#if HAVE_TIGETSTR && USE_WIDEC_SUPPORT
+	    else {
+		int r_max, g_max, b_max;
+
+		if (parse_rgb(&r_max, &g_max, &b_max) > 0) {
+		    int rows = LINES - 1;
+		    int cols = COLS - 1;
+		    int b_delta = (b_max / rows);
+		    int r_delta = (r_max / cols);
+		    int g_delta = (g_max / cols);
+		    int row = 0;
+		    int b = 0;
+
+		    using_rgb = TRUE;
+		    while (row++ < rows) {
+			int col = 0;
+			int r = 0;
+			int g = g_max;
+			while (col++ < cols) {
+			    int color = (((r * (g_max + 1)) + g) * (b_max + 1)
+					 + b + MAX_ANSI);
+#if USE_EXTENDED_COLOR
+			    init_extended_pair(pair, color, color);
+#else
+			    init_pair(pair, color, color);
+#endif
+			    pair++;
+			    r += r_delta;
+			    g -= g_delta;
+			}
+			b += b_delta;
+		    }
+		}
+	    }
+#endif
+	}
+	if ((fill_by == 0) && !replaying) {
+#if USE_WIDEC_SUPPORT
+	    int cube = 0;
+#endif
+	    /*
+	     * Originally (before wide-characters) ncurses supported 16 colors.
+	     */
+	    if (COLORS >= 16 && COLORS <= 256) {
+		mvprintw(2, 0, "System colors:\n");
+		for (n = 0; n < 16; ++n) {
+		    pair = n + MAX_ANSI;
+		    addch((chtype) (' ' | COLOR_PAIR(pair)));
+		    addch((chtype) (' ' | COLOR_PAIR(pair)));
+		    if (((n + 1) % 8) == 0)
+			addch('\n');
+		}
+	    }
+	    /*
+	     * Even with ncurses, you need wide-character support to have more
+	     * than 16 colors.
+	     */
+#if USE_WIDEC_SUPPORT
+	    if (COLORS == 88) {
+		cube = 4;
+	    } else if (COLORS == 256) {
+		cube = 6;
+	    }
+	    if (cube != 0) {
+		int r, g, b;
+		int cube0 = 16;
+		int cube1 = cube0 + (cube * cube * cube);
+
+		addch('\n');
+		printw("Color cube, %dx%dx%d:\n", cube, cube, cube);
+		for (g = 0; g < cube; g++) {
+		    for (r = 0; r < cube; r++) {
+			for (b = 0; b < cube; b++) {
+			    pair = MAX_ANSI
+				+ 16
+				+ (r * cube * cube) + (g * cube) + b;
+			    setcchar(&mycc, mywc, 0, (short) pair, NULL);
+			    add_wch(&mycc);
+			    add_wch(&mycc);
+			}
+			addch(' ');
+		    }
+		    addch('\n');
+		}
+		addch('\n');
+		printw("Grayscale ramp:\n");
+		for (n = cube1; n < COLORS; ++n) {
+		    pair = n + MAX_ANSI;
+		    setcchar(&mycc, mywc, 0, (short) pair, NULL);
+		    add_wch(&mycc);
+		    add_wch(&mycc);
+		}
+	    } else if ((COLORS > 256) && using_rgb) {
+		int rows = LINES - 1;
+		int cols = COLS - 1;
+		int row = 0;
+
+		pair = MAX_ANSI;
+		while (row++ < rows) {
+		    int col = 0;
+		    while (col++ < cols) {
+			setcchar(&mycc, mywc, 0, (short) pair, &pair);
+			add_wch(&mycc);
+			++pair;
+		    }
+		    addch('\n');
+		}
+		addch('\n');
+	    }
+#endif
 	}
     }
 
@@ -309,7 +503,7 @@
 	    }
 	    move(0, 0);
 	} else {
-	    endwin();
+	    stop_curses();
 	    fprintf(stderr, "Cannot open \"%s\"\n", fill_by);
 	    ExitProgram(EXIT_FAILURE);
 	}
@@ -321,14 +515,14 @@
 	 * Use the last file as the initial/current screen.
 	 */
 	if (last < 0) {
-	    endwin();
+	    stop_curses();
 	    printf("No screen-dumps given\n");
 	    ExitProgram(EXIT_FAILURE);
 	}
 
 	which = last;
 	if (load_screen(files[which]) == ERR) {
-	    endwin();
+	    stop_curses();
 	    printf("Cannot load screen-dump %s\n", files[which]);
 	    ExitProgram(EXIT_FAILURE);
 	}
@@ -358,7 +552,7 @@
 		if (++which > last)
 		    which = 0;
 		break;
-	    case '?':
+	    case HELP_KEY_1:
 		replay_help();
 		break;
 	    default:
@@ -383,10 +577,14 @@
 	int x = 0;
 	int color = 0;
 	int altchars = 0;
+	bool dirty = use_colors || (fill_by != 0);
 
 	while (!done) {
-	    switch (get_command(which, last)) {
+	    switch (get_command(color, which, last)) {
 	    case 'n':
+		if (dirty && files[which]) {
+		    dump_screen(files, color, which, last, use_colors);
+		}
 		setup_next();
 		done = TRUE;
 		break;
@@ -395,46 +593,12 @@
 		done = TRUE;
 		break;
 	    case ' ':
-		if (files[which] != 0) {
-		    show_what(which + 1, last);
-		    if (scr_dump(files[which]) == ERR) {
-			endwin();
-			printf("Cannot write screen-dump %s\n", files[which]);
-			cleanup(files);
-			done = TRUE;
-			break;
-		    }
-		    ++which;
-		    if (has_colors()) {
-			int cx, cy;
-			short pair = (short) (which % COLOR_PAIRS);
-			/*
-			 * Change the background color, to make it more
-			 * obvious.  But that changes the existing text-color. 
-			 * Copy the old values from the currently displayed
-			 * screen.
-			 */
-			bkgd((chtype) COLOR_PAIR(pair));
-			for (cy = 1; cy < LINES; ++cy) {
-			    for (cx = 0; cx < COLS; ++cx) {
-				wmove(curscr, cy, cx);
-				wmove(stdscr, cy, cx);
-#if USE_WIDEC_SUPPORT
-				if (win_wch(curscr, &mycc) != ERR) {
-				    myxx = wcwidth(mycc.chars[0]);
-				    if (myxx > 0) {
-					wadd_wchnstr(stdscr, &mycc, 1);
-					cx += (myxx - 1);
-				    }
-				}
-#else
-				waddch(stdscr, winch(curscr));
-#endif
-			    }
-			}
-		    }
+		if (dump_screen(files, color, which, last, use_colors)) {
+		    which = (which + 1) % MAX_ANSI;
+		    dirty = FALSE;
 		} else {
-		    beep();
+		    setup_next();
+		    done = TRUE;
 		}
 		break;
 	    case KEY_LEFT:
@@ -461,9 +625,11 @@
 		altchars = !altchars;
 		break;
 	    case 'c':
-		color = (color + 1) % COLORS;
+		if (use_colors) {
+		    color = (color + 1) % MAX_ANSI;
+		}
 		break;
-	    case '?':
+	    case HELP_KEY_1:
 		editor_help();
 		break;
 	    default:
@@ -471,11 +637,15 @@
 		continue;
 	    }
 	    if (!done) {
-		attr_t attr = (A_REVERSE | COLOR_PAIR(color * COLORS));
-		chtype ch2 = (altchars ? ACS_DIAMOND : '#');
+		chtype attr = A_REVERSE;
+		chtype ch2 = (altchars ? MyMarker : '#');
+		if (use_colors) {
+		    attr |= (chtype) COLOR_PAIR(color);
+		}
 		move(y, x);
-		addch(ch2 | attr);
+		AddCh(ch2 | attr);
 		move(y, x);
+		dirty = TRUE;
 	    }
 	}
 	endwin();
@@ -485,7 +655,7 @@
 
 #else
 int
-main(int argc, char *argv[])
+main(void)
 {
     printf("This program requires the screen-dump functions\n");
     ExitProgram(EXIT_FAILURE);
diff --git a/test/savescreen.sh b/test/savescreen.sh
index e49aa17..1ffab2f 100755
--- a/test/savescreen.sh
+++ b/test/savescreen.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 ##############################################################################
-# Copyright (c) 2007,2009 Free Software Foundation, Inc.                     #
+# Copyright 2020,2022 Thomas E. Dickey                                       #
+# Copyright 2007-2009,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"), #
@@ -26,14 +27,24 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: savescreen.sh,v 1.4 2009/10/10 17:08:45 tom Exp $
+# $Id: savescreen.sh,v 1.8 2022/07/16 16:34:34 tom Exp $
 #
 # Use this script to exercise "savescreen".
 # It starts by generating a series of temporary-filenames, which are passed
 # to the test-program.  Loop as long as the first file named exists.
+
+: "${TMPDIR:=/tmp}"
+
+# "mktemp -d" would be preferable, but is not standard.
+MY_DIR=$TMPDIR/savescreen$$
+trap "rm -rf $MY_DIR; exit 1" 1 2 3
+trap "rm -rf $MY_DIR" 0
+umask 077
+mkdir $MY_DIR || exit 1
+
 PARAMS=
 NFILES=4
-PREFIX=savescreen-$$
+PREFIX=$MY_DIR/savescreen
 n=0
 BEGINS=$PREFIX-$n.tmp
 while test $n != $NFILES
@@ -43,12 +54,12 @@
 	n=`expr $n + 1`
 done
 
-./savescreen $PARAMS
+${0%.sh} $PARAMS
 if test -f $BEGINS
 then
 	while test -f $BEGINS
 	do
-		./savescreen -r $PARAMS
+		"${0%.sh}" -r $PARAMS
 		test $? != 0 && break
 	done
 else
diff --git a/test/sp_tinfo.c b/test/sp_tinfo.c
new file mode 100644
index 0000000..72b20cf
--- /dev/null
+++ b/test/sp_tinfo.c
@@ -0,0 +1,359 @@
+/****************************************************************************
+ * Copyright 2019-2022,2023 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.                                                           *
+ ****************************************************************************/
+
+/*
+ * $Id: sp_tinfo.c,v 1.29 2023/06/24 14:14:56 tom Exp $
+ *
+ * TOTO: add option for non-sp-funcs interface
+ */
+
+#define USE_TINFO
+#include <test.priv.h>
+
+#if HAVE_TPUTS_SP
+/*
+ * The higher-level curses library stores a TERMINAL* inside SCREEN, but the
+ * latter is opaque.  This structure helps us keep the two associated.
+ */
+typedef struct {
+    const char *name;
+    FILE *fp;
+    SCREEN *sp;
+    TERMINAL *term;
+    int (*outc) (SCREEN *, int);
+} MYDATA;
+
+static bool opt_n = FALSE;	/* true to suppress new_prescr */
+static bool opt_t = FALSE;	/* true to use termcap */
+
+static int
+my_outc(SCREEN *sp, int ch)
+{
+    (void) sp;
+    return fputc(ch, stdout);
+}
+
+static int
+my_errc(SCREEN *sp, int ch)
+{
+    (void) sp;
+    return fputc(ch, stderr);
+}
+
+static MYDATA *
+initialize(const char *name, FILE *output)
+{
+    MYDATA *result = typeCalloc(MYDATA, 1);
+    int error;
+
+    result->fp = output;
+    result->name = name;
+    result->outc = (fileno(output) == 1) ? my_outc : my_errc;
+    result->sp = opt_n ? NULL : new_prescr();
+
+    if (opt_t) {
+	char *temp = strdup(name);
+	tgetent_sp(result->sp, temp, name);
+	free(temp);
+    } else {
+	setupterm((NCURSES_CONST char *) name, fileno(output), &error);
+    }
+    result->term = cur_term;
+
+    return result;
+}
+
+static void
+show_flag(MYDATA * data, const char *name, int value)
+{
+    if (value < 0) {
+	fprintf(data->fp, " %s = (unknown)\n", name);
+    } else if (value == 0) {
+	fprintf(data->fp, " %s = false\n", name);
+    } else {
+	fprintf(data->fp, " %s = true\n", name);
+    }
+}
+
+#define TC_PARMS data->sp, (NCURSES_CONST char *)tc
+#define TI_PARMS data->sp, (NCURSES_CONST char *)ti
+
+static void
+show_cap_flag(MYDATA * data, const char *ti, const char *tc)
+{
+    const char *name = (opt_t ? tc : ti);
+    show_flag(data, name, (opt_t
+			   ? tgetflag_sp(TC_PARMS)
+			   : tigetflag_sp(TI_PARMS)));
+}
+
+static void
+show_number(MYDATA * data, const char *name, int value)
+{
+    if (value <= -2) {
+	fprintf(data->fp, " %s = (unknown)\n", name);
+    } else if (value <= -1) {
+	fprintf(data->fp, " %s = (missing)\n", name);
+    } else {
+	fprintf(data->fp, " %s = %d\n", name, value);
+    }
+}
+
+static void
+show_cap_number(MYDATA * data, const char *ti, const char *tc)
+{
+    const char *name = (opt_t ? tc : ti);
+    show_number(data, name, (opt_t
+			     ? tgetnum_sp(TC_PARMS)
+			     : tigetnum_sp(TI_PARMS)));
+}
+
+static void
+show_string(MYDATA * data, const char *name, const char *value)
+{
+    fprintf(data->fp, " %s = ", name);
+    if (value == 0) {
+	fprintf(data->fp, "(missing)");
+    } else if (value == (char *) -1) {
+	fprintf(data->fp, "(canceled)");
+    } else {
+	int ch;
+	while ((ch = UChar(*value++)) != '\0') {
+	    if (ch < 32) {
+		fprintf(data->fp, "^%c", ch | '@');
+	    } else if (ch == 127) {
+		fprintf(data->fp, "^?");
+	    } else if (ch > 127) {
+		fprintf(data->fp, "\\%03o", ch);
+	    } else {
+		fprintf(data->fp, "%c", ch);
+	    }
+	}
+    }
+    fprintf(data->fp, "\n");
+}
+
+static void
+show_cap_string(MYDATA * data, const char *ti, const char *tc)
+{
+    const char *name = (opt_t ? tc : ti);
+    char tcapjunk[1024];
+    char *tcap_ptr = tcapjunk;
+    show_string(data, name, (opt_t
+			     ? tgetstr_sp(TC_PARMS, &tcap_ptr)
+			     : tigetstr_sp(TI_PARMS)));
+}
+
+static void
+show_char(MYDATA * data, const char *name, int value)
+{
+    if (value < 0) {
+	show_string(data, name, "(missing)");
+    } else {
+	char temp[2];
+	temp[0] = (char) value;
+	temp[1] = '\0';
+	show_string(data, name, temp);
+    }
+}
+
+static void
+do_stuff(MYDATA * data)
+{
+    SCREEN *sp = data->sp;
+#if NCURSES_EXT_FUNCS
+    char *s;
+    int my_code = 1234;
+    const char *my_text = "\033[?m";
+#endif
+
+    set_curterm_sp(sp, data->term);
+
+    /* putp always goes to standard output */
+    putp_sp(sp, "Hello ");
+    putp_sp(sp, data->name);
+    putp_sp(sp, "!\n");
+
+    fprintf(data->fp, "Term: %s\n", termname_sp(sp));
+    fprintf(data->fp, "Long: %s\n", longname_sp(sp));
+    show_cap_flag(data, "am", "am");
+    show_cap_number(data, "lines", "li");
+    show_cap_string(data, "clear", "cl");
+    show_cap_string(data, "tbc", "ct");
+    show_flag(data, "has_ic", has_ic_sp(sp));
+    show_flag(data, "has_il", has_il_sp(sp));
+    show_number(data, "baudrate", baudrate_sp(sp));
+    show_char(data, "erase ch", erasechar_sp(sp));
+    show_char(data, "kill ch", killchar_sp(sp));
+    show_string(data, "unctrl", unctrl_sp(sp, 033));
+    fflush(data->fp);
+
+#if NCURSES_EXT_FUNCS
+    define_key_sp(sp, my_text, my_code);
+    has_key_sp(sp, 0);
+    key_defined_sp(sp, my_text);
+    if ((s = keybound_sp(sp, my_code, 0)) != 0)
+	free(s);
+#endif
+    keyname_sp(sp, '?');
+#if NCURSES_EXT_FUNCS
+    keyok_sp(sp, my_code, FALSE);
+    keyok_sp(sp, my_code, TRUE);
+#endif
+
+    savetty_sp(sp);
+
+    def_shell_mode_sp(sp);
+
+    /*
+     * These functions are low-level settings for ncurses.
+     */
+#if NCURSES_EXT_FUNCS
+    set_tabsize_sp(sp, 5);	/* waddch */
+#endif
+    typeahead_sp(sp, FALSE);	/* waddch */
+    use_env_sp(sp, FALSE);	/* newterm */
+    use_tioctl_sp(sp, FALSE);	/* newterm */
+    intrflush_sp(sp, 0, 0);	/* wgetch */
+    flushinp_sp(sp);		/* waddch */
+    halfdelay_sp(sp, 5);	/* wgetch */
+
+    /*
+     * These manipulate the terminal modes, mainly for wgetch.
+     */
+    cbreak_sp(sp);
+    raw_sp(sp);
+    def_prog_mode_sp(sp);
+
+    delay_output_sp(sp, 200);
+
+    napms_sp(sp, 10);
+
+    nocbreak_sp(sp);
+    noqiflush_sp(sp);
+    noraw_sp(sp);
+    qiflush_sp(sp);
+
+    resetty_sp(sp);
+
+    tputs_sp(sp, "{reset-mode}\n", 0, data->outc);
+
+    reset_prog_mode_sp(sp);
+
+    curs_set_sp(sp, 0);
+    tputs_sp(sp, "{prog-mode}\n", 0, data->outc);
+
+    reset_shell_mode_sp(sp);
+
+    tputs_sp(sp, "{shell-mode}\n", 0, data->outc);
+}
+
+static void
+cleanup(MYDATA * data)
+{
+    set_curterm(data->term);
+    del_curterm(data->term);
+    free(data);
+}
+
+static void
+usage(int ok)
+{
+    static const char *tbl[] =
+    {
+	"Usage: sp_tinfo [output] [error]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -n       suppress call to new_prescr()"
+	," -t       use termcap functions rather than terminfo"
+    };
+    size_t n;
+    for (n = 0; n < SIZEOF(tbl); ++n) {
+	fprintf(stderr, "%s\n", tbl[n]);
+    }
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    MYDATA *my_out;
+    MYDATA *my_err;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "nt")) != -1) {
+	switch (ch) {
+	case 'n':
+	    opt_n = TRUE;
+	    break;
+	case 't':
+	    opt_t = TRUE;
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    argv += (optind - 1);
+    argc -= (optind - 1);
+
+    if (argc > 3)
+	usage(FALSE);
+
+    my_out = initialize((argc > 1) ? argv[1] : "vt100", stdout);
+    my_err = initialize((argc > 2) ? argv[2] : "ansi", stderr);
+
+    do_stuff(my_out);
+    do_stuff(my_err);
+
+    if (my_out != my_err) {
+	cleanup(my_out);
+	cleanup(my_err);
+    } else {
+	cleanup(my_out);
+    }
+
+    ExitProgram(EXIT_SUCCESS);
+}
+#else
+int
+main(void)
+{
+    fprintf(stderr,
+	    "This program requires the low-level ncurses sp-funcs tputs_sp\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
diff --git a/test/tclock.c b/test/tclock.c
index 96e1d19..1a74962 100644
--- a/test/tclock.c
+++ b/test/tclock.c
@@ -1,22 +1,12 @@
-/* $Id: tclock.c,v 1.34 2014/08/02 16:37:03 tom Exp $ */
+/* $Id: tclock.c,v 1.48 2023/02/25 16:42:22 tom Exp $ */
 
+#define NEED_TIME_H
 #include <test.priv.h>
 
-#if HAVE_MATH_H
+#if HAVE_MATH_H && HAVE_MATH_FUNCS
 
 #include <math.h>
 
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
 /*
   tclock - analog/digital clock for curses.
   If it gives you joy, then
@@ -58,7 +48,7 @@
     MvAddCh(y, x, (chtype) col);
 }
 
-/* Draw a diagonal(arbitrary) line using Bresenham's alogrithm. */
+/* Draw a diagonal(arbitrary) line using Bresenham's algorithm. */
 static void
 dline(int pair, int from_x, int from_y, int x2, int y2, int ch)
 {
@@ -116,9 +106,35 @@
     }
 }
 
-int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+static void
+usage(int ok)
 {
+    static const char *msg[] =
+    {
+	"Usage: tclock [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+#if HAVE_USE_DEFAULT_COLORS
+	," -d       invoke use_default_colors"
+#endif
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    static TimeType initial;
+
     int i, cx, cy;
     double cr, mradius, hradius, mangle, hangle;
     double sangle, sradius, hours;
@@ -130,13 +146,31 @@
     bool odd = FALSE;
     time_t tim;
     struct tm *t;
-    char szChar[10];
+    char szChar[20];
     char *text;
     short my_bg = COLOR_BLACK;
-#if HAVE_GETTIMEOFDAY
-    struct timeval current;
+    TimeType current;
+#if HAVE_USE_DEFAULT_COLORS
+    bool d_option = FALSE;
 #endif
-    double fraction = 0.0;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "d")) != -1) {
+	switch (ch) {
+#if HAVE_USE_DEFAULT_COLORS
+	case 'd':
+	    d_option = TRUE;
+	    break;
+#endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
 
     setlocale(LC_ALL, "");
 
@@ -149,7 +183,7 @@
     if (has_colors()) {
 	start_color();
 #if HAVE_USE_DEFAULT_COLORS
-	if (use_default_colors() == OK)
+	if (d_option && (use_default_colors() == OK))
 	    my_bg = -1;
 #endif
 	init_pair(1, COLOR_RED, my_bg);
@@ -175,7 +209,7 @@
 	sangle = (i + 1) * (2.0 * PI) / 12.0;
 	sdx = A2X(sangle, sradius);
 	sdy = A2Y(sangle, sradius);
-	sprintf(szChar, "%d", i + 1);
+	_nc_SPRINTF(szChar, _nc_SLIMIT(sizeof(szChar)) "%d", i + 1);
 
 	MvAddStr(cy - sdy, cx + sdx, szChar);
     }
@@ -201,11 +235,9 @@
 	hdx = A2X(hangle, hradius);
 	hdy = A2Y(hangle, hradius);
 
-#if HAVE_GETTIMEOFDAY
-	gettimeofday(&current, 0);
-	fraction = ((double) current.tv_usec / 1.0e6);
-#endif
-	sangle = ((t->tm_sec + fraction) * (2.0 * PI) / 60.0);
+	GetClockTime(&current);
+
+	sangle = (ElapsedSeconds(&initial, &current) * (2.0 * PI) / 60.0);
 	sdx = A2X(sangle, sradius);
 	sdy = A2Y(sangle, sradius);
 
@@ -254,15 +286,14 @@
 
     }
 
-    curs_set(1);
-    endwin();
+    stop_curses();
     ExitProgram(EXIT_SUCCESS);
 }
 #else
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(void)
 {
-    printf("This program requires the development header math.h\n");
+    printf("This program requires the header math.h and trignometric functions\n");
     ExitProgram(EXIT_FAILURE);
 }
 #endif
diff --git a/test/terminal.xbm b/test/terminal.xbm
new file mode 100644
index 0000000..b8d9204
--- /dev/null
+++ b/test/terminal.xbm
@@ -0,0 +1,52 @@
+/*****************************************************************************/
+/**       Copyright 1988 by Evans & Sutherland Computer Corporation,        **/
+/**                          Salt Lake City, Utah                           **/
+/**                                                                         **/
+/**                           All Rights Reserved                           **/
+/**                                                                         **/
+/**    Permission to use, copy, modify, and distribute this software and    **/
+/**    its documentation  for  any  purpose  and  without  fee is hereby    **/
+/**    granted, provided that the above copyright notice appear  in  all    **/
+/**    copies and that both  that  copyright  notice  and  this  permis-    **/
+/**    sion  notice appear in supporting  documentation,  and  that  the    **/
+/**    name  of Evans & Sutherland  not be used in advertising or publi-    **/
+/**    city pertaining to distribution  of the software without  specif-    **/
+/**    ic, written prior permission.                                        **/
+/**                                                                         **/
+/**    EVANS  & SUTHERLAND  DISCLAIMS  ALL  WARRANTIES  WITH  REGARD  TO    **/
+/**    THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILI-    **/
+/**    TY AND FITNESS, IN NO EVENT SHALL EVANS &  SUTHERLAND  BE  LIABLE    **/
+/**    FOR  ANY  SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY  DAM-    **/
+/**    AGES  WHATSOEVER RESULTING FROM  LOSS OF USE,  DATA  OR  PROFITS,    **/
+/**    WHETHER   IN  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS    **/
+/**    ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE  OR PER-    **/
+/**    FORMANCE OF THIS SOFTWARE.                                           **/
+/*****************************************************************************/
+
+#define xterm_width 48
+#define xterm_height 48
+static char xterm_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x00,
+   0x20, 0x00, 0x00, 0x00, 0x00, 0x03, 0x20, 0xfe, 0xff, 0xff, 0x1f, 0x05,
+   0x20, 0x01, 0x00, 0x00, 0x20, 0x09, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x11,
+   0xa0, 0xfc, 0xff, 0x00, 0x40, 0x21, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x21,
+   0xa0, 0xfc, 0x01, 0x00, 0x40, 0x21, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x21,
+   0xa0, 0xfc, 0xff, 0x3f, 0x40, 0x21, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x21,
+   0xa0, 0xfc, 0x03, 0x00, 0x40, 0x21, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x21,
+   0xa0, 0xfc, 0xff, 0x01, 0x40, 0x21, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x21,
+   0xa0, 0xfc, 0x00, 0x00, 0x40, 0x21, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x21,
+   0xa0, 0x00, 0x00, 0x00, 0x40, 0x21, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x21,
+   0xa0, 0x00, 0x00, 0x00, 0x40, 0x21, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x21,
+   0xa0, 0x00, 0x00, 0x00, 0x40, 0x21, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x21,
+   0xa0, 0x00, 0x00, 0x00, 0x40, 0x21, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x11,
+   0xa0, 0x00, 0x00, 0x00, 0x40, 0x11, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x09,
+   0xa0, 0x00, 0x00, 0x00, 0x40, 0x09, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x05,
+   0x20, 0x01, 0x00, 0x00, 0x20, 0x05, 0x20, 0xfe, 0xff, 0xff, 0x1f, 0x03,
+   0x20, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0xc0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x20, 0x00, 0x00, 0x00, 0x00, 0x03,
+   0xa0, 0xaa, 0xaa, 0xaa, 0x2a, 0x03, 0x10, 0x00, 0x00, 0x00, 0x80, 0x02,
+   0x50, 0x55, 0x55, 0x55, 0x95, 0x02, 0x08, 0x00, 0x00, 0x00, 0x40, 0x02,
+   0xa8, 0xaa, 0xaa, 0xaa, 0x4a, 0x02, 0x04, 0x00, 0x00, 0x00, 0x20, 0x01,
+   0xb4, 0xff, 0xff, 0xff, 0xad, 0x00, 0x02, 0x00, 0x00, 0x00, 0x50, 0x00,
+   0xfe, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/test/test.priv.h b/test/test.priv.h
index eedf201..a901185 100644
--- a/test/test.priv.h
+++ b/test/test.priv.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 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            *
@@ -29,7 +30,7 @@
 /****************************************************************************
  *  Author: Thomas E. Dickey                    1996-on                     *
  ****************************************************************************/
-/* $Id: test.priv.h,v 1.131 2014/10/25 01:20:34 tom Exp $ */
+/* $Id: test.priv.h,v 1.218 2024/02/10 14:40:03 tom Exp $ */
 
 #ifndef __TEST_PRIV_H
 #define __TEST_PRIV_H 1
@@ -58,22 +59,58 @@
 /*
  * Fallback definitions to accommodate broken compilers.
  */
+#ifndef HAVE_ALLOC_PAIR
+#define HAVE_ALLOC_PAIR 0
+#endif
+
 #ifndef HAVE_ASSUME_DEFAULT_COLORS
 #define HAVE_ASSUME_DEFAULT_COLORS 0
 #endif
 
-#ifndef HAVE_CURSES_VERSION
-#define HAVE_CURSES_VERSION 0
+#ifndef HAVE_CFMAKERAW
+#define HAVE_CFMAKERAW 0
 #endif
 
 #ifndef HAVE_CHGAT
 #define HAVE_CHGAT 0
 #endif
 
+#ifndef HAVE_CLOCK_GETTIME
+#define HAVE_CLOCK_GETTIME 0
+#endif
+
+#ifndef HAVE_COLOR_CONTENT
+#define HAVE_COLOR_CONTENT 0
+#endif
+
+#ifndef HAVE_COPYWIN
+#define HAVE_COPYWIN 0
+#endif
+
 #ifndef HAVE_COLOR_SET
 #define HAVE_COLOR_SET 0
 #endif
 
+#ifndef HAVE_BSD_STRING_H
+#define HAVE_BSD_STRING_H 0
+#endif
+
+#ifndef HAVE_CURSES_VERSION
+#define HAVE_CURSES_VERSION 0
+#endif
+
+#ifndef HAVE_CURSCR
+#define HAVE_CURSCR 0
+#endif
+
+#ifndef HAVE_DELSCREEN
+#define HAVE_DELSCREEN 0
+#endif
+
+#ifndef HAVE_DUPWIN
+#define HAVE_DUPWIN 0
+#endif
+
 #ifndef HAVE_FILTER
 #define HAVE_FILTER 0
 #endif
@@ -94,6 +131,10 @@
 #define HAVE_GETMAXX 0
 #endif
 
+#ifndef HAVE_GETTIMEOFDAY
+#define HAVE_GETTIMEOFDAY 0
+#endif
+
 #ifndef HAVE_GETOPT_H
 #define HAVE_GETOPT_H 0
 #endif
@@ -106,6 +147,14 @@
 #define HAVE_GETWIN 0
 #endif
 
+#ifndef HAVE_HALFDELAY
+#define HAVE_HALFDELAY 0
+#endif
+
+#ifndef HAVE_INIT_EXTENDED_COLOR
+#define HAVE_INIT_EXTENDED_COLOR 0
+#endif
+
 #ifndef HAVE_LIBFORM
 #define HAVE_LIBFORM 0
 #endif
@@ -118,10 +167,18 @@
 #define HAVE_LIBPANEL 0
 #endif
 
+#ifndef HAVE_LANGINFO_CODESET
+#define HAVE_LANGINFO_CODESET 0
+#endif
+
 #ifndef HAVE_LOCALE_H
 #define HAVE_LOCALE_H 0
 #endif
 
+#ifndef HAVE_MATH_FUNCS
+#define HAVE_MATH_FUNCS 0
+#endif
+
 #ifndef HAVE_MATH_H
 #define HAVE_MATH_H 0
 #endif
@@ -130,10 +187,18 @@
 #define HAVE_MENU_H 0
 #endif
 
+#ifndef HAVE_MVDERWIN
+#define HAVE_MVDERWIN 0
+#endif
+
 #ifndef HAVE_MVVLINE
 #define HAVE_MVVLINE 0
 #endif
 
+#ifndef HAVE_MVWIN
+#define HAVE_MVWIN 0
+#endif
+
 #ifndef HAVE_MVWVLINE
 #define HAVE_MVWVLINE 0
 #endif
@@ -146,6 +211,10 @@
 #define HAVE_NC_ALLOC_H 0
 #endif
 
+#ifndef HAVE_NEWPAD
+#define HAVE_NEWPAD 0
+#endif
+
 #ifndef HAVE_PANEL_H
 #define HAVE_PANEL_H 0
 #endif
@@ -154,10 +223,18 @@
 #define HAVE_PUTWIN 0
 #endif
 
+#ifndef HAVE_RESET_COLOR_PAIRS
+#define HAVE_RESET_COLOR_PAIRS 0
+#endif
+
 #ifndef HAVE_RESIZE_TERM
 #define HAVE_RESIZE_TERM 0
 #endif
 
+#ifndef HAVE_RESTARTTERM
+#define HAVE_RESTARTTERM 0
+#endif
+
 #ifndef HAVE_RIPOFFLINE
 #define HAVE_RIPOFFLINE 0
 #endif
@@ -178,6 +255,18 @@
 #define HAVE_SLK_INIT 0
 #endif
 
+#ifndef HAVE_STDINT_H
+#define HAVE_STDINT_H 0
+#endif
+
+#ifndef HAVE_STDNORETURN_H
+#define HAVE_STDNORETURN_H 0
+#endif
+
+#ifndef HAVE_STRSTR
+#define HAVE_STRSTR 0
+#endif
+
 #ifndef HAVE_SYS_IOCTL_H
 #define HAVE_SYS_IOCTL_H 0
 #endif
@@ -214,6 +303,26 @@
 #define HAVE_TIGETSTR 0
 #endif
 
+#ifndef HAVE_TIPARM
+#define HAVE_TIPARM 0
+#endif
+
+#ifndef HAVE_TIPARM_S
+#define HAVE_TIPARM_S 0
+#endif
+
+#ifndef HAVE_TISCAN_S
+#define HAVE_TISCAN_S 0
+#endif
+
+#ifndef HAVE_TPUTS_SP
+#define HAVE_TPUTS_SP 0
+#endif
+
+#ifndef HAVE_TSEARCH
+#define HAVE_TSEARCH 0
+#endif
+
 #ifndef HAVE_TYPEAHEAD
 #define HAVE_TYPEAHEAD 0
 #endif
@@ -222,6 +331,10 @@
 #define HAVE_WINSSTR 0
 #endif
 
+#ifndef HAVE_UNGET_WCH
+#define HAVE_UNGET_WCH 0
+#endif
+
 #ifndef HAVE_USE_DEFAULT_COLORS
 #define HAVE_USE_DEFAULT_COLORS 0
 #endif
@@ -250,10 +363,18 @@
 #define HAVE_VID_PUTS 0
 #endif
 
+#ifndef HAVE_WINSDELLN
+#define HAVE_WINSDELLN 0
+#endif
+
 #ifndef HAVE_WRESIZE
 #define HAVE_WRESIZE 0
 #endif
 
+#ifndef HAVE__TRACEF
+#define HAVE__TRACEF 0
+#endif
+
 #ifndef NCURSES_EXT_FUNCS
 #define NCURSES_EXT_FUNCS 0
 #endif
@@ -270,6 +391,10 @@
 #define NO_LEAKS 0
 #endif
 
+#ifndef HAVE__NC_TPARM_ANALYZE
+#define HAVE__NC_TPARM_ANALYZE 0
+#endif
+
 /*
  * Workaround for HPUX
  */
@@ -306,6 +431,16 @@
 #include <curses.h>
 #endif
 
+#if HAVE_STDNORETURN_H && !defined(NCURSES_VERSION)
+#include <stdnoreturn.h>
+#undef GCC_NORETURN
+#define GCC_NORETURN _Noreturn
+#endif
+
+#if !(defined(NCURSES_WGETCH_EVENTS) && defined(NEED_KEY_EVENT))
+#undef KEY_EVENT		/* reduce compiler-warnings with Visual C++ */
+#endif
+
 #if defined(HAVE_XCURSES) || defined(PDCURSES)
 /* no other headers */
 #undef  HAVE_SETUPTERM		/* nonfunctional */
@@ -352,12 +487,29 @@
 #include <assert.h>
 #include <ctype.h>
 
+#if HAVE_STDINT_H
+#include <stdint.h>
+#define my_intptr_t	intptr_t
+#else
+#define my_intptr_t	long
+#endif
+
+#if defined(_MSC_VER)
+#undef popen
+#define popen(s,n) _popen(s,n)
+#undef pclose
+#define pclose(s) _pclose(s)
+#endif
+
 #ifndef GCC_NORETURN
 #define GCC_NORETURN		/* nothing */
 #endif
 #ifndef GCC_PRINTFLIKE
 #define GCC_PRINTFLIKE(a,b)	/* nothing */
 #endif
+#ifndef GCC_SCANFLIKE
+#define GCC_SCANFLIKE(a,b)	/* nothing */
+#endif
 #ifndef GCC_UNUSED
 #define GCC_UNUSED		/* nothing */
 #endif
@@ -366,6 +518,12 @@
 #define getnstr(s,n) getstr(s)
 #endif
 
+#if HAVE_INIT_EXTENDED_COLOR
+#define USE_EXTENDED_COLOR 1
+#else
+#define USE_EXTENDED_COLOR 0
+#endif
+
 #ifndef USE_SOFTKEYS
 #if HAVE_SLK_INIT
 #define USE_SOFTKEYS 1
@@ -380,6 +538,24 @@
 #define slk_clear()		/* nothing */
 #endif
 
+#ifndef HAVE_CURSES_DATA_TABSIZE
+#define HAVE_CURSES_DATA_TABSIZE 0
+#endif
+
+#if !NCURSES_EXT_FUNCS
+#if HAVE_CURSES_DATA_TABSIZE
+#define set_tabsize(n)	TABSIZE = (n)
+#else
+#define set_tabsize(n)		/* nothing */
+#endif
+#endif
+
+#if HAVE_TPUTS_SP
+#define USE_SP_FUNCS 1
+#else
+#define USE_SP_FUNCS 0
+#endif
+
 #ifndef HAVE_WSYNCDOWN
 #define wsyncdown(win)		/* nothing */
 #endif
@@ -415,9 +591,13 @@
 
 /* workaround, to build against NetBSD's variant of the form library */
 #ifdef HAVE_NETBSD_FORM_H
-#define form_getyx(form, y, x) y = current_field(form)->cursor_ypos, x = current_field(form)->cursor_xpos
-#else
-#define form_getyx(form, y, x) y = (form)->currow, x = (form)->curcol
+#define form_getyx(form, y, x) y = (int)current_field(form)->cursor_ypos, x = (int)current_field(form)->cursor_xpos
+#define form_field_row(field) (field)->form_row
+#define form_field_col(field) (field)->form_col
+#else /* e.g., SVr4, ncurses */
+#define form_getyx(form, y, x) y = (int)(form)->currow, x = (int)(form)->curcol
+#define form_field_row(field) (field)->frow
+#define form_field_col(field) (field)->fcol
 #endif
 
 /* workaround, to build against NetBSD's variant of the form library */
@@ -448,10 +628,6 @@
 #define NCURSES_PAIRS_T short
 #endif
 
-#ifndef NCURSES_OPAQUE
-#define NCURSES_OPAQUE 0
-#endif
-
 #ifndef CCHARW_MAX
 #define CCHARW_MAX 5
 #endif
@@ -495,38 +671,62 @@
 #undef	WACS_NEQUAL
 #undef	WACS_STERLING
 
-#define	WACS_RARROW     &(CURSES_WACS_ARRAY['+'])
-#define	WACS_LARROW     &(CURSES_WACS_ARRAY[','])
-#define	WACS_UARROW     &(CURSES_WACS_ARRAY['-'])
-#define	WACS_DARROW     &(CURSES_WACS_ARRAY['.'])
-#define	WACS_BLOCK      &(CURSES_WACS_ARRAY['0'])
-#define	WACS_DIAMOND    &(CURSES_WACS_ARRAY['`'])
-#define	WACS_CKBOARD    &(CURSES_WACS_ARRAY['a'])
-#define	WACS_DEGREE     &(CURSES_WACS_ARRAY['f'])
-#define	WACS_PLMINUS    &(CURSES_WACS_ARRAY['g'])
-#define	WACS_BOARD      &(CURSES_WACS_ARRAY['h'])
-#define	WACS_LANTERN    &(CURSES_WACS_ARRAY['i'])
-#define	WACS_LRCORNER   &(CURSES_WACS_ARRAY['j'])
-#define	WACS_URCORNER   &(CURSES_WACS_ARRAY['k'])
-#define	WACS_ULCORNER   &(CURSES_WACS_ARRAY['l'])
-#define	WACS_LLCORNER   &(CURSES_WACS_ARRAY['m'])
-#define	WACS_PLUS       &(CURSES_WACS_ARRAY['n'])
-#define	WACS_HLINE      &(CURSES_WACS_ARRAY['q'])
-#define	WACS_S1         &(CURSES_WACS_ARRAY['o'])
-#define	WACS_S9         &(CURSES_WACS_ARRAY['s'])
-#define	WACS_LTEE       &(CURSES_WACS_ARRAY['t'])
-#define	WACS_RTEE       &(CURSES_WACS_ARRAY['u'])
-#define	WACS_BTEE       &(CURSES_WACS_ARRAY['v'])
-#define	WACS_TTEE       &(CURSES_WACS_ARRAY['w'])
-#define	WACS_VLINE      &(CURSES_WACS_ARRAY['x'])
-#define	WACS_BULLET     &(CURSES_WACS_ARRAY['~'])
-#define	WACS_S3		&(CURSES_WACS_ARRAY['p'])
-#define	WACS_S7		&(CURSES_WACS_ARRAY['r'])
-#define	WACS_LEQUAL	&(CURSES_WACS_ARRAY['y'])
-#define	WACS_GEQUAL	&(CURSES_WACS_ARRAY['z'])
-#define	WACS_PI		&(CURSES_WACS_ARRAY['{'])
-#define	WACS_NEQUAL	&(CURSES_WACS_ARRAY['|'])
-#define	WACS_STERLING	&(CURSES_WACS_ARRAY['}'])
+#define WACS_RARROW     &(CURSES_WACS_ARRAY['+'])
+#define WACS_LARROW     &(CURSES_WACS_ARRAY[','])
+#define WACS_UARROW     &(CURSES_WACS_ARRAY['-'])
+#define WACS_DARROW     &(CURSES_WACS_ARRAY['.'])
+#define WACS_BLOCK      &(CURSES_WACS_ARRAY['0'])
+#define WACS_DIAMOND    &(CURSES_WACS_ARRAY['`'])
+#define WACS_CKBOARD    &(CURSES_WACS_ARRAY['a'])
+#define WACS_DEGREE     &(CURSES_WACS_ARRAY['f'])
+#define WACS_PLMINUS    &(CURSES_WACS_ARRAY['g'])
+#define WACS_BOARD      &(CURSES_WACS_ARRAY['h'])
+#define WACS_LANTERN    &(CURSES_WACS_ARRAY['i'])
+#define WACS_LRCORNER   &(CURSES_WACS_ARRAY['j'])
+#define WACS_URCORNER   &(CURSES_WACS_ARRAY['k'])
+#define WACS_ULCORNER   &(CURSES_WACS_ARRAY['l'])
+#define WACS_LLCORNER   &(CURSES_WACS_ARRAY['m'])
+#define WACS_PLUS       &(CURSES_WACS_ARRAY['n'])
+#define WACS_HLINE      &(CURSES_WACS_ARRAY['q'])
+#define WACS_S1         &(CURSES_WACS_ARRAY['o'])
+#define WACS_S9         &(CURSES_WACS_ARRAY['s'])
+#define WACS_LTEE       &(CURSES_WACS_ARRAY['t'])
+#define WACS_RTEE       &(CURSES_WACS_ARRAY['u'])
+#define WACS_BTEE       &(CURSES_WACS_ARRAY['v'])
+#define WACS_TTEE       &(CURSES_WACS_ARRAY['w'])
+#define WACS_VLINE      &(CURSES_WACS_ARRAY['x'])
+#define WACS_BULLET     &(CURSES_WACS_ARRAY['~'])
+#define WACS_S3         &(CURSES_WACS_ARRAY['p'])
+#define WACS_S7         &(CURSES_WACS_ARRAY['r'])
+#define WACS_LEQUAL     &(CURSES_WACS_ARRAY['y'])
+#define WACS_GEQUAL     &(CURSES_WACS_ARRAY['z'])
+#define WACS_PI         &(CURSES_WACS_ARRAY['{'])
+#define WACS_NEQUAL     &(CURSES_WACS_ARRAY['|'])
+#define WACS_STERLING   &(CURSES_WACS_ARRAY['}'])
+#endif
+
+#ifndef WA_NORMAL
+#define WA_NORMAL       A_NORMAL
+#endif
+#ifndef WA_BOLD
+#define WA_BOLD         A_BOLD
+#endif
+#ifndef WA_REVERSE
+#define WA_REVERSE      A_REVERSE
+#endif
+#ifndef WA_UNDERLINE
+#define WA_UNDERLINE    A_UNDERLINE
+#endif
+#ifndef WA_BLINK
+#define WA_BLINK        A_BLINK
+#endif
+
+#ifndef OK
+#define OK (0)
+#endif
+
+#ifndef ERR
+#define ERR (-1)
 #endif
 
 #undef CTRL
@@ -539,12 +739,162 @@
 #define KEY_MIN 256		/* not defined in Solaris 8 */
 #endif
 
+#define HELP_KEY_1	'?'
+#define HELP_KEY_2	KEY_F(1)
+
+/* our "standard" options for getopt, needed for help2man */
+#define OPTS_USAGE	'h'
+#define OPTS_VERSION	'V'
+#define OPTS_COMMON	"hV"
+#define USAGE_COMMON	\
+ "Common options:"\
+," -h       show this message"\
+," -V       show version of curses"
+
+#if HAVE_CURSES_VERSION
+#define format_version(buffer, size) strcpy(buffer, curses_version())
+#elif defined(NCURSES_VERSION_MAJOR) && defined(NCURSES_VERSION_MINOR) && defined(NCURSES_VERSION_PATCH)
+#define format_version(buffer, size) \
+	_nc_SPRINTF(buffer, _nc_SLIMIT(size) "ncurses %d.%d.%d", \
+		    NCURSES_VERSION_MAJOR, \
+		    NCURSES_VERSION_MINOR, \
+		    NCURSES_VERSION_PATCH)
+#else
+#define format_version(buffer, size) strcpy(buffer, "ncurses-examples")
+#endif
+
+#define VERSION_COMMON() \
+static char *version_common(char **argv) { \
+	char *base = argv[0]; \
+	char *part = strrchr(base, '/'); \
+	size_t need = strlen(base) + 80; \
+	char *result = malloc(need); \
+	if (result != NULL) { \
+	    if (part++ == NULL) part = base; \
+	    _nc_SPRINTF(result, _nc_SLIMIT(need) "%.20s: ", part); \
+	    format_version(result + strlen(result), need - strlen(result)); \
+	} \
+	return result; \
+} \
+static void show_version(char **argv) { \
+	char *value = version_common(argv); \
+	if (value != NULL) { \
+	    puts(value); \
+	    free(value); \
+	} \
+}
+
+/* from nc_string.h, to make this stand alone */
+#if HAVE_BSD_STRING_H
+#include <bsd/string.h>
+#endif
+
+#ifdef __cplusplus
+#define NCURSES_VOID		/* nothing */
+#else
+#define NCURSES_VOID (void)
+#endif
+
+#ifndef HAVE_STRLCAT
+#define HAVE_STRLCAT 0
+#endif
+
+#ifndef HAVE_STRLCPY
+#define HAVE_STRLCPY 0
+#endif
+
+#ifndef HAVE_SNPRINTF
+#define HAVE_SNPRINTF 0
+#endif
+
+#ifndef HAVE_STRDUP
+#define HAVE_STRDUP 0
+#endif
+
+#ifndef USE_STRING_HACKS
+#define USE_STRING_HACKS 0
+#endif
+
+#ifndef HAVE_STRSTR
+#define HAVE_STRSTR 0
+#endif
+
+#ifndef NCURSES_CAST
+#ifdef __cplusplus
+extern "C" {
+#define NCURSES_CAST(type,value) static_cast<type>(value)
+#else
+#define NCURSES_CAST(type,value) (type)(value)
+#endif
+#endif
+
+#if USE_STRING_HACKS && HAVE_STRLCAT
+#define _nc_STRCAT(d,s,n)	NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,n))
+#define _nc_STRNCAT(d,s,m,n)	NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,m))
+#else
+#define _nc_STRCAT(d,s,n)	NCURSES_VOID strcat((d),(s))
+#define _nc_STRNCAT(d,s,m,n)	NCURSES_VOID strncat((d),(s),(n))
+#endif
+
+#if USE_STRING_HACKS && HAVE_STRLCPY
+#define _nc_STRCPY(d,s,n)	NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
+#define _nc_STRNCPY(d,s,n)	NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
+#else
+#define _nc_STRCPY(d,s,n)	NCURSES_VOID strcpy((d),(s))
+#define _nc_STRNCPY(d,s,n)	NCURSES_VOID strncpy((d),(s),(n))
+#endif
+
+#if USE_STRING_HACKS && HAVE_SNPRINTF
+#define _nc_SPRINTF             NCURSES_VOID (snprintf)
+#define _nc_SLIMIT(n)           NCURSES_CAST(size_t,n),
+#else
+#define _nc_SPRINTF             NCURSES_VOID (sprintf)
+#define _nc_SLIMIT(n)		/* nothing */
+#endif
+
+/*
+ * X/Open Curses does not define the arrays of terminfo/termcap names as SVr4
+ * curses did, and some implementations provide them anyway, but undeclared.
+ */
 #ifdef DECL_CURSES_DATA_BOOLNAMES
 extern char *boolnames[], *boolcodes[], *boolfnames[];
 extern char *numnames[], *numcodes[], *numfnames[];
 extern char *strnames[], *strcodes[], *strfnames[];
 #endif
 
+/*
+ * Again, an SVr4 curses feature latent in the libraries but not in headers.
+ */
+#ifndef DECL_CURSES_DATA_TABSIZE
+#define DECL_CURSES_DATA_TABSIZE 0
+#endif
+
+#if DECL_CURSES_DATA_TABSIZE
+extern int TABSIZE;
+#undef  HAVE_CURSES_DATA_TABSIZE
+#define HAVE_CURSES_DATA_TABSIZE 1
+#endif
+
+#ifndef HAVE_CURSES_DATA_TABSIZE
+#define HAVE_CURSES_DATA_TABSIZE 0
+#endif
+
+/*
+ * X/Open Curses provides termname(), whose return value is analogous to the
+ * SVr4 curses variable ttytype[].
+ */
+#ifndef HAVE_CURSES_DATA_TTYTYPE
+#define HAVE_CURSES_DATA_TTYTYPE 0
+#endif
+
+#ifndef DECL_CURSES_DATA_TTYTYPE
+#define DECL_CURSES_DATA_TTYTYPE 0
+#endif
+
+#if !defined(ttytype) && (!HAVE_CURSES_DATA_TTYTYPE || DECL_CURSES_DATA_TTYTYPE)
+#define ttytype termname()
+#endif
+
 #define colored_chtype(ch, attr, pair) \
 	((chtype) (ch) | (chtype) (attr) | (chtype) COLOR_PAIR(pair))
 
@@ -585,18 +935,18 @@
  * These usually are implemented as macros, but may be functions.
  */
 #if !defined(getcurx) && !HAVE_GETCURX
-#define getcurx(win)            ((win)?(win)->_curx:ERR)
-#define getcury(win)            ((win)?(win)->_cury:ERR)
+#define getcurx(win)            ((win) ? ((int)(win)->_curx) : ERR)
+#define getcury(win)            ((win) ? ((int)(win)->_cury) : ERR)
 #endif
 
 #if !defined(getbegx) && !HAVE_GETBEGX
-#define getbegx(win)            ((win)?(win)->_begx:ERR)
-#define getbegy(win)            ((win)?(win)->_begy:ERR)
+#define getbegx(win)            ((win) ? ((int)(win)->_begx) : ERR)
+#define getbegy(win)            ((win) ? ((int)(win)->_begy) : ERR)
 #endif
 
 #if !defined(getmaxx) && !HAVE_GETMAXX
-#define getmaxx(win)            ((win)?((win)->_maxx + 1):ERR)
-#define getmaxy(win)            ((win)?((win)->_maxy + 1):ERR)
+#define getmaxx(win)            ((win) ? ((int)(win)->_maxx + 1) : ERR)
+#define getmaxy(win)            ((win) ? ((int)(win)->_maxy + 1) : ERR)
 #endif
 
 /*
@@ -650,6 +1000,15 @@
 #define NCURSES_XNAMES 0
 #endif
 
+/*
+ * ncurses restores the cursor in endwin().  Other libraries may not.
+ */
+#ifdef NCURSES_VERSION
+#define stop_curses() endwin()
+#else
+#define stop_curses() do { endwin(); curs_set(1); } while (0)
+#endif
+
 /* ncurses implements tparm() with varargs, X/Open with a fixed-parameter list
  * (which is incompatible with legacy usage, doesn't solve any problems).
  */
@@ -658,15 +1017,20 @@
 
 #define UChar(c)    ((unsigned char)(c))
 
+#ifndef SIZEOF
 #define SIZEOF(table)	(sizeof(table)/sizeof(table[0]))
+#endif
 
 #if defined(NCURSES_VERSION) && HAVE_NC_ALLOC_H
 #include <nc_alloc.h>
-#if HAVE_NC_FREEALL && defined(USE_TINFO)
+#if HAVE_EXIT_TERMINFO && !defined(USE_CURSES) && (defined(USE_TERMINFO) || defined(USE_TINFO))
 #undef ExitProgram
-#define ExitProgram(code) _nc_free_tinfo(code)
+#define ExitProgram(code) exit_terminfo(code)
+#elif HAVE_EXIT_CURSES
+#undef ExitProgram
+#define ExitProgram(code) exit_curses(code)
 #endif
-#else
+#else /* not ncurses-tree */
 #define typeMalloc(type,n) (type *) malloc((size_t)(n) * sizeof(type))
 #define typeCalloc(type,elts) (type *) calloc((size_t)(elts), sizeof(type))
 #define typeRealloc(type,n,p) (type *) realloc(p, (size_t)(n) * sizeof(type))
@@ -683,7 +1047,12 @@
 #define EXIT_FAILURE 1
 #endif
 
-#if defined(__MINGW32__) || defined(USE_WIN32CON_DRIVER)
+#undef _NC_WINDOWS
+#if (defined(_WIN32) || defined(_WIN64))
+#define _NC_WINDOWS 1
+#endif
+
+#if defined(_NC_WINDOWS) || defined(USE_WIN32CON_DRIVER)
 
 #if defined(PDCURSES)
 #ifdef WINVER
@@ -701,7 +1070,19 @@
 #define SIGKILL 9
 #define getlogin() "username"
 
-#elif defined(HAVE_NCURSESW_NCURSES_H)
+#elif defined(EXP_WIN32_DRIVER)
+
+#if defined(HAVE_NCURSESW_NCURSES_H)
+#include <ncursesw/nc_win32.h>
+#elif defined(HAVE_NCURSES_NCURSES_H)
+#include <ncurses/nc_win32.h>
+#else
+#include <nc_win32.h>
+#endif
+
+#else
+
+#if defined(HAVE_NCURSESW_NCURSES_H)
 #include <ncursesw/nc_mingw.h>
 #elif defined(HAVE_NCURSES_NCURSES_H)
 #include <ncurses/nc_mingw.h>
@@ -709,19 +1090,70 @@
 #include <nc_mingw.h>
 #endif
 
+#endif
+
 /* conflicts in test/firstlast.c */
 #undef large
 #undef small
 
 #endif
 
+#ifdef NEED_TIME_H
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+#endif
+
+#if HAVE_CLOCK_GETTIME
+# define GetClockTime(t) clock_gettime(CLOCK_REALTIME, t)
+# define TimeType struct timespec
+# define TimeScale 1000000000L	/* 1e9 */
+# define ElapsedSeconds(b,e) \
+	    (double) (((e)->tv_sec - (b)->tv_sec) \
+		    + ((e)->tv_nsec - (b)->tv_nsec) / TimeScale)
+#elif HAVE_GETTIMEOFDAY
+# define GetClockTime(t) gettimeofday(t, 0)
+# define TimeType struct timeval
+# define TimeScale 1000000L	/* 1e6 */
+# define ElapsedSeconds(b,e) \
+	    (double) (((e)->tv_sec - (b)->tv_sec) \
+		    + ((e)->tv_usec - (b)->tv_usec) / TimeScale)
+#else
+# define TimeType time_t
+# define GetClockTime(t) time((time_t*)0)
+# define ElapsedSeconds(b,e) (double)((e) - (b))
+#endif
+
+/*
+ * Ultrix 3.1
+ */
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
+
+#if !HAVE_STRSTR
+extern char *_nc_strstr(const char *, const char *);
+#define strstr(a,b) _nc_strstr((a),(b))
+#endif /* !HAVE_STRSTR */
+
 /* Use this to quiet gcc's -Wwrite-strings warnings, but accommodate SVr4
  * curses which doesn't have const parameters declared (so far) in the places
  * that XSI shows.
  */
 #ifndef NCURSES_CONST
+#ifdef PDCURSES
+#define NCURSES_CONST		const	/* close enough */
+#else
 #define NCURSES_CONST		/* nothing */
 #endif
+#endif
 
 /* out-of-band values for representing absent capabilities */
 #define ABSENT_BOOLEAN		((signed char)-1)	/* 255 */
@@ -739,12 +1171,24 @@
 
 #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
 
-#define CATCHALL(handler) { \
+#define CATCHALL(handler) do { \
 		int nsig; \
 		for (nsig = SIGHUP; nsig < SIGTERM; ++nsig) \
 		    if (nsig != SIGKILL) \
 			signal(nsig, handler); \
-	    }
+	    } while(0)
+
+#ifdef NCURSES_VERSION
+#define InitAndCatch(init,handler) do { CATCHALL(handler); init; } while (0)
+#else
+#define InitAndCatch(init,handler) do { init; CATCHALL(handler); } while (0)
+#endif
+
+#if defined(_NC_WINDOWS) || defined(USE_WIN32CON_DRIVER)
+#define SetupAlarm(opt)	(void)opt
+#else
+#define SetupAlarm(opt)	if (opt) alarm((unsigned)opt)
+#endif
 
 /*
  * Workaround for clean(er) compile with Solaris's legacy curses.
@@ -799,24 +1243,50 @@
 #endif
 
 /*
- * ncurses uses const in some places where X/Open does (or did) not allow.
+ * ncurses provides a termcap interface; a few packagers replace or displace
+ * its header file with an incompatible one.  The demo_termcap program uses
+ * the ncurses file, if available.
  */
 #ifdef NCURSES_VERSION
+#ifndef HAVE_NCURSES_TERMCAP_H
+#define HAVE_NCURSES_TERMCAP_H 0
+#endif
+#ifndef HAVE_TERMCAP_H
+#define HAVE_TERMCAP_H 0
+#endif
+#endif
+
+/*
+ * ncurses uses const in some places where X/Open does (or did) not allow.
+ */
+#if defined(NCURSES_CONST)
+#define CONST_MENUS NCURSES_CONST
+#elif defined(PDCURSES)
 #define CONST_MENUS const
 #else
 #define CONST_MENUS		/* nothing */
 #endif
 
+#if defined(NCURSES_CONST)
+#define CONST_FMT NCURSES_CONST
+#elif defined(PDCURSES)
+#define CONST_FMT const
+#else
+#define CONST_FMT		/* nothing */
+#endif
+
 /*
  * Simplify setting up demo of threading with these macros.
  */
 
 #if HAVE_USE_WINDOW
 #define USING_WINDOW(w,func) use_window(w, (NCURSES_WINDOW_CB) func, w)
+#define USING_WINDOW1(w,func,safe) use_window(w, (NCURSES_WINDOW_CB) safe, NULL)
 #define USING_WINDOW2(w,func,data) use_window(w, (NCURSES_WINDOW_CB) func, data)
 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
 #else
-#define USING_WINDOW(w,func) func(w)
+#define USING_WINDOW(w,func) func(w, NULL)
+#define USING_WINDOW1(w,func,safe) func(w)
 #define USING_WINDOW2(w,func,data) func(w,data)
 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
 #endif
@@ -829,35 +1299,47 @@
 #define WANT_USE_SCREEN() extern void _nc_want_use_screen(void)
 #endif
 
-#ifdef TRACE
+#if defined(TRACE) && HAVE__TRACEF && HAVE_CURSES_TRACE
 #define Trace(p) _tracef p
 #define USE_TRACE 1
+#define START_TRACE() \
+	if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \
+	    int t = _nc_getenv_num("NCURSES_TRACE"); \
+	    if (t >= 0) \
+		curses_trace((unsigned) t); \
+	}
+extern unsigned _nc_tracing;
+extern int _nc_getenv_num(const char *);
 #else
+#undef TRACE
 #define Trace(p)		/* nothing */
 #define USE_TRACE 0
+#define START_TRACE()		/* nothing */
 #endif
 
 #define Trace2(p)		/* nothing */
 
-#define MvAddCh         (void) mvaddch
-#define MvWAddCh        (void) mvwaddch
-#define MvAddStr        (void) mvaddstr
-#define MvWAddStr       (void) mvwaddstr
-#define MvWAddChStr     (void) mvwaddchstr
-#define MvPrintw        (void) mvprintw
-#define MvWPrintw       (void) mvwprintw
-#define MvHLine         (void) mvhline
-#define MvWHLine        (void) mvwhline
-#define MvVLine         (void) mvvline
-#define MvWVLine        (void) mvwvline
+#define AddCh(c)		(void) addch((chtype)(c))
+#define WAddCh(w,c)		(void) waddch((w),(chtype)(c))
+#define MvAddCh(y,x,c)		(void) mvaddch((y),(x),(chtype)(c))
+#define MvWAddCh(w,y,x,c)	(void) mvwaddch((w),(y),(x),(chtype)(c))
+#define MvAddStr(y,x,s)		(void) mvaddstr((y),(x),(s))
+#define MvWAddStr(w,y,x,s)	(void) mvwaddstr((w),(y),(x),(s))
+#define MvWAddChStr(w,y,x,s)	(void) mvwaddchstr((w),(y),(x),(s))
+#define MvPrintw		(void) mvprintw
+#define MvWPrintw		(void) mvwprintw
+#define MvHLine			(void) mvhline
+#define MvWHLine		(void) mvwhline
+#define MvVLine			(void) mvvline
+#define MvWVLine		(void) mvwvline
 
 /*
  * The macro likely uses unsigned values, while X/Open prototype uses int.
  */
 #if defined(wattrset) || defined(PDCURSES)
-#define AttrArg(p,a)    (attr_t) ((attr_t)(p) | (attr_t)(a))
+#define AttrArg(p,a)    (chtype) ((chtype)(p) | (chtype)(a))
 #else
-#define AttrArg(p,a)    (int) ((attr_t)(p) | (attr_t)(a))
+#define AttrArg(p,a)    (int) ((chtype)(p) | (chtype)(a))
 #endif
 
 /*
diff --git a/test/test_add_wchstr.c b/test/test_add_wchstr.c
index c59a339..f69e1dd 100644
--- a/test/test_add_wchstr.c
+++ b/test/test_add_wchstr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2010-2012,2014 Free Software Foundation, Inc.                   *
+ * Copyright 2020-2021,2022 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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_add_wchstr.c,v 1.21 2014/08/02 17:24:55 tom Exp $
+ * $Id: test_add_wchstr.c,v 1.34 2022/12/10 22:28:50 tom Exp $
  *
  * Demonstrate the waddwchstr() and wadd_wch functions.
  * Thomas Dickey - 2009/9/12
@@ -48,18 +49,24 @@
 #define WIDE_LINEDATA
 #include <linedata.h>
 
+#undef AddCh
 #undef MvAddCh
 #undef MvAddStr
 #undef MvWAddCh
+#undef MvWAddChStr
 #undef MvWAddStr
+#undef WAddCh
 
-/* definitions to make it simpler to compare with test_addstr.c */
+/*
+ * redefinitions to simplify comparison between test_*str programs
+ */
 #define AddNStr    add_wchnstr
 #define AddStr     add_wchstr
 #define MvAddNStr  (void) mvadd_wchnstr
 #define MvAddStr   (void) mvadd_wchstr
 #define MvWAddNStr (void) mvwadd_wchnstr
 #define MvWAddStr  (void) mvwadd_wchstr
+#define MvWAddChStr(w,y,x,s)	(void) mvwadd_wchstr((w),(y),(x),(s))
 #define WAddNStr   wadd_wchnstr
 #define WAddStr    wadd_wchstr
 
@@ -125,10 +132,11 @@
     if (!pass_ctls) {
 	size_t adjust = 0;
 	size_t n;
-	const char *s;
 
-	for (n = 0; n < result; ++n) {
-	    if (source[n] < 256 && (s = unctrl((chtype) source[n])) != 0) {
+	for (n = 0; source[n] != 0; ++n) {
+	    const char *s;
+
+	    if ((source[n] < 256) && (s = unctrl((chtype) source[n])) != 0) {
 		adjust += (strlen(s) - 1);
 	    }
 	}
@@ -183,7 +191,7 @@
 }
 
 static int
-ColOf(wchar_t *buffer, int length, int margin)
+ColOf(const wchar_t *buffer, int length, int margin)
 {
     int n;
     int result;
@@ -291,7 +299,7 @@
 
 #define LEN(n) ((length - (n) > n_opt) ? n_opt : (length - (n)))
 static void
-test_add_wchstr(int level)
+recursive_test(int level)
 {
     static bool first = TRUE;
 
@@ -306,14 +314,19 @@
     WINDOW *work = 0;
     WINDOW *show = 0;
     int margin = (2 * MY_TABSIZE) - 1;
-    Options option = ((m_opt ? oMove : oDefault)
-		      | ((w_opt || (level > 0)) ? oWindow : oDefault));
+    Options option = (Options) ((unsigned) (m_opt
+					    ? oMove
+					    : oDefault)
+				| (unsigned) ((w_opt || (level > 0))
+					      ? oWindow
+					      : oDefault));
 
     if (first) {
 	static char cmd[80];
 	setlocale(LC_ALL, "");
 
-	putenv(strcpy(cmd, "TABSIZE=8"));
+	_nc_STRCPY(cmd, "TABSIZE=8", sizeof(cmd));
+	putenv(cmd);
 
 	initscr();
 	(void) cbreak();	/* take input chars one at a time, no wait for \n */
@@ -351,8 +364,8 @@
     MvWVLine(work, row, margin + 1, ACS_VLINE, limit - 2);
     limit /= 2;
 
-    (void) mvwadd_wchstr(work, 1, 2, ChStr("String"));
-    (void) mvwadd_wchstr(work, limit + 1, 2, ChStr("Chars"));
+    MvWAddChStr(work, 1, 2, ChStr("String"));
+    MvWAddChStr(work, limit + 1, 2, ChStr("Chars"));
     wnoutrefresh(work);
 
     buffer[length = 0] = '\0';
@@ -369,7 +382,7 @@
 	wmove(work, row, margin + 1);
 	switch (ch) {
 	case key_RECUR:
-	    test_add_wchstr(level + 1);
+	    recursive_test(level + 1);
 
 	    if (look)
 		touchwin(look);
@@ -529,33 +542,37 @@
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *tbl[] =
     {
 	"Usage: test_add_wchstr [options]"
 	,""
+	,USAGE_COMMON
 	,"Options:"
-	,"  -f FILE read data from given file"
-	,"  -n NUM  limit string-adds to NUM bytes on ^N replay"
-	,"  -m      perform wmove/move separately from add-functions"
-	,"  -p      pass-thru control characters without using unctrl()"
-	,"  -w      use window-parameter even when stdscr would be implied"
+	," -f FILE  read data from given file"
+	," -n NUM   limit string-adds to NUM bytes on ^N replay"
+	," -m       perform wmove/move separately from add-functions"
+	," -p       pass-thru control characters without using unctrl()"
+	," -w       use window-parameter even when stdscr would be implied"
     };
     unsigned n;
     for (n = 0; n < SIZEOF(tbl); ++n)
 	fprintf(stderr, "%s\n", tbl[n]);
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     int ch;
 
     setlocale(LC_ALL, "");
 
-    while ((ch = getopt(argc, argv, "f:mn:pw")) != -1) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "f:mn:pw")) != -1) {
 	switch (ch) {
 	case 'f':
 	    init_linedata(optarg);
@@ -574,16 +591,22 @@
 	case 'w':
 	    w_opt = TRUE;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
-	    break;
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
     if (optind < argc)
-	usage();
+	usage(FALSE);
 
-    test_add_wchstr(0);
+    recursive_test(0);
     endwin();
+#if NO_LEAKS
+    free(temp_buffer);
+#endif
     ExitProgram(EXIT_SUCCESS);
 }
 #else
diff --git a/test/test_addchstr.c b/test/test_addchstr.c
index 2aae844..cddc315 100644
--- a/test/test_addchstr.c
+++ b/test/test_addchstr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2009-2010,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 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            *
@@ -26,16 +27,18 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_addchstr.c,v 1.18 2012/12/16 00:36:27 tom Exp $
+ * $Id: test_addchstr.c,v 1.29 2022/12/10 22:28:50 tom Exp $
  *
  * Demonstrate the waddchstr() and waddch functions.
  * Thomas Dickey - 2009/9/12
  */
 
 #include <test.priv.h>
-
 #include <linedata.h>
 
+/*
+ * redefinitions to simplify comparison between test_*str programs
+ */
 #undef MvAddStr
 #undef MvWAddStr
 
@@ -48,9 +51,6 @@
 #define WAddNStr   waddchnstr
 #define WAddStr    waddchstr
 
-#define AddCh      addch
-#define WAddCh     waddch
-
 #define MY_TABSIZE 8
 
 typedef enum {
@@ -65,7 +65,7 @@
 static bool w_opt = FALSE;
 static int n_opt = -1;
 
-static attr_t show_attr;
+static chtype show_attr;
 static chtype *temp_buffer;
 static size_t temp_length;
 
@@ -207,7 +207,7 @@
 
 #define LEN(n) ((length - (n) > n_opt) ? n_opt : (length - (n)))
 static void
-test_adds(int level)
+recursive_test(int level)
 {
     static bool first = TRUE;
 
@@ -233,7 +233,8 @@
 	static char cmd[80];
 	setlocale(LC_ALL, "");
 
-	putenv(strcpy(cmd, "TABSIZE=8"));
+	_nc_STRCPY(cmd, "TABSIZE=8", sizeof(cmd));
+	putenv(cmd);
 
 	initscr();
 	(void) cbreak();	/* take input chars one at a time, no wait for \n */
@@ -282,7 +283,7 @@
     doupdate();
 
     if (has_colors()) {
-	show_attr = (attr_t) COLOR_PAIR(1);
+	show_attr = (chtype) COLOR_PAIR(1);
 	wbkgdset(work, show_attr | ' ');
     } else {
 	show_attr = A_STANDOUT;
@@ -292,7 +293,7 @@
 	wmove(work, row, margin + 1);
 	switch (ch) {
 	case key_RECUR:
-	    test_adds(level + 1);
+	    recursive_test(level + 1);
 
 	    if (look)
 		touchwin(look);
@@ -459,33 +460,37 @@
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *tbl[] =
     {
 	"Usage: test_addchstr [options]"
 	,""
+	,USAGE_COMMON
 	,"Options:"
-	,"  -f FILE read data from given file"
-	,"  -n NUM  limit string-adds to NUM bytes on ^N replay"
-	,"  -m      perform wmove/move separately from add-functions"
-	,"  -p      pass-thru control characters without using unctrl()"
-	,"  -w      use window-parameter even when stdscr would be implied"
+	," -f FILE  read data from given file"
+	," -n NUM   limit string-adds to NUM bytes on ^N replay"
+	," -m       perform wmove/move separately from add-functions"
+	," -p       pass-thru control characters without using unctrl()"
+	," -w       use window-parameter even when stdscr would be implied"
     };
     unsigned n;
     for (n = 0; n < SIZEOF(tbl); ++n)
 	fprintf(stderr, "%s\n", tbl[n]);
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     int ch;
 
     setlocale(LC_ALL, "");
 
-    while ((ch = getopt(argc, argv, "f:mn:pw")) != -1) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "f:mn:pw")) != -1) {
 	switch (ch) {
 	case 'f':
 	    init_linedata(optarg);
@@ -504,15 +509,21 @@
 	case 'w':
 	    w_opt = TRUE;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
-	    break;
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
     if (optind < argc)
-	usage();
+	usage(FALSE);
 
-    test_adds(0);
+    recursive_test(0);
     endwin();
+#if NO_LEAKS
+    free(temp_buffer);
+#endif
     ExitProgram(EXIT_SUCCESS);
 }
diff --git a/test/test_addstr.c b/test/test_addstr.c
index a14cded..ba8a90e 100644
--- a/test/test_addstr.c
+++ b/test/test_addstr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2009-2010,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 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            *
@@ -26,16 +27,18 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_addstr.c,v 1.10 2012/12/16 00:14:10 tom Exp $
+ * $Id: test_addstr.c,v 1.20 2022/12/10 22:28:50 tom Exp $
  *
  * Demonstrate the waddstr() and waddch functions.
  * Thomas Dickey - 2009/9/12
  */
 
 #include <test.priv.h>
-
 #include <linedata.h>
 
+/*
+ * redefinitions to simplify comparison between test_*str programs
+ */
 #define AddNStr    addnstr
 #define AddStr     addstr
 #define MvAddNStr  (void) mvaddnstr
@@ -43,9 +46,6 @@
 #define WAddNStr   waddnstr
 #define WAddStr    waddstr
 
-#define AddCh      addch
-#define WAddCh     waddch
-
 #define MY_TABSIZE 8
 
 typedef enum {
@@ -129,7 +129,7 @@
 
 #define LEN(n) ((length - (n) > n_opt) ? n_opt : (length - (n)))
 static void
-test_adds(int level)
+recursive_test(int level)
 {
     static bool first = TRUE;
 
@@ -155,7 +155,8 @@
 	static char cmd[80];
 	setlocale(LC_ALL, "");
 
-	putenv(strcpy(cmd, "TABSIZE=8"));
+	_nc_STRCPY(cmd, "TABSIZE=8", sizeof(cmd));
+	putenv(cmd);
 
 	initscr();
 	(void) cbreak();	/* take input chars one at a time, no wait for \n */
@@ -211,7 +212,7 @@
 	wmove(work, row, margin + 1);
 	switch (ch) {
 	case key_RECUR:
-	    test_adds(level + 1);
+	    recursive_test(level + 1);
 
 	    if (look)
 		touchwin(look);
@@ -374,32 +375,36 @@
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *tbl[] =
     {
 	"Usage: test_addstr [options]"
 	,""
+	,USAGE_COMMON
 	,"Options:"
-	,"  -f FILE read data from given file"
-	,"  -n NUM  limit string-adds to NUM bytes on ^N replay"
-	,"  -m      perform wmove/move separately from add-functions"
-	,"  -w      use window-parameter even when stdscr would be implied"
+	," -f FILE  read data from given file"
+	," -n NUM   limit string-adds to NUM bytes on ^N replay"
+	," -m       perform wmove/move separately from add-functions"
+	," -w       use window-parameter even when stdscr would be implied"
     };
     unsigned n;
     for (n = 0; n < SIZEOF(tbl); ++n)
 	fprintf(stderr, "%s\n", tbl[n]);
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     int ch;
 
     setlocale(LC_ALL, "");
 
-    while ((ch = getopt(argc, argv, "f:mn:w")) != -1) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "f:mn:w")) != -1) {
 	switch (ch) {
 	case 'f':
 	    init_linedata(optarg);
@@ -415,15 +420,18 @@
 	case 'w':
 	    w_opt = TRUE;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
-	    break;
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
     if (optind < argc)
-	usage();
+	usage(FALSE);
 
-    test_adds(0);
+    recursive_test(0);
     endwin();
     ExitProgram(EXIT_SUCCESS);
 }
diff --git a/test/test_addwstr.c b/test/test_addwstr.c
index ff5a350..9e51f49 100644
--- a/test/test_addwstr.c
+++ b/test/test_addwstr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2009-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_addwstr.c,v 1.12 2014/08/02 17:24:55 tom Exp $
+ * $Id: test_addwstr.c,v 1.22 2023/05/27 20:13:10 tom Exp $
  *
  * Demonstrate the waddwstr() and wadd_wch functions.
  * Thomas Dickey - 2009/9/12
@@ -48,12 +49,16 @@
 #define WIDE_LINEDATA
 #include <linedata.h>
 
+#undef AddCh
 #undef MvAddCh
 #undef MvAddStr
 #undef MvWAddCh
 #undef MvWAddStr
+#undef WAddCh
 
-/* definitions to make it simpler to compare with inserts.c */
+/*
+ * redefinitions to simplify comparison between test_*str programs
+ */
 #define AddNStr    addnwstr
 #define AddStr     addwstr
 #define MvAddNStr  (void) mvaddnwstr
@@ -103,14 +108,13 @@
     wprintw(win,
 	    "down-arrow or ^N to repeat on next line, ^W for inner window, ESC to exit.\n");
     wclrtoeol(win);
-    wprintw(win, "Level %d,%s inserted %d characters <", level,
-	    showstate, length);
+    wprintw(win, "Level %d,%s added %d characters <", level, showstate, length);
     waddwstr(win, buffer);
     waddstr(win, ">");
 }
 
 static int
-ColOf(wchar_t *buffer, int length, int margin)
+ColOf(const wchar_t *const buffer, int length, int margin)
 {
     int n;
     int result;
@@ -218,7 +222,7 @@
 
 #define LEN(n) ((length - (n) > n_opt) ? n_opt : (length - (n)))
 static void
-test_inserts(int level)
+recursive_test(int level)
 {
     static bool first = TRUE;
 
@@ -233,15 +237,19 @@
     WINDOW *work = 0;
     WINDOW *show = 0;
     int margin = (2 * MY_TABSIZE) - 1;
-    Options option = (Options) ((int) (m_opt ? oMove : oDefault)
-				| (int) ((w_opt || (level > 0))
-					 ? oWindow : oDefault));
+    Options option = (Options) ((unsigned) (m_opt
+					    ? oMove
+					    : oDefault)
+				| (unsigned) ((w_opt || (level > 0))
+					      ? oWindow
+					      : oDefault));
 
     if (first) {
 	static char cmd[80];
 	setlocale(LC_ALL, "");
 
-	putenv(strcpy(cmd, "TABSIZE=8"));
+	_nc_STRCPY(cmd, "TABSIZE=8", sizeof(cmd));
+	putenv(cmd);
 
 	initscr();
 	(void) cbreak();	/* take input chars one at a time, no wait for \n */
@@ -249,7 +257,7 @@
 	keypad(stdscr, TRUE);
 
 	/*
-	 * Show the characters inserted in color, to distinguish from those that
+	 * Show the characters added in color, to distinguish from those that
 	 * are shifted.
 	 */
 	if (has_colors()) {
@@ -297,7 +305,7 @@
 	wmove(work, row, margin + 1);
 	switch (ch) {
 	case key_RECUR:
-	    test_inserts(level + 1);
+	    recursive_test(level + 1);
 
 	    if (look)
 		touchwin(look);
@@ -367,7 +375,7 @@
 		    break;
 		}
 
-		/* do the corresponding single-character insertion */
+		/* do the corresponding single-character add */
 		row2 = limit + row;
 		for (col = 0; col < length; ++col) {
 		    col2 = ColOf(buffer, col, margin);
@@ -422,7 +430,7 @@
 		break;
 	    }
 
-	    /* do the corresponding single-character insertion */
+	    /* do the corresponding single-character add */
 	    switch (option) {
 	    case oDefault:
 		if (move(limit + row, col) != ERR) {
@@ -459,32 +467,36 @@
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *tbl[] =
     {
-	"Usage: inserts [options]"
+	"Usage: test_addwstr [options]"
 	,""
+	,USAGE_COMMON
 	,"Options:"
-	,"  -f FILE read data from given file"
-	,"  -n NUM  limit string-inserts to NUM bytes on ^N replay"
-	,"  -m      perform wmove/move separately from insert-functions"
-	,"  -w      use window-parameter even when stdscr would be implied"
+	," -f FILE  read data from given file"
+	," -n NUM   limit string-adds to NUM bytes on ^N replay"
+	," -m       perform wmove/move separately from add-functions"
+	," -w       use window-parameter even when stdscr would be implied"
     };
     unsigned n;
     for (n = 0; n < SIZEOF(tbl); ++n)
 	fprintf(stderr, "%s\n", tbl[n]);
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     int ch;
 
     setlocale(LC_ALL, "");
 
-    while ((ch = getopt(argc, argv, "f:mn:w")) != -1) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "f:mn:w")) != -1) {
 	switch (ch) {
 	case 'f':
 	    init_linedata(optarg);
@@ -500,15 +512,18 @@
 	case 'w':
 	    w_opt = TRUE;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
-	    break;
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
     if (optind < argc)
-	usage();
+	usage(FALSE);
 
-    test_inserts(0);
+    recursive_test(0);
     endwin();
     ExitProgram(EXIT_SUCCESS);
 }
diff --git a/test/test_arrays.c b/test/test_arrays.c
index e4b9fb1..f89cb28 100644
--- a/test/test_arrays.c
+++ b/test/test_arrays.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007,2008 Free Software Foundation, Inc.                   *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 2007-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_arrays.c,v 1.5 2010/11/13 19:57:57 tom Exp $
+ * $Id: test_arrays.c,v 1.13 2022/12/10 23:23:27 tom Exp $
  *
  * Author: Thomas E Dickey
  *
@@ -50,7 +51,14 @@
 #if HAVE_TIGETSTR
 #if defined(HAVE_CURSES_DATA_BOOLNAMES) || defined(DECL_CURSES_DATA_BOOLNAMES)
 
-#define DUMP(name) dump_array(#name, name)
+static bool opt_C;
+static bool opt_T;
+static bool opt_c;
+static bool opt_f;
+static bool opt_n;
+static bool opt_t;
+
+#define PLAIN(opts, name) if (opts) dump_array(#name, name)
 
 static void
 dump_array(const char *name, NCURSES_CONST char *const *list)
@@ -63,27 +71,153 @@
     }
 }
 
-int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+static void
+dump_plain(void)
 {
-    DUMP(boolnames);
-    DUMP(boolcodes);
-    DUMP(boolfnames);
+    PLAIN(opt_T && opt_n, boolnames);
+    PLAIN(opt_C && opt_c, boolcodes);
+    PLAIN(opt_T && opt_f, boolfnames);
 
-    DUMP(numnames);
-    DUMP(numcodes);
-    DUMP(numfnames);
+    PLAIN(opt_T && opt_n, numnames);
+    PLAIN(opt_C && opt_c, numcodes);
+    PLAIN(opt_T && opt_f, numfnames);
 
-    DUMP(strnames);
-    DUMP(strcodes);
-    DUMP(strfnames);
+    PLAIN(opt_T && opt_n, strnames);
+    PLAIN(opt_C && opt_c, strcodes);
+    PLAIN(opt_T && opt_f, strfnames);
+}
+
+#define STRING(opts, name) if (opts) { printf("%s\"%s\"", c++ ? "," : "", name); }
+#define NUMBER(opts, value) if (opts) { printf("%s%d", c++ ? "," : "", value); }
+
+static void
+dump_table(void)
+{
+    int c = 0;
+    int r;
+
+    STRING(opt_t, "Index");
+    STRING(opt_t, "Type");
+    STRING(opt_n, "Name");
+    STRING(opt_c, "Code");
+    STRING(opt_f, "FName");
+    printf("\n");
+
+    for (r = 0; boolnames[r]; ++r) {
+	c = 0;
+	NUMBER(opt_t, r);
+	STRING(opt_t, "bool");
+	STRING(opt_T && opt_n, boolnames[r]);
+	STRING(opt_C && opt_c, boolcodes[r]);
+	STRING(opt_T && opt_f, boolfnames[r]);
+	printf("\n");
+    }
+
+    for (r = 0; numnames[r]; ++r) {
+	c = 0;
+	NUMBER(opt_t, r);
+	STRING(opt_t, "num");
+	STRING(opt_T && opt_n, numnames[r]);
+	STRING(opt_C && opt_c, numcodes[r]);
+	STRING(opt_T && opt_f, numfnames[r]);
+	printf("\n");
+    }
+
+    for (r = 0; strnames[r]; ++r) {
+	c = 0;
+	NUMBER(opt_t, r);
+	STRING(opt_t, "str");
+	STRING(opt_T && opt_n, strnames[r]);
+	STRING(opt_C && opt_c, strcodes[r]);
+	STRING(opt_T && opt_f, strfnames[r]);
+	printf("\n");
+    }
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: test_arrays [options]"
+	,""
+	,"If no options are given, print all (boolean, numeric, string)"
+	,"capability names showing their index within the tables."
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -C       print termcap names"
+	," -T       print terminfo names"
+	," -c       print termcap names"
+	," -f       print full terminfo names"
+	," -n       print short terminfo names"
+	," -t       print the result as CSV table"
+    };
+    unsigned n;
+    for (n = 0; n < SIZEOF(msg); ++n) {
+	fprintf(stderr, "%s\n", msg[n]);
+    }
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "CTcfnt")) != -1) {
+	switch (ch) {
+	case 'C':
+	    opt_C = TRUE;
+	    break;
+	case 'T':
+	    opt_T = TRUE;
+	    break;
+	case 'c':
+	    opt_c = TRUE;
+	    break;
+	case 'f':
+	    opt_f = TRUE;
+	    break;
+	case 'n':
+	    opt_n = TRUE;
+	    break;
+	case 't':
+	    opt_t = TRUE;
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
+    if (!(opt_T || opt_C)) {
+	opt_T = opt_C = TRUE;
+    }
+    if (!(opt_c || opt_f || opt_n)) {
+	opt_c = opt_f = opt_n = TRUE;
+    }
+
+    if (opt_t) {
+	dump_table();
+    } else {
+	dump_plain();
+    }
 
     ExitProgram(EXIT_SUCCESS);
 }
 
 #else
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(void)
 {
     printf("This program requires the terminfo arrays\n");
     ExitProgram(EXIT_FAILURE);
@@ -91,7 +225,7 @@
 #endif
 #else /* !HAVE_TIGETSTR */
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(void)
 {
     printf("This program requires the terminfo functions such as tigetstr\n");
     ExitProgram(EXIT_FAILURE);
diff --git a/test/test_delwin.c b/test/test_delwin.c
new file mode 100644
index 0000000..09ef5c5
--- /dev/null
+++ b/test/test_delwin.c
@@ -0,0 +1,151 @@
+/****************************************************************************
+ * Copyright 2022,2023 Thomas E. Dickey                                     *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/*
+ * $Id: test_delwin.c,v 1.5 2023/05/27 20:34:51 tom Exp $
+ */
+#include <test.priv.h>
+
+#define STATUS 10
+
+static SCREEN *my_screen;
+
+static void
+show_rc(const char *what, const char *explain, int rc)
+{
+    printw("%s : %d (%s)\n", what, rc, explain);
+}
+
+static void
+next_step(WINDOW *win)
+{
+    int ch = wgetch(win);
+    if (ch == QUIT || ch == ESCAPE) {
+	endwin();
+	/* use this to verify if delscreen frees all memory */
+	delscreen(my_screen);
+	exit(EXIT_FAILURE);
+    }
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: test_delwin [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char **argv)
+{
+    WINDOW *parent, *child1;
+    int rc;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
+    if ((my_screen = newterm(NULL, stdout, stdin)) == NULL)
+	ExitProgram(EXIT_FAILURE);
+
+    noecho();
+    cbreak();
+
+    refresh();
+    wsetscrreg(stdscr, 0, STATUS - 1);
+    scrollok(stdscr, TRUE);
+
+    parent = newwin(0, 0, STATUS, 0);
+    box(parent, 0, 0);
+    wrefresh(parent);
+    next_step(parent);
+
+    printw("New window %p    %s\n", (void *) parent, "Top window");
+    mvwprintw(parent, 1, 1, "Top window");
+    wrefresh(parent);
+    next_step(stdscr);
+
+    child1 = derwin(parent, LINES - STATUS - 4, COLS - 4, 2, 2);
+    box(child1, 0, 0);
+    mvwprintw(child1, 1, 1, "Sub window");
+    wrefresh(child1);
+
+    printw("Sub window %p    %s\n", (void *) child1, "Hello world!");
+    next_step(stdscr);
+
+    show_rc("Deleted parent",
+	    "should fail, it still has a subwindow",
+	    delwin(parent));
+    next_step(stdscr);
+    show_rc("Deleted child1",
+	    "should succeed",
+	    rc = delwin(child1));
+    next_step(stdscr);
+    if (rc == OK) {
+	wclrtobot(parent);
+	box(parent, 0, 0);
+	next_step(parent);
+    }
+    show_rc("Deleted parent",
+	    "should succeed, it has no subwindow now",
+	    rc = delwin(parent));
+    next_step(stdscr);
+    if (rc == OK) {
+	touchwin(stdscr);
+	next_step(stdscr);
+    }
+    show_rc("Deleted parent",
+	    "should fail, may dump core",
+	    delwin(parent));
+    next_step(stdscr);
+    endwin();
+    ExitProgram(EXIT_SUCCESS);
+}
diff --git a/test/test_endwin.c b/test/test_endwin.c
new file mode 100644
index 0000000..8e0d283
--- /dev/null
+++ b/test/test_endwin.c
@@ -0,0 +1,132 @@
+/****************************************************************************
+ * Copyright 2023 Thomas E. Dickey                                          *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+/*
+ * $Id: test_endwin.c,v 1.2 2023/11/10 15:17:19 tom Exp $
+ */
+#include <test.priv.h>
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: test_endwin [options]"
+	,""
+	,"Options:"
+	," -e   call endwin() an extra time"
+	," -i   call initscr() before endwin()"
+	," -n   call newterm() before endwin()"
+	," -r   call refresh() before endwin()"
+	," -s   call getch() after endwin(), to refresh screen"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+#define status(opt,name,rc) if (opt) printf(" %s: %s", name, (rc) == OK ? "OK" : "ERR")
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+    int rc_r = OK;
+    int rc_e1 = OK;
+    int rc_e2 = OK;
+    int rc_e3 = OK;
+    SCREEN *sp = NULL;
+    bool opt_e = FALSE;
+    bool opt_i = FALSE;
+    bool opt_n = FALSE;
+    bool opt_r = FALSE;
+    bool opt_s = FALSE;
+
+    while ((ch = getopt(argc, argv, "einrs" OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case 'e':
+	    opt_e = TRUE;
+	    break;
+	case 'i':
+	    opt_i = TRUE;
+	    break;
+	case 'n':
+	    opt_n = TRUE;
+	    break;
+	case 'r':
+	    opt_r = TRUE;
+	    break;
+	case 's':
+	    opt_s = TRUE;
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+    if (opt_i && opt_n)
+	usage(TRUE);
+
+    if (opt_i) {
+	initscr();
+    } else if (opt_n) {
+	sp = newterm(NULL, stdout, stdin);
+    }
+    if (opt_r) {
+	rc_r = refresh();
+    }
+    rc_e1 = endwin();
+    if (opt_e) {
+	rc_e2 = endwin();
+    }
+    if (opt_s) {
+	getch();
+	rc_e3 = endwin();
+    }
+    printf("status:");
+    status(opt_i, "initscr(-i)", OK);
+    status(opt_n, "newterm(-n)", (sp != NULL) ? OK : ERR);
+    status(opt_r, "refresh(-r)", rc_r);
+    status(TRUE, "endwin", rc_e1);
+    status(opt_e, "endwin(-e)", rc_e2);
+    status(opt_s, "endwin(-s)", rc_e3);
+    printf("\n");
+    ExitProgram(EXIT_SUCCESS);
+}
diff --git a/test/test_get_wstr.c b/test/test_get_wstr.c
index dc01b0e..2a788fc 100644
--- a/test/test_get_wstr.c
+++ b/test/test_get_wstr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007-2009,2011 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 2007-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_get_wstr.c,v 1.8 2011/01/15 18:15:11 tom Exp $
+ * $Id: test_get_wstr.c,v 1.14 2022/12/10 23:59:13 tom Exp $
  *
  * Author: Thomas E Dickey
  *
@@ -43,6 +44,7 @@
  */
 
 #include <test.priv.h>
+#include <popup_msg.h>
 
 #if HAVE_CHGAT
 /* NetBSD curses wchgat */
@@ -79,14 +81,14 @@
 static void
 ShowPrompt(WINDOW *txtwin, int limit)
 {
-    wchgat(txtwin, limit, A_REVERSE, 0, NULL);
+    wchgat(txtwin, limit, WA_REVERSE, 0, NULL);
     wnoutrefresh(txtwin);
 }
 
 static void
 MovePrompt(WINDOW *txtwin, int limit, int y, int x)
 {
-    wchgat(txtwin, Remainder(txtwin), A_NORMAL, 0, NULL);
+    wchgat(txtwin, Remainder(txtwin), WA_NORMAL, 0, NULL);
     wmove(txtwin, y, x);
     ShowPrompt(txtwin, limit);
 }
@@ -134,8 +136,30 @@
 }
 
 static int
-test_get_wstr(int level, char **argv, WINDOW *strwin)
+recursive_test(int level, char **argv, WINDOW *strwin)
 {
+    static const char *help[] =
+    {
+	"Commands:",
+	"  q,^Q,ESC       - quit this program",
+	"  ^Q,ESC         - quit help-screen",
+	"",
+	"  p,<Up>         - move beginning of prompt one up row",
+	"  j,<Down>       - move beginning of prompt one down row",
+	"  h,<Left>       - move beginning of prompt one left column",
+	"  l,<Right>      - move beginning of prompt one right column",
+	"",
+	"  -              - reduce getnstr buffer-size one column",
+	"  +              - increase getnstr buffer-size one column",
+	"  :              - prompt for input-text",
+	"",
+	"  <              - scroll \"left\" through getstr-functions",
+	"  >              - scroll \"right\" through getstr-functions",
+	"",
+	"  w              - recur to subwindow",
+	"  ?,<F1>         - show help-screen",
+	0
+    };
     WINDOW *txtbox = 0;
     WINDOW *txtwin = 0;
     FILE *fp;
@@ -225,7 +249,7 @@
 	    break;
 
 	case 'w':
-	    test_get_wstr(level + 1, argv, strwin);
+	    recursive_test(level + 1, argv, strwin);
 	    if (txtbox != 0) {
 		touchwin(txtbox);
 		wnoutrefresh(txtbox);
@@ -311,10 +335,13 @@
 	    }
 	    noecho();
 	    (void) wattrset(txtwin, A_NORMAL);
-	    wprintw(strwin, "%d", rc);
+	    wprintw(strwin, "%s:", (rc == OK) ? "OK" : "ERR");
 	    (void) waddwstr(strwin, (wchar_t *) buffer);
 	    wnoutrefresh(strwin);
 	    break;
+	case HELP_KEY_1:
+	    popup_msg(stdscr, help);
+	    break;
 	default:
 	    beep();
 	    break;
@@ -328,18 +355,48 @@
     return TRUE;
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: test_get_wstr [options] [file1 [...]]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
 main(int argc, char *argv[])
 {
     WINDOW *chrbox;
     WINDOW *strwin;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
 
     setlocale(LC_ALL, "");
 
-    if (argc < 2) {
-	fprintf(stderr, "usage: %s file\n", argv[0]);
-	return EXIT_FAILURE;
-    }
+    if (optind + 1 > argc)
+	usage(FALSE);
 
     initscr();
 
@@ -349,7 +406,7 @@
 
     strwin = derwin(chrbox, 4, COLS - 2, 1, 1);
 
-    test_get_wstr(1, argv, strwin);
+    recursive_test(optind, argv, strwin);
 
     endwin();
     ExitProgram(EXIT_SUCCESS);
diff --git a/test/test_getstr.c b/test/test_getstr.c
index 3f64c77..dbc0a0a 100644
--- a/test/test_getstr.c
+++ b/test/test_getstr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007-2009,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 2007-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_getstr.c,v 1.10 2012/07/07 18:22:49 tom Exp $
+ * $Id: test_getstr.c,v 1.16 2022/12/10 23:58:37 tom Exp $
  *
  * Author: Thomas E Dickey
  *
@@ -43,6 +44,7 @@
  */
 
 #include <test.priv.h>
+#include <popup_msg.h>
 
 #if HAVE_CHGAT
 /* Solaris SVr4 curses lacks wchgat, mvgetnstr, mvwgetnstr */
@@ -86,14 +88,14 @@
 static void
 ShowPrompt(WINDOW *txtwin, int limit)
 {
-    wchgat(txtwin, limit, A_REVERSE, 0, NULL);
+    wchgat(txtwin, limit, WA_REVERSE, 0, NULL);
     wnoutrefresh(txtwin);
 }
 
 static void
 MovePrompt(WINDOW *txtwin, int limit, int y, int x)
 {
-    wchgat(txtwin, Remainder(txtwin), A_NORMAL, 0, NULL);
+    wchgat(txtwin, Remainder(txtwin), WA_NORMAL, 0, NULL);
     wmove(txtwin, y, x);
     ShowPrompt(txtwin, limit);
 }
@@ -141,8 +143,30 @@
 }
 
 static int
-test_getstr(int level, char **argv, WINDOW *strwin)
+recursive_test(int level, char **argv, WINDOW *strwin)
 {
+    static const char *help[] =
+    {
+	"Commands:",
+	"  q,^Q,ESC       - quit this program",
+	"  ^Q,ESC         - quit help-screen",
+	"",
+	"  p,<Up>         - move beginning of prompt one up row",
+	"  j,<Down>       - move beginning of prompt one down row",
+	"  h,<Left>       - move beginning of prompt one left column",
+	"  l,<Right>      - move beginning of prompt one right column",
+	"",
+	"  -              - reduce getnstr buffer-size one column",
+	"  +              - increase getnstr buffer-size one column",
+	"  :              - prompt for input-text",
+	"",
+	"  <              - scroll \"left\" through getstr-functions",
+	"  >              - scroll \"right\" through getstr-functions",
+	"",
+	"  w              - recur to subwindow",
+	"  ?,<F1>         - show help-screen",
+	0
+    };
     WINDOW *txtbox = 0;
     WINDOW *txtwin = 0;
     FILE *fp;
@@ -233,7 +257,7 @@
 	    break;
 
 	case 'w':
-	    test_getstr(level + 1, argv, strwin);
+	    recursive_test(level + 1, argv, strwin);
 	    if (txtbox != 0) {
 		touchwin(txtbox);
 		wnoutrefresh(txtbox);
@@ -322,6 +346,9 @@
 	    wprintw(strwin, "%s:%s", ok_keyname(rc), buffer);
 	    wnoutrefresh(strwin);
 	    break;
+	case HELP_KEY_1:
+	    popup_msg(stdscr, help);
+	    break;
 	default:
 	    beep();
 	    break;
@@ -335,18 +362,48 @@
     return TRUE;
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: test_getstr [options] [file1 [...]]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
 main(int argc, char *argv[])
 {
     WINDOW *chrbox;
     WINDOW *strwin;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
 
     setlocale(LC_ALL, "");
 
-    if (argc < 2) {
-	fprintf(stderr, "usage: %s file\n", argv[0]);
-	return EXIT_FAILURE;
-    }
+    if (optind + 1 > argc)
+	usage(FALSE);
 
     initscr();
 
@@ -356,7 +413,7 @@
 
     strwin = derwin(chrbox, 4, COLS - 2, 1, 1);
 
-    test_getstr(1, argv, strwin);
+    recursive_test(optind, argv, strwin);
 
     endwin();
     ExitProgram(EXIT_SUCCESS);
diff --git a/test/test_instr.c b/test/test_instr.c
index 627db08..c87bdd7 100644
--- a/test/test_instr.c
+++ b/test/test_instr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007,2010 Free Software Foundation, Inc.                   *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 2007-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_instr.c,v 1.5 2010/05/01 19:13:46 tom Exp $
+ * $Id: test_instr.c,v 1.12 2022/12/10 23:58:01 tom Exp $
  *
  * Author: Thomas E Dickey
  *
@@ -68,7 +69,7 @@
 }
 
 static int
-test_inchs(int level, char **argv, WINDOW *chrwin, WINDOW *strwin)
+recursive_test(int level, char **argv, WINDOW *chrwin, WINDOW *strwin)
 {
     WINDOW *txtbox = 0;
     WINDOW *txtwin = 0;
@@ -85,6 +86,7 @@
 	return FALSE;
     }
 
+    *buffer = '\0';
     if (level > 1) {
 	txtbox = newwin(LINES - BASE_Y, COLS - level, BASE_Y, level);
 	box(txtbox, 0, 0);
@@ -150,7 +152,7 @@
 		beep();
 	    break;
 	case 'w':
-	    test_inchs(level + 1, argv, chrwin, strwin);
+	    recursive_test(level + 1, argv, chrwin, strwin);
 	    if (txtbox != 0) {
 		touchwin(txtbox);
 		wnoutrefresh(txtbox);
@@ -230,19 +232,49 @@
     return TRUE;
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: test_instr [options] [file1 [...]]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
 main(int argc, char *argv[])
 {
     WINDOW *chrbox;
     WINDOW *chrwin;
     WINDOW *strwin;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
 
     setlocale(LC_ALL, "");
 
-    if (argc < 2) {
-	fprintf(stderr, "usage: %s file\n", argv[0]);
-	return EXIT_FAILURE;
-    }
+    if (optind + 1 > argc)
+	usage(FALSE);
 
     initscr();
 
@@ -253,7 +285,7 @@
     chrwin = derwin(chrbox, 2, COLS - 2, 1, 1);
     strwin = derwin(chrbox, 2, COLS - 2, 3, 1);
 
-    test_inchs(1, argv, chrwin, strwin);
+    recursive_test(optind, argv, chrwin, strwin);
 
     endwin();
     ExitProgram(EXIT_SUCCESS);
diff --git a/test/test_inwstr.c b/test/test_inwstr.c
index 3d2656f..c22add7 100644
--- a/test/test_inwstr.c
+++ b/test/test_inwstr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007,2010 Free Software Foundation, Inc.                   *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 2007-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_inwstr.c,v 1.4 2010/05/01 19:13:46 tom Exp $
+ * $Id: test_inwstr.c,v 1.8 2022/12/10 23:56:39 tom Exp $
  *
  * Author: Thomas E Dickey
  *
@@ -70,7 +71,7 @@
 }
 
 static int
-test_inchs(int level, char **argv, WINDOW *chrwin, WINDOW *strwin)
+recursive_test(int level, char **argv, WINDOW *chrwin, WINDOW *strwin)
 {
     WINDOW *txtbox = 0;
     WINDOW *txtwin = 0;
@@ -151,7 +152,7 @@
 		beep();
 	    break;
 	case 'w':
-	    test_inchs(level + 1, argv, chrwin, strwin);
+	    recursive_test(level + 1, argv, chrwin, strwin);
 	    if (txtbox != 0) {
 		touchwin(txtbox);
 		wnoutrefresh(txtbox);
@@ -231,19 +232,49 @@
     return TRUE;
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: test_inwstr [options] [file1 [...]]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
 main(int argc, char *argv[])
 {
     WINDOW *chrbox;
     WINDOW *chrwin;
     WINDOW *strwin;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
 
     setlocale(LC_ALL, "");
 
-    if (argc < 2) {
-	fprintf(stderr, "usage: %s file\n", argv[0]);
-	return EXIT_FAILURE;
-    }
+    if (optind + 1 > argc)
+	usage(FALSE);
 
     initscr();
 
@@ -254,7 +285,7 @@
     chrwin = derwin(chrbox, 2, COLS - 2, 1, 1);
     strwin = derwin(chrbox, 2, COLS - 2, 3, 1);
 
-    test_inchs(1, argv, chrwin, strwin);
+    recursive_test(optind, argv, chrwin, strwin);
 
     endwin();
     ExitProgram(EXIT_SUCCESS);
diff --git a/test/test_mouse.c b/test/test_mouse.c
new file mode 100644
index 0000000..5508ea4
--- /dev/null
+++ b/test/test_mouse.c
@@ -0,0 +1,284 @@
+/****************************************************************************
+ * Copyright 2022-2023,2024 Thomas E. Dickey                                *
+ * Copyright 2022 Leonid S. Usov <leonid.s.usov at gmail.com>               *
+ *                                                                          *
+ * 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.                               *
+ ****************************************************************************/
+/*
+ * $Id: test_mouse.c,v 1.31 2024/03/30 20:45:31 tom Exp $
+ *
+ * Author: Leonid S Usov
+ *
+ * Observe mouse events in the raw terminal or parsed ncurses modes
+ */
+
+#include <test.priv.h>
+
+#if defined(NCURSES_MOUSE_VERSION) && !defined(_NC_WINDOWS)
+
+static int logoffset = 0;
+
+static void
+raw_loop(void)
+{
+    char *xtermcap;
+
+    printf("Entering raw mode. Ctrl-c to quit.\n");
+
+    newterm(NULL, stdout, stdin);
+    raw();
+    xtermcap = tigetstr("XM");
+    if (!VALID_STRING(xtermcap)) {
+	fprintf(stderr, "couldn't get XM terminfo");
+	return;
+    }
+
+    putp(tgoto(xtermcap, 1, 1));
+    fflush(stdout);
+
+    while (1) {
+	int c = getc(stdin);
+	const char *pretty;
+
+	if (c == -1 || c == '\003') {
+	    break;
+	} else if (c == '\033') {
+	    printf("\r\n\\E");
+	} else if ((pretty = unctrl((chtype) c)) != NULL) {
+	    printf("%s", pretty);
+	} else if (isprint(c)) {
+	    printf("%c", c);
+	} else {
+	    printf("{%x}", UChar(c));
+	}
+    }
+
+    putp(tgoto(xtermcap, 0, 0));
+    fflush(stdout);
+    noraw();
+}
+
+static void logw(const char *fmt, ...) GCC_PRINTFLIKE(1, 2);
+
+static void
+logw(const char *fmt, ...)
+{
+    int row = getcury(stdscr);
+    va_list args;
+
+    va_start(args, fmt);
+    wmove(stdscr, row++, 0);
+    vw_printw(stdscr, fmt, args);
+    va_end(args);
+
+    clrtoeol();
+
+    row %= (getmaxy(stdscr) - logoffset);
+    if (row < logoffset) {
+	row = logoffset;
+    }
+
+    wmove(stdscr, row, 0);
+    wprintw(stdscr, ">");
+    clrtoeol();
+}
+
+static void
+cooked_loop(char *my_environ, int interval)
+{
+    MEVENT event;
+
+    initscr();
+    noecho();
+    cbreak();			/* Line buffering disabled; pass everything */
+    nonl();
+    keypad(stdscr, TRUE);
+
+    /* Get all the mouse events */
+    mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);
+    mouseinterval(interval);
+
+    logw("Ctrl-c to quit");
+    logw("--------------");
+    if (my_environ)
+	logw("%s", my_environ);
+    logoffset = getcury(stdscr);
+
+    while (1) {
+	int c = getch();
+
+	switch (c) {
+	case KEY_MOUSE:
+	    if (getmouse(&event) == OK) {
+		unsigned btn;
+		mmask_t events;
+#if NCURSES_MOUSE_VERSION > 1
+		const unsigned max_btn = 5;
+#else
+		const unsigned max_btn = 4;
+#endif
+		const mmask_t btn_mask = (NCURSES_BUTTON_RELEASED |
+					  NCURSES_BUTTON_PRESSED |
+					  NCURSES_BUTTON_CLICKED |
+					  NCURSES_DOUBLE_CLICKED |
+					  NCURSES_TRIPLE_CLICKED);
+		bool found = FALSE;
+		for (btn = 1; btn <= max_btn; btn++) {
+		    events = (mmask_t) (event.bstate
+					& NCURSES_MOUSE_MASK(btn, btn_mask));
+		    if (events == 0)
+			continue;
+#define ShowQ(btn,name) \
+	(((event.bstate & NCURSES_MOUSE_MASK(btn, NCURSES_ ## name)) != 0) \
+	 ? (" " #name) \
+	 : "")
+#define ShowM(name) \
+	(((event.bstate & NCURSES_MOUSE_MASK(btn, BUTTON_ ## name)) != 0) \
+	 ? (" " #name) \
+	 : "")
+#define ShowP() \
+	 ((event.bstate & REPORT_MOUSE_POSITION) != 0 \
+	  ? " position" \
+	  : "")
+		    logw("[%08lX] button %d%s%s%s%s%s%s%s%s%s @ %d, %d",
+			 (unsigned long) events,
+			 btn,
+			 ShowQ(btn, BUTTON_RELEASED),
+			 ShowQ(btn, BUTTON_PRESSED),
+			 ShowQ(btn, BUTTON_CLICKED),
+			 ShowQ(btn, DOUBLE_CLICKED),
+			 ShowQ(btn, TRIPLE_CLICKED),
+			 ShowM(SHIFT),
+			 ShowM(CTRL),
+			 ShowM(ALT),
+			 ShowP(),
+			 event.y, event.x);
+		    found = TRUE;
+		}
+		/*
+		 * A position report need not have a button associated with it.
+		 * The modifiers probably are unused.
+		 */
+		if (!found && (event.bstate & REPORT_MOUSE_POSITION)) {
+		    logw("[%08lX]%s%s%s%s @ %d, %d",
+			 (unsigned long) events,
+			 ShowM(SHIFT),
+			 ShowM(CTRL),
+			 ShowM(ALT),
+			 ShowP(),
+			 event.y, event.x);
+		}
+	    }
+	    break;
+	case '\003':
+	    goto end;
+	default:
+	    logw("got another char: 0x%x", UChar(c));
+	}
+	refresh();
+    }
+  end:
+    endwin();
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: test_mouse [options]"
+	,""
+	,"Test mouse events.  These examples for $TERM demonstrate xterm"
+	,"features:"
+	,"    xterm"
+	,"    xterm-1002"
+	,"    xterm-1003"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -r       show raw input stream, injecting a new line before every ESC"
+	," -i n     set mouse interval to n; default is 0 (no double-clicks)"
+	," -T term  use terminal description other than $TERM"
+    };
+    unsigned n;
+    for (n = 0; n < sizeof(msg) / sizeof(char *); ++n) {
+	fprintf(stderr, "%s\n", msg[n]);
+    }
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    bool rawmode = FALSE;
+    int interval = 0;
+    int ch;
+    size_t my_len;
+    char *my_environ = NULL;
+    const char *term_format = "TERM=%s";
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "i:rT:")) != -1) {
+	switch (ch) {
+	case 'i':
+	    interval = atoi(optarg);
+	    break;
+	case 'r':
+	    rawmode = TRUE;
+	    break;
+	case 'T':
+	    my_len = strlen(term_format) + strlen(optarg) + 1;
+	    my_environ = malloc(my_len);
+	    if (my_environ != NULL) {
+		_nc_SPRINTF(my_environ, _nc_SLIMIT(my_len) term_format, optarg);
+		putenv(my_environ);
+	    }
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc) {
+	usage(FALSE);
+	ExitProgram(EXIT_FAILURE);
+    }
+
+    if (rawmode) {
+	raw_loop();
+    } else {
+	cooked_loop(my_environ, interval);
+    }
+
+    ExitProgram(EXIT_SUCCESS);
+}
+#else
+int
+main(void)
+{
+    printf("This program requires the ncurses library\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
diff --git a/test/test_opaque.c b/test/test_opaque.c
index 6ec75fa..09b98c0 100644
--- a/test/test_opaque.c
+++ b/test/test_opaque.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020-2021,2022 Thomas E. Dickey                                *
+ * Copyright 2007-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_opaque.c,v 1.9 2009/10/24 21:21:29 tom Exp $
+ * $Id: test_opaque.c,v 1.15 2022/12/11 00:03:10 tom Exp $
  *
  * Author: Thomas E Dickey
  *
@@ -44,6 +45,9 @@
        bool is_scrollok(const WINDOW *win);
        bool is_syncok(const WINDOW *win);
        int wgetscrreg (const WINDOW *, int *, int *);
+       bool is_pad(const WINDOW *win);
+       bool is_subwin(const WINDOW *win);
+       int wgetdelay(const WINDOW *win);
  */
 
 #include <test.priv.h>
@@ -51,7 +55,7 @@
 #define BASE_Y 6
 #define MAX_COLS 1024
 
-#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20080119) && NCURSES_EXT_FUNCS
+#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20090906) && NCURSES_EXT_FUNCS && NCURSES_OPAQUE
 
 static bool
 Quit(int ch)
@@ -208,6 +212,8 @@
 };
 /* *INDENT-ON* */
 
+#define bool2c(c) ((c) ? 'T' : 'F')
+
 /*
  * Display and/or allow update for the properties accessed in the opaque
  * window.  Some may change state after refreshing the window, so we
@@ -226,18 +232,35 @@
 	show_keyword(stswin, n, active, bool_funcs[n].name);
 
 	to_result(stswin, n, before);
-	wprintw(stswin, "%c", bool_funcs[n].func(txtwin, -1) ? 'T' : 'F');
+	wprintw(stswin, "%c", bool2c(bool_funcs[n].func(txtwin, -1)));
     }
 
+    show_keyword(stswin, n, active, "is_pad");
+    to_result(stswin, n, TRUE);
+    wprintw(stswin, "%c", bool2c(is_pad(txtwin)));
+
+    ++n;
+    show_keyword(stswin, n, active, "is_subwin");
+    to_result(stswin, n, TRUE);
+    wprintw(stswin, "%c", bool2c(is_subwin(txtwin)));
+
+    ++n;
     show_keyword(stswin, n, active, "wgetparent");
     to_result(stswin, n, TRUE);
     wprintw(stswin, "%p", (void *) wgetparent(txtwin));
 
     ++n;
+    show_keyword(stswin, n, active, "wgetdelay");
+    to_result(stswin, n, TRUE);
+    wprintw(stswin, "%d", wgetdelay(txtwin));
+
+    ++n;
     show_keyword(stswin, n, active, "wgetscrreg");
     to_result(stswin, n, TRUE);
     if (wgetscrreg(txtwin, &top, &bottom) == OK)
 	wprintw(stswin, "%d,%d", top, bottom);
+    else
+	wprintw(stswin, "none");
 
     wnoutrefresh(stswin);
     return active;
@@ -431,18 +454,48 @@
     set_tabsize(save_tabsize);
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: test_opaque [options] file1 [file2 [...]]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
 main(int argc, char *argv[])
 {
     WINDOW *stsbox;
     WINDOW *stswin;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
 
     setlocale(LC_ALL, "");
 
-    if (argc < 2) {
-	fprintf(stderr, "usage: %s file\n", argv[0]);
-	return EXIT_FAILURE;
-    }
+    if (optind + 1 > argc)
+	usage(FALSE);
 
     initscr();
 
@@ -456,7 +509,7 @@
     stswin = derwin(stsbox, BASE_Y - 2, COLS - 2, 1, 1);
     keypad(stswin, TRUE);
 
-    test_opaque(1, argv, stswin);
+    test_opaque(optind, argv, stswin);
 
     endwin();
     ExitProgram(EXIT_SUCCESS);
diff --git a/test/test_setupterm.c b/test/test_setupterm.c
index 6d7e0e2..24d7c46 100644
--- a/test/test_setupterm.c
+++ b/test/test_setupterm.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2015 Free Software Foundation, Inc.                        *
+ * Copyright 2020-2022,2023 Thomas E. Dickey                                *
+ * Copyright 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            *
@@ -29,7 +30,7 @@
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: test_setupterm.c,v 1.8 2015/06/28 00:53:46 tom Exp $
+ * $Id: test_setupterm.c,v 1.17 2023/06/24 14:19:52 tom Exp $
  *
  * A simple demo of setupterm/restartterm.
  */
@@ -42,6 +43,55 @@
 static bool n_opt = FALSE;
 static bool r_opt = FALSE;
 
+#if NO_LEAKS
+static TERMINAL **saved_terminals;
+static size_t num_saved;
+static size_t max_saved;
+
+static void
+failed(const char *msg)
+{
+    perror(msg);
+    ExitProgram(EXIT_FAILURE);
+}
+
+static void
+finish(int code)
+{
+    size_t n;
+    for (n = 0; n < num_saved; ++n)
+	del_curterm(saved_terminals[n]);
+    free(saved_terminals);
+    ExitProgram(code);
+}
+
+static void
+save_curterm(void)
+{
+    size_t n;
+    bool found = FALSE;
+    for (n = 0; n < num_saved; ++n) {
+	if (saved_terminals[n] == cur_term) {
+	    found = TRUE;
+	    break;
+	}
+    }
+    if (!found) {
+	if (num_saved + 1 >= max_saved) {
+	    max_saved += 100;
+	    saved_terminals = typeRealloc(TERMINAL *, max_saved, saved_terminals);
+	    if (saved_terminals == NULL)
+		failed("realloc");
+	}
+	saved_terminals[num_saved++] = cur_term;
+    }
+}
+
+#else
+#define finish(code) ExitProgram(code)
+#define save_curterm()		/* nothing */
+#endif
+
 static void
 test_rc(NCURSES_CONST char *name, int actual_rc, int actual_err)
 {
@@ -96,44 +146,53 @@
     int rc;
     int err = -99;
 
-    if (r_opt) {
+#if HAVE_RESTARTTERM
+    if (r_opt)
 	rc = restartterm(name, 0, f_opt ? NULL : &err);
-    } else {
+    else
+#endif
 	rc = setupterm(name, 0, f_opt ? NULL : &err);
-    }
     test_rc(name, rc, err);
+    save_curterm();
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *msg[] =
     {
-	"Usage: test_setupterm [options] [terminal]",
-	"",
-	"Demonstrate error-checking for setupterm and restartterm.",
-	"",
-	"Options:",
-	" -a       automatic test for each success/error code",
-	" -f       treat errors as fatal",
-	" -n       set environment to disable terminfo database, assuming",
-	"          the compiled-in paths for database also fail",
-	" -r       test restartterm rather than setupterm",
+	"Usage: test_setupterm [options] [terminal]"
+	,""
+	,USAGE_COMMON
+	,"Demonstrate error-checking for setupterm and restartterm."
+	,""
+	,"Options:"
+	," -a       automatic test for each success/error code"
+	," -f       treat errors as fatal"
+	," -n       set environment to disable terminfo database, assuming"
+	,"          the compiled-in paths for database also fail"
+#if HAVE_RESTARTTERM
+	," -r       test restartterm rather than setupterm"
+#endif
     };
     unsigned n;
     for (n = 0; n < SIZEOF(msg); ++n) {
 	fprintf(stderr, "%s\n", msg[n]);
     }
-    ExitProgram(EXIT_FAILURE);
+    finish(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
 {
+    int ch;
     int n;
 
-    while ((n = getopt(argc, argv, "afnr")) != -1) {
-	switch (n) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "afnr")) != -1) {
+	switch (ch) {
 	case 'a':
 	    a_opt = TRUE;
 	    break;
@@ -143,12 +202,17 @@
 	case 'n':
 	    n_opt = TRUE;
 	    break;
+#if HAVE_RESTARTTERM
 	case 'r':
 	    r_opt = TRUE;
 	    break;
+#endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
-	    break;
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
 
@@ -176,13 +240,14 @@
     if (r_opt) {
 	newterm("ansi", stdout, stdin);
 	reset_shell_mode();
+	save_curterm();
     }
 
     if (a_opt) {
 	static char predef[][9] =
 	{"vt100", "dumb", "lpr", "unknown", "none-such"};
 	if (optind < argc) {
-	    usage();
+	    usage(FALSE);
 	}
 	for (n = 0; n < 4; ++n) {
 	    test_setupterm(predef[n]);
@@ -197,12 +262,12 @@
 	}
     }
 
-    ExitProgram(EXIT_SUCCESS);
+    finish(EXIT_SUCCESS);
 }
 
 #else /* !HAVE_TIGETSTR */
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(void)
 {
     printf("This program requires the terminfo functions such as tigetstr\n");
     ExitProgram(EXIT_FAILURE);
diff --git a/test/test_sgr.c b/test/test_sgr.c
new file mode 100644
index 0000000..8763dca
--- /dev/null
+++ b/test/test_sgr.c
@@ -0,0 +1,392 @@
+/****************************************************************************
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2015-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: Thomas E. Dickey
+ *
+ * $Id: test_sgr.c,v 1.22 2023/05/27 20:13:10 tom Exp $
+ *
+ * A simple demo of the sgr/sgr0 terminal capabilities.
+ */
+#define USE_TINFO
+#include <test.priv.h>
+
+#if !HAVE_TIGETSTR
+static GCC_NORETURN void failed(const char *);
+
+static void
+failed(const char *msg)
+{
+    fprintf(stderr, "%s\n", msg);
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
+
+#if HAVE_TIGETSTR
+
+static bool no_init = FALSE;
+static bool q_opt = FALSE;
+
+static char *d_opt;
+static char *e_opt;
+static char **db_list;
+static int db_item;
+
+static long total_values;
+
+static char *
+make_dbitem(const char *const p, const char *const q)
+{
+    size_t need = strlen(e_opt) + 2 + (size_t) (p - q);
+    char *result = malloc(need);
+    _nc_SPRINTF(result, _nc_SLIMIT(need) "%s=%.*s", e_opt, (int) (p - q), q);
+    return result;
+}
+
+static void
+make_dblist(void)
+{
+    if (d_opt && e_opt) {
+	int pass;
+
+	for (pass = 0; pass < 2; ++pass) {
+	    char *p, *q;
+	    size_t count = 0;
+
+	    for (p = q = d_opt; *p != '\0'; ++p) {
+		if (*p == ':') {
+		    if (p != q + 1) {
+			if (pass) {
+			    db_list[count] = make_dbitem(p, q);
+			}
+			count++;
+		    }
+		    q = p + 1;
+		}
+	    }
+	    if (p != q + 1) {
+		if (pass) {
+		    db_list[count] = make_dbitem(p, q);
+		}
+		count++;
+	    }
+	    if (!pass) {
+		db_list = typeCalloc(char *, count + 1);
+	    }
+	}
+    }
+}
+
+static char *
+next_dbitem(void)
+{
+    char *result = 0;
+
+    if (db_list) {
+	if ((result = db_list[db_item]) == 0) {
+	    db_item = 0;
+	    result = db_list[0];
+	} else {
+	    db_item++;
+	}
+    }
+    printf("** %s\n", result ? result : "<null>");
+    return result;
+}
+
+#if NO_LEAKS
+static void
+free_dblist(void)
+{
+    if (db_list) {
+	int n;
+	for (n = 0; db_list[n]; ++n)
+	    free(db_list[n]);
+	free(db_list);
+	db_list = 0;
+    }
+}
+#endif
+
+#define MAXPAR    9
+#define MAXSGR    (1 << MAXPAR)
+#define BITS2P(n) (count & (1 << (n - 1)))
+#define MASK_SMSO (1 << 0)
+#define MASK_BOLD (1 << 5)
+#define MASK_REV  (1 << 2)
+
+static void
+dumpit(unsigned bits, unsigned ignore, const char *sgr, const char *sgr0)
+{
+    static const char sample[] = "abcdefghijklm";
+    static char params[] = "SURBDBIPA";
+    unsigned n;
+
+    printf("%4u ", bits);
+    bits &= ~ignore;
+    for (n = 0; n < MAXPAR; ++n) {
+	putchar((int) ((bits & (unsigned) (1 << n)) ? params[n] : '-'));
+    }
+    putchar(' ');
+    putp(sgr);
+    putp(sample);
+    putp(sgr0);
+    putchar('\n');
+}
+
+static bool
+one_bit(unsigned a, unsigned b)
+{
+    unsigned c = (a ^ b);
+    bool result = FALSE;
+    if (c) {
+	while (!(c & 1)) {
+	    c >>= 1;
+	}
+	result = (c == 1);
+    }
+    return result;
+}
+
+static void
+brute_force(const char *name)
+{
+    unsigned count;
+    char *my_sgr;
+    char *my_sgr0;
+    char *my_bold;
+    char *my_revs;
+    char *my_smso;
+    char *my_name = strdup(name);
+
+    if (db_list) {
+	putenv(next_dbitem());
+    }
+
+    if (!q_opt)
+	printf("Terminal type \"%s\"\n", my_name);
+
+    if (no_init) {
+	START_TRACE();
+    } else {
+	setupterm((NCURSES_CONST char *) my_name, 1, (int *) 0);
+    }
+
+    if (!q_opt) {
+	if (strcmp(my_name, ttytype))
+	    printf("... actual \"%s\"\n", ttytype);
+    }
+
+    my_sgr = tigetstr("sgr");
+    my_sgr0 = tigetstr("sgr0");
+    my_bold = tigetstr("bold");
+    my_revs = tigetstr("rev");
+    my_smso = tigetstr("smso");
+
+    if (!VALID_STRING(my_sgr)) {
+	fprintf(stderr, "no \"sgr\" capability found\n");
+    } else if (!VALID_STRING(my_sgr0)) {
+	fprintf(stderr, "no \"sgr0\" capability found\n");
+    } else {
+	char *values[MAXSGR + MAXPAR];
+	unsigned j;
+	unsigned ignore = 0;
+	unsigned reason = 0;
+	unsigned repeat = 0;
+	for (count = 0; count < MAXSGR; ++count) {
+	    values[count] = tparm(my_sgr,
+				  BITS2P(1),
+				  BITS2P(2),
+				  BITS2P(3),
+				  BITS2P(4),
+				  BITS2P(5),
+				  BITS2P(6),
+				  BITS2P(7),
+				  BITS2P(8),
+				  BITS2P(9));
+	    if (values[count] != 0) {
+		values[count] = strdup(values[count]);
+	    }
+	}
+	for (count = 0; count < MAXSGR; ++count) {
+	    if (values[count] != 0) {
+		for (j = count + 1; j < MAXSGR; ++j) {
+		    if (values[j] == 0)
+			continue;
+		    if (strcmp(values[count], values[j]))
+			continue;
+		    if (one_bit(count, j)) {
+			free(values[j]);
+			values[j] = 0;
+		    }
+		}
+	    }
+	}
+	for (j = 0; j < MAXPAR; ++j) {
+	    unsigned mask = (unsigned) (1 << j);
+	    for (count = 0; count < MAXSGR; ++count) {
+		if ((count & mask) != 0)
+		    continue;
+		if (values[count] != 0 && values[count + mask] != 0) {
+		    mask = 0;
+		    break;
+		}
+	    }
+	    ignore |= mask;
+	}
+	/* smso is tested first, but often duplicates bold or reverse. */
+	if (VALID_STRING(my_smso)) {
+	    if (VALID_STRING(my_bold) && !strcmp(my_bold, my_smso)) {
+		repeat |= MASK_SMSO;
+		reason = MASK_BOLD;
+	    }
+	    if (VALID_STRING(my_revs) && !strcmp(my_revs, my_smso)) {
+		repeat |= MASK_SMSO;
+		reason = MASK_REV;
+	    }
+	}
+	for (count = 0; count < MAXSGR; ++count) {
+	    if (values[count] != 0) {
+		bool found = FALSE;
+		if ((repeat & MASK_SMSO) != 0
+		    && (count & MASK_SMSO) != 0) {
+		    found = TRUE;
+		} else {
+		    for (j = 0; j < count; ++j) {
+			if (values[j] != 0 && !strcmp(values[j], values[count])) {
+			    if ((repeat & MASK_SMSO) != 0
+				&& (j & MASK_SMSO) != 0
+				&& (count & reason) != 0) {
+				continue;
+			    }
+			    found = TRUE;
+			    break;
+			}
+		    }
+		}
+		if (!found) {
+		    dumpit(count, ignore, values[count], my_sgr0);
+		    ++total_values;
+		}
+	    }
+	}
+	for (count = 0; count < MAXSGR; ++count) {
+	    free(values[count]);
+	}
+    }
+    free(my_name);
+    del_curterm(cur_term);
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: test_sgr [options] [terminal]"
+	,""
+	,"Print all distinct combinations of sgr capability."
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -d LIST  colon-separated list of databases to use"
+	," -e NAME  environment variable to set with -d option"
+	," -n       do not initialize terminal, to test error-checking"
+	," -q       quiet (prints only counts)"
+    };
+    unsigned n;
+    for (n = 0; n < SIZEOF(msg); ++n) {
+	fprintf(stderr, "%s\n", msg[n]);
+    }
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+    char *name;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "d:e:nq")) != -1) {
+	switch (ch) {
+	case 'd':
+	    d_opt = optarg;
+	    break;
+	case 'e':
+	    e_opt = optarg;
+	    break;
+	case 'n':
+	    no_init = TRUE;
+	    break;
+	case 'q':
+	    q_opt = TRUE;
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+
+    make_dblist();
+
+    if (optind < argc) {
+	int n;
+	for (n = optind; n < argc; ++n) {
+	    brute_force(argv[n]);
+	}
+    } else if ((name = getenv("TERM")) != 0) {
+	brute_force(name);
+    } else {
+	static char dumb[] = "dumb";
+	brute_force(dumb);
+    }
+
+    printf("%ld distinct values\n", total_values);
+
+#if NO_LEAKS
+    free_dblist();
+#endif
+
+    ExitProgram(EXIT_SUCCESS);
+}
+
+#else /* !HAVE_TIGETSTR */
+int
+main(void)
+{
+    failed("This program requires the terminfo functions such as tigetstr");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif /* HAVE_TIGETSTR */
diff --git a/test/test_termattrs.c b/test/test_termattrs.c
new file mode 100644
index 0000000..ec44cc2
--- /dev/null
+++ b/test/test_termattrs.c
@@ -0,0 +1,207 @@
+/****************************************************************************
+ * Copyright 2020,2022 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.                                                           *
+ ****************************************************************************/
+/*
+ * $Id: test_termattrs.c,v 1.8 2022/12/10 23:23:27 tom Exp $
+ *
+ * Demonstrate the termattrs and term_attrs functions.
+ */
+
+#define USE_CURSES
+#define USE_TINFO
+#include <test.priv.h>
+
+#if HAVE_SETUPTERM
+
+static FILE *my_fp;
+
+static void
+test_termattrs(unsigned long value)
+{
+#define DATA(name) { name, #name }
+    static struct {
+	unsigned long code;
+	const char *name;
+    } table[] = {
+#ifdef A_ATTRIBUTES
+	DATA(A_ATTRIBUTES),
+#endif
+#ifdef A_CHARTEXT
+	    DATA(A_CHARTEXT),
+#endif
+#ifdef A_COLOR
+	    DATA(A_COLOR),
+#endif
+#ifdef A_STANDOUT
+	    DATA(A_STANDOUT),
+#endif
+#ifdef A_UNDERLINE
+	    DATA(A_UNDERLINE),
+#endif
+#ifdef A_REVERSE
+	    DATA(A_REVERSE),
+#endif
+#ifdef A_BLINK
+	    DATA(A_BLINK),
+#endif
+#ifdef A_DIM
+	    DATA(A_DIM),
+#endif
+#ifdef A_BOLD
+	    DATA(A_BOLD),
+#endif
+#ifdef A_ALTCHARSET
+	    DATA(A_ALTCHARSET),
+#endif
+#ifdef A_INVIS
+	    DATA(A_INVIS),
+#endif
+#ifdef A_PROTECT
+	    DATA(A_PROTECT),
+#endif
+#ifdef A_HORIZONTAL
+	    DATA(A_HORIZONTAL),
+#endif
+#ifdef A_LEFT
+	    DATA(A_LEFT),
+#endif
+#ifdef A_LOW
+	    DATA(A_LOW),
+#endif
+#ifdef A_RIGHT
+	    DATA(A_RIGHT),
+#endif
+#ifdef A_TOP
+	    DATA(A_TOP),
+#endif
+#ifdef A_VERTICAL
+	    DATA(A_VERTICAL),
+#endif
+#ifdef A_ITALIC
+	    DATA(A_ITALIC),
+#endif
+    };
+    size_t n;
+    fprintf(my_fp, "Result: %08lX\r\n", value);
+    for (n = 0; n < SIZEOF(table); ++n) {
+	if ((value & table[n].code) != 0) {
+	    fprintf(my_fp, "%08lX %08lX %s\r\n",
+		    table[n].code, value & table[n].code, table[n].name);
+	}
+    };
+    fputs("\r\n", my_fp);
+}
+
+static void
+usage(int ok)
+{
+    static const char *tbl[] =
+    {
+	"Usage: test_termattrs [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -e       use stderr (default stdout)"
+	," -n       do not initialize terminal"
+	," -s       use setupterm rather than newterm"
+#if USE_WIDEC_SUPPORT
+	," -w       use term_attrs rather than termattrs"
+#endif
+    };
+    unsigned n;
+    for (n = 0; n < SIZEOF(tbl); ++n)
+	fprintf(stderr, "%s\n", tbl[n]);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+    bool no_init = FALSE;
+    bool s_opt = FALSE;
+#if USE_WIDEC_SUPPORT
+    bool w_opt = FALSE;
+#endif
+
+    my_fp = stdout;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "ensw")) != -1) {
+	switch (ch) {
+	case 'e':
+	    my_fp = stderr;
+	    break;
+	case 'n':
+	    no_init = TRUE;
+	    break;
+	case 's':
+	    s_opt = TRUE;
+	    break;
+#if USE_WIDEC_SUPPORT
+	case 'w':
+	    w_opt = TRUE;
+	    break;
+#endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
+    if (no_init) {
+	START_TRACE();
+    } else if (s_opt) {
+	setupterm((char *) 0, fileno(my_fp), (int *) 0);
+    } else {
+	newterm((char *) 0, my_fp, stdin);
+    }
+#if USE_WIDEC_SUPPORT
+    if (w_opt)
+	test_termattrs((unsigned long) term_attrs());
+    else
+#endif
+	test_termattrs((unsigned long) termattrs());
+    ExitProgram(EXIT_SUCCESS);
+}
+
+#else
+int
+main(void)
+{
+    fprintf(stderr, "This program requires terminfo\n");
+    exit(EXIT_FAILURE);
+}
+#endif
diff --git a/test/test_tparm.c b/test/test_tparm.c
new file mode 100644
index 0000000..50289de
--- /dev/null
+++ b/test/test_tparm.c
@@ -0,0 +1,709 @@
+/****************************************************************************
+ * Copyright 2020-2022,2023 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
+ *
+ * $Id: test_tparm.c,v 1.39 2023/11/11 01:00:03 tom Exp $
+ *
+ * Exercise tparm/tiparm, either for all possible capabilities with fixed
+ * parameters, or one capability with specific combinations of parameters.
+ */
+#define USE_TINFO
+#include <test.priv.h>
+
+#if NCURSES_XNAMES
+#if HAVE_TERM_ENTRY_H
+#include <term_entry.h>
+#else
+#undef NCURSES_XNAMES
+#define NCURSES_XNAMES 0
+#endif
+#endif
+
+#define MAX_PARM 9
+
+#define GrowArray(array,limit,length) \
+	    if (length + 2 >= limit) { \
+		limit *= 2; \
+		array = typeRealloc(char *, limit, array); \
+		if (array == 0) { \
+		    failed("no memory: " #array); \
+		} \
+	    }
+
+static GCC_NORETURN void failed(const char *);
+
+static void
+failed(const char *msg)
+{
+    fprintf(stderr, "%s\n", msg);
+    ExitProgram(EXIT_FAILURE);
+}
+
+#if HAVE_TIGETSTR
+
+static int a_opt;
+static int p_opt;
+static int v_opt;
+
+#if HAVE_TIPARM
+static int i_opt;
+#endif
+
+#if HAVE_TIPARM_S
+static int s_opt;
+#endif
+
+/*
+ * Total tests (and failures):
+ */
+static long total_tests;
+static long total_fails;
+
+/*
+ * Total characters formatted for tputs:
+ */
+static long total_nulls;
+static long total_ctrls;
+static long total_print;
+
+static int
+output_func(int ch)
+{
+    if (ch == 0) {
+	total_nulls++;
+    } else if (ch < 32 || (ch >= 127 && ch < 160)) {
+	total_ctrls++;
+    } else {
+	total_print++;
+    }
+    return ch;
+}
+
+static int
+isNumeric(char *source)
+{
+    char *next = 0;
+    long value = strtol(source, &next, 0);
+    int result = (next == 0 || next == source || *next != '\0') ? 0 : 1;
+    (void) value;
+    return result;
+}
+
+static int
+relevant(const char *name, const char *value)
+{
+    int code = 1;
+    if (VALID_STRING(value)) {
+	if (strstr(value, "%p") == 0
+	    && strstr(value, "%d") == 0
+	    && strstr(value, "%s") == 0
+	    && (!p_opt || strstr(value, "$<") == 0)) {
+	    if (v_opt > 2)
+		printf("? %s noparams\n", name);
+	    code = 0;
+	}
+    } else {
+	if (v_opt > 2) {
+	    printf("? %s %s\n",
+		   (value == ABSENT_STRING)
+		   ? "absent"
+		   : "cancel",
+		   name);
+	}
+	code = 0;
+    }
+    return code;
+}
+
+static int
+increment(long *all_parms, int *num_parms, int len_parms, int end_parms)
+{
+    int rc = 0;
+    int n;
+
+    if (len_parms > MAX_PARM)
+	len_parms = MAX_PARM;
+
+    if (end_parms < len_parms) {
+	if (all_parms[end_parms]++ >= num_parms[end_parms]) {
+	    all_parms[end_parms] = 0;
+	    increment(all_parms, num_parms, len_parms, end_parms + 1);
+	}
+    }
+    for (n = 0; n < len_parms; ++n) {
+	if (all_parms[n] != 0) {
+	    rc = 1;
+	    break;
+	}
+    }
+    /* return 1 until the vector resets to all 0's */
+    return rc;
+}
+
+/* parse the format string to determine which positional parameters
+ * are assumed to be strings.
+ */
+#if HAVE_TISCAN_S
+static int
+analyze_format(const char *format, int *mask, char **p_is_s)
+{
+    int arg_count;
+    int arg_mask;
+    int n;
+    if (tiscan_s(&arg_count, &arg_mask, format) == OK) {
+	*mask = arg_mask;
+	for (n = 0; n < MAX_PARM; ++n) {
+	    static char dummy[1];
+	    p_is_s[n] = (arg_mask & 1) ? dummy : NULL;
+	    arg_mask >>= 1;
+	}
+    } else {
+	*mask = 0;
+	arg_count = 0;
+	for (n = 0; n < MAX_PARM; ++n) {
+	    p_is_s[n] = NULL;
+	}
+    }
+    return arg_count;
+}
+#elif HAVE__NC_TPARM_ANALYZE
+extern int _nc_tparm_analyze(TERMINAL *, const char *, char **, int *);
+
+static int
+analyze_format(const char *format, int *mask, char **p_is_s)
+{
+    int popcount = 0;
+    int analyzed = _nc_tparm_analyze(cur_term, format, p_is_s, &popcount);
+    int n;
+    if (analyzed < popcount) {
+	analyzed = popcount;
+    }
+    *mask = 0;
+    for (n = 0; n < MAX_PARM; ++n) {
+	if (p_is_s[n])
+	    *mask |= (1 << n);
+    }
+    return analyzed;
+}
+#else
+/* TODO: make this work without direct use of ncurses internals. */
+static int
+analyze_format(const char *format, int *mask, char **p_is_s)
+{
+    int n;
+    char *filler = strstr(format, "%s");
+    *mask = 0;
+    for (n = 0; n < MAX_PARM; ++n) {
+	p_is_s[n] = filler;
+    }
+    return n;
+}
+#endif
+
+#define NumStr(n) use_strings[n] \
+ 		  ? (long) (my_intptr_t) (number[n] \
+		     ? string[n] \
+		     : NULL) \
+		  : number[n]
+
+#define NS_0(fmt)	fmt
+#define NS_1(fmt)	NS_0(fmt), NumStr(0)
+#define NS_2(fmt)	NS_1(fmt), NumStr(1)
+#define NS_3(fmt)	NS_2(fmt), NumStr(2)
+#define NS_4(fmt)	NS_3(fmt), NumStr(3)
+#define NS_5(fmt)	NS_4(fmt), NumStr(4)
+#define NS_6(fmt)	NS_5(fmt), NumStr(5)
+#define NS_7(fmt)	NS_6(fmt), NumStr(6)
+#define NS_8(fmt)	NS_7(fmt), NumStr(7)
+#define NS_9(fmt)	NS_8(fmt), NumStr(8)
+
+static void
+test_tparm(const char *name, const char *format, long *number, char **string)
+{
+    char *use_strings[MAX_PARM];
+    char *result = NULL;
+    int nparam;
+    int mask;
+
+    nparam = analyze_format(format, &mask, use_strings);
+#if HAVE_TIPARM_S
+    if (s_opt) {
+	switch (nparam) {
+	case 0:
+	    result = tiparm_s(0, mask, NS_0(format));
+	    break;
+	case 1:
+	    result = tiparm_s(1, mask, NS_1(format));
+	    break;
+	case 2:
+	    result = tiparm_s(2, mask, NS_2(format));
+	    break;
+	case 3:
+	    result = tiparm_s(3, mask, NS_3(format));
+	    break;
+	case 4:
+	    result = tiparm_s(4, mask, NS_4(format));
+	    break;
+	case 5:
+	    result = tiparm_s(5, mask, NS_5(format));
+	    break;
+	case 6:
+	    result = tiparm_s(6, mask, NS_6(format));
+	    break;
+	case 7:
+	    result = tiparm_s(7, mask, NS_7(format));
+	    break;
+	case 8:
+	    result = tiparm_s(8, mask, NS_8(format));
+	    break;
+	case 9:
+	    result = tiparm_s(9, mask, NS_9(format));
+	    break;
+	}
+    } else
+#endif
+#if HAVE_TIPARM
+    if (i_opt) {
+	switch (nparam) {
+	case 0:
+	    result = tiparm(NS_0(format));
+	    break;
+	case 1:
+	    result = tiparm(NS_1(format));
+	    break;
+	case 2:
+	    result = tiparm(NS_2(format));
+	    break;
+	case 3:
+	    result = tiparm(NS_3(format));
+	    break;
+	case 4:
+	    result = tiparm(NS_4(format));
+	    break;
+	case 5:
+	    result = tiparm(NS_5(format));
+	    break;
+	case 6:
+	    result = tiparm(NS_6(format));
+	    break;
+	case 7:
+	    result = tiparm(NS_7(format));
+	    break;
+	case 8:
+	    result = tiparm(NS_8(format));
+	    break;
+	case 9:
+	    result = tiparm(NS_9(format));
+	    break;
+	}
+    } else
+#endif
+	result = tparm(NS_9(format));
+    total_tests++;
+    if (result != NULL) {
+	tputs(result, 1, output_func);
+    } else {
+	total_fails++;
+    }
+    if (v_opt > 1) {
+	int n;
+	printf(".. %3d =", result != 0 ? (int) strlen(result) : -1);
+	for (n = 0; n < nparam; ++n) {
+	    if (use_strings[n]) {
+		if (number[n]) {
+		    printf(" \"%s\"", string[n]);
+		} else {
+		    printf("  ?");
+		}
+	    } else {
+		printf(" %2ld", number[n]);
+	    }
+	}
+	printf(" %s\n", name);
+    }
+}
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: test_tparm [options] [capability] [value1 [value2 [...]]]"
+	,""
+	,"Use tparm/tputs for all distinct combinations of given capability."
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -T TERM  override $TERM; this may be a comma-separated list or \"-\""
+	,"          to read a list from standard-input"
+	," -a       test all combinations of parameters"
+	,"          [value1...] forms a vector of maximum parameter-values."
+#if HAVE_TIPARM
+	," -i       test tiparm rather than tparm"
+#endif
+	," -p       test capabilities with no parameters but having padding"
+	," -r NUM   repeat tests NUM times"
+#if HAVE_TIPARM_S
+	," -s       test tiparm_s rather than tparm"
+#endif
+	," -v       show values and results"
+    };
+    unsigned n;
+    for (n = 0; n < SIZEOF(msg); ++n) {
+	fprintf(stderr, "%s\n", msg[n]);
+    }
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+
+#define PLURAL(n) n, (n != 1) ? "s" : ""
+#define COLONS(n) (n >= 1) ? ":" : ""
+
+#define NUMFORM "%10ld"
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+    int n;
+    int r_run, t_run, n_run;
+    char *old_term = getenv("TERM");
+    int r_opt = 1;
+    char *t_opt = 0;
+
+    int std_caps = 0;		/* predefine items in all_caps[] */
+    int len_caps = 0;		/* cur # of items in all_caps[] */
+    int max_caps = 10;		/* max # of items in all_caps[] */
+    char **all_caps = typeCalloc(char *, max_caps);
+
+    long all_parms[10];		/* workspace for "-a" option */
+
+    int len_terms = 0;		/* cur # of items in all_terms[] */
+    int max_terms = 10;		/* max # of items in all_terms[] */
+    char **all_terms = typeCalloc(char *, max_terms);
+
+    int use_caps;
+    int max_name = 10;		/* max # of items in cap_name[] */
+    int max_data = 10;		/* max # of items in cap_data[] */
+    char **cap_name;
+    char **cap_data;
+
+    int len_parms = 0;		/* cur # of items in num_parms[], str_parms[] */
+    int max_parms = argc + 10;	/* max # of items in num_parms[], str_parms[] */
+    int *num_parms = typeCalloc(int, max_parms);
+    char **str_parms = typeCalloc(char *, max_parms);
+    long use_parms = 1;
+
+    if (all_caps == 0 || all_terms == 0 || num_parms == 0 || str_parms == 0)
+	failed("no memory");
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "T:aipr:sv")) != -1) {
+	switch (ch) {
+	case 'T':
+	    t_opt = optarg;
+	    break;
+	case 'a':
+	    ++a_opt;
+	    break;
+#if HAVE_TIPARM
+	case 'i':
+	    ++i_opt;
+	    break;
+#endif
+	case 'p':
+	    ++p_opt;
+	    break;
+	case 'r':
+	    r_opt = atoi(optarg);
+	    break;
+#if HAVE_TIPARM_S
+	case 's':
+	    ++s_opt;
+	    break;
+#endif
+	case 'v':
+	    ++v_opt;
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+
+    /*
+     * If there is a nonnumeric parameter after the options, use that as the
+     * capability name.
+     */
+    if (optind < argc) {
+	if (!isNumeric(argv[optind])) {
+	    all_caps[len_caps++] = strdup(argv[optind++]);
+	}
+    }
+
+    /*
+     * Any remaining arguments must be possible parameter values.  If numeric,
+     * and "-a" is not set, use those as the actual values for which the
+     * capabilities are tested.
+     */
+    while (optind < argc) {
+	if (isNumeric(argv[optind])) {
+	    char *dummy = 0;
+	    long value = strtol(argv[optind], &dummy, 0);
+	    num_parms[len_parms] = (int) value;
+	}
+	str_parms[len_parms] = argv[optind];
+	++optind;
+	++len_parms;
+    }
+    for (n = len_parms; n < max_parms; ++n) {
+	static char dummy[1];
+	str_parms[n] = dummy;
+    }
+    if (v_opt) {
+	printf("%d parameter%s%s\n", PLURAL(len_parms), COLONS(len_parms));
+	if (v_opt > 3) {
+	    for (n = 0; n < len_parms; ++n) {
+		printf(" %d: %d (%s)\n", n + 1, num_parms[n], str_parms[n]);
+	    }
+	}
+    }
+
+    /*
+     * Make a list of values for $TERM.  Accept "-" for standard input to
+     * simplify scripting a check of the whole database.
+     */
+    old_term = strdup((old_term == 0) ? "unknown" : old_term);
+    if (t_opt != 0) {
+	if (!strcmp(t_opt, "-")) {
+	    char buffer[BUFSIZ];
+	    while (fgets(buffer, sizeof(buffer) - 1, stdin) != 0) {
+		char *s = buffer;
+		char *t;
+		while (isspace(UChar(s[0])))
+		    ++s;
+		t = s + strlen(s);
+		while (t != s && isspace(UChar(t[-1])))
+		    *--t = '\0';
+		s = strdup(s);
+		if (len_terms + 2 >= max_terms) {
+		    max_terms *= 2;
+		    all_terms = typeRealloc(char *, max_terms, all_terms);
+		    if (all_terms == 0)
+			failed("no memory: all_terms");
+		}
+		all_terms[len_terms++] = s;
+	    }
+	} else {
+	    char *s = t_opt;
+	    char *t;
+	    while ((t = strtok(s, ",")) != 0) {
+		s = 0;
+		if (len_terms + 2 >= max_terms) {
+		    max_terms *= 2;
+		    all_terms = typeRealloc(char *, max_terms, all_terms);
+		    if (all_terms == 0)
+			failed("no memory: all_terms");
+		}
+		all_terms[len_terms++] = strdup(t);
+	    }
+	}
+    } else {
+	all_terms[len_terms++] = strdup(old_term);
+    }
+    all_terms[len_terms] = 0;
+    if (v_opt) {
+	printf("%d term%s:\n", PLURAL(len_terms));
+	if (v_opt > 3) {
+	    for (n = 0; n < len_terms; ++n) {
+		printf(" %d: %s\n", n + 1, all_terms[n]);
+	    }
+	}
+    }
+
+    /*
+     * If no capability name was selected, use the predefined list of string
+     * capabilities.
+     *
+     * TODO: To address the "other" systems which do not follow SVr4,
+     * just use the output from infocmp on $TERM.
+     */
+    if (len_caps == 0) {
+#if defined(HAVE_CURSES_DATA_BOOLNAMES) || defined(DECL_CURSES_DATA_BOOLNAMES)
+	for (n = 0; strnames[n] != 0; ++n) {
+	    GrowArray(all_caps, max_caps, len_caps);
+	    all_caps[len_caps++] = strdup(strnames[n]);
+	}
+#else
+	all_caps[len_caps++] = strdup("cup");
+	all_caps[len_caps++] = strdup("sgr");
+#endif
+    }
+    std_caps = len_caps;
+    all_caps[len_caps] = 0;
+    if (v_opt) {
+	printf("%d name%s%s\n", PLURAL(len_caps), COLONS(len_caps));
+	if (v_opt > 3) {
+	    for (n = 0; n < len_caps; ++n) {
+		printf(" %d: %s\n", n + 1, all_caps[n]);
+	    }
+	}
+    }
+
+    cap_name = typeMalloc(char *, (max_name = 1 + len_caps));
+    cap_data = typeMalloc(char *, (max_data = 1 + len_caps));
+
+    if (r_opt <= 0)
+	r_opt = 1;
+
+    if (a_opt) {
+	for (n = 0; n < max_parms; ++n)
+	    if (num_parms[n])
+		use_parms *= (num_parms[n] + 1);
+    }
+
+    for (r_run = 0; r_run < r_opt; ++r_run) {
+	for (t_run = 0; t_run < len_terms; ++t_run) {
+	    int errs;
+
+	    if (setupterm(all_terms[t_run], fileno(stdout), &errs) != OK) {
+		printf("** skipping %s (errs:%d)\n", all_terms[t_run], errs);
+	    }
+#if NCURSES_XNAMES
+	    len_caps = std_caps;
+	    if (cur_term) {
+		TERMTYPE *term = (TERMTYPE *) cur_term;
+		for (n = STRCOUNT; n < NUM_STRINGS(term); ++n) {
+		    GrowArray(all_caps, max_caps, len_caps);
+		    GrowArray(cap_name, max_name, len_caps);
+		    GrowArray(cap_data, max_data, len_caps);
+		    all_caps[len_caps++] = strdup(ExtStrname(term, (int) n, strnames));
+		}
+	    }
+#else
+	    (void) std_caps;
+#endif
+
+	    /*
+	     * Most of the capabilities have no parameters, e.g., they are
+	     * function-keys or simple operations such as clear-display.
+	     * Ignore those, since they do not really exercise tparm.
+	     */
+	    use_caps = 0;
+	    for (n = 0; n < len_caps; ++n) {
+		char *value = tigetstr(all_caps[n]);
+		if (relevant(all_caps[n], value)) {
+		    cap_name[use_caps] = all_caps[n];
+		    cap_data[use_caps] = value;
+		    use_caps++;
+		}
+	    }
+
+	    if (v_opt) {
+		printf("[%d:%d] %d paramerized cap%s * %ld test-case%s \"%s\"\n",
+		       r_run + 1, r_opt,
+		       PLURAL(use_caps),
+		       PLURAL(use_parms),
+		       all_terms[t_run]);
+	    }
+
+	    memset(all_parms, 0, sizeof(all_parms));
+	    if (a_opt) {
+		/* for each combination of values */
+		do {
+		    for (n_run = 0; n_run < use_caps; ++n_run) {
+			test_tparm(cap_name[n_run],
+				   cap_data[n_run],
+				   all_parms,
+				   str_parms);
+		    }
+		}
+		while (increment(all_parms, num_parms, len_parms, 0));
+	    } else {
+		/* for the given values */
+		for (n_run = 0; n_run < use_caps; ++n_run) {
+		    test_tparm(cap_name[n_run],
+			       cap_data[n_run],
+			       all_parms,
+			       str_parms);
+		}
+	    }
+#if NCURSES_XNAMES
+	    for (n = std_caps; n < len_caps; ++n) {
+		free(all_caps[n]);
+	    }
+#endif
+	    if (cur_term != 0) {
+		del_curterm(cur_term);
+	    } else {
+		printf("? no cur_term\n");
+	    }
+	}
+    }
+
+    printf("Tests:\n");
+    printf(NUMFORM " total\n", total_tests);
+    if (total_fails)
+	printf(NUMFORM " failed\n", total_fails);
+    printf("Characters:\n");
+    printf(NUMFORM " nulls\n", total_nulls);
+    printf(NUMFORM " controls\n", total_ctrls);
+    printf(NUMFORM " printable\n", total_print);
+    printf(NUMFORM " total\n", total_nulls + total_ctrls + total_print);
+#if NO_LEAKS
+    for (n = 0; n < std_caps; ++n) {
+	free(all_caps[n]);
+    }
+    free(all_caps);
+    free(old_term);
+    for (n = 0; n < len_terms; ++n) {
+	free(all_terms[n]);
+    }
+    free(all_terms);
+    free(num_parms);
+    free(str_parms);
+    free(cap_name);
+    free(cap_data);
+#endif
+
+    ExitProgram(EXIT_SUCCESS);
+}
+
+#else /* !HAVE_TIGETSTR */
+int
+main(void)
+{
+    failed("This program requires the terminfo functions such as tigetstr");
+}
+#endif /* HAVE_TIGETSTR */
diff --git a/test/test_unget_wch.c b/test/test_unget_wch.c
new file mode 100644
index 0000000..5808530
--- /dev/null
+++ b/test/test_unget_wch.c
@@ -0,0 +1,116 @@
+/****************************************************************************
+ * Copyright 2022 Thomas E. Dickey                                          *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+/*
+ * $Id: test_unget_wch.c,v 1.4 2022/12/10 23:31:31 tom Exp $
+ *
+ * Demonstrate the unget_wch and unget functions.
+ */
+
+#include <test.priv.h>
+
+#if USE_WIDEC_SUPPORT && HAVE_UNGET_WCH
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: test_unget_wch [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int step = 0;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
+    setlocale(LC_ALL, "");
+    initscr();
+    keypad(stdscr, TRUE);
+    cbreak();
+    noecho();
+    scrollok(stdscr, TRUE);
+
+    for (;;) {
+	wint_t widechar;
+	int rc = get_wch(&widechar);
+	if (rc == KEY_CODE_YES) {
+	    printw("KEY[%d] %s\n", ++step, keyname((int) widechar));
+	    ungetch((int) widechar);
+	    printw("...[%d] %s\n", step, keyname(getch()));
+	} else if (widechar == QUIT || widechar == ESCAPE) {
+	    break;
+	} else {
+	    printw("CHR[%d] %s\n", ++step, key_name((wchar_t) widechar));
+	    unget_wch((wchar_t) widechar);
+	    rc = get_wch(&widechar);
+	    printw("%s[%d] %s\n",
+		   ((rc == KEY_CODE_YES)
+		    ? "???"
+		    : "..."),
+		   step, key_name((wchar_t) widechar));
+	}
+    }
+
+    endwin();
+
+    ExitProgram(EXIT_SUCCESS);
+}
+
+#else
+int
+main(void)
+{
+    printf("This program requires the wide-ncurses library\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
diff --git a/test/test_vid_puts.c b/test/test_vid_puts.c
index 9896d1b..0d7d7ab 100644
--- a/test/test_vid_puts.c
+++ b/test/test_vid_puts.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2013,2014 Free Software Foundation, Inc.                   *
+ * Copyright 2020-2021,2022 Thomas E. Dickey                                *
+ * Copyright 2013-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_vid_puts.c,v 1.6 2014/07/19 23:09:28 tom Exp $
+ * $Id: test_vid_puts.c,v 1.17 2022/12/10 22:28:50 tom Exp $
  *
  * Demonstrate the vid_puts and vid_attr functions.
  * Thomas Dickey - 2013/01/12
@@ -37,15 +38,13 @@
 
 #if USE_WIDEC_SUPPORT && HAVE_SETUPTERM && HAVE_VID_PUTS
 
-#define valid(s) ((s != 0) && s != (char *)-1)
-
 static FILE *my_fp;
 static bool p_opt = FALSE;
 
 static
 TPUTS_PROTO(outc, c)
 {
-    int rc = c;
+    int rc;
 
     rc = putc(c, my_fp);
     TPUTS_RETURN(rc);
@@ -54,7 +53,7 @@
 static bool
 outs(const char *s)
 {
-    if (valid(s)) {
+    if (VALID_STRING(s)) {
 	tputs(s, 1, outc);
 	return TRUE;
     }
@@ -64,10 +63,12 @@
 static void
 cleanup(void)
 {
-    outs(exit_attribute_mode);
-    if (!outs(orig_colors))
-	outs(orig_pair);
-    outs(cursor_normal);
+    if (cur_term != 0) {
+	outs(exit_attribute_mode);
+	if (!outs(orig_colors))
+	    outs(orig_pair);
+	outs(cursor_normal);
+    }
 }
 
 static void
@@ -93,46 +94,63 @@
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *tbl[] =
     {
 	"Usage: test_vid_puts [options]"
 	,""
+	,USAGE_COMMON
 	,"Options:"
-	,"  -e      use stderr (default stdout)"
-	,"  -p      use vid_puts (default vid_attr)"
+	," -e       use stderr (default stdout)"
+	," -n       do not initialize terminal"
+	," -p       use vid_puts (default vid_attr)"
     };
     unsigned n;
     for (n = 0; n < SIZEOF(tbl); ++n)
 	fprintf(stderr, "%s\n", tbl[n]);
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     int ch;
+    bool no_init = FALSE;
 
     my_fp = stdout;
 
-    while ((ch = getopt(argc, argv, "ep")) != -1) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "enp")) != -1) {
 	switch (ch) {
 	case 'e':
 	    my_fp = stderr;
 	    break;
+	case 'n':
+	    no_init = TRUE;
+	    break;
 	case 'p':
 	    p_opt = TRUE;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
-	    break;
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
     if (optind < argc)
-	usage();
+	usage(FALSE);
 
-    setupterm((char *) 0, 1, (int *) 0);
+    setlocale(LC_ALL, "");
+    if (no_init) {
+	START_TRACE();
+    } else {
+	setupterm((char *) 0, fileno(my_fp), (int *) 0);
+    }
     test_vid_puts();
     cleanup();
     ExitProgram(EXIT_SUCCESS);
diff --git a/test/test_vidputs.c b/test/test_vidputs.c
index 7c7ade3..31dc9da 100644
--- a/test/test_vidputs.c
+++ b/test/test_vidputs.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2013,2014 Free Software Foundation, Inc.                   *
+ * Copyright 2020-2021,2022 Thomas E. Dickey                                *
+ * Copyright 2013-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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_vidputs.c,v 1.5 2014/07/19 23:09:58 tom Exp $
+ * $Id: test_vidputs.c,v 1.15 2022/12/10 23:23:27 tom Exp $
  *
  * Demonstrate the vidputs and vidattr functions.
  * Thomas Dickey - 2013/01/12
@@ -37,15 +38,13 @@
 
 #if HAVE_SETUPTERM && HAVE_VIDPUTS
 
-#define valid(s) ((s != 0) && s != (char *)-1)
-
 static FILE *my_fp;
 static bool p_opt = FALSE;
 
 static
 TPUTS_PROTO(outc, c)
 {
-    int rc = c;
+    int rc;
 
     rc = putc(c, my_fp);
     TPUTS_RETURN(rc);
@@ -54,7 +53,7 @@
 static bool
 outs(const char *s)
 {
-    if (valid(s)) {
+    if (VALID_STRING(s)) {
 	tputs(s, 1, outc);
 	return TRUE;
     }
@@ -64,10 +63,12 @@
 static void
 cleanup(void)
 {
-    outs(exit_attribute_mode);
-    if (!outs(orig_colors))
-	outs(orig_pair);
-    outs(cursor_normal);
+    if (cur_term != 0) {
+	outs(exit_attribute_mode);
+	if (!outs(orig_colors))
+	    outs(orig_pair);
+	outs(cursor_normal);
+    }
 }
 
 static void
@@ -93,54 +94,70 @@
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *tbl[] =
     {
 	"Usage: test_vidputs [options]"
 	,""
+	,USAGE_COMMON
 	,"Options:"
-	,"  -e      use stderr (default stdout)"
-	,"  -p      use vidputs (default vidattr)"
+	," -e       use stderr (default stdout)"
+	," -n       do not initialize terminal"
+	," -p       use vidputs (default vidattr)"
     };
     unsigned n;
     for (n = 0; n < SIZEOF(tbl); ++n)
 	fprintf(stderr, "%s\n", tbl[n]);
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     int ch;
+    bool no_init = FALSE;
 
     my_fp = stdout;
 
-    while ((ch = getopt(argc, argv, "ep")) != -1) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "enp")) != -1) {
 	switch (ch) {
 	case 'e':
 	    my_fp = stderr;
 	    break;
+	case 'n':
+	    no_init = TRUE;
+	    break;
 	case 'p':
 	    p_opt = TRUE;
 	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
-	    break;
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
     if (optind < argc)
-	usage();
+	usage(FALSE);
 
-    setupterm((char *) 0, 1, (int *) 0);
+    if (no_init) {
+	START_TRACE();
+    } else {
+	setupterm((char *) 0, fileno(my_fp), (int *) 0);
+    }
     test_vidputs();
     cleanup();
     ExitProgram(EXIT_SUCCESS);
 }
+
 #else
 int
-main(int argc GCC_UNUSED,
-     char *argv[]GCC_UNUSED)
+main(void)
 {
     fprintf(stderr, "This program requires terminfo\n");
     exit(EXIT_FAILURE);
diff --git a/test/testaddch.c b/test/testaddch.c
index ccadab8..e393c3c 100644
--- a/test/testaddch.c
+++ b/test/testaddch.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 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            *
@@ -29,7 +30,7 @@
  * This is an example written by Alexander V. Lukyanov <lav@yars.free.net>,
  * to demonstrate an inconsistency between ncurses and SVr4 curses.
  *
- * $Id: testaddch.c,v 1.12 2014/08/02 23:11:20 tom Exp $
+ * $Id: testaddch.c,v 1.15 2022/12/10 23:44:18 tom Exp $
  */
 #include <test.priv.h>
 
@@ -40,13 +41,45 @@
 	addch(((unsigned char) (*s++)) | a);
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: testaddch [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
-main(
-	int argc GCC_UNUSED,
-	char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     unsigned i;
     chtype back, set, attr;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
 
     setlocale(LC_ALL, "");
 
diff --git a/test/testcurs.c b/test/testcurs.c
index 7a44a2c..750e5a4 100644
--- a/test/testcurs.c
+++ b/test/testcurs.c
@@ -6,13 +6,13 @@
  *  wrs(5/28/93) -- modified to be consistent (perform identically) with either
  *                  PDCurses or under Unix System V, R4
  *
- * $Id: testcurs.c,v 1.50 2015/07/05 00:11:10 tom Exp $
+ * $Id: testcurs.c,v 1.58 2023/05/28 14:23:34 tom Exp $
  */
 
 #include <test.priv.h>
 
 #if defined(XCURSES)
-char *XCursesProgramName = "testcurs";
+const char *XCursesProgramName = "testcurs";
 #endif
 
 static int initTest(WINDOW **);
@@ -20,127 +20,16 @@
 static void inputTest(WINDOW *);
 static void introTest(WINDOW *);
 static void outputTest(WINDOW *);
+#if HAVE_NEWPAD
 static void padTest(WINDOW *);
+#endif
 static void scrollTest(WINDOW *);
 #if defined(PDCURSES) && !defined(XCURSES)
 static void resizeTest(WINDOW *);
 #endif
 
-struct commands {
-    NCURSES_CONST char *text;
-    void (*function) (WINDOW *);
-};
-typedef struct commands COMMAND;
-
-static const COMMAND command[] =
-{
-    {"General Test", introTest},
-    {"Pad Test", padTest},
-#if defined(PDCURSES) && !defined(XCURSES)
-    {"Resize Test", resizeTest},
-#endif
-    {"Scroll Test", scrollTest},
-    {"Input Test", inputTest},
-    {"Output Test", outputTest}
-};
-#define MAX_OPTIONS (int) SIZEOF(command)
-
 static int width, height;
 
-int
-main(
-	int argc GCC_UNUSED,
-	char *argv[]GCC_UNUSED)
-{
-    WINDOW *win;
-    int key;
-    int old_option = (-1);
-    int new_option = 0;
-    bool quit = FALSE;
-    int n;
-
-    setlocale(LC_ALL, "");
-
-#ifdef PDCDEBUG
-    PDC_debug("testcurs started\n");
-#endif
-    if (!initTest(&win))
-	ExitProgram(EXIT_FAILURE);
-
-    erase();
-    display_menu(old_option, new_option);
-    for (;;) {
-#ifdef A_COLOR
-	if (has_colors()) {
-	    init_pair(1, COLOR_WHITE, COLOR_BLUE);
-	    wbkgd(win, (chtype) COLOR_PAIR(1));
-	} else
-	    wbkgd(win, A_REVERSE);
-#else
-	wbkgd(win, A_REVERSE);
-#endif
-	werase(win);
-
-	noecho();
-	keypad(stdscr, TRUE);
-	raw();
-	key = getch();
-	if (key < KEY_MIN && key > 0 && isalpha(key)) {
-	    if (islower(key))
-		key = toupper(key);
-	    for (n = 0; n < MAX_OPTIONS; ++n) {
-		if (key == command[n].text[0]) {
-		    display_menu(old_option, new_option = n);
-		    key = ' ';
-		    break;
-		}
-	    }
-	}
-	switch (key) {
-	case 10:
-	case 13:
-	case KEY_ENTER:
-	    erase();
-	    refresh();
-	    (*command[new_option].function) (win);
-	    erase();
-	    display_menu(old_option, new_option);
-	    break;
-	case KEY_UP:
-	    new_option = ((new_option == 0)
-			  ? new_option
-			  : new_option - 1);
-	    display_menu(old_option, new_option);
-	    break;
-	case KEY_DOWN:
-	    new_option = ((new_option == (MAX_OPTIONS - 1))
-			  ? new_option
-			  : new_option + 1);
-	    display_menu(old_option, new_option);
-	    break;
-	case 'Q':
-	case 'q':
-	    quit = TRUE;
-	    break;
-	default:
-	    beep();
-	    break;
-	case ' ':
-	    break;
-	}
-	if (quit == TRUE)
-	    break;
-    }
-
-    delwin(win);
-
-    endwin();
-#ifdef XCURSES
-    XCursesExit();
-#endif
-    ExitProgram(EXIT_SUCCESS);
-}
-
 static void
 Continue(WINDOW *win)
 {
@@ -170,7 +59,7 @@
     PDC_debug("initTest called\n");
 #endif
 #ifdef TRACE
-    trace(TRACE_MAXIMUM);
+    curses_trace(TRACE_MAXIMUM);
 #endif
     initscr();
 #ifdef PDCDEBUG
@@ -184,7 +73,7 @@
     height = 13;		/* Create a drawing window */
     *win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2);
     if (*win == NULL) {
-	endwin();
+	stop_curses();
 	return 0;
     }
     return 1;
@@ -271,7 +160,7 @@
 {
     int answered;
     int repeat;
-    int w, h, bx, by, sw, sh, i, c, num;
+    int w, h, bx, by, sw, sh, i, num;
     char buffer[80];
     WINDOW *subWin;
     wclear(win);
@@ -349,6 +238,8 @@
 #endif
 
     for (;;) {
+	int c;
+
 	wmove(win, 3, 5);
 	c = wgetch(win);
 	wclrtobot(win);
@@ -361,11 +252,11 @@
 #ifdef KEY_MOUSE
 	if (c == KEY_MOUSE) {
 #if defined(NCURSES_MOUSE_VERSION)
-#define ButtonChanged(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, 037))
-#define ButtonPressed(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED))
-#define ButtonDouble(n)  ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED))
-#define ButtonTriple(n)  ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED))
-#define ButtonRelease(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED))
+#define ButtonChanged(n) ((event.bstate) & NCURSES_MOUSE_MASK(n, (NCURSES_BUTTON_RELEASED|NCURSES_BUTTON_PRESSED|NCURSES_BUTTON_CLICKED|NCURSES_DOUBLE_CLICKED|NCURSES_TRIPLE_CLICKED|NCURSES_RESERVED_EVENT)))
+#define ButtonPressed(n) ((event.bstate) & NCURSES_MOUSE_MASK(n, NCURSES_BUTTON_PRESSED))
+#define ButtonDouble(n)  ((event.bstate) & NCURSES_MOUSE_MASK(n, NCURSES_DOUBLE_CLICKED))
+#define ButtonTriple(n)  ((event.bstate) & NCURSES_MOUSE_MASK(n, NCURSES_TRIPLE_CLICKED))
+#define ButtonRelease(n) ((event.bstate) & NCURSES_MOUSE_MASK(n, NCURSES_BUTTON_RELEASED))
 	    MEVENT event;
 	    int button = 0;
 
@@ -466,7 +357,6 @@
 static void
 outputTest(WINDOW *win)
 {
-    WINDOW *win1;
     char Buffer[80];
     chtype ch;
     int by, bx;
@@ -506,7 +396,7 @@
 	MvWAddStr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS");
 	Continue(win);
     } else {
-	win1 = newwin(10, 50, 14, 25);
+	WINDOW *win1 = newwin(10, 50, 14, 25);
 	if (win1 == NULL) {
 	    endwin();
 	    return;
@@ -668,7 +558,7 @@
 
     win1 = newwin(10, 50, 14, 25);
     if (win1 == NULL) {
-	endwin();
+	stop_curses();
 	return;
     }
 #ifdef A_COLOR
@@ -696,12 +586,15 @@
 }
 #endif
 
+#if HAVE_NEWPAD
 static void
 padTest(WINDOW *dummy GCC_UNUSED)
 {
-    WINDOW *pad, *spad;
+    WINDOW *pad;
 
     if ((pad = newpad(50, 100)) != 0) {
+	WINDOW *spad;
+
 	wattron(pad, A_REVERSE);
 	MvWAddStr(pad, 5, 2, "This is a new pad");
 	(void) wattrset(pad, A_NORMAL);
@@ -736,6 +629,28 @@
 	delwin(pad);
     }
 }
+#endif /* HAVE_NEWPAD */
+
+struct commands {
+    NCURSES_CONST char *text;
+    void (*function) (WINDOW *);
+};
+typedef struct commands COMMAND;
+
+static const COMMAND command[] =
+{
+    {"General Test", introTest},
+#if HAVE_NEWPAD
+    {"Pad Test", padTest},
+#endif
+#if defined(PDCURSES) && !defined(XCURSES)
+    {"Resize Test", resizeTest},
+#endif
+    {"Scroll Test", scrollTest},
+    {"Input Test", inputTest},
+    {"Output Test", outputTest}
+};
+#define MAX_OPTIONS (int) SIZEOF(command)
 
 static void
 display_menu(int old_option, int new_option)
@@ -760,3 +675,131 @@
 	     "Use Up and Down Arrows to select - Enter to run - Q to quit");
     refresh();
 }
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: testcurs [options]"
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    WINDOW *win;
+    int old_option = (-1);
+    int new_option = 0;
+    bool quit = FALSE;
+    int n;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+    if (optind < argc)
+	usage(FALSE);
+
+    setlocale(LC_ALL, "");
+
+#ifdef PDCDEBUG
+    PDC_debug("testcurs started\n");
+#endif
+    if (!initTest(&win))
+	ExitProgram(EXIT_FAILURE);
+
+    erase();
+    display_menu(old_option, new_option);
+
+    for (;;) {
+	int key;
+
+#ifdef A_COLOR
+	if (has_colors()) {
+	    init_pair(1, COLOR_WHITE, COLOR_BLUE);
+	    wbkgd(win, (chtype) COLOR_PAIR(1));
+	} else
+	    wbkgd(win, A_REVERSE);
+#else
+	wbkgd(win, A_REVERSE);
+#endif
+	werase(win);
+
+	noecho();
+	keypad(stdscr, TRUE);
+	raw();
+	key = getch();
+	if (key < KEY_MIN && key > 0 && isalpha(key)) {
+	    if (islower(key))
+		key = toupper(key);
+	    for (n = 0; n < MAX_OPTIONS; ++n) {
+		if (key == command[n].text[0]) {
+		    display_menu(old_option, new_option = n);
+		    key = ' ';
+		    break;
+		}
+	    }
+	}
+	switch (key) {
+	case 10:
+	case 13:
+	case KEY_ENTER:
+	    erase();
+	    refresh();
+	    (*command[new_option].function) (win);
+	    erase();
+	    display_menu(old_option, new_option);
+	    break;
+	case KEY_UP:
+	    new_option = ((new_option == 0)
+			  ? new_option
+			  : new_option - 1);
+	    display_menu(old_option, new_option);
+	    break;
+	case KEY_DOWN:
+	    new_option = ((new_option == (MAX_OPTIONS - 1))
+			  ? new_option
+			  : new_option + 1);
+	    display_menu(old_option, new_option);
+	    break;
+	case 'Q':
+	case 'q':
+	    quit = TRUE;
+	    break;
+	default:
+	    beep();
+	    break;
+	case ' ':
+	    break;
+	}
+	if (quit == TRUE)
+	    break;
+    }
+
+    delwin(win);
+
+    stop_curses();
+#ifdef XCURSES
+    XCursesExit();
+#endif
+    ExitProgram(EXIT_SUCCESS);
+}
diff --git a/test/testscanw.c b/test/testscanw.c
index 79589c2..415250c 100644
--- a/test/testscanw.c
+++ b/test/testscanw.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2022 Thomas E. Dickey                                *
+ * Copyright 1998-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            *
@@ -29,15 +30,49 @@
  * Date:  1997/03/17
  * From:  bayern@morpheus.cis.yale.edu
  *
- * $Id: testscanw.c,v 1.11 2006/04/01 19:08:03 tom Exp $
+ * $Id: testscanw.c,v 1.15 2022/12/11 00:10:29 tom Exp $
  */
 #include <test.priv.h>
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: testscanw [options] tokens"
+	,""
+	,"Tokens are integers (starting line-number) or k+, k- to turn keypad on/off."
+	,""
+	,USAGE_COMMON
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
 main(int argc, char *argv[])
 {
     long badanswer = 1;
     long *response = &badanswer;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+	switch (ch) {
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
 
     setlocale(LC_ALL, "");
 
@@ -47,14 +82,16 @@
     echo();
 
 #if 0
-    trace(TRACE_UPDATE | TRACE_CALLS);
+    curses_trace(TRACE_UPDATE | TRACE_CALLS);
 #endif
-    while (argc > 1) {
-	if (isdigit(UChar(*argv[1])))
-	    move(atoi(argv[1]), 0);
-	else if (!strcmp(argv[1], "-k"))
+    while (optind < argc) {
+	char *token = argv[optind++];
+	if (isdigit(UChar(*token)))
+	    move(atoi(token), 0);
+	else if (!strcmp(token, "k+"))
 	    keypad(stdscr, TRUE);
-	argc--, argv++;
+	else if (!strcmp(token, "k-"))
+	    keypad(stdscr, FALSE);
     }
 
     while (badanswer) {
diff --git a/test/tput-colorcube b/test/tput-colorcube
new file mode 100755
index 0000000..67a4997
--- /dev/null
+++ b/test/tput-colorcube
@@ -0,0 +1,131 @@
+#!/bin/sh
+##############################################################################
+# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 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 "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: tput-colorcube,v 1.2 2020/02/02 23:34:34 tom Exp $
+# Use this script to print an xterm-style color cube, e.g., as done in
+# the xterm 88colors2.pl and 256colors2.pl scripts.
+
+failed() {
+	printf "?? $*\n" >&2
+	exit 1
+}
+
+newline() {
+	tput op
+	printf "\n"
+}
+
+if [ $# = 1 ]
+then
+	myterm=$1
+elif [ $# = 0 ]
+then
+	myterm=$TERM
+else
+	failed "expected one parameter or none"
+fi
+
+colors=$(tput -T $myterm colors 2>/dev/null)
+if [ ${colors:-0} -le 0 ]
+then
+	myterm=${myterm%%-color}
+	colors=$(tput -T $myterm colors 2>/dev/null)
+fi
+if [ ${colors:-0} -le 0 ]
+then
+	failed "terminal $myterm does not support color"
+fi
+
+printf "System colors:\n"
+
+color=0
+inrow=$colors
+to_do=$colors
+[ $colors -gt 256 ] && colors=256
+[ $inrow  -gt   8 ] && inrow=8
+[ $to_do  -gt  16 ] && to_do=16
+while [ $color -lt $to_do ]
+do
+	[ $color = $inrow ] && newline
+	tput setab $color
+	printf '  '
+	color=$(expr $color + 1)
+done
+newline
+
+[ $colors -le 16 ] && exit
+
+if [ $colors = 256 ]
+then
+	cube=6
+	ramp=232
+elif [ $colors -ge 88 ]
+then
+	cube=4
+	ramp=80
+else
+	exit
+fi
+
+printf "\n"
+printf "Color cube, ${cube}x${cube}x${cube}:\n"
+g=0
+cube2=$(expr $cube \* $cube)
+while [ $g -lt $cube ]
+do
+	r=0
+	while [ $r -lt $cube ]
+	do
+		b=0
+		while [ $b -lt $cube ]
+		do
+			color=$(expr 16 + \( $r \* $cube2 \) + \( $g \* $cube \) + $b)
+			tput setab $color
+			printf '  '
+			b=$(expr $b + 1)
+		done
+		tput op
+		printf ' '
+		r=$(expr $r + 1)
+	done
+	newline
+	g=$(expr $g + 1)
+done
+
+printf "\n"
+printf "Grayscale ramp:\n"
+color=$ramp
+while [ $color -lt $colors ]
+do
+	tput setab $color
+	printf '  '
+	color=$(expr $color + 1)
+done
+newline
+# vi:ts=4 sw=4
diff --git a/test/tput-initc b/test/tput-initc
new file mode 100755
index 0000000..9d71c4f
--- /dev/null
+++ b/test/tput-initc
@@ -0,0 +1,156 @@
+#!/bin/sh
+##############################################################################
+# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 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 "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: tput-initc,v 1.6 2020/02/02 23:34:34 tom Exp $
+# Some of the ".dat" files in ncurses' test-directory give r/g/b numbers for
+# default palettes of xterm and Linux console.  This script reads the numbers
+# and (assuming the same or compatible terminal) uses tput to (re)initialize
+# the palette using those numbers.
+
+failed() {
+	printf "?? $*\n" >&2
+	exit 1
+}
+
+usage() {
+	cat >&2 <<-EOF
+	usage: $0 [-r] [-s] [palette-data]
+
+	Use this script with a palette data-file to (re)initialize colors with
+	tput.  This script assumes arrangements for 16-, 88- and 256-colors
+	like the xterm 88colors2.pl and 256colors2.pl scripts.
+
+	Options:
+	 -r	reverse palette
+	 -s	reverse system colors (first 16 if more than 16 colors)
+EOF
+	exit 1
+}
+
+opt_r=no
+opt_s=no
+
+while getopts "rs" option "$@"
+do
+	case $option in
+	(r)
+		opt_r=yes
+		;;
+	(s)
+		opt_s=yes
+		;;
+	(*)
+		usage
+		;;
+	esac
+done
+shift $(expr $OPTIND - 1)
+
+if [ $# = 1 ]
+then
+	file=$1
+elif [ $# = 0 ]
+then
+	file=$TERM.dat
+else
+	failed "expected one parameter or none"
+fi
+
+if [ ! -f "$file" ]
+then
+	if [ -f "$file.dat" ]
+	then
+		file="$file.dat"
+	else
+		failed "no such file: $file"
+	fi
+fi
+
+myterm=${file%%.dat}
+colors=$(tput -T $myterm colors 2>/dev/null)
+if [ ${colors:-0} -le 0 ]
+then
+	myterm=${myterm%%-color}
+	colors=$(tput -T $myterm colors 2>/dev/null)
+fi
+if [ ${colors:-0} -le 0 ]
+then
+	failed "terminal $myterm does not support color"
+fi
+
+cat $file |\
+awk	-v opt_r=$opt_r \
+	-v opt_s=$opt_s \
+	-v colors=$colors \
+	-v myterm=$myterm '
+BEGIN {
+	limit = 1000;
+	range = -1;
+	cramp = -1;
+	if ( colors == 88 ) {
+		cramp = 80;
+	} else if ( colors = 256 ) {
+		cramp = 232;
+	}
+}
+function scaled(n) {
+	return (n * 1000)/limit;
+}
+
+/^scale:[0-9]+/{
+	sub("^scale:","",$0);
+	limit = $0;
+}
+
+/^[0-9]+:/{
+	sub(":","",$1);
+	item = $1 + 0;
+	if (range < item) {
+		range = item;
+	}
+	params[$1] = sprintf ("%d %d %d", scaled($2),scaled($3),scaled($4));
+}
+END {
+	for (n = 0; n <= range; ++n) {
+		m = n;
+		if ( opt_r == "yes" ) {
+			if ( colors <= 16 ) {
+				m = range - n;
+			} else if ( ( opt_s == "yes" ) && ( n < 16 ) ) {
+				m = 15 - n;
+			} else if ( n >= cramp ) {
+				m = cramp + colors - 1 - n;
+			} else {
+				m = 16 + cramp - 1 - n;
+			}
+		}
+		printf "tput -T%s initc %d %s\n", myterm, m, params[n];
+	}
+}
+' |sh -
diff --git a/test/tracemunch b/test/tracemunch
index 1ea6f4b..b2d3b03 100755
--- a/test/tracemunch
+++ b/test/tracemunch
@@ -1,7 +1,8 @@
-#!/usr/bin/perl -w
-# $Id: tracemunch,v 1.6 2005/03/12 21:48:23 tom Exp $
+#!/usr/bin/env perl
+# $Id: tracemunch,v 1.41 2021/09/04 10:31:03 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2002,2005 Free Software Foundation, Inc.                #
+# Copyright 2018-2020,2021 Thomas E. Dickey                                  #
+# Copyright 1998-2005,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"), #
@@ -32,130 +33,907 @@
 # The error logs produced by ncurses with tracing enabled can be very tedious
 # to wade through.  This script helps by compacting runs of log lines that
 # can be conveniently expressed as higher-level operations.
+
 use strict;
+use warnings;
 
-our $putattr="PutAttrChar\\({{ '(.)' = 0[0-7]+ }}\\) at \\(([0-9]+), ([0-9]+)\\)";
-our $waddnstr="waddnstr\\(0x([0-9a-f]+),\"([^\"]+)\",[0-9]+\\) called {A_NORMAL}";
+$| = 1;
 
-our $win_nums=0;
-our $curscr="";
-our $newscr="";
-our $stdscr="";
-our @win_addr;
+our $putattr =
+    'PutAttrChar\(\{\{ ' . "'(.)'"
+  . ' = 0[0-7]+ \}\}\) at \(([0-9]+), ([0-9]+)\)';
+our $waddnstr =
+'^called \{waddnstr\((0x[[:xdigit:]]+|window\d+),"((\\.|[^\"]*))",[-]?[0-9]+\)';
 
-sub transaddr
-{
+our %TR = qw(
+  DISABLE       0x0000
+  TIMES         0x0001
+  TPUTS         0x0002
+  UPDATE        0x0004
+  MOVE          0x0008
+  CHARPUT       0x0010
+  ORDINARY      0x001F
+  CALLS         0x0020
+  VIRTPUT       0x0040
+  IEVENT        0x0080
+  BITS          0x0100
+  ICALLS        0x0200
+  CCALLS        0x0400
+  DATABASE      0x0800
+  ATTRS         0x1000
+);
+
+our $tracelevel = 0;
+
+our $tSCREEN   = 1;    # SCREEN*
+our $tWINDOW   = 2;    # WINDOW*
+our $tTERMINAL = 3;    # TERMINAL*
+our $tPANEL    = 4;    # PANEL*
+our $tFIELD    = 5;    # FIELD*
+our $tFORM     = 5;    # FORM*
+our $tMENU     = 6;    # MENU*
+our $tITEM     = 7;    # ITEM*
+
+our %known_p1_types = (
+    $tSCREEN   => "SCREEN*",
+    $tWINDOW   => "WINDOW*",
+    $tTERMINAL => "TERMINAL*",
+    $tPANEL    => "PANEL*",
+    $tFORM     => "FORM*",
+    $tFIELD    => "FIELD*",
+    $tMENU     => "MENU*",
+    $tITEM     => "ITEM*",
+);
+
+# If the trace is complete, we can infer addresses using the return value from
+# newwin, etc.  But if it is incomplete, we can still check for special cases
+# such as SCREEN* and WINDOW* parameters.  In this table, the type for the
+# first parameter is encoded, relying upon an ncurses programming convention:
+our %known_p1 = (
+    TransformLine          => $tSCREEN,
+    _nc_console_read       => $tSCREEN,
+    _nc_freewin            => $tWINDOW,
+    _nc_initscr            => $tSCREEN,
+    _nc_makenew            => $tSCREEN,
+    _nc_mingw_console_read => $tSCREEN,
+    _nc_reset_colors       => $tSCREEN,
+    _nc_scroll_optimize    => $tSCREEN,
+    _nc_tinfo              => $tSCREEN,
+    _nc_tinfo_mvcur        => $tSCREEN,
+    _nc_wgetch             => $tWINDOW,
+    adjust_window          => $tWINDOW,
+    assume_default_colors  => $tSCREEN,
+    attr_get               => $tWINDOW,
+    baudrate               => $tSCREEN,
+    beep                   => $tSCREEN,
+    border_set             => $tWINDOW,
+    bottom_panel           => $tPANEL,
+    bottom_panel           => $tPANEL,
+    box                    => $tWINDOW,
+    box_set                => $tWINDOW,
+    can_change_color       => $tSCREEN,
+    cbreak                 => $tSCREEN,
+    ceiling_panel          => $tSCREEN,
+    clearok                => $tWINDOW,
+    color_content          => $tSCREEN,
+    copywin                => $tWINDOW,
+    current_item           => $tMENU,
+    curs_set               => $tSCREEN,
+    decrease_size          => $tSCREEN,
+    def_prog_mode          => $tSCREEN,
+    def_shell_mode         => $tSCREEN,
+    define_key             => $tSCREEN,
+    del_curterm            => $tSCREEN,
+    del_panel              => $tPANEL,
+    del_panel              => $tPANEL,
+    delay_output           => $tSCREEN,
+    delscreen              => $tSCREEN,
+    delwin                 => $tWINDOW,
+    derwin                 => $tWINDOW,
+    doupdate               => $tSCREEN,
+    dup_field              => $tFIELD,
+    dupwin                 => $tWINDOW,
+    echo                   => $tSCREEN,
+    endwin                 => $tSCREEN,
+    erasechar              => $tSCREEN,
+    field_opts_off         => $tFIELD,
+    field_opts_on          => $tFIELD,
+    filter                 => $tSCREEN,
+    flash                  => $tSCREEN,
+    flushinp               => $tSCREEN,
+    form_driver            => $tFORM,
+    form_driver_w          => $tFORM,
+    form_opts_off          => $tFORM,
+    form_opts_on           => $tFORM,
+    free_field             => $tFIELD,
+    free_form              => $tFORM,
+    free_item              => $tITEM,
+    free_menu              => $tMENU,
+    getattrs               => $tWINDOW,
+    getbegx                => $tWINDOW,
+    getbegy                => $tWINDOW,
+    getbkgd                => $tWINDOW,
+    getcurx                => $tWINDOW,
+    getcury                => $tWINDOW,
+    getmaxx                => $tWINDOW,
+    getmaxy                => $tWINDOW,
+    getmouse               => $tSCREEN,
+    getparx                => $tWINDOW,
+    getpary                => $tWINDOW,
+    ground_panel           => $tSCREEN,
+    halfdelay              => $tSCREEN,
+    has_ic                 => $tSCREEN,
+    has_il                 => $tSCREEN,
+    has_key                => $tSCREEN,
+    hide_panel             => $tPANEL,
+    hide_panel             => $tPANEL,
+    idcok                  => $tWINDOW,
+    idlok                  => $tWINDOW,
+    immedok                => $tWINDOW,
+    increase_size          => $tSCREEN,
+    init_color             => $tSCREEN,
+    init_pair              => $tSCREEN,
+    intrflush              => $tSCREEN,
+    is_cleared             => $tWINDOW,
+    is_idcok               => $tWINDOW,
+    is_idlok               => $tWINDOW,
+    is_immedok             => $tWINDOW,
+    is_keypad              => $tWINDOW,
+    is_leaveok             => $tWINDOW,
+    is_linetouched         => $tWINDOW,
+    is_nodelay             => $tWINDOW,
+    is_notimeout           => $tWINDOW,
+    is_pad                 => $tWINDOW,
+    is_scrollok            => $tWINDOW,
+    is_subwin              => $tWINDOW,
+    is_syncok              => $tWINDOW,
+    is_term_resized        => $tSCREEN,
+    is_wintouched          => $tWINDOW,
+    item_count             => $tMENU,
+    item_description       => $tITEM,
+    item_index             => $tITEM,
+    item_init              => $tMENU,
+    item_name              => $tITEM,
+    item_opts              => $tITEM,
+    item_opts_off          => $tITEM,
+    item_opts_on           => $tITEM,
+    item_term              => $tMENU,
+    item_userptr           => $tITEM,
+    item_value             => $tITEM,
+    item_visible           => $tITEM,
+    key_defined            => $tSCREEN,
+    keybound               => $tSCREEN,
+    keyok                  => $tSCREEN,
+    keypad                 => $tWINDOW,
+    killchar               => $tSCREEN,
+    leaveok                => $tWINDOW,
+    link_field             => $tFIELD,
+    longname               => $tSCREEN,
+    menu_back              => $tMENU,
+    menu_driver            => $tMENU,
+    menu_fore              => $tMENU,
+    menu_format            => $tMENU,
+    menu_grey              => $tMENU,
+    menu_init              => $tMENU,
+    menu_items             => $tMENU,
+    menu_mark              => $tMENU,
+    menu_opts              => $tMENU,
+    menu_opts_off          => $tMENU,
+    menu_opts_on           => $tMENU,
+    menu_pad               => $tMENU,
+    menu_pattern           => $tMENU,
+    menu_spacing           => $tMENU,
+    menu_sub               => $tMENU,
+    menu_term              => $tMENU,
+    menu_userptr           => $tMENU,
+    menu_win               => $tMENU,
+    meta                   => $tWINDOW,
+    mouseinterval          => $tSCREEN,
+    mousemask              => $tSCREEN,
+    move_field             => $tFIELD,
+    move_panel             => $tPANEL,
+    move_panel             => $tPANEL,
+    mvcur                  => $tSCREEN,
+    mvderwin               => $tWINDOW,
+    mvwadd_wch             => $tWINDOW,
+    mvwadd_wchnstr         => $tWINDOW,
+    mvwadd_wchstr          => $tWINDOW,
+    mvwaddch               => $tWINDOW,
+    mvwaddchnstr           => $tWINDOW,
+    mvwaddchstr            => $tWINDOW,
+    mvwaddnstr             => $tWINDOW,
+    mvwaddnwstr            => $tWINDOW,
+    mvwaddstr              => $tWINDOW,
+    mvwaddwstr             => $tWINDOW,
+    mvwchgat               => $tWINDOW,
+    mvwdelch               => $tWINDOW,
+    mvwget_wch             => $tWINDOW,
+    mvwget_wstr            => $tWINDOW,
+    mvwgetch               => $tWINDOW,
+    mvwgetn_wstr           => $tWINDOW,
+    mvwgetnstr             => $tWINDOW,
+    mvwgetstr              => $tWINDOW,
+    mvwhline               => $tWINDOW,
+    mvwhline_set           => $tWINDOW,
+    mvwin                  => $tWINDOW,
+    mvwin_wch              => $tWINDOW,
+    mvwin_wchnstr          => $tWINDOW,
+    mvwin_wchstr           => $tWINDOW,
+    mvwinch                => $tWINDOW,
+    mvwinchnstr            => $tWINDOW,
+    mvwinchstr             => $tWINDOW,
+    mvwins_nwstr           => $tWINDOW,
+    mvwins_wch             => $tWINDOW,
+    mvwins_wstr            => $tWINDOW,
+    mvwinsch               => $tWINDOW,
+    mvwinsnstr             => $tWINDOW,
+    mvwinsstr              => $tWINDOW,
+    mvwinstr               => $tWINDOW,
+    mvwinwstr              => $tWINDOW,
+    mvwvline               => $tWINDOW,
+    mvwvline_set           => $tWINDOW,
+    new_panel              => $tWINDOW,
+    new_panel              => $tWINDOW,
+    newpad                 => $tSCREEN,
+    newterm                => $tSCREEN,
+    newwin                 => $tSCREEN,
+    nl                     => $tSCREEN,
+    nocbreak               => $tSCREEN,
+    nodelay                => $tWINDOW,
+    noecho                 => $tSCREEN,
+    nofilter               => $tSCREEN,
+    nonl                   => $tSCREEN,
+    noqiflush              => $tSCREEN,
+    noraw                  => $tSCREEN,
+    notimeout              => $tWINDOW,
+    overlap                => $tWINDOW,
+    overlay                => $tWINDOW,
+    overwrite              => $tWINDOW,
+    pair_content           => $tSCREEN,
+    panel_above            => $tPANEL,
+    panel_above            => $tPANEL,
+    panel_below            => $tPANEL,
+    panel_below            => $tPANEL,
+    panel_hidden           => $tPANEL,
+    panel_hidden           => $tPANEL,
+    panel_userptr          => $tPANEL,
+    panel_userptr          => $tPANEL,
+    panel_window           => $tPANEL,
+    panel_window           => $tPANEL,
+    pecho_wchar            => $tWINDOW,
+    pechochar              => $tWINDOW,
+    pnoutrefresh           => $tWINDOW,
+    pos_form_cursor        => $tFORM,
+    pos_menu_cursor        => $tMENU,
+    post_form              => $tFORM,
+    post_menu              => $tMENU,
+    putwin                 => $tWINDOW,
+    qiflush                => $tSCREEN,
+    raw                    => $tSCREEN,
+    redrawwin              => $tWINDOW,
+    replace_panel          => $tPANEL,
+    replace_panel          => $tPANEL,
+    reset_prog_mode        => $tSCREEN,
+    reset_shell_mode       => $tSCREEN,
+    resetty                => $tSCREEN,
+    resize_term            => $tSCREEN,
+    resizeterm             => $tSCREEN,
+    restartterm            => $tSCREEN,
+    ripoffline             => $tSCREEN,
+    savetty                => $tSCREEN,
+    scale_menu             => $tMENU,
+    scr_init               => $tSCREEN,
+    scr_restore            => $tSCREEN,
+    scr_set                => $tSCREEN,
+    scroll                 => $tWINDOW,
+    scrollok               => $tWINDOW,
+    set_current_field      => $tFORM,
+    set_current_item       => $tMENU,
+    set_curterm            => $tTERMINAL,
+    set_field_back         => $tFIELD,
+    set_field_buffer       => $tFIELD,
+    set_field_fore         => $tFIELD,
+    set_field_init         => $tFORM,
+    set_field_just         => $tFIELD,
+    set_field_opts         => $tFIELD,
+    set_field_pad          => $tFIELD,
+    set_field_status       => $tFIELD,
+    set_field_term         => $tFORM,
+    set_field_type         => $tFIELD,
+    set_field_userptr      => $tFIELD,
+    set_form_fields        => $tFORM,
+    set_form_init          => $tFORM,
+    set_form_opts          => $tFORM,
+    set_form_page          => $tFORM,
+    set_form_sub           => $tFORM,
+    set_form_term          => $tFORM,
+    set_form_userptr       => $tFORM,
+    set_form_win           => $tFORM,
+    set_item_init          => $tMENU,
+    set_item_opts          => $tITEM,
+    set_item_term          => $tMENU,
+    set_item_userptr       => $tITEM,
+    set_item_value         => $tITEM,
+    set_menu_back          => $tMENU,
+    set_menu_fore          => $tMENU,
+    set_menu_format        => $tMENU,
+    set_menu_grey          => $tMENU,
+    set_menu_init          => $tMENU,
+    set_menu_items         => $tMENU,
+    set_menu_mark          => $tMENU,
+    set_menu_opts          => $tMENU,
+    set_menu_pad           => $tMENU,
+    set_menu_pattern       => $tMENU,
+    set_menu_spacing       => $tMENU,
+    set_menu_sub           => $tMENU,
+    set_menu_term          => $tMENU,
+    set_menu_userptr       => $tMENU,
+    set_menu_win           => $tMENU,
+    set_new_page           => $tFIELD,
+    set_panel_userptr      => $tPANEL,
+    set_panel_userptr      => $tPANEL,
+    set_term               => $tSCREEN,
+    set_top_row            => $tMENU,
+    show_panel             => $tPANEL,
+    show_panel             => $tPANEL,
+    slk_attr               => $tSCREEN,
+    slk_attr_set           => $tSCREEN,
+    slk_attroff            => $tSCREEN,
+    slk_attron             => $tSCREEN,
+    slk_attrset            => $tSCREEN,
+    slk_clear              => $tSCREEN,
+    slk_color              => $tSCREEN,
+    slk_init               => $tSCREEN,
+    slk_label              => $tSCREEN,
+    slk_noutrefresh        => $tSCREEN,
+    slk_refresh            => $tSCREEN,
+    slk_restore            => $tSCREEN,
+    slk_set                => $tSCREEN,
+    slk_touch              => $tSCREEN,
+    start_color            => $tSCREEN,
+    subwin                 => $tWINDOW,
+    syncok                 => $tWINDOW,
+    termattrs              => $tSCREEN,
+    termname               => $tSCREEN,
+    tgetflag               => $tSCREEN,
+    tgetnum                => $tSCREEN,
+    tigetflag              => $tSCREEN,
+    tigetnum               => $tSCREEN,
+    tigetstr               => $tSCREEN,
+    tinfo                  => $tSCREEN,
+    top_panel              => $tPANEL,
+    top_panel              => $tPANEL,
+    top_row                => $tMENU,
+    touchline              => $tWINDOW,
+    touchwin               => $tWINDOW,
+    typeahead              => $tSCREEN,
+    unfocus_current_field  => $tFORM,
+    unget_wch              => $tSCREEN,
+    ungetch                => $tSCREEN,
+    ungetmouse             => $tSCREEN,
+    unpost_form            => $tFORM,
+    unpost_menu            => $tMENU,
+    untouchwin             => $tWINDOW,
+    update_panels_sp       => $tSCREEN,
+    use_default_colors     => $tSCREEN,
+    use_env                => $tSCREEN,
+    use_legacy_coding      => $tSCREEN,
+    use_screen             => $tSCREEN,
+    use_tioctl             => $tSCREEN,
+    use_window             => $tWINDOW,
+    vidattr                => $tSCREEN,
+    vidputs                => $tSCREEN,
+    vw_printw              => $tWINDOW,
+    vwprintw               => $tWINDOW,
+    wadd_wch               => $tWINDOW,
+    wadd_wchnstr           => $tWINDOW,
+    wadd_wchstr            => $tWINDOW,
+    waddch                 => $tWINDOW,
+    waddchnstr             => $tWINDOW,
+    waddchstr              => $tWINDOW,
+    waddnstr               => $tWINDOW,
+    waddnwstr              => $tWINDOW,
+    waddstr                => $tWINDOW,
+    waddwstr               => $tWINDOW,
+    wattr_get              => $tWINDOW,
+    wattr_off              => $tWINDOW,
+    wattr_on               => $tWINDOW,
+    wattr_set              => $tWINDOW,
+    wattroff               => $tWINDOW,
+    wattron                => $tWINDOW,
+    wattrset               => $tWINDOW,
+    wbkgd                  => $tWINDOW,
+    wbkgdset               => $tWINDOW,
+    wborder                => $tWINDOW,
+    wborder_set            => $tWINDOW,
+    wchgat                 => $tWINDOW,
+    wclear                 => $tWINDOW,
+    wclrtobot              => $tWINDOW,
+    wclrtoeol              => $tWINDOW,
+    wcolor_set             => $tWINDOW,
+    wcursyncup             => $tWINDOW,
+    wdelch                 => $tWINDOW,
+    wdeleteln              => $tWINDOW,
+    wechochar              => $tWINDOW,
+    wenclose               => $tWINDOW,
+    werase                 => $tWINDOW,
+    wget_wch               => $tWINDOW,
+    wget_wstr              => $tWINDOW,
+    wgetbkgrnd             => $tWINDOW,
+    wgetch                 => $tWINDOW,
+    wgetch_events          => $tWINDOW,
+    wgetdelay              => $tWINDOW,
+    wgetn_wstr             => $tWINDOW,
+    wgetnstr               => $tWINDOW,
+    wgetparent             => $tWINDOW,
+    wgetscrreg             => $tWINDOW,
+    wgetstr                => $tWINDOW,
+    whline                 => $tWINDOW,
+    whline_set             => $tWINDOW,
+    win_wch                => $tWINDOW,
+    win_wchnstr            => $tWINDOW,
+    win_wchstr             => $tWINDOW,
+    winch                  => $tWINDOW,
+    winchnstr              => $tWINDOW,
+    winchstr               => $tWINDOW,
+    winnstr                => $tWINDOW,
+    winnwstr               => $tWINDOW,
+    wins_nwstr             => $tWINDOW,
+    wins_wch               => $tWINDOW,
+    wins_wstr              => $tWINDOW,
+    winsch                 => $tWINDOW,
+    winsdelln              => $tWINDOW,
+    winsertln              => $tWINDOW,
+    winsnstr               => $tWINDOW,
+    winsstr                => $tWINDOW,
+    winstr                 => $tWINDOW,
+    winwstr                => $tWINDOW,
+    wmouse_trafo           => $tWINDOW,
+    wmove                  => $tWINDOW,
+    wnoutrefresh           => $tWINDOW,
+    wprintw                => $tWINDOW,
+    wredrawln              => $tWINDOW,
+    wrefresh               => $tWINDOW,
+    wresize                => $tWINDOW,
+    wscrl                  => $tWINDOW,
+    wsetscrreg             => $tWINDOW,
+    wstandend              => $tWINDOW,
+    wstandout              => $tWINDOW,
+    wsyncdown              => $tWINDOW,
+    wsyncup                => $tWINDOW,
+    wtimeout               => $tWINDOW,
+    wtouchln               => $tWINDOW,
+    wvline                 => $tWINDOW,
+);
+
+our $fld_nums = 0;
+our $frm_nums = 0;
+our $itm_nums = 0;
+our $mnu_nums = 0;
+our $pan_nums = 0;
+our $scr_nums = 0;
+our $thr_nums = 0;
+our $trm_nums = 0;
+our $try_nums = 0;
+our $usr_nums = 0;
+our $win_nums = 0;
+
+our $curscr = "";
+our $newscr = "";
+our $stdscr = "";
+
+our %fld_addr;    # FIELD*
+our %frm_addr;    # FORM*
+our %itm_addr;    # ITEM*
+our %mnu_addr;    # MENU*
+our %pan_addr;    # PANEL*
+our %scr_addr;    # SCREEN*
+our %thr_addr;    # thread-id
+our %trm_addr;    # TERMINAL*
+our %try_addr;    # tries-number
+our %usr_addr;    # user-pointer
+our %win_addr;    # WINDOW*
+
+sub has_addr($) {
+    my $value  = shift;
+    my $result = 0;
+    $result = 1 if ( $value =~ /\b0x[[:xdigit:]]+\b/i );
+    return $result;
+}
+
+sub transaddr($) {
+    my $arg = shift;
     my $n;
-    my $arg = $_[0];
 
-    $arg =~ s/$curscr/curscr/g if ($curscr);
-    $arg =~ s/$newscr/newscr/g if ($newscr);
-    $arg =~ s/$stdscr/stdscr/g if ($stdscr);
-    for $n (0..$#win_addr) {
-	$arg =~ s/$win_addr[$n]/window$n/g if $win_addr[$n];
+    $arg =~ s/\b$curscr\b/curscr/g if ($curscr);
+    $arg =~ s/\b$newscr\b/newscr/g if ($newscr);
+    $arg =~ s/\b$stdscr\b/stdscr/g if ($stdscr);
+    if ( &has_addr($arg) ) {
+        foreach my $addr ( keys %fld_addr ) {
+            $n = $fld_addr{$addr};
+            $arg =~ s/\b$addr\b/field$n/g if ( defined $n );
+        }
+    }
+    if ( &has_addr($arg) ) {
+        foreach my $addr ( keys %frm_addr ) {
+            $n = $frm_addr{$addr};
+            $arg =~ s/\b$addr\b/form$n/g if ( defined $n );
+        }
+    }
+    if ( &has_addr($arg) ) {
+        foreach my $addr ( keys %itm_addr ) {
+            $n = $itm_addr{$addr};
+            $arg =~ s/\b$addr\b/item$n/g if ( defined $n );
+        }
+    }
+    if ( &has_addr($arg) ) {
+        foreach my $addr ( keys %mnu_addr ) {
+            $n = $mnu_addr{$addr};
+            $arg =~ s/\b$addr\b/menu$n/g if ( defined $n );
+        }
+    }
+    if ( &has_addr($arg) ) {
+        foreach my $addr ( keys %pan_addr ) {
+            $n = $pan_addr{$addr};
+            $arg =~ s/\b$addr\b/panel$n/g if ( defined $n );
+        }
+    }
+    if ( &has_addr($arg) ) {
+        foreach my $addr ( keys %scr_addr ) {
+            $n = $scr_addr{$addr};
+            $arg =~ s/\b$addr\b/screen$n/g if ( defined $n );
+        }
+    }
+    if ( &has_addr($arg) ) {
+        foreach my $addr ( keys %thr_addr ) {
+            $n = $thr_addr{$addr};
+            $arg =~ s/\b$addr\b/thread$n/g if ( defined $n );
+        }
+    }
+    if ( &has_addr($arg) ) {
+        foreach my $addr ( keys %trm_addr ) {
+            $n = $trm_addr{$addr};
+            $arg =~ s/\b$addr\b/terminal$n/g if ( defined $n );
+        }
+    }
+    if ( &has_addr($arg) ) {
+        foreach my $addr ( keys %try_addr ) {
+            $n = $try_addr{$addr};
+            $arg =~ s/\b$addr\b/tries_$n/g if ( defined $n );
+        }
+    }
+    if ( &has_addr($arg) ) {
+        foreach my $addr ( keys %usr_addr ) {
+            $n = $usr_addr{$addr};
+            $arg =~ s/\b$addr\b/user_ptr$n/g if ( defined $n );
+        }
+    }
+    if ( &has_addr($arg) ) {
+        foreach my $addr ( keys %win_addr ) {
+            $n = $win_addr{$addr};
+            $arg =~ s/\b$addr\b/window$n/g if ( defined $n );
+        }
+    }
+    if ( &has_addr($arg) ) {
+        if ( $arg =~ /add_wch\((window\d+,)?0x[[:xdigit:]]+\)/i ) {
+            $arg =~ s/(0x[[:xdigit:]]+)[)]/\&wch)/i;
+        }
+        elsif (
+            $arg =~ /color_content\((screen\d+,)?\d+(,0x[[:xdigit:]]+){3}/i )
+        {
+            $arg =~ s/(,0x[[:xdigit:]]+){3}[)]/,\&r,\&g,\&b)/i;
+        }
+        elsif ( $arg =~ /pair_content\((screen\d+,)?\d+(,0x[[:xdigit:]]+){2}/i )
+        {
+            $arg =~ s/(,0x[[:xdigit:]]+){2}[)]/,\&fg,\&bg)/i;
+        }
+    }
+    if ( &has_addr($arg) and $arg =~ /called\s+\{/ ) {
+        my $func = $arg;
+        chomp $func;
+        $func =~ s/^.*called\s+\{([[:alnum:]_]+)\(.*$/$1/;
+        if ( defined $known_p1{$func} ) {
+            my $addr = $arg;
+            my $type = $known_p1{$func};
+            chomp $addr;
+            $addr =~ s/^[^(]+\((0x[[:xdigit:]]+).*$/$1/i;
+            if ( $addr !~ /^0x[[:xdigit:]]+$/i ) {
+                if ( $type == $tSCREEN and $addr =~ /^[^(]+\(screen\d+[,)]/ ) {
+
+                    # ignore
+                }
+                elsif ( $type == $tWINDOW
+                    and $addr =~
+                    /^[^(]+\((stdscr|newscr|curscr|window\d+)[,)]/ )
+                {
+
+                    # ignore
+                }
+                elsif ( $type == $tTERMINAL
+                    and $addr =~ /^[^(]+\(terminal\d+[,)]/ )
+                {
+                    # ignore
+                }
+                elsif ( $type == $tPANEL and $addr =~ /^[^(]+\(panel\d+[,)]/ ) {
+
+                    # ignore
+                }
+                elsif ( $type == $tFIELD and $addr =~ /^[^(]+\(field\d+[,)]/ ) {
+
+                    # ignore
+                }
+                elsif ( $type == $tMENU and $addr =~ /^[^(]+\(menu\d+[,)]/ ) {
+
+                    # ignore
+                }
+                elsif ( $type == $tITEM and $addr =~ /^[^(]+\(item\d+[,)]/ ) {
+
+                    # ignore
+                }
+                else {
+                    printf "OOPS - expected type \"%s\", skipping\n>>$addr\n",
+                      $known_p1_types{$type};
+                }
+            }
+            elsif ( $type == $tSCREEN ) {
+                $scr_addr{$addr} = ++$scr_nums;
+                $arg = &transaddr($arg);
+            }
+            elsif ( $type == $tWINDOW ) {
+                $win_addr{$addr} = ++$win_nums;
+                $arg = &transaddr($arg);
+            }
+            elsif ( $type == $tTERMINAL ) {
+                $trm_addr{$addr} = ++$trm_nums;
+                $arg = &transaddr($arg);
+            }
+            elsif ( $type == $tPANEL ) {
+                $pan_addr{$addr} = ++$pan_nums;
+                $arg = &transaddr($arg);
+            }
+            elsif ( $type == $tFIELD ) {
+                $fld_addr{$addr} = ++$fld_nums;
+                $arg = &transaddr($arg);
+            }
+            elsif ( $type == $tFORM ) {
+                $frm_addr{$addr} = ++$frm_nums;
+                $arg = &transaddr($arg);
+            }
+            elsif ( $type == $tMENU ) {
+                $mnu_addr{$addr} = ++$mnu_nums;
+                $arg = &transaddr($arg);
+            }
+            elsif ( $type == $tITEM ) {
+                $itm_addr{$addr} = ++$itm_nums;
+                $arg = &transaddr($arg);
+            }
+        }
     }
 
     return $arg;
 }
 
-while (<STDIN>)
-{
-	my $addr;
-	my $n;
-	my $awaiting;
+sub muncher($) {
+    my $STDIN = shift;
 
-CLASSIFY: {
-	# Transform window pointer addresses so it's easier to compare logs
-	$awaiting = "curscr" if ($_ =~ /creating curscr/);
-	$awaiting = "newscr" if ($_ =~ /creating newscr/);
-	$awaiting = "stdscr" if ($_ =~ /creating stdscr/);
-	if ($_ =~ /^create :window 0x([0-9a-f]+)/) {
-	    $addr = "0x$1";
-	    if ($awaiting eq "curscr") {
-		$curscr = $addr;
-	    } elsif ($awaiting eq "newscr") {
-		$newscr = $addr;
-	    } elsif ($awaiting eq "stdscr") {
-		$stdscr = $addr;
-	    } else {
-		$win_addr[$win_nums] = $addr;
-		$win_nums = $win_nums + 1;
-	    }
-	    $awaiting = "";
-	} elsif ($_ =~ /^\.\.\.deleted win=0x([0-9a-f]+)/) {
-	    $addr = "0x$1";
-	    $_ = &transaddr($_);
-	    if ($addr eq $curscr) {
-		$curscr = "";
-	    } elsif ($addr eq $newscr) {
-		$newscr = "";
-	    } elsif ($addr eq $stdscr) {
-		$stdscr = "";
-	    } else {
-		for $n (0..$#win_addr) {
-		    if ($win_addr[$n] eq $addr) {
-			$win_addr[$n] = "";
-		    }
-		}
-	    }
-	}
+    while (<$STDIN>) {
+        my $addr;
+        my $n;
+        my $awaiting = "";
 
-	# Compactify runs of PutAttrChar calls (TR_CHARPUT)
-	if ($_ =~ /$putattr/)
-	{
-		my $putattr_chars = $1;
-		my $starty = $2;
-		my $startx = $3;
-		while (<STDIN>)
-		{
-			if ($_ =~ /$putattr/) {
-				$putattr_chars .= $1;
-			} else {
-				last;
-			}
-		}
-		print "RUN of PutAttrChar()s: \"$putattr_chars\" from ${starty}, ${startx}\n";
-		redo CLASSIFY;
-	}
+      CLASSIFY: {
 
-	# Compactify runs of waddnstr calls (TR_CALLS)
-	if ($_ =~ /$waddnstr/)
-	{
-		my $waddnstr_chars = $2;
-		my $winaddr = $1;
-		while (<STDIN>)
-		{
-			if ($_ =~ /$waddnstr/ && $1 eq $winaddr) {
-				$waddnstr_chars .= $2;
-			} else {
-				last;
-			}
-		}
-		my $winaddstr = &transaddr($winaddr);
-		print "RUN of waddnstr()s: $winaddr, \"$waddnstr_chars\"\n";
-		redo CLASSIFY;
-	}
+            next unless $_;
 
-	# More transformations can go here
+            # just in case someone tries a file with cr/lf line-endings:
+            $_ =~ s/\r\n/\n/g;
+            $_ =~ s/\r/\n/g;
 
-	# Repeated runs of anything
-	my $anyline = &transaddr($_);
-	my $repeatcount = 1;
-	while (<STDIN>) {
-	    if (&transaddr($_) eq $anyline) {
-		$repeatcount++;
-	    } else {
-		last;
-	    }
-	}
-	if ($repeatcount > 1) {
-		print "${repeatcount} REPEATS OF $anyline";
-	} else {
-		print $anyline
-	}
-	redo CLASSIFY if $_;
+            if ( $_ =~
+                /^TRACING NCURSES version.*\(tracelevel=(0x[[:xdigit:]]+)\)/ )
+            {
+                $tracelevel = hex $1;
+                print;
+                next;
+            }
 
-	} # :CLASSIFY
+            my $thread = "";
+            if ( $_ =~ /^(0x[[:xdigit:]]+):/ ) {
+                $thr_addr{$1} = ++$thr_nums unless defined $thr_addr{$1};
+                $thread = "thread" . $thr_addr{$1} . ":";
+                $_ =~ s/^[^:]*://;
+            }
+
+            # Transform window pointer addresses to make it easier to compare logs
+            $awaiting = "curscr" if ( $_ =~ /creating curscr/ );
+            $awaiting = "newscr" if ( $_ =~ /creating newscr/ );
+            $awaiting = "stdscr" if ( $_ =~ /creating stdscr/ );
+            $awaiting = "screen" if ( $_ =~ /^(\+ )*called \{new_prescr\(\)/ );
+            if ( $_ =~ /^create :window 0x([[:xdigit:]]+)/ ) {
+                $addr = "0x$1";
+                if ( $awaiting eq "curscr" ) {
+                    $curscr = $addr;
+                }
+                elsif ( $awaiting eq "newscr" ) {
+                    $newscr = $addr;
+                }
+                elsif ( $awaiting eq "stdscr" ) {
+                    $stdscr = $addr;
+                }
+                else {
+                    $win_addr{$addr} = $win_nums++;
+                }
+                $awaiting = "";
+            }
+            elsif ( $_ =~ /^create :(root|new)_panel 0x([[:xdigit:]]+)/ ) {
+                $addr            = "0x$2";
+                $pan_addr{$addr} = $pan_nums++;
+                $_               = &transaddr($_);
+            }
+            elsif ( $_ =~ /^create :user_ptr 0x([[:xdigit:]]+)/ ) {
+                $addr            = "0x$1";
+                $usr_addr{$addr} = $usr_nums++;
+                $_               = &transaddr($_);
+            }
+            elsif ( $_ =~ /^create :field 0x([[:xdigit:]]+)/ ) {
+                $addr            = "0x$1";
+                $fld_addr{$addr} = $fld_nums++;
+                $_               = &transaddr($_);
+            }
+            elsif ( $_ =~ /^create :form 0x([[:xdigit:]]+)/ ) {
+                $addr            = "0x$1";
+                $frm_addr{$addr} = $frm_nums++;
+                $_               = &transaddr($_);
+            }
+            elsif ( $_ =~ /^create :menu 0x([[:xdigit:]]+)/ ) {
+                $addr            = "0x$1";
+                $mnu_addr{$addr} = $mnu_nums++;
+                $_               = &transaddr($_);
+            }
+            elsif ( $_ =~ /^create :item 0x([[:xdigit:]]+)/ ) {
+                $addr            = "0x$1";
+                $itm_addr{$addr} = $itm_nums++;
+                $_               = &transaddr($_);
+            }
+            elsif ( $_ =~ /^(\+ )*called \{set_curterm\((0x[[:xdigit:]]+)\)/ ) {
+                $trm_addr{$2} = ++$trm_nums unless defined $trm_addr{$2};
+            }
+            elsif ( $_ =~ /^(\+ )*called \{_nc_add_to_try\((0x[[:xdigit:]]+),/ )
+            {
+                $try_addr{$2} = ++$try_nums unless defined $try_addr{$2};
+            }
+            elsif ( $_ =~ /^(\+ )*_nc_alloc_screen_sp 0x([[:xdigit:]]+)/ ) {
+                $addr = "0x$2";
+                $scr_addr{$addr} = ++$scr_nums unless ( $scr_addr{$addr} );
+                $awaiting = "";
+            }
+            elsif ( $_ =~ /^(\+ )*return }0x([[:xdigit:]]+)/ ) {
+                $addr = "0x$2";
+                if ( $awaiting eq "screen" ) {
+                    $scr_addr{$addr} = ++$scr_nums unless ( $scr_addr{$addr} );
+                }
+            }
+            elsif ( $_ =~ /^\.\.\.deleted win=0x([[:xdigit:]]+)/ ) {
+                $addr = "0x$1";
+                $_    = &transaddr($_);
+                if ( $addr eq $curscr ) {
+                    $curscr = "";
+                }
+                elsif ( $addr eq $newscr ) {
+                    $newscr = "";
+                }
+                elsif ( $addr eq $stdscr ) {
+                    $stdscr = "";
+                }
+                else {
+                    undef $win_addr{$addr};
+                }
+            }
+            elsif ( $_ =~ /^\.\.\.deleted pan=\"0x([[:xdigit:]]+)\"/ ) {
+                $addr = "0x$1";
+                $_    = &transaddr($_);
+                undef $pan_addr{$addr};
+            }
+            elsif ( $_ =~ /^([+ ])*called \{free_field\(0x([[:xdigit:]]+)\)/ ) {
+                $addr = "0x$2";
+                $_    = &transaddr($_);
+                undef $fld_addr{$addr};
+            }
+            elsif ( $_ =~ /^([+ ])*called \{free_form\(0x([[:xdigit:]]+)\)/ ) {
+                $addr = "0x$2";
+                $_    = &transaddr($_);
+                undef $frm_addr{$addr};
+            }
+            elsif ( $_ =~ /^([+ ])*called \{free_menu\(0x([[:xdigit:]]+)\)/ ) {
+                $addr = "0x$2";
+                $_    = &transaddr($_);
+                undef $mnu_addr{$addr};
+            }
+            elsif ( $_ =~ /^([+ ])*called \{free_item\(0x([[:xdigit:]]+)\)/ ) {
+                $addr = "0x$2";
+                $_    = &transaddr($_);
+                undef $itm_addr{$addr};
+            }
+
+            # Compactify runs of PutAttrChar
+            if ( ( ( $tracelevel & $TR{CHARPUT} ) != 0 ) and $_ =~ /$putattr/ )
+            {
+                my $putattr_chars = $1;
+                my $starty        = $2;
+                my $startx        = $3;
+                while (<$STDIN>) {
+                    if ( $_ =~ /$putattr/ ) {
+                        $putattr_chars .= $1;
+                    }
+                    else {
+                        next if ( $_ =~ /^PUTC 0x[[:xdigit:]]+.*/ );
+                        next if ( $_ =~ /^\.\.\.skip.*/ );
+                        next if ( $_ =~ /^forced to blank.*/ );
+                        last;
+                    }
+                }
+                print "RUN of PutAttrChar()s:"
+                  . " \"$putattr_chars\" from ${starty}, ${startx}\n";
+                redo CLASSIFY;
+            }
+
+            # Compactify runs of waddnstr calls
+            if ( ( ( $tracelevel & $TR{CALLS} ) != 0 ) and $_ =~ /$waddnstr/ ) {
+                my $waddnstr_chars = $2;
+                my $winaddr        = $1;
+                while (<$STDIN>) {
+                    next if ( $_ =~ /^return \}0/ );
+                    if ( $_ =~ /$waddnstr/ && $1 eq $winaddr ) {
+                        $waddnstr_chars .= $2;
+                    }
+                    else {
+                        last;
+                    }
+                }
+                my $winaddstr = &transaddr($winaddr);
+                print "RUN of waddnstr()s:"
+                  . " $winaddstr, \"$waddnstr_chars\"\n";
+                redo CLASSIFY;
+            }
+
+            # More transformations can go here
+
+            # Repeated runs of anything
+            my $anyline     = &transaddr($_);
+            my $repeatcount = 1;
+            while (<$STDIN>) {
+                if ( &transaddr($_) eq $anyline ) {
+                    $repeatcount++;
+                }
+                else {
+                    last;
+                }
+            }
+            if ( $repeatcount > 1 ) {
+                print "${repeatcount} REPEATS OF $anyline";
+            }
+            else {
+                print $thread . $anyline;
+            }
+            redo CLASSIFY if $_;
+
+        }    # :CLASSIFY
+    }
+}
+
+for my $tr ( keys %TR ) {
+    $TR{$tr} = hex $TR{$tr};
+}
+
+if ( $#ARGV >= 0 ) {
+    while ( $#ARGV >= 0 ) {
+        my $file = shift @ARGV;
+        open my $ifh, "<", $file or die $!;
+        &muncher($ifh);
+    }
+}
+else {
+    &muncher( \*STDIN );
 }
 
 # tracemunch ends here
diff --git a/test/view.c b/test/view.c
index 4782d85..72e0cfb 100644
--- a/test/view.c
+++ b/test/view.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 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            *
@@ -33,7 +34,8 @@
  *
  * modified by Thomas Dickey <dickey@clark.net> July 1995 to demonstrate
  * the use of 'resizeterm()', and May 2000 to illustrate wide-character
- * handling.
+ * handling.  This program intentionally does not use pads, to allow testing
+ * with less-capable implementations of curses.
  *
  * Takes a filename argument.  It's a simple file-viewer with various
  * scroll-up and scroll-down commands.
@@ -50,56 +52,20 @@
  * scroll operation worked, and the refresh() code only had to do a
  * partial repaint.
  *
- * $Id: view.c,v 1.94 2013/09/28 21:58:42 tom Exp $
+ * $Id: view.c,v 1.145 2022/12/04 00:40:11 tom Exp $
  */
 
 #include <test.priv.h>
 #include <widechars.h>
+#include <popup_msg.h>
 
+#include <sys/stat.h>
 #include <time.h>
 
-#undef CTRL			/* conflict on AIX 5.2 with <sys/ioctl.h> */
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#else
-#if !defined(__MINGW32__)
-# include <sgtty.h>
-#endif
-#endif
-
-#if !defined(sun) || !HAVE_TERMIOS_H
-# if HAVE_SYS_IOCTL_H
-#  include <sys/ioctl.h>
-# endif
-#endif
+static GCC_NORETURN void finish(int sig);
 
 #define my_pair 1
 
-/* This is needed to compile 'struct winsize' */
-#if NEED_PTEM_H
-#include <sys/stream.h>
-#include <sys/ptem.h>
-#endif
-
-#undef CTRL
-#define CTRL(x)	((x) & 0x1f)
-
-static void finish(int sig) GCC_NORETURN;
-static void show_all(const char *tag);
-
-#if defined(SIGWINCH) && defined(TIOCGWINSZ) && HAVE_RESIZE_TERM
-#define CAN_RESIZE 1
-#else
-#define CAN_RESIZE 0
-#endif
-
-#if CAN_RESIZE
-static void adjust(int sig);
-static int interrupted;
-static bool waiting = FALSE;
-#endif
-
 static int shift = 0;
 static bool try_color = FALSE;
 
@@ -108,46 +74,29 @@
 static NCURSES_CH_T **lptr;
 static int num_lines;
 
-static void usage(void) GCC_NORETURN;
+#if USE_WIDEC_SUPPORT
+static bool n_option = FALSE;
+#endif
 
-static void
-usage(void)
+static GCC_NORETURN void
+failed(const char *msg)
 {
-    static const char *msg[] =
-    {
-	"Usage: view [options] file"
-	,""
-	,"Options:"
-	," -c       use color if terminal supports it"
-	," -i       ignore INT, QUIT, TERM signals"
-	," -n NUM   specify maximum number of lines (default 1000)"
-#if defined(KEY_RESIZE)
-	," -r       use old-style sigwinch handler rather than KEY_RESIZE"
-#endif
-	," -s       start in single-step mode, waiting for input"
-#ifdef TRACE
-	," -t       trace screen updates"
-	," -T NUM   specify trace mask"
-#endif
-    };
-    size_t n;
-    for (n = 0; n < SIZEOF(msg); n++)
-	fprintf(stderr, "%s\n", msg[n]);
+    endwin();
+    fprintf(stderr, "%s\n", msg);
     ExitProgram(EXIT_FAILURE);
 }
 
 static int
-ch_len(NCURSES_CH_T * src)
+ch_len(NCURSES_CH_T *src)
 {
     int result = 0;
-#if USE_WIDEC_SUPPORT
-    int count;
-#endif
 
 #if USE_WIDEC_SUPPORT
     for (;;) {
+	int count;
 	TEST_CCHAR(src, count, {
-	    ++result;
+	    int len = wcwidth(test_wch[0]);
+	    result += (len > 0) ? len : 1;
 	    ++src;
 	}
 	, {
@@ -161,110 +110,353 @@
     return result;
 }
 
-/*
- * Allocate a string into an array of chtype's.  If UTF-8 mode is
- * active, translate the string accordingly.
- */
-static NCURSES_CH_T *
-ch_dup(char *src)
+static void
+finish(int sig)
 {
-    unsigned len = (unsigned) strlen(src);
-    NCURSES_CH_T *dst = typeMalloc(NCURSES_CH_T, len + 1);
-    size_t j, k;
+    endwin();
+#if NO_LEAKS
+    if (vec_lines != 0) {
+	int n;
+	for (n = 0; n < num_lines; ++n) {
+	    free(vec_lines[n]);
+	}
+	free(vec_lines);
+    }
+#endif
+    ExitProgram(sig != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
+}
+
+static void
+show_all(const char *tag)
+{
+    int i;
+    int digits;
+    char temp[BUFSIZ];
+    time_t this_time;
+
+    for (digits = 1, i = num_lines; i > 0; i /= 10) {
+	++digits;
+    }
+
+    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+		"view %.*s", (int) strlen(tag), tag);
+    i = (int) strlen(temp);
+    _nc_SPRINTF(temp + i, _nc_SLIMIT(sizeof(temp) - (size_t) i)
+		" %.*s", (int) sizeof(temp) - i - 2, fname);
+    move(0, 0);
+    printw("%.*s", COLS, temp);
+    clrtoeol();
+    this_time = time((time_t *) 0);
+    _nc_STRNCPY(temp, ctime(&this_time), (size_t) 30);
+    if ((i = (int) strlen(temp)) != 0) {
+	temp[--i] = 0;
+	if (move(0, COLS - i - 2) != ERR)
+	    printw("  %s", temp);
+    }
+
+    scrollok(stdscr, FALSE);	/* prevent screen from moving */
+    for (i = 1; i < LINES; i++) {
+	NCURSES_CH_T *s;
+	int len;
+	int actual = (int) (lptr + i - vec_lines);
+
+	if (actual > num_lines) {
+	    if (i < LINES - 1) {
+		int y, x;
+		getyx(stdscr, y, x);
+		move(i, 0);
+		clrtobot();
+		move(y, x);
+	    }
+	    break;
+	}
+	move(i, 0);
+	printw("%*d:", digits, actual);
+	clrtoeol();
+	if ((s = lptr[i - 1]) == 0) {
+	    continue;
+	}
+	len = ch_len(s);
+	if (len > shift) {
 #if USE_WIDEC_SUPPORT
-    wchar_t wstr[CCHARW_MAX + 1];
-    wchar_t wch;
-    int l = 0;
-    size_t rc;
+	    /*
+	     * An index into an array of cchar_t's is not necessarily the same
+	     * as the column-offset.  A pad would do this directly.  Here we
+	     * must translate (or compute a table of offsets).
+	     */
+	    {
+		int j;
+		int width = 1;
+
+		for (j = actual = 0; j < shift; ++j) {
+		    int count;
+
+		    TEST_CCHAR(s + j, count, {
+			width = wcwidth(test_wch[0]);
+		    }
+		    , {
+			width = 1;
+		    });
+		    actual += width;
+		    if (actual > shift) {
+			break;
+		    } else if (actual == shift) {
+			++j;
+			break;
+		    }
+		}
+		if (actual < len) {
+		    if (actual > shift)
+			addch('<');
+		    add_wchstr(s + j + (actual > shift));
+		}
+	    }
+#else
+	    addchstr(s + shift);
+#endif
+	}
+#if defined(NCURSES_VERSION) || defined(HAVE_WCHGAT)
+	if (try_color)
+	    wchgat(stdscr, -1, WA_NORMAL, my_pair, NULL);
+#endif
+    }
+    setscrreg(1, LINES - 1);
+    scrollok(stdscr, TRUE);
+    refresh();
+}
+
+static void
+read_file(const char *filename)
+{
+    FILE *fp;
+    int pass;
+    int k;
     int width;
+    size_t j;
+    size_t len;
+    struct stat sb;
+    char *my_blob;
+    char **my_vec = 0;
+    WINDOW *my_win;
+
+    if (stat(filename, &sb) != 0
+	|| (sb.st_mode & S_IFMT) != S_IFREG) {
+	failed("input is not a file");
+    }
+
+    if (sb.st_size == 0) {
+	failed("input is empty");
+    }
+
+    if ((fp = fopen(filename, "r")) == 0) {
+	failed("cannot open input-file");
+    }
+
+    if ((my_blob = malloc((size_t) sb.st_size + 1)) == 0) {
+	failed("cannot allocate memory for input-file");
+    }
+
+    len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp);
+    fclose(fp);
+
+    if (len > (size_t) sb.st_size)
+	len = (size_t) sb.st_size;
+    my_blob[len] = '\0';
+
+    for (pass = 0; pass < 2; ++pass) {
+	char *base = my_blob;
+	k = 0;
+	for (j = 0; j < len; ++j) {
+	    if (my_blob[j] == '\n') {
+		if (pass) {
+		    my_vec[k] = base;
+		    my_blob[j] = '\0';
+		}
+		base = my_blob + j + 1;
+		++k;
+	    }
+	}
+	if (base != (my_blob + j)) {
+	    if (pass)
+		my_vec[k] = base;
+	    ++k;
+	}
+	num_lines = k;
+	if (pass == 0) {
+	    if (((my_vec = typeCalloc(char *, (size_t) k + 2)) == 0)) {
+		failed("cannot allocate line-vector #1");
+	    }
+	} else {
+	    if (my_vec[0] == NULL)
+		my_vec[0] = my_blob;
+	}
+    }
+
+#if USE_WIDEC_SUPPORT
+    if (!memcmp("\357\273\277", my_blob, 3)) {
+	char *s = my_blob + 3;
+	char *d = my_blob;
+	Trace(("trim BOM"));
+	do {
+	} while ((*d++ = *s++) != '\0');
+    }
+#endif
+
+    width = (int) strlen(my_vec[0]);
+    for (k = 1; my_vec[k]; ++k) {
+	int check = (int) (my_vec[k] - my_vec[k - 1]);
+	if (width < check)
+	    width = check;
+    }
+    width = (width + 1) * 5;
+    my_win = newwin(2, width, 0, 0);
+    if (my_win == 0) {
+	failed("cannot allocate temporary window");
+    }
+
+    if ((vec_lines = typeCalloc(NCURSES_CH_T *, (size_t) num_lines + 2)) == 0) {
+	failed("cannot allocate line-vector #2");
+    }
+
+    /*
+     * Use the curses library for rendering, including tab-conversion.  This
+     * will not make the resulting array's indices correspond to column for
+     * lines containing double-width cells because the "in_wch" functions will
+     * ignore the skipped cells.  Use pads for that sort of thing.
+     */
+    Trace(("slurp the file"));
+    for (k = 0; my_vec[k]; ++k) {
+	char *s;
+	int y, x;
+#if USE_WIDEC_SUPPORT
+	char *last = my_vec[k] + (int) strlen(my_vec[k]);
+	wchar_t wch[2];
+	size_t rc;
 #ifndef state_unused
-    mbstate_t state;
+	mbstate_t state;
 #endif
 #endif /* USE_WIDEC_SUPPORT */
 
+	werase(my_win);
+	wmove(my_win, 0, 0);
 #if USE_WIDEC_SUPPORT
-    reset_mbytes(state);
+	wch[1] = 0;
+	reset_mbytes(state);
 #endif
-    for (j = k = 0; j < len; j++) {
+	for (s = my_vec[k]; *s != '\0'; ++s) {
 #if USE_WIDEC_SUPPORT
-	rc = (size_t) check_mbytes(wch, src + j, len - j, state);
-	if (rc == (size_t) -1 || rc == (size_t) -2)
-	    break;
-	j += rc - 1;
-	if ((width = wcwidth(wch)) < 0)
-	    break;
-	if ((width > 0 && l > 0) || l == CCHARW_MAX) {
-	    wstr[l] = L'\0';
-	    l = 0;
-	    if (setcchar(dst + k, wstr, 0, 0, NULL) != OK)
-		break;
-	    ++k;
+	    if (!n_option) {
+		rc = (size_t) check_mbytes(wch[0], s, (size_t) (last - s), state);
+		if ((long) rc == -1 || (long) rc == -2) {
+		    break;
+		}
+		s += rc - 1;
+		waddwstr(my_win, wch);
+	    } else
+#endif
+		waddch(my_win, *s & 0xff);
 	}
-	if (width == 0 && l == 0)
-	    wstr[l++] = L' ';
-	wstr[l++] = wch;
-#else
-	dst[k++] = (chtype) UChar(src[j]);
-#endif
-    }
+	getyx(my_win, y, x);
+	if (y)
+	    x = width - 1;
+	wmove(my_win, 0, 0);
+	/* "x + 1" works with standard curses; some implementations are buggy */
+	if ((vec_lines[k] = typeCalloc(NCURSES_CH_T, x + width + 1)) == 0) {
+	    failed("cannot allocate line-vector #3");
+	}
 #if USE_WIDEC_SUPPORT
-    if (l > 0) {
-	wstr[l] = L'\0';
-	if (setcchar(dst + k, wstr, 0, 0, NULL) == OK)
-	    ++k;
-    }
-    wstr[0] = L'\0';
-    setcchar(dst + k, wstr, 0, 0, NULL);
+	win_wchnstr(my_win, vec_lines[k], x);
 #else
-    dst[k] = 0;
+	winchnstr(my_win, vec_lines[k], x);
 #endif
-    return dst;
+    }
+
+    delwin(my_win);
+    free(my_vec);
+    free(my_blob);
 }
 
+static GCC_NORETURN void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: view [options] file"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+	," -c       use color if terminal supports it"
+	," -i       ignore INT, QUIT, TERM signals"
+#if USE_WIDEC_SUPPORT
+	," -n       use waddch (bytes) rather then wadd_wch (wide-chars)"
+#endif
+	," -s       start in single-step mode, waiting for input"
+#ifdef TRACE
+	," -t       trace screen updates"
+	," -T NUM   specify trace mask"
+#endif
+    };
+    size_t n;
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
 main(int argc, char *argv[])
 {
-    int MAXLINES = 1000;
-    FILE *fp;
-    char buf[BUFSIZ];
+    static const char *help[] =
+    {
+	"Commands:",
+	"  q,^Q,ESC       - quit this program",
+	"",
+	"  p,<Up>         - scroll the viewport up by one row",
+	"  n,<Down>       - scroll the viewport down by one row",
+	"  l,<Left>       - scroll the viewport left by one column",
+	"  r,<Right>      - scroll the viewport right by one column",
+	"  <,>            - scroll the viewport left/right by 8 columns",
+	"",
+	"  h,<Home>       - scroll the viewport to top of file",
+	"  ^F,<PageDn>    - scroll to the next page",
+	"  ^B,<PageUp>    - scroll to the previous page",
+	"  e,<End>        - scroll the viewport to end of file",
+	"",
+	"  ^L             - repaint using redrawwin()",
+	"",
+	"  0 through 9    - enter digits for count",
+	"  s              - use entered count for halfdelay() parameter",
+	"                 - if no entered count, stop nodelay()",
+	"  <space>        - begin nodelay()",
+	0
+    };
+
+    int ch;
     int i;
     int my_delay = 0;
     NCURSES_CH_T **olptr;
     int value = 0;
     bool done = FALSE;
     bool got_number = FALSE;
+    bool ignore_sigs = FALSE;
     bool single_step = FALSE;
-#if CAN_RESIZE
-    bool nonposix_resize = FALSE;
-#endif
     const char *my_label = "Input";
 
     setlocale(LC_ALL, "");
 
-#ifndef NCURSES_VERSION
-    /*
-     * We know ncurses will catch SIGINT if we don't establish our own handler.
-     * Other versions of curses may/may not catch it.
-     */
-    (void) signal(SIGINT, finish);	/* arrange interrupts to terminate */
-#endif
-
-    while ((i = getopt(argc, argv, "cin:rstT:")) != -1) {
-	switch (i) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "cinstT:")) != -1) {
+	switch (ch) {
 	case 'c':
 	    try_color = TRUE;
 	    break;
 	case 'i':
-	    CATCHALL(SIG_IGN);
+	    ignore_sigs = TRUE;
 	    break;
+#if USE_WIDEC_SUPPORT
 	case 'n':
-	    if ((MAXLINES = atoi(optarg)) < 1 ||
-		(MAXLINES + 2) <= 1)
-		usage();
-	    break;
-#if CAN_RESIZE
-	case 'r':
-	    nonposix_resize = TRUE;
+	    n_option = TRUE;
 	    break;
 #endif
 	case 's':
@@ -276,91 +468,26 @@
 		char *next = 0;
 		int tvalue = (int) strtol(optarg, &next, 0);
 		if (tvalue < 0 || (next != 0 && *next != 0))
-		    usage();
-		trace((unsigned) tvalue);
+		    usage(FALSE);
+		curses_trace((unsigned) tvalue);
 	    }
 	    break;
 	case 't':
-	    trace(TRACE_CALLS);
+	    curses_trace(TRACE_CALLS);
 	    break;
 #endif
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	    usage();
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
     if (optind + 1 != argc)
-	usage();
+	usage(FALSE);
 
-    if ((vec_lines = typeCalloc(NCURSES_CH_T *, (size_t) MAXLINES + 2)) == 0)
-	usage();
-
-    assert(vec_lines != 0);
-
-    fname = argv[optind];
-    if ((fp = fopen(fname, "r")) == 0) {
-	perror(fname);
-	ExitProgram(EXIT_FAILURE);
-    }
-#if CAN_RESIZE
-    if (nonposix_resize)
-	(void) signal(SIGWINCH, adjust);	/* arrange interrupts to resize */
-#endif
-
-    Trace(("slurp the file"));
-    for (lptr = &vec_lines[0]; (lptr - vec_lines) < MAXLINES; lptr++) {
-	char temp[BUFSIZ], *s, *d;
-	int col;
-
-	if (fgets(buf, sizeof(buf), fp) == 0)
-	    break;
-
-#if USE_WIDEC_SUPPORT
-	if (lptr == vec_lines) {
-	    if (!memcmp("", buf, 3)) {
-		Trace(("trim BOM"));
-		s = buf + 3;
-		d = buf;
-		do {
-		} while ((*d++ = *s++) != '\0');
-	    }
-	}
-#endif
-
-	/* convert tabs and nonprinting chars so that shift will work properly */
-	for (s = buf, d = temp, col = 0; (*d = *s) != '\0'; s++) {
-	    if (*d == '\r') {
-		if (s[1] == '\n')
-		    continue;
-		else
-		    break;
-	    }
-	    if (*d == '\n') {
-		*d = '\0';
-		break;
-	    } else if (*d == '\t') {
-		col = (col | 7) + 1;
-		while ((d - temp) != col)
-		    *d++ = ' ';
-	    } else
-#if USE_WIDEC_SUPPORT
-		col++, d++;
-#else
-	    if (isprint(UChar(*d))) {
-		col++;
-		d++;
-	    } else {
-		sprintf(d, "\\%03o", UChar(*s));
-		d += strlen(d);
-		col = (int) (d - temp);
-	    }
-#endif
-	}
-	*lptr = ch_dup(temp);
-    }
-    (void) fclose(fp);
-    num_lines = (int) (lptr - vec_lines);
-
-    (void) initscr();		/* initialize the curses library */
+    InitAndCatch(initscr(), ignore_sigs ? SIG_IGN : finish);
     keypad(stdscr, TRUE);	/* enable keyboard mapping */
     (void) nonl();		/* tell curses not to do NL->CR/NL on output */
     (void) cbreak();		/* take input chars one at a time, no wait for \n */
@@ -369,6 +496,8 @@
 	nodelay(stdscr, TRUE);
     idlok(stdscr, TRUE);	/* allow use of insert/delete line */
 
+    read_file(fname = argv[optind]);
+
     if (try_color) {
 	if (has_colors()) {
 	    start_color();
@@ -387,17 +516,7 @@
 	    show_all(my_label);
 
 	for (;;) {
-#if CAN_RESIZE
-	    if (interrupted) {
-		adjust(0);
-		my_label = "interrupt";
-	    }
-	    waiting = TRUE;
 	    c = getch();
-	    waiting = FALSE;
-#else
-	    c = getch();
-#endif
 	    if ((c < 127) && isdigit(c)) {
 		if (!got_number) {
 		    MvPrintw(0, 0, "Count: ");
@@ -441,16 +560,48 @@
 	    break;
 
 	case 'h':
+	    /* FALLTHRU */
 	case KEY_HOME:
 	    lptr = vec_lines;
 	    break;
 
+	case '<':
+	    if ((shift -= 8) < 0)
+		shift = 0;
+	    break;
+	case '>':
+	    shift += 8;
+	    break;
+
 	case 'e':
+	    /* FALLTHRU */
 	case KEY_END:
 	    if (num_lines > LINES)
-		lptr = vec_lines + num_lines - LINES + 1;
+		lptr = (vec_lines + num_lines - LINES + 1);
 	    else
-		lptr = vec_lines;
+		lptr = (vec_lines + (num_lines - 2));
+	    break;
+
+	case CTRL('F'):
+	    /* FALLTHRU */
+	case KEY_NPAGE:
+	    for (i = 0; i < n; i++) {
+		if ((lptr - vec_lines) < (num_lines - 5))
+		    lptr += (LINES - 1);
+		else
+		    lptr = (vec_lines + num_lines - 2);
+	    }
+	    break;
+
+	case CTRL('B'):
+	    /* FALLTHRU */
+	case KEY_PPAGE:
+	    for (i = 0; i < n; i++) {
+		if ((lptr - vec_lines) >= LINES)
+		    lptr -= (LINES - 1);
+		else
+		    lptr = vec_lines;
+	    }
 	    break;
 
 	case 'r':
@@ -468,6 +619,8 @@
 	    break;
 
 	case 'q':
+	case QUIT:
+	case ESCAPE:
 	    done = TRUE;
 	    break;
 
@@ -476,12 +629,17 @@
 	    break;
 #endif
 	case 's':
+#if HAVE_HALFDELAY
 	    if (got_number) {
 		halfdelay(my_delay = n);
 	    } else {
 		nodelay(stdscr, FALSE);
 		my_delay = -1;
 	    }
+#else
+	    nodelay(stdscr, FALSE);
+	    my_delay = -1;
+#endif
 	    break;
 	case ' ':
 	    nodelay(stdscr, TRUE);
@@ -494,6 +652,9 @@
 	    if (!my_delay)
 		napms(50);
 	    break;
+	case HELP_KEY_1:
+	    popup_msg(stdscr, help);
+	    break;
 	default:
 	    beep();
 	    break;
@@ -506,105 +667,3 @@
 
     finish(0);			/* we're done */
 }
-
-static void
-finish(int sig)
-{
-    endwin();
-#if NO_LEAKS
-    if (vec_lines != 0) {
-	int n;
-	for (n = 0; n < num_lines; ++n) {
-	    free(vec_lines[n]);
-	}
-	free(vec_lines);
-    }
-#endif
-    ExitProgram(sig != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-#if CAN_RESIZE
-/*
- * This uses functions that are "unsafe", but it seems to work on SunOS. 
- * Usually: the "unsafe" refers to the functions that POSIX lists which may be
- * called from a signal handler.  Those do not include buffered I/O, which is
- * used for instance in wrefresh().  To be really portable, you should use the
- * KEY_RESIZE return (which relies on ncurses' sigwinch handler).
- *
- * The 'wrefresh(curscr)' is needed to force the refresh to start from the top
- * of the screen -- some xterms mangle the bitmap while resizing.
- */
-static void
-adjust(int sig)
-{
-    if (waiting || sig == 0) {
-	struct winsize size;
-
-	if (ioctl(fileno(stdout), TIOCGWINSZ, &size) == 0) {
-	    resize_term(size.ws_row, size.ws_col);
-	    wrefresh(curscr);
-	    show_all(sig ? "SIGWINCH" : "interrupt");
-	}
-	interrupted = FALSE;
-    } else {
-	interrupted = TRUE;
-    }
-    (void) signal(SIGWINCH, adjust);	/* some systems need this */
-}
-#endif /* CAN_RESIZE */
-
-static void
-show_all(const char *tag)
-{
-    int i;
-    char temp[BUFSIZ];
-    NCURSES_CH_T *s;
-    time_t this_time;
-
-#if CAN_RESIZE
-    sprintf(temp, "%.20s (%3dx%3d) col %d ", tag, LINES, COLS, shift);
-    i = (int) strlen(temp);
-    if ((i + 7) < (int) sizeof(temp)) {
-	sprintf(temp + i, "view %.*s",
-		(int) (sizeof(temp) - 7 - (size_t) i),
-		fname);
-    }
-#else
-    (void) tag;
-    sprintf(temp, "view %.*s", (int) sizeof(temp) - 7, fname);
-#endif
-    move(0, 0);
-    printw("%.*s", COLS, temp);
-    clrtoeol();
-    this_time = time((time_t *) 0);
-    strncpy(temp, ctime(&this_time), (size_t) 30);
-    if ((i = (int) strlen(temp)) != 0) {
-	temp[--i] = 0;
-	if (move(0, COLS - i - 2) != ERR)
-	    printw("  %s", temp);
-    }
-
-    scrollok(stdscr, FALSE);	/* prevent screen from moving */
-    for (i = 1; i < LINES; i++) {
-	move(i, 0);
-	printw("%3ld:", (long) (lptr + i - vec_lines));
-	clrtoeol();
-	if ((s = lptr[i - 1]) != 0) {
-	    int len = ch_len(s);
-	    if (len > shift) {
-#if USE_WIDEC_SUPPORT
-		add_wchstr(s + shift);
-#else
-		addchstr(s + shift);
-#endif
-	    }
-#if defined(NCURSES_VERSION) || defined(HAVE_WCHGAT)
-	    if (try_color)
-		wchgat(stdscr, -1, A_NORMAL, my_pair, NULL);
-#endif
-	}
-    }
-    setscrreg(1, LINES - 1);
-    scrollok(stdscr, TRUE);
-    refresh();
-}
diff --git a/test/widechars-utf8-tabs.txt b/test/widechars-utf8-tabs.txt
new file mode 100644
index 0000000..ca605a1
--- /dev/null
+++ b/test/widechars-utf8-tabs.txt
@@ -0,0 +1,15 @@
+APPLE	-- It's an APPLE.
+DOG		-- No, that's not my DOG.
+ORANGE	-- Yeah, that's JUICY.
+CHICKEN	-- Normally not a PET.
+CAT		-- No, never put a DOG and a CAT together!
+FISH	-- Cats like FISH.
+LEMON	-- You KNOW how it TASTES.
+----+----1----+----2----+----3----+----4
+APPLE	-- It's an APPLE.
+ APPLE	-- It's an APPLE.
+  APPLE	-- It's an APPLE.
+   APPLE	-- It's an APPLE.
+    APPLE	-- It's an APPLE.
+     APPLE	-- It's an APPLE.
+----+----1----+----2----+----3----+----4
diff --git a/test/widechars.h b/test/widechars.h
index e7897ba..2578a92 100644
--- a/test/widechars.h
+++ b/test/widechars.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2012 Free Software Foundation, Inc.                        *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 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            *
@@ -33,7 +34,7 @@
 
 #if USE_WIDEC_SUPPORT
 
-#if defined(__MINGW32__)
+#if defined(_NC_WINDOWS) && !defined(_MSC_VER) && !defined(EXP_WIN32_DRIVER)
 /*
  * MinGW has wide-character functions, but they do not work correctly.
  */
@@ -45,7 +46,7 @@
 extern int __MINGW_NOTHROW _nc_mblen(const char *, size_t);
 #define mblen(s,n) _nc_mblen(s, n)
 
-#endif /* __MINGW32__ */
+#endif /* _WIN32||_WIN64 */
 
 #if HAVE_MBTOWC && HAVE_MBLEN
 #define reset_mbytes(state) IGNORE_RC(mblen(NULL, 0)), IGNORE_RC(mbtowc(NULL, NULL, 0))
diff --git a/test/worm.c b/test/worm.c
index c3fc0da..7c4842e 100644
--- a/test/worm.c
+++ b/test/worm.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 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            *
@@ -47,25 +48,20 @@
 
 		July 1995 (esr): worms is now in living color! :-)
 
-Options:
-	-f			fill screen with copies of 'WORM' at start.
-	-l <n>			set worm length
-	-n <n>			set number of worms
-	-t			make worms leave droppings
-	-T <start> <end>	set trace interval
-	-S			set single-stepping during trace interval
-	-N			suppress cursor-movement optimization
-
   This program makes a good torture-test for the ncurses cursor-optimization
   code.  You can use -T to set the worm move interval over which movement
   traces will be dumped.  The program stops and waits for one character of
   input at the beginning and end of the interval.
 
-  $Id: worm.c,v 1.65 2013/06/22 20:01:41 tom Exp $
+  $Id: worm.c,v 1.89 2022/12/24 20:46:49 tom Exp $
 */
 
 #include <test.priv.h>
 
+#ifndef NCURSES_VERSION
+#undef TRACE
+#endif
+
 #ifdef USE_PTHREADS
 #include <pthread.h>
 #endif
@@ -102,6 +98,7 @@
 static bool quitting = FALSE;
 
 static WORM worm[MAX_WORMS];
+static int max_refs;
 static int **refs;
 static int last_x, last_y;
 
@@ -110,6 +107,18 @@
 static chtype trail = ' ';
 
 static unsigned pending;
+
+#ifdef USE_PTHREADS
+#define Locked(statement) { \
+	pthread_mutex_lock(&pending_mutex); \
+	statement; \
+	pthread_mutex_unlock(&pending_mutex); \
+    }
+pthread_mutex_t pending_mutex;
+#else
+#define Locked(statement) statement
+#endif
+
 #ifdef TRACE
 static int generation, trace_start, trace_end;
 #endif /* TRACE */
@@ -201,20 +210,34 @@
 };
 /* *INDENT-ON* */
 
+#if HAVE_USE_WINDOW
+static int
+safe_wgetch(WINDOW *w, void *data GCC_UNUSED)
+{
+    return wgetch(w);
+}
+static int
+safe_wrefresh(WINDOW *w, void *data GCC_UNUSED)
+{
+    return wrefresh(w);
+}
+#endif
+
+#ifdef KEY_RESIZE
 static void
 failed(const char *s)
 {
     perror(s);
-    endwin();
+    stop_curses();
     ExitProgram(EXIT_FAILURE);
 }
+#endif
 
 static void
 cleanup(void)
 {
-    USING_WINDOW(stdscr, wrefresh);
-    curs_set(1);
-    endwin();
+    USING_WINDOW1(stdscr, wrefresh, safe_wrefresh);
+    stop_curses();
 }
 
 static void
@@ -237,13 +260,18 @@
     WORM *w = (WORM *) data;
     const struct options *op;
     unsigned mask = (unsigned) (~(1 << (w - worm)));
-    chtype attrs = w->attrs | ((mask & pending) ? A_REVERSE : 0);
+    chtype attrs;
 
     int x;
     int y;
     int h;
 
     bool done = FALSE;
+    bool is_pending;
+
+    Locked(is_pending = ((mask & pending) != 0));
+
+    attrs = w->attrs | (is_pending ? A_REVERSE : 0);
 
     if ((x = w->xpos[h = w->head]) < 0) {
 	wmove(win, y = w->ypos[h] = last_y, x = w->xpos[h] = 0);
@@ -294,6 +322,7 @@
     switch (op->nopts) {
     case 0:
 	done = TRUE;
+	Trace(("done - draw_worm"));
 	break;
     case 1:
 	w->orientation = op->opts[0];
@@ -324,9 +353,12 @@
 static bool
 quit_worm(int bitnum)
 {
-    pending |= (1 << bitnum);
+    Locked(pending = (pending | (unsigned) (1 << bitnum)));
+
     napms(10);			/* let the other thread(s) have a chance */
-    pending &= ~(1 << bitnum);
+
+    Locked(pending = (pending & (unsigned) ~(1 << bitnum)));
+
     return quitting;
 }
 
@@ -335,14 +367,14 @@
 {
     unsigned long compare = 0;
     Trace(("start_worm"));
-    while (!quit_worm(((struct worm *) arg) - worm)) {
-	while (compare < sequence) {
+    while (!quit_worm((int) (((struct worm *) arg) - worm))) {
+	for (;;) {
+	    bool done = FALSE;
+	    Locked(done = (compare >= sequence));
+	    if (done)
+		break;
 	    ++compare;
-#if HAVE_USE_WINDOW
-	    use_window(stdscr, draw_worm, arg);
-#else
-	    draw_worm(stdscr, arg);
-#endif
+	    USING_WINDOW2(stdscr, draw_worm, arg);
 	}
     }
     Trace(("...start_worm (done)"));
@@ -367,13 +399,7 @@
     }
 #else
     for (n = 0, w = &worm[0]; n < number; n++, w++) {
-	if (
-#if HAVE_USE_WINDOW
-	       USING_WINDOW2(stdscr, draw_worm, w)
-#else
-	       draw_worm(stdscr, w)
-#endif
-	    )
+	if (USING_WINDOW2(stdscr, draw_worm, w))
 	    done = TRUE;
     }
 #endif
@@ -384,17 +410,18 @@
 get_input(void)
 {
     int ch;
-    ch = USING_WINDOW(stdscr, wgetch);
+    ch = USING_WINDOW1(stdscr, wgetch, safe_wgetch);
     return ch;
 }
 
 #ifdef KEY_RESIZE
 static int
-update_refs(WINDOW *win)
+update_refs(WINDOW *win, void *data)
 {
     int x, y;
 
     (void) win;
+    (void) data;
     if (last_x != COLS - 1) {
 	for (y = 0; y <= last_y; y++) {
 	    refs[y] = typeRealloc(int, (size_t) COLS, refs[y]);
@@ -408,6 +435,7 @@
     if (last_y != LINES - 1) {
 	for (y = LINES; y <= last_y; y++)
 	    free(refs[y]);
+	max_refs = LINES;
 	refs = typeRealloc(int *, (size_t) LINES, refs);
 	for (y = last_y + 1; y < LINES; y++) {
 	    refs[y] = typeMalloc(int, (size_t) COLS);
@@ -422,41 +450,73 @@
 }
 #endif
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: worm [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+#if HAVE_USE_DEFAULT_COLORS
+	," -d       invoke use_default_colors"
+#endif
+	," -f       fill screen with copies of \"WORM\" at start"
+	," -l <n>   set length of worms"
+	," -n <n>   set number of worms"
+	," -t       leave trail of \".\""
+#ifdef TRACE
+	," -T <start>,<end> set trace interval"
+	," -N       suppress cursor-movement optimization"
+#endif
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
 int
 main(int argc, char *argv[])
 {
+    int ch;
     int x, y;
     int n;
     struct worm *w;
     int *ip;
     bool done = FALSE;
-    int max_refs;
+#if HAVE_USE_DEFAULT_COLORS
+    bool opt_d = FALSE;
+#endif
 
     setlocale(LC_ALL, "");
 
-    for (x = 1; x < argc; x++) {
-	char *p;
-	p = argv[x];
-	if (*p == '-')
-	    p++;
-	switch (*p) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "dfl:n:tT:N")) != -1) {
+	switch (ch) {
+#if HAVE_USE_DEFAULT_COLORS
+	case 'd':
+	    opt_d = TRUE;
+	    break;
+#endif
 	case 'f':
 	    field = "WORM";
 	    break;
 	case 'l':
-	    if (++x == argc)
-		goto usage;
-	    if ((length = atoi(argv[x])) < 2 || length > MAX_LENGTH) {
+	    if ((length = atoi(optarg)) < 2 || length > MAX_LENGTH) {
 		fprintf(stderr, "%s: Invalid length\n", *argv);
-		ExitProgram(EXIT_FAILURE);
+		usage(FALSE);
 	    }
 	    break;
 	case 'n':
-	    if (++x == argc)
-		goto usage;
-	    if ((number = atoi(argv[x])) < 1 || number > MAX_WORMS) {
+	    if ((number = atoi(optarg)) < 1 || number > MAX_WORMS) {
 		fprintf(stderr, "%s: Invalid number of worms\n", *argv);
-		ExitProgram(EXIT_FAILURE);
+		usage(FALSE);
 	    }
 	    break;
 	case 't':
@@ -464,20 +524,23 @@
 	    break;
 #ifdef TRACE
 	case 'T':
-	    trace_start = atoi(argv[++x]);
-	    trace_end = atoi(argv[++x]);
+	    if (sscanf(optarg, "%d,%d", &trace_start, &trace_end) != 2)
+		usage(FALSE);
 	    break;
 	case 'N':
 	    _nc_optimize_enable ^= OPTIMIZE_ALL;	/* declared by ncurses */
 	    break;
 #endif /* TRACE */
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
 	default:
-	  usage:
-	    fprintf(stderr,
-		    "usage: %s [-field] [-length #] [-number #] [-trail]\n", *argv);
-	    ExitProgram(EXIT_FAILURE);
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
 	}
     }
+    if (optind < argc)
+	usage(FALSE);
 
     signal(SIGINT, onsig);
     initscr();
@@ -495,7 +558,7 @@
 	int bg = COLOR_BLACK;
 	start_color();
 #if HAVE_USE_DEFAULT_COLORS
-	if (use_default_colors() == OK)
+	if (opt_d && (use_default_colors() == OK))
 	    bg = -1;
 #endif
 
@@ -558,21 +621,23 @@
 	    }
 	}
     }
-    USING_WINDOW(stdscr, wrefresh);
+    USING_WINDOW1(stdscr, wrefresh, safe_wrefresh);
     nodelay(stdscr, TRUE);
 
-    while (!done) {
-	int ch;
+#ifdef USE_PTHREADS
+    pthread_mutex_init(&pending_mutex, NULL);
+#endif
 
-	++sequence;
+    while (!done) {
+	Locked(++sequence);
 	if ((ch = get_input()) > 0) {
 #ifdef TRACE
 	    if (trace_start || trace_end) {
 		if (generation == trace_start) {
-		    trace(TRACE_CALLS);
+		    curses_trace(TRACE_CALLS);
 		    get_input();
 		} else if (generation == trace_end) {
-		    trace(0);
+		    curses_trace(0);
 		    get_input();
 		}
 
@@ -593,6 +658,7 @@
 	    if (ch == 'q') {
 		quitting = TRUE;
 		done = TRUE;
+		Trace(("done - quitting"));
 		continue;
 	    } else if (ch == 's') {
 		nodelay(stdscr, FALSE);
@@ -603,21 +669,11 @@
 
 	done = draw_all_worms();
 	napms(10);
-	USING_WINDOW(stdscr, wrefresh);
+	USING_WINDOW1(stdscr, wrefresh, safe_wrefresh);
     }
 
     Trace(("Cleanup"));
     cleanup();
-#ifdef NO_LEAKS
-    for (y = 0; y < max_refs; y++) {
-	free(refs[y]);
-    }
-    free(refs);
-    for (n = number, w = &worm[0]; --n >= 0; w++) {
-	free(w->xpos);
-	free(w->ypos);
-    }
-#endif
 #ifdef USE_PTHREADS
     /*
      * Do this just in case one of the threads did not really exit.
@@ -627,5 +683,15 @@
 	pthread_join(worm[n].thread, NULL);
     }
 #endif
+#if NO_LEAKS
+    for (y = 0; y < max_refs; y++) {
+	free(refs[y]);
+    }
+    free(refs);
+    for (n = number, w = &worm[0]; --n >= 0; w++) {
+	free(w->xpos);
+	free(w->ypos);
+    }
+#endif
     ExitProgram(EXIT_SUCCESS);
 }
diff --git a/test/xmas.c b/test/xmas.c
index 087fcd9..9ba3a26 100644
--- a/test/xmas.c
+++ b/test/xmas.c
@@ -92,7 +92,7 @@
 /******************************************************************************/
 
 /*
- * $Id: xmas.c,v 1.28 2013/04/27 19:46:53 tom Exp $
+ * $Id: xmas.c,v 1.39 2022/12/04 00:40:11 tom Exp $
  */
 #include <test.priv.h>
 
@@ -133,22 +133,7 @@
 static WINDOW *w_del_msg;
 static bool *my_pairs;
 
-static int boxit(void);
-static int seas(void);
-static int greet(void);
-static int fromwho(void);
-static int tree(void);
-static int balls(void);
-static int star(void);
-static int strng1(void);
-static int strng2(void);
-static int strng3(void);
-static int strng4(void);
-static int strng5(void);
-static int reindeer(void);
-static int blinkit(void);
-
-static void done(int sig) GCC_NORETURN;
+static GCC_NORETURN void done(int sig);
 
 static void
 set_color(WINDOW *win, chtype color)
@@ -183,495 +168,6 @@
     }
 }
 
-int
-main(int argc GCC_UNUSED, char **argv GCC_UNUSED)
-{
-    int loopy;
-
-    setlocale(LC_ALL, "");
-
-    initscr();
-    noecho();
-    nonl();
-    refresh();
-
-    CATCHALL(done);
-
-    if (has_colors()) {
-	start_color();
-#if HAVE_USE_DEFAULT_COLORS
-	if (use_default_colors() == OK)
-	    my_bg = -1;
-#endif
-    }
-    curs_set(0);
-
-    if ((treescrn = newwin(16, 27, 3, 53)) == 0 ||
-	(treescrn2 = newwin(16, 27, 3, 53)) == 0 ||
-	(treescrn3 = newwin(16, 27, 3, 53)) == 0 ||
-	(treescrn4 = newwin(16, 27, 3, 53)) == 0 ||
-	(treescrn5 = newwin(16, 27, 3, 53)) == 0 ||
-	(treescrn6 = newwin(16, 27, 3, 53)) == 0 ||
-	(treescrn7 = newwin(16, 27, 3, 53)) == 0 ||
-	(treescrn8 = newwin(16, 27, 3, 53)) == 0 ||
-
-	(dotdeer0 = newwin(3, 71, 0, 8)) == 0 ||
-
-	(stardeer0 = newwin(4, 56, 0, 8)) == 0 ||
-
-	(lildeer0 = newwin(7, 53, 0, 8)) == 0 ||
-	(lildeer1 = newwin(2, 4, 0, 0)) == 0 ||
-	(lildeer2 = newwin(2, 4, 0, 0)) == 0 ||
-	(lildeer3 = newwin(2, 4, 0, 0)) == 0 ||
-
-	(middeer0 = newwin(15, 42, 0, 8)) == 0 ||
-	(middeer1 = newwin(3, 7, 0, 0)) == 0 ||
-	(middeer2 = newwin(3, 7, 0, 0)) == 0 ||
-	(middeer3 = newwin(3, 7, 0, 0)) == 0 ||
-
-	(bigdeer0 = newwin(10, 23, 0, 0)) == 0 ||
-	(bigdeer1 = newwin(10, 23, 0, 0)) == 0 ||
-	(bigdeer2 = newwin(10, 23, 0, 0)) == 0 ||
-	(bigdeer3 = newwin(10, 23, 0, 0)) == 0 ||
-	(bigdeer4 = newwin(10, 23, 0, 0)) == 0 ||
-
-	(lookdeer0 = newwin(10, 25, 0, 0)) == 0 ||
-	(lookdeer1 = newwin(10, 25, 0, 0)) == 0 ||
-	(lookdeer2 = newwin(10, 25, 0, 0)) == 0 ||
-	(lookdeer3 = newwin(10, 25, 0, 0)) == 0 ||
-	(lookdeer4 = newwin(10, 25, 0, 0)) == 0 ||
-
-	(w_holiday = newwin(1, 26, 3, 27)) == 0 ||
-
-	(w_del_msg = newwin(1, 19, 23, 60)) == 0) {
-	endwin();
-	fprintf(stderr, "Cannot create windows - screen too small\n");
-	ExitProgram(EXIT_FAILURE);
-    }
-
-    MvWAddStr(w_del_msg, 0, 0, "Hit any key to quit");
-
-    MvWAddStr(w_holiday, 0, 0, "H A P P Y  H O L I D A Y S");
-
-    /* set up the windows for our various reindeer */
-
-    /* lildeer1 */
-    MvWAddCh(lildeer1, 0, 0, (chtype) 'V');
-    MvWAddCh(lildeer1, 1, 0, (chtype) '@');
-    MvWAddCh(lildeer1, 1, 1, (chtype) '<');
-    MvWAddCh(lildeer1, 1, 2, (chtype) '>');
-    MvWAddCh(lildeer1, 1, 3, (chtype) '~');
-
-    /* lildeer2 */
-    MvWAddCh(lildeer2, 0, 0, (chtype) 'V');
-    MvWAddCh(lildeer2, 1, 0, (chtype) '@');
-    MvWAddCh(lildeer2, 1, 1, (chtype) '|');
-    MvWAddCh(lildeer2, 1, 2, (chtype) '|');
-    MvWAddCh(lildeer2, 1, 3, (chtype) '~');
-
-    /* lildeer3 */
-    MvWAddCh(lildeer3, 0, 0, (chtype) 'V');
-    MvWAddCh(lildeer3, 1, 0, (chtype) '@');
-    MvWAddCh(lildeer3, 1, 1, (chtype) '>');
-    MvWAddCh(lildeer3, 1, 2, (chtype) '<');
-    MvWAddCh(lildeer2, 1, 3, (chtype) '~');
-
-    /* middeer1 */
-    MvWAddCh(middeer1, 0, 2, (chtype) 'y');
-    MvWAddCh(middeer1, 0, 3, (chtype) 'y');
-    MvWAddCh(middeer1, 1, 2, (chtype) '0');
-    MvWAddCh(middeer1, 1, 3, (chtype) '(');
-    MvWAddCh(middeer1, 1, 4, (chtype) '=');
-    MvWAddCh(middeer1, 1, 5, (chtype) ')');
-    MvWAddCh(middeer1, 1, 6, (chtype) '~');
-    MvWAddCh(middeer1, 2, 3, (chtype) '\\');
-    MvWAddCh(middeer1, 2, 4, (chtype) '/');
-
-    /* middeer2 */
-    MvWAddCh(middeer2, 0, 2, (chtype) 'y');
-    MvWAddCh(middeer2, 0, 3, (chtype) 'y');
-    MvWAddCh(middeer2, 1, 2, (chtype) '0');
-    MvWAddCh(middeer2, 1, 3, (chtype) '(');
-    MvWAddCh(middeer2, 1, 4, (chtype) '=');
-    MvWAddCh(middeer2, 1, 5, (chtype) ')');
-    MvWAddCh(middeer2, 1, 6, (chtype) '~');
-    MvWAddCh(middeer2, 2, 3, (chtype) '|');
-    MvWAddCh(middeer2, 2, 5, (chtype) '|');
-
-    /* middeer3 */
-    MvWAddCh(middeer3, 0, 2, (chtype) 'y');
-    MvWAddCh(middeer3, 0, 3, (chtype) 'y');
-    MvWAddCh(middeer3, 1, 2, (chtype) '0');
-    MvWAddCh(middeer3, 1, 3, (chtype) '(');
-    MvWAddCh(middeer3, 1, 4, (chtype) '=');
-    MvWAddCh(middeer3, 1, 5, (chtype) ')');
-    MvWAddCh(middeer3, 1, 6, (chtype) '~');
-    MvWAddCh(middeer3, 2, 2, (chtype) '/');
-    MvWAddCh(middeer3, 2, 6, (chtype) '\\');
-
-    /* bigdeer1 */
-    MvWAddCh(bigdeer1, 0, 17, (chtype) '\\');
-    MvWAddCh(bigdeer1, 0, 18, (chtype) '/');
-    MvWAddCh(bigdeer1, 0, 20, (chtype) '\\');
-    MvWAddCh(bigdeer1, 0, 21, (chtype) '/');
-    MvWAddCh(bigdeer1, 1, 18, (chtype) '\\');
-    MvWAddCh(bigdeer1, 1, 20, (chtype) '/');
-    MvWAddCh(bigdeer1, 2, 19, (chtype) '|');
-    MvWAddCh(bigdeer1, 2, 20, (chtype) '_');
-    MvWAddCh(bigdeer1, 3, 18, (chtype) '/');
-    MvWAddCh(bigdeer1, 3, 19, (chtype) '^');
-    MvWAddCh(bigdeer1, 3, 20, (chtype) '0');
-    MvWAddCh(bigdeer1, 3, 21, (chtype) '\\');
-    MvWAddCh(bigdeer1, 4, 17, (chtype) '/');
-    MvWAddCh(bigdeer1, 4, 18, (chtype) '/');
-    MvWAddCh(bigdeer1, 4, 19, (chtype) '\\');
-    MvWAddCh(bigdeer1, 4, 22, (chtype) '\\');
-    MvWAddStr(bigdeer1, 5, 7, "^~~~~~~~~//  ~~U");
-    MvWAddStr(bigdeer1, 6, 7, "( \\_____( /");
-    MvWAddStr(bigdeer1, 7, 8, "( )    /");
-    MvWAddStr(bigdeer1, 8, 9, "\\\\   /");
-    MvWAddStr(bigdeer1, 9, 11, "\\>/>");
-
-    /* bigdeer2 */
-    MvWAddCh(bigdeer2, 0, 17, (chtype) '\\');
-    MvWAddCh(bigdeer2, 0, 18, (chtype) '/');
-    MvWAddCh(bigdeer2, 0, 20, (chtype) '\\');
-    MvWAddCh(bigdeer2, 0, 21, (chtype) '/');
-    MvWAddCh(bigdeer2, 1, 18, (chtype) '\\');
-    MvWAddCh(bigdeer2, 1, 20, (chtype) '/');
-    MvWAddCh(bigdeer2, 2, 19, (chtype) '|');
-    MvWAddCh(bigdeer2, 2, 20, (chtype) '_');
-    MvWAddCh(bigdeer2, 3, 18, (chtype) '/');
-    MvWAddCh(bigdeer2, 3, 19, (chtype) '^');
-    MvWAddCh(bigdeer2, 3, 20, (chtype) '0');
-    MvWAddCh(bigdeer2, 3, 21, (chtype) '\\');
-    MvWAddCh(bigdeer2, 4, 17, (chtype) '/');
-    MvWAddCh(bigdeer2, 4, 18, (chtype) '/');
-    MvWAddCh(bigdeer2, 4, 19, (chtype) '\\');
-    MvWAddCh(bigdeer2, 4, 22, (chtype) '\\');
-    MvWAddStr(bigdeer2, 5, 7, "^~~~~~~~~//  ~~U");
-    MvWAddStr(bigdeer2, 6, 7, "(( )____( /");
-    MvWAddStr(bigdeer2, 7, 7, "( /      |");
-    MvWAddStr(bigdeer2, 8, 8, "\\/      |");
-    MvWAddStr(bigdeer2, 9, 9, "|>     |>");
-
-    /* bigdeer3 */
-    MvWAddCh(bigdeer3, 0, 17, (chtype) '\\');
-    MvWAddCh(bigdeer3, 0, 18, (chtype) '/');
-    MvWAddCh(bigdeer3, 0, 20, (chtype) '\\');
-    MvWAddCh(bigdeer3, 0, 21, (chtype) '/');
-    MvWAddCh(bigdeer3, 1, 18, (chtype) '\\');
-    MvWAddCh(bigdeer3, 1, 20, (chtype) '/');
-    MvWAddCh(bigdeer3, 2, 19, (chtype) '|');
-    MvWAddCh(bigdeer3, 2, 20, (chtype) '_');
-    MvWAddCh(bigdeer3, 3, 18, (chtype) '/');
-    MvWAddCh(bigdeer3, 3, 19, (chtype) '^');
-    MvWAddCh(bigdeer3, 3, 20, (chtype) '0');
-    MvWAddCh(bigdeer3, 3, 21, (chtype) '\\');
-    MvWAddCh(bigdeer3, 4, 17, (chtype) '/');
-    MvWAddCh(bigdeer3, 4, 18, (chtype) '/');
-    MvWAddCh(bigdeer3, 4, 19, (chtype) '\\');
-    MvWAddCh(bigdeer3, 4, 22, (chtype) '\\');
-    MvWAddStr(bigdeer3, 5, 7, "^~~~~~~~~//  ~~U");
-    MvWAddStr(bigdeer3, 6, 6, "( ()_____( /");
-    MvWAddStr(bigdeer3, 7, 6, "/ /       /");
-    MvWAddStr(bigdeer3, 8, 5, "|/          \\");
-    MvWAddStr(bigdeer3, 9, 5, "/>           \\>");
-
-    /* bigdeer4 */
-    MvWAddCh(bigdeer4, 0, 17, (chtype) '\\');
-    MvWAddCh(bigdeer4, 0, 18, (chtype) '/');
-    MvWAddCh(bigdeer4, 0, 20, (chtype) '\\');
-    MvWAddCh(bigdeer4, 0, 21, (chtype) '/');
-    MvWAddCh(bigdeer4, 1, 18, (chtype) '\\');
-    MvWAddCh(bigdeer4, 1, 20, (chtype) '/');
-    MvWAddCh(bigdeer4, 2, 19, (chtype) '|');
-    MvWAddCh(bigdeer4, 2, 20, (chtype) '_');
-    MvWAddCh(bigdeer4, 3, 18, (chtype) '/');
-    MvWAddCh(bigdeer4, 3, 19, (chtype) '^');
-    MvWAddCh(bigdeer4, 3, 20, (chtype) '0');
-    MvWAddCh(bigdeer4, 3, 21, (chtype) '\\');
-    MvWAddCh(bigdeer4, 4, 17, (chtype) '/');
-    MvWAddCh(bigdeer4, 4, 18, (chtype) '/');
-    MvWAddCh(bigdeer4, 4, 19, (chtype) '\\');
-    MvWAddCh(bigdeer4, 4, 22, (chtype) '\\');
-    MvWAddStr(bigdeer4, 5, 7, "^~~~~~~~~//  ~~U");
-    MvWAddStr(bigdeer4, 6, 6, "( )______( /");
-    MvWAddStr(bigdeer4, 7, 5, "(/          \\");
-    MvWAddStr(bigdeer4, 8, 0, "v___=             ----^");
-
-    /* lookdeer1 */
-    MvWAddStr(lookdeer1, 0, 16, "\\/     \\/");
-    MvWAddStr(lookdeer1, 1, 17, "\\Y/ \\Y/");
-    MvWAddStr(lookdeer1, 2, 19, "\\=/");
-    MvWAddStr(lookdeer1, 3, 17, "^\\o o/^");
-    MvWAddStr(lookdeer1, 4, 17, "//( )");
-    MvWAddStr(lookdeer1, 5, 7, "^~~~~~~~~// \\O/");
-    MvWAddStr(lookdeer1, 6, 7, "( \\_____( /");
-    MvWAddStr(lookdeer1, 7, 8, "( )    /");
-    MvWAddStr(lookdeer1, 8, 9, "\\\\   /");
-    MvWAddStr(lookdeer1, 9, 11, "\\>/>");
-
-    /* lookdeer2 */
-    MvWAddStr(lookdeer2, 0, 16, "\\/     \\/");
-    MvWAddStr(lookdeer2, 1, 17, "\\Y/ \\Y/");
-    MvWAddStr(lookdeer2, 2, 19, "\\=/");
-    MvWAddStr(lookdeer2, 3, 17, "^\\o o/^");
-    MvWAddStr(lookdeer2, 4, 17, "//( )");
-    MvWAddStr(lookdeer2, 5, 7, "^~~~~~~~~// \\O/");
-    MvWAddStr(lookdeer2, 6, 7, "(( )____( /");
-    MvWAddStr(lookdeer2, 7, 7, "( /      |");
-    MvWAddStr(lookdeer2, 8, 8, "\\/      |");
-    MvWAddStr(lookdeer2, 9, 9, "|>     |>");
-
-    /* lookdeer3 */
-    MvWAddStr(lookdeer3, 0, 16, "\\/     \\/");
-    MvWAddStr(lookdeer3, 1, 17, "\\Y/ \\Y/");
-    MvWAddStr(lookdeer3, 2, 19, "\\=/");
-    MvWAddStr(lookdeer3, 3, 17, "^\\o o/^");
-    MvWAddStr(lookdeer3, 4, 17, "//( )");
-    MvWAddStr(lookdeer3, 5, 7, "^~~~~~~~~// \\O/");
-    MvWAddStr(lookdeer3, 6, 6, "( ()_____( /");
-    MvWAddStr(lookdeer3, 7, 6, "/ /       /");
-    MvWAddStr(lookdeer3, 8, 5, "|/          \\");
-    MvWAddStr(lookdeer3, 9, 5, "/>           \\>");
-
-    /* lookdeer4 */
-    MvWAddStr(lookdeer4, 0, 16, "\\/     \\/");
-    MvWAddStr(lookdeer4, 1, 17, "\\Y/ \\Y/");
-    MvWAddStr(lookdeer4, 2, 19, "\\=/");
-    MvWAddStr(lookdeer4, 3, 17, "^\\o o/^");
-    MvWAddStr(lookdeer4, 4, 17, "//( )");
-    MvWAddStr(lookdeer4, 5, 7, "^~~~~~~~~// \\O/");
-    MvWAddStr(lookdeer4, 6, 6, "( )______( /");
-    MvWAddStr(lookdeer4, 7, 5, "(/          \\");
-    MvWAddStr(lookdeer4, 8, 0, "v___=             ----^");
-
-	/***********************************************/
-    cbreak();
-    nodelay(stdscr, TRUE);
-    for (;;) {
-	clear();
-	werase(treescrn);
-	touchwin(w_del_msg);
-	touchwin(treescrn);
-	werase(treescrn2);
-	touchwin(treescrn2);
-	werase(treescrn8);
-	touchwin(treescrn8);
-	refresh();
-	look_out(150);
-	boxit();
-	refresh();
-	look_out(150);
-	seas();
-	refresh();
-	look_out(150);
-	greet();
-	refresh();
-	look_out(150);
-	fromwho();
-	refresh();
-	look_out(150);
-	tree();
-	look_out(150);
-	balls();
-	look_out(150);
-	star();
-	look_out(150);
-	strng1();
-	strng2();
-	strng3();
-	strng4();
-	strng5();
-
-	/* set up the windows for our blinking trees */
-	/* **************************************** */
-	/* treescrn3 */
-
-	overlay(treescrn, treescrn3);
-
-	/*balls */
-	MvWAddCh(treescrn3, 4, 18, ' ');
-	MvWAddCh(treescrn3, 7, 6, ' ');
-	MvWAddCh(treescrn3, 8, 19, ' ');
-	MvWAddCh(treescrn3, 11, 22, ' ');
-
-	/*star */
-	MvWAddCh(treescrn3, 0, 12, '*');
-
-	/*strng1 */
-	MvWAddCh(treescrn3, 3, 11, ' ');
-
-	/*strng2 */
-	MvWAddCh(treescrn3, 5, 13, ' ');
-	MvWAddCh(treescrn3, 6, 10, ' ');
-
-	/*strng3 */
-	MvWAddCh(treescrn3, 7, 16, ' ');
-	MvWAddCh(treescrn3, 7, 14, ' ');
-
-	/*strng4 */
-	MvWAddCh(treescrn3, 10, 13, ' ');
-	MvWAddCh(treescrn3, 10, 10, ' ');
-	MvWAddCh(treescrn3, 11, 8, ' ');
-
-	/*strng5 */
-	MvWAddCh(treescrn3, 11, 18, ' ');
-	MvWAddCh(treescrn3, 12, 13, ' ');
-
-	/* treescrn4 */
-
-	overlay(treescrn, treescrn4);
-
-	/*balls */
-	MvWAddCh(treescrn4, 3, 9, ' ');
-	MvWAddCh(treescrn4, 4, 16, ' ');
-	MvWAddCh(treescrn4, 7, 6, ' ');
-	MvWAddCh(treescrn4, 8, 19, ' ');
-	MvWAddCh(treescrn4, 11, 2, ' ');
-	MvWAddCh(treescrn4, 12, 23, ' ');
-
-	/*star */
-	(void) wstandout(treescrn4);
-	MvWAddCh(treescrn4, 0, 12, '*');
-	(void) wstandend(treescrn4);
-
-	/*strng1 */
-	MvWAddCh(treescrn4, 3, 13, ' ');
-
-	/*strng2 */
-
-	/*strng3 */
-	MvWAddCh(treescrn4, 7, 15, ' ');
-	MvWAddCh(treescrn4, 8, 11, ' ');
-
-	/*strng4 */
-	MvWAddCh(treescrn4, 9, 16, ' ');
-	MvWAddCh(treescrn4, 10, 12, ' ');
-	MvWAddCh(treescrn4, 11, 8, ' ');
-
-	/*strng5 */
-	MvWAddCh(treescrn4, 11, 18, ' ');
-	MvWAddCh(treescrn4, 12, 14, ' ');
-
-	/* treescrn5 */
-
-	overlay(treescrn, treescrn5);
-
-	/*balls */
-	MvWAddCh(treescrn5, 3, 15, ' ');
-	MvWAddCh(treescrn5, 10, 20, ' ');
-	MvWAddCh(treescrn5, 12, 1, ' ');
-
-	/*star */
-	MvWAddCh(treescrn5, 0, 12, '*');
-
-	/*strng1 */
-	MvWAddCh(treescrn5, 3, 11, ' ');
-
-	/*strng2 */
-	MvWAddCh(treescrn5, 5, 12, ' ');
-
-	/*strng3 */
-	MvWAddCh(treescrn5, 7, 14, ' ');
-	MvWAddCh(treescrn5, 8, 10, ' ');
-
-	/*strng4 */
-	MvWAddCh(treescrn5, 9, 15, ' ');
-	MvWAddCh(treescrn5, 10, 11, ' ');
-	MvWAddCh(treescrn5, 11, 7, ' ');
-
-	/*strng5 */
-	MvWAddCh(treescrn5, 11, 17, ' ');
-	MvWAddCh(treescrn5, 12, 13, ' ');
-
-	/* treescrn6 */
-
-	overlay(treescrn, treescrn6);
-
-	/*balls */
-	MvWAddCh(treescrn6, 6, 7, ' ');
-	MvWAddCh(treescrn6, 7, 18, ' ');
-	MvWAddCh(treescrn6, 10, 4, ' ');
-	MvWAddCh(treescrn6, 11, 23, ' ');
-
-	/*star */
-	(void) wstandout(treescrn6);
-	MvWAddCh(treescrn6, 0, 12, '*');
-	(void) wstandend(treescrn6);
-
-	/*strng1 */
-
-	/*strng2 */
-	MvWAddCh(treescrn6, 5, 11, ' ');
-
-	/*strng3 */
-	MvWAddCh(treescrn6, 7, 13, ' ');
-	MvWAddCh(treescrn6, 8, 9, ' ');
-
-	/*strng4 */
-	MvWAddCh(treescrn6, 9, 14, ' ');
-	MvWAddCh(treescrn6, 10, 10, ' ');
-	MvWAddCh(treescrn6, 11, 6, ' ');
-
-	/*strng5 */
-	MvWAddCh(treescrn6, 11, 16, ' ');
-	MvWAddCh(treescrn6, 12, 12, ' ');
-
-	/* treescrn7 */
-
-	overlay(treescrn, treescrn7);
-
-	/*balls */
-	MvWAddCh(treescrn7, 3, 15, ' ');
-	MvWAddCh(treescrn7, 6, 7, ' ');
-	MvWAddCh(treescrn7, 7, 18, ' ');
-	MvWAddCh(treescrn7, 10, 4, ' ');
-	MvWAddCh(treescrn7, 11, 22, ' ');
-
-	/*star */
-	MvWAddCh(treescrn7, 0, 12, '*');
-
-	/*strng1 */
-	MvWAddCh(treescrn7, 3, 12, ' ');
-
-	/*strng2 */
-	MvWAddCh(treescrn7, 5, 13, ' ');
-	MvWAddCh(treescrn7, 6, 9, ' ');
-
-	/*strng3 */
-	MvWAddCh(treescrn7, 7, 15, ' ');
-	MvWAddCh(treescrn7, 8, 11, ' ');
-
-	/*strng4 */
-	MvWAddCh(treescrn7, 9, 16, ' ');
-	MvWAddCh(treescrn7, 10, 12, ' ');
-	MvWAddCh(treescrn7, 11, 8, ' ');
-
-	/*strng5 */
-	MvWAddCh(treescrn7, 11, 18, ' ');
-	MvWAddCh(treescrn7, 12, 14, ' ');
-
-	look_out(150);
-	reindeer();
-
-	touchwin(w_holiday);
-	wrefresh(w_holiday);
-	wrefresh(w_del_msg);
-
-	look_out(500);
-	for (loopy = 0; loopy < 100; loopy++) {
-	    blinkit();
-	}
-
-#ifdef NOLOOP
-	done(0);
-#endif
-    }
-    /*NOTREACHED */
-}
-
 static int
 boxit(void)
 {
@@ -958,37 +454,31 @@
     switch (cycle) {
     case 0:
 	overlay(treescrn3, treescrn8);
-	wrefresh(treescrn8);
-	wrefresh(w_del_msg);
 	break;
     case 1:
 	overlay(treescrn4, treescrn8);
-	wrefresh(treescrn8);
-	wrefresh(w_del_msg);
 	break;
     case 2:
 	overlay(treescrn5, treescrn8);
-	wrefresh(treescrn8);
-	wrefresh(w_del_msg);
 	break;
     case 3:
 	overlay(treescrn6, treescrn8);
-	wrefresh(treescrn8);
-	wrefresh(w_del_msg);
 	break;
     case 4:
 	overlay(treescrn7, treescrn8);
-	wrefresh(treescrn8);
-	wrefresh(w_del_msg);
 	break;
     }
     touchwin(treescrn8);
+    wrefresh(treescrn8);
+    wrefresh(w_del_msg);
+    look_out(50);
 
     /*ALL ON************************************************** */
 
     overlay(treescrn, treescrn8);
     wrefresh(treescrn8);
     wrefresh(w_del_msg);
+    look_out(50);
 
     ++cycle;
     return (0);
@@ -1010,9 +500,6 @@
     y_pos = 0;
 
     for (x_pos = 70; x_pos > 62; x_pos--) {
-	if (x_pos < 62) {
-	    y_pos = 1;
-	}
 	for (looper = 0; looper < 4; looper++) {
 	    MvWAddCh(dotdeer0, y_pos, x_pos, (chtype) '.');
 	    wrefresh(dotdeer0);
@@ -1146,12 +633,9 @@
 static void
 done(int sig GCC_UNUSED)
 {
-    CATCHALL(done);
-
     move(LINES - 1, 0);
     refresh();
-    endwin();
-    curs_set(1);
+    stop_curses();
 
 #if NO_LEAKS
     if (my_pairs != 0)
@@ -1160,3 +644,535 @@
 
     ExitProgram(EXIT_SUCCESS);
 }
+
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: xmas [options]"
+	,""
+	,USAGE_COMMON
+	,"Options:"
+#if HAVE_USE_DEFAULT_COLORS
+	," -d       invoke use_default_colors"
+#endif
+	," -q       execute once, then quit"
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
+int
+main(int argc, char *argv[])
+{
+    int ch;
+    int loopy;
+#if HAVE_USE_DEFAULT_COLORS
+    bool opt_d = FALSE;
+#endif
+    bool opt_q = FALSE;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON "dq")) != -1) {
+	switch (ch) {
+#if HAVE_USE_DEFAULT_COLORS
+	case 'd':
+	    opt_d = TRUE;
+	    break;
+#endif
+	case 'q':
+	    opt_q = TRUE;
+	    break;
+	case OPTS_VERSION:
+	    show_version(argv);
+	    ExitProgram(EXIT_SUCCESS);
+	default:
+	    usage(ch == OPTS_USAGE);
+	    /* NOTREACHED */
+	}
+    }
+
+    setlocale(LC_ALL, "");
+
+    InitAndCatch(initscr(), done);
+    noecho();
+    nonl();
+    refresh();
+
+    if (has_colors()) {
+	start_color();
+#if HAVE_USE_DEFAULT_COLORS
+	if (opt_d && (use_default_colors() == OK))
+	    my_bg = -1;
+#endif
+    }
+    curs_set(0);
+
+    if ((treescrn = newwin(16, 27, 3, 53)) == 0 ||
+	(treescrn2 = newwin(16, 27, 3, 53)) == 0 ||
+	(treescrn3 = newwin(16, 27, 3, 53)) == 0 ||
+	(treescrn4 = newwin(16, 27, 3, 53)) == 0 ||
+	(treescrn5 = newwin(16, 27, 3, 53)) == 0 ||
+	(treescrn6 = newwin(16, 27, 3, 53)) == 0 ||
+	(treescrn7 = newwin(16, 27, 3, 53)) == 0 ||
+	(treescrn8 = newwin(16, 27, 3, 53)) == 0 ||
+
+	(dotdeer0 = newwin(3, 71, 0, 8)) == 0 ||
+
+	(stardeer0 = newwin(4, 56, 0, 8)) == 0 ||
+
+	(lildeer0 = newwin(7, 53, 0, 8)) == 0 ||
+	(lildeer1 = newwin(2, 4, 0, 0)) == 0 ||
+	(lildeer2 = newwin(2, 4, 0, 0)) == 0 ||
+	(lildeer3 = newwin(2, 4, 0, 0)) == 0 ||
+
+	(middeer0 = newwin(15, 42, 0, 8)) == 0 ||
+	(middeer1 = newwin(3, 7, 0, 0)) == 0 ||
+	(middeer2 = newwin(3, 7, 0, 0)) == 0 ||
+	(middeer3 = newwin(3, 7, 0, 0)) == 0 ||
+
+	(bigdeer0 = newwin(10, 23, 0, 0)) == 0 ||
+	(bigdeer1 = newwin(10, 23, 0, 0)) == 0 ||
+	(bigdeer2 = newwin(10, 23, 0, 0)) == 0 ||
+	(bigdeer3 = newwin(10, 23, 0, 0)) == 0 ||
+	(bigdeer4 = newwin(10, 23, 0, 0)) == 0 ||
+
+	(lookdeer0 = newwin(10, 25, 0, 0)) == 0 ||
+	(lookdeer1 = newwin(10, 25, 0, 0)) == 0 ||
+	(lookdeer2 = newwin(10, 25, 0, 0)) == 0 ||
+	(lookdeer3 = newwin(10, 25, 0, 0)) == 0 ||
+	(lookdeer4 = newwin(10, 25, 0, 0)) == 0 ||
+
+	(w_holiday = newwin(1, 26, 3, 27)) == 0 ||
+
+	(w_del_msg = newwin(1, 19, 23, 60)) == 0) {
+	stop_curses();
+	fprintf(stderr, "Cannot create windows - screen too small\n");
+	ExitProgram(EXIT_FAILURE);
+    }
+
+    MvWAddStr(w_del_msg, 0, 0, "Hit any key to quit");
+
+    MvWAddStr(w_holiday, 0, 0, "H A P P Y  H O L I D A Y S");
+
+    /* set up the windows for our various reindeer */
+
+    /* lildeer1 */
+    MvWAddCh(lildeer1, 0, 0, (chtype) 'V');
+    MvWAddCh(lildeer1, 1, 0, (chtype) '@');
+    MvWAddCh(lildeer1, 1, 1, (chtype) '<');
+    MvWAddCh(lildeer1, 1, 2, (chtype) '>');
+    MvWAddCh(lildeer1, 1, 3, (chtype) '~');
+
+    /* lildeer2 */
+    MvWAddCh(lildeer2, 0, 0, (chtype) 'V');
+    MvWAddCh(lildeer2, 1, 0, (chtype) '@');
+    MvWAddCh(lildeer2, 1, 1, (chtype) '|');
+    MvWAddCh(lildeer2, 1, 2, (chtype) '|');
+    MvWAddCh(lildeer2, 1, 3, (chtype) '~');
+
+    /* lildeer3 */
+    MvWAddCh(lildeer3, 0, 0, (chtype) 'V');
+    MvWAddCh(lildeer3, 1, 0, (chtype) '@');
+    MvWAddCh(lildeer3, 1, 1, (chtype) '>');
+    MvWAddCh(lildeer3, 1, 2, (chtype) '<');
+    MvWAddCh(lildeer2, 1, 3, (chtype) '~');
+
+    /* middeer1 */
+    MvWAddCh(middeer1, 0, 2, (chtype) 'y');
+    MvWAddCh(middeer1, 0, 3, (chtype) 'y');
+    MvWAddCh(middeer1, 1, 2, (chtype) '0');
+    MvWAddCh(middeer1, 1, 3, (chtype) '(');
+    MvWAddCh(middeer1, 1, 4, (chtype) '=');
+    MvWAddCh(middeer1, 1, 5, (chtype) ')');
+    MvWAddCh(middeer1, 1, 6, (chtype) '~');
+    MvWAddCh(middeer1, 2, 3, (chtype) '\\');
+    MvWAddCh(middeer1, 2, 4, (chtype) '/');
+
+    /* middeer2 */
+    MvWAddCh(middeer2, 0, 2, (chtype) 'y');
+    MvWAddCh(middeer2, 0, 3, (chtype) 'y');
+    MvWAddCh(middeer2, 1, 2, (chtype) '0');
+    MvWAddCh(middeer2, 1, 3, (chtype) '(');
+    MvWAddCh(middeer2, 1, 4, (chtype) '=');
+    MvWAddCh(middeer2, 1, 5, (chtype) ')');
+    MvWAddCh(middeer2, 1, 6, (chtype) '~');
+    MvWAddCh(middeer2, 2, 3, (chtype) '|');
+    MvWAddCh(middeer2, 2, 5, (chtype) '|');
+
+    /* middeer3 */
+    MvWAddCh(middeer3, 0, 2, (chtype) 'y');
+    MvWAddCh(middeer3, 0, 3, (chtype) 'y');
+    MvWAddCh(middeer3, 1, 2, (chtype) '0');
+    MvWAddCh(middeer3, 1, 3, (chtype) '(');
+    MvWAddCh(middeer3, 1, 4, (chtype) '=');
+    MvWAddCh(middeer3, 1, 5, (chtype) ')');
+    MvWAddCh(middeer3, 1, 6, (chtype) '~');
+    MvWAddCh(middeer3, 2, 2, (chtype) '/');
+    MvWAddCh(middeer3, 2, 6, (chtype) '\\');
+
+    /* bigdeer1 */
+    MvWAddCh(bigdeer1, 0, 17, (chtype) '\\');
+    MvWAddCh(bigdeer1, 0, 18, (chtype) '/');
+    MvWAddCh(bigdeer1, 0, 20, (chtype) '\\');
+    MvWAddCh(bigdeer1, 0, 21, (chtype) '/');
+    MvWAddCh(bigdeer1, 1, 18, (chtype) '\\');
+    MvWAddCh(bigdeer1, 1, 20, (chtype) '/');
+    MvWAddCh(bigdeer1, 2, 19, (chtype) '|');
+    MvWAddCh(bigdeer1, 2, 20, (chtype) '_');
+    MvWAddCh(bigdeer1, 3, 18, (chtype) '/');
+    MvWAddCh(bigdeer1, 3, 19, (chtype) '^');
+    MvWAddCh(bigdeer1, 3, 20, (chtype) '0');
+    MvWAddCh(bigdeer1, 3, 21, (chtype) '\\');
+    MvWAddCh(bigdeer1, 4, 17, (chtype) '/');
+    MvWAddCh(bigdeer1, 4, 18, (chtype) '/');
+    MvWAddCh(bigdeer1, 4, 19, (chtype) '\\');
+    MvWAddCh(bigdeer1, 4, 22, (chtype) '\\');
+    MvWAddStr(bigdeer1, 5, 7, "^~~~~~~~~//  ~~U");
+    MvWAddStr(bigdeer1, 6, 7, "( \\_____( /");
+    MvWAddStr(bigdeer1, 7, 8, "( )    /");
+    MvWAddStr(bigdeer1, 8, 9, "\\\\   /");
+    MvWAddStr(bigdeer1, 9, 11, "\\>/>");
+
+    /* bigdeer2 */
+    MvWAddCh(bigdeer2, 0, 17, (chtype) '\\');
+    MvWAddCh(bigdeer2, 0, 18, (chtype) '/');
+    MvWAddCh(bigdeer2, 0, 20, (chtype) '\\');
+    MvWAddCh(bigdeer2, 0, 21, (chtype) '/');
+    MvWAddCh(bigdeer2, 1, 18, (chtype) '\\');
+    MvWAddCh(bigdeer2, 1, 20, (chtype) '/');
+    MvWAddCh(bigdeer2, 2, 19, (chtype) '|');
+    MvWAddCh(bigdeer2, 2, 20, (chtype) '_');
+    MvWAddCh(bigdeer2, 3, 18, (chtype) '/');
+    MvWAddCh(bigdeer2, 3, 19, (chtype) '^');
+    MvWAddCh(bigdeer2, 3, 20, (chtype) '0');
+    MvWAddCh(bigdeer2, 3, 21, (chtype) '\\');
+    MvWAddCh(bigdeer2, 4, 17, (chtype) '/');
+    MvWAddCh(bigdeer2, 4, 18, (chtype) '/');
+    MvWAddCh(bigdeer2, 4, 19, (chtype) '\\');
+    MvWAddCh(bigdeer2, 4, 22, (chtype) '\\');
+    MvWAddStr(bigdeer2, 5, 7, "^~~~~~~~~//  ~~U");
+    MvWAddStr(bigdeer2, 6, 7, "(( )____( /");
+    MvWAddStr(bigdeer2, 7, 7, "( /      |");
+    MvWAddStr(bigdeer2, 8, 8, "\\/      |");
+    MvWAddStr(bigdeer2, 9, 9, "|>     |>");
+
+    /* bigdeer3 */
+    MvWAddCh(bigdeer3, 0, 17, (chtype) '\\');
+    MvWAddCh(bigdeer3, 0, 18, (chtype) '/');
+    MvWAddCh(bigdeer3, 0, 20, (chtype) '\\');
+    MvWAddCh(bigdeer3, 0, 21, (chtype) '/');
+    MvWAddCh(bigdeer3, 1, 18, (chtype) '\\');
+    MvWAddCh(bigdeer3, 1, 20, (chtype) '/');
+    MvWAddCh(bigdeer3, 2, 19, (chtype) '|');
+    MvWAddCh(bigdeer3, 2, 20, (chtype) '_');
+    MvWAddCh(bigdeer3, 3, 18, (chtype) '/');
+    MvWAddCh(bigdeer3, 3, 19, (chtype) '^');
+    MvWAddCh(bigdeer3, 3, 20, (chtype) '0');
+    MvWAddCh(bigdeer3, 3, 21, (chtype) '\\');
+    MvWAddCh(bigdeer3, 4, 17, (chtype) '/');
+    MvWAddCh(bigdeer3, 4, 18, (chtype) '/');
+    MvWAddCh(bigdeer3, 4, 19, (chtype) '\\');
+    MvWAddCh(bigdeer3, 4, 22, (chtype) '\\');
+    MvWAddStr(bigdeer3, 5, 7, "^~~~~~~~~//  ~~U");
+    MvWAddStr(bigdeer3, 6, 6, "( ()_____( /");
+    MvWAddStr(bigdeer3, 7, 6, "/ /       /");
+    MvWAddStr(bigdeer3, 8, 5, "|/          \\");
+    MvWAddStr(bigdeer3, 9, 5, "/>           \\>");
+
+    /* bigdeer4 */
+    MvWAddCh(bigdeer4, 0, 17, (chtype) '\\');
+    MvWAddCh(bigdeer4, 0, 18, (chtype) '/');
+    MvWAddCh(bigdeer4, 0, 20, (chtype) '\\');
+    MvWAddCh(bigdeer4, 0, 21, (chtype) '/');
+    MvWAddCh(bigdeer4, 1, 18, (chtype) '\\');
+    MvWAddCh(bigdeer4, 1, 20, (chtype) '/');
+    MvWAddCh(bigdeer4, 2, 19, (chtype) '|');
+    MvWAddCh(bigdeer4, 2, 20, (chtype) '_');
+    MvWAddCh(bigdeer4, 3, 18, (chtype) '/');
+    MvWAddCh(bigdeer4, 3, 19, (chtype) '^');
+    MvWAddCh(bigdeer4, 3, 20, (chtype) '0');
+    MvWAddCh(bigdeer4, 3, 21, (chtype) '\\');
+    MvWAddCh(bigdeer4, 4, 17, (chtype) '/');
+    MvWAddCh(bigdeer4, 4, 18, (chtype) '/');
+    MvWAddCh(bigdeer4, 4, 19, (chtype) '\\');
+    MvWAddCh(bigdeer4, 4, 22, (chtype) '\\');
+    MvWAddStr(bigdeer4, 5, 7, "^~~~~~~~~//  ~~U");
+    MvWAddStr(bigdeer4, 6, 6, "( )______( /");
+    MvWAddStr(bigdeer4, 7, 5, "(/          \\");
+    MvWAddStr(bigdeer4, 8, 0, "v___=             ----^");
+
+    /* lookdeer1 */
+    MvWAddStr(lookdeer1, 0, 16, "\\/     \\/");
+    MvWAddStr(lookdeer1, 1, 17, "\\Y/ \\Y/");
+    MvWAddStr(lookdeer1, 2, 19, "\\=/");
+    MvWAddStr(lookdeer1, 3, 17, "^\\o o/^");
+    MvWAddStr(lookdeer1, 4, 17, "//( )");
+    MvWAddStr(lookdeer1, 5, 7, "^~~~~~~~~// \\O/");
+    MvWAddStr(lookdeer1, 6, 7, "( \\_____( /");
+    MvWAddStr(lookdeer1, 7, 8, "( )    /");
+    MvWAddStr(lookdeer1, 8, 9, "\\\\   /");
+    MvWAddStr(lookdeer1, 9, 11, "\\>/>");
+
+    /* lookdeer2 */
+    MvWAddStr(lookdeer2, 0, 16, "\\/     \\/");
+    MvWAddStr(lookdeer2, 1, 17, "\\Y/ \\Y/");
+    MvWAddStr(lookdeer2, 2, 19, "\\=/");
+    MvWAddStr(lookdeer2, 3, 17, "^\\o o/^");
+    MvWAddStr(lookdeer2, 4, 17, "//( )");
+    MvWAddStr(lookdeer2, 5, 7, "^~~~~~~~~// \\O/");
+    MvWAddStr(lookdeer2, 6, 7, "(( )____( /");
+    MvWAddStr(lookdeer2, 7, 7, "( /      |");
+    MvWAddStr(lookdeer2, 8, 8, "\\/      |");
+    MvWAddStr(lookdeer2, 9, 9, "|>     |>");
+
+    /* lookdeer3 */
+    MvWAddStr(lookdeer3, 0, 16, "\\/     \\/");
+    MvWAddStr(lookdeer3, 1, 17, "\\Y/ \\Y/");
+    MvWAddStr(lookdeer3, 2, 19, "\\=/");
+    MvWAddStr(lookdeer3, 3, 17, "^\\o o/^");
+    MvWAddStr(lookdeer3, 4, 17, "//( )");
+    MvWAddStr(lookdeer3, 5, 7, "^~~~~~~~~// \\O/");
+    MvWAddStr(lookdeer3, 6, 6, "( ()_____( /");
+    MvWAddStr(lookdeer3, 7, 6, "/ /       /");
+    MvWAddStr(lookdeer3, 8, 5, "|/          \\");
+    MvWAddStr(lookdeer3, 9, 5, "/>           \\>");
+
+    /* lookdeer4 */
+    MvWAddStr(lookdeer4, 0, 16, "\\/     \\/");
+    MvWAddStr(lookdeer4, 1, 17, "\\Y/ \\Y/");
+    MvWAddStr(lookdeer4, 2, 19, "\\=/");
+    MvWAddStr(lookdeer4, 3, 17, "^\\o o/^");
+    MvWAddStr(lookdeer4, 4, 17, "//( )");
+    MvWAddStr(lookdeer4, 5, 7, "^~~~~~~~~// \\O/");
+    MvWAddStr(lookdeer4, 6, 6, "( )______( /");
+    MvWAddStr(lookdeer4, 7, 5, "(/          \\");
+    MvWAddStr(lookdeer4, 8, 0, "v___=             ----^");
+
+	/***********************************************/
+    cbreak();
+    nodelay(stdscr, TRUE);
+    do {
+	clear();
+	werase(treescrn);
+	touchwin(w_del_msg);
+	touchwin(treescrn);
+	werase(treescrn2);
+	touchwin(treescrn2);
+	werase(treescrn8);
+	touchwin(treescrn8);
+	refresh();
+	look_out(150);
+	boxit();
+	refresh();
+	look_out(150);
+	seas();
+	refresh();
+	look_out(150);
+	greet();
+	refresh();
+	look_out(150);
+	fromwho();
+	refresh();
+	look_out(150);
+	tree();
+	look_out(150);
+	balls();
+	look_out(150);
+	star();
+	look_out(150);
+	strng1();
+	strng2();
+	strng3();
+	strng4();
+	strng5();
+
+	/* set up the windows for our blinking trees */
+	/* **************************************** */
+	/* treescrn3 */
+
+	overlay(treescrn, treescrn3);
+
+	/*balls */
+	MvWAddCh(treescrn3, 4, 18, ' ');
+	MvWAddCh(treescrn3, 7, 6, ' ');
+	MvWAddCh(treescrn3, 8, 19, ' ');
+	MvWAddCh(treescrn3, 11, 22, ' ');
+
+	/*star */
+	MvWAddCh(treescrn3, 0, 12, '*');
+
+	/*strng1 */
+	MvWAddCh(treescrn3, 3, 11, ' ');
+
+	/*strng2 */
+	MvWAddCh(treescrn3, 5, 13, ' ');
+	MvWAddCh(treescrn3, 6, 10, ' ');
+
+	/*strng3 */
+	MvWAddCh(treescrn3, 7, 16, ' ');
+	MvWAddCh(treescrn3, 7, 14, ' ');
+
+	/*strng4 */
+	MvWAddCh(treescrn3, 10, 13, ' ');
+	MvWAddCh(treescrn3, 10, 10, ' ');
+	MvWAddCh(treescrn3, 11, 8, ' ');
+
+	/*strng5 */
+	MvWAddCh(treescrn3, 11, 18, ' ');
+	MvWAddCh(treescrn3, 12, 13, ' ');
+
+	/* treescrn4 */
+
+	overlay(treescrn, treescrn4);
+
+	/*balls */
+	MvWAddCh(treescrn4, 3, 9, ' ');
+	MvWAddCh(treescrn4, 4, 16, ' ');
+	MvWAddCh(treescrn4, 7, 6, ' ');
+	MvWAddCh(treescrn4, 8, 19, ' ');
+	MvWAddCh(treescrn4, 11, 2, ' ');
+	MvWAddCh(treescrn4, 12, 23, ' ');
+
+	/*star */
+	(void) wstandout(treescrn4);
+	MvWAddCh(treescrn4, 0, 12, '*');
+	(void) wstandend(treescrn4);
+
+	/*strng1 */
+	MvWAddCh(treescrn4, 3, 13, ' ');
+
+	/*strng2 */
+
+	/*strng3 */
+	MvWAddCh(treescrn4, 7, 15, ' ');
+	MvWAddCh(treescrn4, 8, 11, ' ');
+
+	/*strng4 */
+	MvWAddCh(treescrn4, 9, 16, ' ');
+	MvWAddCh(treescrn4, 10, 12, ' ');
+	MvWAddCh(treescrn4, 11, 8, ' ');
+
+	/*strng5 */
+	MvWAddCh(treescrn4, 11, 18, ' ');
+	MvWAddCh(treescrn4, 12, 14, ' ');
+
+	/* treescrn5 */
+
+	overlay(treescrn, treescrn5);
+
+	/*balls */
+	MvWAddCh(treescrn5, 3, 15, ' ');
+	MvWAddCh(treescrn5, 10, 20, ' ');
+	MvWAddCh(treescrn5, 12, 1, ' ');
+
+	/*star */
+	MvWAddCh(treescrn5, 0, 12, '*');
+
+	/*strng1 */
+	MvWAddCh(treescrn5, 3, 11, ' ');
+
+	/*strng2 */
+	MvWAddCh(treescrn5, 5, 12, ' ');
+
+	/*strng3 */
+	MvWAddCh(treescrn5, 7, 14, ' ');
+	MvWAddCh(treescrn5, 8, 10, ' ');
+
+	/*strng4 */
+	MvWAddCh(treescrn5, 9, 15, ' ');
+	MvWAddCh(treescrn5, 10, 11, ' ');
+	MvWAddCh(treescrn5, 11, 7, ' ');
+
+	/*strng5 */
+	MvWAddCh(treescrn5, 11, 17, ' ');
+	MvWAddCh(treescrn5, 12, 13, ' ');
+
+	/* treescrn6 */
+
+	overlay(treescrn, treescrn6);
+
+	/*balls */
+	MvWAddCh(treescrn6, 6, 7, ' ');
+	MvWAddCh(treescrn6, 7, 18, ' ');
+	MvWAddCh(treescrn6, 10, 4, ' ');
+	MvWAddCh(treescrn6, 11, 23, ' ');
+
+	/*star */
+	(void) wstandout(treescrn6);
+	MvWAddCh(treescrn6, 0, 12, '*');
+	(void) wstandend(treescrn6);
+
+	/*strng1 */
+
+	/*strng2 */
+	MvWAddCh(treescrn6, 5, 11, ' ');
+
+	/*strng3 */
+	MvWAddCh(treescrn6, 7, 13, ' ');
+	MvWAddCh(treescrn6, 8, 9, ' ');
+
+	/*strng4 */
+	MvWAddCh(treescrn6, 9, 14, ' ');
+	MvWAddCh(treescrn6, 10, 10, ' ');
+	MvWAddCh(treescrn6, 11, 6, ' ');
+
+	/*strng5 */
+	MvWAddCh(treescrn6, 11, 16, ' ');
+	MvWAddCh(treescrn6, 12, 12, ' ');
+
+	/* treescrn7 */
+
+	overlay(treescrn, treescrn7);
+
+	/*balls */
+	MvWAddCh(treescrn7, 3, 15, ' ');
+	MvWAddCh(treescrn7, 6, 7, ' ');
+	MvWAddCh(treescrn7, 7, 18, ' ');
+	MvWAddCh(treescrn7, 10, 4, ' ');
+	MvWAddCh(treescrn7, 11, 22, ' ');
+
+	/*star */
+	MvWAddCh(treescrn7, 0, 12, '*');
+
+	/*strng1 */
+	MvWAddCh(treescrn7, 3, 12, ' ');
+
+	/*strng2 */
+	MvWAddCh(treescrn7, 5, 13, ' ');
+	MvWAddCh(treescrn7, 6, 9, ' ');
+
+	/*strng3 */
+	MvWAddCh(treescrn7, 7, 15, ' ');
+	MvWAddCh(treescrn7, 8, 11, ' ');
+
+	/*strng4 */
+	MvWAddCh(treescrn7, 9, 16, ' ');
+	MvWAddCh(treescrn7, 10, 12, ' ');
+	MvWAddCh(treescrn7, 11, 8, ' ');
+
+	/*strng5 */
+	MvWAddCh(treescrn7, 11, 18, ' ');
+	MvWAddCh(treescrn7, 12, 14, ' ');
+
+	look_out(150);
+	reindeer();
+
+	touchwin(w_holiday);
+	wrefresh(w_holiday);
+	wrefresh(w_del_msg);
+
+	look_out(500);
+	for (loopy = 0; loopy < 100; loopy++) {
+	    blinkit();
+	}
+    } while (!opt_q);
+    done(0);
+}
diff --git a/test/xterm-16color.dat b/test/xterm-16color.dat
index 6d47d93..075c44b 100644
--- a/test/xterm-16color.dat
+++ b/test/xterm-16color.dat
@@ -1,5 +1,6 @@
 ##############################################################################
-# Copyright (c) 2004,2006 Free Software Foundation, Inc.                     #
+# Copyright 2020,2021 Thomas E. Dickey                                       #
+# Copyright 2004-2006,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 "Software"), #
@@ -25,21 +26,21 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: xterm-16color.dat,v 1.2 2006/04/22 21:40:00 tom Exp $
-# This illustrates the predefined colors for XFree86 xterm's "xterm-16color". 
+# $Id: xterm-16color.dat,v 1.5 2021/06/17 21:20:30 tom Exp $
+# This illustrates the predefined colors for XFree86 xterm's "xterm-16color".
 # If you set $TERM to "xterm-88color" (and have xterm compiled to support the
 # 88-color or 256-color feature), you can use the ncurses 'd' screen to
 # manipulate the colors shown in the screen.  The 'd' screen is limited to
 # the first 16 colors, and xterm happens to use the same first 16 colors in
 # the extended color models that support initc.
 #
-# The colors shown are for xterm patch #189.
+# The colors shown are for xterm patch #192.
 scale:255
 0:	  0   0   0		black
 1:	205   0	  0		red3
 2:	  0 205	  0		green3
 3:	205 205	  0		yellow3
-4:	 30 144 255		DodgerBlue1
+4:	  0   0 238		blue2
 5:	205   0 205		magenta3
 6:	  0 205 205		cyan3
 7:	229 229 229 		gray90
@@ -47,7 +48,7 @@
 9:	255   0   0		red
 10:	  0 255   0		green
 11:	255 255   0		yellow
-12:	 99 184 255		SteelBlue1
+12:	 92  92 255		customblue
 13:	255   0 255		magenta
 14:	  0 255 255		cyan
 15:	255 255 255		white
diff --git a/test/xterm-256color.dat b/test/xterm-256color.dat
index 3dcaabd..28f518e 100644
--- a/test/xterm-256color.dat
+++ b/test/xterm-256color.dat
@@ -1,5 +1,6 @@
 ##############################################################################
-# Copyright (c) 2009 Free Software Foundation, Inc.                          #
+# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 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 "Software"), #
@@ -25,7 +26,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: xterm-256color.dat,v 1.1 2009/10/30 22:33:40 tom Exp $
+# $Id: xterm-256color.dat,v 1.3 2020/02/08 21:38:22 tom Exp $
 # This illustrates the predefined colors for xterm's "xterm-256color" feature.
 # If you set $TERM to "xterm-256color" (and have xterm compiled to support the
 # 256-color feature), you can use the ncurses 'd' screen to
@@ -33,13 +34,13 @@
 # the first 16 colors, and xterm happens to use the same first 16 colors in
 # the extended color models that support initc.
 #
-# The colors shown are for xterm patch #189.
+# The colors shown are for xterm patch #192.
 scale:255
 0:	  0   0   0		black
 1:	205   0	  0		red3
 2:	  0 205	  0		green3
 3:	205 205	  0		yellow3
-4:	 30 144 255		DodgerBlue1
+4:	  0   0 238		blue2
 5:	205   0 205		magenta3
 6:	  0 205 205		cyan3
 7:	229 229 229 		gray90
@@ -47,7 +48,7 @@
 9:	255   0   0		red
 10:	  0 255   0		green
 11:	255 255   0		yellow
-12:	 99 184 255		SteelBlue1
+12:	 92  92 255		customblue
 13:	255   0 255		magenta
 14:	  0 255 255		cyan
 15:	255 255 255		white
diff --git a/test/xterm-88color.dat b/test/xterm-88color.dat
index 95a753c..48ee18b 100644
--- a/test/xterm-88color.dat
+++ b/test/xterm-88color.dat
@@ -1,5 +1,6 @@
 ##############################################################################
-# Copyright (c) 2005-2006,2009 Free Software Foundation, Inc.                #
+# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2005-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 "Software"), #
@@ -25,7 +26,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: xterm-88color.dat,v 1.3 2009/10/30 22:33:56 tom Exp $
+# $Id: xterm-88color.dat,v 1.5 2020/02/08 21:38:22 tom Exp $
 # This illustrates the predefined colors for xterm's "xterm-88color" feature.
 # If you set $TERM to "xterm-88color" (and have xterm compiled to support the
 # 88-color or 256-color feature), you can use the ncurses 'd' screen to
@@ -33,13 +34,13 @@
 # the first 16 colors, and xterm happens to use the same first 16 colors in
 # the extended color models that support initc.
 #
-# The colors shown are for xterm patch #189.
+# The colors shown are for xterm patch #192.
 scale:255
 0:	  0   0   0		black
 1:	205   0	  0		red3
 2:	  0 205	  0		green3
 3:	205 205	  0		yellow3
-4:	 30 144 255		DodgerBlue1
+4:	  0   0 238		blue2
 5:	205   0 205		magenta3
 6:	  0 205 205		cyan3
 7:	229 229 229 		gray90
@@ -47,7 +48,7 @@
 9:	255   0   0		red
 10:	  0 255   0		green
 11:	255 255   0		yellow
-12:	 99 184 255		SteelBlue1
+12:	 92  92 255		customblue
 13:	255   0 255		magenta
 14:	  0 255 255		cyan
 15:	255 255 255		white
diff --git a/test/xterm-color_48x48.xpm b/test/xterm-color_48x48.xpm
new file mode 100644
index 0000000..d8a501f
--- /dev/null
+++ b/test/xterm-color_48x48.xpm
@@ -0,0 +1,61 @@
+/* XPM */
+static char * xterm_color_48x48_xpm[] = {
+"48 48 10 1",
+".	c None",
+" 	c #555500",
+"+	c #000000",
+"@	c #FFFFFF",
+"#	c #FF0000",
+"$	c #070700",
+"%	c #0B0B00",
+"&	c #FF8400",
+"*	c #49FF00",
+"=	c #60B7FF",
+"................................................",
+"......++++++++++++++++++++++++++++++++++........",
+".....+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@++......",
+".....+@@@++++++++++++++++++++++++++++@@@+@+.....",
+".....+@@++++++++++++++++++++++++++++++@@+@@+....",
+".....+@++++++++++++++++++++++++++++++++@+@@@+...",
+".....+@++###++++###++++++++++++++++++++@+@@@@+..",
+".....+@+++##++++##+++++++++++++++++++++@+@@@@+..",
+".....+@++++##++##++++++++++++++++++++++@+@@@@+..",
+".....+@++++##++##++++++++++++++++++++++@+@@@@+..",
+".....+@+++++####+++++++++++++++++++++++@+@@@@+..",
+".....+@+++++####+++++++++++++++++++++++@+@@@@+..",
+".....+@++++++##++++++++++++++++++++++++@+@@@@+..",
+".....+@+++++####+++++++++++++++++++++++@+@@@@+..",
+".....+@+++++####+++++++++++++++++++++++@+@@@@+..",
+".....+@++++##++##++++++++++++++++++++++@+@@@@+..",
+".....+@++++##++##++++++++++++++++++++++@+@@@@+..",
+".....+@+++##++++##+++++++++++++++++++++@+@@@@+..",
+".....+@++###++++###++++++++++++++++++++@+@@@@+..",
+".....+@++++++++++++++++++++++++++++++++@+@@@@+..",
+".....+@$+++++++++++++++++++++++++++++++@+@@@@+..",
+".....+@%@@@@@@@+&&&&&++****+++==+++==++@+@@@@+..",
+".....+@++++@++++&++++++*+++*++==+++==++@+@@@@+..",
+".....+@++++@++++&++++++*+++*++=+=+=+=++@+@@@@+..",
+".....+@++++@++++&&&&+++****+++=+=+=+=++@+@@@@+..",
+".....+@++++@++++&++++++*+*++++=++=++=++@+@@@+...",
+".....+@++++@++++&++++++*++*+++=++=++=++@+@@@+...",
+".....+@++++@++++&&&&&++*+++*++=+++++=++@+@@+....",
+".....+@++++++++++++++++++++++++++++++++@+@@+....",
+".....+@++++++++++++++++++++++++++++++++@+@+.....",
+".....+@@++++++++++++++++++++++++++++++@@+@+.....",
+".....+@@@++++++++++++++++++++++++++++@@@++......",
+".....+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@++......",
+"......++++++++++++++++++++++++++++++++++........",
+"................................................",
+"................................................",
+"......++++++++++++++++++++++++++++++++++++......",
+".....+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@++......",
+".....+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@@++......",
+"....+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+@+......",
+"....+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@@+@+......",
+"...+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+@@+......",
+"...+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@@+@@+......",
+"..+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+@@+.......",
+"..+@++@++++++++++++++++++++++++++@++@+@+........",
+".+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+@+.........",
+".+++++++++++++++++++++++++++++++++++++..........",
+"................................................"};