# ------------------------------------------------------------------------------
 #  Imakefile           |    4 +++
 #  Makefile.in         |   10 ++++-----
 #  fontutils.c         |   53 +++++++++++++++++++++++++++++++++++---------------
 #  main.c              |   33 ++++++++++++-------------------
 #  ptyx.h              |    2 -
 #  util.c              |    2 -
 #  version.h           |    4 +--
 #  vttests/16colors.sh |   29 ++++++++++++++++++++++-----
 #  vttests/8colors.sh  |   27 +++++++++++++++++++++----
 #  vttests/title.sh    |    3 +-
 #  xterm.log.html      |   27 +++++++++++++++++++++++++
 #  xterm.man           |    2 +
 #  12 files changed, 142 insertions, 54 deletions
 # ------------------------------------------------------------------------------
 Index: Imakefile
--- xterm-95+/Imakefile Sun Oct 25 13:31:39 1998
 +++ xterm-96/Imakefile  Sun Apr 18 19:02:06 1999
 @@ -49,6 +49,10 @@
           PTYLIB = -lpucc
 #endif
 
+#if (LinuxCLibMajorVersion >= 6 && LinuxCLibMinorVersion >= 1)
 +         PTYLIB = -lutil
 +#endif
+
 #if XtermWithI18N
         I18NDEF = -DI18N
 #endif
Index: Makefile.in
--- xterm-95+/Makefile.in       Sun Apr 11 16:38:14 1999
 +++ xterm-96/Makefile.in        Thu Apr 15 07:09:29 1999
 @@ -94,15 +94,15 @@
  install : $(INSTALL_DIRS) xterm resize
        $(INSTALL_PROGRAM) -s -m @XTERM_MODE@ xterm  $(bindir)/xterm
        $(INSTALL_PROGRAM) -s -m  755 resize $(bindir)/resize
-       $(INSTALL_DATA) xterm.man    $(mandir)/xterm.$(manext)
 -       $(INSTALL_DATA) resize.man   $(mandir)/resize.$(manext)
 -       $(INSTALL_DATA) XTerm.ad     $(appsdir)/XTerm
 -       $(INSTALL_DATA) XTerm-col.ad $(appsdir)/XTerm-color
 +       $(INSTALL_DATA) $(srcdir)/xterm.man    $(mandir)/xterm.$(manext)
 +       $(INSTALL_DATA) $(srcdir)/resize.man   $(mandir)/resize.$(manext)
 +       $(INSTALL_DATA) $(srcdir)/XTerm.ad     $(appsdir)/XTerm
 +       $(INSTALL_DATA) $(srcdir)/XTerm-col.ad $(appsdir)/XTerm-color
         @echo 'Completed installation of executables and documentation.'
        @echo 'Use "make install-ti" to install terminfo description.'
 
 install-ti:
-       TERMINFO=@private_TERMINFO@ tic terminfo
 +       TERMINFO=@private_TERMINFO@ tic $(srcdir)/terminfo
  
 installdirs: $(INSTALL_DIRS)
 
Index: fontutils.c
--- xterm-95+/fontutils.c       Sun Apr 11 16:38:14 1999
 +++ xterm-96/fontutils.c        Thu Apr 15 20:08:12 1999
 @@ -118,7 +118,7 @@
   * or NULL on error.
  */
 static FontNameProperties *
