[unix-pc.sources] Patch #3 to Xmodem v3.6

egray@fthood.UUCP (02/01/89)

This is an *unoffical* patch to Steve Grandi's Xmodem v3.6.

Well, it seems that when I make a mistake, I make it in several places!
This patch will fix the "truncate error" bug that not only appeared
in Xmodem, but in Pcomm as well.

Emmet P. Gray				US Army, HQ III Corps & Fort Hood
...!uunet!uiucuxc!fthood!egray		Attn: AFZF-DE-ENV
					Directorate of Engineering & Housing
					Environmental Management Office
					Fort Hood, TX 76544-5057

------------------------------------------------------------------------------
*** old/receive.c	Wed Sep 14 12:32:08 1988
--- receive.c	Tue Jan 31 14:17:33 1989
***************
*** 555,559
  	FILE *fp, *tempfp;
  	register int num;
! 	char *tempfile, *mktemp(), buf[BUFSIZ];
  
  	if (!(fp = fopen(file, "r")))

--- 555,560 -----
  	FILE *fp, *tempfp;
  	register int num;
! 	char *s, tempfile[128], *strrchr(), *strcpy(), *strcat(), *mktemp();
! 	char buf[BUFSIZ];
  
  	if (!(fp = fopen(file, "r")))
***************
*** 566,570
  	 * links across different file systems aren't allowed).
  	 */
! 	tempfile = mktemp("trunXXXXXX");
  	if (!(tempfp = fopen(tempfile, "w"))) {
  		fclose(fp);

--- 567,578 -----
  	 * links across different file systems aren't allowed).
  	 */
! 	strcpy(tempfile, file);
! 	if (s = strrchr(tempfile, '/'))
! 		*++s = '\0';
! 	else
! 		strcpy(tempfile, "./");
! 	strcat(tempfile, "trunXXXXXX");
! 	mktemp(tempfile);
! 
  	if (!(tempfp = fopen(tempfile, "w"))) {
  		fclose(fp);
*** old/xmodem.h	Sat Jul 16 22:38:18 1988
--- xmodem.h	Tue Jan 31 14:44:12 1989
***************
*** 12,15
  #include <sys/time.h>
  #include <sgtty.h>
  #endif /* SYSV */
  #include <signal.h>

--- 12,16 -----
  #include <sys/time.h>
  #include <sgtty.h>
+ #define strrchr rindex
  #endif /* SYSV */
  #include <signal.h>