[comp.sys.amiga] Late breaking fixes to VT100 R2.7

acs@amdahl.amdahl.com (Tony Sumrall) (10/06/87)

I've fixed the BS<->DEL bug and DBW has verified it.  I tried to get this
to doc before he posted R2.7 but, alas, I was too late.  Included are
mode to README (I added some doc to the R2.6 section by accident).  There
should be a signature at the end of this thing.

*** README	Thu Oct  1 05:59:53 1987
--- README.old	Mon Oct  5 17:46:49 1987
***************
*** 41,51 ****
  	  file, +i file says use "file".  User may also specify script
  	  files on the command line which will be executed in sequence.
  	- New init file command SHORTCUT.  See vt100.doc.
- 	- I've included the font code.  It looks for an env variable named
- 	  "font" (yes, lowercase) and, if found, uses that font for its
- 	  test.  If you don't like it you may wanna remove it.  I was gonna
- 	  ifdef it but I ran out of time.  Remember that there's a PD set
- 	  cmd to allow Lattice users to set env vars.
  	- Nagging bug: On 2nd and subsequent uses of the requester, the
  	  1st character of the last use is redisplayed.  Intuition bug?
  v2.6 870227 DBW - bug fixes for all the stuff in v2.5
--- 41,46 ----
***************
*** 56,61 ****
--- 51,62 ----
  	- MAJOR CHANGE: re write the INPUT/SCRIPT commands, see VT100.DOC
  	- Fixed a major problem with Set Directory causing LOCK conflicts
  	- Moved the Title up 1 pixel so that it doesn't get cut off anymore
+ 	- I've included the font code.  It looks for an env variable named
+ 	  "font" (yes, lowercase) and, if found, uses that font for its
+ 	  test.  If you don't like it you may wanna remove it.  I was gonna
+ 	  ifdef it but I ran out of time.  Remember that there's a PD set
+ 	  cmd to allow Lattice users to set env vars.
+ 
  v2.5 870214 DBW - more additions (see readme file)
  	- All prompting now done through a string requester/gadget.
  	  NOTE: YOU MUST SELECT THE INPUT STRING OF THE REQUESTER BEFORE
*** script.c	Wed Sep 30 12:01:27 1987
--- script.old.c	Tue Sep 29 18:23:23 1987
***************
*** 753,764 ****
  char	*par;
  {
      setvar(par,0,&p_bs_del);
!     if (doing_init == 0)
! 	redoutil();	/* Calls InitUtilItems which does swap_bs_del() */
!     else {
!     	swap_bs_del();	/* Setup keys[] properly... */
!     	swap_bs_del();	/* ...for new mode	    */
!     }
  }
  
  void cmd_bkg(par)
--- 753,759 ----
  char	*par;
  {
      setvar(par,0,&p_bs_del);
!     if (doing_init == 0) redoutil();
  }
  
  void cmd_bkg(par)
*** init.c	Wed Sep 30 12:03:39 1987
--- init.old.c	Mon Oct  5 17:46:52 1987
***************
*** 523,530 ****
      if (p_keyapp == 0)	UtilItem[6].Flags |= CHECKED;
      if (p_curapp)	UtilItem[7].Flags |= CHECKED;
      if (p_bs_del)	UtilItem[8].Flags |= CHECKED;
-     swap_bs_del();	/* Setup keys[] properly... */
-     swap_bs_del();	/* ...for mode		    */
  }
  
  /****************************************************************/
--- 523,528 ----
-- 
Tony Sumrall acs@amdahl.com <=> amdahl!acs

[ Opinions expressed herein are the author's and should not be construed
  to reflect the views of Amdahl Corp. ]

davison@drivax.UUCP (Wayne Davison) (10/14/87)

Here's a few fixes for VT100 R2.7:

