# https://invisible-island.net/archives/xterm/patches/xterm-374.patch.gz
# patch by Thomas E. Dickey <dickey@invisible-island.net>
# created  Tue Oct 11 00:22:50 UTC 2022
# ------------------------------------------------------------------------------
# MANIFEST                 |    4 
# Makefile.in              |    6 
# Tekproc.c                |    6 
# aclocal.m4               |    6 
# button.c                 |   22 +--
# charproc.c               |   63 +++++----
# configure                |  179 ++++++++++++++------------
# configure.in             |    8 -
# ctlseqs.ms               |  103 ++++++++-------
# ctlseqs.txt              |  134 ++++++++++----------
# fontutils.c              |   16 +-
# graphics_sixel.c         |   52 +++++--
# menu.c                   |    4 
# minstall.in              |    8 -
# misc.c                   |  150 ++++++++++------------
# package/debian/changelog |    6 
# package/freebsd/Makefile |    4 
# package/pkgsrc/Makefile  |    2 
# package/xterm.spec       |    4 
# ptydata.c                |   45 +++---
# ptyx.h                   |   11 -
# trace.c                  |   18 +-
# trace.h                  |    6 
# version.h                |    6 
# vms.c                    |    4 
# vms.h                    |    4 
# vttests/256colors2.pl    |   17 +-
# vttests/88colors2.pl     |   17 +-
# vttests/halves.pl        |  224 ++++++++++++++++++---------------
# vttests/insdelln.pl      |  299 +++++++++++++++++++++++++--------------------
# vttests/lrmm-scroll.pl   |   38 ++++-
# vttests/scroll.pl        |  299 +++++++++++++++++++++++++--------------------
# xterm-374/run-tic.in     |  138 ++++++++++++++++++++
# xterm.appdata.xml        |    2 
# xterm.h                  |    8 -
# xterm.log.html           |   45 ++++++
# xterm.man                |   35 +++--
# 37 files changed, 1185 insertions(+), 808 deletions(-)
# ------------------------------------------------------------------------------
# Please remove the following file before applying this patch.
# (You can feed this patch to 'sh' to do so.)

rm -f run-tic.sh
exit

Index: MANIFEST
--- xterm-373+/MANIFEST	2022-03-11 19:51:56.000000000 +0000
+++ xterm-374/MANIFEST	2022-10-06 11:03:41.000000000 +0000
@@ -1,4 +1,4 @@
-MANIFEST for xterm, version xterm-373
+MANIFEST for xterm, version xterm-374
 --------------------------------------------------------------------------------
 MANIFEST                        this file
 256colres.h                     resource-definitions for 256-color mode
@@ -79,7 +79,7 @@
 ptyx.h                          structure-definitions for 'xterm'
 resize.c                        program to compute/modify xterm's window size
 resize.man                      manual page for 'resize'
-run-tic.sh                      run tic, filtering out harmless messages
+run-tic.in                      run tic, filtering out harmless messages (template)
 screen.c                        VT100 screen update functions
 scrollback.c                    manage scrollback (a big FIFO)
 scrollbar.c                     VT100 scrollbar support functions
Index: Makefile.in
--- xterm-373+/Makefile.in	2022-02-21 18:30:44.000000000 +0000
+++ xterm-374/Makefile.in	2022-10-02 21:20:56.000000000 +0000
@@ -1,4 +1,4 @@
-## $XTermId: Makefile.in,v 1.260 2022/02/21 18:30:44 tom Exp $
+## $XTermId: Makefile.in,v 1.261 2022/10/02 21:20:56 tom Exp $
 # -----------------------------------------------------------------------------
 # this file is part of xterm
 #
@@ -423,6 +423,8 @@
 
 @no_ticprog@install-full \
 @no_ticprog@install-ti :: $(TERMINFO_DIR)
+@no_ticprog@	@echo "Installing $(srcdir)/terminfo"
+@no_ticprog@	@$(SHELL) -c "chmod +x $(srcdir)/run-tic.sh"
 @no_ticprog@	@$(SHELL) -c "$(SET_TERMINFO) $(srcdir)/run-tic.sh $(srcdir)/terminfo"
 @no_ticprog@	@echo 'Completed installation of terminfo description.'
 
@@ -566,7 +568,7 @@
 
 distclean :: clean
 	-$(RM) Makefile config.status config.cache config.log xtermcfg.h
-	-$(RM) df-install minstall
+	-$(RM) df-install minstall run-tic.sh
 
 distclean \
 docs-clean ::
Index: Tekproc.c
--- xterm-373+/Tekproc.c	2022-09-25 17:53:18.000000000 +0000
+++ xterm-374/Tekproc.c	2022-10-06 19:41:47.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: Tekproc.c,v 1.248 2022/09/25 17:53:18 tom Exp $ */
+/* $XTermId: Tekproc.c,v 1.249 2022/10/06 19:41:47 tom Exp $ */
 
 /*
  * Copyright 2001-2021,2022 by Thomas E. Dickey
@@ -1335,9 +1335,9 @@
     if (tekscr->gin_terminator == GIN_TERM_EOT)
 	cplot[len++] = '\004';
 #ifdef VMS
-    tt_write(cplot + adj, len - adj);
+    tt_write(cplot + adj, (size_t) (len - adj));
 #else /* VMS */
-    v_write(screen->respond, cplot + adj, (unsigned) (len - adj));
+    v_write(screen->respond, cplot + adj, (size_t) (len - adj));
 #endif /* VMS */
 }
 
Index: aclocal.m4
--- xterm-373+/aclocal.m4	2022-09-11 19:00:29.000000000 +0000
+++ xterm-374/aclocal.m4	2022-10-02 23:57:07.000000000 +0000
@@ -1,4 +1,4 @@
-dnl $XTermId: aclocal.m4,v 1.498 2022/09/11 19:00:29 tom Exp $
+dnl $XTermId: aclocal.m4,v 1.501 2022/10/02 23:57:07 tom Exp $
 dnl
 dnl ---------------------------------------------------------------------------
 dnl
@@ -4738,7 +4738,7 @@
 fi
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_XOPEN_SOURCE version: 60 updated: 2022/09/10 15:16:16
+dnl CF_XOPEN_SOURCE version: 62 updated: 2022/10/02 19:55:56
 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,
@@ -4789,7 +4789,7 @@
 	cf_xopen_source="-D_SGI_SOURCE"
 	cf_XOPEN_SOURCE=
 	;;
-(linux*gnu|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
+(linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
 	CF_GNU_SOURCE($cf_XOPEN_SOURCE)
 	;;
 (minix*)
Index: button.c
--- xterm-373+/button.c	2022-09-11 22:41:48.000000000 +0000
+++ xterm-374/button.c	2022-10-06 16:52:06.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: button.c,v 1.641 2022/09/11 22:41:48 tom Exp $ */
+/* $XTermId: button.c,v 1.642 2022/10/06 16:52:06 tom Exp $ */
 
 /*
  * Copyright 1999-2021,2022 by Thomas E. Dickey
@@ -2332,7 +2332,7 @@
  * Translate ISO-8859-1 or UTF-8 data to NRCS.
  */
 static void
-ToNational(XtermWidget xw, Char *buffer, unsigned *length)
+ToNational(XtermWidget xw, Char *buffer, size_t *length)
 {
     TScreen *screen = TScreenOf(xw);
     DECNRCM_codes gsetL = screen->gsets[screen->curgl];
@@ -2346,7 +2346,7 @@
 	memset(data, 0, sizeof(*data));
 	data->next = data->buffer;
 	data->last = data->buffer + *length;
-	memcpy(data->buffer, buffer, (size_t) *length);
+	memcpy(data->buffer, buffer, *length);
 	p = buffer;
 	while (data->next < data->last) {
 	    unsigned chr, out, gl, gr;
@@ -2365,14 +2365,14 @@
 	    }
 	    *p++ = (Char) ((out < 256) ? out : ' ');
 	}
-	*length = (unsigned) (p - buffer);
+	*length = (size_t) (p - buffer);
 	free(data);
     } else
 #endif
     {
 	Char *p;
 
-	for (p = buffer; (int) (p - buffer) < (int) *length; ++p) {
+	for (p = buffer; (size_t) (p - buffer) < *length; ++p) {
 	    unsigned gl, gr;
 	    unsigned chr = *p;
 	    unsigned out = chr;
@@ -2387,7 +2387,7 @@
 }
 
 static void
-_qWriteSelectionData(XtermWidget xw, Char *lag, unsigned length)
+_qWriteSelectionData(XtermWidget xw, Char *lag, size_t length)
 {
     TScreen *screen = TScreenOf(xw);
 
@@ -2409,7 +2409,9 @@
 	Char buf[64];
 	unsigned x = 0;
 
-	TRACE(("convert to base64 %d:%s\n", length, visibleChars(p, length)));
+	TRACE(("convert to base64 %lu:%s\n",
+	       (unsigned long) length,
+	       visibleChars(p, length)));
 
 	/*
 	 * Handle the case where the selection is from _this_ xterm, which
@@ -2497,7 +2499,7 @@
 
 #if OPT_PASTE64
     if (screen->base64_paste) {
-	_qWriteSelectionData(xw, lag, (unsigned) (end - lag));
+	_qWriteSelectionData(xw, lag, (size_t) (end - lag));
 	base64_flush(screen);
     } else
 #endif
@@ -2507,14 +2509,14 @@
 	    for (cp = line; cp != end; cp++) {
 		if (*cp == '\n') {
 		    *cp = '\r';
-		    _qWriteSelectionData(xw, lag, (unsigned) (cp - lag + 1));
+		    _qWriteSelectionData(xw, lag, (size_t) (cp - lag + 1));
 		    lag = cp + 1;
 		}
 	    }
 	}
 
 	if (lag != end) {
-	    _qWriteSelectionData(xw, lag, (unsigned) (end - lag));
+	    _qWriteSelectionData(xw, lag, (size_t) (end - lag));
 	}
     }
 #ifdef VMS
Index: charproc.c
--- xterm-373+/charproc.c	2022-09-25 17:45:08.000000000 +0000
+++ xterm-374/charproc.c	2022-10-10 15:42:50.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: charproc.c,v 1.1900 2022/09/25 17:45:08 tom Exp $ */
+/* $XTermId: charproc.c,v 1.1906 2022/10/10 15:42:50 tom Exp $ */
 
 /*
  * Copyright 1999-2021,2022 by Thomas E. Dickey
@@ -742,7 +742,7 @@
 #endif
 
 #if OPT_SIXEL_GRAPHICS
-    Bres(XtNsixelScrolling, XtCSixelScrolling, screen.sixel_scrolling, False),
+    Bres(XtNsixelScrolling, XtCSixelScrolling, screen.sixel_scrolling, True),
     Bres(XtNsixelScrollsRight, XtCSixelScrollsRight,
 	 screen.sixel_scrolls_right, False),
 #endif
@@ -2281,7 +2281,7 @@
     SLnone = 0,			/* no status-line timer needed */
     SLclock = 1,		/* status-line updates once/second */
     SLcoords = 2,		/* status-line shows cursor-position */
-    SLwritten = 3		/* status-line may need asynchonous repainting */
+    SLwritten = 3		/* status-line may need asynchronous repainting */
 } SL_MODE;
 
 #define SL_BUFSIZ 80
@@ -5734,7 +5734,7 @@
    or generated by us in response to a query ESC sequence. */
 
 void
-v_write(int f, const Char *data, unsigned len)
+v_write(int f, const Char *data, size_t len)
 {
     TRACE2(("v_write(%d:%s)\n", len, visibleChars(data, len)));
     if (v_bufstr == NULL) {
@@ -5749,10 +5749,11 @@
 	}
     }
     if_DEBUG({
-	fprintf(stderr, "v_write called with %u bytes (%ld left over)",
-		len, (long) (v_bufptr - v_bufstr));
+	fprintf(stderr, "v_write called with %lu bytes (%lu left over)",
+		(unsigned long) len,
+		(unsigned long) (v_bufptr - v_bufstr));
 	if (len > 1 && len < 10)
-	    fprintf(stderr, " \"%.*s\"", len, (const char *) data);
+	    fprintf(stderr, " \"%.*s\"", (int) len, (const char *) data);
 	fprintf(stderr, "\n");
     });
 
@@ -5796,12 +5797,12 @@
 	    if (v_bufend < v_bufptr + len) {
 		/* still won't fit: get more space */
 		/* Don't use XtRealloc because an error is not fatal. */
-		unsigned size = (unsigned) (v_bufptr - v_buffer);
+		size_t size = (size_t) (v_bufptr - v_buffer);
 		v_buffer = TypeRealloc(Char, size + len, v_buffer);
 		if (v_buffer) {
 		    if_DEBUG({
-			fprintf(stderr, "expanded buffer to %u\n",
-				size + len);
+			fprintf(stderr, "expanded buffer to %lu\n",
+				(unsigned long) (size + len));
 		    });
 		    v_bufstr = v_buffer;
 		    v_bufptr = v_buffer + size;
@@ -5842,9 +5843,9 @@
 
 #ifdef VMS
 	riten = tt_write(v_bufstr,
-			 ((v_bufptr - v_bufstr <= VMS_TERM_BUFFER_SIZE)
-			  ? v_bufptr - v_bufstr
-			  : VMS_TERM_BUFFER_SIZE));
+			 (size_t) ((v_bufptr - v_bufstr <= VMS_TERM_BUFFER_SIZE)
+				   ? v_bufptr - v_bufstr
+				   : VMS_TERM_BUFFER_SIZE));
 	if (riten == 0)
 	    return (riten);
 #else /* VMS */
@@ -5877,9 +5878,9 @@
      */
     if (v_bufend - v_bufptr > 1024) {	/* arbitrary hysteresis */
 	/* save pointers across realloc */
-	int start = (int) (v_bufstr - v_buffer);
-	int size = (int) (v_bufptr - v_buffer);
-	unsigned allocsize = (unsigned) (size ? size : 1);
+	size_t start = (size_t) (v_bufstr - v_buffer);
+	size_t size = (size_t) (v_bufptr - v_buffer);
+	size_t allocsize = (size ? size : 1);
 
 	v_buffer = TypeRealloc(Char, allocsize, v_buffer);
 	if (v_buffer) {
@@ -5887,7 +5888,7 @@
 	    v_bufptr = v_buffer + size;
 	    v_bufend = v_buffer + allocsize;
 	    if_DEBUG({
-		fprintf(stderr, "shrunk buffer to %u\n", allocsize);
+		fprintf(stderr, "shrunk buffer to %lu\n", (unsigned long) allocsize);
 	    });
 	} else {
 	    /* should we print a warning if couldn't return memory? */
@@ -7047,12 +7048,12 @@
 	    }
 	    break;
 #if OPT_SIXEL_GRAPHICS
-	case srm_DECSDM:	/* sixel scrolling */
+	case srm_DECSDM:	/* sixel display mode (no scrolling) */
 	    if (optSixelGraphics(screen)) {	/* FIXME: VT24x did not scroll sixel graphics */
 		(*func) (&xw->keyboard.flags, MODE_DECSDM);
-		TRACE(("DECSET/DECRST DECSDM %s (resource default is %d)\n",
+		TRACE(("DECSET/DECRST DECSDM %s (resource default is %s)\n",
 		       BtoS(xw->keyboard.flags & MODE_DECSDM),
-		       TScreenOf(xw)->sixel_scrolling));
+		       BtoS(!TScreenOf(xw)->sixel_scrolling)));
 		update_decsdm();
 	    }
 	    break;
@@ -7398,7 +7399,7 @@
 	    DoSM(DP_X_LRMM, LEFT_RIGHT);
 	    break;
 #if OPT_SIXEL_GRAPHICS
-	case srm_DECSDM:	/* sixel scrolling */
+	case srm_DECSDM:	/* sixel display mode (no scroll) */
 	    DoSM(DP_DECSDM, xw->keyboard.flags & MODE_DECSDM);
 	    update_decsdm();
 	    break;
@@ -7761,7 +7762,7 @@
 	    }
 	    break;
 #if OPT_SIXEL_GRAPHICS
-	case srm_DECSDM:	/* sixel scrolling */
+	case srm_DECSDM:	/* sixel display mode (no scroll) */
 	    bitcpy(&xw->keyboard.flags, screen->save_modes[DP_DECSDM], MODE_DECSDM);
 	    update_decsdm();
 	    break;
@@ -8718,10 +8719,9 @@
 	    newLD = getLineData(screen, row);
 
 	    copyLineData(newLD, oldLD);
-	}
-#else
-	screen->visbuf = screen->editBuf_index[toBuf];
+	} else
 #endif
+	    screen->visbuf = screen->editBuf_index[toBuf];
     }
 }
 
