🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.4bsd
Article #418

pr can mis-print first char on page +FIX

#418
From: Jeff Gilliam
Date: Fri, 21 Nov 1986 09:38
47 lines
1715 bytes
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
Technical Details
Message-ID: <2742@voder.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!lll-lcc!pyramid!voder!jeff

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!lll-lcc!pyramid!voder!jeff
From: jeff@voder.UUCP (Jeff Gilliam)
Newsgroups: comp.bugs.4bsd
Subject: pr can mis-print first char on page +FIX
Message-ID: <2742@voder.UUCP>
Date: Fri, 21-Nov-86 04:38:30 EST
Article-I.D.: voder.2742
Posted: Fri Nov 21 04:38:30 1986
Date-Received: Fri, 21-Nov-86 07:47:47 EST
Organization: National Semiconductor, Santa Clara
Lines: 47