xterm-99.patch.txt

XFree86 3.9Pk - xterm patch #99 - 1999/5/2 - T.Dickey <dickey@clark.net>
 
More bug fixes against recent changes (initial-erase and UTF-8 display).
If no new bugs surface, I will work on cut/paste for the UTF-8 configuration.
 
# ------------------------------------------------------------------------------
#  charproc.c     |   15 +++++-------
#  ctlseqs.ms     |    5 ++--
#  main.c         |    7 ++++-
#  ptydata.c      |   68 ++++++++++++++++++++++++++++++-------------------------
#  ptyx.h         |   12 ++++-----
#  screen.c       |    8 ++++--
#  util.c         |    2 -
#  version.h      |    2 -
#  xterm.log.html |   35 ++++++++++++++++++++++++++--
#  xterm.man      |   16 ++++++++++--
#  10 files changed, 112 insertions, 58 deletions
# ------------------------------------------------------------------------------
Index: charproc.c
--- xterm-98+/charproc.c        Mon Apr 26 18:40:33 1999
+++ xterm-99/charproc.c Sun May  2 19:54:39 1999
@@ -361,7 +361,6 @@
 #endif
 static  Boolean        defaultFALSE       = FALSE;
 static  Boolean        defaultTRUE        = TRUE;
-static  Boolean        defaultMAYBE       = MAYBE;
 static  int    defaultZERO        = 0;
 static  int    defaultIntBorder   = DEFBORDER;
 static  int    defaultSaveLines   = SAVELINES;
@@ -587,7 +586,7 @@
         XtRBoolean, (XtPointer) &defaultFALSE},
 {XtNbackarrowKey, XtCBackarrowKey, XtRBoolean, sizeof(Boolean),
         XtOffsetOf(XtermWidgetRec, screen.backarrow_key),
-        XtRBoolean, (XtPointer) &defaultMAYBE},
+        XtRBoolean, (XtPointer) &defaultTRUE},
 {XtNbellSuppressTime, XtCBellSuppressTime, XtRInt, sizeof(int),
         XtOffsetOf(XtermWidgetRec, screen.bellSuppressTime),
         XtRInt, (XtPointer) &defaultBellSuppressTime},
@@ -2623,8 +2622,8 @@
 
                        if (n >= limit) {
                                limit = (n + 1) * 2;
-                               lobyte = XtRealloc(lobyte, limit);
-                               hibyte = XtRealloc(hibyte, limit);
+                               lobyte = (Char *)XtRealloc(lobyte, limit);
+                               hibyte = (Char *)XtRealloc(hibyte, limit);
                        }
                        for (j = offset; j < offset+n; j++) {
                                k = j-offset;
@@ -4023,7 +4022,7 @@
    wnew->screen.font_doublesize = request->screen.font_doublesize;
 #endif
 
-   wnew->num_ptrs = 3; /* OFF_FLAGS, OFF_CHARS, OFF_ATTRS */
+   wnew->num_ptrs = (OFF_ATTRS+1); /* OFF_FLAGS, OFF_CHARS, OFF_ATTRS */
 #if OPT_ISO_COLORS
    wnew->screen.boldColors    = request->screen.boldColors;
    wnew->screen.colorAttrMode = request->screen.colorAttrMode;
@@ -4048,7 +4047,7 @@
    if (!color_ok)
        wnew->screen.colorMode = False;
 
-   wnew->num_ptrs += 1;
+   wnew->num_ptrs = (OFF_COLOR+1);
    wnew->sgr_foreground = -1;
 #endif /* OPT_ISO_COLORS */
 
@@ -4057,7 +4056,7 @@
 #endif
 
 #if OPT_DEC_CHRSET
-   wnew->num_ptrs += 1;
+   wnew->num_ptrs = (OFF_CSETS+1);
 #endif
 
 #if OPT_WIDE_CHARS
@@ -4068,7 +4067,7 @@
       TRACE(("initialized UTF-8 mode\n"));
    }
    if (wnew->screen.wide_chars != False)
