*CORRECTION* MicroEMACS 3.9e standout bugs (fix)

*CORRECTION* MicroEMACS 3.9e standout bugs (fix)

Post by George M. Si » Sun, 02 Dec 1990 14:33:00



(This patch is a repost WITH CORRECTION.  The standout patches which I
recently posted for MicroEMACS 3.9e contained an error for display.c.
This was traced to the conversion of the patches from 3.8l.  The patch
program made a patch with 'fuzz factor 2' which I missed and as luck
would have it the patch went into the wrong place.  That incorrectly
patched file was then used as the basis for the last posting.  Below is
a full reposting of the corrected patches.  If this is the first time
you are applying the standout patches, you can simply invoke patch:
'patch <thisfile'.  For those people who do not have the original
source files, I have also enclosed a shar file which will fix the
problem in an already patched display.c.  To use it, delete everything
above the 'cut here' line below, unshar it:  'sh <thatfile' then run it
thru patch:  'patch display.c display.c_fix'.  Sorry for the confusion.)

The recently posted version of MicroEMACS (3.9e) does not include the
standout patches required for terminals with embedded attributes (which
require a display position for standout begin/end - e.g. most TVI, LSI,
Qume, etc. terminals and compatible).  If FIXSG is set (defined as set
when TERMCAP is set), then for terminal entries which have non-zero
'sg' attributes defined, the mode lines will be properly managed.

I have re-integrated the patch previously posted for releases 3.8i and
3.8l for the 3.9e release.  Daniel Lawrence, MicroEMACS author, promises
that this patch will be included in future versions of MicroEMACS.

I have tested the patch on a variety of terminals without any
problems.  No problems were reported from the use of this patch in the
previous releases.  The patch in context diff format appears below.

George M. Sipe,         Phone: (404) 662-1533
Tolerant Systems, 6961 Peachtree Industrial, Norcross, GA  30071
UUCP: ...!{decvax,hplabs,ihnp4,linus,rutgers,seismo}!gatech!rebel!george

*** display.c_orig      Wed Nov 25 12:24:49 1987
--- display.c   Wed Dec  2 12:34:57 1987
***************
*** 623,628
        register int nbflag;    /* non-blanks to the right flag? */
        int rev;                /* reverse video flag */
        int req;                /* reverse video request flag */

        /* set up pointers to virtual and physical lines */

--- 623,631 -----
        register int nbflag;    /* non-blanks to the right flag? */
        int rev;                /* reverse video flag */
        int req;                /* reverse video request flag */
+ #if   TERMCAP & FIXSG & REVSTA
+       int sook;               /* standout ok flag */
+ #endif

        /* set up pointers to virtual and physical lines */
***************
*** 655,661

                /* scan through the line and dump it to the screen and
                   the virtual screen array                             */