-get_font_name_props(Display *dpy, XFontStruct *fs)
 +get_font_name_props(Display *dpy, XFontStruct *fs, char *result)
  {
        static FontNameProperties props;
        static char *last_name;
@@ -147,6 +147,8 @@
        if (last_name != 0)
                XFree(last_name);
        last_name = name;
+       if (result != 0)
 +               strcpy(result, name);
  
        /*
        * Now split it up into parts and put them in
@@ -254,7 +256,7 @@
        int res_x;
        int res_y;
 
-       props = get_font_name_props(screen->display, screen->fnt_norm);
 +       props = get_font_name_props(screen->display, screen->fnt_norm, (char *)0);
         if (props == 0)
                return 0;
 
@@ -312,6 +314,25 @@
 #endif /* OPT_DEC_CHRSET */
 
 /*
+ * Case-independent comparison for font-names, including wildcards.
 + */
+static int
+same_font_name(char *name1, char *name2)
 +{
+       while (*name1 && *name2) {
 +               if (*name1 == '*') {
 +                       return same_font_name(name1+1, name2+1)
 +                          ||  same_font_name(name1, name2+1);
 +               } else if (*name2 == '*') {
 +                       return same_font_name(name2, name1);
 +               } else if (char2lower(*name1++) != char2lower(*name2++)) {
 +                       return 0;
 +               }
 +       }
+       return (*name1 == *name2);      /* both should be NUL */
 +}
+
+/*
  * Double-check the fontname that we asked for versus what the font server
  * actually gave us.  The larger fixed fonts do not always have a matching bold
  * font, and the font server may try to scale another font or otherwise
@@ -322,19 +343,17 @@
  * offset.
  */
 static int
-got_bold_font(Display *dpy, XFontStruct *fs, char *fontname)
 +got_bold_font(Display *dpy, XFontStruct *fs, char *requested)
  {
        FontNameProperties *fp;
-       char oldname[MAX_FONTNAME], *p = oldname;
 -       strcpy(p, fontname);
 -       if ((fp = get_font_name_props(dpy, fs)) == 0)
 -               return 0;
 -       fontname = bold_font_name(fp);
 -       while (*p && *fontname) {
 -               if (char2lower(*p++) != char2lower(*fontname++))
 -                       return 0;
 -       }
-       return (*p == *fontname);       /* both should be NUL */
 +       char actual[MAX_FONTNAME];
 +       int got;
 +
+       if ((fp = get_font_name_props(dpy, fs, actual)) == 0)
 +               got = 0;
 +       else
+               got = same_font_name(requested, actual);
 +       return got;
  }
 
 /*
@@ -380,6 +399,7 @@
        Pixel new_normal;
        Pixel new_revers;
        char *tmpname = NULL;
+       char normal[MAX_FONTNAME];
         Boolean proportional = False;
        int ch;
 
@@ -399,8 +419,9 @@
        if (EmptyFont(nfs))
                goto bad;               /* can't use a 0-sized font */
 
+       strcpy(normal, nfontname);
         if (bfontname == 0) {
-               fp = get_font_name_props(screen->display, nfs);
 +               fp = get_font_name_props(screen->display, nfs, normal);
                 if (fp != 0) {
                        bfontname = bold_font_name(fp);
                        TRACE(("...derived bold %s\n", bfontname))
@@ -511,7 +532,9 @@
        }
 #endif
 
-       screen->enbolden = (nfs == bfs);
 +       screen->enbolden = (nfs == bfs) || same_font_name(normal, bfontname);
 +       TRACE(("Will %suse 1-pixel offset/overstrike to simulate bold\n", screen->enbolden ? "" : "not "))
 +
        set_menu_font (False);
        screen->menu_font_number = fontnum;
        set_menu_font (True);
Index: main.c
--- xterm-95+/main.c    Sun Apr 11 16:38:14 1999
 +++ xterm-96/main.c     Sun Apr 18 21:27:30 1999
 @@ -69,8 +69,6 @@
  
 /* main.c */
 
-#define _GNU_SOURCE 1  /* needed to prototype getpt() with glibc 2.1 */
 -
 #include <version.h>
 #include <xterm.h>
 
@@ -156,11 +154,6 @@
 #define USE_HANDSHAKE
 #endif
 
-#if defined USE_USG_PTYS && (defined (__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1))
 -#define USE_GETPT
-#include <stdlib.h>
-#endif
-
 #if defined(SYSV) && !defined(SVR4) && !defined(ISC22) && !defined(ISC30)
 /* older SYSV systems cannot ignore SIGHUP.
    Shell hangs, or you get extra shells, or something like that */
@@ -184,6 +177,10 @@
 #define LASTLOG
 #define WTMP
 #undef  HAS_LTCHARS
+#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
 +#define USE_USG_PTYS 1
+#include <pty.h>
 +#endif
 #endif
 
 #ifdef __CYGWIN32__
@@ -564,7 +561,7 @@
 static struct ltchars d_ltc;
 #endif /* HAS_LTCHARS */
 
-#ifdef __sgi
+#if defined (__sgi) || (defined(__linux__) && defined(__sparc__))
  #undef TIOCLSET /* XXX why is this undef-ed again? */
 #endif
 
@@ -1888,7 +1885,7 @@
 static int
 get_pty (int *pty)
 {
-#ifdef __osf__
+#if defined(__osf__) || (defined(linux) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1)
      int tty;
     return (openpty(pty, &tty, ttydev, NULL, NULL));
 #elif defined(SYSV) && defined(i386) && !defined(SVR4)
@@ -1918,15 +1915,9 @@
         if (pty_search(pty) == 0)
            return 0;
 #elif defined(USE_USG_PTYS)
-#if defined USE_GETPT
-       if ((*pty = getpt ()) < 0) {
 -           return 1;
 -       }
-#else
         if ((*pty = open ("/dev/ptmx", O_RDWR)) < 0) {
            return 1;
        }
-#endif
 #if defined(SVR4) || defined(SCO325) || (defined(i386) && defined(SYSV))
        strcpy(ttydev, ptsname(*pty));
 #if defined (SYSV) && defined(i386) && !defined(SVR4)
@@ -2122,7 +2113,7 @@
 /* ARGSUSED */
 static SIGNAL_T hungtty(int i GCC_UNUSED)
 {
-       longjmp(env, 1);
 +       siglongjmp(env, 1);
         SIGNAL_RETURN;
 }
 
@@ -2307,7 +2298,7 @@
 
                signal(SIGALRM, hungtty);
                alarm(2);               /* alarm(1) might return too soon */
-               if (! setjmp(env)) {
 +               if (! sigsetjmp(env, 1)) {
                         tty = open ("/dev/tty", O_RDWR, 0);
                        alarm(0);
                        tty_got_hung = False;
@@ -2675,12 +2666,12 @@
 #endif
 #endif /* USE_SYSV_PGRP */
                while (1) {
-#ifdef TIOCNOTTY
+#if defined(TIOCNOTTY) && !(defined(linux) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1)
                         if (!no_dev_tty && (tty = open ("/dev/tty", O_RDWR)) >= 0) {
                                ioctl (tty, TIOCNOTTY, (char *) NULL);
                                close (tty);
                        }
-#endif /* TIOCNOTTY */
+#endif /* TIOCNOTTY && !linux*/
  #ifdef CSRG_BASED
                        (void)revoke(ttydev);
 #endif
@@ -3042,7 +3033,9 @@
                signal (SIGTERM, SIG_DFL);
 
 #if OPT_INITIAL_ERASE
-               if (! resource.ptyInitialErase) {
 +               if (! resource.ptyInitialErase
 +                && !override_tty_modes
 +                && !ttymodelist[XTTYMODE_erase].set) {
  #ifdef USE_SYSV_TERMIO
                        if(ioctl(tty, TCGETA, &tio) == -1)
                                tio = d_tio;
Index: ptyx.h
--- xterm-95+/ptyx.h    Sun Apr 11 16:38:14 1999
 +++ xterm-96/ptyx.h     Sun Apr 18 21:09:37 1999
 @@ -132,7 +132,7 @@
  #ifdef __hpux
 #define TTYDEV         "/dev/pty/ttyxx"
 #else  /* !__hpux */
-#ifdef __osf__
+#if defined(__osf__) || (defined(linux) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1)
  #define TTYDEV         "/dev/ttydirs/xxx/xxxxxxxxxxxxxx"
 #else
 #define        TTYDEV          "/dev/ttyxx"
Index: util.c
--- xterm-95+/util.c    Sun Apr 11 16:38:14 1999
 +++ xterm-96/util.c     Thu Apr 15 20:44:47 1999
 @@ -1560,7 +1560,7 @@
                                 x, y, x + len * FontWidth(screen) - 1, y);
                }
 #if OPT_BOX_CHARS
-#define DrawX(col) x + (col * FontWidth(screen))
 +#define DrawX(col) x + (col * (screen->fnt_wide))
  #define DrawSegment(first,last) (void)drawXtermText(screen, flags, gc, DrawX(first), y, chrset, PAIRED_CHARS(text+first, text2+first), last-first)
        } else {        /* fill in missing box-characters */
                XFontStruct *font = (flags & BOLD)
Index: version.h
--- xterm-95+/version.h Sun Apr 11 16:38:14 1999
 +++ xterm-96/version.h  Sun Apr 18 19:03:02 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   95
-#define XFREE86_VERSION "XFree86 3.9Ph"
 +#define XTERM_PATCH   96
+#define XFREE86_VERSION "XFree86 3.9Pj"
 Index: vttests/16colors.sh
--- xterm-95+/vttests/16colors.sh       Mon Mar 29 13:36:18 1999
 +++ xterm-96/vttests/16colors.sh        Thu Apr 15 06:43:47 1999
 @@ -7,7 +7,26 @@
  # The high (8-15) combinations for foreground or background are marked with
 # a '+' sign.
 
-trap 'echo -n "^[[0m"; exit' 0 1 2 5 15
 +ESC="^["
+CMD='echo'
+OPT='-n'
+SUF=''
+TMP=/tmp/xterm$$
+for verb in print printf ; do
 +    rm -f $TMP
+    eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
 +    if test -f $TMP ; then
 +       if test ! -s $TMP ; then
 +           CMD="$verb"
 +           OPT=
 +           SUF='\c'
 +           break
 +       fi
+    fi
 +done
+rm -f $TMP
+
+trap '$CMD "^[[0m"; exit' 0 1 2 5 15
  echo "^[[0m"
 while true
 do
@@ -38,8 +57,8 @@
                else
                    color="+$fcolor"
                fi
-               echo -n "^[[0;${AT}m$attr"
 -               echo -n "^[[${HI}${FG}m$color"
 +               $CMD $OPT "^[[0;${AT}m$attr"
 +               $CMD $OPT "^[[${HI}${FG}m$color"
                 for BG in 1 2 3 4 5 6 7
                do
                    case $BG in
@@ -52,8 +71,8 @@
                    6) bcolor="CYN ";;
                    7) bcolor="WHT ";;
                    esac
-                   echo -n "^[[4${BG}m$bcolor"
 -                   echo -n "^[[10${BG}m+$bcolor"
 +                   $CMD $OPT "^[[4${BG}m$bcolor"
 +                   $CMD $OPT "^[[10${BG}m+$bcolor"
                 done
                echo "^[[0m"
            done
Index: vttests/8colors.sh
--- xterm-95+/vttests/8colors.sh        Mon Mar 29 13:36:18 1999
 +++ xterm-96/vttests/8colors.sh Thu Apr 15 06:43:16 1999
 @@ -4,7 +4,26 @@
  # -- Thomas Dickey (1999/3/27)
 # Show a simple 8-color test pattern
 
-trap 'echo -n "^[[0m"; exit' 0 1 2 5 15
 +ESC="^["
+CMD='echo'
+OPT='-n'
+SUF=''
+TMP=/tmp/xterm$$
+for verb in print printf ; do
 +    rm -f $TMP
+    eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
 +    if test -f $TMP ; then
 +       if test ! -s $TMP ; then
 +           CMD="$verb"
 +           OPT=
 +           SUF='\c'
 +           break
 +       fi
+    fi
 +done
+rm -f $TMP
+
+trap '$CMD $OPT "^[[0m"; exit' 0 1 2 5 15
  echo "^[[0m"
 while true
 do
@@ -28,8 +47,8 @@
            6) fcolor="cyan    ";;
            7) fcolor="white   ";;
            esac
-           echo -n "^[[0;${AT}m$attr"
 -           echo -n "^[[3${FG}m$fcolor"
 +           $CMD $OPT "^[[0;${AT}m$attr"
 +           $CMD $OPT "^[[3${FG}m$fcolor"
             for BG in 1 2 3 4 5 6 7
            do
                case $BG in
@@ -42,7 +61,7 @@
                6) bcolor="cyan    ";;
                7) bcolor="white   ";;
                esac
