Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!beta!hc!ames!amdahl!drivax!davison From: davison@drivax.UUCP (Wayne Davison) Newsgroups: comp.sys.amiga Subject: Re: Late breaking fixes to VT100 R2.7 Message-ID: <2590@drivax.UUCP> Date: Wed, 14-Oct-87 14:11:31 EDT Article-I.D.: drivax.2590 Posted: Wed Oct 14 14:11:31 1987 Date-Received: Sat, 17-Oct-87 19:39:43 EDT References: <15638@amdahl.amdahl.com> Reply-To: davison@drivax.UUCP (Wayne Davison) Organization: Digital Research, Inc. Lines: 103 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();