xterm-43.patch.txt

XFree86 3.9d - xterm patch #43 - 1997/6/10 - T.Dickey
 
Here's a fix for two problems:
 
        + modify handling of tgetent results in xterm and resize programs to
          make them tolerant of missing termcap file, or unknown terminal name.
          In this scheme, an explicit "-tn" option will succeed, overriding
          the fallback list.
 
        + a nit in the configure script (log extra information to help diagnose
          which case of the test-compile of tgetent was used).
 
--------------------------------------------------------------------------------
 aclocal.m4 |   14 ++--
 configure  |  194 ++++++++++++++++++++++++++++++-----------------------------
 main.c     |   54 +++++++---------
 resize.c   |   64 ++++++++++---------
 4 files changed, 166 insertions, 160 deletions
--------------------------------------------------------------------------------
Index: aclocal.m4
--- xterm-42+/aclocal.m4        Tue Jun  3 16:05:50 1997
+++ xterm-43/aclocal.m4 Tue Jun 10 19:17:08 1997
@@ -169,17 +169,21 @@
        buffer[0] = 0;
        tgetent(buffer, "vt100");
        exit(buffer[0] == 0); }],
-       [cf_cv_func_tgetent=yes
+       [echo "yes, there is a termcap/tgetent present" 1>&AC_FD_CC
+        cf_cv_func_tgetent=yes
         break],
-       [cf_cv_func_tgetent=no],
-       [cf_cv_func_tgetent=no])
+       [echo "no, there is no termcap/tgetent present" 1>&AC_FD_CC
+        cf_cv_func_tgetent=no],
+       [echo "cross-compiling, cannot verify if a termcap/tgetent is present" 1>&AC_FD_CC
+        cf_cv_func_tgetent=no])
 done
 # If there was no workable (termcap) version, maybe there is a terminfo version
 if test $cf_cv_func_tgetent = no ; then
        for cf_termlib in $cf_TERMLIB
        do
                AC_TRY_LINK([],[tgetent(0, 0)],
-                       [cf_cv_func_tgetent=$cf_termlib
+                       [echo "there is a terminfo/tgetent present" 1>&AC_FD_CC
+                        cf_cv_func_tgetent=$cf_termlib
                         break],
                        [LIBS="$cf_save_LIBS"])
        done
@@ -188,7 +192,7 @@
 AC_MSG_RESULT($cf_cv_func_tgetent)
 # If we found any sort of tgetent, check for the termcap.h file.  If this is
 # linking against ncurses, we'll trigger the ifdef in resize.c that turns the
-# termcap stuff back off.
+# termcap stuff back off.  Including termcap.h should otherwise be harmless.
 if test $cf_cv_func_tgetent != no ; then
        AC_CHECK_HEADERS(termcap.h)
        if test $cf_cv_func_tgetent != yes ; then
Index: configure
--- xterm-42+/configure Tue Jun 10 15:10:00 1997
+++ xterm-43/configure  Tue Jun 10 19:17:17 1997
@@ -1325,10 +1325,11 @@
 do
        LIBS="$cf_save_LIBS -l$cf_termlib"
        if test "$cross_compiling" = yes; then
-  cf_cv_func_tgetent=no
+  echo "cross-compiling, cannot verify if a termcap/tgetent is present" 1>&5
+        cf_cv_func_tgetent=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 1332 "configure"
+#line 1333 "configure"
 #include "confdefs.h"
 
 /* terminfo implementations ignore the buffer argument, making it useless for
@@ -1341,15 +1342,17 @@
        tgetent(buffer, "vt100");
        exit(buffer[0] == 0); }
 EOF
-if { (eval echo configure:1345: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1346: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
-  cf_cv_func_tgetent=yes
+  echo "yes, there is a termcap/tgetent present" 1>&5
+        cf_cv_func_tgetent=yes
         break
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -fr conftest*
-  cf_cv_func_tgetent=no
+  echo "no, there is no termcap/tgetent present" 1>&5
+        cf_cv_func_tgetent=no
 fi
 rm -fr conftest*
 fi
@@ -1360,16 +1363,17 @@
        for cf_termlib in $cf_TERMLIB
        do
                cat > conftest.$ac_ext <<EOF
-#line 1364 "configure"
+#line 1367 "configure"
 #include "confdefs.h"
 
 int main() {
 tgetent(0, 0)
 ; return 0; }
 EOF
-if { (eval echo configure:1371: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1374: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
-  cf_cv_func_tgetent=$cf_termlib
+  echo "there is a terminfo/tgetent present" 1>&5
+                        cf_cv_func_tgetent=$cf_termlib
                         break
 else
   echo "configure: failed program was:" >&5
@@ -1386,23 +1390,23 @@
 echo "$ac_t""$cf_cv_func_tgetent" 1>&6
 # If we found any sort of tgetent, check for the termcap.h file.  If this is
 # linking against ncurses, we'll trigger the ifdef in resize.c that turns the
-# termcap stuff back off.
+# termcap stuff back off.  Including termcap.h should otherwise be harmless.
 if test $cf_cv_func_tgetent != no ; then
        for ac_hdr in termcap.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1396: checking for $ac_hdr" >&5
+echo "configure:1400: 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 1401 "configure"
+#line 1405 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1406: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1410: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1441,12 +1445,12 @@
 
 ###    checks for compiler characteristics
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:1445: checking for working const" >&5
+echo "configure:1449: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1450 "configure"
+#line 1454 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1495,7 +1499,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1499: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1503: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -1516,7 +1520,7 @@
 fi
 
 echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6
-echo "configure:1520: checking for ${CC-cc} option to accept ANSI C" >&5
+echo "configure:1524: checking for ${CC-cc} option to accept ANSI C" >&5
 if eval "test \"`echo '$''{'cf_cv_ansi_cc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1533,7 +1537,7 @@
 do
        CFLAGS="$cf_save_CFLAGS $cf_arg"
        cat > conftest.$ac_ext <<EOF
-#line 1537 "configure"
+#line 1541 "configure"
 #include "confdefs.h"
 
 #ifndef CC_HAS_PROTOS
@@ -1548,7 +1552,7 @@
 struct s2 {int (*f) (double a);};
 ; return 0; }
 EOF
-if { (eval echo configure:1552: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1556: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_ansi_cc="$cf_arg"; break
 else
@@ -1575,7 +1579,7 @@
 # Uses ac_ vars as temps to allow command line to override cache and checks.
 # --without-x overrides everything else, but does not touch the cache.
 echo $ac_n "checking for X""... $ac_c" 1>&6
-echo "configure:1579: checking for X" >&5
+echo "configure:1583: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -1637,12 +1641,12 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 1641 "configure"
+#line 1645 "configure"
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1646: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1650: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1711,14 +1715,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1715 "configure"
+#line 1719 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:1722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   LIBS="$ac_save_LIBS"
 # We can link X programs with no special library path.
@@ -1824,17 +1828,17 @@
     case "`(uname -sr) 2>/dev/null`" in
     "SunOS 5"*)
       echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6
-echo "configure:1828: checking whether -R must be followed by a space" >&5
+echo "configure:1832: checking whether -R must be followed by a space" >&5
       ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
       cat > conftest.$ac_ext <<EOF
-#line 1831 "configure"
+#line 1835 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:1838: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1842: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -1850,14 +1854,14 @@
       else
        LIBS="$ac_xsave_LIBS -R $x_libraries"
        cat > conftest.$ac_ext <<EOF
-#line 1854 "configure"
+#line 1858 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:1861: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1865: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -1889,7 +1893,7 @@
     # libraries were built with DECnet support.  And karl@cs.umb.edu says
     # the Alpha needs dnet_stub (dnet does not exist).
     echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:1893: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:1897: checking for dnet_ntoa in -ldnet" >&5
 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1897,7 +1901,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1901 "configure"
+#line 1905 "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
@@ -1908,7 +1912,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:1912: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1916: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1930,7 +1934,7 @@
 
     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
       echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6
-echo "configure:1934: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:1938: checking for dnet_ntoa in -ldnet_stub" >&5
 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1938,7 +1942,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1942 "configure"
+#line 1946 "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
@@ -1949,7 +1953,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:1953: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1957: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1978,12 +1982,12 @@
     # The nsl library prevents programs from opening the X display
     # on Irix 5.2, according to dickey@clark.net.
     echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:1982: checking for gethostbyname" >&5
+echo "configure:1986: checking for gethostbyname" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1987 "configure"
+#line 1991 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -2006,7 +2010,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2010: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2014: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -2027,7 +2031,7 @@
 
     if test $ac_cv_func_gethostbyname = no; then
       echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:2031: checking for gethostbyname in -lnsl" >&5
+echo "configure:2035: checking for gethostbyname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2035,7 +2039,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2039 "configure"
+#line 2043 "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
@@ -2046,7 +2050,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:2050: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2054: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2076,12 +2080,12 @@
     # -lsocket must be given before -lnsl if both are needed.
     # We assume that if connect needs -lnsl, so does gethostbyname.
     echo $ac_n "checking for connect""... $ac_c" 1>&6
-echo "configure:2080: checking for connect" >&5
+echo "configure:2084: checking for connect" >&5
 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2085 "configure"
+#line 2089 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -2104,7 +2108,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2108: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2112: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
@@ -2125,7 +2129,7 @@
 
     if test $ac_cv_func_connect = no; then
       echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
-echo "configure:2129: checking for connect in -lsocket" >&5
+echo "configure:2133: checking for connect in -lsocket" >&5
 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2133,7 +2137,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2137 "configure"
+#line 2141 "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
@@ -2144,7 +2148,7 @@
 connect()
 ; return 0; }
 EOF
-if { (eval echo configure:2148: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2152: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2168,12 +2172,12 @@
 
     # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
     echo $ac_n "checking for remove""... $ac_c" 1>&6
-echo "configure:2172: checking for remove" >&5
+echo "configure:2176: checking for remove" >&5
 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2177 "configure"
+#line 2181 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -2196,7 +2200,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2200: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2204: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_remove=yes"
 else
@@ -2217,7 +2221,7 @@
 
     if test $ac_cv_func_remove = no; then
       echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:2221: checking for remove in -lposix" >&5
+echo "configure:2225: checking for remove in -lposix" >&5
 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2225,7 +2229,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lposix  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2229 "configure"
+#line 2233 "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
@@ -2236,7 +2240,7 @@
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:2240: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2260,12 +2264,12 @@
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:2264: checking for shmat" >&5
+echo "configure:2268: checking for shmat" >&5
 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2269 "configure"
+#line 2273 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -2288,7 +2292,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2292: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2296: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_shmat=yes"
 else
@@ -2309,7 +2313,7 @@
 
     if test $ac_cv_func_shmat = no; then
       echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:2313: checking for shmat in -lipc" >&5
+echo "configure:2317: checking for shmat in -lipc" >&5
 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2317,7 +2321,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lipc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2321 "configure"
+#line 2325 "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
@@ -2328,7 +2332,7 @@
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:2332: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2336: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2361,7 +2365,7 @@
   # libraries we check for below, so use a different variable.
   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
   echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
-echo "configure:2365: checking for IceConnectionNumber in -lICE" >&5
+echo "configure:2369: checking for IceConnectionNumber in -lICE" >&5
 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2369,7 +2373,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lICE  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2373 "configure"
+#line 2377 "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
@@ -2380,7 +2384,7 @@
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:2384: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2388: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2410,7 +2414,7 @@
 
 
 echo $ac_n "checking for XOpenDisplay in -lX11""... $ac_c" 1>&6
-echo "configure:2414: checking for XOpenDisplay in -lX11" >&5
+echo "configure:2418: checking for XOpenDisplay in -lX11" >&5
 ac_lib_var=`echo X11'_'XOpenDisplay | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2418,7 +2422,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2422 "configure"
+#line 2426 "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
@@ -2429,7 +2433,7 @@
 XOpenDisplay()
 ; return 0; }
 EOF
-if { (eval echo configure:2433: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2450,7 +2454,7 @@
 fi
 
 echo $ac_n "checking for XtAppInitialize in -lXt""... $ac_c" 1>&6
-echo "configure:2454: checking for XtAppInitialize in -lXt" >&5
+echo "configure:2458: checking for XtAppInitialize in -lXt" >&5
 ac_lib_var=`echo Xt'_'XtAppInitialize | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2458,7 +2462,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2462 "configure"
+#line 2466 "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
@@ -2469,7 +2473,7 @@
 XtAppInitialize()
 ; return 0; }
 EOF
-if { (eval echo configure:2473: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2477: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2501,17 +2505,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2505: checking for $ac_hdr" >&5
+echo "configure:2509: 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 2510 "configure"
+#line 2514 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2515: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2519: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2538,7 +2542,7 @@
 done
 
 echo $ac_n "checking for XmuClientWindow in -lXmu""... $ac_c" 1>&6
-echo "configure:2542: checking for XmuClientWindow in -lXmu" >&5
+echo "configure:2546: 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
@@ -2546,7 +2550,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXmu  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2550 "configure"
+#line 2554 "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
@@ -2557,7 +2561,7 @@
 XmuClientWindow()
 ; return 0; }
 EOF
-if { (eval echo configure:2561: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2565: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2585,7 +2589,7 @@
 fi
 
 echo $ac_n "checking for XextCreateExtension in -lXext""... $ac_c" 1>&6
-echo "configure:2589: checking for XextCreateExtension in -lXext" >&5
+echo "configure:2593: 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
@@ -2593,7 +2597,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXext  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2597 "configure"
+#line 2601 "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
@@ -2604,7 +2608,7 @@
 XextCreateExtension()
 ; return 0; }
 EOF
-if { (eval echo configure:2608: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2612: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2625,7 +2629,7 @@
 fi
 
 echo $ac_n "checking for XawSimpleMenuAddGlobalActions in -lXaw""... $ac_c" 1>&6
-echo "configure:2629: checking for XawSimpleMenuAddGlobalActions in -lXaw" >&5
+echo "configure:2633: checking for XawSimpleMenuAddGlobalActions in -lXaw" >&5
 ac_lib_var=`echo Xaw'_'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
@@ -2633,7 +2637,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXaw $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2637 "configure"
+#line 2641 "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
@@ -2644,7 +2648,7 @@
 XawSimpleMenuAddGlobalActions()
 ; return 0; }
 EOF
-if { (eval echo configure:2648: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2652: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2671,7 +2675,7 @@
 LIBS="$LIBS $X_EXTRA_LIBS"
 
 echo $ac_n "checking if we should use imake to help""... $ac_c" 1>&6
-echo "configure:2675: checking if we should use imake to help" >&5
+echo "configure:2679: 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
   enableval="$enable_imake"
@@ -2696,7 +2700,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:2700: checking for $ac_word" >&5
+echo "configure:2704: 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
@@ -2774,7 +2778,7 @@
 # macros do not work well enough to actually use the Makefile for a build, but
 # the definitions are usable (probably).
 echo $ac_n "checking for compiler options known to imake""... $ac_c" 1>&6
-echo "configure:2778: checking for compiler options known to imake" >&5
+echo "configure:2782: checking for compiler options known to imake" >&5
 if eval "test \"`echo '$''{'cf_cv_imake_cflags'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2820,7 +2824,7 @@
 
 
 echo $ac_n "checking for default terminal-id""... $ac_c" 1>&6
-echo "configure:2824: checking for default terminal-id" >&5
+echo "configure:2828: 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
   withval="$with_terminal_id"
@@ -2841,7 +2845,7 @@
 
 ###    checks for optional features
 echo $ac_n "checking if you want ANSI color""... $ac_c" 1>&6
-echo "configure:2845: checking if you want ANSI color" >&5
+echo "configure:2849: 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
   enableval="$enable_ansi_color"
@@ -2864,7 +2868,7 @@
 
 
 echo $ac_n "checking if you want 16 colors like aixterm""... $ac_c" 1>&6
-echo "configure:2868: checking if you want 16 colors like aixterm" >&5
+echo "configure:2872: 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
   enableval="$enable_16_color"
@@ -2887,7 +2891,7 @@
 
 
 echo $ac_n "checking for default color-mode""... $ac_c" 1>&6
-echo "configure:2891: checking for default color-mode" >&5
+echo "configure:2895: checking for default color-mode" >&5
 # Check whether --enable-color-mode or --disable-color-mode was given.
 if test "${enable_color_mode+set}" = set; then
   enableval="$enable_color_mode"
@@ -2910,7 +2914,7 @@
 
 
 echo $ac_n "checking if you want debugging traces""... $ac_c" 1>&6
-echo "configure:2914: checking if you want debugging traces" >&5
+echo "configure:2918: checking if you want debugging traces" >&5
 # Check whether --enable-trace or --disable-trace was given.
 if test "${enable_trace+set}" = set; then
   enableval="$enable_trace"
@@ -2937,7 +2941,7 @@
 fi
 
 echo $ac_n "checking if you want VT52 emulation""... $ac_c" 1>&6
-echo "configure:2941: checking if you want VT52 emulation" >&5
+echo "configure:2945: checking if you want VT52 emulation" >&5
 # Check whether --enable-vt52 or --disable-vt52 was given.
 if test "${enable_vt52+set}" = set; then
   enableval="$enable_vt52"
@@ -2961,7 +2965,7 @@
 
 if test -n "$GCC" ; then
 echo $ac_n "checking if you want to turn on gcc warnings""... $ac_c" 1>&6
-echo "configure:2965: checking if you want to turn on gcc warnings" >&5
+echo "configure:2969: 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
   enableval="$enable_warnings"
@@ -3000,9 +3004,9 @@
 if test -n "$GCC"
 then
        echo "checking for gcc __attribute__ directives" 1>&6
-echo "configure:3004: checking for gcc __attribute__ directives" >&5
+echo "configure:3008: checking for gcc __attribute__ directives" >&5
        cat > conftest.$ac_ext <<EOF
-#line 3006 "configure"
+#line 3010 "configure"
 #include "confdefs.h"
 #include "conftest.h"
 #include "conftest.i"
@@ -3040,7 +3044,7 @@
 EOF
                        ;;
                esac
-               if { (eval echo configure:3044: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+               if { (eval echo configure:3048: \"$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
@@ -3054,11 +3058,11 @@
 
 
                cat > conftest.$ac_ext <<EOF
-#line 3058 "configure"
+#line 3062 "configure"
 int main(int argc, char *argv[]) { return argv[argc-1] == 0; }
 EOF
                echo "checking for gcc warning options" 1>&6
-echo "configure:3062: checking for gcc warning options" >&5
+echo "configure:3066: checking for gcc warning options" >&5
        cf_save_CFLAGS="$CFLAGS"
        cf_warn_CFLAGS="-W -Wall"
        for cf_opt in \
@@ -3074,7 +3078,7 @@
                Wstrict-prototypes
        do
                CFLAGS="$cf_save_CFLAGS $cf_warn_CFLAGS -$cf_opt"
-               if { (eval echo configure:3078: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+               if { (eval echo configure:3082: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
                        test -n "$verbose" && echo "$ac_t""... -$cf_opt" 1>&6
                        cf_warn_CFLAGS="$cf_warn_CFLAGS -$cf_opt"
                        test "$cf_opt" = Wcast-qual && cf_warn_CFLAGS="$cf_warn_CFLAGS -DXTSTRINGDEFINES"
Index: main.c
--- xterm-42+/main.c    Tue Jun  3 16:05:50 1997
+++ xterm-43/main.c     Tue Jun 10 20:41:54 1997
@@ -498,7 +498,7 @@
 static void KeyboardMapping PROTO_XT_ACTIONS_ARGS;
 static void Syntax PROTO((char *badOption));
 static void get_terminal PROTO((void));
-static void resize PROTO((TScreen *s, char *n, char *oldtc, char *newtc));
+static void resize PROTO((TScreen *s, char *oldtc, char *newtc));
 
 static SIGNAL_T reapchild PROTO((int n));
 
@@ -2262,35 +2262,40 @@
                envnew = vtterm;
                ptr = termcap;
        }
-       *ptr = 0;
+
+       /*
+        * This used to exit if no termcap entry was found for the specified
+        * terminal name.  That's a little unfriendly, so instead we'll allow
+        * the program to proceed (but not to set $TERMCAP) if the termcap
+        * entry is not found.
+        */
+       *ptr = 0;       /* initialize, in case we're using terminfo's tgetent */
        TermName = NULL;
        if (resource.term_name) {
+           TermName = resource.term_name;
            if (tgetent (ptr, resource.term_name) == 1) {
-               TermName = resource.term_name;
                if (*ptr) 
                    if (!screen->TekEmu)
-                       resize (screen, TermName, termcap, newtc);
-           } else {
-               fprintf (stderr, "%s:  invalid termcap entry \"%s\".\n",
-                        ProgramName, resource.term_name);
+                       resize (screen, termcap, newtc);
            }
        }
+
+       /*
+        * This block is invoked only if there was no terminal name specified
+        * by the command-line option "-tn".
+        */
        if (!TermName) {
+           TermName = *envnew;
            while (*envnew != NULL) {
                if(tgetent(ptr, *envnew) == 1) {
                        TermName = *envnew;
                        if (*ptr) 
                            if(!screen->TekEmu)
-                               resize(screen, TermName, termcap, newtc);
+                               resize(screen, termcap, newtc);
                        break;
                }
                envnew++;
            }
-           if (TermName == NULL) {
-               fprintf (stderr, "%s:  unable to find usable termcap entry.\n",
-                        ProgramName);
-               Exit (1);
-           }
        }
 
 #if defined(sun) && !defined(SVR4)
@@ -3145,7 +3150,7 @@
 #else /* USE_SYSV_ENVVAR */
                if(!screen->TekEmu && *newtc) {
                    strcpy (termcap, newtc);
-                   resize (screen, TermName, termcap, newtc);
+                   resize (screen, termcap, newtc);
                }
                if (term->misc.titeInhibit) {
                    remove_termcap_entry (newtc, ":ti=");
@@ -3512,33 +3517,25 @@
     *ptr = 0;
     TermName = NULL;
     if (resource.term_name) {
+       TermName = resource.term_name;
        if (tgetent (ptr, resource.term_name) == 1) {
-           TermName = resource.term_name;
            if (*ptr)
                if (!screen->TekEmu)
-                   resize (screen, TermName, termcap, newtc);
-       } else {
-           fprintf (stderr, "%s:  invalid termcap entry \"%s\".\n",
-               ProgramName, resource.term_name);
-       }
+                   resize (screen, termcap, newtc);
     }
 
     if (!TermName) {
+       TermName = *envnew;
        while (*envnew != NULL) {
            if(tgetent(ptr, *envnew) == 1) {
                TermName = *envnew;
                if (*ptr)
                    if(!screen->TekEmu)
-                       resize(screen, TermName, termcap, newtc);
+                       resize(screen, termcap, newtc);
                break;
            }
            envnew++;
        }
-       if (TermName == NULL) {
-           fprintf (stderr, "%s:  unable to find usable termcap entry.\n",
-               ProgramName);
-           Exit (1);
-       }
     }
 
     /*
@@ -3607,7 +3604,7 @@
 
     if(!screen->TekEmu && *newtc) {
        strcpy (termcap, newtc);
-       resize (screen, TermName, termcap, newtc);
+       resize (screen, termcap, newtc);
     }
     if (term->misc.titeInhibit) {
        remove_termcap_entry (newtc, ":ti=");
@@ -3850,9 +3847,8 @@
 
 /* ARGSUSED */
 static void
-resize(screen, TermName, oldtc, newtc)
+resize(screen, oldtc, newtc)
 TScreen *screen;
-char *TermName;
 register char *oldtc, *newtc;
 {
 #ifndef USE_SYSV_ENVVARS
Index: resize.c
--- xterm-42+/resize.c  Tue Jun  3 16:05:50 1997
+++ xterm-43/resize.c   Tue Jun 10 19:41:58 1997
@@ -282,6 +282,7 @@
 #endif /* USE_TERMIOS */
 #endif /* USE_SYSV_TERMIO */
 #ifdef USE_TERMCAP
+       int ok_tcap = 1;
        char termcap [1024];
        char newtc [1024];
 #endif /* USE_TERMCAP */
@@ -378,11 +379,8 @@
                setname = "setenv TERM xterm;\n";
        }
        termcap[0] = 0; /* ...just in case we've accidentally gotten terminfo */
-       if(tgetent (termcap, env) <= 0) {
-           fprintf(stderr, "%s: Can't get entry \"%s\"\n",
-                   myname, env);
-           exit(1);
-       }
+       if(tgetent (termcap, env) <= 0 || termcap[0] == 0)
+           ok_tcap = 0;
 #endif /* USE_TERMCAP */
 #ifdef USE_TERMINFO
        if(!(env = getenv("TERM")) || !*env) {
@@ -495,37 +493,40 @@
        signal(SIGTERM, SIG_DFL);
 
 #ifdef USE_TERMCAP
-       /* update termcap string */
-       /* first do columns */
-       if ((ptr = strindex (termcap, "co#")) == NULL) {
-               fprintf(stderr, "%s: No `co#'\n", myname);
-               exit (1);
-       }
+       if (ok_tcap) {
+               /* update termcap string */
+               /* first do columns */
+               if ((ptr = strindex (termcap, "co#")) == NULL) {
+                       fprintf(stderr, "%s: No `co#'\n", myname);
+                       exit (1);
+               }
 
-       i = ptr - termcap + 3;
-       strncpy (newtc, termcap, i);
-       sprintf (newtc + i, "%d", cols);
-       ptr = strchr(ptr, ':');
-       strcat (newtc, ptr);
-
-       /* now do lines */
-       if ((ptr = strindex (newtc, "li#")) == NULL) {
-               fprintf(stderr, "%s: No `li#'\n", myname);
-               exit (1);
-       }
+               i = ptr - termcap + 3;
+               strncpy (newtc, termcap, i);
+               sprintf (newtc + i, "%d", cols);
+               ptr = strchr(ptr, ':');
+               strcat (newtc, ptr);
+
+               /* now do lines */
+               if ((ptr = strindex (newtc, "li#")) == NULL) {
+                       fprintf(stderr, "%s: No `li#'\n", myname);
+                       exit (1);
+               }
 
-       i = ptr - newtc + 3;
-       strncpy (termcap, newtc, i);
-       sprintf (termcap + i, "%d", rows);
-       ptr = strchr(ptr, ':');
-       strcat (termcap, ptr);
+               i = ptr - newtc + 3;
+               strncpy (termcap, newtc, i);
+               sprintf (termcap + i, "%d", rows);
+               ptr = strchr(ptr, ':');
+               strcat (termcap, ptr);
+       }
 #endif /* USE_TERMCAP */
 
        if(SHELL_BOURNE == shell_type) {
 
 #ifdef USE_TERMCAP
-               printf ("%sTERMCAP='%s';\n",
-                setname, termcap);
+               if (ok_tcap)
+                       printf ("%sTERMCAP='%s';\n",
+                        setname, termcap);
 #endif /* USE_TERMCAP */
 #ifdef USE_TERMINFO
 #ifndef SVR4
@@ -537,8 +538,9 @@
        } else {                /* not Bourne shell */
 
 #ifdef USE_TERMCAP
-               printf ("set noglob;\n%ssetenv TERMCAP '%s';\nunset noglob;\n",
-                setname, termcap);
+               if (ok_tcap)
+                       printf ("set noglob;\n%ssetenv TERMCAP '%s';\nunset noglob;\n",
+                        setname, termcap);
 #endif /* USE_TERMCAP */
 #ifdef USE_TERMINFO
 #ifndef SVR4