-      wnew->num_ptrs += 1;
+      wnew->num_ptrs = (OFF_WIDEC+1);
 #endif
 
    wnew->screen.underline = request->screen.underline;
Index: ctlseqs.ms
--- xterm-98+/ctlseqs.ms        Sun Apr 11 16:38:14 1999
+++ xterm-99/ctlseqs.ms Wed Apr 28 06:14:51 1999
@@ -659,8 +659,9 @@
   \(-> \*1 (``VT220'')
 .br
 and \*(Pv is the firmware version (for \fIxterm\fP, this is the XFree86
-patch number, starting with 95), and \*(Pc indicates the ROM cartridge
-registration number (always zero).
+patch number, starting with 95).
+In a DEC terminal, \*(Pc indicates the ROM cartridge
+registration number and is always zero.
 .
 .IP \\*(Cs\\*(Pm\\*s\\*d
 Line Position Absolute  [row] (default = [1,column]) (VPA)
Index: main.c
--- xterm-98+/main.c    Mon Apr 26 18:33:51 1999
+++ xterm-99/main.c     Sun May  2 13:45:36 1999
@@ -738,7 +738,7 @@
 #ifndef USE_SYSV_UTMP
 static int tslot;
 #endif /* USE_SYSV_UTMP */
-static jmp_buf env;
+static sigjmp_buf env;
 
 char *ProgramName;
 
@@ -759,6 +759,7 @@
 #endif
 #if OPT_INITIAL_ERASE
     Boolean ptyInitialErase;   /* if true, use pty's sense of erase char */
+    Boolean backarrow_is_erase;        /* override backspace/delete */
 #endif
     Boolean wait_for_map;
     Boolean useInsertMode;
@@ -806,6 +807,8 @@
 #if OPT_INITIAL_ERASE
     {"ptyInitialErase", "PtyInitialErase", XtRBoolean, sizeof (Boolean),
        offset(ptyInitialErase), XtRString, "false"},
+    {"backarrowKeyIsErase", "BackarrowKeyIsErase", XtRBoolean, sizeof(Boolean),
+        offset(backarrow_is_erase), XtRBoolean, "false"},
 #endif
     {"waitForMap", "WaitForMap", XtRBoolean, sizeof (Boolean),
        offset(wait_for_map), XtRString, "false"},
@@ -2398,7 +2401,7 @@
                                initial_erase = sg.sg_erase;
 #endif /* USE_SYSV_TERMIO */
                        }
-                       if (term->screen.backarrow_key == MAYBE)
+                       if (resource.backarrow_is_erase)
                        if (initial_erase == 0177) {    /* see input.c */
                                term->keyboard.flags &= ~MODE_DECBKM;
                        }
Index: ptydata.c
--- xterm-98+/ptydata.c Sun Apr 25 19:24:39 1999
+++ xterm-99/ptydata.c  Sun May  2 19:07:04 1999
@@ -103,43 +103,51 @@
                for (i = 0; i < data->cnt; i++) {
                    unsigned c = data->buf[i];
                    /* Combine UTF-8 into Unicode */
-                   /* Incomplete characters silently ignored,
-                    * should probably be better represented by U+fffc
-                    * (replacement character).
-                    */
-                   if (c > 0x7f) {
-                       if (screen->utf_count > 0 && (c & 0xc0) == 0x80) {
-                               screen->utf_char <<= 6;
-                               screen->utf_char |= (c & 0x3f);
-                               screen->utf_count--;
-                               if (screen->utf_count == 0)
-                                   data->buf2[j++] = c = screen->utf_char;
+                   if (c < 0x80) {
+                       if (screen->utf_count > 0)
+                           data->buf2[j++] = 0xfffd;
+                       data->buf2[j++] = c;
+                       screen->utf_count = 0;
+                   } else if (c < 0xc0) {
+                       if (screen->utf_count < 1) {
+                           data->buf2[j++] = 0xfffd;
                        } else {
-                           if ((c & 0xe0) == 0xc0) {
-                               screen->utf_count = 1;
-                               screen->utf_char = (c & 0x1f);
-                           } else if ((c & 0xf0) == 0xe0) {
-                               screen->utf_count = 2;
-                               screen->utf_char = (c & 0x0f);
-                           } else if ((c & 0xf8) == 0xf0) {
-                               screen->utf_count = 3;
-                               screen->utf_char = (c & 0x07);
-                           } else if ((c & 0xfc) == 0xf8) {
-                               screen->utf_count = 4;
-                               screen->utf_char = (c & 0x03);
-                           } else if ((c & 0xfe) == 0xfc) {
-                               screen->utf_count = 5;
-                               screen->utf_char = (c & 0x01);
+                           if (screen->utf_char > 0x03ff) {
+                               /* value would be >0xffff */
+                               screen->utf_char = 0xfffd;
                            } else {
-                               screen->utf_count = 0;
+                             screen->utf_char <<= 6;
+                             screen->utf_char |= (c & 0x3f);
                            }
+                           screen->utf_count--;
+                           if (screen->utf_count == 0)
+                               data->buf2[j++] = c = screen->utf_char;
                        }
                    } else {
-                       data->buf2[j++] = c;
-                       screen->utf_count = 0;
+                       if (screen->utf_count > 0)
+                           data->buf2[j++] = 0xfffd;
+                       if (c < 0xe0) {
+                           screen->utf_count = 1;
+                           screen->utf_char = (c & 0x1f);
+                       } else if (c < 0xf0) {
+                           screen->utf_count = 2;
+                           screen->utf_char = (c & 0x0f);
+                       } else if (c < 0xf8) {
+                           screen->utf_count = 3;
+                           screen->utf_char = (c & 0x07);
+                       } else if (c < 0xfc) {
+                           screen->utf_count = 4;
+                           screen->utf_char = (c & 0x03);
+                       } else if (c < 0xfe) {
+                           screen->utf_count = 5;
+                           screen->utf_char = (c & 0x01);
+                       } else {
+                           data->buf2[j++] = 0xfffd;
+                           screen->utf_count = 0;
+                       }
                    }
                }
-               TRACE(("UTF8 count %d, char %04X input %d/%d bytes\n",
+               TRACE(("UTF-8 count %d, char %04X input %d/%d bytes\n",
                        screen->utf_count,
                        screen->utf_char,
                        data->cnt, j))
Index: ptyx.h
--- xterm-98+/ptyx.h    Mon Apr 26 18:31:27 1999
+++ xterm-99/ptyx.h     Sun May  2 13:42:35 1999
@@ -249,9 +249,6 @@
 #define        NBOX    5                       /* Number of Points in box      */
 #define        NPARAM  10                      /* Max. parameters              */
 
-#define MAYBE          2               /* not exactly True             */
-#define MAYBENOT       3               /* not exactly False            */
-
 typedef struct {
        unsigned char   a_type;
        unsigned char   a_pintro;
@@ -528,7 +525,7 @@
 #if OPT_ISO_COLORS || OPT_DEC_CHRSET || OPT_WIDE_CHARS
 #define MAX_PTRS term->num_ptrs
 #else
-#define MAX_PTRS 3
+#define MAX_PTRS (OFF_ATTRS+1)
 #endif
 
 #define BUF_HEAD 1
@@ -605,10 +602,11 @@
 
 /***====================================================================***/
 
+/* The order of ifdef's matches the logic for num_ptrs in VTInitialize */
 typedef enum {
        OFF_FLAGS = 0           /* BUF_HEAD */
-       , OFF_CHARS
-       , OFF_ATTRS
+       , OFF_CHARS = 1
+       , OFF_ATTRS = 2
 #if OPT_ISO_COLORS
        , OFF_COLOR
 #endif
@@ -1061,7 +1059,7 @@
 #if OPT_ISO_COLORS
     int         sgr_foreground;        /* current SGR foreground color */
 #endif
-#if OPT_ISO_COLORS || OPT_DEC_CHRSET
+#if OPT_ISO_COLORS || OPT_DEC_CHRSET || OPT_WIDE_CHARS
     int         num_ptrs;      /* number of pointers per row in 'ScrnBuf' */
 #endif
     unsigned   initflags;      /* initial mode flags           */
Index: screen.c
--- xterm-98+/screen.c  Mon Apr 26 20:56:09 1999
+++ xterm-99/screen.c   Sun May  2 19:40:55 1999
@@ -325,7 +325,7 @@
                if (str2 != 0
                 && (wc = SCRN_BUF_WIDEC(screen, screen->cur_row) + screen->cur_col) != 0) {
                        if (flags & INVISIBLE)
-                               memset(wc, ' ', length);
+                               memset(wc, 0, length);
                        else
                                memcpy(wc, str2, length);
                }
@@ -788,8 +788,12 @@
                   gc_changes |= (flags & (FG_COLOR|BG_COLOR));
                }
 
-               if(chars[col] == 0)
+               if(chars[col] == 0) {
+#if OPT_WIDE_CHARS
+                   if (widec == 0 || widec[col] == 0)
+#endif
                        chars[col] = ' ';
+               }
           }
 
           TRACE(("%s @%d, calling drawXtermText %d..%d:%s\n",
Index: util.c
--- xterm-98+/util.c    Sun Apr 25 21:24:19 1999
+++ xterm-99/util.c     Sun May  2 19:55:06 1999
@@ -1362,7 +1362,7 @@
                static unsigned dlen;
                if (dlen <= len) {
                        dlen = (len + 1) * 2;
-                       dbuf = XtRealloc(dbuf, dlen);
+                       dbuf = (Char *)XtRealloc(dbuf, dlen);
                        memset(dbuf, 0, dlen);
                }
                text2 = dbuf;
Index: version.h
--- xterm-98+/version.h Mon Apr 26 21:04:55 1999
+++ xterm-99/version.h  Wed Apr 28 05:58:56 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   98
+#define XTERM_PATCH   99
 #define XFREE86_VERSION "XFree86 3.9Pk"
Index: xterm.log.html
--- xterm-98+/xterm.log.html    Mon Apr 26 20:57:36 1999
+++ xterm-99/xterm.log.html     Sun May  2 19:44:12 1999
@@ -41,6 +41,7 @@
 xc/programs/Xserver/hw/xfree86).
 
 <UL>
+<LI><A HREF="#xterm_99">Patch #99 - 1999/5/2 - XFree86 3.9Pk</A>
 <LI><A HREF="#xterm_98">Patch #98 - 1999/4/26 - XFree86 3.9Pk</A>
 <LI><A HREF="#xterm_97">Patch #97 - 1999/4/25 - XFree86 3.9Pk</A>
 <LI><A HREF="#xterm_96">Patch #96 - 1999/4/19 - XFree86 3.9Pj</A>
@@ -142,6 +143,36 @@
 <LI><A HREF="#xterm_01">Patch #1 - 1996/1/6</A>
 </UL>
 
+<H1><A NAME="xterm_99">Patch #99 - 1999/5/2 - XFree86 3.9Pk</A></H1>
+<ul>
+       <li>correct logic that computes num_ptrs count of the number of indices
+         into the screen buffer.  This is the maximum of the colors and
+         character-set indices; was incorrect in patch #97.
+
+       <li>correct argument type for sigsetjmp, incidental change in patch
+         #96's Unix88 PTY patch (reported by Bram Moolenaar).
+
+       <li>correct description of secondary DA in ctlseqs.ms (reported by Bram
+         Moolenaar).
+
+       <li>decouple the backarrowKey and ptyInitialErase resources by
+         adding a new resource backarrowKeyIsErase, to accommodate people
+         using applications which have hardcoded tests for characters 8 and
+         127 rather than relying on the stty settings.
+
+       <li>modify the UTF-8 decoder so that all possible illegal UTF-8
+         sequences are properly represented by U+FFFD.  This should be very
+         helpful for developers of code that output UTF-8 strings for
+         debugging.  See the file utf-8-test.txt in
+         http://www.cl.cam.ac.uk/~mgk25/download/ucs-fonts.tar.gz for a
+         demonstration text that contains numerous illegal UTF-8 values. 
+         (patch by Markus Kuhn).
+
+       <li>correct a place in ScrnRefresh where I was filling the high byte of
+         a wide character with a space rather than a null (reported by Markus
+         Kuhn).
+</ul>
+
 <H1><A NAME="xterm_98">Patch #98 - 1999/4/26 - XFree86 3.9Pk</A></H1>
 <ul>
        <li>correct data manipulation in unparseputc(), broken for
@@ -191,8 +222,8 @@
          The more obvious -utf8 and +utf8 would conflict with xterm's
          -ut and +ut (utmp) options.
 
-         The utf8 changes were requested by Markus Kuhn
-         &lt;Markus.Kuhn@cl.cam.ac.uk&gt;.  This patch does not complete utf8
+         The UTF-8 changes were requested by Markus Kuhn
+         &lt;Markus.Kuhn@cl.cam.ac.uk&gt;.  This patch does not complete UTF-8
          implementation, but makes it usable, i.e., display and refresh work,
          and I am able to display the test cases which Markus provides.
          More work is needed to complete this feature:
Index: xterm.man
--- xterm-98+/xterm.man Sun Apr 25 21:25:53 1999
+++ xterm-99/xterm.man  Sun May  2 13:47:19 1999
@@ -336,10 +336,13 @@
 for function keys.
 .TP 8
 .B \-ie
-Turn on the \fBptyInitialErase\fP resource.
+Turn on the \fBptyInitialErase\fP resource, i.e.,
+use the pseudo-terminal's sense of the stty erase value.
 .TP 8
 .B +ie
-Turn off the \fBptyInitialErase\fP resource.
+Turn off the \fBptyInitialErase\fP resource, i.e.,
+set the stty erase value using the \fBkD\fP string from the termcap entry as
+a reference, if available.
 .TP 8
 .B \-im
 Turn on the \fBuseInsertMode\fP resource.
@@ -679,6 +682,12 @@
 The program understands all of the core X Toolkit resource names and
 classes as well as:
 .TP 8
+.B "backarrowKeyIsErase (\fPclass\fB BackarrowKeyIsErase)"
+Tie the VTxxx \fBbackarrowKey\fP and \fBptyInitialErase\fP resources
+together by setting the DECBKM state according to whether the initial value of
+stty erase is a backspace or delete character.
+The default is ``false'', which disables this feature.
+.TP 8
 .B "hpFunctionKeys (\fPclass\fB HpFunctionKeys)"
 Specifies whether or not HP Function Key escape codes should be generated for
 function keys instead of standard escape sequences.
@@ -692,7 +701,7 @@
 .TP 8
 .B "ptyInitialErase (\fPclass\fB PtyInitialErase)"
 If ``true'', \fIxterm\fP will use the pseudo-terminal's sense of the stty erase
-value to set the \fBbackarrowKey\fP resource toggle.
+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
 a reference, if available.
@@ -834,6 +843,7 @@
 Specifies whether the backarrow key transmits
 a backspace
 or delete character.
+This corresponds to the DECBKM control sequence.
 The default (backspace) is ``true.''
 Pressing the control key toggles this behavior.
 .TP 8