-               echo -n "^[[4${BG}m$bcolor"
 +               $CMD $OPT "^[[4${BG}m$bcolor"
             done
            echo "^[[0m"
        done
Index: vttests/title.sh
--- xterm-95+/vttests/title.sh  Sun Apr 11 16:38:14 1999
 +++ xterm-96/vttests/title.sh   Thu Apr 15 17:38:07 1999
 @@ -34,7 +34,8 @@
  stty $old
 
 # We actually get this terminated by an <esc>backslash, but the backslash
-# is lost.  We'll also lose doublequote characters when restoring the title.
 +# is lost.  We may lose doublequote characters when restoring the title,
 +# depending on the shell.
 original=`echo "$original" |sed -e 's/^...//' -e 's/.$//'`
 original=${ESC}]2\;"${original}^G"${SUF}
 
Index: xterm.log.html
--- xterm-95+/xterm.log.html    Sun Apr 11 16:38:14 1999
 +++ xterm-96/xterm.log.html     Mon Apr 19 20:57:09 1999
 @@ -41,6 +41,7 @@
  xc/programs/Xserver/hw/xfree86).
 
 <UL>
+<LI><A HREF="#xterm_96">Patch #96 - 1999/4/19 - XFree86 3.9Pj</A>
  <LI><A HREF="#xterm_95">Patch #95 - 1999/4/5 - XFree86 3.9Ph</A>
 <LI><A HREF="#xterm_94">Patch #94 - 1999/3/27 - XFree86 3.9Pf</A>
 <LI><A HREF="#xterm_93">Patch #93 - 1999/3/14 - XFree86 3.9Pd</A>