@@ -8751,7 +8751,7 @@
 
 #if OPT_TEK4014
     if (Tpushb > Tpushback) {
-	fillPtyData(xw, VTbuffer, (char *) Tpushback, (int) (Tpushb - Tpushback));
+	fillPtyData(xw, VTbuffer, (char *) Tpushback, (size_t) (Tpushb - Tpushback));
 	Tpushb = Tpushback;
     }
 #endif
@@ -10635,9 +10635,12 @@
 	   BtoS(wnew->keyboard.flags & MODE_DECBKM)));
 
 #if OPT_SIXEL_GRAPHICS
+    /* Sixel scrolling is opposite of Sixel Display Mode */
     init_Bres(screen.sixel_scrolling);
     if (screen->sixel_scrolling)
-	wnew->keyboard.flags |= MODE_DECSDM;
+	UIntClr(wnew->keyboard.flags, MODE_DECSDM);
+    else
+	UIntSet(wnew->keyboard.flags, MODE_DECSDM);
     TRACE(("initialized DECSDM %s\n",
 	   BtoS(wnew->keyboard.flags & MODE_DECSDM)));
 #endif
@@ -13284,10 +13287,12 @@
 	screen->pointer_mode = screen->pointer_mode0;
 #if OPT_SIXEL_GRAPHICS
 	if (TScreenOf(xw)->sixel_scrolling)
-	    xw->keyboard.flags |= MODE_DECSDM;
+	    UIntClr(xw->keyboard.flags, MODE_DECSDM);
+	else
+	    UIntSet(xw->keyboard.flags, MODE_DECSDM);
 	TRACE(("full reset DECSDM to %s (resource default is %s)\n",
 	       BtoS(xw->keyboard.flags & MODE_DECSDM),
-	       BtoS(TScreenOf(xw)->sixel_scrolling)));
+	       BtoS(!TScreenOf(xw)->sixel_scrolling)));
 #endif
 
 #if OPT_GRAPHICS
Index: configure
--- xterm-373+/configure	2022-09-11 22:36:51.000000000 +0000
+++ xterm-374/configure	2022-10-10 16:35:26.000000000 +0000
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by Autoconf 2.52.20210509.
+# Generated by Autoconf 2.52.20221009.
 #
-# Copyright 2003-2020,2021	Thomas E. Dickey
+# Copyright 2003-2021,2022	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
@@ -33,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
@@ -50,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
@@ -879,7 +879,7 @@
 if "$ac_init_version"; then
   cat <<\EOF
 
-Copyright 2003-2020,2021	Thomas E. Dickey
+Copyright 2003-2021,2022	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
@@ -893,7 +893,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.20210509.  Invocation command line was
+generated by GNU Autoconf 2.52.20221009.  Invocation command line was
 
   $ $0 $@
 
@@ -3052,7 +3052,7 @@
 	cf_xopen_source="-D_SGI_SOURCE"
 	cf_XOPEN_SOURCE=
 	;;
