[comp.sys.amiga] patch 1 for diff.c

jw@sics.se (Johan Widen) (03/13/88)

Here are some (relatively minor) fixes for the diff program that was recently
posted in comp.sources.amiga.

They fix:
	strange behaviour if you do not invoke diff with
		diff -c
	I consider this to be a minor bug as a non context diff is next to
	useless.

	More imortant: if you do a diff between an empty file and a non
	empty file, then the old version will output the diff but it will
	also output an error message, saying that it can't find the first line
	in the empty file.


*** diff.c.old	Sun Mar 13 10:26:07 1988
--- diff.c	Sat Mar  5 12:43:54 1988
***************
*** 1169,1180 ****
  	    range(bstart, bend, 1);	/* Print both, if different */
    }
    putchar('\n');
!   if (!eflag) {
    	fetch(oldseek, astart, aend, 0, 0, lenA, infd[0], "< ");
  	if (astart <= aend && bstart <= bend)
    	  printf("---\n");
    }
!   fetch(newseek, bstart, bend, 0, 0, lenB, infd[1], eflag ? "" : "> ");
    if (eflag && bstart <= bend)
    	printf(".\n");
  }
--- 1169,1181 ----
  	    range(bstart, bend, 1);	/* Print both, if different */
    }
    putchar('\n');
!   if (c != 'a') {
    	fetch(oldseek, astart, aend, 0, 0, lenA, infd[0], "< ");
  	if (astart <= aend && bstart <= bend)
    	  printf("---\n");
    }
!   if(c != 'd')
! 	fetch(newseek, bstart, bend, 0, 0, lenB, infd[1], eflag ? "" : "> ");
    if (eflag && bstart <= bend)
    	printf(".\n");
  }
***************
*** 1257,1262 ****
--- 1258,1265 ----
  	first = start;
  	last = end;
    }
+   if (first > last)
+ 	return;
    if (fseek(fd, seekvec[first], 0) != 0) {
    	printf("?Can't read line %d at %08lx (hex) in file%c\n",
    	  start, seekvec[first],
-- 
Johan Widen
SICS, PO Box 1263, S-164 28 KISTA, SWEDEN
Tel: +46 8 752 15 32	Ttx: 812 61 54 SICS S	Fax: +46 8 751 72 30
Internet: jw@sics.se or {mcvax,munnari,ukc,unido}!enea!sics.se!jw