!               cp3 = &vp1->v_text[term.t_ncol];
                while (cp1 < cp3) {
                        TTputc(*cp1);
                        ++ttcol;

--- 658,672 -----

                /* scan through the line and dump it to the screen and
                   the virtual screen array                             */
! #if   TERMCAP & FIXSG & REVSTA
!               if (req && SG > 0) {         /* Skip over 'spaces' */
!                   ttcol += SG;
!                   cp1 += SG;
!                   cp2 += SG;
!                   cp3 = &vp1->v_text[term.t_ncol-SG];
!               } else
! #endif
!                       cp3 = &vp1->v_text[term.t_ncol];
                while (cp1 < cp3) {
                        TTputc(*cp1);
                        ++ttcol;
***************
*** 702,707
        cp3 = &vp1->v_text[term.t_ncol];
        cp4 = &vp2->v_text[term.t_ncol];

        while (cp3[-1] == cp4[-1]) {
                --cp3;
                --cp4;

--- 713,725 -----
        cp3 = &vp1->v_text[term.t_ncol];
        cp4 = &vp2->v_text[term.t_ncol];

+ #if   TERMCAP & FIXSG & REVSTA
+       if (req && SG > 0)                   /* Adjust for 'spaces' */
+           sook = (cp1 - &vp1->v_text[0]) > 0;
+       else
+           sook = FALSE;
+ #endif
+
        while (cp3[-1] == cp4[-1]) {
                --cp3;
                --cp4;
***************
*** 722,727

        movecursor(row, cp1 - &vp1->v_text[0]);  /* Go to start of line. */
  #if   REVSTA
        TTrev(rev);
  #endif

--- 740,748 -----

        movecursor(row, cp1 - &vp1->v_text[0]);  /* Go to start of line. */
  #if   REVSTA
+ #if   TERMCAP & FIXSG
+       if (!sook) TTrev(rev);
+ #else
        TTrev(rev);
  #endif
  #endif
***************
*** 724,729
  #if   REVSTA
        TTrev(rev);
  #endif

        while (cp1 != cp5) {            /* Ordinary. */
                TTputc(*cp1);

--- 745,751 -----
  #else
        TTrev(rev);
  #endif
+ #endif

        while (cp1 != cp5) {            /* Ordinary. */
                TTputc(*cp1);
***************
*** 737,742
                        *cp2++ = *cp1++;
        }
  #if   REVSTA
        TTrev(FALSE);
  #endif
        vp1->v_flag &= ~VFCHG;           /* flag this line as updated */

--- 759,767 -----
                        *cp2++ = *cp1++;
        }
  #if   REVSTA
+ #if   TERMCAP & FIXSG
+       if (!sook) TTrev(FALSE);
+ #else
        TTrev(FALSE);
  #endif
  #endif
***************
*** 739,744
  #if   REVSTA
        TTrev(FALSE);
  #endif
        vp1->v_flag &= ~VFCHG;           /* flag this line as updated */
        return(TRUE);
  #endif

--- 764,770 -----
  #else
        TTrev(FALSE);
  #endif
+ #endif
        vp1->v_flag &= ~VFCHG;           /* flag this line as updated */
        return(TRUE);
  #endif
***************
*** 780,785
  #endif
                lchar = '-';

      bp = wp->w_bufp;
      if ((bp->b_flag&BFTRUNC) != 0)
        vtputc('#');

--- 806,815 -----
  #endif
                lchar = '-';

+ #if   TERMCAP & FIXSG & REVSTA
+     if (revexist && SG > 0)                        /* Initial spaces. */
+       for (i = 0; i < SG; ++i) vtputc(' ');
+ #endif
      bp = wp->w_bufp;
      if ((bp->b_flag&BFTRUNC) != 0)
        vtputc('#');
***************
*** 870,875
          ++n;
          }

      while (n < term.t_ncol)             /* Pad to full width. */
          {
          vtputc(lchar);

--- 900,909 -----
          ++n;
          }

+ #if   TERMCAP & FIXSG & REVSTA
+     if (revexist && SG > 0)                /* Adjust for standouts. */
+       n += SG * 3;
+ #endif
      while (n < term.t_ncol)             /* Pad to full width. */
          {
          vtputc(lchar);
***************
*** 875,880
          vtputc(lchar);
          ++n;
          }
  }

  upmode()      /* update all the mode lines */

--- 909,923 -----
          vtputc(lchar);
          ++n;
          }
+ #if   TERMCAP & FIXSG & REVSTA
+ /* The 'so' position will show as a reverse space, while the 'se'
+    position will be a normal space.  To balance the (visible)
+    reverse spaces at each end of the mode line, twice as many
+    spaces must exist at the end than do at the beginning.
+ */
+     if (revexist && SG > 0)                /* Trailing spaces. */
+       for (i = 0; i < SG * 2; ++i) vtputc(' ');
+ #endif
  }

  upmode()      /* update all the mode lines */
*** edef.h_orig Wed Nov 25 15:12:52 1987
--- edef.h      Wed Nov 25 15:12:51 1987
***************
*** 125,130
  char  tap[NPAT];                      /* Reversed pattern array.      */
  char  rpat[NPAT];                     /* replacement pattern          */

  /* The variable matchlen holds the length of the matched
   * string - used by the replace functions.
   * The variable patmatch holds the string that satisfies

--- 125,134 -----
  char  tap[NPAT];                      /* Reversed pattern array.      */
  char  rpat[NPAT];                     /* replacement pattern          */

+ #if   FIXSG & REVSTA
+ int   SG;                             /* number of standout glitches  */
+ #endif
+
  /* The variable matchlen holds the length of the matched
   * string - used by the replace functions.
   * The variable patmatch holds the string that satisfies
***************
*** 263,268
  extern        char    pat[];                  /* Search pattern               */
  extern        char    tap[];                  /* Reversed pattern array.      */
  extern        char    rpat[];                 /* replacement pattern          */

  extern unsigned int matchlen;
  extern unsigned int mlenold;

--- 267,276 -----
  extern        char    pat[];                  /* Search pattern               */
  extern        char    tap[];                  /* Reversed pattern array.      */
  extern        char    rpat[];                 /* replacement pattern          */
+
+ #if   FIXSG & REVSTA
+ extern        int     SG;                     /* number of standout glitches  */
+ #endif

  extern unsigned int matchlen;
  extern unsigned int mlenold;