-(linux*gnu|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
+(linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
 
 cf_gnu_xopen_source=$cf_XOPEN_SOURCE
 
@@ -18360,8 +18360,8 @@
 	fi
 	SET_TERMINFO=
 	if test -n "$TERMINFO_DIR" ; then
-		TERMINFO_DIR='$(DESTDIR)'$TERMINFO_DIR
-		SET_TERMINFO='TERMINFO=$(TERMINFO_DIR)'
+		TERMINFO_DIR='${DESTDIR}'$TERMINFO_DIR
+		SET_TERMINFO='TERMINFO=${TERMINFO_DIR}'
 	fi
 	no_ticprog=
 else
@@ -25141,7 +25141,7 @@
 fi
 
 ###	output xtermcfg.h, etc
-ac_config_files="$ac_config_files Makefile df-install minstall:minstall.in"
+ac_config_files="$ac_config_files Makefile df-install minstall:minstall.in run-tic.sh:run-tic.in"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -25231,6 +25231,8 @@
 # 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 \$@"
@@ -25252,9 +25254,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
@@ -25269,7 +25271,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
@@ -25353,10 +25355,10 @@
 cat >>"$CONFIG_STATUS" <<EOF
 ac_cs_version="\\
 config.status
-configured by $0, generated by GNU Autoconf 2.52.20210509,
+configured by $0, generated by GNU Autoconf 2.52.20221009,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
-Copyright 2003-2020,2021	Thomas E. Dickey
+Copyright 2003-2021,2022	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
@@ -25398,7 +25400,7 @@
     echo "$ac_cs_version"; exit 0 ;;
   --he | --h)
     # Conflict between --help and --header
-    { { echo "$as_me:25401: error: ambiguous option: $1
+    { { echo "$as_me:25403: 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;}
@@ -25417,7 +25419,7 @@
     ac_need_defaults=false;;
 
   # This is an error.
-  -*) { { echo "$as_me:25420: error: unrecognized option: $1
+  -*) { { echo "$as_me:25422: 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;}
@@ -25436,7 +25438,7 @@
 ## Running config.status.  ##
 ## ----------------------- ##
 
-This file was extended by $as_me 2.52.20210509, executed with
+This file was extended by $as_me 2.52.20221009, executed with
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
   CONFIG_LINKS    = $CONFIG_LINKS
@@ -25455,8 +25457,9 @@
   "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
   "df-install" ) CONFIG_FILES="$CONFIG_FILES df-install" ;;
   "minstall" ) CONFIG_FILES="$CONFIG_FILES minstall:minstall.in" ;;
+  "run-tic.sh" ) CONFIG_FILES="$CONFIG_FILES run-tic.sh:run-tic.in" ;;
   "xtermcfg.h" ) CONFIG_HEADERS="$CONFIG_HEADERS xtermcfg.h:xtermcfg.hin" ;;
-  *) { { echo "$as_me:25459: error: invalid argument: $ac_config_target" >&5
+  *) { { echo "$as_me:25462: error: invalid argument: $ac_config_target" >&5
 echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
    { (exit 1); exit 1; }; };;
   esac
@@ -25479,14 +25482,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
@@ -25506,7 +25509,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
@@ -25658,11 +25661,11 @@
   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
+      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
@@ -25670,17 +25673,17 @@
       # 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
+  /@[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
+      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
@@ -25690,9 +25693,9 @@
       fi
 
       if test -z "$ac_sed_cmds"; then
-        ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
+        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"
+        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
@@ -25700,7 +25703,7 @@
     fi
   done
   if test -z "$ac_sed_cmds"; then
-    ac_sed_cmds=cat
+    ac_sed_cmds="cat"
   fi
 fi # test -n "$CONFIG_FILES"
 
@@ -25710,7 +25713,7 @@
   # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.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,[^:]*:,,'`
@@ -25747,7 +25750,7 @@
   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
@@ -25775,7 +25778,7 @@
   esac
 
   if test x"$ac_file" != x-; then
-    { echo "$as_me:25778: creating $ac_file" >&5
+    { echo "$as_me:25781: creating $ac_file" >&5
 echo "$as_me: creating $ac_file" >&6;}
     rm -f "$ac_file"
   fi
@@ -25790,23 +25793,23 @@
   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:25796: error: cannot find input file: $f" >&5
+         test -f "$f" || { { echo "$as_me:25799: 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"
          else
            # /dev/null tree
-           { { echo "$as_me:25809: error: cannot find input file: $f" >&5
+           { { echo "$as_me:25812: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          fi;;
@@ -25822,7 +25825,7 @@
       if test -n "$ac_seen"; then
         ac_used=`grep '@datarootdir@' "$ac_item"`
         if test -z "$ac_used"; then
-          { echo "$as_me:25825: WARNING: datarootdir was used implicitly but not set:
+          { echo "$as_me:25828: 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;}
@@ -25831,7 +25834,7 @@
       fi
       ac_seen=`grep '${datarootdir}' "$ac_item"`
       if test -n "$ac_seen"; then
-        { echo "$as_me:25834: WARNING: datarootdir was used explicitly but not set:
+        { echo "$as_me:25837: 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;}
@@ -25856,38 +25859,46 @@
 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
+: "${FGREP:=grep -F}"
+: "${EGREP:=grep -E}"
+cat >>"$CONFIG_STATUS" <<EOF
+  : "\${FGREP:=$FGREP}"
+  : "\${EGREP:=$EGREP}"
+EOF
+cat >>"$CONFIG_STATUS" <<\EOF
   if test x"$ac_file" != x-; then
     cp "$tmp/out" "$ac_file"
 
     for ac_name in prefix exec_prefix datarootdir
     do
-        ac_seen=`${FGREP-fgrep} -n '${'$ac_name'[:=].*}' "$ac_file"`
+        ac_seen=`$FGREP -n '${'$ac_name'[:=].*}' "$ac_file"`
         if test -n "$ac_seen"; then
-            ac_init=`${EGREP-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:25871: WARNING: Variable $ac_name is used but was not set:
+              ac_seen=`echo "$ac_seen" |sed -e 's,^,'"$ac_file"':,'`
+              { echo "$as_me:25882: 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-egrep} -n '@[a-z_][a-z_0-9]+@' "$ac_file" >$tmp/out
-    ${EGREP-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:25882: 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:25893: 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
@@ -25920,7 +25931,7 @@
   # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.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,[^:]*:,,'`
@@ -25928,7 +25939,7 @@
   * )   ac_file_in=$ac_file.in ;;
   esac
 
-  test x"$ac_file" != x- && { echo "$as_me:25931: creating $ac_file" >&5
+  test x"$ac_file" != x- && { echo "$as_me:25942: creating $ac_file" >&5
 echo "$as_me: creating $ac_file" >&6;}
 
   # First look for the input files in the build tree, otherwise in the
@@ -25936,10 +25947,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:25942: error: cannot find input file: $f" >&5
+         test -f "$f" || { { echo "$as_me:25953: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          echo $f;;
@@ -25952,14 +25963,14 @@
            echo "$srcdir/$f"
          else
            # /dev/null tree
-           { { echo "$as_me:25955: error: cannot find input file: $f" >&5
+           { { echo "$as_me:25966: 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
 
@@ -26005,14 +26016,14 @@
 # Break up conftest.defines because some shells have a limit on the size
 # of here documents, and old seds have small limits too (100 cmds).
 echo '  # Handle all the #define templates only if necessary.' >>"$CONFIG_STATUS"
-echo '  if egrep "^[ 	]*#[ 	]*define" $tmp/in >/dev/null; then' >>"$CONFIG_STATUS"
+echo '  if ${EGREP-grep -E} "^[ 	]*#[ 	]*define" "$tmp"/in >/dev/null; then' >>"$CONFIG_STATUS"
 echo '  # If there are no defines, we may have an empty if/fi' >>"$CONFIG_STATUS"
 echo '  :' >>"$CONFIG_STATUS"
 rm -f conftest.tail
 while grep . conftest.defines >/dev/null
 do
-  # Write a limited-size here document to $tmp/defines.sed.
-  echo '  cat >$tmp/defines.sed <<CEOF' >>"$CONFIG_STATUS"
+  # Write a limited-size here document to "$tmp"/defines.sed.
+  echo '  cat >"$tmp"/defines.sed <<CEOF' >>"$CONFIG_STATUS"
   # Speed up: don't consider the non `#define' lines.
   echo '/^[ 	]*#[ 	]*define/!b' >>"$CONFIG_STATUS"
   # Work around the forget-to-reset-the-flag bug.
@@ -26020,16 +26031,16 @@
   echo ': clr' >>"$CONFIG_STATUS"
   sed "${ac_max_here_lines}q" conftest.defines >>"$CONFIG_STATUS"
   echo 'CEOF
-  sed -f $tmp/defines.sed $tmp/in >$tmp/out
-  rm -f $tmp/in
-  mv $tmp/out $tmp/in
+  sed -f "$tmp"/defines.sed "$tmp"/in >"$tmp"/out
+  rm -f "$tmp"/in
+  mv "$tmp"/out "$tmp"/in
 ' >>"$CONFIG_STATUS"
   sed "1,${ac_max_here_lines}d" conftest.defines >conftest.tail
   rm -f conftest.defines
   mv conftest.tail conftest.defines
 done
 rm -f conftest.defines
-echo '  fi # egrep' >>"$CONFIG_STATUS"
+echo '  fi # grep' >>"$CONFIG_STATUS"
 echo >>"$CONFIG_STATUS"
 
 # Break up conftest.undefs because some shells have a limit on the size
@@ -26038,8 +26049,8 @@
 rm -f conftest.tail
 while grep . conftest.undefs >/dev/null
 do
-  # Write a limited-size here document to $tmp/undefs.sed.
-  echo '  cat >$tmp/undefs.sed <<CEOF' >>"$CONFIG_STATUS"
+  # Write a limited-size here document to "$tmp"/undefs.sed.
+  echo '  cat >"$tmp"/undefs.sed <<CEOF' >>"$CONFIG_STATUS"
   # Speed up: don't consider the non `#undef'
   echo '/^[ 	]*#[ 	]*undef/!b' >>"$CONFIG_STATUS"
   # Work around the forget-to-reset-the-flag bug.
@@ -26047,9 +26058,9 @@
   echo ': clr' >>"$CONFIG_STATUS"
   sed "${ac_max_here_lines}q" conftest.undefs >>"$CONFIG_STATUS"
   echo 'CEOF
-  sed -f $tmp/undefs.sed $tmp/in >$tmp/out
-  rm -f $tmp/in
-  mv $tmp/out $tmp/in
+  sed -f "$tmp"/undefs.sed "$tmp"/in >"$tmp"/out
+  rm -f "$tmp"/in
+  mv "$tmp"/out "$tmp"/in
 ' >>"$CONFIG_STATUS"
   sed "1,${ac_max_here_lines}d" conftest.undefs >conftest.tail
   rm -f conftest.undefs
@@ -26062,15 +26073,15 @@
   # 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:26073: $ac_file is unchanged" >&5
+      { echo "$as_me:26084: $ac_file is unchanged" >&5
 echo "$as_me: $ac_file is unchanged" >&6;}
     else
       ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
@@ -26106,8 +26117,8 @@
       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
Index: configure.in
--- xterm-373+/configure.in	2022-09-11 22:34:16.000000000 +0000
+++ xterm-374/configure.in	2022-10-10 16:33:01.000000000 +0000
@@ -1,4 +1,4 @@
-dnl $XTermId: configure.in,v 1.387 2022/09/11 22:34:16 tom Exp $
+dnl $XTermId: configure.in,v 1.390 2022/10/10 16:33:01 tom Exp $
 dnl
 dnl -----------------------------------------------------------------------------
 dnl this file is part of xterm
@@ -444,8 +444,8 @@
 	fi
 	SET_TERMINFO=
 	if test -n "$TERMINFO_DIR" ; then
-		TERMINFO_DIR='$(DESTDIR)'$TERMINFO_DIR
-		SET_TERMINFO='TERMINFO=$(TERMINFO_DIR)'
+		TERMINFO_DIR='${DESTDIR}'$TERMINFO_DIR
+		SET_TERMINFO='TERMINFO=${TERMINFO_DIR}'
 	fi
 	no_ticprog=
 else
@@ -1204,5 +1204,5 @@
 fi
 
 ###	output xtermcfg.h, etc
-AC_CONFIG_FILES([Makefile df-install minstall:minstall.in])
+AC_CONFIG_FILES([Makefile df-install minstall:minstall.in run-tic.sh:run-tic.in])
 AC_OUTPUT
Index: ctlseqs.ms
--- xterm-373+/ctlseqs.ms	2022-03-12 20:29:38.000000000 +0000
+++ xterm-374/ctlseqs.ms	2022-10-10 14:18:26.000000000 +0000
@@ -1,6 +1,6 @@
 .\"#! troff -ms $1		-*- Nroff -*-
 .\" "Xterm Control Sequences" document
-.\" $XTermId: ctlseqs.ms,v 1.640 2022/03/12 20:29:38 tom Exp $
+.\" $XTermId: ctlseqs.ms,v 1.641 2022/10/10 14:18:26 tom Exp $
 .\"
 .\"
 .\" Copyright 1996-2021,2022 by Thomas E. Dickey
@@ -69,8 +69,8 @@
 .\"
 .ds XT XTerm
 .ds xt xterm
-.ds LF Patch #373
-.ds RF 2022/03/12
+.ds LF Patch #374
+.ds RF 2022/10/10
 .\"
 .if n .pl 9999v		\" no page breaks in nroff
 .ND
@@ -1341,7 +1341,7 @@
   \*(Ps = \*6\*7 \(-> Backarrow key sends backspace (DECBKM), VT340, VT420.
 This sets the \fBbackarrowKey\fP resource to \*(``true\*(''.
   \*(Ps = \*6\*9 \(-> Enable left and right margin mode (DECLRMM), VT420 and up.
-  \*(Ps = \*8\*0 \(-> Disable \fISixel Scrolling\fP (DECSDM).
+  \*(Ps = \*8\*0 \(-> Enable \fISixel Display Mode\fP (DECSDM), VT330, VT340, VT382. 
   \*(Ps = \*9\*5 \(-> Do not clear screen when DECCOLM is set/reset
 (DECNCSM), VT510 and up.
   \*(Ps = \*1\*0\*0\*0 \(-> Send Mouse X & Y on button press and release.
@@ -1476,7 +1476,9 @@
 This sets the \fBbackarrowKey\fP resource to \*(``false\*(''.
   \*(Ps = \*6\*9 \(-> Disable left and right margin mode (DECLRMM),
 VT420 and up.
-  \*(Ps = \*8\*0 \(-> Enable \fISixel Scrolling\fP (DECSDM).
+  \*(Ps = \*8\*0 \(-> Disable \fISixel Display Mode\fP (DECSDM), VT330, VT340, VT382.
+Turns on ``Sixel Scrolling''.
+See the section \fBSixel Graphics\fP and mode \*8\*4\*5\*2.
   \*(Ps = \*9\*5 \(-> Clear screen when DECCOLM is set/reset (DECNCSM),
 VT510 and up.
   \*(Ps = \*1\*0\*0\*0 \(-> Don't send Mouse X & Y on button press and
@@ -3604,24 +3606,23 @@
 \fBdecTerminalID\fP or
 \fBdecGraphicsID\fP
 resource,
-it supports Sixel Graphics controls, a palleted bitmap graphics system
+it supports Sixel Graphics controls, a paletted bitmap graphics system
 using sets of six vertical pixels as the basic element.
 .St
 .IP \\*(Cs\\*(Ps\\*s\\*c
-Send Device Attributes (Primary DA), \fI\*(xt\fP.
+Send Device Attributes (Primary DA), DEC graphics terminals, \fI\*(xt\fP.
 \fI\*(xt\fP responds to Send Device Attributes (Primary DA) with these
 additional codes:
   \*(Ps = \*4 \(-> Sixel graphics.
 .iP
 .IP \\*(Cs\\*?\\*(Pm\\*s\\*h
-Set Mode, \fI\*(xt\fP.
-\fI\*(xt\fP has these additional private Set Mode values:
-  \*(Ps = \*8\*0 \(-> Sixel scrolling.
-  \*(Ps = \*1\*0\*7\*0 \(-> use private color registers for each graphic.
-  \*(Ps = \*8\*4\*5\*2 \(-> Sixel scrolling leaves cursor to right of graphic.
+Set Mode (with corresponding Reset Mode \*(Cs\*?\*(Pm\*s\*l):
+  \*(Ps = \*8\*0 \(-> Sixel Display Mode (DECSDM), VT330, VT340, VT382.
+  \*(Ps = \*1\*0\*7\*0 \(-> use private color registers for each graphic, \fI\*(xt\fP.
+  \*(Ps = \*8\*4\*5\*2 \(-> Sixel scrolling leaves cursor to right of graphic, RLogin, \fI\*(xt\fP.
 .iP
 .IP \\*(Dc\\*(Pa\\*s\\*;\\*(Pb\\*s\\*;\\*(Ph\\*s\\*q\\*s\\*(Ps..\\*(Ps\fP\\*s\\*(ST
-Send SIXEL image, DEC graphics terminals, \fI\*(xt\fP.
+Send SIXEL image, DEC graphics terminals, VT330, VT340, VT382.
 See:
 .ID 3
 \fIVT330/VT340 Programmer Reference Manual Volume 2:\fP
@@ -3911,11 +3912,50 @@
 For example, testing a DEC VT420 in 1996 showed that the documented
 code for a valid or invalid response to DECRQSS was reversed.
 .IP
-The VT420 test results were incorporated into \fIvttest\fP program.
+The VT420 test results were incorporated into the \fIvttest\fP program.
 At the time, DEC STD 070 was not available,
 but it also agrees with \fIvttest\fP.
 Later, documentation for the DEC VT525 was shown to have the same flaw.
 .bP
+The VT330/VT340 reference manual for graphics programming
+documents sixel graphics in some detail in chapter 14.
+Overlooked in the first edition, the second edition mentions
+.\" https://vt100.net/docs/vt3xx-gp/chapter14.html#S14.4
+\fISixel Scrolling\fP.
+The VT382 Kanji and Thai manuals provide less information,
+about sixel graphics,
+but do mention DECSDM.
+They differ in their comment about the private mode
+DECSDM (\*(Cs\*?\*8\*0\*h),
+which each manual agrees should \fIset\fP the Sixel Scrolling feature.
+The VT330/VT340 graphics programming manual (second edition, March 1988) says
+.RS 5
+.sp
+When sixel display mode is set, the \fISixel Scrolling\fP feature is enabled. 
+.br
+When sixel display mode is reset, the \fISixel Scrolling\fP feature is disabled.
+.RE
+.IP
+while the VT382 Kanji manual (page 6-6, undated) says
+.RS
+.sp
+Disable sixel scroll
+.RE
+.sp
+and the VT382 Thai manual (page C-30, August 1989) says
+.RS
+.sp
+No Sixel scrolling
+.RE
+.IP
+The standard (DEC STD 070) in chapter 9 (August 3, 1990)
+states on page 17 that video devices will scroll
+when advancing the Sixel active position past the bottom margin,
+but on page 19, in the section on deviations,
+states that VT125 and VT240 did not scroll in this situation.
+The standard does not mention VT330/VT340 or VT382.
+Nor does it document DECSDM.
+.bP
 Not all details are clear even in DEC STD 070
 (which is more than twice the length of the
 VT520 programmer's reference manual,
@@ -4016,7 +4056,7 @@
 \fIProgrammer Reference Manual\fP.
 .br
 Digital Equipment Corporation
-(EK-VT382-RM-001).
+(EK-VT382-RM-001, undated).
 .bP
 .\" https://vt100.net/dec/ek-vt38t-ug-001.pdf
 \fIVT382 Thai Display Terminal\fP
@@ -4180,38 +4220,7 @@
 .IP
 Both the VT220 manual and DEC STD 070 (which documents
 levels 1-4 in detail) state that it is a soft reset, e.g., DECSTR.
-.bP
-The VT330/VT340 reference manual for graphics programming
-documents sixel scrolling in some detail in chapter 14.
-The VT382 Kanji and Thai manuals provide less information,
-but differ in their comment about the private mode
-DECSDM (\*(Cs\*?\*8\*0\*h),
-which each manual agrees should \fIset\fP the Sixel Scrolling feature.
-However, the VT330/VT340 manual says
-.RS
-.IP
-When sixel display mode is set, the Sixel Scrolling feature is enabled. 
-.RE
-.IP
-while the VT382 Kanji manual (page 6-6) says
-.RS
-.IP
-Disable sixel scroll
-.RE
-.IP
-and the VT382 Thai manual (page C-30) says
-.RS
-.IP
-No Sixel scrolling
-.RE
-.IP
-The standard (DEC STD 070) in chapter 9 (August 3, 1990)
-states on page 17 that video devices will scroll
-when advancing the Sixel active position past the bottom margin,
-but on page 19, in the section on deviations,
-states that VT125 and VT240 did not scroll in this situation.
-The standard does not mention VT330/VT340 or VT382.
-Nor does it document DECSDM.
+.
 .LP
 Here are the relevant standards:
 .bP
Index: ctlseqs.txt
--- xterm-373+/ctlseqs.txt	2022-03-12 20:47:06.000000000 +0000
+++ xterm-374/ctlseqs.txt	2022-10-10 14:18:48.000000000 +0000
@@ -21,7 +21,7 @@
                              Thomas Dickey
                       XFree86 Project (1996-2006)
                     invisible-island.net (2006-2022)
-               updated for XTerm Patch #373 (2022/03/12)
+               updated for XTerm Patch #374 (2022/10/10)
 
 
 
@@ -793,7 +793,8 @@
           VT420.  This sets the backarrowKey resource to "true".
             Ps = 6 9  -> Enable left and right margin mode (DECLRMM),
           VT420 and up.
-            Ps = 8 0  -> Disable Sixel Scrolling (DECSDM).
+            Ps = 8 0  -> Enable Sixel Display Mode (DECSDM), VT330,
+          VT340, VT382.
             Ps = 9 5  -> Do not clear screen when DECCOLM is set/reset
           (DECNCSM), VT510 and up.
             Ps = 1 0 0 0  -> Send Mouse X & Y on button press and
@@ -922,7 +923,9 @@
           VT420.  This sets the backarrowKey resource to "false".
             Ps = 6 9  -> Disable left and right margin mode (DECLRMM),
           VT420 and up.
-            Ps = 8 0  -> Enable Sixel Scrolling (DECSDM).
+            Ps = 8 0  -> Disable Sixel Display Mode (DECSDM), VT330,
+          VT340, VT382.  Turns on ``Sixel Scrolling''.  See the section
+          Sixel Graphics and mode 8 4 5 2 .
             Ps = 9 5  -> Clear screen when DECCOLM is set/reset
           (DECNCSM), VT510 and up.
             Ps = 1 0 0 0  -> Don't send Mouse X & Y on button press and
@@ -2728,25 +2731,26 @@
 
 If xterm is configured as VT240, VT241, VT330, VT340 or VT382 using the
 decTerminalID or decGraphicsID resource, it supports Sixel Graphics
-controls, a palleted bitmap graphics system using sets of six vertical
+controls, a paletted bitmap graphics system using sets of six vertical
 pixels as the basic element.
 
-CSI Ps c  Send Device Attributes (Primary DA), xterm.  xterm responds to
-          Send Device Attributes (Primary DA) with these additional
-          codes:
+CSI Ps c  Send Device Attributes (Primary DA), DEC graphics terminals,
+          xterm.  xterm responds to Send Device Attributes (Primary DA)
+          with these additional codes:
             Ps = 4  -> Sixel graphics.
 
 CSI ? Pm h
-          Set Mode, xterm.  xterm has these additional private Set Mode
-          values:
-            Ps = 8 0  -> Sixel scrolling.
+          Set Mode (with corresponding Reset Mode CSI ? Pm l ):
+            Ps = 8 0  -> Sixel Display Mode (DECSDM), VT330, VT340,
+          VT382.
             Ps = 1 0 7 0  -> use private color registers for each
-          graphic.
+          graphic, xterm.
             Ps = 8 4 5 2  -> Sixel scrolling leaves cursor to right of
-          graphic.
+          graphic, RLogin, xterm.
 
 DCS Pa ; Pb ; Ph q  Ps..Ps ST
-          Send SIXEL image, DEC graphics terminals, xterm.  See:
+          Send SIXEL image, DEC graphics terminals, VT330, VT340, VT382.
+          See:
 
              VT330/VT340 Programmer Reference Manual Volume 2:
              Graphics Programming
@@ -2966,11 +2970,40 @@
     DEC VT420 in 1996 showed that the documented code for a valid or
     invalid response to DECRQSS was reversed.
 
-    The VT420 test results were incorporated into vttest program.  At
-    the time, DEC STD 070 was not available, but it also agrees with
+    The VT420 test results were incorporated into the vttest program.
+    At the time, DEC STD 070 was not available, but it also agrees with
     vttest.  Later, documentation for the DEC VT525 was shown to have
     the same flaw.
 
+o   The VT330/VT340 reference manual for graphics programming documents
+    sixel graphics in some detail in chapter 14.  Overlooked in the
+    first edition, the second edition mentions Sixel Scrolling.  The
+    VT382 Kanji and Thai manuals provide less information, about sixel
+    graphics, but do mention DECSDM.  They differ in their comment about
+    the private mode DECSDM (CSI ? 8 0 h ), which each manual agrees
+    should set the Sixel Scrolling feature.  The VT330/VT340 graphics
+    programming manual (second edition, March 1988) says
+
+        When sixel display mode is set, the Sixel Scrolling feature is
+        enabled.
+        When sixel display mode is reset, the Sixel Scrolling feature is
+        disabled.
+
+    while the VT382 Kanji manual (page 6-6, undated) says
+
+        Disable sixel scroll
+
+    and the VT382 Thai manual (page C-30, August 1989) says
+
+        No Sixel scrolling
+
+    The standard (DEC STD 070) in chapter 9 (August 3, 1990) states on
+    page 17 that video devices will scroll when advancing the Sixel
+    active position past the bottom margin, but on page 19, in the
+    section on deviations, states that VT125 and VT240 did not scroll in
+    this situation.  The standard does not mention VT330/VT340 or VT382.
+    Nor does it document DECSDM.
+
 o   Not all details are clear even in DEC STD 070 (which is more than
     twice the length of the VT520 programmer's reference manual, and
     almost three times longer than the VT420 reference manual).
@@ -3022,7 +3055,7 @@
 
 o   VT382 Kanji Display Terminal
     Programmer Reference Manual.
-    Digital Equipment Corporation (EK-VT382-RM-001).
+    Digital Equipment Corporation (EK-VT382-RM-001, undated).
 
 o   VT382 Thai Display Terminal
     Installing and Using Manual.
@@ -3142,31 +3175,6 @@
     Both the VT220 manual and DEC STD 070 (which documents levels 1-4 in
     detail) state that it is a soft reset, e.g., DECSTR.
 
-o   The VT330/VT340 reference manual for graphics programming documents
-    sixel scrolling in some detail in chapter 14.  The VT382 Kanji and
-    Thai manuals provide less information, but differ in their comment
-    about the private mode DECSDM (CSI ? 8 0 h ), which each manual
-    agrees should set the Sixel Scrolling feature.  However, the
-    VT330/VT340 manual says
-
-              When sixel display mode is set, the Sixel Scrolling
-              feature is enabled.
-
-    while the VT382 Kanji manual (page 6-6) says
-
-              Disable sixel scroll
-
-    and the VT382 Thai manual (page C-30) says
-
-              No Sixel scrolling
-
-    The standard (DEC STD 070) in chapter 9 (August 3, 1990) states on
-    page 17 that video devices will scroll when advancing the Sixel
-    active position past the bottom margin, but on page 19, in the
-    section on deviations, states that VT125 and VT240 did not scroll in
-    this situation.  The standard does not mention VT330/VT340 or VT382.
-    Nor does it document DECSDM.
-
 Here are the relevant standards:
 
 o   Additional Controls for Use with American National Standard Code for
@@ -3284,44 +3292,44 @@
         be used in termcap for vi, for example, to turn off saving of
         lines, but restore whatever the original state was on exit.
 
-    while the SCOSC/SCORC  pair  was  added  in  1995  by  XFree86  (and
+    while  the  SCOSC/SCORC  pair  was  added  in  1995  by XFree86 (and
     documented long afterwards).
 
-    The  SCO  ANSI  console  terminal  descriptions  did  not  use these
-    controls (they used the VT100-compatible SC/RC  pair).   SCOSC/SCORC
-    were  an artifact of DOS 2.00 (January 1983), by Microsoft and later
+    The SCO  ANSI  console  terminal  descriptions  did  not  use  these
+    controls  (they  used the VT100-compatible SC/RC pair).  SCOSC/SCORC
+    were an artifact of DOS 2.00 (January 1983), by Microsoft and  later
     supported by SCO and other vendors.
 
-    The SCOSC/SCORC pair is considered a private mode because the  final
+    The  SCOSC/SCORC pair is considered a private mode because the final
     characters (s  and u ) fall in the range from "`" to "~" (octal 0140
-    to octal 0176).  Other private control sequences can be  constructed
+    to  octal 0176).  Other private control sequences can be constructed
     by using octets 074 to 077 (characters "<", "=", ">", or "?") at the
     beginning  of  the  parameter  string.   The  XTSAVE  and  XTRESTORE
     controls use "?") in this manner.
 
     Because  the  XTSAVE  and  XTRESTORE  controls  are  private,  other
-    terminals may behave differently.  For example, DEC  (a  contributor
-    to  the  early xterm as well as a manufacturer of terminals) used an
-    incompatible private control in one of its terminals more than  five
+    terminals  may  behave differently.  For example, DEC (a contributor
+    to the early xterm as well as a manufacturer of terminals)  used  an
+    incompatible  private control in one of its terminals more than five
     years later (for the VT420 PCTerm, announced in February 1992).
 
-    In  that  model  of  the  VT420,  CSI ? Pm; Pc r selects the PC TERM
-    emulation mode.  When this mode is enabled, the keyboard sends  scan
-    codes  rather than characters (analogous to X keyboard events).  The
-    first parameter of this private control enables or disables PC  TERM
+    In that model of the VT420, CSI ? Pm;  Pc  r  selects  the  PC  TERM
+    emulation  mode.  When this mode is enabled, the keyboard sends scan
+    codes rather than characters (analogous to X keyboard events).   The
+    first  parameter of this private control enables or disables PC TERM
     mode, while the second selects a character set.  An ambiguity arises
     if an application omits the second parameter.  In that special case,
-    it  cannot  be  distinguished from XTRESTORE.  DEC did not take this
+    it cannot be distinguished from XTRESTORE.  DEC did  not  take  this
     into account when designing the feature.
 
-    If there were potential users, xterm could  accommodate  this  by  a
-    resource  setting.   In  retrospect (thirty years later), there have
-    been no uses of PC TERM, while the XTRESTORE  feature  is  still  in
+    If  there  were  potential  users, xterm could accommodate this by a
+    resource setting.  In retrospect (thirty years  later),  there  have
+    been  no  uses  of  PC TERM, while the XTRESTORE feature is still in
     use.
 
 o   The aixterm manual page gives the format of the control sequence for
-    foreground and background colors 8-15, but  does  not  specify  what
-    those  colors  are.  That is implied by the description's mention of
+    foreground  and  background  colors  8-15, but does not specify what
+    those colors are.  That is implied by the description's  mention  of
     HFT:
 
         The aixterm command provides a standard terminal type for
@@ -3331,7 +3339,7 @@
         the -v flag.
 
     Unlike xterm, there are no resource names for the 16 colors, leaving
-    the  reader  to  assume that the mapping is hard-coded.  The control
-    sequences for colors 8-15 are not specified by ECMA-48,  but  rather
-    (as  done  in  other instances by xterm) chosen to not conflict with
+    the reader to assume that the mapping is  hard-coded.   The  control
+    sequences  for  colors 8-15 are not specified by ECMA-48, but rather
+    (as done in other instances by xterm) chosen to  not  conflict  with
     current or future standards.
Index: fontutils.c
--- xterm-373+/fontutils.c	2022-07-20 00:21:20.000000000 +0000
+++ xterm-374/fontutils.c	2022-10-06 23:48:16.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: fontutils.c,v 1.740 2022/07/20 00:21:20 tom Exp $ */
+/* $XTermId: fontutils.c,v 1.743 2022/10/06 23:48:16 tom Exp $ */
 
 /*
  * Copyright 1998-2021,2022 by Thomas E. Dickey
@@ -3311,6 +3311,9 @@
 	    if (work->xft_defaults == NULL) {
 		FcInit();
 		work->xft_defaults = FcPatternCreate();
+		XftDefaultSubstitute(screen->display,
+				     XScreenNumberOfScreen(XtScreen(xw)),
+				     work->xft_defaults);
 		if (screen->xft_max_glyph_memory > 0) {
 		    FcPatternAddInteger(work->xft_defaults,
 					XFT_MAX_GLYPH_MEMORY,
@@ -4265,7 +4268,7 @@
 findXftGlyph(XtermWidget xw, XTermXftFonts *fontData, unsigned wc)
 {
     TScreen *screen = TScreenOf(xw);
-    XftFont *given = XftFp(fontData);
+    XftFont *given;
     XftFont *actual = NULL;
     Cardinal n;
     FcResult status;
@@ -4274,6 +4277,7 @@
     /* sanity-check */
     if (fontData == NULL)
 	return result;
+    given = XftFp(fontData);
 
     /* if fontsets are not wanted, just leave */
     if (xw->work.max_fontsets == 0) {
@@ -4308,11 +4312,11 @@
 			   FcMatchPattern);
 	FcDefaultSubstitute(myPattern);
 
-	fontData->fontset = FcFontSetCreate();
-
 	sortedFonts = FcFontSort(NULL, myPattern, FcTrue, NULL, &status);
 
-	if (!sortedFonts || sortedFonts->nfont <= 0) {
+	fontData->fontset = FcFontSetCreate();
+
+	if (fontData->fontset == 0 || !sortedFonts || sortedFonts->nfont <= 0) {
 	    xtermWarning("did not find any usable TrueType font\n");
 	    return 0;
 	}
@@ -4355,7 +4359,7 @@
 	fontData->fs_size = (unsigned) fontData->fontset->nfont;
     }
 
-    if (fontData->fontset != NULL) {
+    {
 	XftFont *check;
 	Cardinal empty = fontData->fs_size;
 
Index: graphics_sixel.c
--- xterm-373+/graphics_sixel.c	2022-02-21 23:13:48.000000000 +0000
+++ xterm-374/graphics_sixel.c	2022-10-10 15:09:41.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: graphics_sixel.c,v 1.36 2022/02/21 23:13:48 tom Exp $ */
+/* $XTermId: graphics_sixel.c,v 1.38 2022/10/10 15:09:41 tom Exp $ */
 
 /*
  * Copyright 2014-2021,2022 by Ross Combs
@@ -109,15 +109,24 @@
     int col;			/* context used during parsing */
 } SixelContext;
 
-/* sixel scrolling:
- * VK100/GIGI ? (did it even support Sixel?)
- * VT125      unsupported
- * VT240      unsupported
- * VT241      unsupported
- * VT330      mode setting
- * VT382      ?
- * VT340      mode setting
- * dxterm     ?
+/* SIXEL SCROLLING, which is on by default in VT3xx terminals, can be
+ * turned off to better emulate VT2xx terminals by setting Sixel
+ * Display Mode (DECSDM)
+ *
+ *		SIXEL DISPLAY MODE	SIXEL SCROLLING
+ * VT125	Always on		Unsupported
+ * VT240	Always on		Unsupported
+ * VT241	Always on		Unsupported
+ * VT330	Available via DECSDM	Default mode
+ * VT382	Available via DECSDM	Default mode
+ * VT340	Available via DECSDM	Default mode
+ * VK100/GIGI	No sixel support	No sixel support
+ *
+ * dxterm (DECterm) emulated a VT100 series terminal, and supported sixels
+ * according to 1995 posting to comp.os.vms:
+ *	https://groups.google.com/g/comp.os.vms/c/XAUMmLtC8Yk
+ * though not DRCS according to
+ *	http://odl.sysworks.biz/disk$axpdocdec023/office/dwmot126/vmsdw126/relnotes/6470pro_004.html
  */
 
 static void
@@ -250,17 +259,26 @@
 			   + FontWidth(screen) - 1)
 			  / FontWidth(screen)));
 	} else {
-	    /* FIXME: At least of the VT382 the vertical position appears to be
-	     * truncated (rounded toward zero after converting to character row.
-	     * This code rounds up, which seems more useful, but it would be
-	     * better to be compatible.  Verify this is true on a VT3[34]0 as
-	     * well.
+	    /* NOTE: XTerm follows the VT382 behavior in text cursor
+	     * placement.  The VT382's vertical position appears to be
+	     * truncated (rounded toward zero) after converting to character
+	     * row.  While rounding up is more often what is desired, so as to
+	     * not overwrite the image, doing so automatically would cause text
+	     * or graphics to scroll off the top of the screen.  Therefore,
+	     * applications must add their own newline character, if desired,
+	     * after a sixel image.
+	     *
+	     * FIXME: The VT340 also rounds down, but it seems to have a
+	     * strange behavior where, on rare occasions, two newlines are
+	     * required to advance beyond the end of the image.  This appears
+	     * to be a firmware bug, but it should be added as an option for
+	     * compatibility.
 	     */
-	    new_row = (graphic->charrow
+	    new_row = (graphic->charrow - 1
 		       + (((graphic->actual_height * graphic->pixh)
 			   + FontHeight(screen) - 1)
 			  / FontHeight(screen)));
-	    new_col = 0;
+	    new_col = graphic->charcol;
 	}
 
 	TRACE(("setting text position after %dx%d\t%.1f start (%d %d): cursor (%d,%d)\n",
Index: menu.c
--- xterm-373+/menu.c	2022-09-08 22:18:39.000000000 +0000
+++ xterm-374/menu.c	2022-10-07 08:00:53.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: menu.c,v 1.369 2022/09/08 22:18:39 tom Exp $ */
+/* $XTermId: menu.c,v 1.370 2022/10/07 08:00:53 Ben.Wong Exp $ */
 
 /*
  * Copyright 1999-2021,2022 by Thomas E. Dickey
@@ -2344,7 +2344,7 @@
     UpdateCheckbox("update_decsdm",
 		   vtMenuEntries,
 		   vtMenu_sixelscrolling,
-		   (term->keyboard.flags & MODE_DECSDM) != 0);
+		   (term->keyboard.flags & MODE_DECSDM) == 0);
 }
 
 void
Index: minstall.in
--- xterm-373+/minstall.in	2021-01-27 01:36:06.000000000 +0000
+++ xterm-374/minstall.in	2022-10-02 20:13:11.000000000 +0000
@@ -1,9 +1,9 @@
 #!/bin/sh
-# $XTermId: minstall.in,v 1.26 2021/01/27 01:36:06 tom Exp $
+# $XTermId: minstall.in,v 1.27 2022/10/02 20:13:11 tom Exp $
 # -----------------------------------------------------------------------------
 # this file is part of xterm
 #
-# Copyright 2001-2019,2021 by Thomas E. Dickey
+# Copyright 2001-2021,2022 by Thomas E. Dickey
 #
 #                         All Rights Reserved
 #
@@ -126,8 +126,8 @@
 test -z "$X_MANSECT" && X_MANSECT=$suffix
 
 VERSION_H=`echo "$OLD_FILE" | sed -e 's,/[^/]*$,/version.h,' -e s',^[^/]*$,version.h,'`
-PATCH_NUM=`${FGREP-fgrep} XTERM_PATCH "$VERSION_H" | sed -e 's/[^0-9]*//g'`
-PATCH_YMD=`${FGREP-fgrep} XTERM_DATE  "$VERSION_H" | sed -e 's,[^0-9/.-]*,,g'`
+PATCH_NUM=`@FGREP@ XTERM_PATCH "$VERSION_H" | sed -e 's/[^0-9]*//g'`
+PATCH_YMD=`@FGREP@ XTERM_DATE  "$VERSION_H" | sed -e 's,[^0-9/.-]*,,g'`
 
 # Make capitalization variants
 APP_chr0=`echo "$APP_name" | sed -e 's/^\(.\).*/\1/' | tr "$lower" "$upper"`
Index: misc.c
--- xterm-373+/misc.c	2022-09-15 21:00:41.000000000 +0000
+++ xterm-374/misc.c	2022-10-06 22:24:07.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: misc.c,v 1.1022 2022/09/15 21:00:41 tom Exp $ */
+/* $XTermId: misc.c,v 1.1028 2022/10/06 22:24:07 tom Exp $ */
 
 /*
  * Copyright 1999-2021,2022 by Thomas E. Dickey
@@ -1219,13 +1219,13 @@
 {
     if (*param_count == 1) {
 	const char *value = params[0];
-	int need = (int) strlen(value);
-	int used = (int) (VTbuffer->next - VTbuffer->buffer);
-	int have = (int) (VTbuffer->last - VTbuffer->buffer);
+	size_t need = strlen(value);
+	size_t used = (size_t) (VTbuffer->next - VTbuffer->buffer);
+	size_t have = (size_t) (VTbuffer->last - VTbuffer->buffer);
 
-	if (have - used + need < BUF_SIZE) {
+	if ((have - used) + need < (size_t) BUF_SIZE) {
 
-	    fillPtyData(term, VTbuffer, value, (int) strlen(value));
+	    fillPtyData(term, VTbuffer, value, strlen(value));
 
 	    TRACE(("Interpret %s\n", value));
 	    VTbuffer->update++;
@@ -1739,7 +1739,7 @@
 	    memmove(copybuffer + del_cnt,
 		    expansion + hint_len,
 		    strlen(expansion) - hint_len);
-	    v_write(pty, copybuffer, (unsigned) buf_cnt);
+	    v_write(pty, copybuffer, buf_cnt);
 	    /* v_write() just reset our flag */
 	    screen->dabbrev_working = True;
 	    free(copybuffer);
@@ -2559,7 +2559,7 @@
 
     if (screen->logging && !(screen->inhibit & I_LOG)) {
 	Char *cp;
-	int i;
+	size_t i;
 
 #ifdef VMS			/* avoid logging output loops which otherwise occur sometimes
 				   when there is no output and cp/screen->logstart are 1 apart */
@@ -2569,8 +2569,8 @@
 #endif /* VMS */
 	cp = VTbuffer->next;
 	if (screen->logstart != 0
-	    && (i = (int) (cp - screen->logstart)) > 0) {
-	    IGNORE_RC(write(screen->logfd, screen->logstart, (size_t) i));
+	    && (i = (size_t) (cp - screen->logstart)) > 0) {
+	    IGNORE_RC(write(screen->logfd, screen->logstart, i));
 	}
 	screen->logstart = VTbuffer->next;
     }
@@ -3376,93 +3376,85 @@
 	    PDATA('6', CUT_BUFFER6),
 	    PDATA('7', CUT_BUFFER7),
     };
+    char target_used[XtNumber(table)];
+    char select_code[XtNumber(table) + 1];
+    String select_args[XtNumber(table) + 1];
 
     const char *base = buf;
-    Cardinal j, n = 0;
+    Cardinal j;
+    Cardinal num_targets = 0;
 
     TRACE(("Manipulate selection data\n"));
 
+    memset(target_used, 0, sizeof(target_used));
     while (*buf != ';' && *buf != '\0') {
 	++buf;
     }
 
     if (*buf == ';') {
-	char *used;
 
 	*buf++ = '\0';
-
 	if (*base == '\0')
 	    base = "s0";
 
-	if ((used = x_strdup(base)) != 0) {
-	    String *select_args;
-
-	    if ((select_args = TypeCallocN(String, 2 + strlen(base))) != 0) {
-		while (*base != '\0') {
-		    for (j = 0; j < XtNumber(table); ++j) {
-			if (*base == table[j].given) {
-			    used[n] = *base;
-			    select_args[n++] = table[j].result;
-			    TRACE(("atom[%d] %s\n", n, table[j].result));
-			    break;
-			}
+	while (*base != '\0') {
+	    for (j = 0; j < XtNumber(table); ++j) {
+		if (*base == table[j].given) {
+		    if (!target_used[j]) {
+			target_used[j] = 1;
+			select_code[num_targets] = *base;
+			select_args[num_targets++] = table[j].result;
+			TRACE(("atom[%d] %s\n", num_targets, table[j].result));
 		    }
-		    ++base;
+		    break;
 		}
-		used[n] = 0;
+	    }
+	    ++base;
+	}
+	select_code[num_targets] = '\0';
 
-		if (!strcmp(buf, "?")) {
-		    if (AllowWindowOps(xw, ewGetSelection)) {
-			TRACE(("Getting selection\n"));
-			unparseputc1(xw, ANSI_OSC);
-			unparseputs(xw, "52");
-			unparseputc(xw, ';');
-
-			unparseputs(xw, used);
-			unparseputc(xw, ';');
-
-			/* Tell xtermGetSelection data is base64 encoded */
-			screen->base64_paste = n;
-			screen->base64_final = final;
-
-			screen->selection_time =
-			    XtLastTimestampProcessed(TScreenOf(xw)->display);
-
-			/* terminator will be written in this call */
-			xtermGetSelection((Widget) xw,
-					  screen->selection_time,
-					  select_args, n,
-					  NULL);
-			/*
-			 * select_args is used via SelectionReceived, cannot
-			 * free it here.
-			 */
-		    } else {
-			free(select_args);
-		    }
-		} else {
-		    if (AllowWindowOps(xw, ewSetSelection)) {
-			char *old = buf;
+	if (!strcmp(buf, "?")) {
+	    if (AllowWindowOps(xw, ewGetSelection)) {
+		TRACE(("Getting selection\n"));
+		unparseputc1(xw, ANSI_OSC);
+		unparseputs(xw, "52");
+		unparseputc(xw, ';');
+
+		unparseputs(xw, select_code);
+		unparseputc(xw, ';');
+
+		/* Tell xtermGetSelection data is base64 encoded */
+		screen->base64_paste = num_targets;
+		screen->base64_final = final;
+
+		screen->selection_time =
+		    XtLastTimestampProcessed(TScreenOf(xw)->display);
+
+		/* terminator will be written in this call */
+		xtermGetSelection((Widget) xw,
+				  screen->selection_time,
+				  select_args, num_targets,
+				  NULL);
+	    }
+	} else {
+	    if (AllowWindowOps(xw, ewSetSelection)) {
+		char *old = buf;
 
-			TRACE(("Setting selection(%s) with %s\n", used, buf));
-			screen->selection_time =
-			    XtLastTimestampProcessed(TScreenOf(xw)->display);
-
-			for (j = 0; j < n; ++j) {
-			    buf = old;
-			    ClearSelectionBuffer(screen, select_args[j]);
-			    while (*buf != '\0') {
-				AppendToSelectionBuffer(screen,
-							CharOf(*buf++),
-							select_args[j]);
-			    }
-			}
-			CompleteSelection(xw, select_args, n);
+		TRACE(("Setting selection(%s) with %s\n", select_code, buf));
+		screen->selection_time =
+		    XtLastTimestampProcessed(TScreenOf(xw)->display);
+
+		for (j = 0; j < num_targets; ++j) {
+		    buf = old;
+		    ClearSelectionBuffer(screen, select_args[j]);
+		    while (*buf != '\0') {
+			AppendToSelectionBuffer(screen,
+						CharOf(*buf++),
+						select_args[j]);
 		    }
-		    free(select_args);
 		}
+		CompleteSelection(xw, select_args, num_targets);
 	    }
-	    free(used);
 	}
     }
 }
@@ -4033,8 +4025,8 @@
 	    /* FALLTHRU */
 	case 1:
 	    if (*cp != ';') {
-		TRACE(("do_osc did not find semicolon offset %d\n",
-		       (int) (cp - oscbuf)));
+		TRACE(("do_osc did not find semicolon offset %lu\n",
+		       (unsigned long) (cp - oscbuf)));
 		return;
 	    }
 	    state = 2;
@@ -4051,9 +4043,9 @@
 		case 2:
 		    break;
 		default:
-		    TRACE(("do_osc found nonprinting char %02X offset %d\n",
+		    TRACE(("do_osc found nonprinting char %02X offset %lu\n",
 			   CharOf(*cp),
-			   (int) (cp - oscbuf)));
+			   (unsigned long) (cp - oscbuf)));
 		    return;
 		}
 	    }
Index: package/debian/changelog
--- xterm-373+/package/debian/changelog	2022-03-11 19:51:56.000000000 +0000
+++ xterm-374/package/debian/changelog	2022-09-27 08:18:41.000000000 +0000
@@ -1,3 +1,9 @@
+xterm-dev (374) unstable; urgency=low
+
+  * maintenance updates
+
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Tue, 27 Sep 2022 04:18:41 -0400
+
 xterm-dev (373) unstable; urgency=low
 
   * maintenance updates
Index: package/freebsd/Makefile
--- xterm-373+/package/freebsd/Makefile	2022-03-11 19:51:56.000000000 +0000
+++ xterm-374/package/freebsd/Makefile	2022-09-27 08:18:41.000000000 +0000
@@ -1,4 +1,4 @@
-# $XTermId: Makefile,v 1.94 2022/03/11 19:51:56 tom Exp $
+# $XTermId: Makefile,v 1.95 2022/09/27 08:18:41 tom Exp $
 # $FreeBSD: head/x11/xterm/Makefile 492827 2019-02-13 06:43:36Z ehaupt $
 
 # This is adapted from the FreeBSD port, installing as "xterm-dev" with
@@ -7,7 +7,7 @@
 # and "make makesum".
 
 PORTNAME=	xterm
-PORTVERSION=	373
+PORTVERSION=	374
 CATEGORIES=	x11
 MASTER_SITES=	ftp://ftp.invisible-island.net/xterm/:src1 \
 		https://invisible-mirror.net/archives/xterm/:src1
Index: package/pkgsrc/Makefile
--- xterm-373+/package/pkgsrc/Makefile	2022-03-11 19:51:56.000000000 +0000
+++ xterm-374/package/pkgsrc/Makefile	2022-09-27 08:18:41.000000000 +0000
@@ -1,6 +1,6 @@
 # $NetBSD: Makefile,v 1.117 2018/03/12 11:18:00 wiz Exp $
 
-DISTNAME=	xterm-373
+DISTNAME=	xterm-374
 PKGREVISION=	1
 CATEGORIES=	x11
 MASTER_SITES=	ftp://ftp.invisible-island.net/xterm/
Index: package/xterm.spec
--- xterm-373+/package/xterm.spec	2022-03-11 19:51:56.000000000 +0000
+++ xterm-374/package/xterm.spec	2022-09-27 08:18:41.000000000 +0000
@@ -1,11 +1,11 @@
-# $XTermId: xterm.spec,v 1.150 2022/03/11 19:51:56 tom Exp $
+# $XTermId: xterm.spec,v 1.151 2022/09/27 08:18:41 tom Exp $
 Summary: X terminal emulator (development version)
 %global my_middle xterm
 %global my_suffix -dev
 %global fullname %{my_middle}%{my_suffix}
 %global my_class XTermDev
 Name: %{fullname}
-Version: 373
+Version: 374
 Release: 1
 License: X11
 Group: User Interface/X
Index: ptydata.c
--- xterm-373+/ptydata.c	2020-10-12 18:46:28.000000000 +0000
+++ xterm-374/ptydata.c	2022-10-10 19:27:56.000000000 +0000
@@ -1,7 +1,7 @@
-/* $XTermId: ptydata.c,v 1.150 2020/10/12 18:46:28 tom Exp $ */
+/* $XTermId: ptydata.c,v 1.158 2022/10/10 19:27:56 tom Exp $ */
 
 /*
- * Copyright 1999-2019,2020 by Thomas E. Dickey
+ * Copyright 1999-2020,2022 by Thomas E. Dickey
  *
  *                         All Rights Reserved
  *
@@ -68,8 +68,8 @@
 Bool
 decodeUtf8(TScreen *screen, PtyData *data)
 {
-    int i;
-    int length = (int) (data->last - data->next);
+    size_t i;
+    size_t length = (size_t) (data->last - data->next);
     int utf_count = 0;
     unsigned utf_char = 0;
 
@@ -226,8 +226,8 @@
 #if OPT_TRACE > 1
     TRACE(("UTF-8 char %04X [%d..%d]\n",
 	   data->utf_data,
-	   (int) (data->next - data->buffer),
-	   (int) (data->next - data->buffer + data->utf_size - 1)));
+	   (size_t) (data->next - data->buffer),
+	   (size_t) (data->next - data->buffer + data->utf_size - 1)));
 #endif
 
     return (data->utf_size != 0);
@@ -410,10 +410,10 @@
     FlushLog(xw);
 
     if (data->next != data->buffer) {
-	int i;
-	int n = (int) (data->last - data->next);
+	size_t i;
+	size_t n = (size_t) (data->last - data->next);
 
-	TRACE(("shifting buffer down by %d\n", n));
+	TRACE(("shifting buffer down by %lu\n", (unsigned long) n));
 	for (i = 0; i < n; ++i) {
 	    data->buffer[i] = data->next[i];
 	}
@@ -428,16 +428,16 @@
  * and nextPtyData() will return that.
  */
 void
-fillPtyData(XtermWidget xw, PtyData *data, const char *value, int length)
+fillPtyData(XtermWidget xw, PtyData *data, const char *value, size_t length)
 {
-    int size;
-    int n;
+    size_t size;
+    size_t n;
 
     /* remove the used portion of the buffer */
     trimPtyData(xw, data);
 
     VTbuffer->last += length;
-    size = (int) (VTbuffer->last - VTbuffer->next);
+    size = (size_t) (VTbuffer->last - VTbuffer->next);
 
     /* shift the unused portion up to make room */
     for (n = size; n >= length; --n)
@@ -605,20 +605,19 @@
  * Write data back to the PTY
  */
 void
-writePtyData(int f, IChar *d, unsigned len)
+writePtyData(int f, IChar *d, size_t len)
 {
-    unsigned n = (len << 1);
+    size_t n = (len << 1);
 
     if (VTbuffer->write_len <= len) {
 	VTbuffer->write_len = n;
-	VTbuffer->write_buf = (Char *) XtRealloc((char *)
-						 VTbuffer->write_buf, VTbuffer->write_len);
+	VTbuffer->write_buf = realloc(VTbuffer->write_buf, VTbuffer->write_len);
     }
 
     for (n = 0; n < len; n++)
 	VTbuffer->write_buf[n] = (Char) d[n];
 
-    TRACE(("writePtyData %u:%s\n", n,
+    TRACE(("writePtyData %lu:%s\n", (unsigned long) n,
 	   visibleChars(VTbuffer->write_buf, n)));
     v_write(f, VTbuffer->write_buf, n);
 }
@@ -668,7 +667,7 @@
 #endif
 
 void
-v_write(int f, const Char *data, unsigned len)
+v_write(int f, const Char *data, size_t len)
 {
     (void) f;
     (void) data;
@@ -923,8 +922,8 @@
 			    c_in, c_out);
 		} else if (message_level > 1) {
 		    *next = '\0';
-		    printf("TEST %04X (%d:%s) ->%04X\n", c_in,
-			   (int) (next - buffer),
+		    printf("TEST %04X (%lu:%s) ->%04X\n", c_in,
+			   (unsigned long) (next - buffer),
 			   buffer,
 			   c_out);
 		    fflush(stdout);
@@ -937,8 +936,8 @@
 		data->last = next;
 		decodeUtf8(&screen, data);
 		if (message_level > 1) {
-		    printf("TEST %04X (%d:%s) ->%04X\n", c_in,
-			   (int) (next - data->buffer),
+		    printf("TEST %04X (%lu:%s) ->%04X\n", c_in,
+			   (unsigned long) (next - data->buffer),
 			   data->buffer,
 			   data->utf_data);
 		    fflush(stdout);
Index: ptyx.h
--- xterm-373+/ptyx.h	2022-09-23 22:19:42.000000000 +0000
+++ xterm-374/ptyx.h	2022-10-07 08:00:53.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: ptyx.h,v 1.1073 2022/09/23 22:19:42 tom Exp $ */
+/* $XTermId: ptyx.h,v 1.1076 2022/10/07 08:00:53 Ben.Wong Exp $ */
 
 /*
  * Copyright 1999-2021,2022 by Thomas E. Dickey
@@ -1717,9 +1717,9 @@
 	int      update;	/* HandleInterpret */
 #if OPT_WIDE_CHARS
 	IChar    utf_data;	/* resulting character */
-	int      utf_size;	/* ...number of bytes decoded */
+	size_t   utf_size;	/* ...number of bytes decoded */
 	Char    *write_buf;
-	unsigned write_len;
+	size_t   write_len;
 #endif
 	Char     buffer[1];
 } PtyData;
@@ -3313,7 +3313,7 @@
 #define MODE_DECCKM	xBIT(2)	/* private mode 1: cursor keys */
 #define MODE_SRM	xBIT(3)	/* mode 12: send-receive mode */
 #define MODE_DECBKM	xBIT(4)	/* private mode 67: backarrow */
-#define MODE_DECSDM	xBIT(5)	/* private mode 80: sixel scrolling mode */
+#define MODE_DECSDM	xBIT(5)	/* private mode 80: sixel DISPLAY mode -- note, when SDM is off, the terminal is in sixel SCROLLING mode  */
 
 #define N_MARGINBELL	10
 
@@ -3491,7 +3491,8 @@
 #endif
 
 /*
- * Sixel-scrolling is backwards, perhaps from an error in the hardware design.
+ * Sixel scrolling is on when Sixel Display Mode is off, and vice versa.
+ * (Note: DEC erroneously conflates the two in the VT330/340 manual).
  */
 #define SixelScrolling(xw) (!((xw)->keyboard.flags & MODE_DECSDM))
 
Index: run-tic.in
--- /dev/null	2022-10-10 22:47:02.224000000 +0000
+++ xterm-374/run-tic.in	2022-10-02 21:42:36.000000000 +0000
@@ -0,0 +1,138 @@
+#!/bin/sh
+# $XTermId: run-tic.in,v 1.1 2022/10/02 21:42:36 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2006-2021,2022 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# 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, 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 LISTED COPYRIGHT HOLDER(S) 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.
+# -----------------------------------------------------------------------------
+#
+# Run tic, either using ncurses' extension feature or filtering out harmless
+# messages for the extensions which are otherwise ignored by other versions of
+# tic.
+
+USE_NCURSES=20190609
+
+failed() {
+	echo "? $*" >&2
+	exit 1
+}
+
+need_ncurses() {
+	failed "This terminal description relies on ncurses 6.1 $USE_NCURSES"
+}
+
+use_ncurses6() {
+	VER=`infocmp6 -V 2>/dev/null`
+	test -n "$VER" && INFOCMP_PROG=infocmp6
+	VER=`tic6 -V 2>/dev/null`
+	test -n "$VER" && TIC_PROG=tic6
+	test -z "$VER" && need_ncurses
+}
+
+MYTEMP=`mktemp -d 2>/dev/null`
+if test -z "$MYTEMP"
+then
+	MYTEMP=${TMPDIR:-/tmp}/run-tic$$
+fi
+mkdir -p "$MYTEMP" || failed "cannot mkdir $MYTEMP"
+trap "rm -rf $MYTEMP; exit 1" 1 2 3 15
+trap "rm -rf $MYTEMP" 0
+
+STDERR=$MYTEMP/run-tic$$.log
+VER=`tic -V 2>/dev/null`
+OPT=
+
+TIC_PROG=tic
+INFOCMP_PROG=infocmp
+unset TERM
+unset TERMINFO_DIRS
+
+PASS1="$*"
+PASS2="$*"
+
+case "x$VER" in
+*ncurses*)
+	OPT="-x"
+	# Prefer ncurses 6.1 over 6.0 over any 5, if we can get it, to support
+	# large numbers (used in xterm-direct) and large entries (an issue with
+	# xterm-nrc).
+	case "$VER" in
+	*\ [7-9].*|*\ 6.[1-9].20[12][0-9]*)
+		check=`echo "$VER" | sed -e 's/^.*\.//' -e 's/[^0-9].*$//'`
+		[ "$check" -ge "20210626" ] && \
+		[ "$check" -lt "20210828" ] && use_ncurses6
+		[ "$check" -lt "$USE_NCURSES" ] && use_ncurses6
+		;;
+	*)
+		# On systems with only ncurses 5, check for development version
+		# of ncurses.
+		use_ncurses6
+		;;
+	esac
+	echo "** using tic from $VER"
+	# If this is 6.1.20180127 or later and using ABI 6, then it supports
+	# entries larger than 4096 bytes (up to 32768).
+	case "$VER" in
+	*\ [7-9].*|*\ 6.[1-9].20[12][0-9]*)
+		expect="	cols#100000,"
+		cat >"$MYTEMP"/fake.ti <<EOF
+fake|test 32-bit numbers,
+$expect
+EOF
+		TERMINFO="$MYTEMP" $TIC_PROG $OPT "$MYTEMP"/fake.ti 2>/dev/null
+		check=`TERMINFO="$MYTEMP" TERM=fake $INFOCMP_PROG -1 fake 2>/dev/null |grep "$expect"`
+		test "x$check" = "x$expect" || BIG=no
+		;;
+	*)
+		BIG=no
+		;;
+	esac
+	if test "$BIG" = no
+	then
+		# Trim out the SGR 1006 feature, to keep "xterm-nrc" smaller
+		# than 4096 bytes.
+		echo "...this version does not support large terminal descriptions"
+		PASS2=$MYTEMP/input
+		sed -e 's/use=xterm+sm+1006,//' -e '/^[	 ][	 ]*$/d' "$PASS1" >"$PASS2"
+		set "$PASS2"
+	fi
+	;;
+esac
+
+echo "** $TIC_PROG $OPT $PASS1"
+$TIC_PROG $OPT "$PASS2" 2>"$STDERR"
+RET=$?
+
+sed -e "s%$PASS2%$PASS1%" "$STDERR" | \
+@FGREP@ -v 'Unknown Capability' | \
+@FGREP@ -v 'Capability is not recognized:' | \
+@FGREP@ -v 'tic: Warning near line ' >&2
+rm -f "$STDERR"
+
+exit $RET
Index: trace.c
--- xterm-373+/trace.c	2022-09-06 23:55:46.000000000 +0000
+++ xterm-374/trace.c	2022-10-06 20:43:02.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: trace.c,v 1.238 2022/09/06 23:55:46 tom Exp $ */
+/* $XTermId: trace.c,v 1.239 2022/10/06 20:43:02 tom Exp $ */
 
 /*
  * Copyright 1997-2021,2022 by Thomas E. Dickey
@@ -309,17 +309,17 @@
 }
 
 const char *
-visibleChars(const Char *buf, unsigned len)
+visibleChars(const Char *buf, size_t len)
 {
     static char *result;
-    static unsigned used;
+    static size_t used;
 
     if (buf != 0) {
-	unsigned limit = ((len + 1) * 8) + 1;
+	size_t limit = ((len + 1) * 8) + 1;
 
 	if (limit > used) {
 	    used = limit;
-	    result = XtRealloc(result, used);
+	    result = realloc(result, used);
 	}
 	if (result != 0) {
 	    char *dst = result;
@@ -359,17 +359,17 @@
 }
 
 const char *
-visibleIChars(const IChar *buf, unsigned len)
+visibleIChars(const IChar *buf, size_t len)
 {
     static char *result;
-    static unsigned used;
+    static size_t used;
 
     if (buf != 0) {
-	unsigned limit = ((len + 1) * 12) + 1;
+	size_t limit = ((len + 1) * 12) + 1;
 
 	if (limit > used) {
 	    used = limit;
-	    result = XtRealloc(result, used);
+	    result = realloc(result, used);
 	}
 	if (result != 0) {
 	    char *dst = result;
Index: trace.h
--- xterm-373+/trace.h	2022-02-21 22:54:05.000000000 +0000
+++ xterm-374/trace.h	2022-10-06 20:40:49.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: trace.h,v 1.93 2022/02/21 22:54:05 tom Exp $ */
+/* $XTermId: trace.h,v 1.94 2022/10/06 20:40:49 tom Exp $ */
 
 /*
  * Copyright 1997-2021,2022 by Thomas E. Dickey
@@ -69,9 +69,9 @@
 #define TRACE_L "{{"
 #define TRACE_R "}}"
 
-extern	const char * visibleChars(const Char * /* buf */, unsigned /* len */);
+extern	const char * visibleChars(const Char * /* buf */, size_t /* len */);
 extern	const char * visibleEventMode(EventMode);
-extern	const char * visibleIChars(const IChar * /* buf */, unsigned /* len */);
+extern	const char * visibleIChars(const IChar * /* buf */, size_t /* len */);
 extern	const char * visibleUChar(unsigned);
 extern	const char * visibleDblChrset(unsigned /* chrset */);
 extern	const char * visibleEventType (int);
Index: version.h
--- xterm-373+/version.h	2022-09-25 23:03:48.000000000 +0000
+++ xterm-374/version.h	2022-10-10 16:31:27.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: version.h,v 1.524 2022/09/25 23:03:48 tom Exp $ */
+/* $XTermId: version.h,v 1.527 2022/10/10 16:31:27 tom Exp $ */
 
 /*
  * Copyright 1998-2021,2022 by Thomas E. Dickey
@@ -38,8 +38,8 @@
  * version of X to which this version of xterm has been built.  The resulting
  * number in parentheses is my patch number (Thomas E. Dickey).
  */
-#define XTERM_PATCH   373
-#define XTERM_DATE    2022-09-25
+#define XTERM_PATCH   374
+#define XTERM_DATE    2022-10-10
 
 #ifndef __vendorversion__
 #define __vendorversion__ "XTerm"
Index: vms.c
--- xterm-373+/vms.c	2020-01-18 18:32:45.000000000 +0000
+++ xterm-374/vms.c	2022-10-06 19:35:35.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: vms.c,v 1.14 2020/01/18 18:32:45 tom Exp $ */
+/* $XTermId: vms.c,v 1.15 2022/10/06 19:35:35 tom Exp $ */
 
 /*  vms.c
  *
@@ -390,7 +390,7 @@
 
  */
 
-int tt_write(const char *tt_write_buf, int size)
+int tt_write(const char *tt_write_buf, size_t size)
 {
   int status;
   TT_BUF_STRUCT *echoBuff;
Index: vms.h
--- xterm-373+/vms.h	2010-10-11 08:05:35.000000000 +0000
+++ xterm-374/vms.h	2022-10-06 19:37:30.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/xterm/vms.h,v 1.1 2000/02/08 17:19:45 dawes Exp $ */
+/* $XTermId: vms.h,v 1.6 2022/10/06 19:37:30 tom Exp $ */
 
 /* vms.h
  */
@@ -38,4 +38,4 @@
 	int		return_addr;
 } itemlist[MAXITEMLIST];
 
-int tt_write(const char *tt_write_buf,int size);
+int tt_write(const char *tt_write_buf, size_t size);
Index: vttests/256colors2.pl
--- xterm-373+/vttests/256colors2.pl	2020-06-07 22:52:05.000000000 +0000
+++ xterm-374/vttests/256colors2.pl	2022-10-10 17:22:07.000000000 +0000
@@ -1,9 +1,9 @@
 #!/usr/bin/env perl
-# $XTermId: 256colors2.pl,v 1.25 2020/06/07 22:52:05 tom Exp $
+# $XTermId: 256colors2.pl,v 1.26 2022/10/10 17:22:07 tom Exp $
 # -----------------------------------------------------------------------------
 # this file is part of xterm
 #
-# Copyright 1999-2018,2020 by Thomas E. Dickey
+# Copyright 1999-2020,2022 by Thomas E. Dickey
 # Copyright 2002 by Steve Wall
 # Copyright 1999 by Todd Larason
 #
@@ -140,9 +140,16 @@
 }
 
 if ( $opt_8 and $opt_u ) {
-    my $lc_ctype = `locale 2>/dev/null | fgrep LC_CTYPE | sed -e 's/^.*=//'`;
-    if ( $lc_ctype =~ /utf.?8/i ) {
-        binmode( STDOUT, ":utf8" );
+    if ( open( FP, "locale 2>/dev/null |" ) ) {
+        my (@locale) = <FP>;
+        chomp @locale;
+        close(FP);
+        for my $n ( 0 .. $#locale ) {
+            if ( $locale[$n] =~ /^LC_CTYPE=/ ) {
+                binmode( STDOUT, ":utf8" ) if ( $locale[$n] =~ /utf.?8/i );
+                last;
+            }
+        }
     }
 }
 
Index: vttests/88colors2.pl
--- xterm-373+/vttests/88colors2.pl	2020-06-07 22:48:11.000000000 +0000
+++ xterm-374/vttests/88colors2.pl	2022-10-11 00:05:34.000000000 +0000
@@ -1,9 +1,9 @@
 #!/usr/bin/env perl
-# $XTermId: 88colors2.pl,v 1.19 2020/06/07 22:48:11 tom Exp $
+# $XTermId: 88colors2.pl,v 1.22 2022/10/11 00:05:34 tom Exp $
 # -----------------------------------------------------------------------------
 # this file is part of xterm
 #
-# Copyright 1999-2018,2020 by Thomas E. Dickey
+# Copyright 1999-2021,2022 by Thomas E. Dickey
 # Copyright 1999 by Steve Wall
 #
 #                         All Rights Reserved
@@ -141,9 +141,16 @@
 }
 
 if ( $opt_8 and $opt_u ) {
-    my $lc_ctype = `locale 2>/dev/null | fgrep LC_CTYPE | sed -e 's/^.*=//'`;
-    if ( $lc_ctype =~ /utf.?8/i ) {
-        binmode( STDOUT, ":utf8" );
+    if ( open( FP, "locale 2>/dev/null |" ) ) {
+        my (@locale) = <FP>;
+        chomp @locale;
+        close(FP);
+        for my $n ( 0 .. $#locale ) {
+            if ( $locale[$n] =~ /^LC_CTYPE=/ ) {
+                binmode( STDOUT, ":utf8" ) if ( $locale[$n] =~ /utf.?8/i );
+                last;
+            }
+        }
     }
 }
 
Index: vttests/halves.pl
--- xterm-373+/vttests/halves.pl	2007-07-18 01:24:37.000000000 +0000
+++ xterm-374/vttests/halves.pl	2022-10-10 23:59:05.000000000 +0000
@@ -1,9 +1,9 @@
 #!/usr/bin/env perl
-# $XTermId: halves.pl,v 1.6 2007/07/18 01:24:37 tom Exp $
+# $XTermId: halves.pl,v 1.10 2022/10/10 23:59:05 tom Exp $
 # -----------------------------------------------------------------------------
 # this file is part of xterm
 #
-# Copyright 2007 by Thomas E. Dickey
+# Copyright 2007,2022 by Thomas E. Dickey
 #
 #                         All Rights Reserved
 #
@@ -35,133 +35,153 @@
 # overstrike, insert- and delete-characters to see if the double-width
 # characters are completely cleared when "partly" modified.
 use strict;
+use warnings;
 
 use Getopt::Std;
 
-our ($opt_c, $opt_n, $opt_r, $opt_w);
-our ($lineno, $test_string, $term_width);
+our ( $opt_c, $opt_n, $opt_r, $opt_w );
+our ( $lineno, $test_string, $term_width );
 
 # returns the number of columns in the screen
 sub screen_width() {
-	my $data = `resize -u |fgrep COLUMNS=`;
-	$data =~ s/COLUMNS=//;
-	$data =~ s/;//;
-	return $data
+    open( FP, "resize -u |" ) or exit $!;
+    my (@input) = <FP>;
+    chomp @input;
+    close(FP);
+    my $result = 80;
+    for my $n ( 0 .. $#input ) {
+        if ( $input[$n] =~ /^COLUMNS=/ ) {
+            $result = $input[$n];
+            $result =~ s/^[^=]*=//;
+            last;
+        }
+    }
+    return $result;
 }
 
 sub set_color($) {
-	my $code = $_[0];
-	if (defined($opt_c)) {
-		if ($code == 3) {
-			printf "\x1b[1;33;42m";	# yellow-on-green
-		} elsif ($code == 2) {
-			printf "\x1b[0;31;45m";	# red-on-magenta
-		} elsif ($code == 1) {
-			printf "\x1b[0;36;44m";	# cyan-on-blue
-		} else {
-			printf "\x1b[0;39;49m";
-		}
-	}
+    my $code = $_[0];
+    if ( defined($opt_c) ) {
+        if ( $code == 3 ) {
+            printf "\x1b[1;33;42m";    # yellow-on-green
+        }
+        elsif ( $code == 2 ) {
+            printf "\x1b[0;31;45m";    # red-on-magenta
+        }
+        elsif ( $code == 1 ) {
+            printf "\x1b[0;36;44m";    # cyan-on-blue
+        }
+        else {
+            printf "\x1b[0;39;49m";
+        }
+    }
 }
 
 # returns a string of two-column characters given an ASCII alpha/numeric string
 sub double_cells($) {
-	my $value = $_[0];
-	$value =~ s/ /  /g;
-	pack("U*",
-	map { ($_ <= 32 || $_ > 127)      # if non-ASCII character...
-	       ? 32                       # ...just show a blank
-	       : (0xff00 + ($_ - 32))     # map to "Fullwidth Form"
-	} unpack("C*", $value));          # unpack unsigned-char characters
+    my $value = $_[0];
+    $value =~ s/ /  /g;
+    pack(
+        "U*",
+        map {
+            ( $_ <= 32 || $_ > 127 )    # if non-ASCII character...
+              ? 32                      # ...just show a blank
+              : ( 0xff00 + ( $_ - 32 ) )    # map to "Fullwidth Form"
+        } unpack( "C*", $value )
+    );                                      # unpack unsigned-char characters
 }
 
 sub move_to($) {
-	printf "\x1b[%dG", $_[0] + 1;
+    printf "\x1b[%dG", $_[0] + 1;
 }
 
 sub delete_char() {
-	set_color(2);
-	printf "\x1b[%dP", 1;
-	set_color(1);
+    set_color(2);
+    printf "\x1b[%dP", 1;
+    set_color(1);
 }
 
 sub insert_once($) {
-	set_color(2);
-	printf "\x1b[%d@%s", length($_[0]);
-	write_chars($_[0]);
+    set_color(2);
+    printf "\x1b[%d@", length( $_[0] );
+    write_chars( $_[0] );
 }
 
 sub insert_mode($) {
-	set_color(2);
-	printf "\x1b[%dP", length($_[0]);
-	printf "\x1b[4h";
-	write_chars($_[0]);
-	printf "\x1b[4l";
+    set_color(2);
+    printf "\x1b[%dP", length( $_[0] );
+    printf "\x1b[4h";
+    write_chars( $_[0] );
+    printf "\x1b[4l";
 }
 
 sub write_chars($) {
-	set_color(3);
-	printf "%s", $_[0];
-	set_color(1);
+    set_color(3);
+    printf "%s", $_[0];
+    set_color(1);
 }
 
 # vary the starting point of each line, to make a more interesting pattern
 sub starts_of($) {
-	my $value = $_[0];
-	if (defined($opt_w)) {
-		# 0,1,1,2,2,3,3,...
-		$value = (($value + 1) / 2) % length($test_string);
-	} else {
-		$value %= length($test_string);
-	}
-	return $value;
+    my $value = $_[0];
+    if ( defined($opt_w) ) {
+
+        # 0,1,1,2,2,3,3,...
+        $value = ( ( $value + 1 ) / 2 ) % length($test_string);
+    }
+    else {
+        $value %= length($test_string);
+    }
+    return $value;
 }
 
 # write the text for the given line-number
 sub testit($) {
-	my $number = $_[0];
-	my $length = $term_width;
-	if ( defined($opt_n) ) {
-		printf "%5d ", $number % 99999;
-		$length -= 6;
-	}
-	# if we're printing double-column characters, we have half as much
-	# space effectively - but don't forget the remainder, so we can push
-	# the characters by single-columns.
-	if (defined($opt_c)) {
-		set_color(1);
-		printf "\x1b[K";
-	}
-	my $starts = starts_of($number);
-	if ( defined($opt_w) ) {
-		printf " ", if ( ($number % 2 ) != 0);
-		$length = ($length - (($number) % 2)) / 2;
-	}
-	my $string = substr($test_string, $starts);
-	while ( length($string) < $length ) {
-		$string = $string . $test_string;
-	}
-	$string = substr($string, 0, $length);
-	if ( defined($opt_w) ) {
-		$string = double_cells($string);
-	}
-	printf "%s", $string;
-	# now - within the line - modify it
-	move_to((4 * $term_width) / 5);
-	insert_mode("XX");
-	move_to((3 * $term_width) / 5);
-	delete_char();
-	move_to((2 * $term_width) / 5);
-	insert_once('~');
-	move_to((1 * $term_width) / 5);
-	write_chars('~');
-	move_to(0);
-	set_color(0);
-	printf "\n", $string;
+    my $number = $_[0];
+    my $length = $term_width;
+    if ( defined($opt_n) ) {
+        printf "%5d ", $number % 99999;
+        $length -= 6;
+    }
+
+    # if we're printing double-column characters, we have half as much
+    # space effectively - but don't forget the remainder, so we can push
+    # the characters by single-columns.
+    if ( defined($opt_c) ) {
+        set_color(1);
+        printf "\x1b[K";
+    }
+    my $starts = starts_of($number);
+    if ( defined($opt_w) ) {
+        printf " ", if ( ( $number % 2 ) != 0 );
+        $length = ( $length - ( ($number) % 2 ) ) / 2;
+    }
+    my $string = substr( $test_string, $starts );
+    while ( length($string) < $length ) {
+        $string = $string . $test_string;
+    }
+    $string = substr( $string, 0, $length );
+    if ( defined($opt_w) ) {
+        $string = double_cells($string);
+    }
+    printf "%s", $string;
+
+    # now - within the line - modify it
+    move_to( ( 4 * $term_width ) / 5 );
+    insert_mode("XX");
+    move_to( ( 3 * $term_width ) / 5 );
+    delete_char();
+    move_to( ( 2 * $term_width ) / 5 );
+    insert_once('~');
+    move_to( ( 1 * $term_width ) / 5 );
+    write_chars('~');
+    move_to(0);
+    set_color(0);
+    printf "\n";
 }
 
 sub main::HELP_MESSAGE() {
-	printf STDERR <<EOF
+    printf STDERR <<EOF
 Usage: $0 [options]
 
 Options:
@@ -171,25 +191,27 @@
 -r   repeat indefinitely
 -w   write wide-characters
 EOF
-;
-	exit;
+      ;
+    exit;
 }
 
 &getopts('cnrw') || die();
 
 $term_width = screen_width();
 
-$test_string="0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+$test_string =
+  "0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
-binmode(STDOUT, ":utf8");
+binmode( STDOUT, ":utf8" );
 if ( defined($opt_r) ) {
-	for ($lineno = 0; ; ++$lineno) {
-		testit($lineno);
-	}
-} else {
-	for ($lineno = 0; $lineno < 24; ++$lineno) {
-		testit($lineno);
-	}
+    for ( $lineno = 0 ; ; ++$lineno ) {
+        testit($lineno);
+    }
+}
+else {
+    for ( $lineno = 0 ; $lineno < 24 ; ++$lineno ) {
+        testit($lineno);
+    }
 }
 
 exit;
Index: vttests/insdelln.pl
--- xterm-373+/vttests/insdelln.pl	2009-07-02 22:05:30.000000000 +0000
+++ xterm-374/vttests/insdelln.pl	2022-10-10 17:05:38.000000000 +0000
@@ -1,9 +1,9 @@
 #!/usr/bin/env perl
-# $XTermId: insdelln.pl,v 1.6 2009/07/02 22:05:30 tom Exp $
+# $XTermId: vxt-insdelln,v 1.10 2022/10/10 17:05:38 tom Exp $
 # -----------------------------------------------------------------------------
 # this file is part of xterm
 #
-# Copyright 2009 by Thomas E. Dickey
+# Copyright 2009,2022 by Thomas E. Dickey
 #
 #                         All Rights Reserved
 #
@@ -38,190 +38,223 @@
 #	add option to wrap the test-pattern
 #	use scrolling-margins to help fill-in a chunk
 use strict;
+use warnings;
 
 use Getopt::Std;
 
-# do this so outout from successive calls to this script won't get in the
+# do this so output from successive calls to this script won't get in the
 # wrong order:
 use IO::Handle;
 STDERR->autoflush(1);
 STDOUT->autoflush(1);
 
-our ($opt_c, $opt_n, $opt_r, $opt_w);
-our ($lineno, $test_string, $term_height, $term_width);
+our ( $opt_c,  $opt_n,       $opt_r,       $opt_w );
+our ( $lineno, $test_string, $term_height, $term_width );
+
+our @resize;
+
+sub read_resize($) {
+    my $field  = shift;
+    my $result = shift;
+    if ( $#resize < 0 ) {
+        open( FP, "resize -u |" ) or exit $!;
+        @resize = <FP>;
+        chomp @resize;
+        close(FP);
+    }
+    for my $n ( 0 .. $#resize ) {
+        if ( $resize[$n] =~ /^$field=/ ) {
+            $result = $resize[$n];
+            $result =~ s/^[^=]*=//;
+            $result =~ s/;.*//;
+            last;
+        }
+    }
+    return $result;
+}
 
 # returns the number of rows in the screen
 sub screen_height() {
-	my $data = `resize -u |fgrep LINES=`;
-	$data =~ s/LINES=//;
-	$data =~ s/;//;
-	return $data
+    return &read_resize( "LINES", 24 );
 }
 
 # returns the number of columns in the screen
 sub screen_width() {
-	my $data = `resize -u |fgrep COLUMNS=`;
-	$data =~ s/COLUMNS=//;
-	$data =~ s/;//;
-	return $data
+    return &read_resize( "COLUMNS", 80 );
 }
 
 sub set_color($) {
-	my $code = $_[0];
-	if (defined($opt_c)) {
-		if ($code == 3) {
-			printf "\x1b[1;33;42m";	# yellow-on-green
-		} elsif ($code == 2) {
-			printf "\x1b[0;31;45m";	# red-on-magenta
-		} elsif ($code == 1) {
-			printf "\x1b[0;36;44m";	# cyan-on-blue
-		} else {
-			printf "\x1b[0;39;49m";
-		}
-	}
+    my $code = $_[0];
+    if ( defined($opt_c) ) {
+        if ( $code == 3 ) {
+            printf "\x1b[1;33;42m";    # yellow-on-green
+        }
+        elsif ( $code == 2 ) {
+            printf "\x1b[0;31;45m";    # red-on-magenta
+        }
+        elsif ( $code == 1 ) {
+            printf "\x1b[0;36;44m";    # cyan-on-blue
+        }
+        else {
+            printf "\x1b[0;39;49m";
+        }
+    }
 }
 
 # returns a string of two-column characters given an ASCII alpha/numeric string
 sub double_cells($) {
-	my $value = $_[0];
-	$value =~ s/ /  /g;
-	pack("U*",
-	map { ($_ <= 32 || $_ > 127)      # if non-ASCII character...
-	       ? 32                       # ...just show a blank
-	       : (0xff00 + ($_ - 32))     # map to "Fullwidth Form"
-	} unpack("C*", $value));          # unpack unsigned-char characters
+    my $value = $_[0];
+    $value =~ s/ /  /g;
+    pack(
+        "U*",
+        map {
+            ( $_ <= 32 || $_ > 127 )    # if non-ASCII character...
+              ? 32                      # ...just show a blank
+              : ( 0xff00 + ( $_ - 32 ) )    # map to "Fullwidth Form"
+        } unpack( "C*", $value )
+    );                                      # unpack unsigned-char characters
 }
 
 sub clear_screen() {
-	upper_left();
-	printf "\x1b[J";
+    upper_left();
+    printf "\x1b[J";
 }
 
 sub clr_to_eol() {
-	printf "\x1b[K";
+    printf "\x1b[K";
 }
 
 sub lower_left() {
-	printf "\x1b[%dH", $term_height;
+    printf "\x1b[%dH", $term_height;
 }
 
 sub upper_left() {
-	printf "\x1b[H";
+    printf "\x1b[H";
 }
 
 sub move_to($) {
-	printf "\x1b[%dG", $_[0] + 1;
+    printf "\x1b[%dG", $_[0] + 1;
 }
 
 sub insert_lines($) {
-	#lower_left;
-	if ($_[0]) {
-		printf "\x1b[%dL", $_[0];
-	} else {
-		printf "\x1b[L";
-	}
+
+    #lower_left;
+    if ( $_[0] ) {
+        printf "\x1b[%dL", $_[0];
+    }
+    else {
+        printf "\x1b[L";
+    }
 }
 
 sub delete_lines($) {
-	if ($_[0]) {
-		printf "\x1b[%dM", $_[0];
-	} else {
-		printf "\x1b[M";
-	}
+    if ( $_[0] ) {
+        printf "\x1b[%dM", $_[0];
+    }
+    else {
+        printf "\x1b[M";
+    }
 }
 
 sub delete_char() {
-	set_color(2);
-	printf "\x1b[%dP", 1;
-	set_color(1);
+    set_color(2);
+    printf "\x1b[%dP", 1;
+    set_color(1);
 }
 
 sub insert_once($) {
-	set_color(2);
-	printf "\x1b[%d@%s", length($_[0]);
-	write_chars($_[0]);
+    my $text = shift;
+    set_color(2);
+    printf "\x1b[%d@", length($text);
+    write_chars($text);
 }
 
 sub insert_mode($) {
-	set_color(2);
-	printf "\x1b[%dP", length($_[0]);
-	printf "\x1b[4h";
-	write_chars($_[0]);
-	printf "\x1b[4l";
+    set_color(2);
+    printf "\x1b[%dP", length( $_[0] );
+    printf "\x1b[4h";
+    write_chars( $_[0] );
+    printf "\x1b[4l";
 }
 
 sub write_chars($) {
-	set_color(3);
-	printf "%s", $_[0];
-	set_color(1);
+    set_color(3);
+    printf "%s", $_[0];
+    set_color(1);
 }
 
 # vary the starting point of each line, to make a more interesting pattern
 sub starts_of($) {
-	my $value = $_[0];
-	if (defined($opt_w)) {
-		# 0,1,1,2,2,3,3,...
-		$value = (($value + 1) / 2) % length($test_string);
-	} else {
-		$value %= length($test_string);
-	}
-	return $value;
+    my $value = $_[0];
+    if ( defined($opt_w) ) {
+
+        # 0,1,1,2,2,3,3,...
+        $value = ( ( $value + 1 ) / 2 ) % length($test_string);
+    }
+    else {
+        $value %= length($test_string);
+    }
+    return $value;
 }
 
 # write the text for the given line-number
 sub testit($) {
-	my $number = $_[0];
-	my $length = $term_width;
-	# use delete-lines to "pull" the screen up, like scrolling.
-	select(undef, undef, undef, 0.1);
-	if ((($number / $term_height) % 2) != 0) {
-		upper_left;
-		insert_lines(1);
-	} else {
-		upper_left;
-		delete_lines(1);
-		lower_left;
-	}
-	if ( defined($opt_n) ) {
-		printf "%5d ", $number % 99999;
-		$length -= 6;
-	}
-	# if we're printing double-column characters, we have half as much
-	# space effectively - but don't forget the remainder, so we can push
-	# the characters by single-columns.
-	if (defined($opt_c)) {
-		set_color(1);
-		clr_to_eol();
-	}
-	my $starts = starts_of($number);
-	if ( defined($opt_w) ) {
-		printf " ", if ( ($number % 2 ) != 0);
-		$length = ($length - (($number) % 2)) / 2;
-	}
-	my $string = substr($test_string, $starts);
-	while ( length($string) < $length ) {
-		$string = $string . $test_string;
-	}
-	$string = substr($string, 0, $length);
-	if ( defined($opt_w) ) {
-		$string = double_cells($string);
-	}
-	printf "%s", $string;
-	# now - within the line - modify it
-	move_to((4 * $term_width) / 5);
-	insert_mode("XX");
-	move_to((3 * $term_width) / 5);
-	delete_char();
-	move_to((2 * $term_width) / 5);
-	insert_once('~');
-	move_to((1 * $term_width) / 5);
-	write_chars('~');
-	move_to(0);
-	set_color(0);
+    my $number = $_[0];
+    my $length = $term_width;
+
+    # use delete-lines to "pull" the screen up, like scrolling.
+    select( undef, undef, undef, 0.1 );
+    if ( ( ( $number / $term_height ) % 2 ) != 0 ) {
+        upper_left;
+        insert_lines(1);
+    }
+    else {
+        upper_left;
+        delete_lines(1);
+        lower_left;
+    }
+    if ( defined($opt_n) ) {
+        printf "%5d ", $number % 99999;
+        $length -= 6;
+    }
+
+    # if we're printing double-column characters, we have half as much
+    # space effectively - but don't forget the remainder, so we can push
+    # the characters by single-columns.
+    if ( defined($opt_c) ) {
+        set_color(1);
+        clr_to_eol();
+    }
+    my $starts = starts_of($number);
+    if ( defined($opt_w) ) {
+        printf " ", if ( ( $number % 2 ) != 0 );
+        $length = ( $length - ( ($number) % 2 ) ) / 2;
+    }
+    my $string = substr( $test_string, $starts );
+    while ( length($string) < $length ) {
+        $string = $string . $test_string;
+    }
+    $string = substr( $string, 0, $length );
+    if ( defined($opt_w) ) {
+        $string = double_cells($string);
+    }
+    printf "%s", $string;
+
+    # now - within the line - modify it
+    move_to( ( 4 * $term_width ) / 5 );
+    insert_mode("XX");
+    move_to( ( 3 * $term_width ) / 5 );
+    delete_char();
+    move_to( ( 2 * $term_width ) / 5 );
+    insert_once('~');
+    move_to( ( 1 * $term_width ) / 5 );
+    write_chars('~');
+    move_to(0);
+    set_color(0);
 }
 
 sub main::HELP_MESSAGE() {
-	printf STDERR <<EOF
+    printf STDERR <<EOF
 Usage: $0 [options]
 
 Options:
@@ -231,27 +264,29 @@
 -r   repeat indefinitely
 -w   write wide-characters
 EOF
-;
-	exit;
+      ;
+    exit;
 }
 
 &getopts('cnrw') || die();
 
 $term_height = screen_height();
-$term_width = screen_width();
+$term_width  = screen_width();
 
-$test_string="0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+$test_string =
+  "0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
-binmode(STDOUT, ":utf8");
+binmode( STDOUT, ":utf8" );
 clear_screen();
 if ( defined($opt_r) ) {
-	for ($lineno = 0; ; ++$lineno) {
-		testit($lineno);
-	}
-} else {
-	for ($lineno = 0; $lineno < $term_height * 2; ++$lineno) {
-		testit($lineno);
-	}
+    for ( $lineno = 0 ; ; ++$lineno ) {
+        testit($lineno);
+    }
+}
+else {
+    for ( $lineno = 0 ; $lineno < $term_height * 2 ; ++$lineno ) {
+        testit($lineno);
+    }
 }
 lower_left();
 clr_to_eol();
Index: vttests/lrmm-scroll.pl
--- xterm-373+/vttests/lrmm-scroll.pl	2019-07-10 08:22:48.000000000 +0000
+++ xterm-374/vttests/lrmm-scroll.pl	2022-10-10 17:07:48.000000000 +0000
@@ -1,7 +1,7 @@
 #!/usr/bin/env perl
-# $XTermId: lrmm-scroll.pl,v 1.12 2019/07/10 08:22:48 tom Exp $
+# $XTermId: lrmm-scroll.pl,v 1.14 2022/10/10 17:07:48 tom Exp $
 # -----------------------------------------------------------------------------
-# Copyright 2019 by Thomas E. Dickey
+# Copyright 2019,2022 by Thomas E. Dickey
 #
 #                         All Rights Reserved
 #
@@ -40,7 +40,7 @@
 use Term::ReadKey;
 use Getopt::Std;
 
-# do this so outout from successive calls to this script won't get in the
+# do this so output from successive calls to this script won't get in the
 # wrong order:
 use IO::Handle;
 STDERR->autoflush(1);
@@ -52,20 +52,36 @@
 
 our $CSI = "\033[";
 
+our @resize;
+
+sub read_resize($) {
+    my $field  = shift;
+    my $result = shift;
+    if ( $#resize < 0 ) {
+        open( FP, "resize -u |" ) or exit $!;
+        @resize = <FP>;
+        chomp @resize;
+        close(FP);
+    }
+    for my $n ( 0 .. $#resize ) {
+        if ( $resize[$n] =~ /^$field=/ ) {
+            $result = $resize[$n];
+            $result =~ s/^[^=]*=//;
+            $result =~ s/;.*//;
+            last;
+        }
+    }
+    return $result;
+}
+
 # returns the number of rows in the screen
 sub screen_height() {
-    my $data = `resize -u |fgrep LINES=`;
-    $data =~ s/LINES=//;
-    $data =~ s/;//;
-    return $data;
+    return &read_resize( "LINES", 24 );
 }
 
 # returns the number of columns in the screen
 sub screen_width() {
-    my $data = `resize -u |fgrep COLUMNS=`;
-    $data =~ s/COLUMNS=//;
-    $data =~ s/;//;
-    return $data;
+    return &read_resize( "COLUMNS", 80 );
 }
 
 sub set_color($) {
Index: vttests/scroll.pl
--- xterm-373+/vttests/scroll.pl	2009-07-02 23:54:51.000000000 +0000
+++ xterm-374/vttests/scroll.pl	2022-10-10 17:02:54.000000000 +0000
@@ -1,9 +1,9 @@
 #!/usr/bin/env perl
-# $XTermId: scroll.pl,v 1.2 2009/07/02 23:54:51 tom Exp $
+# $XTermId: scroll.pl,v 1.4 2022/10/10 17:02:54 tom Exp $
 # -----------------------------------------------------------------------------
 # this file is part of xterm
 #
-# Copyright 2009 by Thomas E. Dickey
+# Copyright 2009,2022 by Thomas E. Dickey
 #
 #                         All Rights Reserved
 #
@@ -38,189 +38,222 @@
 #	add option to wrap the test-pattern
 #	use scrolling-margins to help fill-in a chunk
 use strict;
+use warnings;
 
 use Getopt::Std;
 
-# do this so outout from successive calls to this script won't get in the
+# do this so output from successive calls to this script won't get in the
 # wrong order:
 use IO::Handle;
 STDERR->autoflush(1);
 STDOUT->autoflush(1);
 
-our ($opt_c, $opt_n, $opt_r, $opt_w);
-our ($lineno, $test_string, $term_height, $term_width, $max_scroll);
+our ( $opt_c, $opt_n, $opt_r, $opt_w );
+our ( $lineno, $test_string, $term_height, $term_width, $max_scroll );
+
+our @resize;
+
+sub read_resize($) {
+    my $field  = shift;
+    my $result = shift;
+    if ( $#resize < 0 ) {
+        open( FP, "resize -u |" ) or exit $!;
+        @resize = <FP>;
+        chomp @resize;
+        close(FP);
+    }
+    for my $n ( 0 .. $#resize ) {
+        if ( $resize[$n] =~ /^$field=/ ) {
+            $result = $resize[$n];
+            $result =~ s/^[^=]*=//;
+            $result =~ s/;.*//;
+            last;
+        }
+    }
+    return $result;
+}
 
 # returns the number of rows in the screen
 sub screen_height() {
-	my $data = `resize -u |fgrep LINES=`;
-	$data =~ s/LINES=//;
-	$data =~ s/;//;
-	return $data
+    return &read_resize( "LINES", 24 );
 }
 
 # returns the number of columns in the screen
 sub screen_width() {
-	my $data = `resize -u |fgrep COLUMNS=`;
-	$data =~ s/COLUMNS=//;
-	$data =~ s/;//;
-	return $data
+    return &read_resize( "COLUMNS", 80 );
 }
 
 sub set_color($) {
-	my $code = $_[0];
-	if (defined($opt_c)) {
-		if ($code == 3) {
-			printf "\x1b[1;33;42m";	# yellow-on-green
-		} elsif ($code == 2) {
-			printf "\x1b[0;31;45m";	# red-on-magenta
-		} elsif ($code == 1) {
-			printf "\x1b[0;36;44m";	# cyan-on-blue
-		} else {
-			printf "\x1b[0;39;49m";
-		}
-	}
+    my $code = $_[0];
+    if ( defined($opt_c) ) {
+        if ( $code == 3 ) {
+            printf "\x1b[1;33;42m";    # yellow-on-green
+        }
+        elsif ( $code == 2 ) {
+            printf "\x1b[0;31;45m";    # red-on-magenta
+        }
+        elsif ( $code == 1 ) {
+            printf "\x1b[0;36;44m";    # cyan-on-blue
+        }
+        else {
+            printf "\x1b[0;39;49m";
+        }
+    }
 }
 
 # returns a string of two-column characters given an ASCII alpha/numeric string
 sub double_cells($) {
-	my $value = $_[0];
-	$value =~ s/ /  /g;
-	pack("U*",
-	map { ($_ <= 32 || $_ > 127)      # if non-ASCII character...
-	       ? 32                       # ...just show a blank
-	       : (0xff00 + ($_ - 32))     # map to "Fullwidth Form"
-	} unpack("C*", $value));          # unpack unsigned-char characters
+    my $value = $_[0];
+    $value =~ s/ /  /g;
+    pack(
+        "U*",
+        map {
+            ( $_ <= 32 || $_ > 127 )    # if non-ASCII character...
+              ? 32                      # ...just show a blank
+              : ( 0xff00 + ( $_ - 32 ) )    # map to "Fullwidth Form"
+        } unpack( "C*", $value )
+    );                                      # unpack unsigned-char characters
 }
 
 sub clear_screen() {
-	upper_left();
-	printf "\x1b[J";
+    upper_left();
+    printf "\x1b[J";
 }
 
 sub clr_to_eol() {
-	printf "\x1b[K";
+    printf "\x1b[K";
 }
 
 sub lower_left() {
-	printf "\x1b[%dH", $term_height;
+    printf "\x1b[%dH", $term_height;
 }
 
 sub upper_left() {
-	printf "\x1b[H";
+    printf "\x1b[H";
 }
 
 sub move_to($) {
-	printf "\x1b[%dG", $_[0] + 1;
+    printf "\x1b[%dG", $_[0] + 1;
 }
 
 sub bak_scroll($) {
-	#lower_left;
-	if ($_[0]) {
-		printf "\x1b[%dS", $_[0];
-	} else {
-		printf "\x1b[S";
-	}
+
+    #lower_left;
+    if ( $_[0] ) {
+        printf "\x1b[%dS", $_[0];
+    }
+    else {
+        printf "\x1b[S";
+    }
 }
 
 sub fwd_scroll($) {
-	if ($_[0]) {
-		printf "\x1b[%dT", $_[0];
-	} else {
-		printf "\x1b[T";
-	}
+    if ( $_[0] ) {
+        printf "\x1b[%dT", $_[0];
+    }
+    else {
+        printf "\x1b[T";
+    }
 }
 
 sub delete_char() {
-	set_color(2);
-	printf "\x1b[%dP", 1;
-	set_color(1);
+    set_color(2);
+    printf "\x1b[%dP", 1;
+    set_color(1);
 }
 
 sub insert_once($) {
-	set_color(2);
-	printf "\x1b[%d@%s", length($_[0]);
-	write_chars($_[0]);
+    my $data = shift;
+    set_color(2);
+    printf "\x1b[%d@%s", length($data), $data;
+    write_chars($data);
 }
 
 sub insert_mode($) {
-	set_color(2);
-	printf "\x1b[%dP", length($_[0]);
-	printf "\x1b[4h";
-	write_chars($_[0]);
-	printf "\x1b[4l";
+    set_color(2);
+    printf "\x1b[%dP", length( $_[0] );
+    printf "\x1b[4h";
+    write_chars( $_[0] );
+    printf "\x1b[4l";
 }
 
 sub write_chars($) {
-	set_color(3);
-	printf "%s", $_[0];
-	set_color(1);
+    set_color(3);
+    printf "%s", $_[0];
+    set_color(1);
 }
 
 # vary the starting point of each line, to make a more interesting pattern
 sub starts_of($) {
-	my $value = $_[0];
-	if (defined($opt_w)) {
-		# 0,1,1,2,2,3,3,...
-		$value = (($value + 1) / 2) % length($test_string);
-	} else {
-		$value %= length($test_string);
-	}
-	return $value;
+    my $value = $_[0];
+    if ( defined($opt_w) ) {
+
+        # 0,1,1,2,2,3,3,...
+        $value = ( ( $value + 1 ) / 2 ) % length($test_string);
+    }
+    else {
+        $value %= length($test_string);
+    }
+    return $value;
 }
 
 # write the text for the given line-number
 sub testit($) {
-	my $number = $_[0];
-	my $length = $term_width;
-	# use delete-lines to "pull" the screen up, like scrolling.
-	select(undef, undef, undef, 0.1);
-	if ((($number / $max_scroll) % 2) != 0) {
-		lower_left;
-		fwd_scroll(1);
-	} else {
-		lower_left;
-		bak_scroll(1);
-	}
-	if ( defined($opt_n) ) {
-		printf "%5d ", $number % 99999;
-		$length -= 6;
-	}
-	# if we're printing double-column characters, we have half as much
-	# space effectively - but don't forget the remainder, so we can push
-	# the characters by single-columns.
-	if (defined($opt_c)) {
-		set_color(1);
-		clr_to_eol();
-	}
-	my $starts = starts_of($number);
-	if ( defined($opt_w) ) {
-		printf " ", if ( ($number % 2 ) != 0);
-		$length = ($length - (($number) % 2)) / 2;
-	}
-	my $string = substr($test_string, $starts);
-	while ( length($string) < $length ) {
-		$string = $string . $test_string;
-	}
-	$string = substr($string, 0, $length);
-	if ( defined($opt_w) ) {
-		$string = double_cells($string);
-	}
-	printf "%s", $string;
-	# now - within the line - modify it
-	move_to((4 * $term_width) / 5);
-	insert_mode("XX");
-	move_to((3 * $term_width) / 5);
-	delete_char();
-	move_to((2 * $term_width) / 5);
-	insert_once('~');
-	move_to((1 * $term_width) / 5);
-	write_chars('~');
-	move_to(0);
-	set_color(0);
+    my $number = $_[0];
+    my $length = $term_width;
+
+    # use delete-lines to "pull" the screen up, like scrolling.
+    select( undef, undef, undef, 0.1 );
+    if ( ( ( $number / $max_scroll ) % 2 ) != 0 ) {
+        lower_left;
+        fwd_scroll(1);
+    }
+    else {
+        lower_left;
+        bak_scroll(1);
+    }
+    if ( defined($opt_n) ) {
+        printf "%5d ", $number % 99999;
+        $length -= 6;
+    }
+
+    # if we're printing double-column characters, we have half as much
+    # space effectively - but don't forget the remainder, so we can push
+    # the characters by single-columns.
+    if ( defined($opt_c) ) {
+        set_color(1);
+        clr_to_eol();
+    }
+    my $starts = starts_of($number);
+    if ( defined($opt_w) ) {
+        printf " ", if ( ( $number % 2 ) != 0 );
+        $length = ( $length - ( ($number) % 2 ) ) / 2;
+    }
+    my $string = substr( $test_string, $starts );
+    while ( length($string) < $length ) {
+        $string = $string . $test_string;
+    }
+    $string = substr( $string, 0, $length );
+    if ( defined($opt_w) ) {
+        $string = double_cells($string);
+    }
+    printf "%s", $string;
+
+    # now - within the line - modify it
+    move_to( ( 4 * $term_width ) / 5 );
+    insert_mode("XX");
+    move_to( ( 3 * $term_width ) / 5 );
+    delete_char();
+    move_to( ( 2 * $term_width ) / 5 );
+    insert_once('~');
+    move_to( ( 1 * $term_width ) / 5 );
+    write_chars('~');
+    move_to(0);
+    set_color(0);
 }
 
 sub main::HELP_MESSAGE() {
-	printf STDERR <<EOF
+    printf STDERR <<EOF
 Usage: $0 [options]
 
 Options:
@@ -230,28 +263,30 @@
 -r   repeat indefinitely
 -w   write wide-characters
 EOF
-;
-	exit;
+      ;
+    exit;
 }
 
 &getopts('cnrw') || die();
 
 $term_height = screen_height();
-$term_width = screen_width();
-$max_scroll = $term_height * 2;
+$term_width  = screen_width();
+$max_scroll  = $term_height * 2;
 
-$test_string="0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+$test_string =
+  "0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
-binmode(STDOUT, ":utf8");
+binmode( STDOUT, ":utf8" );
 clear_screen();
 if ( defined($opt_r) ) {
-	for ($lineno = 0; ; ++$lineno) {
-		testit($lineno);
-	}
-} else {
-	for ($lineno = 0; $lineno < $max_scroll * 2; ++$lineno) {
-		testit($lineno);
-	}
+    for ( $lineno = 0 ; ; ++$lineno ) {
+        testit($lineno);
+    }
+}
+else {
+    for ( $lineno = 0 ; $lineno < $max_scroll * 2 ; ++$lineno ) {
+        testit($lineno);
+    }
 }
 lower_left();
 clr_to_eol();
Index: xterm.appdata.xml
--- xterm-373+/xterm.appdata.xml	2022-09-25 23:04:49.000000000 +0000
+++ xterm-374/xterm.appdata.xml	2022-10-11 00:04:52.000000000 +0000
@@ -35,7 +35,7 @@
     <keyword>terminal</keyword>
   </keywords>
   <releases>
-    <release version="373" date="2022-09-25"/>
+    <release version="374" date="2022-10-10"/>
   </releases>
   <url type="homepage">https://invisible-island.net/xterm/</url>
   <update_contact>dickey@invisible-island.net</update_contact>
Index: xterm.h
--- xterm-373+/xterm.h	2022-09-18 20:47:29.000000000 +0000
+++ xterm-374/xterm.h	2022-10-06 19:48:28.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: xterm.h,v 1.915 2022/09/18 20:47:29 tom Exp $ */
+/* $XTermId: xterm.h,v 1.918 2022/10/06 19:48:28 tom Exp $ */
 
 /*
  * Copyright 1999-2021,2022 by Thomas E. Dickey
@@ -1034,7 +1034,7 @@
 extern void unparseputn (XtermWidget /* xw */, unsigned /* n */);
 extern void unparseputs (XtermWidget /* xw */, const char * /* s */);
 extern void unparseseq (XtermWidget /* xw */, ANSI * /* ap */);
-extern void v_write (int  /* f */, const Char * /* d */, unsigned  /* len */);
+extern void v_write (int  /* f */, const Char * /* d */, size_t  /* len */);
 extern void xtermAddInput (Widget  /* w */);
 extern void xtermDecodeSCS (XtermWidget /* xw */, int /* which */, int /* sgroup */, int /* prefix */, int /* suffix */);
 
@@ -1390,7 +1390,7 @@
 
 extern Bool decodeUtf8 (TScreen * /* screen */, PtyData * /* data */);
 extern int readPtyData (XtermWidget /* xw */, PtySelect * /* select_mask */, PtyData * /* data */);
-extern void fillPtyData (XtermWidget /* xw */, PtyData * /* data */, const char * /* value */, int  /* length */);
+extern void fillPtyData (XtermWidget /* xw */, PtyData * /* data */, const char * /* value */, size_t  /* length */);
 extern void initPtyData (PtyData ** /* data */);
 extern void trimPtyData (XtermWidget /* xw */, PtyData * /* data */);
 
@@ -1405,7 +1405,7 @@
 extern IChar nextPtyData (TScreen * /* screen */, PtyData * /* data */);
 extern PtyData * fakePtyData (PtyData * /* result */, Char * /* next */, Char * /* last */);
 extern void switchPtyData (TScreen * /* screen */, int  /* f */);
-extern void writePtyData (int  /* f */, IChar * /* d */, unsigned  /* len */);
+extern void writePtyData (int  /* f */, IChar * /* d */, size_t  /* len */);
 
 #define morePtyData(screen, data) \
 	(((data)->last > (data)->next) \
Index: xterm.log.html
--- xterm-373+/xterm.log.html	2022-09-25 23:05:09.000000000 +0000
+++ xterm-374/xterm.log.html	2022-10-11 00:04:21.000000000 +0000
@@ -30,7 +30,7 @@
  * sale, use or other dealings in this Software without prior written        *
  * authorization.                                                            *
  *****************************************************************************
-  $XTermId: xterm.log.html,v 1.2437 2022/09/25 23:05:09 tom Exp $
+  $XTermId: xterm.log.html,v 1.2447 2022/10/11 00:04:21 tom Exp $
   -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
 <html>
@@ -70,6 +70,8 @@
   CHANGELOG</a>).</p>
 
   <ul>
+    <li><a href="#xterm_374">Patch #374 - 2022/10/10</a></li>
+
     <li><a href="#xterm_373">Patch #373 - 2022/09/25</a></li>
 
     <li><a href="#xterm_372">Patch #372 - 2022/03/09</a></li>
@@ -1024,6 +1026,47 @@
     <li><a href="#xterm_01">Patch #1 - 1996/1/6</a></li>
   </ul>
 
+  <h1><a name="xterm_374" id="xterm_374">Patch #374 -
+  2022/10/10</a></h1>
+
+  <ul>
+    <li>eliminate use of grep aliases from vttests scripts.</li>
+
+    <li>amend discussion of <code>DECSDM</code> versus <em>Sixel
+    Scrolling</em> in <code>ctlseqs.ms</code> (reports by Hayaki
+    Saito, Ben Wong).</li>
+
+    <li>change default for <code>sixelScrolling</code> resource to
+    better match VT330/VT340 <code>DECSDM</code> setting (patch by
+    Ben Wong).</li>
+
+    <li>fix some gcc and coverity warnings.</li>
+
+    <li>improve memory usage for <tt>OSC&nbsp;52</tt> (report by
+    David Leadbeater).</li>
+
+    <li>fix regression in <a href="#xterm_373">xterm-373</a> change
+    adding resources <tt>xftTrackMemUsage</tt> to
+    <tt>xftMaxGlyphMemory</tt>, which did not first cache the
+    server's resource-settings (report/testcase by Gabor Hauzer, as
+    well as Debian #1021243).</li>
+
+    <li>fix regression in <a href="#xterm_373">xterm-373</a> change
+    for status-line vs alternate screen (report by Rajeev V.
+    Pillai).</li>
+
+    <li>configure script improvements:
+      <ul>
+        <li>modify <tt>CF_XOPEN_SOURCE</tt> to handle more special
+        cases of Linux (reports by Adam Sampson, Sven
+        Joachim).</li>
+
+        <li>modify checks for egrep/fgrep aliases to work around
+        warning messages from GNU grep 3.8</li>
+      </ul>
+    </li>
+  </ul>
+
   <h1><a name="xterm_373" id="xterm_373">Patch #373 -
   2022/09/25</a></h1>
 
Index: xterm.man
--- xterm-373+/xterm.man	2022-09-12 20:46:04.000000000 +0000
+++ xterm-374/xterm.man	2022-10-08 00:17:27.000000000 +0000
@@ -1,5 +1,5 @@
 '\" t
-.\" $XTermId: xterm.man,v 1.863 2022/09/12 20:46:04 tom Exp $
+.\" $XTermId: xterm.man,v 1.864 2022/10/08 00:17:27 tom Exp $
 .\"
 .\" Copyright 1996-2021,2022 by Thomas E. Dickey
 .\"
@@ -5128,7 +5128,10 @@
 this resource tells it whether to
 scroll up one line at a time when sixels would be written
 past the bottom line on the window.
-The default is \*(``false\*('' which enables scrolling.
+The default is \*(``true\*('' which enables scrolling.
+.IP
+Sixel scrolling is the opposite of DEC Sixel Display Mode (DECSDM):
+when one is on, the other is off.
 .TP 8
 .B "sixelScrollsRight\fP (class\fB SixelScrollsRight\fP)"
 If \fI\*n\fR is configured to support SIXEL graphics,
@@ -6694,15 +6697,29 @@
 .
 .TP
 .B Sixel Scrolling\fP (resource \fBsixelScrolling\fP)
+This corresponds to the \fBsixelScrolling\fP resource.
+It can also be turned off and on using the private mode DECSDM
+(Sixel Display Mode).
+.RS
+.bP
 When enabled,
-sixel graphics are positioned at the current text cursor location, scroll
-the image vertically if larger than the screen, and leave the text cursor
-at the start of the next complete line after the image when returning to text
-mode (this is the default).
+\fI\*n\fR draws sixel graphics at the current text cursor location,
+scrolling the image vertically if it is larger than the screen,
+and leaving the text cursor
+at the same column in the next complete line after the image when
+returning to text mode
+.IP
+This is the default,
+which corresponds to the \fIreset\fP state of DECSDM.
+.bP
 When disabled,
-sixel graphics are positioned at the upper left of the screen, are
-cropped to fit the screen, and do not affect the text cursor location.
-This corresponds to the \fBsixelScrolling\fP resource.
+\fI\*n\fR draws sixel graphics starting at the upper left of the screen,
+cropping to fit the screen,
+and does not alter the text cursor location.
+.IP
+This corresponds to the \fIset\fP state of DECSDM.
+.RE
+.IP
 There is no corresponding command-line option.
 .
 .TP
