[news.software.b] Bug fix on batched news feeds

marka@natmlab.UUCP (03/24/87)

	The latest patch contained a bug where if rnews is feed batched
	news via a pipe it would fail. The following is an unofficial
	patch. I suggest that if you feed a site batched news you send
	this through by hand (i.e. unbatched). Keep this patch so it can
	be removed when an official patch comes.

*** ifuncs.c	Tue Mar 24 08:49:19 1987
--- ifuncs.c.sav	Mon Mar 23 17:21:11 1987
***************
*** 1070,1076
  		cmd[0] = c;
  		fgets(cmd + 1, BUFLEN, infp);
  		if (strncmp(cmd, "#! cunbatch", 11) == 0) {
! 			reset_infp(cmd);
  			i = strlen(cmd);
  			(void) lseek(0, (long) i, 0);	/* position STDIN for
  							 * exec */

--- 1070,1076 -----
  		cmd[0] = c;
  		fgets(cmd + 1, BUFLEN, infp);
  		if (strncmp(cmd, "#! cunbatch", 11) == 0) {
! 			reset_infp();
  			i = strlen(cmd);
  			(void) lseek(0, (long) i, 0);	/* position STDIN for
  							 * exec */
***************
*** 1078,1084
  			input_pipe(cmd, "compress", "-d", (char *) 0);
  			continue;	/* look for the #! rnews */
  		} else if (strncmp(cmd, "#! c7unbatch", 12) == 0) {
! 			reset_infp(cmd);
  			i = strlen(cmd);
  			(void) lseek(0, (long) i, 0);	/* position STDIN for
  							 * exec */

--- 1078,1084 -----
  			input_pipe(cmd, "compress", "-d", (char *) 0);
  			continue;	/* look for the #! rnews */
  		} else if (strncmp(cmd, "#! c7unbatch", 12) == 0) {
! 			reset_infp();
  			i = strlen(cmd);
  			(void) lseek(0, (long) i, 0);	/* position STDIN for
  							 * exec */
***************
*** 1209,1215
  			exit(0);/* all done */
  
  		} else {
! 			reset_infp(cmd);
  			i = strlen(cmd);
  			(void) lseek(0, (long)i, 0);
  			docmd(cmd);

--- 1209,1215 -----
  			exit(0);/* all done */
  
  		} else {
! 			reset_infp();
  			i = strlen(cmd);
  			(void) lseek(0, (long)i, 0);
  			docmd(cmd);
***************
*** 1330,1337
   * beginning.  We want the real file descriptor (beyond buffers) to
   * reflect the true beginning.  Do whatever is necessary.
   */
! reset_infp(cmd)
! char *cmd;
  {
  	register FILE *ofd;
  	register int c;

--- 1330,1336 -----
   * beginning.  We want the real file descriptor (beyond buffers) to
   * reflect the true beginning.  Do whatever is necessary.
   */
! reset_infp()
  {
  	register FILE *ofd;
  	register int c;
***************
*** 1345,1352
  	ofdname = "/tmp/inewsXXXXXX";
  	(void) mktemp(ofdname);
  	ofd = fopen(ofdname, "w");
- 	while ( c = *cmd++ ) /* put command line back so seek will line up */
- 		putc(c, ofd);
  	while ((c=getc(infp)) != EOF)
  		putc(c, ofd);
  	if (ferror(ofd))

--- 1344,1349 -----
  	ofdname = "/tmp/inewsXXXXXX";
  	(void) mktemp(ofdname);
  	ofd = fopen(ofdname, "w");
  	while ((c=getc(infp)) != EOF)
  		putc(c, ofd);
  	if (ferror(ofd))
D