# ------------------------------------------------------------------------------
 #  Makefile.in    |    2 
 #  aclocal.m4     |   95 +++++++++++--
 #  button.c       |    9 -
 #  charproc.c     |    8 -
 #  configure      |  385 +++++++++++++++++++------------------------------------
 #  ctlseqs.ms     |    4 
 #  fontutils.c    |    7 -
 #  install.sh     |   16 +-
 #  main.c         |  261 +++++++++++++++++++++----------------
 #  mkdirs.sh      |    2 
 #  os2main.c      |   21 ---
 #  termcap        |   24 ++-
 #  terminfo       |   56 +++++++-
 #  version.h      |    2 
 #  xterm.h        |    2 
 #  xterm.log.html |   39 +++++
 #  xterm.man      |    4 
 #  17 files changed, 506 insertions, 431 deletions
 # ------------------------------------------------------------------------------
 Index: Makefile.in
--- xterm-113+/Makefile.in      Sun Aug 22 14:20:13 1999
 +++ xterm-114/Makefile.in       Wed Sep 15 05:40:45 1999
 @@ -9,7 +9,7 @@
 CPP            = @CPP@
 LINK           = $(CC) $(CFLAGS)
 INSTALL                = @INSTALL@
-INSTALL_PROGRAM        = @INSTALL_PROGRAM@
 +INSTALL_PROGRAM        = @INSTALL_PROGRAM@ @XTERM_USR@ @XTERM_GRP@
  INSTALL_DATA   = @INSTALL_DATA@
 
 X_CFLAGS       = @X_CFLAGS@
Index: aclocal.m4
--- xterm-113+/aclocal.m4       Sun Aug 22 14:20:13 1999
 +++ xterm-114/aclocal.m4        Wed Sep 15 22:08:52 1999
 @@ -693,23 +693,34 @@
  [test -n "$verbose" && echo "  $1" 1>&AC_FD_MSG
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl Check if xterm is installed setuid, assume we want to do the same on a
 +dnl Check if xterm is installed setuid/setgid, assume we want to do the same on a
  dnl new install
 AC_DEFUN([CF_XTERM_MODE],[
 AC_PATH_PROG(XTERM_PATH,xterm)
 XTERM_MODE=755
+XTERM_USR=
+XTERM_GRP=
 AC_MSG_CHECKING(for presumed installation-mode)
 if test -f "$XTERM_PATH" ; then
-       ls -Ll $XTERM_PATH >conftest.out
 -       read cf_mode cf_rest <conftest.out
 +       ls -Llg $XTERM_PATH >conftest.out
 +       read cf_mode cf_links XTERM_USR XTERM_GRP cf_rest <conftest.out
         case ".$cf_mode" in #(vi
-       .???s*)
+       .???s*) #(vi
                 XTERM_MODE=4711
                ;;
+       .??????s*)
 +               XTERM_MODE=2711
 +               ;;
         esac
 fi
-AC_MSG_RESULT($XTERM_MODE)
+test "$XTERM_USR" = "root" && XTERM_USR=""
 +test "$XTERM_GRP" = "root" && XTERM_GRP=""
 +AC_MSG_RESULT($XTERM_MODE $XTERM_USR $XTERM_GRP)
 +test -n "$XTERM_USR" && XTERM_USR="-o $XTERM_USR"
 +test -n "$XTERM_GRP" && XTERM_GRP="-g $XTERM_GRP"
  AC_SUBST(XTERM_MODE)
+AC_SUBST(XTERM_USR)
+AC_SUBST(XTERM_GRP)
  ])dnl
 dnl ---------------------------------------------------------------------------
 dnl Check for Xaw (Athena) libraries
@@ -726,21 +737,77 @@
        [  --with-neXtaw           link with neXT Athena library],
        [cf_x_athena=neXtaw])
 
-AC_CHECK_HEADERS(X11/$cf_x_athena/SimpleMenu.h)
 
 AC_CHECK_LIB(Xext,XextCreateExtension,
        [LIBS="-lXext $LIBS"])
 
-AC_CHECK_LIB(Xmu, XmuClientWindow,,[
-AC_CHECK_LIB(Xmu_s, XmuClientWindow)])
 +cf_x_athena_include=""
+cf_x_athena_lib=""
+
+for cf_path in default \
+       /usr/contrib/X11R6 \
 +       /usr/contrib/X11R5 \
 +       /usr/lib/X11R5
 +do
