[comp.windows.x] bug in X.V10R4 version of xterm

jb@cs.brown.EDU (Jim Bloom) (09/11/87)

Xterm has some problems on an Encore.  It seems to lose state whenever it
scrolls backwards (usually seen in editors).  After looking through the code
I discovered that ScrnInsertLine() assumes that it is safe to do a bcopy()
when the source and destination overlap.  In this case, dest = src + off.
If the trivial version of bcopy written in C is used, the bcopy yields
bogus results.  On most machines, a block move instruction is used.  The
VAX movc3 does this correctly, but other versions do not.

To fix this problem, I have modified the code to not assume anything about
overlapping data areas.

					Jim


*** screen.c.old	Thu Sep 10 17:17:08 1987
--- screen.c	Thu Sep 10 17:17:08 1987
***************
*** 95,106 ****
  	for (i = 2 * n - 1; i >= 0; i--)
  		bzero ((char *) save [i], size);
  
! 	/* move down lines */
! 	bcopy ((char *) &sb [2 * where], (char *) &sb [2 * (where + n)],
  		2 * sizeof (char *) * (last - where));
  
! 	/* reuse storage for new lines at where */
! 	bcopy ((char *)save, (char *) &sb[2 * where], 2 * sizeof(char *) * n);
  }
  
  
--- 95,107 ----
  	for (i = 2 * n - 1; i >= 0; i--)
  		bzero ((char *) save [i], size);
  
! 	/* Copy lines down into temporary storage */
! 	bcopy ((char *) &sb [2 * where], (char *) &save [2 * n],
  		2 * sizeof (char *) * (last - where));
  
! 	/* Copy everything back reusing saved storage */
! 	bcopy ((char *)save, (char *) &sb[2 * where],
! 		2 * sizeof (char *) * (n + last - where));
  }