*** estruct.h_orig      Wed Nov 25 15:12:21 1987
--- estruct.h   Wed Nov 25 15:12:19 1987
***************
*** 74,79
  #define VT52    0                       /* VT52 terminal (Zenith).      */
  #define RAINBOW 0                       /* Use Rainbow fast video.      */
  #define TERMCAP 0                       /* Use TERMCAP                  */
  #define       IBMPC   1                       /* IBM-PC CGA/MONO/EGA driver   */
  #define       DG10    0                       /* Data General system/10       */
  #define       TIPC    0                       /* TI Profesional PC driver     */

--- 79,85 -----
  #define VT52    0                       /* VT52 terminal (Zenith).      */
  #define RAINBOW 0                       /* Use Rainbow fast video.      */
  #define TERMCAP 0                       /* Use TERMCAP                  */
+ #define       FIXSG   TERMCAP                 /* Fix stand-out glitch         */
  #define       IBMPC   1                       /* IBM-PC CGA/MONO/EGA driver   */
  #define       DG10    0                       /* Data General system/10       */
  #define       TIPC    0                       /* TI Profesional PC driver     */
*** tcap.c_orig Wed Nov 25 15:12:54 1987
--- tcap.c      Wed Nov 25 15:12:53 1987
***************
*** 117,122
        SO = tgetstr("so", &p);
        if (SO != NULL)
                revexist = TRUE;

          if(CL == NULL || CM == NULL || UP == NULL)
          {

--- 117,125 -----
        SO = tgetstr("so", &p);
        if (SO != NULL)
                revexist = TRUE;
+ #if   FIXSG & REVSTA
+       SG = tgetnum("sg");   /* standout glitch      */
+ #endif

          if(CL == NULL || CM == NULL || UP == NULL)
          {
***************
*** 167,173
  int state;            /* FALSE = normal video, TRUE = reverse video */

  {
!       static int revstate = FALSE;
        if (state) {
                if (SO != NULL)
                        putpad(SO);

--- 170,178 -----
  int state;            /* FALSE = normal video, TRUE = reverse video */

  {
!       static int oldstate = TRUE + TRUE;
!       if (state == oldstate) return;
!       oldstate = state;
        if (state) {
                if (SO != NULL)
                        putpad(SO);

---------------------cut here-------------CUT HERE--------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#       display.c_fix
# This archive created: Wed Dec  2 13:09:43 1987
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'display.c_fix'
then
        echo shar: "will not over-write existing file 'display.c_fix'"
else
sed 's/^X//' << \SHAR_EOF > 'display.c_fix'
XNotice:  This patch is for those people who have already patched display.c
Xwith the previously posted standout patch which contains an error.  The
Xpurpose of this patch is to correct that error.  YOU SHOULD NOT APPLY THIS
XPATCH IF YOU DID NOT APPLY THE PREVIOUS ONE.  IF YOU RETAINED THE ORIGINAL
XSOURCE TO display.c THEN YOU SHOULD NOT NEED THIS PATCH AT ALL.
X
X*** display.c_bad      Wed Dec  2 13:05:17 1987
X--- display.c  Wed Dec  2 13:06:20 1987
X***************
X*** 806,811
X  #endif
X               lchar = '-';
X  
X      bp = wp->w_bufp;
X      if ((bp->b_flag&BFTRUNC) != 0)
X       vtputc('#');
X
X--- 806,815 -----
X  #endif
X               lchar = '-';
X  
X+ #if  TERMCAP & FIXSG & REVSTA
X+     if (revexist && SG > 0)                       /* Initial spaces. */
X+      for (i = 0; i < SG; ++i) vtputc(' ');
X+ #endif
X      bp = wp->w_bufp;
X      if ((bp->b_flag&BFTRUNC) != 0)
X       vtputc('#');
X***************
X*** 855,864
X      n += 8;
X  #endif
X  
X- #if  TERMCAP & FIXSG & REVSTA
X-     if (revexist && SG > 0)                       /* Initial spaces. */
X-      for (i = 0; i < SG; ++i) vtputc(' ');
X- #endif
X      vtputc(lchar);
X      vtputc(lchar);
X      vtputc(' ');
X
X--- 859,864 -----
X      n += 8;
X  #endif
X  
X      vtputc(lchar);
X      vtputc(lchar);
X      vtputc(' ');
SHAR_EOF
fi
exit 0
#       End of shell archive
--
George M. Sipe,         Phone: (404) 662-1533
Tolerant Systems, 6961 Peachtree Industrial, Norcross, GA  30071
UUCP: ...!{decvax,hplabs,ihnp4,linus,rutgers,seismo}!gatech!rebel!george