Firstly, the file-chopping code for XMODEM downloads is a little over-zealous.
The current code (which has been around for quite some time) will chop off ANY
pattern of nulls AND Ctrl-Z's.  This is particularly bad for .arc files, since
the last two characters before the padding are always a Ctrl-Z/null.  There is
also a problem with the xmodem send-padding.  It always uses nulls for padding
even when the last character of the file was a null.  This makes it impossible
to chop the file upon receipt, because there is no distinction between padding
and data.  While fixing these bugs, I noticed that the number of bytes to send
was decremented inside the retry loop, which will trash your file if you don't
have a perfectly clean send.  I also found that the chop algorithm will always
write at least 1 byte, when sometimes it shouldn't write any.

The following context diff fixes these problems.  The chopping algorithm chops
contiguous strings of nulls OR Ctrl-Zs (not a mixture), and will avoid writing
anything if we chopped them all (e.g. 128-bytes worth).  The sending algorithm
is optimized a bit and fixes the subtraction and padding bugs.  Enjoy!
--
 Wayne Davison					      ...amdahl!drivax!davison
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
	   Ziol soft ol of egrt.  Stz'l ltt oy ngx eqf rteohitk oz.
	       Oy ngx rg, hstqlt rkgh dt q fgzt zg stz dt afgv.


*** xmodem.c.orig	Wed Oct  7 17:11:05 1987
--- xmodem.c	Wed Oct  7 18:26:57 1987
***************
*** 287,295 ****
      if ((firstchar == EOT) && (errors < ERRORMAX))
  	{
  	sendchar(ACK);
! 	while (bufptr > 0 && (bufr[--bufptr] == 0x00 ||
! 			      bufr[bufptr]   == 0x1A)) ;
! 	write(fd, bufr, ++bufptr);
  	close(fd);
  	Do_XON();
  	ScrollInfoMsg(1);
--- 287,300 ----
      if ((firstchar == EOT) && (errors < ERRORMAX))
  	{
  	sendchar(ACK);
! 		/* use firstchar to remember the last char for chopping */
! 	if (bufptr && ((firstchar = bufr[--bufptr]) == 0 || firstchar == 0x1A))
! 	    {
! 	    while (bufptr && bufr[--bufptr] == firstchar)
! 		;
! 	    if (bufptr || bufr[0] != firstchar)	 /* check for null buffer */
! 		write(fd, bufr, ++bufptr);
! 	    }
  	close(fd);
  	Do_XON();
  	ScrollInfoMsg(1);
***************
*** 343,362 ****
  	    {
  	    attempts = 0;
  	    sprintf(scrstr2,"Sending block %4d",sectnum);
  	    do {
  		InfoMsgNoScroll(scrstr2);
  		sendchar(SOH);
  		sendchar(sectnum);
  		sendchar(~sectnum);
  		checksum = 0;
! 		size = SECSIZ <= bytes_to_send ? SECSIZ : bytes_to_send;
! 		bytes_to_send -= size;
! 		for (j = bufptr; j < (bufptr + SECSIZ); j++)
! 		if (j < (bufptr + size)) {
! 		    sendchar(bufr[j]);
  		    checksum += bufr[j];
  		    }
! 		else sendchar(0);
  		sendchar(checksum);
  		attempts++;
  		c = readchar();
--- 348,374 ----
  	    {
  	    attempts = 0;
  	    sprintf(scrstr2,"Sending block %4d",sectnum);
+ 	    size = SECSIZ <= bytes_to_send ? SECSIZ : bytes_to_send;
+ 	    bytes_to_send -= size;
  	    do {
  		InfoMsgNoScroll(scrstr2);
  		sendchar(SOH);
  		sendchar(sectnum);
  		sendchar(~sectnum);
  		checksum = 0;
! 		for (j = bufptr; j < bufptr + size; j++)
! 		    {
! 		    sendchar(bufr[j]);		/* send buffer data */
  		    checksum += bufr[j];
  		    }
! 		if( size < SECSIZ )		/* check if we need to pad */
! 		    {
! 		    c = bufr[j-1] ? 0 : 0x1A;	/* choose correct padding */
! 		    j = SECSIZ - size;
! 		    checksum += j * c;
! 		    while ( j-- )
! 			sendchar(c);		/* send padding */
! 		    }
  		sendchar(checksum);
  		attempts++;
  		c = readchar();