[net.bugs] how to unscrew yourself

mp@whuxle.UUCP (Mark Plotnick) (05/29/84)

This supercedes the bug fix posted yesterday.

The code for the 'N' command zeroes fp, the file pointer to the current
article.  If you try to go to a nonexistent newsgroup, it'll print out
an error message and return to the command loop.  If you type ' ' (or
any other command that requests more of the current article to be
displayed), it'll try to read in another chunk of the current article.
appfile() will die (on a vax, you'll get a bus error) because iop
(which is fp) is NULL.

Readnews doesn't have this problem because showtail() checks to see if
fp is NULL.  If it is, the program  won't try to display the article,
BUT will still mark it as having been read!

Here are suggested fixes to visual.c and readr.c.  They simply make
sure that obit == -1 (and therefore that, if an invalid newsgroup is
entered, getnextart will re-read the article back in).  The fix I
posted yesterday only checked that fp==NULL and tried to simulate an A
command to read the article back in.   This was an insufficient test
because apparently fp is ALWAYS NULL after the call to next_ng_command,
even if the command was successful and the newsgroup was changed.  This
problem only showed up if you N'ed to a valid newsgroup that had fewer
articles than the number of the previous article in the previous
newsgroup.  Thanks to Andy for promptly pointing this out.

I should have noticed the real problem in the first place.  obit was
being set to -1 in next_ng_command, except in one case - when an
invalid newsgroup was asked for - and this was the case that was giving
Andy coredumps!

Suggestions to those who are thinking about re-writing the netnews code:
-  next_ng_command should return THREE different values rather than two:
   one to signify that the newsgroup change was successful, one to indicate
   that it wasn't (thus the old article should be redisplayed), and one to
   indicate that there aren't any more newsgroups to be jumped to.

-  more generally, ask MRH to put you on the netnews designers mailing list
   so that we can redesign this marvelous piece of software before it becomes
   another uucp.

*** visual.c.1.5	Mon May 28 15:35:25 1984
--- visual.c	Mon May 28 17:36:18 1984
***************
*** 654,659
  			fclose(fp);
  			fp = NULL;
  		}
  		if (next_ng_command())
  			quitflg = 1;
  		break;

--- 654,660 -----
  			fclose(fp);
  			fp = NULL;
  		}
+ 		obit = -1;
  		if (next_ng_command())
  			quitflg = 1;
  		break;
***************
*** 1318,1324
  	register int c;
  	register char *icol;	/* &linebuf[0] <= icol <= maxcol */
  
! 	if (artread || artlines >= nlines)
  		return;
  	maxcol = linebuf;
  	icol = linebuf;

--- 1319,1325 -----
  	register int c;
  	register char *icol;	/* &linebuf[0] <= icol <= maxcol */
  
! 	if (artread || artlines >= nlines || iop==NULL)
  		return;
  	maxcol = linebuf;
  	icol = linebuf;




*** readr.c.1.5	Mon May 28 16:04:20 1984
--- readr.c	Mon May 28 17:47:58 1984
***************
*** 421,426
  			fclose(fp);
  			fp = NULL;
  		}
  		if (next_ng_command())
  			return TRUE;
  		break;

--- 421,437 -----
  			fclose(fp);
  			fp = NULL;
  		}
+ #ifdef MIT
+ 		/* mp, 5/84: make sure we re-open the article.  next_ng_command
+ 		   will always set obit to -1, except when a non-
+ 		   existent group name is given.  This is a glitch, since if
+ 		   bit==obit, getnextart won't re-open the article and fp will
+ 		   STILL be NULL.  So we set obit to -1, as in the U command,
+ 		   to ensure that getnextart always re-opens an article.
+ 		   Actually, this statement should probably be placed at the
+ 		   top of next_ng_command. */
+ 		obit = -1;
+ #endif
  		if (next_ng_command())
  			return TRUE;
  		break;