@@ -138,6 +139,32 @@
 <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_96">Patch #96 - 1999/4/19 - XFree86 3.9Pj</A></H1>
 +<ul>
+       <li>modify Makefile.in to work with configure script's --srcdir option.
 +         (patch by Jeremy Buhler <jbuhler@cs.washington.edu>)
 +
+       <li>add checks for 'echo -n' equivalent for 8colors.sh and 16colors.sh
 +         scripts (reported by Vikas Agnihotri).
 +
+       <li>improve logic that looks for bold fonts to allow for wildcards
 +         in the specification for normal fonts, and to ensure that if
 +         a bold font is specified as normal, that xterm will simulate a
 +         bold version of that using a one-pixel offset overstrike
 +         (reported by Henrik Harmsen <harmsen@erv.ericsson.se>).
 +
+       <li>correct horizontal spacing of doublewidth line-drawing characters
 +         that xterm simulates.
 +
+       <li>improve support for Unix98 PTY's, using patch in Debian bug report
 +         #35650, by Topi Miettinen <Topi.Miettinen@medialab.sonera.fi>.
 +         Andreas Jaeger says this also corrects a permissions problem
 +         reported by cat@zip.net.au
 +
+       <li>modify initial-erase logic to ensure that <code>ttyModes</code>
 +         resource overrides it.
 +</ul>
 
 <H1><A NAME="xterm_95">Patch #95 - 1999/4/5 - XFree86 3.9Ph</A></H1>
 <ul>
Index: xterm.man
--- xterm-95+/xterm.man Sun Apr 11 16:38:14 1999
 +++ xterm-96/xterm.man  Mon Apr 19 19:31:44 1999
 @@ -2242,6 +2242,8 @@
  .br
 \fIXterm Control Sequences\fP
 (this is the file ctlseqs.ms).
+.sp
+http://www.clark.net/pub/dickey/xterm/xterm.html
 .SH BUGS
 .PP
 Large pastes do not work on some systems.  This is not a bug in