[net.bugs.4bsd] bugs in addbib

hjpark@kaist.UUCP (HyeonJe Park) (05/07/84)

addbib has the another problem yet in spite of the fix of Mr. Plotnick.
And so, I post it with his changes.

-----------------------------------------------------------------------
Subject: /usr/bin/addbib
Index: /usr/src/usr.bin/refer/addbib.c in 4.2BSD

Description:
	After fgets(line,...) is called, and the content of "line" is used,
	it is not cleared, when we type contl-d.

Repeated-By:
	%addbib test
	Instructions? y
	Author: contl-d

	or
	%addbib test
	...
	Journal: kaist
	Volume: contl-d

	etc...

Fix:

8a9,12
> #define clrbuf(buf)		{ \
> 				register char *p = buf; \
> 				while (*p) *p++ = NULL; \
> 				}
104a109
> 			clrbuf(line);
106c111,112
< 			fgets(line, BUFSIZ, stdin);
---
> 			if (!fgets(line, BUFSIZ, stdin))
> 				goto last;
147a154
> 		last:
160a168
> 			clearerr(stdin);
170c178,179
< 			fgets(line, BUFSIZ, stdin);
---
> 			if (fgets(line, BUFSIZ, stdin) == NULL)
> 				return;	
177a187
> 		clrbuf(line);

	Park, Hyeon Je
	KAIST, Seoul, Korea
	(UUCP: ...!hplabs!kaist!hjpark)