[comp.sources.bugs] Patch for uumailclean

jfh@rpp386.Dallas.TX.US (The Beach Bum) (10/22/88)

This patch corrects a problem where a 7 character system name would prevent
the work file from being found.  The troublesome while() loop was waiting
until after the terminating character had been copied to stop copying the
file name.

If the work file name was FILNAMELEN characters long, then copying
stopped after the last legitimate character was copied when `--n' went
to 0.  The while() has been re-written to stop *before* the seperating
character or after FILENAMELEN characters have been copied.  Since the
last character which was placed in d[] is legitimate, we don't go back
to the d[-1]'th element to terminate the string, we just go ahead and add
the '\0' to the end of the existing string.

*** orig/uumailclean.c
--- uumailclean.c
**************
*** 368,375
  	n = FILENAMELEN - 1;
  	do {
  		*d++ = *s;
! 	} while (*s != '\0' && *s != ' ' && *s++ != '\n' && --n);
! 	d[-1] = '\0';
  	DEBUG(5, "dfile set to %s\n", dfile);
  
  	if (fgets(buf, BUFSIZ, fp) == NULL) {
--- 368,375 -----
  	n = FILENAMELEN - 1;
  	do {
  		*d++ = *s;
! 	} while (*++s != '\0' && *s != ' ' && *s != '\n' && --n);
! 	*d = '\0';
  	DEBUG(5, "dfile set to %s\n", dfile);
  
  	if (fgets(buf, BUFSIZ, fp) == NULL) {
**************
*** 385,392
  	n = FILENAMELEN - 1;
  	do {
  		*d++ = *s;
! 	} while (*s != '\0' && *s != ' ' && *s++ != '\n' && --n);
! 	d[-1] = '\0';
  	DEBUG(5, "xfile set to %s\n", xfile);
  
  	fclose(fp);
--- 385,392 -----
  	n = FILENAMELEN - 1;
  	do {
  		*d++ = *s;
! 	} while (*++s != '\0' && *s != ' ' && *s != '\n' && --n);
! 	*d = '\0';
  	DEBUG(5, "xfile set to %s\n", xfile);
  
  	fclose(fp);
-- 
John F. Haugh II                        +----Make believe quote of the week----
VoiceNet: (214) 250-3311   Data: -6272  | Nancy Reagan on Richard Stallman:
InterNet: jfh@rpp386.Dallas.TX.US       |          "Just say `Gno'"
UucpNet : <backbone>!killer!rpp386!jfh  +--------------------------------------