+
+       if test -z "$cf_x_athena_include" ; then
 +               cf_save="$CFLAGS"
 +               cf_test=X11/$cf_x_athena/SimpleMenu.h
 +               if test $cf_path != default ; then
 +                       CFLAGS="-I$cf_path/include $cf_save"
 +                       AC_MSG_CHECKING(for $cf_test in $cf_path)
 +               else
 +                       AC_MSG_CHECKING(for $cf_test)
 +               fi
 +               AC_TRY_COMPILE([
 +#include <X11/Intrinsic.h>
+#include <$cf_test>],[],
 +                       [cf_result=yes],
 +                       [cf_result=no])
 +               AC_MSG_RESULT($cf_result)
 +               if test "$cf_result" = yes ; then
 +                       cf_x_athena_include=$cf_path
 +               else
 +                       CFLAGS="$cf_save"
 +               fi
 +       fi
+
 +       for cf_lib in "-l$cf_x_athena -lXmu" "-l${cf_x_athena}_s -lXmu_s"
 +       do
+               if test -z "$cf_x_athena_lib" ; then
 +                       cf_save="$LIBS"
 +                       cf_test=XawSimpleMenuAddGlobalActions
 +                       if test $cf_path != default ; then
 +                               LIBS="-L$cf_path/lib $cf_lib $LIBS"
 +                               AC_MSG_CHECKING(for $cf_lib in $cf_path)
 +                       else
 +                               LIBS="$cf_lib $LIBS"
 +                               AC_MSG_CHECKING(for $cf_test in $cf_lib)
 +                       fi
 +                       AC_TRY_LINK([],[$cf_test()],
 +                               [cf_result=yes],
 +                               [cf_result=no],
 +                               [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
 +                       AC_MSG_RESULT($cf_result)
 +                       if test "$cf_result" = yes ; then
 +                               cf_x_athena_lib="$cf_lib"
+                       else
 +                               LIBS="$cf_save"
 +                       fi
 +               fi
 +       done
+done
 +
+if test -z "$cf_x_athena_include" ; then
 +       AC_MSG_WARN(
 +[Unable to successfully find Athena header files with test program])
 +fi
 
-AC_CHECK_LIB($cf_x_athena, XawSimpleMenuAddGlobalActions,
 -       [LIBS="-l$cf_x_athena $LIBS"],[
 -AC_CHECK_LIB(${cf_x_athena}_s, XawSimpleMenuAddGlobalActions,
 -       [LIBS="-l${cf_x_athena}_s $LIBS"],
 +if test -z "$cf_x_athena_lib" ; then
         AC_ERROR(
-[Unable to successfully link Athena library (-l$cf_x_athena) with test program]),
 -       [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
 +[Unable to successfully link Athena library (-l$cf_x_athena) with test program])
 +fi
+
 CF_UPPER(CF_X_ATHENA_LIBS,HAVE_LIB_$cf_x_athena)
 AC_DEFINE_UNQUOTED($CF_X_ATHENA_LIBS)
 ])dnl
Index: button.c
--- xterm-113+/button.c Sun Aug 22 14:20:13 1999
 +++ xterm-114/button.c  Wed Sep 15 21:50:53 1999
 @@ -1745,20 +1745,21 @@
           case XA_CUT_BUFFER7: cutbuffer = 7; break;
          default:             cutbuffer = -1;
        }
-       if (cutbuffer >= 0)
 +       if (cutbuffer >= 0) {
             if ( termw->screen.selection_length >
-                4*XMaxRequestSize(XtDisplay((Widget)termw))-32)
 +                4*XMaxRequestSize(XtDisplay((Widget)termw))-32) {
                 fprintf(stderr,
                        "%s: selection too big (%d bytes), not storing in CUT_BUFFER%d\n",
                        xterm_name, termw->screen.selection_length, cutbuffer);
-           else
 +           } else {
               /* Cutbuffers are untyped, so in the wide chars case, we
                 just store the raw UTF-8 data.  It is unlikely it
                 will be useful to anyone. */
                XStoreBuffer( XtDisplay((Widget)termw),
                              termw->screen.selection_data,
                              termw->screen.selection_length, cutbuffer );
-       else if (!replyToEmacs) {
 +           }
 +       } else if (!replyToEmacs) {
             have_selection |=
                XtOwnSelection( (Widget)termw, atoms[i],
                            termw->screen.selection_time,
Index: charproc.c
--- xterm-113+/charproc.c       Sun Aug 22 14:20:13 1999
 +++ xterm-114/charproc.c        Wed Sep 15 06:18:54 1999
 @@ -1583,12 +1583,12 @@
                                  case 8:
                                        term->flags |= INVISIBLE;
                                        break;
-                                case 24:
 -                                       term->flags &= ~UNDERLINE;
 -                                       if_OPT_ISO_COLORS(screen,{setExtendedFG();})
 -                                       break;
                                  case 22: /* reset 'bold' */
                                        term->flags &= ~BOLD;
+                                       if_OPT_ISO_COLORS(screen,{setExtendedFG();})
 +                                       break;
 +                                case 24:
 +                                       term->flags &= ~UNDERLINE;
                                         if_OPT_ISO_COLORS(screen,{setExtendedFG();})
                                        break;
                                 case 25: /* reset 'blink' */
Index: configure
--- xterm-113+/configure        Sun Aug 22 14:20:13 1999
 +++ xterm-114/configure Wed Sep 15 22:09:10 1999
 @@ -3522,49 +3522,9 @@
  fi
 
 
-for ac_hdr in X11/$cf_x_athena/SimpleMenu.h
 -do
-ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
 -echo "configure:3530: checking for $ac_hdr" >&5
 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
 -  echo $ac_n "(cached) $ac_c" 1>&6
 -else
-  cat > conftest.$ac_ext <<EOF
 -#line 3535 "configure"
-#include "confdefs.h"
 -#include <$ac_hdr>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
 -{ (eval echo configure:3540: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 -if test -z "$ac_err"; then
-  rm -rf conftest*
 -  eval "ac_cv_header_$ac_safe=yes"
-else
 -  echo "$ac_err" >&5
-  echo "configure: failed program was:" >&5
 -  cat conftest.$ac_ext >&5
 -  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=no"
 -fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
 -  echo "$ac_t""yes" 1>&6
-    ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
 -  cat >> confdefs.h <<EOF
 -#define $ac_tr_hdr 1
-EOF
- 
-else
-  echo "$ac_t""no" 1>&6
-fi
 -done
-
 
 echo $ac_n "checking for XextCreateExtension in -lXext""... $ac_c" 1>&6
-echo "configure:3568: checking for XextCreateExtension in -lXext" >&5
 +echo "configure:3528: checking for XextCreateExtension in -lXext" >&5
  ac_lib_var=`echo Xext'_'XextCreateExtension | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3572,7 +3532,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXext  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3576 "configure"
+#line 3536 "configure"
  #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3583,7 +3543,7 @@
 XextCreateExtension()
 ; return 0; }
 EOF
-if { (eval echo configure:3587: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
 +if { (eval echo configure:3547: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3604,182 +3564,102 @@
 fi
 
 
-echo $ac_n "checking for XmuClientWindow in -lXmu""... $ac_c" 1>&6
 -echo "configure:3609: checking for XmuClientWindow in -lXmu" >&5
 -ac_lib_var=`echo Xmu'_'XmuClientWindow | sed 'y%./+-%__p_%'`
 -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
 -  echo $ac_n "(cached) $ac_c" 1>&6
 -else
-  ac_save_LIBS="$LIBS"
-LIBS="-lXmu  $LIBS"
 -cat > conftest.$ac_ext <<EOF
 -#line 3617 "configure"
-#include "confdefs.h"
 -/* Override any gcc2 internal prototype to avoid an error.  */
 -/* We use char because int might match the return type of a gcc2
 -    builtin and then its argument prototype would still apply.  */
 -char XmuClientWindow();
-
-int main() {
-XmuClientWindow()
-; return 0; }
-EOF
-if { (eval echo configure:3628: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
 -  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
 -else
-  echo "configure: failed program was:" >&5
 -  cat conftest.$ac_ext >&5
 -  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
 -fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
 -  echo "$ac_t""yes" 1>&6
-    ac_tr_lib=HAVE_LIB`echo Xmu | sed -e 's/[^a-zA-Z0-9_]/_/g' \
 -    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
 -  cat >> confdefs.h <<EOF
 -#define $ac_tr_lib 1
-EOF
-
-  LIBS="-lXmu $LIBS"
+cf_x_athena_include=""
 +cf_x_athena_lib=""
 
-else
-  echo "$ac_t""no" 1>&6
+for cf_path in default \
 +       /usr/contrib/X11R6 \
 +       /usr/contrib/X11R5 \
 +       /usr/lib/X11R5
 +do
 
-echo $ac_n "checking for XmuClientWindow in -lXmu_s""... $ac_c" 1>&6
 -echo "configure:3655: checking for XmuClientWindow in -lXmu_s" >&5
 -ac_lib_var=`echo Xmu_s'_'XmuClientWindow | sed 'y%./+-%__p_%'`
 -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
 -  echo $ac_n "(cached) $ac_c" 1>&6
 -else
-  ac_save_LIBS="$LIBS"
-LIBS="-lXmu_s  $LIBS"
 -cat > conftest.$ac_ext <<EOF
 -#line 3663 "configure"
+       if test -z "$cf_x_athena_include" ; then
 +               cf_save="$CFLAGS"
 +               cf_test=X11/$cf_x_athena/SimpleMenu.h
 +               if test $cf_path != default ; then
 +                       CFLAGS="-I$cf_path/include $cf_save"
 +                       echo $ac_n "checking for $cf_test in $cf_path""... $ac_c" 1>&6
 +echo "configure:3583: checking for $cf_test in $cf_path" >&5
 +               else
 +                       echo $ac_n "checking for $cf_test""... $ac_c" 1>&6
 +echo "configure:3586: checking for $cf_test" >&5
 +               fi
 +               cat > conftest.$ac_ext <<EOF
 +#line 3589 "configure"
 #include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
 -/* We use char because int might match the return type of a gcc2
 -    builtin and then its argument prototype would still apply.  */
 -char XmuClientWindow();
 
+#include <X11/Intrinsic.h>
+#include <$cf_test>
  int main() {
-XmuClientWindow()
-; return 0; }
-EOF
-if { (eval echo configure:3674: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
 -  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
 -else
-  echo "configure: failed program was:" >&5
 -  cat conftest.$ac_ext >&5
 -  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
 -fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
 
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
 -  echo "$ac_t""yes" 1>&6
-    ac_tr_lib=HAVE_LIB`echo Xmu_s | sed -e 's/[^a-zA-Z0-9_]/_/g' \
 -    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
 -  cat >> confdefs.h <<EOF
 -#define $ac_tr_lib 1
-EOF
-
-  LIBS="-lXmu_s $LIBS"
-
 -else
-  echo "$ac_t""no" 1>&6
-fi
 -
-fi
-
-
-echo $ac_n "checking for XawSimpleMenuAddGlobalActions in -l$cf_x_athena""... $ac_c" 1>&6
 -echo "configure:3705: checking for XawSimpleMenuAddGlobalActions in -l$cf_x_athena" >&5
 -ac_lib_var=`echo $cf_x_athena'_'XawSimpleMenuAddGlobalActions | sed 'y%./+-%__p_%'`
 -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
 -  echo $ac_n "(cached) $ac_c" 1>&6
 -else
-  ac_save_LIBS="$LIBS"
-LIBS="-l$cf_x_athena  $LIBS"
 -cat > conftest.$ac_ext <<EOF
 -#line 3713 "configure"
-#include "confdefs.h"
 -/* Override any gcc2 internal prototype to avoid an error.  */
 -/* We use char because int might match the return type of a gcc2
 -    builtin and then its argument prototype would still apply.  */
 -char XawSimpleMenuAddGlobalActions();
-
 -int main() {
-XawSimpleMenuAddGlobalActions()
 ; return 0; }
 EOF
-if { (eval echo configure:3724: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
 +if { (eval echo configure:3598: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
+  cf_result=yes
  else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
+  cf_result=no
  fi
 rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
 -  echo "$ac_t""yes" 1>&6
-  LIBS="-l$cf_x_athena $LIBS"
 -else
-  echo "$ac_t""no" 1>&6
+               echo "$ac_t""$cf_result" 1>&6
 +               if test "$cf_result" = yes ; then
 +                       cf_x_athena_include=$cf_path
 +               else
 +                       CFLAGS="$cf_save"
 +               fi
 +       fi
 
-echo $ac_n "checking for XawSimpleMenuAddGlobalActions in -l${cf_x_athena}_s""... $ac_c" 1>&6
 -echo "configure:3744: checking for XawSimpleMenuAddGlobalActions in -l${cf_x_athena}_s" >&5
 -ac_lib_var=`echo ${cf_x_athena}_s'_'XawSimpleMenuAddGlobalActions | sed 'y%./+-%__p_%'`
 -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
 -  echo $ac_n "(cached) $ac_c" 1>&6
 -else
-  ac_save_LIBS="$LIBS"
-LIBS="-l${cf_x_athena}_s $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
 -cat > conftest.$ac_ext <<EOF
 -#line 3752 "configure"
+       for cf_lib in "-l$cf_x_athena -lXmu" "-l${cf_x_athena}_s -lXmu_s"
 +       do
+               if test -z "$cf_x_athena_lib" ; then
 +                       cf_save="$LIBS"
 +                       cf_test=XawSimpleMenuAddGlobalActions
 +                       if test $cf_path != default ; then
 +                               LIBS="-L$cf_path/lib $cf_lib $LIBS"
 +                               echo $ac_n "checking for $cf_lib in $cf_path""... $ac_c" 1>&6
 +echo "configure:3624: checking for $cf_lib in $cf_path" >&5
 +                       else
 +                               LIBS="$cf_lib $LIBS"
 +                               echo $ac_n "checking for $cf_test in $cf_lib""... $ac_c" 1>&6
 +echo "configure:3628: checking for $cf_test in $cf_lib" >&5
 +                       fi
 +                       cat > conftest.$ac_ext <<EOF
 +#line 3631 "configure"
 #include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
 -/* We use char because int might match the return type of a gcc2
 -    builtin and then its argument prototype would still apply.  */
 -char XawSimpleMenuAddGlobalActions();
 
 int main() {
-XawSimpleMenuAddGlobalActions()
+$cf_test()
 ; return 0; }
 EOF
-if { (eval echo configure:3763: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
 +if { (eval echo configure:3638: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
+  cf_result=yes
  else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
+  cf_result=no
  fi
 rm -f conftest*
-LIBS="$ac_save_LIBS"
+                       echo "$ac_t""$cf_result" 1>&6
 +                       if test "$cf_result" = yes ; then
 +                               cf_x_athena_lib="$cf_lib"
 +                       else
 +                               LIBS="$cf_save"
 +                       fi
 +               fi
 +       done
+done
  
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
 -  echo "$ac_t""yes" 1>&6
-  LIBS="-l${cf_x_athena}_s $LIBS"
 -else
-  echo "$ac_t""no" 1>&6
-{ echo "configure: error: Unable to successfully link Athena library (-l$cf_x_athena) with test program" 1>&2; exit 1; }
 +if test -z "$cf_x_athena_include" ; then
 +       echo "configure: warning: Unable to successfully find Athena header files with test program" 1>&2
  fi
 
+if test -z "$cf_x_athena_lib" ; then
 +       { echo "configure: error: Unable to successfully link Athena library (-l$cf_x_athena) with test program" 1>&2; exit 1; }
  fi
 
 
@@ -3800,12 +3680,12 @@
 for ac_func in grantpt
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3804: checking for $ac_func" >&5
 +echo "configure:3684: checking for $ac_func" >&5
  if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3809 "configure"
+#line 3689 "configure"
  #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3828,7 +3708,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3832: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
 +if { (eval echo configure:3712: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -3850,7 +3730,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for openpty in -lutil""... $ac_c" 1>&6
-echo "configure:3854: checking for openpty in -lutil" >&5
 +echo "configure:3734: checking for openpty in -lutil" >&5
  ac_lib_var=`echo util'_'openpty | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3858,7 +3738,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lutil  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3862 "configure"
+#line 3742 "configure"
  #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3869,7 +3749,7 @@
 openpty()
 ; return 0; }
 EOF
-if { (eval echo configure:3873: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
 +if { (eval echo configure:3753: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3904,7 +3784,7 @@
 # Extract the first word of "xterm", so it can be a program name with args.
 set dummy xterm; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3908: checking for $ac_word" >&5
 +echo "configure:3788: checking for $ac_word" >&5
  if eval "test \"`echo '$''{'ac_cv_path_XTERM_PATH'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3937,18 +3817,29 @@
 fi
 
 XTERM_MODE=755
+XTERM_USR=
+XTERM_GRP=
 echo $ac_n "checking for presumed installation-mode""... $ac_c" 1>&6
-echo "configure:3942: checking for presumed installation-mode" >&5
 +echo "configure:3824: checking for presumed installation-mode" >&5
  if test -f "$XTERM_PATH" ; then
-       ls -Ll $XTERM_PATH >conftest.out
 -       read cf_mode cf_rest <conftest.out
 +       ls -Llg $XTERM_PATH >conftest.out
 +       read cf_mode cf_links XTERM_USR XTERM_GRP cf_rest <conftest.out
         case ".$cf_mode" in #(vi
-       .???s*)
+       .???s*) #(vi
                 XTERM_MODE=4711
                ;;
+       .??????s*)
 +               XTERM_MODE=2711
 +               ;;
         esac
 fi
-echo "$ac_t""$XTERM_MODE" 1>&6
+test "$XTERM_USR" = "root" && XTERM_USR=""
 +test "$XTERM_GRP" = "root" && XTERM_GRP=""
 +echo "$ac_t""$XTERM_MODE $XTERM_USR $XTERM_GRP" 1>&6
 +test -n "$XTERM_USR" && XTERM_USR="-o $XTERM_USR"
 +test -n "$XTERM_GRP" && XTERM_GRP="-g $XTERM_GRP"
 +
+
 
 
 
@@ -3957,12 +3848,12 @@
        
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3961: checking for $ac_func" >&5
 +echo "configure:3852: checking for $ac_func" >&5
  if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3966 "configure"
+#line 3857 "configure"
  #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3985,7 +3876,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3989: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
 +if { (eval echo configure:3880: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4011,7 +3902,7 @@
 
 
 echo $ac_n "checking if we should use imake to help""... $ac_c" 1>&6
-echo "configure:4015: checking if we should use imake to help" >&5
 +echo "configure:3906: checking if we should use imake to help" >&5
  
 # Check whether --enable-imake or --disable-imake was given.
 if test "${enable_imake+set}" = set; then
@@ -4036,7 +3927,7 @@
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4040: checking for $ac_word" >&5
 +echo "configure:3931: checking for $ac_word" >&5
  if eval "test \"`echo '$''{'ac_cv_path_IMAKE'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4175,7 +4066,7 @@
 
 
 echo $ac_n "checking for default terminal-id""... $ac_c" 1>&6
-echo "configure:4179: checking for default terminal-id" >&5
 +echo "configure:4070: checking for default terminal-id" >&5
  
 # Check whether --with-terminal-id or --without-terminal-id was given.
 if test "${with_terminal_id+set}" = set; then
@@ -4196,7 +4087,7 @@
 
 
 echo $ac_n "checking for default terminal-type""... $ac_c" 1>&6
-echo "configure:4200: checking for default terminal-type" >&5
 +echo "configure:4091: checking for default terminal-type" >&5
  
 # Check whether --with-terminal-type or --without-terminal-type was given.
 if test "${with_terminal_type+set}" = set; then
@@ -4213,7 +4104,7 @@
 
 
 echo $ac_n "checking for private terminfo-directory""... $ac_c" 1>&6
-echo "configure:4217: checking for private terminfo-directory" >&5
 +echo "configure:4108: checking for private terminfo-directory" >&5
  
 # Check whether --with-own-terminfo or --without-own-terminfo was given.
 if test "${with_own_terminfo+set}" = set; then
@@ -4250,7 +4141,7 @@
 
 ###    checks for optional features
 echo $ac_n "checking if you want active-icons""... $ac_c" 1>&6
-echo "configure:4254: checking if you want active-icons" >&5
 +echo "configure:4145: checking if you want active-icons" >&5
  
 # Check whether --enable-active-icon or --disable-active-icon was given.
 if test "${enable_active_icon+set}" = set; then
@@ -4276,7 +4167,7 @@
 fi
 
 echo $ac_n "checking if you want ANSI color""... $ac_c" 1>&6
-echo "configure:4280: checking if you want ANSI color" >&5
 +echo "configure:4171: checking if you want ANSI color" >&5
  
 # Check whether --enable-ansi-color or --disable-ansi-color was given.
 if test "${enable_ansi_color+set}" = set; then
@@ -4302,7 +4193,7 @@
 if test $enable_ansi_color = yes ; then
 
        echo $ac_n "checking if you want 16 colors like aixterm""... $ac_c" 1>&6
-echo "configure:4306: checking if you want 16 colors like aixterm" >&5
 +echo "configure:4197: checking if you want 16 colors like aixterm" >&5
         
 # Check whether --enable-16-color or --disable-16-color was given.
 if test "${enable_16_color+set}" = set; then
@@ -4326,7 +4217,7 @@
 
 
        echo $ac_n "checking if you want 256 colors""... $ac_c" 1>&6
-echo "configure:4330: checking if you want 256 colors" >&5
 +echo "configure:4221: checking if you want 256 colors" >&5
         
 # Check whether --enable-256-color or --disable-256-color was given.
 if test "${enable_256_color+set}" = set; then
@@ -4356,7 +4247,7 @@
 fi
 
 echo $ac_n "checking if you want blinking cursor""... $ac_c" 1>&6
-echo "configure:4360: checking if you want blinking cursor" >&5
 +echo "configure:4251: checking if you want blinking cursor" >&5
  
 # Check whether --enable-blink-cursor or --disable-blink-cursor was given.
 if test "${enable_blink_cursor+set}" = set; then
@@ -4382,7 +4273,7 @@
 if test $enable_ansi_color = yes ; then
 
        echo $ac_n "checking if you want bold colors mapped like IBM PC""... $ac_c" 1>&6
-echo "configure:4386: checking if you want bold colors mapped like IBM PC" >&5
 +echo "configure:4277: checking if you want bold colors mapped like IBM PC" >&5
         
 # Check whether --enable-bold-color or --disable-bold-color was given.
 if test "${enable_bold_color+set}" = set; then
@@ -4406,7 +4297,7 @@
 
 
        echo $ac_n "checking if you want color-mode enabled by default""... $ac_c" 1>&6
-echo "configure:4410: checking if you want color-mode enabled by default" >&5
 +echo "configure:4301: checking if you want color-mode enabled by default" >&5
         
 # Check whether --enable-color-mode or --disable-color-mode was given.
 if test "${enable_color_mode+set}" = set; then
@@ -4432,7 +4323,7 @@
 fi
 
 echo $ac_n "checking if you want support for color highlighting""... $ac_c" 1>&6
-echo "configure:4436: checking if you want support for color highlighting" >&5
 +echo "configure:4327: checking if you want support for color highlighting" >&5
  
 # Check whether --enable-highlighting or --disable-highlighting was given.
 if test "${enable_highlighting+set}" = set; then
@@ -4456,7 +4347,7 @@
 
 
 echo $ac_n "checking if you want support for doublesize characters""... $ac_c" 1>&6
-echo "configure:4460: checking if you want support for doublesize characters" >&5
 +echo "configure:4351: checking if you want support for doublesize characters" >&5
  
 # Check whether --enable-doublechars or --disable-doublechars was given.
 if test "${enable_doublechars+set}" = set; then
@@ -4480,7 +4371,7 @@
 
 
 echo $ac_n "checking if you want fallback-support for box characters""... $ac_c" 1>&6
-echo "configure:4484: checking if you want fallback-support for box characters" >&5
 +echo "configure:4375: checking if you want fallback-support for box characters" >&5
  
 # Check whether --enable-boxchars or --disable-boxchars was given.
 if test "${enable_boxchars+set}" = set; then
@@ -4504,7 +4395,7 @@
 
 
 echo $ac_n "checking if you want support for HP-style function keys""... $ac_c" 1>&6
-echo "configure:4508: checking if you want support for HP-style function keys" >&5
 +echo "configure:4399: checking if you want support for HP-style function keys" >&5
  
 # Check whether --enable-hp-fkeys or --disable-hp-fkeys was given.
 if test "${enable_hp_fkeys+set}" = set; then
@@ -4530,7 +4421,7 @@
 fi
 
 echo $ac_n "checking if you want support for internationalization""... $ac_c" 1>&6
-echo "configure:4534: checking if you want support for internationalization" >&5
 +echo "configure:4425: checking if you want support for internationalization" >&5
  
 # Check whether --enable-i18n or --disable-i18n was given.
 if test "${enable_i18n+set}" = set; then
@@ -4556,7 +4447,7 @@
 fi
 
 echo $ac_n "checking if you want support for initial-erase setup""... $ac_c" 1>&6
-echo "configure:4560: checking if you want support for initial-erase setup" >&5
 +echo "configure:4451: checking if you want support for initial-erase setup" >&5
  
 # Check whether --enable-initial-erase or --disable-initial-erase was given.
 if test "${enable_initial_erase+set}" = set; then
@@ -4582,7 +4473,7 @@
 fi
 
 echo $ac_n "checking if you want support for input-method""... $ac_c" 1>&6
-echo "configure:4586: checking if you want support for input-method" >&5
 +echo "configure:4477: checking if you want support for input-method" >&5
  
 # Check whether --enable-input-method or --disable-input-method was given.
 if test "${enable_input_method+set}" = set; then
@@ -4602,13 +4493,13 @@
 echo "$ac_t""$enable_ximp" 1>&6
 
 echo $ac_n "checking if X libraries support input-method""... $ac_c" 1>&6
-echo "configure:4606: checking if X libraries support input-method" >&5
 +echo "configure:4497: checking if X libraries support input-method" >&5
  if eval "test \"`echo '$''{'cf_cv_input_method'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 4612 "configure"
+#line 4503 "configure"
  #include "confdefs.h"
 
 #include <X11/IntrinsicP.h>
@@ -4635,7 +4526,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4639: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
 +if { (eval echo configure:4530: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
   cf_cv_input_method=yes
 else
@@ -4658,7 +4549,7 @@
 fi
 
 echo $ac_n "checking if you want support for logging""... $ac_c" 1>&6
-echo "configure:4662: checking if you want support for logging" >&5
 +echo "configure:4553: checking if you want support for logging" >&5
  
 # Check whether --enable-logging or --disable-logging was given.
 if test "${enable_logging+set}" = set; then
@@ -4682,7 +4573,7 @@
 EOF
 
        echo $ac_n "checking if you want to allow logging via a pipe""... $ac_c" 1>&6
-echo "configure:4686: checking if you want to allow logging via a pipe" >&5
 +echo "configure:4577: checking if you want to allow logging via a pipe" >&5
         
 # Check whether --enable-logfile-exec or --disable-logfile-exec was given.
 if test "${enable_logfile_exec+set}" = set; then
@@ -4709,7 +4600,7 @@
 fi
 
 echo $ac_n "checking if you want support for iconify/maximize translations""... $ac_c" 1>&6
-echo "configure:4713: checking if you want support for iconify/maximize translations" >&5
 +echo "configure:4604: checking if you want support for iconify/maximize translations" >&5
  
 # Check whether --enable-maximize or --disable-maximize was given.
 if test "${enable_maximize+set}" = set; then
@@ -4733,7 +4624,7 @@
 
 
 echo $ac_n "checking if you want NumLock to override keyboard tables""... $ac_c" 1>&6
-echo "configure:4737: checking if you want NumLock to override keyboard tables" >&5
 +echo "configure:4628: checking if you want NumLock to override keyboard tables" >&5
  
 # Check whether --enable-num-lock or --disable-num-lock was given.
 if test "${enable_num_lock+set}" = set; then
@@ -4757,7 +4648,7 @@
 
 
 echo $ac_n "checking if you want support for right-scrollbar""... $ac_c" 1>&6
-echo "configure:4761: checking if you want support for right-scrollbar" >&5
 +echo "configure:4652: checking if you want support for right-scrollbar" >&5
  
 # Check whether --enable-rightbar or --disable-rightbar was given.
 if test "${enable_rightbar+set}" = set; then
@@ -4783,7 +4674,7 @@
 fi
 
 echo $ac_n "checking if you want check for redundant name-change""... $ac_c" 1>&6
-echo "configure:4787: checking if you want check for redundant name-change" >&5
 +echo "configure:4678: checking if you want check for redundant name-change" >&5
  
 # Check whether --enable-samename or --disable-samename was given.
 if test "${enable_samename+set}" = set; then
@@ -4807,7 +4698,7 @@
 
 
 echo $ac_n "checking if you want support for tek4014""... $ac_c" 1>&6
-echo "configure:4811: checking if you want support for tek4014" >&5
 +echo "configure:4702: checking if you want support for tek4014" >&5
  
 # Check whether --enable-tek4014 or --disable-tek4014 was given.
 if test "${enable_tek4014+set}" = set; then
@@ -4837,7 +4728,7 @@
 fi
 
 echo $ac_n "checking if you want pulldown menus with a toolbar""... $ac_c" 1>&6
-echo "configure:4841: checking if you want pulldown menus with a toolbar" >&5
 +echo "configure:4732: checking if you want pulldown menus with a toolbar" >&5
  
 # Check whether --enable-toolbar or --disable-toolbar was given.
 if test "${enable_toolbar+set}" = set; then
@@ -4861,7 +4752,7 @@
 
 
 echo $ac_n "checking if you want VT52 emulation""... $ac_c" 1>&6
-echo "configure:4865: checking if you want VT52 emulation" >&5
 +echo "configure:4756: checking if you want VT52 emulation" >&5
  
 # Check whether --enable-vt52 or --disable-vt52 was given.
 if test "${enable_vt52+set}" = set; then
@@ -4885,7 +4776,7 @@
 
 
 echo $ac_n "checking if you want wide-character support""... $ac_c" 1>&6
-echo "configure:4889: checking if you want wide-character support" >&5
 +echo "configure:4780: checking if you want wide-character support" >&5
  
 # Check whether --enable-wide-chars or --disable-wide-chars was given.
 if test "${enable_wide_chars+set}" = set; then
@@ -4914,7 +4805,7 @@
 fi
 
 echo $ac_n "checking if you want -ziconbeep option""... $ac_c" 1>&6
-echo "configure:4918: checking if you want -ziconbeep option" >&5
 +echo "configure:4809: checking if you want -ziconbeep option" >&5
  
 # Check whether --enable-ziconbeep or --disable-ziconbeep was given.
 if test "${enable_ziconbeep+set}" = set; then
@@ -4939,7 +4830,7 @@
 
 # development/testing aids
 echo $ac_n "checking if you want debugging traces""... $ac_c" 1>&6
-echo "configure:4943: checking if you want debugging traces" >&5
 +echo "configure:4834: checking if you want debugging traces" >&5
  
 # Check whether --enable-trace or --disable-trace was given.
 if test "${enable_trace+set}" = set; then
@@ -4968,7 +4859,7 @@
 
 
 echo $ac_n "checking if you want to see long compiling messages""... $ac_c" 1>&6
-echo "configure:4972: checking if you want to see long compiling messages" >&5
 +echo "configure:4863: checking if you want to see long compiling messages" >&5
  
 # Check whether --enable-echo or --disable-echo was given.
 if test "${enable_echo+set}" = set; then
@@ -5008,7 +4899,7 @@
 
 
 echo $ac_n "checking if you want magic cookie emulation""... $ac_c" 1>&6
-echo "configure:5012: checking if you want magic cookie emulation" >&5
 +echo "configure:4903: checking if you want magic cookie emulation" >&5
  
 # Check whether --enable-xmc-glitch or --disable-xmc-glitch was given.
 if test "${enable_xmc_glitch+set}" = set; then
@@ -5037,7 +4928,7 @@
 
 if test -n "$GCC" ; then
 echo $ac_n "checking if you want to turn on gcc warnings""... $ac_c" 1>&6
-echo "configure:5041: checking if you want to turn on gcc warnings" >&5
 +echo "configure:4932: checking if you want to turn on gcc warnings" >&5
  
 # Check whether --enable-warnings or --disable-warnings was given.
 if test "${enable_warnings+set}" = set; then
@@ -5077,9 +4968,9 @@
 if test -n "$GCC"
 then
        echo "checking for gcc __attribute__ directives" 1>&6
-echo "configure:5081: checking for gcc __attribute__ directives" >&5
 +echo "configure:4972: checking for gcc __attribute__ directives" >&5
         cat > conftest.$ac_ext <<EOF
-#line 5083 "configure"
+#line 4974 "configure"
  #include "confdefs.h"
 #include "conftest.h"
 #include "conftest.i"
@@ -5117,7 +5008,7 @@
 EOF
                        ;;
                esac
-               if { (eval echo configure:5121: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
 +               if { (eval echo configure:5012: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
                         test -n "$verbose" && echo "$ac_t""... $cf_attribute" 1>&6
                        cat conftest.h >>confdefs.h
 #              else
@@ -5134,11 +5025,11 @@
 if test -n "$GCC"
 then
                cat > conftest.$ac_ext <<EOF
-#line 5138 "configure"
+#line 5029 "configure"
  int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
 EOF
                echo "checking for gcc warning options" 1>&6
-echo "configure:5142: checking for gcc warning options" >&5
 +echo "configure:5033: checking for gcc warning options" >&5
         cf_save_CFLAGS="$CFLAGS"
        EXTRA_CFLAGS="-W -Wall"
        cf_warn_CONST=""
@@ -5156,7 +5047,7 @@
                Wstrict-prototypes $cf_warn_CONST
        do
                CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
-               if { (eval echo configure:5160: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
 +               if { (eval echo configure:5051: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
                         test -n "$verbose" && echo "$ac_t""... -$cf_opt" 1>&6
                        EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
                        test "$cf_opt" = Wcast-qual && EXTRA_CFLAGS="$EXTRA_CFLAGS -DXTSTRINGDEFINES"
@@ -5334,6 +5225,8 @@
 s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g
 s%@XTERM_PATH@%$XTERM_PATH%g
 s%@XTERM_MODE@%$XTERM_MODE%g
+s%@XTERM_USR@%$XTERM_USR%g
+s%@XTERM_GRP@%$XTERM_GRP%g
 s%@IMAKE@%$IMAKE%g
 s%@IMAKE_CFLAGS@%$IMAKE_CFLAGS%g
 s%@IMAKE_LOADFLAGS@%$IMAKE_LOADFLAGS%g
Index: ctlseqs.ms
--- xterm-113+/ctlseqs.ms       Sun Jul 18 16:29:08 1999
 +++ xterm-114/ctlseqs.ms        Sun Aug 29 07:44:02 1999
 @@ -1139,7 +1139,7 @@
  0      0       \*(S3\*p
 1      1       \*(S3\*q
 2      2       \*(S3\*r
-3      3       \*(S3\*s
 +3      3       \*(S3\*(cs
  4      4       \*(S3\*t
 5      5       \*(S3\*u
 6      6       \*(S3\*v
@@ -1206,7 +1206,7 @@
 0      0       \*(Es\*?\*p
 1      1       \*(Es\*?\*q
 2      2       \*(Es\*?\*r
-3      3       \*(Es\*?\*s
 +3      3       \*(Es\*?\*(cs
  4      4       \*(Es\*?\*t
 5      5       \*(Es\*?\*u
 6      6       \*(Es\*?\*v
Index: fontutils.c
--- xterm-113+/fontutils.c      Sun Jul  4 15:08:14 1999
 +++ xterm-114/fontutils.c       Wed Sep 15 19:52:41 1999
 @@ -562,10 +562,11 @@
  
 #if OPT_BOX_CHARS
        /*
-        * Xterm uses the first 32 character positions of a font for the
 -        * line-drawing characters.  Check that they are all present.
 +        * Xterm uses character positions 1-31 of a font for the line-drawing
 +        * characters.  Check that they are all present.  The null character
 +        * (0) is special, and is not used.
          */
-       for (ch = 0; ch < 32; ch++) {
 +       for (ch = 1; ch < 32; ch++) {
                 if (xtermMissingChar(ch, nfs)
                 || xtermMissingChar(ch, bfs)) {
                        screen->fnt_boxes = False;
Index: install.sh
--- xterm-113+/install.sh       Wed Jun 23 07:02:33 1999
 +++ xterm-114/install.sh        Tue Sep 14 20:13:55 1999
 @@ -1,4 +1,4 @@
 -#!/bin/sh
+#! /bin/sh
 #
 # install - install a program, script, or datafile
 # This comes from X11R5.
@@ -103,7 +103,7 @@
 if [ x"$dir_arg" != x ]; then
        dst=$src
        src=""
-       
+
         if [ -d $dst ]; then
                instcmd=:
        else
@@ -112,7 +112,7 @@
 else
 
 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad 
 +# might cause directories to be created, which would be especially bad
  # if $src (and thus $dsttmp) contains '*'.
 
        if [ -f $src -o -d $src ]
@@ -122,7 +122,7 @@
                echo "install:  $src does not exist"
                exit 1
        fi
-       
+
         if [ x"$dst" = x ]
        then
                echo "install:  no destination specified"
@@ -189,17 +189,17 @@
 
 # If we're going to rename the final executable, determine the name now.
 
-       if [ x"$transformarg" = x ] 
 +       if [ x"$transformarg" = x ]
         then
                dstfile=`basename $dst`
        else
-               dstfile=`basename $dst $transformbasename | 
 +               dstfile=`basename $dst $transformbasename |
                         sed $transformarg`$transformbasename
        fi
 
 # don't allow the sed command to completely eliminate the filename
 
-       if [ x"$dstfile" = x ] 
 +       if [ x"$dstfile" = x ]
         then
                dstfile=`basename $dst`
        else
@@ -230,7 +230,7 @@
 # Now rename the file to the real destination.
 
        $doit $rmcmd -f $dstdir/$dstfile &&
-       $doit $mvcmd $dsttmp $dstdir/$dstfile 
 +       $doit $mvcmd $dsttmp $dstdir/$dstfile
  
 fi &&
 
Index: main.c
--- xterm-113+/main.c   Sun Aug 22 14:20:13 1999
 +++ xterm-114/main.c    Wed Sep 15 21:51:12 1999
 @@ -3,7 +3,7 @@
  #endif /* lint */
 
 /*
- *                              W A R N I N G
 + *                              W A R N I N G
   *
  * If you think you know what all of this code is doing, you are
  * probably very mistaken.  There be serious and nasty dragons here.
@@ -565,9 +565,9 @@
 static SIGNAL_T reapchild (int n);
 static char *base_name (char *name);
 static int pty_search (int *pty);
-static int remove_termcap_entry (char *buf, char *str);
  static int spawn (void);
 static void get_terminal (void);
+static void remove_termcap_entry (char *buf, char *str);
  static void resize (TScreen *s, char *oldtc, char *newtc);
 
 static Bool added_utmp_entry = False;
@@ -594,6 +594,7 @@
 #endif
 #endif /* USE_SYSV_TERMIO */
 
+#define TERMCAP_ERASE "kb="
 #define VAL_INITIAL_ERASE A2E(127)
 
 /* allow use of system default characters if defined and reasonable */
@@ -664,15 +665,15 @@
 static struct termios d_tio;
 #else /* !USE_SYSV_TERMIO && !USE_POSIX_TERMIOS */
 static struct  sgttyb d_sg = {
-        0, 0, 0177, CKILL, EVENP|ODDP|ECHO|XTABS|CRMOD
 +       0, 0, 0177, CKILL, EVENP|ODDP|ECHO|XTABS|CRMOD
  };
 static struct  tchars d_tc = {
-        CINTR, CQUIT, CSTART,
 -        CSTOP, CEOF, CBRK
 +       CINTR, CQUIT, CSTART,
 +       CSTOP, CEOF, CBRK
  };
 static struct  ltchars d_ltc = {
-        CSUSP, CDSUSP, CRPRNT,
 -        CFLUSH, CWERASE, CLNEXT
 +       CSUSP, CDSUSP, CRPRNT,
 +       CFLUSH, CWERASE, CLNEXT
  };
 static int d_disipline = NTTYDISC;
 static long int d_lmode = LCRTBS|LCRTERA|LCRTKIL|LCTLECH;
@@ -861,7 +862,7 @@
     {"ptyInitialErase", "PtyInitialErase", XtRBoolean, sizeof (Boolean),
        offset(ptyInitialErase), XtRString, "false"},
     {"backarrowKeyIsErase", "BackarrowKeyIsErase", XtRBoolean, sizeof(Boolean),
-        offset(backarrow_is_erase), XtRString, "false"},
 +       offset(backarrow_is_erase), XtRString, "false"},
  #endif
     {"waitForMap", "WaitForMap", XtRBoolean, sizeof (Boolean),
        offset(wait_for_map), XtRString, "false"},
@@ -1245,12 +1246,12 @@
        Cardinal *num_params GCC_UNUSED)
 {
 #if OPT_TEK4014
-  if (w == toplevel)
+  if (w == toplevel) {
      if (term->screen.Tshow)
       hide_vt_window();
     else
       do_hangup(w, (XtPointer)0, (XtPointer)0);
-  else
+  } else
     if (term->screen.Vshow)
       hide_tek_window();
     else
@@ -1312,7 +1313,7 @@
 #endif
        {
            fprintf (stderr,
-                    "%s:  unable to allocate memory for ttydev or ptydev\n",
 +                    "%s:  unable to allocate memory for ttydev or ptydev\n",
                      ProgramName);
            exit (1);
        }
@@ -1355,12 +1356,12 @@
 #ifdef ONLCR
        d_tio.c_oflag = OPOST|ONLCR;
 #else
-        d_tio.c_oflag = OPOST;
 +       d_tio.c_oflag = OPOST;
  #endif
 #endif
 #if defined(macII) || defined(ATT) || defined(CRAY) /* { */
-       d_tio.c_cflag = B9600|CS8|CREAD|PARENB|HUPCL;
 -       d_tio.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
 +       d_tio.c_cflag = B9600|CS8|CREAD|PARENB|HUPCL;
 +       d_tio.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
  #ifdef ECHOKE
        d_tio.c_lflag |= ECHOKE|IEXTEN;
 #endif
@@ -1376,7 +1377,7 @@
        d_tio.c_cc[VQUIT] = CQUIT;
        d_tio.c_cc[VERASE] = CERASE;
        d_tio.c_cc[VKILL] = CKILL;
-       d_tio.c_cc[VEOF] = CEOF;
 +       d_tio.c_cc[VEOF] = CEOF;
         d_tio.c_cc[VEOL] = CNUL;
        d_tio.c_cc[VEOL2] = CNUL;
 #ifdef VSWTCH
@@ -1396,12 +1397,12 @@
        d_tio.c_cc[VTIME] = 0;
 #endif /* } */
 #ifdef HAS_LTCHARS /* { */
-        d_ltc.t_suspc = CSUSP;         /* t_suspc */
 -        d_ltc.t_dsuspc = CDSUSP;       /* t_dsuspc */
 -        d_ltc.t_rprntc = CRPRNT;
 -        d_ltc.t_flushc = CFLUSH;
 -        d_ltc.t_werasc = CWERASE;
 -        d_ltc.t_lnextc = CLNEXT;
 +       d_ltc.t_suspc = CSUSP;          /* t_suspc */
 +       d_ltc.t_dsuspc = CDSUSP;        /* t_dsuspc */
 +       d_ltc.t_rprntc = CRPRNT;
 +       d_ltc.t_flushc = CFLUSH;
 +       d_ltc.t_werasc = CWERASE;
 +       d_ltc.t_lnextc = CLNEXT;
  #endif /* } HAS_LTCHARS */
 #ifdef TIOCLSET /* { */
        d_lmode = 0;
@@ -1409,16 +1410,16 @@
 #else  /* }{ else !macII, ATT, CRAY */
 #ifndef USE_POSIX_TERMIOS
 #ifdef BAUD_0 /* { */
-       d_tio.c_cflag = CS8|CREAD|PARENB|HUPCL;
 +       d_tio.c_cflag = CS8|CREAD|PARENB|HUPCL;
  #else  /* }{ !BAUD_0 */
-       d_tio.c_cflag = B9600|CS8|CREAD|PARENB|HUPCL;
 +       d_tio.c_cflag = B9600|CS8|CREAD|PARENB|HUPCL;
  #endif /* } !BAUD_0 */
 #else /* USE_POSIX_TERMIOS */
        d_tio.c_cflag = CS8|CREAD|PARENB|HUPCL;
        cfsetispeed(&d_tio, B9600);
        cfsetospeed(&d_tio, B9600);
 #endif
-       d_tio.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
 +       d_tio.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
  #ifdef ECHOKE
        d_tio.c_lflag |= ECHOKE|IEXTEN;
 #endif
@@ -1427,20 +1428,20 @@
 #endif
 #ifndef USE_POSIX_TERMIOS
 #ifdef NTTYDISC
-        d_tio.c_line = NTTYDISC;
 +       d_tio.c_line = NTTYDISC;
  #else
        d_tio.c_line = 0;
 #endif
 #endif /* USE_POSIX_TERMIOS */
 #ifdef __sgi
-        d_tio.c_cflag &= ~(HUPCL|PARENB);
 -        d_tio.c_iflag |= BRKINT|ISTRIP|IGNPAR;
 +       d_tio.c_cflag &= ~(HUPCL|PARENB);
 +       d_tio.c_iflag |= BRKINT|ISTRIP|IGNPAR;
  #endif
        d_tio.c_cc[VINTR] = CONTROL('C');       /* '^C' */
        d_tio.c_cc[VERASE] = 0x7f;              /* DEL  */
        d_tio.c_cc[VKILL] = CONTROL('U');       /* '^U' */
        d_tio.c_cc[VQUIT] = CQUIT;              /* '^\' */
-       d_tio.c_cc[VEOF] = CEOF;                /* '^D' */
 +       d_tio.c_cc[VEOF] = CEOF;                /* '^D' */
         d_tio.c_cc[VEOL] = CEOL;                /* '^@' */
        d_tio.c_cc[VMIN] = 1;
        d_tio.c_cc[VTIME] = 0;
@@ -1543,12 +1544,12 @@
            }
        }
 #ifdef HAS_LTCHARS /* { */
-        d_ltc.t_suspc = '\000';                /* t_suspc */
 -        d_ltc.t_dsuspc = '\000';       /* t_dsuspc */
 -        d_ltc.t_rprntc = '\377';       /* reserved...*/
 -        d_ltc.t_flushc = '\377';
 -        d_ltc.t_werasc = '\377';
 -        d_ltc.t_lnextc = '\377';
 +       d_ltc.t_suspc = '\000';         /* t_suspc */
 +       d_ltc.t_dsuspc = '\000';        /* t_dsuspc */
 +       d_ltc.t_rprntc = '\377';        /* reserved...*/
 +       d_ltc.t_flushc = '\377';
 +       d_ltc.t_werasc = '\377';
 +       d_ltc.t_lnextc = '\377';
  #endif /* } HAS_LTCHARS */
 #if defined(USE_TERMIOS) || defined(USE_POSIX_TERMIOS) /* { */
        d_tio.c_cc[VSUSP] = CSUSP;
@@ -1659,7 +1660,7 @@
        }
 #endif /* OPT_ZICONBEEP */
 #if OPT_SAME_NAME
-        sameName = resource.sameName;
 +       sameName = resource.sameName;
  #endif
        xterm_name = resource.xterm_name;
        sunFunctionKeys = resource.sunFunctionKeys;
@@ -1742,7 +1743,7 @@
 
        SetupMenus(toplevel, &form_top, &menu_top);
 
-        term = (XtermWidget) XtVaCreateManagedWidget(
 +       term = (XtermWidget) XtVaCreateManagedWidget(
                 "vt100", xtermWidgetClass, form_top,
 #if OPT_TOOLBAR
                XtNmenuBar,     menu_top,
@@ -1755,7 +1756,7 @@
                0);
            /* this causes the initialize method to be called */
 
-        screen = &term->screen;
 +       screen = &term->screen;
  
        inhibit = 0;
 #ifdef ALLOWLOGGING
@@ -1958,7 +1959,7 @@
        int tty;
        return (openpty(pty, &tty, ttydev, NULL, NULL));
 #elif defined(SYSV) && defined(i386) && !defined(SVR4)
-        /*
+       /*
           The order of this code is *important*.  On SYSV/386 we want to open
          a /dev/ttyp? first if at all possible.  If none are available, then
          we'll try to open a /dev/pts??? device.
@@ -2278,6 +2279,18 @@
 #ifndef AMOEBA
 extern char **environ;
 
+static void
+set_owner(char *device, int uid, int gid, int mode)
 +{
+       if (chown (device, uid, gid) < 0) {
 +               if (getuid() == 0) {
 +                       fprintf(stderr, "Cannot chown %s to %d,%d: %s\n",
 +                               device, uid, gid, strerror(errno));
 +               }
 +       }
+       chmod (device, mode);
 +}
+
 static int
 spawn (void)
 /*
@@ -2375,7 +2388,7 @@
 
                signal(SIGALRM, hungtty);
                alarm(2);               /* alarm(1) might return too soon */
-               if (! sigsetjmp(env, 1)) {
 +              if (! sigsetjmp(env, 1)) {
                         tty = open ("/dev/tty", O_RDWR, 0);
                        alarm(0);
                        tty_got_hung = False;
@@ -2471,6 +2484,11 @@
                        if (initial_erase == 0177) {    /* see input.c */
                                term->keyboard.flags &= ~MODE_DECBKM;
                        }
+                       TRACE(("%s @%d, ptyInitialErase:%d, backspace_is_erase:%d, initial_erase:%d\n",
 +                               __FILE__, __LINE__,
 +                               resource.ptyInitialErase,
 +                               resource.backarrow_is_erase,
 +                               initial_erase))
  #endif
 
 #ifdef MINIX
@@ -2484,7 +2502,7 @@
                        tty = -1;
                }
 
-#ifdef         PUCC_PTYD
 +#ifdef PUCC_PTYD
                if(-1 == (screen->respond = openrpty(ttydev, ptydev,
                                (resource.utmpInhibit ?  OPTY_NOP : OPTY_LOGIN),
                                getuid(), XDisplayString(screen->display))))
@@ -2579,8 +2597,12 @@
        }
 
 #if OPT_INITIAL_ERASE
+       TRACE(("%s @%d, resource ptyInitialErase:%d, backspace_is_erase:%d\n",
 +               __FILE__, __LINE__,
 +               resource.ptyInitialErase,
 +               resource.backarrow_is_erase))
         if (!resource.ptyInitialErase && *newtc) {
-               char *s = strstr(newtc, "kD=");
 +               char *s = strstr(newtc, TERMCAP_ERASE);
                 TRACE(("extracting initial_erase value from termcap\n"))
                if (s != 0) {
                        s += 3;
@@ -2600,6 +2622,7 @@
                        }
                        initial_erase = CharOf(initial_erase);
                }
+               TRACE(("... initial_erase:%d\n", initial_erase))
         }
 #endif
 
@@ -2655,7 +2678,7 @@
 
 #ifdef USE_USG_PTYS
 #if defined(SYSV) && defined(i386) && !defined(SVR4)
-                if (IsPts) {   /* SYSV386 supports both, which did we open? */
 +               if (IsPts) {    /* SYSV386 supports both, which did we open? */
  #endif /* SYSV && i386 && !SVR4 */
                int ptyfd;
 
@@ -2686,24 +2709,24 @@
                tty = ptyfd;
                close (screen->respond);
 #ifdef TIOCSWINSZ
-                /* tell tty how big window is */
 +               /* tell tty how big window is */
  #if OPT_TEK4014
-                if(TEK4014_ACTIVE(screen)) {
 -                        ws.ws_row = 24;
 -                        ws.ws_col = 80;
 -                        ws.ws_xpixel = TFullWidth(screen);
 -                        ws.ws_ypixel = TFullHeight(screen);
 -                } else
 +               if(TEK4014_ACTIVE(screen)) {
 +                       ws.ws_row = 24;
 +                       ws.ws_col = 80;
 +                       ws.ws_xpixel = TFullWidth(screen);
 +                       ws.ws_ypixel = TFullHeight(screen);
 +               } else
  #endif
                {
-                        ws.ws_row = screen->max_row + 1;
 -                        ws.ws_col = screen->max_col + 1;
 -                        ws.ws_xpixel = FullWidth(screen);
 -                        ws.ws_ypixel = FullHeight(screen);
 -                }
 +                       ws.ws_row = screen->max_row + 1;
 +                       ws.ws_col = screen->max_col + 1;
 +                       ws.ws_xpixel = FullWidth(screen);
 +                       ws.ws_ypixel = FullHeight(screen);
 +               }
  #endif
 #if defined(SYSV) && defined(i386) && !defined(SVR4)
-                } else {       /* else pty, not pts */
 +               } else {        /* else pty, not pts */
  #endif /* SYSV && i386 && !SVR4 */
 #endif /* USE_USG_PTYS */
 
@@ -2825,7 +2848,7 @@
                        (void) strcpy(ttydev, ptr);
                }
 #if defined(SYSV) && defined(i386) && !defined(SVR4)
-                } /* end of IsPts else clause */
 +               } /* end of IsPts else clause */
  #endif /* SYSV && i386 && !SVR4 */
 
 #endif /* USE_HANDSHAKE -- from near fork */
@@ -2835,22 +2858,17 @@
                struct group *ttygrp;
                if ((ttygrp = getgrnam("tty")) != 0) {
                        /* change ownership of tty to real uid, "tty" gid */
-                       chown (ttydev, screen->uid, ttygrp->gr_gid);
 -                       chmod (ttydev, 0620);
 +                       set_owner (ttydev, screen->uid, ttygrp->gr_gid, 0620);
                 }
                else {
                        /* change ownership of tty to real group and user id */
-                       chown (ttydev, screen->uid, screen->gid);
 -                       chmod (ttydev, 0622);
 +                       set_owner (ttydev, screen->uid, screen->gid, 0622);
                 }
                endgrent();
        }
 #else /* else !USE_TTY_GROUP */
                /* change ownership of tty to real group and user id */
-               chown (ttydev, screen->uid, screen->gid);
 -
-               /* change protection of tty */
 -               chmod (ttydev, 0622);
 +               set_owner (ttydev, screen->uid, screen->gid, 0622);
  #endif /* USE_TTY_GROUP */
 
                /*
@@ -3126,6 +3144,11 @@
                signal (SIGTERM, SIG_DFL);
 
 #if OPT_INITIAL_ERASE
+               TRACE(("%s @%d, ptyInitialErase:%d, overide_tty_modes:%d, XTTYMODE_erase:%d\n",
 +                       __FILE__, __LINE__,
 +                       resource.ptyInitialErase,
 +                       override_tty_modes,
 +                       ttymodelist[XTTYMODE_erase].set))
                 if (! resource.ptyInitialErase
                 && !override_tty_modes
                 && !ttymodelist[XTTYMODE_erase].set) {
@@ -3520,24 +3543,24 @@
                    resize (screen, termcap, newtc);
                }
                if (term->misc.titeInhibit) {
-                   remove_termcap_entry (newtc, ":ti=");
 -                   remove_termcap_entry (newtc, ":te=");
 +                   remove_termcap_entry (newtc, "ti=");
 +                   remove_termcap_entry (newtc, "te=");
                 }
                /*
                 * work around broken termcap entries */
                if (resource.useInsertMode)     {
-                   remove_termcap_entry (newtc, ":ic=");
 +                   remove_termcap_entry (newtc, "ic=");
                     /* don't get duplicates */
-                   remove_termcap_entry (newtc, ":im=");
 -                   remove_termcap_entry (newtc, ":ei=");
 -                   remove_termcap_entry (newtc, ":mi");
 +                   remove_termcap_entry (newtc, "im=");
 +                   remove_termcap_entry (newtc, "ei=");
 +                   remove_termcap_entry (newtc, "mi");
                     if(*newtc)
                        strcat (newtc, ":im=\\E[4h:ei=\\E[4l:mi:");
                }
 #if OPT_INITIAL_ERASE
-               remove_termcap_entry (newtc, ":kD=");
                 if (*newtc) {
-                   sprintf(newtc + strlen(newtc), ":kD=\\%03o", initial_erase & 0377);
 +                   remove_termcap_entry (newtc, TERMCAP_ERASE);
 +                   sprintf(newtc + strlen(newtc), ":%s\\%03o", TERMCAP_ERASE, initial_erase & 0377);
                 }
 #endif
                if(*newtc)
@@ -3728,7 +3751,7 @@
        signal (SIGINT, Exit);
        signal (SIGQUIT, Exit);
        signal (SIGTERM, Exit);
-        signal (SIGPIPE, Exit);
 +       signal (SIGPIPE, Exit);
  #endif /* USE_SYSV_SIGNALS and not SIGTSTP */
 
        return 0;
@@ -3776,11 +3799,11 @@
        char programpath[1024];
 
        if ((path = getenv("PATH")) == NULL)
-           path = DEF_PATH;
 +           path = DEF_PATH;
         if ((name = strrchr(program, '/')) != NULL)
-           name++;
 +           name++;
         else
-           name = program;
 +           name = program;
  
        do {
            register char *p = programpath;
@@ -3974,16 +3997,16 @@
        resize (screen, termcap, newtc);
     }
     if (term->misc.titeInhibit) {
-       remove_termcap_entry (newtc, ":ti=");
 -       remove_termcap_entry (newtc, ":te=");
 +       remove_termcap_entry (newtc, "ti=");
 +       remove_termcap_entry (newtc, "te=");
      }
     /* work around broken termcap entries */
     if (resource.useInsertMode) {
-       remove_termcap_entry (newtc, ":ic=");
 +       remove_termcap_entry (newtc, "ic=");
         /* don't get duplicates */
-       remove_termcap_entry (newtc, ":im=");
 -       remove_termcap_entry (newtc, ":ei=");
 -       remove_termcap_entry (newtc, ":mi");
 +       remove_termcap_entry (newtc, "im=");
 +       remove_termcap_entry (newtc, "ei=");
 +       remove_termcap_entry (newtc, "mi");
         if (*newtc)
            strcat (newtc, ":im=\\E[4h:ei=\\E[4l:mi:");
     }
@@ -4016,11 +4039,11 @@
        char *argvec[2];
 
        if ((shell = getenv("SHELL")) == NULL)
-           shell = DEF_SHELL; /* "cannot happen" */
 +           shell = DEF_SHELL; /* "cannot happen" */
         if ((shname = strrchr(shell, '/')) != NULL)
-           shname++;
 +           shname++;
         else
-           shname = shell;
 +           shname = shell;
  
        shname_minus = malloc(strlen(shname) + 2);
        (void) strcpy(shname_minus, "-");
@@ -4193,7 +4216,7 @@
 #endif /* USE_SYSV_UTMP */
 #endif /* UTMP */
 #ifndef AMOEBA
-        close(screen->respond); /* close explicitly to avoid race with slave side */
 +       close(screen->respond); /* close explicitly to avoid race with slave side */
  #endif
 #ifdef ALLOWLOGGING
        if(screen->logging)
@@ -4203,15 +4226,9 @@
 #ifndef AMOEBA
        if (!am_slave) {
                /* restore ownership of tty and pty */
-               chown (ttydev, 0, 0);
 +               set_owner (ttydev, 0, 0, 0666);
  #if (!defined(__sgi) && !defined(__osf__) && !defined(__hpux))
-               chown (ptydev, 0, 0);
 -#endif
-
-               /* restore modes of tty and pty */
 -               chmod (ttydev, 0666);
 -#if (!defined(__sgi) && !defined(__osf__) && !defined(__hpux))
 -               chmod (ptydev, 0666);
 +               set_owner (ptydev, 0, 0, 0666);
  #endif
        }
 #endif /* AMOEBA */
@@ -4273,7 +4290,7 @@
 nonblocking_wait(void)
 {
 #ifdef USE_POSIX_WAIT
-        pid_t pid;
 +       pid_t pid;
  
        pid = waitpid(-1, NULL, WNOHANG);
 #elif defined(USE_SYSV_SIGNALS) && (defined(CRAY) || !defined(SIGTSTP))
@@ -4318,24 +4335,42 @@
     SIGNAL_RETURN;
 }
 
-static int
+static void
 remove_termcap_entry (char *buf, char *str)
 {
-    register char *strinbuf;
 +    char *base = buf;
 +    char *first = base;
 +    int count = 0;
 +    size_t len = strlen(str);
 +
+    TRACE(("*** remove_termcap_entry('%s', '%s')\n", str, buf))
  
-    strinbuf = strindex (buf, str);
 -    if (strinbuf) {
-        register char *colonPtr = strchr(strinbuf+1, ':');
 -        if (colonPtr) {
 -            while (*colonPtr) {
 -                *strinbuf++ = *colonPtr++;      /* copy down */
 -            }
 -            *strinbuf = '\0';
 -        } else {
 -            strinbuf[1] = '\0';
 -        }
+    while (*buf != 0) {
 +       if (!count && !strncmp(buf, str, len)) {
 +           while (*buf != 0) {
 +               if (*buf == '\\')
 +                   buf++;
 +               else if (*buf == ':')
 +                   break;
 +               if (*buf != 0)
 +                   buf++;
 +           }
 +           while ((*first++ = *buf++) != 0)
 +               ;
 +           TRACE(("...removed_termcap_entry('%s', '%s')\n", str, base))
 +           return;
 +       } else if (*buf == '\\') {
 +           buf++;
 +       } else if (*buf == ':') {
 +           first = buf;
 +           count = 0;
 +       } else if (!isspace(*buf)) {
 +           count++;
 +       }
+       if (*buf != 0)
 +           buf++;
      }
-    return 0;
+    TRACE(("...cannot remove\n"))
  }
 
 /*
@@ -4431,9 +4466,9 @@
      * much cheaper than called nbio_select.
      */
     if (nbio_isinprogress(fd, ASIO_READ))
-       return 0;
 +       return 0;
      else
-        return 1;
 +       return 1;
  #elif defined(FIORDCK)
     return (ioctl (fd, FIORDCHK, NULL));
 #else /* !FIORDCK */
@@ -4469,7 +4504,7 @@
 int A2E(int x)
 {
     char c;
-    c=x;
+    c = x;
     __atoe_l(&c,1);
     return c;
 }
@@ -4477,7 +4512,7 @@
 int E2A(int x)
 {
     char c;
-    c=x;
+    c = x;
     __etoa_l(&c,1);
     return c;
 }
Index: mkdirs.sh
--- xterm-113+/mkdirs.sh        Sat Dec 13 18:30:40 1997
 +++ xterm-114/mkdirs.sh Mon Feb  2 10:07:50 1998
 @@ -1,4 +1,4 @@
 -#!/bin/sh
+#! /bin/sh
 # mkinstalldirs --- make directory hierarchy
 # Author: Noah Friedman <friedman@prep.ai.mit.edu>
 # Created: 1993-05-16
Index: os2main.c
--- xterm-113+/os2main.c        Sun Aug 22 14:20:13 1999
 +++ xterm-114/os2main.c Wed Sep 15 07:03:41 1999
 @@ -107,7 +107,6 @@
  
 static SIGNAL_T reapchild (int n);
 static char *base_name (char *name);
-static int remove_termcap_entry (char *buf, char *str);
  static int spawn (void);
 static void get_terminal (void);
 static void resize (TScreen *s, char *oldtc, char *newtc);
@@ -1767,26 +1766,6 @@
     } while ( (pid=nonblocking_wait()) > 0);
 
     SIGNAL_RETURN;
-}
-
-static int
-remove_termcap_entry (char *buf, char *str)
 -{
-    register char *strinbuf;
 -
-    strinbuf = strindex (buf, str);
 -    if (strinbuf) {
-        register char *colonPtr = strchr(strinbuf+1, ':');
 -        if (colonPtr) {
 -            while (*colonPtr) {
 -                *strinbuf++ = *colonPtr++;      /* copy down */
 -            }
 -            *strinbuf = '\0';
 -        } else {
 -            strinbuf[1] = '\0';
 -        }
-    }
 -    return 0;
 }
 
 /*
Index: termcap
--- xterm-113+/termcap  Mon May  3 21:18:34 1999
 +++ xterm-114/termcap   Sun Aug 29 16:05:34 1999
 @@ -44,6 +44,21 @@
         :up=\E[A:us=\E[4m:ue=\E[24m:xn:\
        :ut:Co#8:op=\E[39;49m:AB=\E[4%dm:AF=\E[3%dm:\
        :pa#64:Sf=\E[3%dm:Sb=\E[4%dm:
+#
+# The xterm-xfree86 description has all of the features, but is not completely
 +# compatible with vt220.  If you are using a Sun or PC keyboard, set the
 +# sunKeyboard resource to true:
+#      + maps the editing keypad
 +#      + interprets control-function-key as a second array of keys, so a
 +#        12-fkey keyboard can support vt220's 20-fkeys.
 +#      + maps numeric keypad "+" to ",".
 +#      + uses DEC-style control sequences for the application keypad.
 +#        
+vt|xterm-vt220|xterm emulating vt220:\
 +       :kH=\E[4~::@7=\E[4~:*6=\E[4~:
 +       :kh=\E[1~:\
 +       :tc=xterm-xfree86:
 +
 v1|xterm-24|xterms|vs100|24x80 xterm:\
        :li#24:\
        :tc=xterm:
@@ -59,6 +74,11 @@
        :kn#20:\
        :st@:ut@:Co@:NC@:op@:AB@:AF@:pa@:Sf@:Sb@:tc=xterm:
 #
+# Alternate terminal description that "works" for interactive shells such as
 +# tcsh and bash.
+xterm-noapp|xterm with cursor keys in normal mode:\
 +       kl=\E[D:kd=\E[B:kr=\E[C:ku=\E[A:ks=\E=:ke=\E>:ti@:te@:tc=xterm:
 +#
 # This should work for the commonly used "color xterm" variations (XFree86
 # xterm, color_xterm, nxterm, rxvt).  You may have trouble with this using
 # conventional termcap because ncurses reports it is longer than 1023
@@ -66,10 +86,6 @@
 # (you can suppress it with "ac@").
 vc|xterm-color|generic "ANSI" color xterm:\
        :Co#8:NC@:pa#64:op=\E[m:AB=\E[4%dm:AF=\E[3%dm:tc=xterm-r6:
-vt|xterm-vt220|xterm emulating vt220:\
-       :kH=\E[4~::@7=\E[4~:*6=\E[4~:
 -       :kh=\E[1~:\
 -       :tc=xterm-xfree86:
  #
 # vi may work better with this entry, because vi doesn't use insert mode much.
 # |xterm-ic|xterm-vi|xterm with insert character instead of insert mode:\
Index: terminfo
--- xterm-113+/terminfo Mon Jul 12 13:43:45 1999
 +++ xterm-114/terminfo  Sun Aug 29 16:08:07 1999
 @@ -333,6 +333,10 @@
         smso=\E[7m,
        smul=\E[1m,
        use=xterm,
+xterm-boldso|xterm with bold for standout (X Window System),
 +       rmso=\E[m,
 +       smso=\E[1m,
 +       use=xterm,
  xterm-mono|monochrome xterm (X Window System),
        colors@,
        ncv@,
@@ -345,8 +349,52 @@
        sgr@,
        use=xterm,
 #
+# VTxxx terminals are usually set up so that full-screen applications will use
 +# the cursor application mode strings.  This is good for full-screen
 +# applications, including legacy applications which may have hard-coded
 +# behavior, but bad for interactive shells (e.g., tcsh, bash) which use arrow
 +# keys to scroll through a history of command strings.
 +#
+# To see the difference between normal/application modes, consider this example:
 +#      + In normal (non-application) mode, the terminal transmits a down-arrow
 +#        as \E[C, which happens to echo as a down-arrow.
 +#      + In application mode the terminal transmits \EOC, which echoes as C.
 +#        That is because the \EO is the SS3 control, which says to use the
 +#        character from the G3 character set for the next cell.
 +# 
+# One example of hard-coded behavior would be for applications written to work
 +# with VT52 and VT100 terminals.  If the application's parser ignores 'O' and
 +# '?' characters after the escape, then the cursor and keypad strings for the
 +# two terminals are the same.  (Indeed, one of the first curses applications
 +# which I used did something like this to cover "ANSI" terminals -TD).
 +#
+# To make this work (leaving the cursor keys in normal mode), we have to adjust
 +# the terminal initialization sequences:
 +#
+#      smkx/rmkx set/reset the cursor and keypad application modes.  We retain
 +#              the latter (otherwise many applications fail).
 +#
+#      smcup/rmcup set/restore cursor-addressing mode for full-screen
 +#              applications.  For xterm, this normally means the alternate
 +#              screen, which is not compatible with interactive shells.  Some
 +#              programs are "smart" and disable these.
 +#
+xterm-noapp|xterm with cursor keys in normal mode,
 +       kcub1=\E[D,
 +       kcud1=\E[B,
 +       kcuf1=\E[C,
 +       kcuu1=\E[A,
 +       rmcup@,
+       rmkx=\E>,
 +       smcup@,
+       smkx=\E=,
 +       use=xterm,
 +#
 # This should work for the commonly used "color xterm" variations (XFree86
-# xterm, color_xterm, nxterm, rxvt):
 +# xterm, color_xterm, nxterm, rxvt).  Note that it does not set 'bce', so for
 +# XFree86 and and rxvt, some applications that use colors will be less
 +# efficient, and in a few special cases (with "smart" optimization) the wrong
 +# color will be painted in spots.
  xterm-color|generic "ANSI" color xterm (X Window System),
        colors#8,
        ncv@,
@@ -356,11 +404,6 @@
        setaf=\E[3%p1%dm,
        use=xterm-r6,
 #
-xterm-boldso|xterm with bold for standout (X Window System),
 -       rmso=\E[m,
 -       smso=\E[1m,
 -       use=xterm,
 -#
 # vi may work better with this entry, because vi
 # doesn't use insert mode much
 xterm-ic|xterm-vi|xterm with insert character instead of insert mode,
@@ -413,6 +456,7 @@
        setb=%p1%{8}%/%{6}%*%{4}%+\E[%d%p1%{8}%m%Pa%?%ga%{1}%=%t4%e%ga%{3}%=%t6%e%ga%{4}%=%t1%e%ga%{6}%=%t3%e%ga%d%;m,
        setf=%p1%{8}%/%{6}%*%{3}%+\E[%d%p1%{8}%m%Pa%?%ga%{1}%=%t4%e%ga%{3}%=%t6%e%ga%{4}%=%t1%e%ga%{6}%=%t3%e%ga%d%;m,
        use=xterm-xfree86,
+#
 # OPT_PC_MODE should be settable with OSC, and the init for this
 # should turn it off; then ncv could be 0
 # this uses RGB values 0..255; terminfo(5) says they're terminal-dependant
Index: version.h
--- xterm-113+/version.h        Sun Aug 22 14:20:13 1999
 +++ xterm-114/version.h Wed Sep 15 20:51:01 1999
 @@ -6,5 +6,5 @@
   * XFree86 to which this version of xterm has been built.  The number in
  * parentheses is my patch number (T.Dickey).
  */
-#define XTERM_PATCH   113
+#define XTERM_PATCH   114
  #define XFREE86_VERSION "XFree86 3.9.15b"
Index: xterm.h
--- xterm-113+/xterm.h  Sun Aug 22 14:20:13 1999
 +++ xterm-114/xterm.h   Wed Sep 15 05:13:46 1999
 @@ -108,7 +108,7 @@
  #endif
 
 #include <errno.h>
-#ifdef DECL_ERRNO
+#if defined(DECL_ERRNO) && !defined(errno)
  extern int errno;
 #endif
 
Index: xterm.log.html
--- xterm-113+/xterm.log.html   Sun Aug 22 14:20:13 1999
 +++ xterm-114/xterm.log.html    Wed Sep 15 21:08:41 1999
 @@ -41,6 +41,7 @@
  xc/programs/Xserver/hw/xfree86).
 
 <UL>
+<LI><A HREF="#xterm_114">Patch #114 - 1999/9/15 - XFree86 3.9.16</A>
  <LI><A HREF="#xterm_113">Patch #113 - 1999/8/15 - XFree86 3.9.15b</A>
 <LI><A HREF="#xterm_112">Patch #112 - 1999/7/17 - XFree86 3.9Pw</A>
 <LI><A HREF="#xterm_111">Patch #111 - 1999/7/10 - XFree86 3.9Pw</A>
@@ -156,6 +157,44 @@
 <LI><A HREF="#xterm_02">Patch #2 - 1996/1/7</A>
 <LI><A HREF="#xterm_01">Patch #1 - 1996/1/6</A>
 </UL>
+
+<H1><A NAME="xterm_114">Patch #114 - 1999/9/15 - XFree86 3.9.16</A></H1>
 +<ul>
+
+       <li>add configure script checks for Athena headers and libraries under
 +         /usr/contrib to work on HPUX (reported by several people:
 +               David Nixon <djn@csc.liv.ac.uk> 
 +               Aryeh Koenigsberg <aryeh.koenigsberg@telrad.co.il> 
 +               Johannes Mähner <johanm@camline.com> 
 +               Andrew Gaylard <andrew.gaylard@bsw.co.za>).
 +
+       <li>add check to configure script if xterm is installed setgid rather
 +         than setuid, since wtmp and utmp may be installed with group-writable
 +         permissions other than root (based on Debian bug report #7112 by Bo
 +         Branten <bosse@ing.umu.se>).
 +
+       <li>rewrote logic that removes data from termcap entry, e.g., for
 +         titeInhibit, to make it less likely to remove the wrong data.
 +
+       <li>correct logic which checks for missing characters used for line
 +         drawing.  The 0 character was tested unnecessarily, leading to
 +         some inefficiency when rendering.
 +
+       <li>change termcap capability which is used as input or output of
 +         ptyInitialErase logic from <em>kD</em> to <em>kb</em>.
 +         Christian Weisgerber <naddy@mips.rhein-neckar.de> pointed out
 +         in effect that <em>kD</em> (in terminfo <em>kdch1</em>) should
 +         correspond to the control sequence for <em>dch1</em>, which deletes
 +         from the current position toward the right.
 +
+       <li>check for failure to change ownership of the PTY device and warn
 +         when xterm is running setuid'd to root.  This was reported to happen
 +         on the FreeBSD/NetBSD/OpenBSD systems as a result of the chflags()
 +         call.
 +
+       <li>add xterm-noapp terminfo entry to illustate a nominally
 +         bash-compatible terminal description.
 +</ul>
 
 <H1><A NAME="xterm_113">Patch #113 - 1999/8/15 - XFree86 3.9.15b</A></H1>
 Several fixes.  The main one is a first draft of pulldown menus.  It's not
Index: xterm.man
--- xterm-113+/xterm.man        Sun Jul 18 16:29:08 1999
 +++ xterm-114/xterm.man Wed Sep 15 20:41:17 1999
 @@ -357,7 +357,7 @@
  .TP 8
 .B \+ie
 Turn off the \fBptyInitialErase\fP resource, i.e.,
-set the stty erase value using the \fBkD\fP string from the termcap entry as
 +set the stty erase value using the \fBkb\fP string from the termcap entry as
  a reference, if available.
 .TP 8
 .B \-im
@@ -723,7 +723,7 @@
 If ``true'', \fIxterm\fP will use the pseudo-terminal's sense of the stty erase
 value.
 If ``false'', \fIxterm\fP will set the stty erase value to match its own
-configuration, using the \fBkD\fP string from the termcap entry as
 +configuration, using the \fBkb\fP string from the termcap entry as
  a reference, if available.
 In either case, the result is applied to the TERMCAP variable
 which \fIxterm\fP sets.