[comp.bugs.4bsd] pr can mis-print first char on page +FIX

jeff@voder.UUCP (Jeff Gilliam) (11/21/86)

Index:	bin/pr.c 4.3BSD

Description:
	If a file consists of more than BUFS characters (9000 on 4.3BSD),
	and the BUFS'th character begins a new page, that character will
	be mis-printed.
Repeat-By:
	The following script will tickle the bug on 4.3 (4.2 has a different
	BUFS and needs a different input file to demonstrate the problem).

	awk '\
	BEGIN	{ for (i=0; i<95; i++) \
			printf("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"); \
		for (i=0; i<73; i++) \
			printf("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"); \
		  printf("bbbbbb\n"); \
		} \
		{ if (1) exit; }' < /dev/null > /tmp/test$$
	pr /tmp/test$$ | sed -n '/Page 4/,$p'
	rm -f /tmp/test$$

Fix:

Index: pr.c
diff -c -r1.1 -r1.2
*** /tmp/,RCSt1018209	Fri Nov 21 01:27:41 1986
--- /tmp/,RCSt2018209	Fri Nov 21 01:27:42 1986
***************
*** 228,234 ****
  		if (mflg==0) {
  			colp[ncol]--;
  			if (colp[ncol] < buffer)
! 				colp[ncol] = &buffer[BUFS];
  		}
  		line = 0;
  		if (ntflg==0) {
--- 228,234 ----
  		if (mflg==0) {
  			colp[ncol]--;
  			if (colp[ncol] < buffer)
! 				colp[ncol] = &buffer[BUFS-1];
  		}
  		line = 0;
  		if (ntflg==0) {
-- 

Jeff Gilliam	{ucbvax,pyramid,nsc}!voder!jeff